Clean up the q3 plugin a little.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6274 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2022-06-20 07:16:16 +00:00
parent d41ca13562
commit d8364a4cc2
6 changed files with 25 additions and 21 deletions

View file

@ -30,13 +30,6 @@ qboolean VM_NonNative(vm_t *vm);
void *VM_MemoryBase(vm_t *vm); void *VM_MemoryBase(vm_t *vm);
quintptr_t VM_MemoryMask(vm_t *vm); quintptr_t VM_MemoryMask(vm_t *vm);
#define VM_TOSTRCACHE(a) VMQ3_StringToHandle(VM_POINTER(a))
#define VM_FROMSTRCACHE(a) VMQ3_StringFromHandle(a)
char *VMQ3_StringFromHandle(int handle);
int VMQ3_StringToHandle(char *str);
void VMQ3_FlushStringHandles(void);
#define VM_FS_READ 0 #define VM_FS_READ 0
#define VM_FS_WRITE 1 #define VM_FS_WRITE 1
#define VM_FS_APPEND 2 #define VM_FS_APPEND 2

View file

@ -368,9 +368,6 @@ void R_DrawGAliasShadowVolume(entity_t *e, vec3_t lightpos, float radius);
#ifdef GLQUAKE #ifdef GLQUAKE
//misc model formats //misc model formats
void R_DrawHLModel(entity_t *curent); void R_DrawHLModel(entity_t *curent);
//typedef float m3by3_t[3][3];
//int GetTag(model_t *mod, char *tagname, int frame, float **org, m3by3_t **ang);
#endif #endif
// //

View file

@ -1,15 +1,5 @@
#include "q3common.h" #include "q3common.h"
//#include "cg_public.h"
#if defined(VM_CG) && defined(HAVE_CLIENT) #if defined(VM_CG) && defined(HAVE_CLIENT)
#include "shader.h"
#if 1
#include "glquake.h"//hack
#else
typedef float m3by3_t[3][3];
#endif
#include "clq3defs.h" #include "clq3defs.h"
#include "com_mesh.h" #include "com_mesh.h"

View file

@ -1655,6 +1655,7 @@ qint64_t Q3VM_GetRealtime(q3time_t *qtime)
static struct q3gamecode_s q3funcs = static struct q3gamecode_s q3funcs =
{ {
#ifdef HAVE_CLIENT
{ {
CLQ3_SendAuthPacket, CLQ3_SendAuthPacket,
CLQ3_SendConnectPacket, CLQ3_SendConnectPacket,
@ -1680,7 +1681,11 @@ static struct q3gamecode_s q3funcs =
UI_OpenMenu, UI_OpenMenu,
UI_Reset, UI_Reset,
}, },
#else
{NULL},{NULL},{NULL},
#endif
#ifdef HAVE_SERVER
{ {
SVQ3_ShutdownGame, SVQ3_ShutdownGame,
SVQ3_InitGame, SVQ3_InitGame,
@ -1695,6 +1700,9 @@ static struct q3gamecode_s q3funcs =
SVQ3_RestartGamecode, SVQ3_RestartGamecode,
SVQ3_ServerinfoChanged, SVQ3_ServerinfoChanged,
}, },
#else
{NULL},
#endif
}; };
#ifndef STATIC_Q3 #ifndef STATIC_Q3
@ -1706,11 +1714,15 @@ void Q3_Frame(double enginetime, double gametime)
void Q3_Shutdown(void) void Q3_Shutdown(void)
{ {
#ifdef HAVE_SERVER
SVQ3_ShutdownGame(false); SVQ3_ShutdownGame(false);
#endif
#ifdef HAVE_CLIENT
CG_Stop(); CG_Stop();
UI_Stop(); UI_Stop();
VMQ3_FlushStringHandles(); VMQ3_FlushStringHandles();
#endif
} }
#ifdef STATIC_Q3 #ifdef STATIC_Q3
@ -1741,6 +1753,7 @@ qboolean Plug_Init(void)
plugfuncs->ExportFunction("Tick", Q3_Frame); plugfuncs->ExportFunction("Tick", Q3_Frame);
#endif #endif
#ifdef HAVE_CLIENT
drawfuncs = plugfuncs->GetEngineInterface(plug2dfuncs_name, sizeof(*drawfuncs)); drawfuncs = plugfuncs->GetEngineInterface(plug2dfuncs_name, sizeof(*drawfuncs));
scenefuncs = plugfuncs->GetEngineInterface(plug3dfuncs_name, sizeof(*scenefuncs)); scenefuncs = plugfuncs->GetEngineInterface(plug3dfuncs_name, sizeof(*scenefuncs));
inputfuncs = plugfuncs->GetEngineInterface(pluginputfuncs_name, sizeof(*inputfuncs)); inputfuncs = plugfuncs->GetEngineInterface(pluginputfuncs_name, sizeof(*inputfuncs));
@ -1749,6 +1762,7 @@ qboolean Plug_Init(void)
masterfuncs = plugfuncs->GetEngineInterface(plugmasterfuncs_name, sizeof(*masterfuncs)); masterfuncs = plugfuncs->GetEngineInterface(plugmasterfuncs_name, sizeof(*masterfuncs));
if (drawfuncs && scenefuncs && inputfuncs && clientfuncs && audiofuncs && masterfuncs) if (drawfuncs && scenefuncs && inputfuncs && clientfuncs && audiofuncs && masterfuncs)
UI_Init(); UI_Init();
#endif
return true; return true;
} }
#else #else

