Browse Source
Implemented minimum system functionality to initialize Quake from inside a DLL
console
Implemented minimum system functionality to initialize Quake from inside a DLL
console
6 changed files with 88 additions and 47 deletions
-
8engine/code/sys_win.c
-
78engine/projects/uniquake/uniquake.c
-
22engine/projects/uniquake/uniquake.cpp
-
16engine/projects/uniquake/uniquake.h
-
5engine/projects/uniquake/uniquake.vcxproj
-
6engine/projects/uniquake/uniquake.vcxproj.filters
@ -0,0 +1,78 @@ |
|||||
|
// uniquake.cpp : Defines the exported functions for the DLL. |
||||
|
// |
||||
|
|
||||
|
#include "pch.h" |
||||
|
#include "framework.h" |
||||
|
#include "uniquake.h" |
||||
|
|
||||
|
#include "../../code/quakedef.h" |
||||
|
|
||||
|
typedef struct unity_callbacks_s |
||||
|
{ |
||||
|
void(__stdcall *DebugLog)(const char *msg); |
||||
|
void(__stdcall *DebugLogError)(const char *msg); |
||||
|
void(__stdcall *ApplicationQuit)(int exitCode); |
||||
|
double(__stdcall *RealtimeSinceStartup)(); |
||||
|
} unity_callbacks_t; |
||||
|
|
||||
|
const unity_callbacks_t *unity_callbacks; |
||||
|
|
||||
|
void Sys_Error(char *error, ...) |
||||
|
{ |
||||
|
va_list argptr; |
||||
|
char text[1024]; |
||||
|
|
||||
|
va_start(argptr, error); |
||||
|
vsprintf(text, error, argptr); |
||||
|
va_end(argptr); |
||||
|
|
||||
|
unity_callbacks->DebugLogError(text); |
||||
|
unity_callbacks->ApplicationQuit(1); |
||||
|
} |
||||
|
|
||||
|
void Sys_Printf(char *fmt, ...) |
||||
|
{ |
||||
|
va_list argptr; |
||||
|
char text[1024]; |
||||
|
|
||||
|
va_start(argptr, fmt); |
||||
|
vsprintf(text, fmt, argptr); |
||||
|
va_end(argptr); |
||||
|
|
||||
|
unity_callbacks->DebugLog(text); |
||||
|
} |
||||
|
|
||||
|
void Sys_Quit(void) |
||||
|
{ |
||||
|
Host_Shutdown(); |
||||
|
unity_callbacks->ApplicationQuit(0); |
||||
|
} |
||||
|
|
||||
|
double Sys_FloatTime(void) |
||||
|
{ |
||||
|
return unity_callbacks->RealtimeSinceStartup(); |
||||
|
} |
||||
|
|
||||
|
UNIQUAKE_API void Uniquake_Echo(void(__stdcall *DebugLog)(const char *msg), const char *message) |
||||
|
{ |
||||
|
DebugLog(message); |
||||
|
} |
||||
|
|
||||
|
UNIQUAKE_API void Uniquake_Init(const unity_callbacks_t *callbacks, quakeparms_t *parms) |
||||
|
{ |
||||
|
unity_callbacks = callbacks; |
||||
|
|
||||
|
COM_InitArgv(parms->argc, parms->argv); |
||||
|
// TODO winquake writes com_argc/argv back to parms.argc/argv, is this necessary? |
||||
|
|
||||
|
isDedicated = true; |
||||
|
|
||||
|
Host_Init(parms); |
||||
|
} |
||||
|
|
||||
|
UNIQUAKE_API void Uniquake_Update(float deltaTime) |
||||
|
{ |
||||
|
// TODO: limit ticrate when running dedicated server |
||||
|
|
||||
|
Host_Frame(deltaTime); |
||||
|
} |
||||
@ -1,22 +0,0 @@ |
|||||
// uniquake.cpp : Defines the exported functions for the DLL.
|
|
||||
//
|
|
||||
|
|
||||
#include "pch.h"
|
|
||||
#include "framework.h"
|
|
||||
#include "uniquake.h"
|
|
||||
|
|
||||
|
|
||||
// This is an example of an exported variable
|
|
||||
UNIQUAKE_API int nuniquake=0; |
|
||||
|
|
||||
// This is an example of an exported function.
|
|
||||
UNIQUAKE_API int fnuniquake(void) |
|
||||
{ |
|
||||
return 0; |
|
||||
} |
|
||||
|
|
||||
// This is the constructor of a class that has been exported.
|
|
||||
Cuniquake::Cuniquake() |
|
||||
{ |
|
||||
return; |
|
||||
} |
|
||||
@ -1,22 +1,6 @@ |
|||||
// The following ifdef block is the standard way of creating macros which make exporting |
|
||||
// from a DLL simpler. All files within this DLL are compiled with the UNIQUAKE_EXPORTS |
|
||||
// symbol defined on the command line. This symbol should not be defined on any project |
|
||||
// that uses this DLL. This way any other project whose source files include this file see |
|
||||
// UNIQUAKE_API functions as being imported from a DLL, whereas this DLL sees symbols |
|
||||
// defined with this macro as being exported. |
|
||||
#ifdef UNIQUAKE_EXPORTS |
#ifdef UNIQUAKE_EXPORTS |
||||
#define UNIQUAKE_API __declspec(dllexport) |
#define UNIQUAKE_API __declspec(dllexport) |
||||
#else |
#else |
||||
#define UNIQUAKE_API __declspec(dllimport) |
#define UNIQUAKE_API __declspec(dllimport) |
||||
#endif |
#endif |
||||
|
|
||||
// This class is exported from the dll |
|
||||
class UNIQUAKE_API Cuniquake { |
|
||||
public: |
|
||||
Cuniquake(void); |
|
||||
// TODO: add your methods here. |
|
||||
}; |
|
||||
|
|
||||
extern UNIQUAKE_API int nuniquake; |
|
||||
|
|
||||
UNIQUAKE_API int fnuniquake(void); |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue