A few things... f_ruleset stuff, 64bit qvm compatability, added cvars so you can put the built in http server on a custom port, added #warnings to annoy molgrum.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2659 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2007-09-17 20:35:39 +00:00
parent 13eeec99a2
commit 9af1ba84cc
38 changed files with 898 additions and 1185 deletions

View file

@ -75,6 +75,8 @@ endif
CLIENT_DIR=$(BASE_DIR)/client
GL_DIR=$(BASE_DIR)/gl
SW_DIR=$(BASE_DIR)/sw
D3D7_DIR=$(BASE_DIR)/d3d
D3D9_DIR=$(BASE_DIR)/d3d9
SERVER_DIR=$(BASE_DIR)/server
COMMON_DIR=$(BASE_DIR)/common
HTTP_DIR=$(BASE_DIR)/http
@ -111,10 +113,12 @@ ifeq ($(FTE_TARGET),bsd)
endif
BASELDFLAGS ?= -lm -ldl -lpthread
IMAGELDFLAGS=-lpng -ljpeg
#BASELDFLAGS=-lm -lz
GLXLDFLAGS=-L/usr/X11R6/lib -lX11 -lXext -lpng -ljpeg
GLXLDFLAGS=-L/usr/X11R6/lib -lX11 -lXext $(IMAGELDFLAGS)
GLSLDFLAGS=-L/usr/X11R6/lib -lMesaGL -lglide -lvga
XLDFLAGS=-L/usr/X11R6/lib -lX11 -lXext -lpng -ljpeg
XLDFLAGS=-L/usr/X11R6/lib -lX11 -lXext $(IMAGELDFLAGS)
SLDFLAGS=-lvga
ifeq ($(USEASM),true)
@ -145,7 +149,7 @@ else
BASE_ASM_CFLAGS = -DNOASM
endif
BASE_CFLAGS=$(BASE_ASM_CFLAGS) -Wall -Dstrnicmp=strncasecmp -Dstricmp=strcasecmp -I$(CLIENT_DIR) -I$(SERVER_DIR) -I$(COMMON_DIR) -I$(SW_DIR) -I$(GL_DIR) -I$(PROGS_DIR) -I$(LIBS_DIR) -I$(LIBS_DIR)/dxsdk7/include -I$(LIBS_DIR)/sdl/include -I$(LIBS_DIR)/sdl/include/SDL -D_vsnprintf=vsnprintf -D_snprintf=snprintf
BASE_CFLAGS=$(BASE_ASM_CFLAGS) -Wall -Dstrnicmp=strncasecmp -Dstricmp=strcasecmp -I$(CLIENT_DIR) -I$(SERVER_DIR) -I$(COMMON_DIR) -I$(SW_DIR) -I$(GL_DIR) -I$(D3D9_DIR) -I$(D3D7_DIR) -I$(PROGS_DIR) -I$(LIBS_DIR) -I$(LIBS_DIR)/dxsdk7/include -I$(LIBS_DIR)/sdl/include -I$(LIBS_DIR)/sdl/include/SDL -D_vsnprintf=vsnprintf -D_snprintf=snprintf
CLIENT_ONLY_CFLAGS=-DCLIENTONLY
SERVER_ONLY_CFLAGS=-DSERVERONLY
JOINT_CFLAGS=
@ -153,6 +157,7 @@ DEBUG_CFLAGS=-ggdb -g
RELEASE_CFLAGS=-O6 -fno-strict-aliasing -ffast-math -funroll-loops -fexpensive-optimizations $(CPUOPTIMIZATIONS)
GLCFLAGS=-DGLQUAKE
SWCFLAGS=-DSWQUAKE
D3DCFLAGS=-DD3DQUAKE
CLIENT_OBJS = $(CLIENT_ASM_OBJS) \
textedit.o \
@ -264,6 +269,18 @@ GLQUAKE_OBJS = \
gl_vidcommon.o \
gl_hlmdl.o
D3DQUAKE_OBJS = \
d3d_draw.o \
d3d_mesh.o \
d3d_rmain.o \
d3d_rsurf.o \
vid_d3d.o \
d3d9_draw.o \
d3d9_mesh.o \
d3d9_rmain.o \
d3d9_rsurf.o \
vid_d3d9.o
MP3_OBJS = \
fixed.o \
bit.o \
@ -369,7 +386,7 @@ GLCL_EXE_NAME=../fteqwcl_sdl.gl$(BITS)
ifdef windir
GL_LDFLAGS=$(GLLDFLAGS) -lmingw32 -lwsock32 `sdl-config --libs`
else
GL_LDFLAGS=$(GLLDFLAGS) -lpng -ljpeg `sdl-config --libs`
GL_LDFLAGS=$(GLLDFLAGS) $(IMAGELDFLAGS) `sdl-config --libs`
endif
GL_CFLAGS=$(GLCFLAGS) `sdl-config --cflags`
GLB_DIR=gl_sdl$(BITS)
@ -382,7 +399,7 @@ ifdef windir
SW_LDFLAGS=$(SWLDFLAGS) -lmingw32 -lwsock32 -lSDLmain -lSDL
else
#pthread is needed because of SDL.
SW_LDFLAGS=$(SWLDFLAGS) `sdl-config --libs` -lpng -ljpeg
SW_LDFLAGS=$(SWLDFLAGS) `sdl-config --libs` $(IMAGELDFLAGS)
endif
SW_CFLAGS=$(SWCFLAGS) `sdl-config --cflags`
SWB_DIR=sw_sdl$(BITS)
@ -446,6 +463,14 @@ endif
MB_DIR=m_mgw
MCL_DIR=mcl_mgw
D3DCL_OBJS=$(D3DQUAKE_OBJS) snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o
D3D_EXE_NAME=../fted3dqw.exe
D3DCL_EXE_NAME=../fted3dclqw.exe
D3D_LDFLAGS= -ldxguid -lwsock32 -lwinmm -lgdi32 -lole32
D3D_CFLAGS=$(D3DCFLAGS) $(W32_CFLAGS) -DMINIMAL
D3DB_DIR=d3d_mgw
D3DCL_DIR=d3dcl_mgw
MINGL_EXE_NAME=../fteminglqw.exe
MINGL_DIR=mingl_mgw
endif
@ -547,7 +572,7 @@ ifeq ($(FTE_TARGET),morphos)
GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidmorphos.o in_morphos.o snd_morphos.o cd_null.o sys_morphos.o
GL_EXE_NAME=../fteqw.gl
GLCL_EXE_NAME=../fteqwcl.gl
GL_LDFLAGS=$(GLLDFLAGS) -ldl -lsyscall -lpng -ljpeg -lz
GL_LDFLAGS=$(GLLDFLAGS) -ldl -lsyscall $(IMAGELDFLAGS) -lz
GL_CFLAGS=$(GLCFLAGS) -noixemul
GLB_DIR=gl_morphos
GLCL_DIR=glcl_morphos
@ -649,7 +674,7 @@ ifneq ($(OUT_DIR),)
endif
VPATH = $(BASE_DIR) : $(CLIENT_DIR) : $(GL_DIR) : $(COMMON_DIR) : $(SW_DIR) : $(SERVER_DIR) : $(HTTP_DIR) : $(BASE_DIR)/irc : $(BASE_DIR)/email : $(QUX_DIR) : $(PROGS_DIR) : $(SNDCODEC_DIR)
VPATH = $(BASE_DIR) : $(CLIENT_DIR) : $(GL_DIR) : $(COMMON_DIR) : $(SW_DIR) : $(SERVER_DIR) : $(HTTP_DIR) : $(BASE_DIR)/irc : $(BASE_DIR)/email : $(QUX_DIR) : $(PROGS_DIR) : $(SNDCODEC_DIR) : $(D3D7_DIR) : $(D3D9_DIR)
#$(OUT_DIR)/%.d: %.c
# @set -e; rm -f $@; \
@ -718,6 +743,19 @@ sv-dbg:
d3dcl-tmp:
$(MAKE) $(TYPE) OUT_DIR="$(OUT_DIR)" EXE_NAME="$(D3DCL_EXE_NAME)" WCFLAGS="$(D3D_CFLAGS)" LDFLAGS="$(D3D_LDFLAGS) $(LDFLAGS)" SOBJS="$(D3DCL_OBJS)"
d3d-tmp:
$(MAKE) $(TYPE) OUT_DIR="$(OUT_DIR)" EXE_NAME="$(D3D_EXE_NAME)" WCFLAGS="$(D3D_CFLAGS)" LDFLAGS="$(D3D_LDFLAGS) $(LDFLAGS)" SOBJS="$(D3DCL_OBJS)"
d3dcl-rel:
$(MAKE) d3dcl-tmp TYPE=_cl-rel OUT_DIR="$(RELEASE_DIR)/$(D3DCL_DIR)"
d3dcl-dbg:
$(MAKE) d3dcl-tmp TYPE=_cl-dbg OUT_DIR="$(DEBUG_DIR)/$(D3DCL_DIR)"
d3d-rel:
$(MAKE) d3d-tmp TYPE=_clsv-rel OUT_DIR="$(RELEASE_DIR)/$(D3DB_DIR)"
d3d-dbg:
$(MAKE) d3d-tmp TYPE=_clsv-dbg OUT_DIR="$(DEBUG_DIR)/$(D3DB_DIR)"
glcl-tmp:
@ -805,6 +843,7 @@ help:
@-echo "gl"
@-echo "sw"
@-echo "m"
@-echo "d3d (for windows builds)"
@-echo "mcl (currently broken)"
@-echo "glcl (currently broken)"
@-echo "swcl (currently broken)"

View file

@ -500,7 +500,6 @@ void Cam_Track(int pnum, usercmd_t *cmd)
// move there locally immediately
VectorCopy(player->origin, self->origin);
}
Con_Printf("self->weaponframe = %i\n", self->weaponframe);
self->weaponframe = player->weaponframe;
return;

View file

