If you want to help us maintaining this wiki, check out our discord server: https://discord.gg/3u69jMa 

Difference between revisions of "Writing Native Code"

From SWRC Wiki
Jump to navigation Jump to search
(Created page with "==Resources== Media:Headers.zip Unreal Tournament headers modified to be as compatible as possible with RC. Media:Debug.zip Native coding example that implements th...")
 
Line 14: Line 14:
==Code==
==Code==
This code assumes that the folders with the headers for Core and Engine are in the same directory as the source file
This code assumes that the folders with the headers for Core and Engine are in the same directory as the source file
<source lang="cpp" line">
<source lang="cpp" line">
//Linking the import libraries for Core.dll and Engine.dll so that functions from these libraries can be called
//Linking the import libraries for Core.dll and Engine.dll so that functions from these libraries can be called

Revision as of 19:56, 14 January 2018

Resources

Media:Headers.zip

Unreal Tournament headers modified to be as compatible as possible with RC.

Media:Debug.zip

Native coding example that implements the game's main loop and adds useful features like a framerate cap that can be set using a new custom console command ("SetRefreshrate") and error handling using Message boxes that show the stack trace in case of a crash. Also have a look at Republic Commando UCC

Introduction

Getting Started

Code

This code assumes that the folders with the headers for Core and Engine are in the same directory as the source file

//Linking the import libraries for Core.dll and Engine.dll so that functions from these libraries can be called
#pragma comment(lib, "Core/lib/Core.lib")
#pragma comment(lib, "Engine/lib/Engine.lib")

//Includes the headers for core and engine
#include "Engine/Inc/Engine.h"

//This function is going to replace appInit from UnFile.h and thus needs to have the same signature
__declspec(dllexport) void testFunc(const char* InPackage, const char* InCmdLine, FOutputDevice* InLog, FOutputDeviceError* InError,
                                    FFeedbackContext* InWarn, FConfigCache*(*ConfigFactory)(), int RequireConfig){
    const char* newCmdLine = "-windowed -log abcdefg 12345";

    InLog->Logf("Replacing command line with %s", newCmdLine);

    appInit(InPackage, newCmdLine, InLog, InError, InWarn, ConfigFactory, RequireConfig);
}

Making The Game Call Custom Code

IIDKing.PNG

Olly1.PNG

Olly2.PNG

Result.PNG