View file

@ -4,14 +4,22 @@
#include "../plugins/plugin.h" #include "../plugins/plugin.h"
#include "clq3defs.h" #include "clq3defs.h"
#define VM_TOSTRCACHE(a) VMQ3_StringToHandle(VM_POINTER(a))
#define VM_FROMSTRCACHE(a) VMQ3_StringFromHandle(a)
char *VMQ3_StringFromHandle(int handle);
int VMQ3_StringToHandle(char *str);
void VMQ3_FlushStringHandles(void);
//#define Q3_NOENCRYPT //a debugging property, makes it incompatible with q3 //#define Q3_NOENCRYPT //a debugging property, makes it incompatible with q3
#ifdef HAVE_CLIENT
extern plug2dfuncs_t *drawfuncs; extern plug2dfuncs_t *drawfuncs;
extern plug3dfuncs_t *scenefuncs; extern plug3dfuncs_t *scenefuncs;
extern pluginputfuncs_t *inputfuncs; extern pluginputfuncs_t *inputfuncs;
extern plugaudiofuncs_t *audiofuncs; extern plugaudiofuncs_t *audiofuncs;
extern plugmasterfuncs_t*masterfuncs; extern plugmasterfuncs_t*masterfuncs;
extern plugclientfuncs_t*clientfuncs; extern plugclientfuncs_t*clientfuncs;
#endif
extern plugq3vmfuncs_t *vmfuncs; extern plugq3vmfuncs_t *vmfuncs;
extern plugfsfuncs_t *fsfuncs; extern plugfsfuncs_t *fsfuncs;

View file

@ -1607,8 +1607,10 @@ static qintptr_t EXPORT_FN Q3G_SystemCallsNative(qintptr_t arg, ...)
void SVQ3_ShutdownGame(qboolean restarting) void SVQ3_ShutdownGame(qboolean restarting)
{ {
int i; int i;
#ifdef HAVE_CLIENT
if (!restarting) if (!restarting)
CG_Stop(); CG_Stop();
#endif
if (!q3gamevm) if (!q3gamevm)
return; return;
@ -3386,7 +3388,7 @@ void SVQ3_DirectConnect(netadr_t *from, sizebuf_t *msg) //Actually connect the c
if (from->type == NA_LOOPBACK) if (from->type == NA_LOOPBACK)
reason = "localhost"; //Q3 uses this specific string for listen servers. reason = "localhost"; //Q3 uses this specific string for listen servers.
else else
reason = masterfuncs->AdrToString(adr, sizeof(adr), from); reason = msgfuncs->AdrToString(adr, sizeof(adr), from);
worldfuncs->SetIBufKey(&cl->userinfo, "ip", reason); //q3 gamecode needs to know the client's ip (server's perception of the client, NOT QW client's perception of the server/proxy) worldfuncs->SetIBufKey(&cl->userinfo, "ip", reason); //q3 gamecode needs to know the client's ip (server's perception of the client, NOT QW client's perception of the server/proxy)
ret = vmfuncs->Call(q3gamevm, GAME_CLIENT_CONNECT, (int)(cl-svs.clients), true/*firsttime*/, false/*isbot*/); ret = vmfuncs->Call(q3gamevm, GAME_CLIENT_CONNECT, (int)(cl-svs.clients), true/*firsttime*/, false/*isbot*/);