@ -27,8 +27,18 @@ void GLDraw_ShaderImage (int x, int y, int w, int h, float s1, float t1, float s
#define CGTAGNUM 5423
#define VM_FROMHANDLE(a) ((void*)a)
#define VM_TOHANDLE(a) ((int)a)
#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);
extern model_t mod_known[];
#define VM_FROMMHANDLE(a) (a?mod_known+a-1:NULL)
#define VM_TOMHANDLE(a) (a?a-mod_known+1:0)
extern shader_t r_shaders[];
#define VM_FROMSHANDLE(a) (a?r_shaders+a-1:NULL)
#define VM_TOSHANDLE(a) (a?a-r_shaders+1:0)
typedef enum {
CG_PRINT,
@ -139,8 +149,6 @@ typedef enum {
} cgameImport_t;
#define VM_FROMHANDLE(a) ((void*)a)
#define VM_TOHANDLE(a) ((int)a)
/*
==================================================================
@ -426,7 +434,7 @@ int VM_LerpTag(void *out, model_t *model, int f1, int f2, float l2, char *tagnam
#define VALIDATEPOINTER(o,l) if ((int)o + l >= mask || VM_POINTER(o) < offset) Host_EndGame("Call to cgame trap %i passes invalid pointer\n", fn); //out of bounds.
static long CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
static int CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const int *arg)
{
int ret=0;
@ -463,35 +471,10 @@ static long CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const long
case CG_CVAR_REGISTER:
if (arg[0])
VALIDATEPOINTER(arg[0], sizeof(vmcvar_t));
{
vmcvar_t *vmc;
cvar_t *var;
vmc = VM_POINTER(arg[0]);
var = Cvar_Get(VM_POINTER(arg[1]), VM_POINTER(arg[2]), VM_LONG(arg[3])&(CVAR_ARCHIVE|CVAR_USERINFO|CVAR_SERVERINFO), "UI cvar");
if (!vmc)
break;
vmc->handle = (char *)var - (char *)offset;
vmc->integer = var->value;
vmc->value = var->value;
vmc->modificationCount = var->modified;
Q_strncpyz(vmc->string, var->string, sizeof(vmc->string));
}
break;
return VMQ3_Cvar_Register(VM_POINTER(arg[0]), VM_POINTER(arg[1]), VM_POINTER(arg[2]), VM_LONG(arg[3]));
case CG_CVAR_UPDATE:
VALIDATEPOINTER(arg[0], sizeof(vmcvar_t));
{
cvar_t *var;
vmcvar_t *vmc;
vmc = VM_POINTER(arg[0]);
var = (cvar_t *)((int)vmc->handle + (char *)offset);
vmc->integer = var->value;
vmc->value = var->value;
vmc->modificationCount = var->modified;
Q_strncpyz(vmc->string, var->string, sizeof(vmc->string));
}
break;
return VMQ3_Cvar_Update(VM_POINTER(arg[0]));
case CG_CVAR_SET:
{
@ -562,7 +545,7 @@ static long CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const long
case CG_CM_POINTCONTENTS: //int trap_CM_PointContents( const vec3_t p, clipHandle_t model );
{
unsigned int pc;
model_t *mod = VM_FROMHANDLE(arg[1]);
model_t *mod = VM_FROMMHANDLE(arg[1]);
if (!mod)
mod = cl.worldmodel;
if (mod)
@ -577,7 +560,7 @@ static long CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const long
{
unsigned int pc;
float *p = VM_POINTER(arg[0]);
model_t *mod = VM_FROMHANDLE(arg[1]);
model_t *mod = VM_FROMMHANDLE(arg[1]);
float *origin = VM_POINTER(arg[2]);
float *angles = VM_POINTER(arg[3]);
@ -624,7 +607,7 @@ static long CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const long
float *end = VM_POINTER(arg[2]);
float *mins = VM_POINTER(arg[3]);
float *maxs = VM_POINTER(arg[4]);
model_t *mod = VM_FROMHANDLE(arg[5]);
model_t *mod = VM_FROMMHANDLE(arg[5]);
int brushmask = VM_LONG(arg[6]);
float *origin = VM_POINTER(arg[7]);
float *angles = VM_POINTER(arg[8]);
@ -668,7 +651,7 @@ static long CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const long
float *end = VM_POINTER(arg[2]);
float *mins = VM_POINTER(arg[3]);
float *maxs = VM_POINTER(arg[4]);
model_t *mod = VM_FROMHANDLE(arg[5]);
model_t *mod = VM_FROMMHANDLE(arg[5]);
int brushmask = VM_LONG(arg[6]);
if (!mod)
mod = cl.worldmodel;
@ -703,8 +686,9 @@ static long CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const long
case CG_CM_LOADMAP:
{
int i;
strcpy(cl.model_name[1], VM_POINTER(arg[0]));
cl.worldmodel = cl.model_precache[1] = Mod_ForName(VM_POINTER(arg[0]), false);
char *mapname = VM_POINTER(arg[0]);
strcpy(cl.model_name[1], mapname);
cl.worldmodel = cl.model_precache[1] = Mod_ForName(mapname, false);
if (cl.worldmodel->needload)
Host_EndGame("Couldn't load map");
@ -718,21 +702,21 @@ static long CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const long
break;
case CG_CM_INLINEMODEL:
VM_LONG(ret) = VM_TOHANDLE(cl.model_precache[VM_LONG(arg[0])+1]);
VM_LONG(ret) = VM_TOMHANDLE(cl.model_precache[VM_LONG(arg[0])+1]);
break;
case CG_CM_NUMINLINEMODELS:
VM_LONG(ret) = cl.worldmodel?cl.worldmodel->numsubmodels:0;
break;
case CG_CM_TEMPBOXMODEL:
VM_LONG(ret) = VM_TOHANDLE(CM_TempBoxModel(VM_POINTER(arg[0]), VM_POINTER(arg[1])));
VM_LONG(ret) = VM_TOMHANDLE(CM_TempBoxModel(VM_POINTER(arg[0]), VM_POINTER(arg[1])));
break;
case CG_R_MODELBOUNDS:
VALIDATEPOINTER(arg[1], sizeof(vec3_t));
VALIDATEPOINTER(arg[2], sizeof(vec3_t));
{
model_t *mod = VM_FROMHANDLE(arg[0]);
model_t *mod = VM_FROMMHANDLE(arg[0]);
if (mod)
{
VectorCopy(mod->mins, ((float*)VM_POINTER(arg[1])));
@ -747,35 +731,29 @@ static long CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const long
mod = Mod_ForName(VM_POINTER(arg[0]), false);
if (mod->needload || mod->type == mod_dummy)
return 0;
VM_LONG(ret) = VM_TOHANDLE(mod);
VM_LONG(ret) = VM_TOMHANDLE(mod);
}
break;
case CG_R_REGISTERSKIN:
{
char *buf;
char *skinname = VM_POINTER(arg[0]);
buf = Z_TagMalloc(strlen(skinname)+1, CGTAGNUM);
strcpy(buf, skinname);
VM_LONG(ret) = VM_TOHANDLE(buf); //precache skin - engine ignores these anyway... (for now)
}
VM_LONG(ret) = VM_TOSTRCACHE(arg[0]);
break;
case CG_R_REGISTERSHADER:
if (!*(char*)VM_POINTER(arg[0]))
VM_LONG(ret) = 0;
else if (qrenderer == QR_OPENGL)
VM_LONG(ret) = VM_TOHANDLE(R_RegisterPic(VM_POINTER(arg[0])));
else
VM_LONG(ret) = VM_TOHANDLE(Draw_SafeCachePic(VM_POINTER(arg[0])));
VM_LONG(ret) = VM_TOSHANDLE(R_RegisterPic(VM_POINTER(arg[0])));
//FIXME: 64bit else
// VM_LONG(ret) = VM_TOHANDLE(Draw_SafeCachePic(VM_POINTER(arg[0])));
break;
case CG_R_REGISTERSHADERNOMIP:
if (!*(char*)VM_POINTER(arg[0]))
VM_LONG(ret) = 0;
else if (qrenderer == QR_OPENGL)
VM_LONG(ret) = VM_TOHANDLE(R_RegisterPic(VM_POINTER(arg[0])));
else
VM_LONG(ret) = VM_TOHANDLE(Draw_SafeCachePic(VM_POINTER(arg[0])));
VM_LONG(ret) = VM_TOSHANDLE(R_RegisterPic(VM_POINTER(arg[0])));
//FIXME: 64bit else
// VM_LONG(ret) = VM_TOHANDLE(Draw_SafeCachePic(VM_POINTER(arg[0])));
break;
case CG_R_CLEARSCENE: //clear scene
@ -813,22 +791,22 @@ static long CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const long
case CG_R_DRAWSTRETCHPIC:
if (qrenderer == QR_OPENGL)
GLDraw_ShaderImage(VM_FLOAT(arg[0]), VM_FLOAT(arg[1]), VM_FLOAT(arg[2]), VM_FLOAT(arg[3]), VM_FLOAT(arg[4]), VM_FLOAT(arg[5]), VM_FLOAT(arg[6]), VM_FLOAT(arg[7]), (void *)VM_LONG(arg[8]));
else
Draw_Image(VM_FLOAT(arg[0]), VM_FLOAT(arg[1]), VM_FLOAT(arg[2]), VM_FLOAT(arg[3]), VM_FLOAT(arg[4]), VM_FLOAT(arg[5]), VM_FLOAT(arg[6]), VM_FLOAT(arg[7]), (mpic_t *)VM_LONG(arg[8]));
GLDraw_ShaderImage(VM_FLOAT(arg[0]), VM_FLOAT(arg[1]), VM_FLOAT(arg[2]), VM_FLOAT(arg[3]), VM_FLOAT(arg[4]), VM_FLOAT(arg[5]), VM_FLOAT(arg[6]), VM_FLOAT(arg[7]), VM_FROMSHANDLE(arg[8]));
// else
// Draw_Image(VM_FLOAT(arg[0]), VM_FLOAT(arg[1]), VM_FLOAT(arg[2]), VM_FLOAT(arg[3]), VM_FLOAT(arg[4]), VM_FLOAT(arg[5]), VM_FLOAT(arg[6]), VM_FLOAT(arg[7]), (mpic_t *)VM_LONG(arg[8]));
break;
case CG_R_LERPTAG: //Lerp tag...
VALIDATEPOINTER(arg[0], sizeof(float)*12);
VM_LONG(ret) = VM_LerpTag(VM_POINTER(arg[0]), (model_t*)VM_LONG(arg[1]), VM_LONG(arg[2]), VM_LONG(arg[3]), VM_FLOAT(arg[4]), VM_POINTER(arg[5]));
VM_LONG(ret) = VM_LerpTag(VM_POINTER(arg[0]), VM_FROMMHANDLE(arg[1]), VM_LONG(arg[2]), VM_LONG(arg[3]), VM_FLOAT(arg[4]), VM_POINTER(arg[5]));
break;
case CG_S_REGISTERSOUND:
{
sfx_t *sfx;
sfx = S_PrecacheSound(va("../%s", VM_POINTER(arg[0])));
sfx = S_PrecacheSound(VM_POINTER(arg[0]));
if (sfx)
VM_LONG(ret) = VM_TOHANDLE(sfx);
VM_LONG(ret) = VM_TOSTRCACHE(arg[0]);
else
VM_LONG(ret) = -1;
}
@ -836,11 +814,11 @@ static long CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const long
case CG_S_STARTLOCALSOUND:
if (VM_LONG(arg[0]) != -1 && arg[0])
S_LocalSound(((sfx_t*)VM_FROMHANDLE(arg[0]))->name );
S_LocalSound(VM_FROMSTRCACHE(arg[0]));
break;
case CG_S_STARTSOUND:// ( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx )
S_StartSound(VM_LONG(arg[1]), VM_LONG(arg[2]), (sfx_t*)VM_LONG(arg[3]), VM_POINTER(arg[0]), 1, 1);
S_StartSound(VM_LONG(arg[1]), VM_LONG(arg[2]), S_PrecacheSound(VM_FROMSTRCACHE(arg[3])), VM_POINTER(arg[0]), 1, 1);
break;
case CG_S_ADDLOOPINGSOUND:
@ -906,11 +884,14 @@ vec3_t listener_up;
VALIDATEPOINTER(arg[0], 11332);
//do any needed work
memset(VM_POINTER(arg[0]), 0, 11304);
*(int *)VM_POINTER(arg[0]+11304) = vid.width;
*(int *)VM_POINTER(arg[0]+11308) = vid.height;
*(float *)VM_POINTER(arg[0]+11312) = (float)vid.width/vid.height;
memset(VM_POINTER(arg[0]+11316), 0, 11332-11316);
unsigned char *glconfig = VM_POINTER(arg[0]);
{ //FIXME: Clean this shit up
memset(glconfig, 0, 11304);
*(int *)(glconfig+11304) = vid.width;
*(int *)(glconfig+11308) = vid.height;
*(float *)(glconfig+11312) = (float)vid.width/vid.height;
memset((glconfig+11316), 0, 11332-11316);
}
break;
case CG_GETGAMESTATE:
@ -991,15 +972,26 @@ vec3_t listener_up;
// standard Q3
case CG_MEMSET:
VALIDATEPOINTER(arg[0], arg[2]);
memset(VM_POINTER(arg[0]), arg[1], arg[2]);
{
void *dst = VM_POINTER(arg[0]);
memset(dst, arg[1], arg[2]);
}
break;
case CG_MEMCPY:
VALIDATEPOINTER(arg[0], arg[2]);
memcpy(VM_POINTER(arg[0]), VM_POINTER(arg[1]), arg[2]);
{
void *dst = VM_POINTER(arg[0]);
void *src = VM_POINTER(arg[1]);
memcpy(dst, src, arg[2]);
}
break;
case CG_STRNCPY:
VALIDATEPOINTER(arg[0], arg[2]);
strncpy(VM_POINTER(arg[0]), VM_POINTER(arg[1]), arg[2]);
{
void *dst = VM_POINTER(arg[0]);
void *src = VM_POINTER(arg[1]);
strncpy(dst, src, arg[2]);
}
break;
case CG_SIN:
VM_FLOAT(ret)=(float)sin(VM_FLOAT(arg[0]));
@ -1034,7 +1026,7 @@ vec3_t listener_up;
return ret;
}
#ifdef _DEBUG
static long CG_SystemCallsExWrapper(void *offset, unsigned int mask, int fn, const long *arg)
static int CG_SystemCallsExWrapper(void *offset, unsigned int mask, int fn, const int *arg)
{ //this is so we can use edit and continue properly (vc doesn't like function pointers for edit+continue)
return CG_SystemCallsEx(offset, mask, fn, arg);
}
@ -1045,7 +1037,7 @@ static long CG_SystemCallsExWrapper(void *offset, unsigned int mask, int fn, con
//but dlls call it without saying what sort of vm it comes from, so I've got to have them as specifics
static int EXPORT_FN CG_SystemCalls(int arg, ...)
{
long args[10];
int args[10];
va_list argptr;
va_start(argptr, arg);

View file

@ -1183,6 +1183,8 @@ void CL_Disconnect (void)
cl.servercount = 0;
cls.findtrack = false;
Validation_DelatchRulesets();
#ifdef TCPCONNECT
if (cls.sockettcp != INVALID_SOCKET)
{
@ -2170,6 +2172,7 @@ void CL_ConnectionlessPacket (void)
if (!strcmp(com_token, "ccept"))
{
Con_Printf ("accept\n");
Validation_Apply_Ruleset();
Netchan_Setup(NS_CLIENT, &cls.netchan, net_from, cls.qport);
Con_DPrintf ("CL_EstablishConnection: connected to %s\n", cls.servername);
@ -2226,6 +2229,8 @@ client_connect: //fixme: make function
current_loading_size = 0;
loading_stage = 2;
Validation_Apply_Ruleset();
return;
}
// remote command from gui front end
@ -2342,6 +2347,8 @@ void CLNQ_ConnectionlessPacket(void)
}
}
Validation_Apply_Ruleset();
Netchan_Setup (NS_CLIENT, &cls.netchan, net_from, cls.qport);
cls.netchan.isnqprotocol = true;
cls.netchan.compress = 0;

View file

@ -3469,38 +3469,14 @@ char *CL_ParseChat(char *text, player_info_t **player)
{
if (!cls.demoplayback)
Sys_ServerActivity(); //chat always flashes the screen..
/*
//check f_ stuff
if (!strncmp(s, "f_", 2))
{
static float versionresponsetime;
static float modifiedresponsetime;
static float skinsresponsetime;
static float serverresponsetime;
if (!strncmp(s, "f_version", 9) && versionresponsetime < Sys_DoubleTime()) //respond to it.
{
ValidationPrintVersion(text);
versionresponsetime = Sys_DoubleTime() + 5;
}
else if (!strncmp(s, "f_server", 8) && serverresponsetime < Sys_DoubleTime()) //respond to it.
{
Validation_Server();
serverresponsetime = Sys_DoubleTime() + 5;
}
else if (!strncmp(s, "f_modified", 10) && modifiedresponsetime < Sys_DoubleTime()) //respond to it.
{
Validation_FilesModified();
modifiedresponsetime = Sys_DoubleTime() + 5;
}
else if (!strncmp(s, "f_skins", 7) && skinsresponsetime < Sys_DoubleTime()) //respond to it.
{
Validation_Skins();
skinsresponsetime = Sys_DoubleTime() + 5;
}
//check f_ stuff
if (*player && !strncmp(s, "f_", 2))
{
Validation_Auto_Response(*player - cl.players, s);
return s;
}
*/
Validation_CheckIfResponse(text);
#ifdef PLUGINS

View file

@ -11,7 +11,7 @@ static plugin_t *protocolclientplugin;
int VARGS Plug_Menu_Control(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Menu_Control(void *offset, unsigned int mask, const int *arg)
{
if (qrenderer <= 0)
return 0;
@ -45,7 +45,7 @@ int VARGS Plug_Menu_Control(void *offset, unsigned int mask, const long *arg)
}
}
int VARGS Plug_Key_GetKeyCode(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Key_GetKeyCode(void *offset, unsigned int mask, const int *arg)
{
int modifier;
return Key_StringToKeynum(VM_POINTER(arg[0]), &modifier);
@ -54,7 +54,7 @@ int VARGS Plug_Key_GetKeyCode(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_SCR_CenterPrint(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_SCR_CenterPrint(void *offset, unsigned int mask, const int *arg)
{
if (qrenderer <= 0)
return 0;
@ -62,7 +62,7 @@ int VARGS Plug_SCR_CenterPrint(void *offset, unsigned int mask, const long *arg)
SCR_CenterPrint(0, VM_POINTER(arg[0]));
return 0;
}
int VARGS Plug_Media_ShowFrameRGBA_32(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Media_ShowFrameRGBA_32(void *offset, unsigned int mask, const int *arg)
{
void *src = VM_POINTER(arg[0]);
int srcwidth = VM_LONG(arg[1]);
@ -92,7 +92,7 @@ typedef struct {
int pluginimagearraylen;
pluginimagearray_t *pluginimagearray;
int VARGS Plug_Draw_LoadImage(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Draw_LoadImage(void *offset, unsigned int mask, const int *arg)
{
char *name = VM_POINTER(arg[0]);
qboolean fromwad = arg[1];
@ -179,7 +179,7 @@ void Plug_FreePlugImages(plugin_t *plug)
}
//int Draw_Image (float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t image)
int VARGS Plug_Draw_Image(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Draw_Image(void *offset, unsigned int mask, const int *arg)
{
mpic_t *pic;
int i;
@ -210,7 +210,7 @@ int VARGS Plug_Draw_Image(void *offset, unsigned int mask, const long *arg)
return 1;
}
//x1,y1,x2,y2
int VARGS Plug_Draw_Line(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Draw_Line(void *offset, unsigned int mask, const int *arg)
{
switch(qrenderer) //FIXME: I don't want qrenderer seen outside the refresh
{
@ -229,7 +229,7 @@ int VARGS Plug_Draw_Line(void *offset, unsigned int mask, const long *arg)
}
return 1;
}
int VARGS Plug_Draw_Character(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Draw_Character(void *offset, unsigned int mask, const int *arg)
{
if (qrenderer <= 0)
return 0;
@ -237,7 +237,7 @@ int VARGS Plug_Draw_Character(void *offset, unsigned int mask, const long *arg)
return 0;
}
void (D3D_Draw_Fill_Colours) (int x, int y, int w, int h);
int VARGS Plug_Draw_Fill(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Draw_Fill(void *offset, unsigned int mask, const int *arg)
{
float x, y, width, height;
if (qrenderer <= 0)
@ -268,7 +268,7 @@ int VARGS Plug_Draw_Fill(void *offset, unsigned int mask, const long *arg)
}
return 0;
}
int VARGS Plug_Draw_ColourP(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Draw_ColourP(void *offset, unsigned int mask, const int *arg)
{
qbyte *pal = host_basepal + VM_LONG(arg[0])*3;
@ -282,7 +282,7 @@ int VARGS Plug_Draw_ColourP(void *offset, unsigned int mask, const long *arg)
}
return 0;
}
int VARGS Plug_Draw_Colour3f(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Draw_Colour3f(void *offset, unsigned int mask, const int *arg)
{
if (Draw_ImageColours)
{
@ -291,7 +291,7 @@ int VARGS Plug_Draw_Colour3f(void *offset, unsigned int mask, const long *arg)
}
return 0;
}
int VARGS Plug_Draw_Colour4f(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Draw_Colour4f(void *offset, unsigned int mask, const int *arg)
{
if (Draw_ImageColours)
{
@ -309,7 +309,7 @@ int VARGS Plug_Draw_Colour4f(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_LocalSound(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_LocalSound(void *offset, unsigned int mask, const int *arg)
{
if (qrenderer <= 0)
return false;
@ -320,7 +320,7 @@ int VARGS Plug_LocalSound(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_CL_GetStats(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_CL_GetStats(void *offset, unsigned int mask, const int *arg)
{
int i;
int pnum = VM_LONG(arg[0]);
@ -361,7 +361,7 @@ typedef struct {
char team[8];
} vmplugclientinfo_t;
int VARGS Plug_GetPlayerInfo(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_GetPlayerInfo(void *offset, unsigned int mask, const int *arg)
{
int i, pt;
vmplugclientinfo_t *out;
@ -401,12 +401,12 @@ int VARGS Plug_GetPlayerInfo(void *offset, unsigned int mask, const long *arg)
return pt == i;
}
int VARGS Plug_LocalPlayerNumber(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_LocalPlayerNumber(void *offset, unsigned int mask, const int *arg)
{
return cl.playernum[0];
}
int VARGS Plug_GetServerInfo(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_GetServerInfo(void *offset, unsigned int mask, const int *arg)
{
char *outptr = VM_POINTER(arg[0]);
int outlen = VM_LONG(arg[1]);
@ -419,7 +419,7 @@ int VARGS Plug_GetServerInfo(void *offset, unsigned int mask, const long *arg)
return true;
}
int VARGS Plug_SetUserInfo(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_SetUserInfo(void *offset, unsigned int mask, const int *arg)
{
char *key = VM_POINTER(arg[0]);
char *value = VM_POINTER(arg[1]);
@ -429,7 +429,7 @@ int VARGS Plug_SetUserInfo(void *offset, unsigned int mask, const long *arg)
return true;
}
int VARGS Plug_Con_SubPrint(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Con_SubPrint(void *offset, unsigned int mask, const int *arg)
{
char *name = VM_POINTER(arg[0]);
char *text = VM_POINTER(arg[1]);
@ -455,7 +455,7 @@ int VARGS Plug_Con_SubPrint(void *offset, unsigned int mask, const long *arg)
return 1;
}
int VARGS Plug_Con_RenameSub(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Con_RenameSub(void *offset, unsigned int mask, const int *arg)
{
char *name = VM_POINTER(arg[0]);
console_t *con;
@ -469,7 +469,7 @@ int VARGS Plug_Con_RenameSub(void *offset, unsigned int mask, const long *arg)
return 1;
}
int VARGS Plug_Con_IsActive(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Con_IsActive(void *offset, unsigned int mask, const int *arg)
{
char *name = VM_POINTER(arg[0]);
console_t *con;
@ -481,7 +481,7 @@ int VARGS Plug_Con_IsActive(void *offset, unsigned int mask, const long *arg)
return Con_IsActive(con);
}
int VARGS Plug_Con_SetActive(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Con_SetActive(void *offset, unsigned int mask, const int *arg)
{
char *name = VM_POINTER(arg[0]);
console_t *con;
@ -494,7 +494,7 @@ int VARGS Plug_Con_SetActive(void *offset, unsigned int mask, const long *arg)
Con_SetActive(con);
return true;
}
int VARGS Plug_Con_Destroy(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Con_Destroy(void *offset, unsigned int mask, const int *arg)
{
char *name = VM_POINTER(arg[0]);
console_t *con;
@ -507,7 +507,7 @@ int VARGS Plug_Con_Destroy(void *offset, unsigned int mask, const long *arg)
Con_Destroy(con);
return true;
}
int VARGS Plug_Con_NameForNum(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Con_NameForNum(void *offset, unsigned int mask, const int *arg)
{
char num = VM_LONG(arg[0]);
char *buffer = VM_POINTER(arg[1]);

View file

@ -298,15 +298,20 @@ netadr_t ui_pings[MAX_PINGREQUESTS];
#define UITAGNUM 2452
extern model_t mod_known[];
#define VM_FROMMHANDLE(a) (a?mod_known+a-1:NULL)
#define VM_TOMHANDLE(a) (a?a-mod_known+1:0)
extern shader_t r_shaders[];
#define VM_FROMSHANDLE(a) (a?r_shaders+a-1:NULL)
#define VM_TOSHANDLE(a) (a?a-r_shaders+1:0)
typedef struct q3refEntity_s {
refEntityType_t reType;
int renderfx;
struct model_s *hModel; // opaque type outside refresh
int hModel; // opaque type outside refresh
// most recent data
vec3_t lightingOrigin; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN)
@ -324,8 +329,7 @@ typedef struct q3refEntity_s {
// texturing
int skinNum; // inline skin index
//int customSkin; // NULL for default skin
char *customSkin; //the function that references this wants a char* not an int
int customSkin; // NULL for default skin
int customShader; // use one image for the entire thing
// misc
@ -346,13 +350,50 @@ typedef struct q3refEntity_s {
#define Q3RF_THIRD_PERSON 2 // don't draw through eyes, only mirrors (player bodies, chat sprites)
#define Q3RF_FIRST_PERSON 4 // only draw through eyes (view weapon, damage blood blob)
#define Q3RF_DEPTHHACK 8 // for view weapon Z crunching
#define MAX_VMQ3_CACHED_STRINGS 1024
char *stringcache[1024];
char *VMQ3_StringFromHandle(int handle)
{
if (!handle)
return "";
handle--;
if ((unsigned) handle >= MAX_VMQ3_CACHED_STRINGS)
return "";
return stringcache[handle];
}
int VMQ3_StringToHandle(char *str)
{
int i;
for (i = 0; i < MAX_VMQ3_CACHED_STRINGS; i++)
{
if (!stringcache[i])
break;
if (!strcmp(str, stringcache[i]))
return i+1;
}
if (i == MAX_VMQ3_CACHED_STRINGS)
{
Con_Printf("Q3VM out of string handle space\n");
return 0;
}
stringcache[i] = Z_Malloc(strlen(str)+1);
strcpy(stringcache[i], str);
return i+1;
}
#define VM_TOSTRCACHE(a) VMQ3_StringToHandle(VM_POINTER(a))
#define VM_FROMSTRCACHE(a) VMQ3_StringFromHandle(a)
void VQ3_AddEntity(const q3refEntity_t *q3)
{
entity_t ent;
if (!cl_visedicts)
cl_visedicts = cl_visedicts_list[0];
memset(&ent, 0, sizeof(ent));
ent.model = q3->hModel;
ent.model = VM_FROMMHANDLE(q3->hModel);
ent.frame = q3->frame;
ent.oldframe = q3->oldframe;
memcpy(ent.axis, q3->axis, sizeof(q3->axis));
@ -362,14 +403,14 @@ void VQ3_AddEntity(const q3refEntity_t *q3)
ent.rotation = q3->rotation;
if (q3->customSkin)
ent.skinnum = Mod_SkinForName(ent.model, q3->customSkin);
ent.skinnum = Mod_SkinForName(ent.model, VM_FROMSTRCACHE(q3->customSkin));
ent.shaderRGBAf[0] = q3->shaderRGBA[0]/255.0f;
ent.shaderRGBAf[1] = q3->shaderRGBA[1]/255.0f;
ent.shaderRGBAf[2] = q3->shaderRGBA[2]/255.0f;
ent.shaderRGBAf[3] = q3->shaderRGBA[3]/255.0f;
#ifdef Q3SHADERS
ent.forcedshader = (void*)q3->customShader;
ent.forcedshader = VM_FROMSHANDLE(q3->customShader);
ent.shaderTime = q3->shaderTime;
#endif
if (q3->renderfx & Q3RF_FIRST_PERSON)
@ -557,21 +598,19 @@ void UI_RegisterFont(char *fontName, int pointSize, fontInfo_t *font)
Q_strncpyz(font->name, name, sizeof(font->name));
for (i = GLYPH_START; i < GLYPH_END; i++)
{
font->glyphs[i].glyph = (int)R_RegisterPic(font->glyphs[i].shaderName);
font->glyphs[i].glyph = VM_TOSHANDLE(R_RegisterPic(font->glyphs[i].shaderName));
}
}
}
#define VM_FROMHANDLE(a) ((void*)a)
#define VM_TOHANDLE(a) ((int)a)
#define VALIDATEPOINTER(o,l) if ((int)o + l >= mask || VM_POINTER(o) < offset) SV_Error("Call to ui trap %i passes invalid pointer\n", fn); //out of bounds.
#ifndef _DEBUG
static
#endif
long UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
int UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const int *arg)
{
int ret=0;
@ -728,7 +767,7 @@ long UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
case UI_R_REGISTERMODEL: //precache model
{
char *name = VM_POINTER(arg[0]);
VM_LONG(ret) = VM_TOHANDLE(Mod_ForName(name, false));
VM_LONG(ret) = VM_TOMHANDLE(Mod_ForName(name, false));
}
break;
case UI_R_MODELBOUNDS:
@ -736,7 +775,7 @@ long UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
VALIDATEPOINTER(arg[1], sizeof(vec3_t));
VALIDATEPOINTER(arg[2], sizeof(vec3_t));
{
model_t *mod = VM_FROMHANDLE(arg[0]);
model_t *mod = VM_FROMMHANDLE(arg[0]);
if (mod)
{
VectorCopy(mod->mins, ((float*)VM_POINTER(arg[1])));
@ -754,10 +793,7 @@ long UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
case UI_R_REGISTERSKIN:
{
char *buf;
char *skinname = VM_POINTER(arg[0]);
buf = Z_TagMalloc(strlen(skinname)+1, UITAGNUM);
strcpy(buf, skinname);
VM_LONG(ret) = (int)buf; //precache skin - engine ignores these anyway... (for now)
VM_LONG(ret) = VM_TOSTRCACHE(arg[0]);
}
break;
@ -768,9 +804,9 @@ long UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
if (!*(char*)VM_POINTER(arg[0]))
VM_LONG(ret) = 0;
else if (qrenderer == QR_OPENGL)
VM_LONG(ret) = (long)R_RegisterPic(VM_POINTER(arg[0]));
else
VM_LONG(ret) = (long)Draw_SafeCachePic(VM_POINTER(arg[0]));
VM_LONG(ret) = VM_TOSHANDLE(R_RegisterPic(VM_POINTER(arg[0])));
//FIXME: 64bit else
// VM_LONG(ret) = (long)Draw_SafeCachePic(VM_POINTER(arg[0]));
break;
case UI_R_CLEARSCENE: //clear scene
@ -801,16 +837,16 @@ long UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
// qglEnable(GL_BLEND);
// GL_TexEnv(GL_MODULATE);
if (qrenderer == QR_OPENGL)
GLDraw_ShaderImage(VM_FLOAT(arg[0]), VM_FLOAT(arg[1]), VM_FLOAT(arg[2]), VM_FLOAT(arg[3]), VM_FLOAT(arg[4]), VM_FLOAT(arg[5]), VM_FLOAT(arg[6]), VM_FLOAT(arg[7]), (void *)VM_LONG(arg[8]));
else
Draw_Image(VM_FLOAT(arg[0]), VM_FLOAT(arg[1]), VM_FLOAT(arg[2]), VM_FLOAT(arg[3]), VM_FLOAT(arg[4]), VM_FLOAT(arg[5]), VM_FLOAT(arg[6]), VM_FLOAT(arg[7]), (mpic_t *)VM_LONG(arg[8]));
GLDraw_ShaderImage(VM_FLOAT(arg[0]), VM_FLOAT(arg[1]), VM_FLOAT(arg[2]), VM_FLOAT(arg[3]), VM_FLOAT(arg[4]), VM_FLOAT(arg[5]), VM_FLOAT(arg[6]), VM_FLOAT(arg[7]), VM_FROMSHANDLE(arg[8]));
// else
// Draw_Image(VM_FLOAT(arg[0]), VM_FLOAT(arg[1]), VM_FLOAT(arg[2]), VM_FLOAT(arg[3]), VM_FLOAT(arg[4]), VM_FLOAT(arg[5]), VM_FLOAT(arg[6]), VM_FLOAT(arg[7]), (mpic_t *)VM_LONG(arg[8]));
break;
case UI_CM_LERPTAG: //Lerp tag...
// tag, model, startFrame, endFrame, frac, tagName
if ((int)arg[0] + sizeof(float)*12 >= mask || VM_POINTER(arg[0]) < offset)
break; //out of bounds.
VM_LerpTag(VM_POINTER(arg[0]), (model_t*)VM_LONG(arg[1]), VM_LONG(arg[2]), VM_LONG(arg[3]), VM_FLOAT(arg[4]), VM_POINTER(arg[5]));
VM_LerpTag(VM_POINTER(arg[0]), VM_FROMMHANDLE(arg[1]), VM_LONG(arg[2]), VM_LONG(arg[3]), VM_FLOAT(arg[4]), VM_POINTER(arg[5]));
break;
case UI_S_REGISTERSOUND:
@ -818,14 +854,14 @@ long UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
sfx_t *sfx;
sfx = S_PrecacheSound(va("../%s", VM_POINTER(arg[0])));
if (sfx)
VM_LONG(ret) = sfx->name - (char *)offset;
VM_LONG(ret) = VM_TOSTRCACHE(arg[0]); //return handle is the parameter they just gave
else
VM_LONG(ret) = -1;
}
break;
case UI_S_STARTLOCALSOUND:
if (VM_LONG(arg[0]) != -1 && arg[0])
S_LocalSound(VM_LONG(arg[0])+(char *)offset);
S_LocalSound(VM_FROMSTRCACHE(arg[0])); //now we can fix up the sound name
break;
case UI_KEY_GETOVERSTRIKEMODE:
@ -979,37 +1015,14 @@ long UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
break;
case UI_CVAR_REGISTER:
if ((int)arg[0] + sizeof(vmcvar_t) >= mask || VM_POINTER(arg[0]) < offset)
if (VM_OOB(arg[0], sizeof(vmcvar_t)))
break; //out of bounds.
{
vmcvar_t *vmc;
cvar_t *var;
vmc = VM_POINTER(arg[0]);
var = Cvar_Get(VM_POINTER(arg[1]), VM_POINTER(arg[2]), 0/*VM_LONG(arg[3])*/, "UI cvar");
if (!vmc)
break;
vmc->handle = (char *)var - (char *)offset;
return VMQ3_Cvar_Register(VM_POINTER(arg[0]), VM_POINTER(arg[1]), VM_POINTER(arg[2]), VM_LONG(arg[3]));
vmc->integer = var->value;
vmc->value = var->value;
vmc->modificationCount = var->modified;
Q_strncpyz(vmc->string, var->string, sizeof(vmc->string));
}
case UI_CVAR_UPDATE:
if ((int)arg[0] + sizeof(vmcvar_t) >= mask || VM_POINTER(arg[0]) < offset)
if (VM_OOB(arg[0], sizeof(vmcvar_t)))
break; //out of bounds.
{
cvar_t *var;
vmcvar_t *vmc;
vmc = VM_POINTER(arg[0]);
var = (cvar_t *)((int)vmc->handle + (char *)offset);
vmc->integer = var->value;
vmc->value = var->value;
vmc->modificationCount = var->modified;
Q_strncpyz(vmc->string, var->string, sizeof(vmc->string));
}
break;
return VMQ3_Cvar_Update(VM_POINTER(arg[0]));
case UI_MEMORY_REMAINING:
VM_LONG(ret) = Hunk_LowMemAvailable();
@ -1112,14 +1125,13 @@ long UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
case UI_CEIL:
VM_FLOAT(ret)=(float)ceil(VM_FLOAT(arg[0]));
break;
/*
case UI_CACHE_PIC:
if (!Draw_SafeCachePic)
VM_LONG(ret) = 0;
else
{
/*VM_LONG(ret) = (long)*/Draw_SafeCachePic(VM_POINTER(arg[0]));
VM_LONG(ret) = (long)R_RegisterPic(VM_POINTER(arg[0]));
VM_LONG(ret) = 0;//FIXME: 64bit (long)R_RegisterPic(VM_POINTER(arg[0]));
}
break;
case UI_PICFROMWAD:
@ -1127,8 +1139,7 @@ long UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
VM_LONG(ret) = 0;
else
{
/*VM_LONG(ret) = (long)*/Draw_SafePicFromWad(VM_POINTER(arg[0]));
VM_LONG(ret) = (long)R_RegisterPic(VM_POINTER(arg[0]));
VM_LONG(ret) = 0;//FIXME: 64bit (long)R_RegisterPic(VM_POINTER(arg[0]));
}
break;
case UI_GETPLAYERINFO:
@ -1225,7 +1236,7 @@ long UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
return strlen(str);
}
*/
case UI_PC_ADD_GLOBAL_DEFINE:
Con_Printf("UI_PC_ADD_GLOBAL_DEFINE not supported\n");
@ -1264,7 +1275,7 @@ long UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
}
#ifdef _DEBUG
static long UI_SystemCallsExWrapper(void *offset, unsigned int mask, int fn, const long *arg)
static int UI_SystemCallsExWrapper(void *offset, unsigned int mask, int fn, const int *arg)
{ //this is so we can use edit and continue properly (vc doesn't like function pointers for edit+continue)
return UI_SystemCallsEx(offset, mask, fn, arg);
}
@ -1275,7 +1286,7 @@ static long UI_SystemCallsExWrapper(void *offset, unsigned int mask, int fn, con
//but dlls call it without saying what sort of vm it comes from, so I've got to have them as specifics
static int EXPORT_FN UI_SystemCalls(int arg, ...)
{
long args[9];
int args[9];
va_list argptr;
va_start(argptr, arg);
@ -1295,26 +1306,35 @@ static int EXPORT_FN UI_SystemCalls(int arg, ...)
qboolean UI_DrawStatusBar(int scores)
{
return false;
/*
if (!uivm)
return false;
return VM_Call(uivm, UI_DRAWSTATUSBAR, scores);
*/
}
qboolean UI_DrawFinale(void)
{
return false;
/*
if (!uivm)
return false;
return VM_Call(uivm, UI_FINALE);
*/
}
qboolean UI_DrawIntermission(void)
{
return false;
/*
if (!uivm)
return false;
return VM_Call(uivm, UI_INTERMISSION);
*/
}
void UI_DrawMenu(void)
@ -1330,25 +1350,31 @@ void UI_DrawMenu(void)
qboolean UI_CenterPrint(char *text, qboolean finale)
{
scr_centerstring = text;
return false;
/*
if (!uivm)
return false;
return VM_Call(uivm, UI_STRINGCHANGED, SID_CENTERPRINTTEXT);
*/
}
qboolean UI_Q2LayoutChanged(void)
{
return false;
/*
if (!uivm)
return false;
return VM_Call(uivm, UI_STRINGCHANGED, SID_CENTERPRINTTEXT);
*/
}
void UI_StringChanged(int num)
{
if (uivm)
/* if (uivm)
VM_Call(uivm, UI_STRINGCHANGED, num);
*/
}
void UI_Reset(void)
@ -1467,15 +1493,11 @@ void UI_Start (void)
if (qrenderer != QR_OPENGL && qrenderer != QR_DIRECT3D)
return;
uivm = VM_Create(NULL, "vm/qwui", UI_SystemCalls, UI_SystemCallsEx);
if (!uivm) //broken currently, I believe.
uivm = VM_Create(NULL, "vm/ui", UI_SystemCalls, UI_SystemCallsEx);
uivm = VM_Create(NULL, "vm/ui", UI_SystemCalls, UI_SystemCallsEx);
if (uivm)
{
apiversion = VM_Call(uivm, UI_GETAPIVERSION, UI_API_VERSION);
if (apiversion == UI_API_VERSION)
keycatcher = 0;
else if (apiversion != 4 && apiversion != 6) //make sure we can run the thing
apiversion = VM_Call(uivm, UI_GETAPIVERSION, 6);
if (apiversion != 4 && apiversion != 6) //make sure we can run the thing
{
Con_Printf("User-Interface VM uses incompatable API version (%i)\n", apiversion);
VM_Destroy(uivm);

View file

@ -999,13 +999,10 @@ void Skin_FlushPlayers(void);
//valid.c
void Validation_FlushFileList(void);
void ValidationPrintVersion(char *f_query_string);
void Validation_Server(void);
void Validation_FilesModified (void);
void Validation_Skins(void);
void Validation_CheckIfResponse(char *text);
void InitValidation(void);
void Validation_IncludeFile(char *filename, char *file, int filelen);
void Validation_Auto_Response(int playernum, char *s);
extern qboolean f_modified_particles;
extern qboolean care_f_modified;

View file

@ -442,6 +442,7 @@ qboolean CLQ3_SystemInfoChanged(char *str)
char *pc, *pn;
char *rc, *rn;
Con_Printf("Server's sv_pure: \"%s\"\n", Info_ValueForKey(str, "sv_pure"));
usingpure = atoi(Info_ValueForKey(str, "sv_pure"));
usingcheats = atoi(Info_ValueForKey(str, "sv_cheats"));
Cvar_ForceCheatVars(usingpure||usingcheats, usingcheats);

View file

@ -247,14 +247,6 @@ typedef struct {
extern ClientConnectionState_t ccs;
typedef struct {
int handle;
int modificationCount;
float value;
int integer;
char string[256];
} vmcvar_t;
typedef enum {
svcq3_bad,
svcq3_nop,

File diff suppressed because it is too large Load diff

View file

@ -154,13 +154,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#undef QTERM //not supported - FIXME: move to native plugin
#endif
#ifdef __amd64__
//I'm slowly getting these working in 64bit
#undef Q3CLIENT
#undef Q3SERVER
#undef PLUGINS
#endif
#if (defined(Q2CLIENT) || defined(Q2SERVER))
#ifndef Q2BSPS
#error "Q2 game support without Q2BSP support. doesn't make sense"

View file

@ -2,7 +2,7 @@
#if defined(D3DQUAKE) || defined(RGLQUAKE) || defined(SERVERONLY)
#ifdef D3DQUAKE
#include "d3dquake.h"
//#include "d3dquake.h"
#endif
#ifdef RGLQUAKE
#include "glquake.h"
@ -2597,8 +2597,8 @@ qboolean Mod_LoadQ3Model(model_t *mod, void *buffer)
md3tag_t *src;
md3tag_t *dst;
src = (md3tag_t *)(((unsigned int)header)+LittleLong(header->ofsTags));
dst = (md3tag_t *)(((unsigned int)root)+root->ofstags);
src = (md3tag_t *)((char*)header+LittleLong(header->ofsTags));
dst = (md3tag_t *)((char*)root+root->ofstags);
for(i=0;i<LittleLong(header->numTags)*LittleLong(header->numFrames);i++)
{
memcpy(dst->name, src->name, sizeof(dst->name));

View file

@ -160,6 +160,8 @@ char *Cvar_FlagToName(int flag)
return "rendercallback";
case CVAR_NOUNSAFEEXPAND:
return "nounsafeexpand";
case CVAR_RULESETLATCH:
return "rulesetlatch";
}
return NULL;
@ -604,7 +606,7 @@ Cvar_Set
============
*/
cvar_t *Cvar_SetCore (cvar_t *var, const char *value, qboolean force)
{
{ //fixme: force should probably be a latch bitmask
char *latch=NULL;
if (!var)
@ -722,6 +724,47 @@ cvar_t *Cvar_SetCore (cvar_t *var, const char *value, qboolean force)
return var;
}
qboolean Cvar_ApplyLatchFlag(cvar_t *var, char *value, int flag)
{
qboolean result = true;
char *latch;
var->flags &= ~flag;
latch = var->latched_string;
var->latched_string = NULL;
if (!latch)
{
#ifndef _MSC_VER
#warning this means the callback will never be called
#endif
latch = var->string;
var->string = NULL;
}
#ifndef _MSC_VER
#warning set or forceset?
#endif
Cvar_Set(var, value);
if (var->latched_string)
{ //something else latched it
Z_Free(var->latched_string);
var->latched_string = NULL;
result = false;
}
else
var->flags |= flag;
if (latch)
{
if (!strcmp(var->string, latch))
Z_Free(latch); //don't allow a latch to be the same as the current value
else
var->latched_string = latch;
}
return result;
}
void Cvar_ForceCheatVars(qboolean semicheats, qboolean absolutecheats)
{ //this either unlatches if the cheat type is allowed, or enforces a default for full cheats and blank for semicheats.
//this is clientside only.
@ -741,6 +784,9 @@ void Cvar_ForceCheatVars(qboolean semicheats, qboolean absolutecheats)
var->latched_string = NULL;
if (!latch)
{
#ifndef _MSC_VER
#warning this means the callback will never be called
#endif
latch = var->string;
var->string = NULL;
}
@ -777,8 +823,8 @@ void Cvar_ApplyLatches(int latchflag)
int mask = ~0;
int of;
if (latchflag == CVAR_SERVEROVERRIDE) //these ones are cleared
mask = ~CVAR_SERVEROVERRIDE;
if (latchflag == CVAR_SERVEROVERRIDE || latchflag == CVAR_RULESETLATCH) //these ones are cleared
mask = ~latchflag;
for (grp=cvar_groups ; grp ; grp=grp->next)
for (var=grp->cvars ; var ; var=var->next)

View file

@ -1417,11 +1417,13 @@ void COM_Path_f (void)
if (com_purepaths)
{
Con_Printf ("Pure paths:\n");
for (s=com_purepaths ; s ; s=s->nextpure)
{
s->funcs->PrintPath(s->handle);
}
Con_Printf ("----------\n");
Con_Printf ("Impure paths:\n");
}
@ -1605,7 +1607,7 @@ void FS_FlushFSHash(void)
while(bucket)
{
next = bucket->next;
if (bucket->keystring == (char*)(bucket+1))
if (bucket->key.string == (char*)(bucket+1))
Z_Free(bucket);
bucket = next;
}
@ -2856,10 +2858,14 @@ void FS_ForceToPure(char *str, char *crcs, int seed)
if (!str)
{ //pure isn't in use.
if (com_purepaths)
Con_Printf("Pure FS deactivated\n");
com_purepaths = NULL;
FS_FlushFSHash();
return;
}
if (!com_purepaths)
Con_Printf("Pure FS activated\n");
for (sp = com_searchpaths; sp; sp = sp->next)
{

View file

@ -103,7 +103,7 @@ cvar_t plug_loaddefault = SCVAR("plug_loaddefault", "1");
#endif
//custom plugin builtins.
typedef int (VARGS *Plug_Builtin_t)(void *offset, unsigned int mask, const long *arg);
typedef int (VARGS *Plug_Builtin_t)(void *offset, unsigned int mask, const int *arg);
void Plug_RegisterBuiltin(char *name, Plug_Builtin_t bi, int flags);
#define PLUG_BIF_DLLONLY 1
#define PLUG_BIF_QVMONLY 2
@ -214,7 +214,7 @@ static void Plug_RegisterBuiltinIndex(char *name, Plug_Builtin_t bi, int flags,
}
*/
int VARGS Plug_FindBuiltin(void *offset, unsigned int mask, const long *args)
int VARGS Plug_FindBuiltin(void *offset, unsigned int mask, const int *args)
{
int i;
for (i = 0; i < numplugbuiltins; i++)
@ -231,7 +231,7 @@ int VARGS Plug_FindBuiltin(void *offset, unsigned int mask, const long *args)
return 0;
}
long Plug_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
int Plug_SystemCallsEx(void *offset, unsigned int mask, int fn, const int *arg)
{
fn = fn+1;
@ -243,7 +243,7 @@ long Plug_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg
}
#ifdef _DEBUG
static long Plug_SystemCallsExWrapper(void *offset, unsigned int mask, int fn, const long *arg)
static int Plug_SystemCallsExWrapper(void *offset, unsigned int mask, int fn, const int *arg)
{ //this is so we can use edit and continue properly (vc doesn't like function pointers for edit+continue)
return Plug_SystemCallsEx(offset, mask, fn, arg);
}
@ -254,7 +254,7 @@ static long Plug_SystemCallsExWrapper(void *offset, unsigned int mask, int fn, c
//but dlls call it without saying what sort of vm it comes from, so I've got to have them as specifics
static int EXPORT_FN Plug_SystemCalls(int arg, ...)
{
long args[9];
int args[9];
va_list argptr;
va_start(argptr, arg);
@ -282,7 +282,7 @@ static int EXPORT_FN Plug_SystemCalls(int arg, ...)
plugin_t *Plug_Load(char *file)
{
plugin_t *newplug;
long argarray;
int argarray;
for (newplug = plugs; newplug; newplug = newplug->next)
{
@ -336,23 +336,23 @@ int Plug_Emumerated (char *name, int size, void *param)
return true;
}
int VARGS Plug_Con_Print(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Con_Print(void *offset, unsigned int mask, const int *arg)
{
// if (qrenderer <= 0)
// return false;
Con_Printf("%s", (char*)VM_POINTER(arg[0]));
return 0;
}
int VARGS Plug_Sys_Error(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Sys_Error(void *offset, unsigned int mask, const int *arg)
{
Sys_Error("%s", (char*)offset+arg[0]);
return 0;
}
int VARGS Plug_Sys_Milliseconds(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Sys_Milliseconds(void *offset, unsigned int mask, const int *arg)
{
return Sys_DoubleTime()*1000;
}
int VARGS Plug_ExportToEngine(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_ExportToEngine(void *offset, unsigned int mask, const int *arg)
{
char *name = (char*)VM_POINTER(arg[0]);
if (!strcmp(name, "Tick"))
@ -387,7 +387,7 @@ int VARGS Plug_ExportToEngine(void *offset, unsigned int mask, const long *arg)
}
//retrieve a plugin's name
int VARGS Plug_GetPluginName(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_GetPluginName(void *offset, unsigned int mask, const int *arg)
{
int plugnum = VM_LONG(arg[0]);
plugin_t *plug;
@ -414,7 +414,7 @@ int VARGS Plug_GetPluginName(void *offset, unsigned int mask, const long *arg)
}
typedef void (*funcptr_t) ();
int VARGS Plug_ExportNative(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_ExportNative(void *offset, unsigned int mask, const int *arg)
{
funcptr_t func;
char *name = (char*)VM_POINTER(arg[0]);
@ -470,7 +470,7 @@ typedef struct {
int plugincvararraylen;
plugincvararray_t *plugincvararray;
//qhandle_t Cvar_Register (char *name, char *defaultval, int flags, char *grouphint);
int VARGS Plug_Cvar_Register(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Cvar_Register(void *offset, unsigned int mask, const int *arg)
{
char *name = VM_POINTER(arg[0]);
char *defaultvalue = VM_POINTER(arg[1]);
@ -491,14 +491,15 @@ int VARGS Plug_Cvar_Register(void *offset, unsigned int mask, const long *arg)
}
}
plugincvararray = BZ_Realloc(plugincvararray, (plugincvararraylen+1)*sizeof(plugincvararray_t));
plugincvararray[plugincvararraylen].plugin = currentplug;
plugincvararray[plugincvararraylen].var = var;
i = plugincvararraylen;
plugincvararraylen++;
return plugincvararraylen-1;
plugincvararray = BZ_Realloc(plugincvararray, (plugincvararraylen)*sizeof(plugincvararray_t));
plugincvararray[i].plugin = currentplug;
plugincvararray[i].var = var;
return i;
}
//int Cvar_Update, (qhandle_t handle, int modificationcount, char *stringv, float *floatv)); //stringv is 256 chars long, don't expect this function to do anything if modification count is unchanged.
int VARGS Plug_Cvar_Update(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Cvar_Update(void *offset, unsigned int mask, const int *arg)
{
int handle;
int modcount;
@ -528,7 +529,7 @@ int VARGS Plug_Cvar_Update(void *offset, unsigned int mask, const long *arg)
}
//void Cmd_Args(char *buffer, int buffersize)
int VARGS Plug_Cmd_Args(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Cmd_Args(void *offset, unsigned int mask, const int *arg)
{
char *buffer = (char*)VM_POINTER(arg[0]);
char *args;
@ -539,7 +540,7 @@ int VARGS Plug_Cmd_Args(void *offset, unsigned int mask, const long *arg)
return 1;
}
//void Cmd_Argv(int num, char *buffer, int buffersize)
int VARGS Plug_Cmd_Argv(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Cmd_Argv(void *offset, unsigned int mask, const int *arg)
{
char *buffer = (char*)VM_POINTER(arg[1]);
char *args;
@ -550,13 +551,13 @@ int VARGS Plug_Cmd_Argv(void *offset, unsigned int mask, const long *arg)
return 1;
}
//int Cmd_Argc(void)
int VARGS Plug_Cmd_Argc(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Cmd_Argc(void *offset, unsigned int mask, const int *arg)
{
return Cmd_Argc();
}
//void Cvar_SetString (char *name, char *value);
int VARGS Plug_Cvar_SetString(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Cvar_SetString(void *offset, unsigned int mask, const int *arg)
{
char *name = VM_POINTER(arg[0]),
*value = VM_POINTER(arg[1]);
@ -571,7 +572,7 @@ int VARGS Plug_Cvar_SetString(void *offset, unsigned int mask, const long *arg)
}
//void Cvar_SetFloat (char *name, float value);
int VARGS Plug_Cvar_SetFloat(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Cvar_SetFloat(void *offset, unsigned int mask, const int *arg)
{
char *name = VM_POINTER(arg[0]);
float value = VM_FLOAT(arg[1]);
@ -586,7 +587,7 @@ int VARGS Plug_Cvar_SetFloat(void *offset, unsigned int mask, const long *arg)
}
//void Cvar_GetFloat (char *name);
int VARGS Plug_Cvar_GetFloat(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Cvar_GetFloat(void *offset, unsigned int mask, const int *arg)
{
char *name = VM_POINTER(arg[0]);
int ret;
@ -601,7 +602,7 @@ int VARGS Plug_Cvar_GetFloat(void *offset, unsigned int mask, const long *arg)
}
//qboolean Cvar_GetString (char *name, char *retstring, int sizeofretstring);
int VARGS Plug_Cvar_GetString(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Cvar_GetString(void *offset, unsigned int mask, const int *arg)
{
char *name, *ret;
int retsize;
@ -626,7 +627,7 @@ int VARGS Plug_Cvar_GetString(void *offset, unsigned int mask, const long *arg)
}
//void Cmd_AddText (char *text, qboolean insert); //abort the entire engine.
int VARGS Plug_Cmd_AddText(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Cmd_AddText(void *offset, unsigned int mask, const int *arg)
{
if (VM_LONG(arg[1]))
Cbuf_InsertText(VM_POINTER(arg[0]), RESTRICT_LOCAL, false);
@ -665,7 +666,7 @@ void Plug_Command_f(void)
currentplug = oldplug;
}
int VARGS Plug_Cmd_AddCommand(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Cmd_AddCommand(void *offset, unsigned int mask, const int *arg)
{
int i;
char *name = VM_POINTER(arg[0]);
@ -756,7 +757,7 @@ int Plug_NewStreamHandle(plugstream_e type)
//EBUILTIN(int, NET_TCPListen, (char *ip, int port, int maxcount));
//returns a new socket with listen enabled.
int VARGS Plug_Net_TCPListen(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Net_TCPListen(void *offset, unsigned int mask, const int *arg)
{
int handle;
int sock;
@ -815,7 +816,7 @@ int VARGS Plug_Net_TCPListen(void *offset, unsigned int mask, const long *arg)
return handle;
}
int VARGS Plug_Net_Accept(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Net_Accept(void *offset, unsigned int mask, const int *arg)
{
int handle = VM_LONG(arg[0]);
struct sockaddr_in address;
@ -854,7 +855,7 @@ int VARGS Plug_Net_Accept(void *offset, unsigned int mask, const long *arg)
return handle;
}
//EBUILTIN(int, NET_TCPConnect, (char *ip, int port));
int VARGS Plug_Net_TCPConnect(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Net_TCPConnect(void *offset, unsigned int mask, const int *arg)
{
char *localip = VM_POINTER(arg[0]);
unsigned short localport = VM_LONG(arg[1]);
@ -910,7 +911,7 @@ int VARGS Plug_Net_TCPConnect(void *offset, unsigned int mask, const long *arg)
#ifdef GNUTLS
int VARGS Plug_Net_SetTLSClient(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Net_SetTLSClient(void *offset, unsigned int mask, const int *arg)
{
static gnutls_anon_client_credentials anoncred;
static gnutls_certificate_credentials xcred;
@ -1006,7 +1007,7 @@ int VARGS Plug_Net_SetTLSClient(void *offset, unsigned int mask, const long *arg
}
#endif
int VARGS Plug_FS_Open(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_FS_Open(void *offset, unsigned int mask, const int *arg)
{
//modes:
//1: read
@ -1061,7 +1062,7 @@ int VARGS Plug_FS_Open(void *offset, unsigned int mask, const long *arg)
return -2;
}
int VARGS Plug_memset(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_memset(void *offset, unsigned int mask, const int *arg)
{
if (VM_OOB(arg[0], arg[2]))
return false;
@ -1069,7 +1070,7 @@ int VARGS Plug_memset(void *offset, unsigned int mask, const long *arg)
memset(VM_POINTER(arg[0]), VM_LONG(arg[1]), VM_LONG(arg[2]));
return arg[0];
}
int VARGS Plug_memcpy(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_memcpy(void *offset, unsigned int mask, const int *arg)
{
if (VM_OOB(arg[0], arg[2]))
return false;
@ -1079,7 +1080,7 @@ int VARGS Plug_memcpy(void *offset, unsigned int mask, const long *arg)
memcpy(VM_POINTER(arg[0]), VM_POINTER(arg[1]), VM_LONG(arg[2]));
return arg[0];
}
int VARGS Plug_memmove(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_memmove(void *offset, unsigned int mask, const int *arg)
{
if (VM_OOB(arg[0], arg[2]))
return false;
@ -1090,32 +1091,32 @@ int VARGS Plug_memmove(void *offset, unsigned int mask, const long *arg)
return arg[0];
}
int VARGS Plug_sqrt(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_sqrt(void *offset, unsigned int mask, const int *arg)
{
int ret;
VM_FLOAT(ret) = sqrt(VM_FLOAT(arg[0]));
return ret;
}
int VARGS Plug_sin(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_sin(void *offset, unsigned int mask, const int *arg)
{
int ret;
VM_FLOAT(ret) = sin(VM_FLOAT(arg[0]));
return ret;
}
int VARGS Plug_cos(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_cos(void *offset, unsigned int mask, const int *arg)
{
int ret;
VM_FLOAT(ret) = cos(VM_FLOAT(arg[0]));
return ret;
}
int VARGS Plug_atan2(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_atan2(void *offset, unsigned int mask, const int *arg)
{
int ret;
VM_FLOAT(ret) = atan2(VM_FLOAT(arg[0]), VM_FLOAT(arg[1]));
return ret;
}
int VARGS Plug_Net_Recv(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Net_Recv(void *offset, unsigned int mask, const int *arg)
{
int read;
int handle = VM_LONG(arg[0]);
@ -1172,7 +1173,7 @@ int VARGS Plug_Net_Recv(void *offset, unsigned int mask, const long *arg)
return -2;
}
}
int VARGS Plug_Net_Send(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Net_Send(void *offset, unsigned int mask, const int *arg)
{
int written;
int handle = VM_LONG(arg[0]);
@ -1228,7 +1229,7 @@ int VARGS Plug_Net_Send(void *offset, unsigned int mask, const long *arg)
return -2;
}
}
int VARGS Plug_Net_SendTo(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Net_SendTo(void *offset, unsigned int mask, const int *arg)
{
int written;
int handle = VM_LONG(arg[0]);
@ -1296,7 +1297,7 @@ void Plug_Net_Close_Internal(int handle)
pluginstreamarray[handle].plugin = NULL;
}
int VARGS Plug_Net_Close(void *offset, unsigned int mask, const long *arg)
int VARGS Plug_Net_Close(void *offset, unsigned int mask, const int *arg)
{
int handle = VM_LONG(arg[0]);
if (handle < 0 || handle >= pluginstreamarraylen || pluginstreamarray[handle].plugin != currentplug)
@ -1328,7 +1329,7 @@ void Plug_Load_f(void)
}
}
/*
static long Test_SysCalls_Ex(void *offset, unsigned int mask, int fn, const long *arg)
static int Test_SysCalls_Ex(void *offset, unsigned int mask, int fn, const int *arg)
{
switch(fn)
{

View file

@ -308,8 +308,56 @@ int VM_GetFileList(char *path, char *ext, char *output, int buffersize)
#include "clq3defs.h" //okay, urr, this is bad for dedicated servers. urhum. Maybe they're not looking? It's only typedefs and one extern.
#define MAX_VMQ3_CVARS 256 //can be blindly increased
cvar_t *q3cvlist[MAX_VMQ3_CVARS];
int VMQ3_Cvar_Register(vmcvar_t *v, char *name, char *defval, int flags)
{
int i;
cvar_t *c = Cvar_Get(name, defval, 0, "Q3VM cvars");
if (!c) //command name, etc
return 0;
for (i = 0; i < MAX_VMQ3_CVARS; i++)
{
if (!q3cvlist[i])
q3cvlist[i] = c;
if (q3cvlist[i] == c)
{
if (v)
{
v->handle = i+1;
VMQ3_Cvar_Update(v);
}
return i+1;
}
}
Con_Printf("Ran out of VMQ3 cvar handles\n");
return 0;
}
int VMQ3_Cvar_Update(vmcvar_t *v)
{
cvar_t *c;
int i;
i = v->handle;
if (!i)
return 0; //not initialised
i--;
if ((unsigned)i >= MAX_VMQ3_CVARS)
return 0; //a hack attempt
c = q3cvlist[i];
if (!c)
return 0; //that slot isn't active yet
v->integer = c->value;
v->value = c->value;
v->modificationCount = c->modified;
Q_strncpyz(v->string, c->string, sizeof(v->string));
return 1;
}
/*

View file

@ -93,7 +93,6 @@ typedef struct {
char messageString[MAX_STRING_CHARS];
} uiClientState_t;
#define UI_API_VERSION 5000
typedef enum {
UI_GETAPIVERSION = 0, // system reserved
@ -128,12 +127,15 @@ typedef enum {
// overlayed over whatever the cgame has drawn.
// a GetClientState syscall will be made to get the current strings
/*
UI_DRAWSTATUSBAR = 500,
UI_MOUSE_POS,
UI_INTERMISSION,
UI_FINALE,
UI_STRINGCHANGED, //parma is the string id
UI_NEWSERVER //indicates that all the strings have changed.
*/
} uiExport_t;
typedef enum {
@ -236,12 +238,12 @@ typedef enum {
UI_SQRT,
UI_FLOOR,
UI_CEIL,
/*
UI_CACHE_PIC = 500,
UI_PICFROMWAD = 501,
UI_GETPLAYERINFO = 502,
UI_GETSTAT = 503,
UI_GETVIDINFO = 504,
UI_GET_STRING = 510,
*/
} uiImport_t;

View file

@ -94,4 +94,14 @@ qboolean CG_Command(void);
qboolean CG_KeyPress(int key, int down);
#endif
typedef struct {
int handle;
int modificationCount;
float value;
int integer;
char string[256];
} vmcvar_t;
int VMQ3_Cvar_Register(vmcvar_t *v, char *name, char *defval, int flags);
int VMQ3_Cvar_Update(vmcvar_t *v);
#endif

View file

@ -1,3 +1,10 @@
#ifndef __D3DQUAKE_H__
#define __D3DQUAKE_H__
#ifdef __GNUC__
#define _inline static inline
#endif
#include "ddraw.h"
#include "d3d.h"
#include "d3dx.h"
@ -71,3 +78,6 @@ extern lightmapinfo_t **lightmap;
extern void *d3dexplosiontexture;
extern void *d3dballtexture;
#endif

View file

@ -1,5 +1,6 @@
#include "quakedef.h"
#ifdef D3DQUAKE
#include "winquake.h"
#include "d3dquake.h"

View file

@ -1,5 +1,6 @@
#include "quakedef.h"
#ifdef D3DQUAKE
#include "winquake.h"
#include "d3d9quake.h"
#define MAX_WIDTH 512

View file

@ -1,5 +1,6 @@
#include "quakedef.h"
#ifdef D3DQUAKE
#include "winquake.h"
#include "d3d9quake.h"
mleaf_t *r_viewleaf, *r_oldviewleaf;

View file

@ -1,5 +1,6 @@
#include "quakedef.h"
#ifdef D3DQUAKE
#include "winquake.h"
#include "d3d9quake.h"
int numlightmaps;

View file

@ -1,6 +1,7 @@
#include "quakedef.h"
#ifdef D3DQUAKE
#include "d3d9quake.h"
#include "winquake.h"
#include "d3d9quake.h"
//#include "d3d9.h"
@ -526,7 +527,7 @@ void resetD3D9(void)
}
#if WINVER < 0x500
#if (WINVER < 0x500) && !defined(__GNUC__)
typedef struct tagMONITORINFO
{
DWORD cbSize;

View file

@ -147,13 +147,13 @@ cvar_t r_shownormals = SCVAR("r_shownormals", "1");
float Q_rsqrt( float number )
{
long i;
int i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = * ( int * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration

View file

@ -363,6 +363,8 @@ mpic_t *GLDraw_SafePicFromWad (char *name)
mpic_t *GLDraw_SafeCachePic (char *path)
{
//this is EVIL! WRITE IT!
int height = 0;
qbyte *data;
glcachepic_t *pic;

View file

@ -378,6 +378,7 @@ iwboolean FTP_ClientConnThink (FTPclientconn_t *con) //true to kill con
if (temp != INVALID_SOCKET)
{
int _true = true;
ioctlsocket(temp, FIONBIO, &_true);
con->stage = 6;
if (con->type == ftp_getting)

View file

@ -45,12 +45,11 @@ typedef struct FTPclient_s{
FTPclient_t *FTPclient;
qboolean FTP_ServerInit(void)
qboolean FTP_ServerInit(int port)
{
struct sockaddr_in address;
unsigned long _true = true;
int i;
int port = 21;
if ((ftpserversocket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
{
@ -752,7 +751,7 @@ unsigned int WINAPI BlockingClient(FTPclient_t *cl)
}
#endif
iwboolean FTP_ServerRun(iwboolean ftpserverwanted)
iwboolean FTP_ServerRun(iwboolean ftpserverwanted, int port)
{
FTPclient_t *cl, *prevcl;
struct sockaddr_in from;
@ -763,7 +762,7 @@ unsigned long _true = true;
if (!ftpserverinitied)
{
if (ftpserverwanted)
return FTP_ServerInit();
return FTP_ServerInit(port);
return false;
}
else if (!ftpserverwanted)

View file

@ -16,12 +16,11 @@ typedef enum {HTTP_WAITINGFORREQUEST,HTTP_SENDING} http_mode_t;
qboolean HTTP_ServerInit(void)
qboolean HTTP_ServerInit(int port)
{
struct sockaddr_in address;
unsigned long _true = true;
int i;
int port = 80;
if ((httpserversocket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
{
@ -332,10 +331,15 @@ cont:
}
else if (!stricmp(mode, "GET") || !stricmp(mode, "HEAD") || !stricmp(mode, "POST"))
{
if (*resource != '/')
resource[1] = 0; //I'm lazy, they need to comply
Con_Printf("Download request for \"%s\"\n", resource+1);
if (!strnicmp(mode, "P", 1)) //when stuff is posted, data is provided. Give an error message if we couldn't do anything with that data.
cl->file = IWebGenerateFile(resource+1, content, contentlen);
else if (!SV_AllowDownload(resource+1))
cl->file = NULL;
else
cl->file = FS_OpenVFS(resource, "rb", FS_GAME);
cl->file = FS_OpenVFS(resource+1, "rb", FS_GAME);
if (!cl->file)
{
if (HTTPmarkup >= 3)
@ -477,7 +481,7 @@ notimplemented:
}
}
qboolean HTTP_ServerPoll(qboolean httpserverwanted) //loop while true
qboolean HTTP_ServerPoll(qboolean httpserverwanted, int portnum) //loop while true
{
struct sockaddr_in from;
int fromlen;
@ -489,7 +493,7 @@ qboolean HTTP_ServerPoll(qboolean httpserverwanted) //loop while true
if (!httpserverinitied)
{
if (httpserverwanted)
return HTTP_ServerInit();
return HTTP_ServerInit(portnum);
return false;
}
else if (!httpserverwanted)
@ -523,7 +527,14 @@ qboolean HTTP_ServerPoll(qboolean httpserverwanted) //loop while true
return false;
}
ioctlsocket(clientsock, FIONBIO, &_true);
if (ioctlsocket (clientsock, FIONBIO, &_true) == -1)
{
Con_Printf ("HTTP_ServerInit: ioctl FIONBIO: %s\n", strerror(qerrno));
closesocket(clientsock);
return false;
}
Con_Printf("New connection\n");
cl = IWebMalloc(sizeof(HTTP_active_connections_t));

View file

@ -120,8 +120,8 @@ char *Q_strcpyline(char *out, char *in, int maxlen);
iwboolean FTP_StringToAdr (const char *s, qbyte ip[4], qbyte port[2]);
//server tick/control functions
iwboolean FTP_ServerRun(iwboolean ftpserverwanted);
qboolean HTTP_ServerPoll(qboolean httpserverwanted);
iwboolean FTP_ServerRun(iwboolean ftpserverwanted, int port);
qboolean HTTP_ServerPoll(qboolean httpserverwanted, int port);
void HTTP_CL_Think(void);
qboolean HTTP_CL_Get(char *url, char *localfile, void (*NotifyFunction)(char *localfile, qboolean sucess));

View file

@ -311,7 +311,9 @@ IWEBFILE *IWebFOpenRead(char *name) //fread(name, "rb");
#ifndef CLIENTONLY
cvar_t ftpserver = SCVAR("sv_ftp", "0");
cvar_t ftpserver_port = SCVAR("sv_ftp_port", "21");
cvar_t httpserver = SCVAR("sv_http", "0");
cvar_t httpserver_port = SCVAR("sv_http_port", "80");
cvar_t sv_readlevel = SCVAR("sv_readlevel", "0"); //default to allow anyone
cvar_t sv_writelevel = SCVAR("sv_writelevel", "35"); //allowed to write to uploads/uname
cvar_t sv_fulllevel = SCVAR("sv_fulllevel", "51"); //allowed to write anywhere, replace any file...
@ -364,7 +366,17 @@ void IWebInit(void)
Cvar_Register(&sv_readlevel, "Internet Server Access");
Cvar_Register(&ftpserver, "Internet Server Access");
Cvar_Register(&ftpserver_port, "Internet Server Access");
Cvar_Register(&httpserver, "Internet Server Access");
Cvar_Register(&httpserver_port, "Internet Server Access");
//don't allow these to be changed easily
//this basically blocks these from rcon / stuffcmd
ftpserver.restriction = RESTRICT_MAX;
httpserver.restriction = RESTRICT_MAX;
sv_fulllevel.restriction = RESTRICT_MAX;
sv_writelevel.restriction = RESTRICT_MAX;
sv_readlevel.restriction = RESTRICT_MAX;
#endif
}
void IWebRun(void)
@ -372,8 +384,8 @@ void IWebRun(void)
#ifdef WEBSERVER
extern qboolean httpserverfailed, ftpserverfailed;
FTP_ServerRun(ftpserver.value!= 0);
HTTP_ServerPoll(httpserver.value!=0);
FTP_ServerRun(ftpserver.value!= 0, ftpserver_port.value);
HTTP_ServerPoll(httpserver.value!=0, httpserver_port.value);
if (ftpserverfailed)
{
Con_Printf("FTP Server failed to load, setting %s to 0\n", ftpserver.name);

View file

@ -321,7 +321,7 @@ typedef struct {
IWebFile_t IWebFiles[] = {
{"allplayers.html", IWeb_GenerateRankingsFile},
{"index.html", IWeb_GenerateIndexFile},
{"admin.html", IWeb_GenerateAdminFile}
//code is too flawed for this {"admin.html", IWeb_GenerateAdminFile}
};
typedef struct {
@ -409,6 +409,7 @@ vfsfile_t *IWebGenerateFile(char *name, char *content, int contentlength)
int fnum;
char *parms;
int len;
IWeb_FileGen_t *fbuf;
if (!sv.state)
return NULL;
@ -434,7 +435,7 @@ vfsfile_t *IWebGenerateFile(char *name, char *content, int contentlength)
{
if (IWebFiles[fnum].buffer)
{
if (IWebFiles[fnum].lastgenerationtime+10 < Sys_DoubleTime() || contentlength||*parms) //10 sec lifetime
if (IWebFiles[fnum].lastgenerationtime < Sys_DoubleTime())
{
IWebFiles[fnum].buffer->references--; //remove our reference and check free
if (IWebFiles[fnum].buffer->references<=0)
@ -452,7 +453,8 @@ vfsfile_t *IWebGenerateFile(char *name, char *content, int contentlength)
IWebFiles[fnum].buffer = IWeb_GenerationBuffer;
//so it can't be sent once and freed instantly.
IWebFiles[fnum].lastgenerationtime = Sys_DoubleTime();
if (contentlength)
IWebFiles[fnum].lastgenerationtime = Sys_DoubleTime()+10;
}
IWebFiles[fnum].buffer->references++;
IWeb_GenerationBuffer = NULL;

View file

@ -212,7 +212,7 @@ DECLARE_INTERFACE_(IDirect3D, IUnknown)
STDMETHOD(FindDevice)(THIS_ LPD3DFINDDEVICESEARCH,LPD3DFINDDEVICERESULT) PURE;
};
typedef struct IDirect3D *LPDIRECT3D;
//*sigh*... typedef struct IDirect3D *LPDIRECT3D;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -256,7 +256,7 @@ DECLARE_INTERFACE_(IDirect3D2, IUnknown)
STDMETHOD(CreateDevice)(THIS_ REFCLSID,LPDIRECTDRAWSURFACE,LPDIRECT3DDEVICE2*) PURE;
};
typedef struct IDirect3D2 *LPDIRECT3D2;
//typedef struct IDirect3D2 *LPDIRECT3D2;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3D2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -304,7 +304,7 @@ DECLARE_INTERFACE_(IDirect3D3, IUnknown)
STDMETHOD(EvictManagedTextures)(THIS) PURE;
};
typedef struct IDirect3D3 *LPDIRECT3D3;
//this could take a while typedef struct IDirect3D3 *LPDIRECT3D3;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3D3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -354,7 +354,7 @@ DECLARE_INTERFACE_(IDirect3D7, IUnknown)
STDMETHOD(EvictManagedTextures)(THIS) PURE;
};
typedef struct IDirect3D7 *LPDIRECT3D7;
//gcc is kinda fussy typedef struct IDirect3D7 *LPDIRECT3D7;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3D7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -411,7 +411,7 @@ DECLARE_INTERFACE_(IDirect3DDevice, IUnknown)
STDMETHOD(GetDirect3D)(THIS_ LPDIRECT3D*) PURE;
};
typedef struct IDirect3DDevice *LPDIRECT3DDEVICE;
//getting bored already typedef struct IDirect3DDevice *LPDIRECT3DDEVICE;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -505,7 +505,7 @@ DECLARE_INTERFACE_(IDirect3DDevice2, IUnknown)
STDMETHOD(GetClipStatus)(THIS_ LPD3DCLIPSTATUS) PURE;
};
typedef struct IDirect3DDevice2 *LPDIRECT3DDEVICE2;
//typedef struct IDirect3DDevice2 *LPDIRECT3DDEVICE2;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -631,7 +631,7 @@ DECLARE_INTERFACE_(IDirect3DDevice3, IUnknown)
STDMETHOD(ValidateDevice)(THIS_ LPDWORD) PURE;
};
typedef struct IDirect3DDevice3 *LPDIRECT3DDEVICE3;
//dum de dum typedef struct IDirect3DDevice3 *LPDIRECT3DDEVICE3;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DDevice3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -782,7 +782,7 @@ DECLARE_INTERFACE_(IDirect3DDevice7, IUnknown)
STDMETHOD(GetInfo)(THIS_ DWORD,LPVOID,DWORD) PURE;
};
typedef struct IDirect3DDevice7 *LPDIRECT3DDEVICE7;
//they are at least consistant typedef struct IDirect3DDevice7 *LPDIRECT3DDEVICE7;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -910,7 +910,7 @@ DECLARE_INTERFACE_(IDirect3DExecuteBuffer, IUnknown)
STDMETHOD(Optimize)(THIS_ DWORD) PURE;
};
typedef struct IDirect3DExecuteBuffer *LPDIRECT3DEXECUTEBUFFER;
//did anyone ever like this object anyway? typedef struct IDirect3DExecuteBuffer *LPDIRECT3DEXECUTEBUFFER;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DExecuteBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -955,7 +955,7 @@ DECLARE_INTERFACE_(IDirect3DLight, IUnknown)
STDMETHOD(GetLight)(THIS_ LPD3DLIGHT) PURE;
};
typedef struct IDirect3DLight *LPDIRECT3DLIGHT;
//slow typedef struct IDirect3DLight *LPDIRECT3DLIGHT;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DLight_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -995,7 +995,7 @@ DECLARE_INTERFACE_(IDirect3DMaterial, IUnknown)
STDMETHOD(Unreserve)(THIS) PURE;
};
typedef struct IDirect3DMaterial *LPDIRECT3DMATERIAL;
//so many of these! typedef struct IDirect3DMaterial *LPDIRECT3DMATERIAL;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DMaterial_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -1036,7 +1036,7 @@ DECLARE_INTERFACE_(IDirect3DMaterial2, IUnknown)
STDMETHOD(GetHandle)(THIS_ LPDIRECT3DDEVICE2,LPD3DMATERIALHANDLE) PURE;
};
typedef struct IDirect3DMaterial2 *LPDIRECT3DMATERIAL2;
//and other errors to fix after these, lucky me! typedef struct IDirect3DMaterial2 *LPDIRECT3DMATERIAL2;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DMaterial2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -1072,7 +1072,7 @@ DECLARE_INTERFACE_(IDirect3DMaterial3, IUnknown)
STDMETHOD(GetHandle)(THIS_ LPDIRECT3DDEVICE3,LPD3DMATERIALHANDLE) PURE;
};
typedef struct IDirect3DMaterial3 *LPDIRECT3DMATERIAL3;
//this is getting dull typedef struct IDirect3DMaterial3 *LPDIRECT3DMATERIAL3;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DMaterial3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -1112,7 +1112,7 @@ DECLARE_INTERFACE_(IDirect3DTexture, IUnknown)
STDMETHOD(Unload)(THIS) PURE;
};
typedef struct IDirect3DTexture *LPDIRECT3DTEXTURE;
//monkey typedef struct IDirect3DTexture *LPDIRECT3DTEXTURE;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DTexture_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -1151,7 +1151,7 @@ DECLARE_INTERFACE_(IDirect3DTexture2, IUnknown)
STDMETHOD(Load)(THIS_ LPDIRECT3DTEXTURE2) PURE;
};
typedef struct IDirect3DTexture2 *LPDIRECT3DTEXTURE2;
//*snore* typedef struct IDirect3DTexture2 *LPDIRECT3DTEXTURE2;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DTexture2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -1199,7 +1199,7 @@ DECLARE_INTERFACE_(IDirect3DViewport, IUnknown)
STDMETHOD(NextLight)(THIS_ LPDIRECT3DLIGHT,LPDIRECT3DLIGHT*,DWORD) PURE;
};
typedef struct IDirect3DViewport *LPDIRECT3DVIEWPORT;
//*yawn* typedef struct IDirect3DViewport *LPDIRECT3DVIEWPORT;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DViewport_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -1266,7 +1266,7 @@ DECLARE_INTERFACE_(IDirect3DViewport2, IDirect3DViewport)
STDMETHOD(SetViewport2)(THIS_ LPD3DVIEWPORT2) PURE;
};
typedef struct IDirect3DViewport2 *LPDIRECT3DVIEWPORT2;
//they could have coded this right in the first place, you know typedef struct IDirect3DViewport2 *LPDIRECT3DVIEWPORT2;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DViewport2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -1342,7 +1342,7 @@ DECLARE_INTERFACE_(IDirect3DViewport3, IDirect3DViewport2)
STDMETHOD(Clear2)(THIS_ DWORD,LPD3DRECT,DWORD,D3DCOLOR,D3DVALUE,DWORD) PURE;
};
typedef struct IDirect3DViewport3 *LPDIRECT3DVIEWPORT3;
//not too many of these left to go typedef struct IDirect3DViewport3 *LPDIRECT3DVIEWPORT3;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DViewport3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -1410,7 +1410,7 @@ DECLARE_INTERFACE_(IDirect3DVertexBuffer, IUnknown)
STDMETHOD(Optimize)(THIS_ LPDIRECT3DDEVICE3,DWORD) PURE;
};
typedef struct IDirect3DVertexBuffer *LPDIRECT3DVERTEXBUFFER;
//nearly there typedef struct IDirect3DVertexBuffer *LPDIRECT3DVERTEXBUFFER;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DVertexBuffer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
@ -1453,7 +1453,7 @@ DECLARE_INTERFACE_(IDirect3DVertexBuffer7, IUnknown)
STDMETHOD(ProcessVerticesStrided)(THIS_ DWORD,DWORD,DWORD,LPD3DDRAWPRIMITIVESTRIDEDDATA,DWORD,LPDIRECT3DDEVICE7,DWORD) PURE;
};
typedef struct IDirect3DVertexBuffer7 *LPDIRECT3DVERTEXBUFFER7;
//well that was painful typedef struct IDirect3DVertexBuffer7 *LPDIRECT3DVERTEXBUFFER7;
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDirect3DVertexBuffer7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)

View file

@ -45,7 +45,7 @@ void *Hash_Get(hashtable_t *table, char *name)
while(buck)
{
if (!STRCMP(name, buck->keystring))
if (!STRCMP(name, buck->key.string))
return buck->data;
buck = buck->next;
@ -61,7 +61,7 @@ void *Hash_GetInsensative(hashtable_t *table, char *name)
while(buck)
{
if (!stricmp(name, buck->keystring))
if (!stricmp(name, buck->key.string))
return buck->data;
buck = buck->next;
@ -77,7 +77,7 @@ void *Hash_GetKey(hashtable_t *table, int key)
while(buck)
{
if ((int)buck->keystring == key)
if (buck->key.value == key)
return buck->data;
buck = buck->next;
@ -93,7 +93,7 @@ void *Hash_GetNext(hashtable_t *table, char *name, void *old)
while(buck)
{
if (!STRCMP(name, buck->keystring))
if (!STRCMP(name, buck->key.string))
{
if (buck->data == old) //found the old one
break;
@ -107,7 +107,7 @@ void *Hash_GetNext(hashtable_t *table, char *name, void *old)
buck = buck->next;//don't return old
while(buck)
{
if (!STRCMP(name, buck->keystring))
if (!STRCMP(name, buck->key.string))
return buck->data;
buck = buck->next;
@ -123,7 +123,7 @@ void *Hash_GetNextInsensative(hashtable_t *table, char *name, void *old)
while(buck)
{
if (!STRCMP(name, buck->keystring))
if (!STRCMP(name, buck->key.string))
{
if (buck->data == old) //found the old one
break;
@ -137,7 +137,7 @@ void *Hash_GetNextInsensative(hashtable_t *table, char *name, void *old)
buck = buck->next;//don't return old
while(buck)
{
if (!STRCMP(name, buck->keystring))
if (!STRCMP(name, buck->key.string))
return buck->data;
buck = buck->next;
@ -151,7 +151,7 @@ void *Hash_Add(hashtable_t *table, char *name, void *data, bucket_t *buck)
int bucknum = Hash_Key(name, table->numbuckets);
buck->data = data;
buck->keystring = name;
buck->key.string = name;
buck->next = table->bucket[bucknum];
table->bucket[bucknum] = buck;
@ -162,7 +162,7 @@ void *Hash_AddInsensative(hashtable_t *table, char *name, void *data, bucket_t *
int bucknum = Hash_KeyInsensative(name, table->numbuckets);
buck->data = data;
buck->keystring = name;
buck->key.string = name;
buck->next = table->bucket[bucknum];
table->bucket[bucknum] = buck;
@ -173,7 +173,7 @@ void *Hash_AddKey(hashtable_t *table, int key, void *data, bucket_t *buck)
int bucknum = key%table->numbuckets;
buck->data = data;
buck->keystring = (char*)key;
buck->key.value = key;
buck->next = table->bucket[bucknum];
table->bucket[bucknum] = buck;
@ -187,7 +187,7 @@ void Hash_Remove(hashtable_t *table, char *name)
buck = table->bucket[bucknum];
if (!STRCMP(name, buck->keystring))
if (!STRCMP(name, buck->key.string))
{
table->bucket[bucknum] = buck->next;
return;
@ -196,7 +196,7 @@ void Hash_Remove(hashtable_t *table, char *name)
while(buck->next)
{
if (!STRCMP(name, buck->next->keystring))
if (!STRCMP(name, buck->next->key.string))
{
buck->next = buck->next->next;
return;
@ -215,7 +215,7 @@ void Hash_RemoveData(hashtable_t *table, char *name, void *data)
buck = table->bucket[bucknum];
if (buck->data == data)
if (!STRCMP(name, buck->keystring))
if (!STRCMP(name, buck->key.string))
{
table->bucket[bucknum] = buck->next;
return;
@ -225,7 +225,7 @@ void Hash_RemoveData(hashtable_t *table, char *name, void *data)
while(buck->next)
{
if (buck->next->data == data)
if (!STRCMP(name, buck->next->keystring))
if (!STRCMP(name, buck->next->key.string))
{
buck->next = buck->next->next;
return;
@ -244,7 +244,7 @@ void Hash_RemoveKey(hashtable_t *table, int key)
buck = table->bucket[bucknum];
if ((int)buck->keystring == key)
if (buck->key.value == key)
{
table->bucket[bucknum] = buck->next;
return;
@ -253,7 +253,7 @@ void Hash_RemoveKey(hashtable_t *table, int key)
while(buck->next)
{
if ((int)buck->next->keystring == key)
if (buck->next->key.value == key)
{
buck->next = buck->next->next;
return;

View file

@ -7,7 +7,10 @@
#define STRCMP(s1,s2) (((*s1)!=(*s2)) || strcmp(s1+1,s2+1)) //saves about 2-6 out of 120 - expansion of idea from fastqcc
typedef struct bucket_s {
void *data;
char *keystring;
union {
char *string;
int value;
} key;
struct bucket_s *next;
} bucket_t;
typedef struct hashtable_s {

View file

@ -447,6 +447,7 @@ void PR_Deinit(void)
#define PREREL_PROGHEADER_CRC 26940 //prerelease
#define H2_PROGHEADER_CRC 38488 //basic hexen2
#define H2MP_PROGHEADER_CRC 26905 //hexen2 mission pack uses slightly different defs... *sigh*...
#define H2DEMO_PROGHEADER_CRC 14046 //I'm guessing this is from the original release or something
void PR_LoadGlabalStruct(void)
{
@ -664,6 +665,8 @@ progsnum_t AddProgs(char *name)
num = PR_LoadProgs (svprogfuncs, name, H2_PROGHEADER_CRC, NULL, 0);
if (num == -1) //don't commit if bad.
num = PR_LoadProgs (svprogfuncs, name, H2MP_PROGHEADER_CRC, NULL, 0);
if (num == -1)
num = PR_LoadProgs (svprogfuncs, name, H2DEMO_PROGHEADER_CRC, NULL, 0);
if (num == -1) //don't commit if bad.
{
progstype = PROG_PREREL;
@ -1388,9 +1391,9 @@ qboolean PR_GameCodePacket(char *s)
G_INT(OFS_PARM0) = (int)NET_AdrToString (net_from);
G_INT(OFS_PARM0) = PR_SetString(svprogfuncs, NET_AdrToString (net_from));
G_INT(OFS_PARM1) = (int)PR_SetString(svprogfuncs, s);
G_INT(OFS_PARM1) = PR_SetString(svprogfuncs, s);
PR_ExecuteProgram (svprogfuncs, SV_ParseConnectionlessPacket);
return G_FLOAT(OFS_RETURN);
}
@ -2006,7 +2009,7 @@ void PF_setmodel_Internal (progfuncs_t *prinst, edict_t *e, char *m)
// if it is an inline model, get the size information for it
if (m[0] == '*' || (*m&&progstype == PROG_H2))
{
mod = Mod_ForName (m, true);
mod = Mod_ForName (m, false);
if (mod)
{
VectorCopy (mod->mins, e->v->mins);
@ -3758,7 +3761,7 @@ void PF_precache_model_Internal (progfuncs_t *prinst, char *s)
if (s[0] <= ' ')
{
PR_BIError (prinst, "Bad string");
Con_Printf ("precache_model: empty string\n");
return;
}

View file

@ -8,7 +8,7 @@
float RadiusFromBounds (vec3_t mins, vec3_t maxs);
#define USEBOTLIB
//#define USEBOTLIB
#ifdef USEBOTLIB
@ -19,7 +19,7 @@ float RadiusFromBounds (vec3_t mins, vec3_t maxs);
#else
#define QDECL
#endif
#define fileHandle_t char*
#define fileHandle_t int
#define fsMode_t int
#define pc_token_t void
#include "botlib.h"
@ -219,7 +219,7 @@ void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...)
#include "clq3defs.h"
#include "q3g_public.h"
vm_t *q3gamevm;
static vm_t *q3gamevm;
#define fs_key 0
@ -874,7 +874,7 @@ void SVQ3_Adjust_Area_Portal_State(q3sharedEntity_t *ge, qboolean open)
}
#define VALIDATEPOINTER(o,l) if ((int)o + l >= mask || VM_POINTER(o) < offset) SV_Error("Call to game trap %i passes invalid pointer\n", fn); //out of bounds.
long Q3G_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
int Q3G_SystemCallsEx(void *offset, unsigned int mask, int fn, const int *arg)
{
int ret = 0;
switch(fn)
@ -891,37 +891,10 @@ long Q3G_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
case G_CVAR_REGISTER:// ( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );
if (arg[0])
VALIDATEPOINTER(arg[0], sizeof(vmcvar_t));
{
vmcvar_t *vmc;
cvar_t *var;
vmc = VM_POINTER(arg[0]);
var = Cvar_Get(VM_POINTER(arg[1]), VM_POINTER(arg[2]), 0/*VM_LONG(arg[3])*/, "Q3-Game-Code created");
if (!vmc) //qvm doesn't need to retreive it
break;
vmc->handle = (char *)var - (char *)offset;
vmc->integer = var->value;
vmc->value = var->value;
vmc->modificationCount = var->modified;
Q_strncpyz(vmc->string, var->string, sizeof(vmc->string));
}
break;
return VMQ3_Cvar_Register(VM_POINTER(arg[0]), VM_POINTER(arg[1]), VM_POINTER(arg[2]), VM_LONG(arg[3]));
case G_CVAR_UPDATE:// ( vmCvar_t *vmCvar );
VALIDATEPOINTER(arg[0], sizeof(vmcvar_t));
{
cvar_t *var;
vmcvar_t *vmc;
vmc = VM_POINTER(arg[0]);
var = (cvar_t *)((int)vmc->handle + (char *)offset);
if (!var || !vmc->handle)
return false;
vmc->integer = var->value;
vmc->value = var->value;
vmc->modificationCount = var->modified;
Q_strncpyz(vmc->string, var->string, sizeof(vmc->string));
}
break;
return VMQ3_Cvar_Update(VM_POINTER(arg[0]));
case G_CVAR_SET:// ( const char *var_name, const char *value );
{
@ -1061,6 +1034,8 @@ long Q3G_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
case G_GET_USERINFO://int num, char *buffer, int bufferSize 20
if (VM_OOB(arg[1], arg[2]))
return 0;
if ((unsigned)VM_LONG(arg[0]) >= sv.allocated_client_slots)
return 0;
Q_strncpyz(VM_POINTER(arg[1]), svs.clients[VM_LONG(arg[0])].userinfo, VM_LONG(arg[2]));
break;
@ -1087,7 +1062,7 @@ long Q3G_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
case G_ENTITIES_IN_BOX: // ( const vec3_t mins, const vec3_t maxs, gentity_t **list, int maxcount ); 32
// EntitiesInBox will return brush models based on their bounding box,
// so exact determination must still be done with EntityContact
VALIDATEPOINTER(arg[2], sizeof(int*)*VM_LONG(arg[3]));
VALIDATEPOINTER(arg[2], sizeof(int)*VM_LONG(arg[3]));
return SVQ3_EntitiesInBox(VM_POINTER(arg[0]), VM_POINTER(arg[1]), VM_POINTER(arg[2]), VM_LONG(arg[3]));
case G_ADJUST_AREA_PORTAL_STATE:
@ -1122,15 +1097,26 @@ long Q3G_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
// standard Q3
case G_MEMSET:
VALIDATEPOINTER(arg[0], arg[2]);
memset(VM_POINTER(arg[0]), arg[1], arg[2]);
{
void *dst = VM_POINTER(arg[0]);
memset(dst, arg[1], arg[2]);
}
break;
case G_MEMCPY:
VALIDATEPOINTER(arg[0], arg[2]);
memmove(VM_POINTER(arg[0]), VM_POINTER(arg[1]), arg[2]);
{
void *dst = VM_POINTER(arg[0]);
void *src = VM_POINTER(arg[1]);
memmove(dst, src, arg[2]);
}
break;
case G_STRNCPY:
VALIDATEPOINTER(arg[0], arg[2]);
Q_strncpyS(VM_POINTER(arg[0]), VM_POINTER(arg[1]), arg[2]);
{
void *dst = VM_POINTER(arg[0]);
void *src = VM_POINTER(arg[1]);
Q_strncpyS(src, dst, arg[2]);
}
break;
case G_SIN:
VM_FLOAT(ret)=(float)sin(VM_FLOAT(arg[0]));
@ -1592,7 +1578,7 @@ long Q3G_SystemCallsEx(void *offset, unsigned int mask, int fn, const long *arg)
int EXPORT_FN Q3G_SystemCalls(int arg, ...)
{
long args[13];
int args[13];
va_list argptr;
va_start(argptr, arg);
@ -1849,6 +1835,7 @@ qboolean SVQ3_InitGame(void)
char *str;
char sysinfo[8192];
extern cvar_t progs;
cvar_t *sv_pure;
if (sv.worldmodel->type == mod_heightmap)
{
@ -1900,13 +1887,14 @@ qboolean SVQ3_InitGame(void)
str = FS_GetPackNames(buffer, sizeof(buffer), true);
Info_SetValueForKey(sysinfo, "sv_referencedPakNames", str, MAX_SERVERINFO_STRING);
Info_SetValueForKey(sysinfo, "sv_pure", "1", MAX_SERVERINFO_STRING);
sv_pure = Cvar_Get("sv_pure", "1", 0, "Q3 compatability");
Info_SetValueForKey(sysinfo, "sv_pure", sv_pure->string, MAX_SERVERINFO_STRING);
SVQ3_SetConfigString(1, sysinfo);
mapentspointer = sv.worldmodel->entities;
VM_Call(q3gamevm, GAME_INIT, 0, rand(), false);
VM_Call(q3gamevm, GAME_INIT, 0, (int)rand(), false);
CM_InitBoxHull();
@ -1937,17 +1925,17 @@ void SVQ3_RunFrame(void)
void SVQ3_ClientCommand(client_t *cl)
{
VM_Call(q3gamevm, GAME_CLIENT_COMMAND, cl-svs.clients);
VM_Call(q3gamevm, GAME_CLIENT_COMMAND, (int)(cl-svs.clients));
}
void SVQ3_ClientBegin(client_t *cl)
{
VM_Call(q3gamevm, GAME_CLIENT_BEGIN, cl-svs.clients);
VM_Call(q3gamevm, GAME_CLIENT_BEGIN, (int)(cl-svs.clients));
}
void SVQ3_ClientThink(client_t *cl)
{
VM_Call(q3gamevm, GAME_CLIENT_THINK, cl-svs.clients);
VM_Call(q3gamevm, GAME_CLIENT_THINK, (int)(cl-svs.clients));
}
qboolean SVQ3_Command(void)
@ -2303,7 +2291,8 @@ void SVQ3_BuildClientSnapshot( client_t *client )
bitvector = sv.worldmodel->funcs.LeafPVS(sv.worldmodel, sv.worldmodel->funcs.LeafnumForPoint(sv.worldmodel, org), NULL);
clientarea = CM_LeafArea(sv.worldmodel, clientarea);
/*
if( client->areanum != clientarea ) {
if (client->areanum != clientarea)
{
Com_Printf( "%s entered area %i\n", client->name, clientarea);
client->areanum = clientarea;
}
@ -2409,7 +2398,7 @@ void SVQ3_BuildClientSnapshot( client_t *client )
void SVQ3_SendGameState(client_t *client)
{
sizebuf_t msg;
char buffer[MAX_OVERALLMSGLEN];
unsigned char buffer[MAX_OVERALLMSGLEN];
int i;
int j;
char *configString;
@ -2712,7 +2701,7 @@ void SVQ3_UpdateUserinfo_f(client_t *cl)
SV_ExtractFromUserinfo (cl);
VM_Call(q3gamevm, GAME_CLIENT_USERINFO_CHANGED, cl-svs.clients);
VM_Call(q3gamevm, GAME_CLIENT_USERINFO_CHANGED, (int)(cl-svs.clients));
}
void SVQ3_Drop_f(client_t *cl)
@ -2850,7 +2839,6 @@ void SVQ3_ParseClientMessage(client_t *client)
{
Con_Printf("corrupted packet from %s\n", client->name);
client->drop = true;
// SV_DropClient(client);
return;
}
@ -2865,7 +2853,6 @@ void SVQ3_ParseClientMessage(client_t *client)
default:
Con_Printf("corrupted packet from %s\n", client->name);
client->drop = true;
// SV_DropClient(client);
return;
case clcq3_nop:
break;
@ -2937,7 +2924,7 @@ void SVQ3_DirectConnect(void) //Actually connect the client, use up a slot, and
Huff_DecryptPacket(&net_message, 12);
Cmd_TokenizeString(net_message.data+4, false, false);
Cmd_TokenizeString((char*)net_message.data+4, false, false);
userinfo = Cmd_Argv(1);
qport = atoi(Info_ValueForKey(userinfo, "qport"));
challenge = atoi(Info_ValueForKey(userinfo, "challenge"));
@ -2980,7 +2967,7 @@ void SVQ3_DirectConnect(void) //Actually connect the client, use up a slot, and
reason = NET_AdrToString(net_from);
Info_SetValueForStarKey(cl->userinfo, "ip", reason, sizeof(cl->userinfo));
ret = VM_Call(q3gamevm, GAME_CLIENT_CONNECT, cl-svs.clients, false, false);
ret = VM_Call(q3gamevm, GAME_CLIENT_CONNECT, (int)(cl-svs.clients), false, false);
if (!ret)
reason = NULL;
else
@ -3039,7 +3026,7 @@ int SVQ3_AddBot(void)
void SVQ3_DropClient(client_t *cl)
{
if (q3gamevm)
VM_Call(q3gamevm, GAME_CLIENT_DISCONNECT, cl-svs.clients);
VM_Call(q3gamevm, GAME_CLIENT_DISCONNECT, (int)(cl-svs.clients));
}
#endif