diff --git a/Assets/Scripts/UniQuake.cs b/Assets/Scripts/UniQuake.cs index f69bf22..b6ea67e 100644 --- a/Assets/Scripts/UniQuake.cs +++ b/Assets/Scripts/UniQuake.cs @@ -126,7 +126,7 @@ public class UniQuake: MonoBehaviour } [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void UniQuake_InitFunc(QuakeParms parms, IntPtr sysCalls, IntPtr modCalls); + private delegate void UniQuake_InitFunc(QuakeParms parms, IntPtr sysCalls, IntPtr glCalls); private UniQuake_InitFunc UniQuake_Init; [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -139,7 +139,6 @@ public class UniQuake: MonoBehaviour [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void UniQuake_SetFmodSystemFunc(IntPtr fmodSystem); - private UniQuake_SetFmodSystemFunc UniQuake_SetFmodSystem; private void LoadLibrary() @@ -157,12 +156,12 @@ public class UniQuake: MonoBehaviour UniQuake_SetFmodSystem = LoadLibraryFunction("UniQuake_SetFmodSystem"); } - private TDelegate LoadLibraryFunction(string name) + private TDelegate LoadLibraryFunction(string functionName) { - IntPtr procAddress = SystemLibrary.GetProcAddress(libraryHandle, name); + IntPtr procAddress = SystemLibrary.GetProcAddress(libraryHandle, functionName); if (procAddress == IntPtr.Zero) { - throw new DllNotFoundException($"Could not find library function: {name}"); + throw new DllNotFoundException($"Could not find library function: {functionName}"); } return Marshal.GetDelegateForFunctionPointer(procAddress); diff --git a/engine/projects/uniquake/mod_uniquake.c b/engine/projects/uniquake/gl_uniquake.c similarity index 72% rename from engine/projects/uniquake/mod_uniquake.c rename to engine/projects/uniquake/gl_uniquake.c index 4c56c5d..f249568 100644 --- a/engine/projects/uniquake/mod_uniquake.c +++ b/engine/projects/uniquake/gl_uniquake.c @@ -3,18 +3,18 @@ #include "../../code/quakedef.h" #include "../../code/gl_model.h" -typedef struct unity_modcalls_s +typedef struct unity_glcalls_s { void *target; int(*UploadAliasModel)(void *target, char *name, aliashdr_t *aliashdr, maliasframedesc_t *frames, trivertx_t **poseVerts, mtriangle_t *triangles, stvert_t *stVerts); -} unity_modcalls_t; +} unity_glcalls_t; -const unity_modcalls_t *unity_modcalls; +const unity_glcalls_t *unity_glcalls; int UQ_GL_UploadAliasModel(char *name, aliashdr_t *aliashdr, trivertx_t **poseVerts, mtriangle_t *triangles, stvert_t *stVerts) { // C# doesn't really understand this idea of a variable-length embedded array of structs, // so we pass along the pointer to the first frame struct which allows us to manually marshal the entire array. - return unity_modcalls->UploadAliasModel(unity_modcalls->target, name, aliashdr, &aliashdr->frames[0], poseVerts, triangles, stVerts); + return unity_glcalls->UploadAliasModel(unity_glcalls->target, name, aliashdr, &aliashdr->frames[0], poseVerts, triangles, stVerts); } diff --git a/engine/projects/uniquake/sys_uniquake.c b/engine/projects/uniquake/sys_uniquake.c index 1f3e1f9..a124759 100644 --- a/engine/projects/uniquake/sys_uniquake.c +++ b/engine/projects/uniquake/sys_uniquake.c @@ -2,6 +2,25 @@ #include "../../code/quakedef.h" +typedef struct unity_syscalls_s +{ + void *target; + + void(*SysPrint)(void *target, const char *msg); + void(*SysError)(void *target, const char *msg); + void(*SysQuit)(void *target); + double(*SysFloatTime)(void *target); + + int(*SysFileOpenRead)(void *target, char *path, int *hndl); + int(*SysFileOpenWrite)(void *target, char *path); + void(*SysFileClose)(void *target, int handle); + void(*SysFileSeek)(void *target, int handle, int position); + int(*SysFileRead)(void *target, int handle, void *dest, int count); + int(*SysFileWrite)(void *target, int handle, void *data, int count); + int(*SysFileTime)(void *target, char *path); + void(*SysMkDir)(void *target, char *path); +} unity_syscalls_t; + const unity_syscalls_t *unity_syscalls; void Sys_Error(char *error, ...) diff --git a/engine/projects/uniquake/uniquake.c b/engine/projects/uniquake/uniquake.c index c04b5a5..a2d33dd 100644 --- a/engine/projects/uniquake/uniquake.c +++ b/engine/projects/uniquake/uniquake.c @@ -7,10 +7,10 @@ UNIQUAKE_API void UniQuake_SetFmodSystem(FMOD_SYSTEM *system) fmod_system = system; } -UNIQUAKE_API void UniQuake_Init(quakeparms_t *parms, const unity_syscalls_t *syscalls, const unity_modcalls_t *modcalls) +UNIQUAKE_API void UniQuake_Init(quakeparms_t *parms, const unity_syscalls_t *syscalls, const unity_glcalls_t *glcalls) { unity_syscalls = syscalls; - unity_modcalls = modcalls; + unity_glcalls = glcalls; COM_InitArgv(parms->argc, parms->argv); parms->argc = com_argc; diff --git a/engine/projects/uniquake/uniquake.h b/engine/projects/uniquake/uniquake.h index 6a77303..9024056 100644 --- a/engine/projects/uniquake/uniquake.h +++ b/engine/projects/uniquake/uniquake.h @@ -9,26 +9,8 @@ #define UNIQUAKE_API __declspec(dllimport) #endif -typedef struct unity_syscalls_s -{ - void *target; - - void(*SysPrint)(void *target, const char *msg); - void(*SysError)(void *target, const char *msg); - void(*SysQuit)(void *target); - double(*SysFloatTime)(void *target); - - int(*SysFileOpenRead)(void *target, char *path, int *hndl); - int(*SysFileOpenWrite)(void *target, char *path); - void(*SysFileClose)(void *target, int handle); - void(*SysFileSeek)(void *target, int handle, int position); - int(*SysFileRead)(void *target, int handle, void *dest, int count); - int(*SysFileWrite)(void *target, int handle, void *data, int count); - int(*SysFileTime)(void *target, char *path); - void(*SysMkDir)(void *target, char *path); -} unity_syscalls_t; - +typedef struct unity_syscalls_s unity_syscalls_t; extern const unity_syscalls_t *unity_syscalls; -typedef struct unity_modcalls_s unity_modcalls_t; -extern const unity_modcalls_t *unity_modcalls; \ No newline at end of file +typedef struct unity_glcalls_s unity_glcalls_t; +extern const unity_glcalls_t *unity_glcalls; diff --git a/engine/projects/uniquake/uniquake.vcxproj b/engine/projects/uniquake/uniquake.vcxproj index 70175a8..e37c02b 100644 --- a/engine/projects/uniquake/uniquake.vcxproj +++ b/engine/projects/uniquake/uniquake.vcxproj @@ -353,7 +353,7 @@ - + diff --git a/engine/projects/uniquake/uniquake.vcxproj.filters b/engine/projects/uniquake/uniquake.vcxproj.filters index f022f96..2684716 100644 --- a/engine/projects/uniquake/uniquake.vcxproj.filters +++ b/engine/projects/uniquake/uniquake.vcxproj.filters @@ -533,7 +533,7 @@ Source Files - + Source Files