From 4a0c02b6854b86cca22cbc809968dfc5ee2664ba Mon Sep 17 00:00:00 2001 From: Spoike Date: Tue, 17 May 2005 02:36:54 +0000 Subject: [PATCH] Hopefully, the server will now run on 64bit archetectures. Also, a piece of unitialialized memory should now be fixed. there's a con_centertext cvar added an extra default particle texture. further dp protocol compatability stuff. EF_ADDATIVE works on models and supposedly sprites. will do sw sprites too at some point. Linux makefile needs work still. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1017 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_ents.c | 11 +++++- engine/client/cl_input.c | 2 +- engine/client/cl_master.h | 24 ++++++----- engine/client/cl_parse.c | 15 ++++--- engine/client/console.c | 69 ++++++++++++++++++++++++-------- engine/client/m_master.c | 4 +- engine/client/net_master.c | 81 +++++++++++++++++++++++++++++++------- engine/client/pr_csqc.c | 5 ++- engine/client/pr_menu.c | 1 - engine/client/r_part.c | 44 ++++++++++++--------- engine/client/renderer.c | 2 +- engine/client/snd_dma.c | 2 - engine/client/sys_win.c | 2 +- engine/common/bothdefs.h | 3 -- engine/common/gl_q2bsp.c | 3 +- engine/common/plugin.c | 4 +- engine/common/pmove.c | 7 ++-- engine/common/pmove.h | 1 + engine/common/protocol.h | 49 ++++++----------------- engine/gl/gl_alias.c | 45 +++++++++++++++++---- engine/gl/gl_draw.c | 2 - engine/gl/gl_ppl.c | 30 +++++++------- engine/gl/gl_rmain.c | 17 ++++++++ engine/gl/gl_rmisc.c | 24 ++++++++++- engine/gl/gl_shader.c | 8 ++-- engine/gl/glquake.h | 1 + engine/http/ftpserver.c | 7 ++-- engine/nqnet/net_main.c | 4 +- engine/qclib/execloop.h | 59 +++++++++++++++------------ engine/qclib/execloop16d.h | 53 ++++++++++++++----------- engine/qclib/execloop32.h | 53 ++++++++++++++----------- engine/qclib/execloop32d.h | 53 ++++++++++++++----------- engine/qclib/initlib.c | 2 + engine/qclib/pr_edict.c | 48 ++++++++++++++++++++-- engine/qclib/pr_exec.c | 16 +++----- engine/qclib/progsint.h | 2 +- engine/qclib/progslib.h | 6 +-- engine/server/pr_cmds.c | 33 +++++++++++----- engine/server/progdefs.h | 4 +- engine/server/savegame.c | 2 +- engine/server/server.h | 8 ++-- engine/server/sv_chat.c | 2 +- engine/server/sv_ents.c | 18 ++++++--- engine/server/sv_init.c | 38 ++++++++++++------ engine/server/sv_main.c | 21 +++++++--- engine/server/sv_phys.c | 21 +++++----- engine/server/sv_send.c | 2 +- engine/server/sv_user.c | 9 +++-- 48 files changed, 595 insertions(+), 322 deletions(-) diff --git a/engine/client/cl_ents.c b/engine/client/cl_ents.c index f554deaca..ff7ce2d21 100644 --- a/engine/client/cl_ents.c +++ b/engine/client/cl_ents.c @@ -782,7 +782,14 @@ void DP5_ParseDelta(entity_state_t *s) // s->active = true; } if (bits & E5_FLAGS) - s->flags = MSG_ReadByte(); + { + int i = MSG_ReadByte(); + s->flags = 0; + if (i & 4) + s->flags |= Q2RF_WEAPONMODEL|Q2RF_MINLIGHT|Q2RF_DEPTHHACK; + if (i & 8) + s->flags |= Q2RF_EXTERNALMODEL; + } if (bits & E5_ORIGIN) { if (bits & E5_ORIGIN32) @@ -922,7 +929,7 @@ void CLNQ_ParseDarkPlaces5Entities(void) //the things I do.. :o( } } - from->flags = 0x80000000; + from->flags |= 0x80000000; if (remove) { continue; diff --git a/engine/client/cl_input.c b/engine/client/cl_input.c index 89d74899e..f2eb2052d 100644 --- a/engine/client/cl_input.c +++ b/engine/client/cl_input.c @@ -683,7 +683,7 @@ void CLNQ_SendMove (usercmd_t *cmd, int pnum) MSG_WriteByte (&buf, clc_move); - MSG_WriteFloat (&buf, cl.time); // so server can get ping times + MSG_WriteFloat (&buf, cl.gametime); // so server can get ping times for (i=0 ; i<3 ; i++) MSG_WriteAngle (&buf, cl.viewangles[pnum][i]); diff --git a/engine/client/cl_master.h b/engine/client/cl_master.h index ee9331454..44005547f 100644 --- a/engine/client/cl_master.h +++ b/engine/client/cl_master.h @@ -4,18 +4,24 @@ #define SS_NETQUAKE 4 #define SS_FAVORITE 8 //filter all others. #define SS_KEEPINFO 16 +#define SS_DARKPLACES 32 //despite not supporting nq or q2, we still load them. We just filter them. This is to make sure we properly write the listing files. -#define MT_BAD 0 //this would be an error -#define MT_BCASTQW 1 //-1status -#define MT_BCASTQ2 2 //-1status -#define MT_BCASTNQ 3 //see code -#define MT_SINGLEQW 4 //-1status -#define MT_SINGLEQ2 5 //-1status -#define MT_SINGLENQ 6 //see code. -#define MT_MASTERQW 7 //c\n\0 -#define MT_MASTERQ2 8 //query +enum { + MT_BAD, //this would be an error + MT_BCASTQW, //-1status + MT_BCASTQ2, //-1status + MT_BCASTNQ, //see code + MT_BCASTDP, + MT_SINGLEQW, //-1status + MT_SINGLEQ2, //-1status + MT_SINGLENQ, //see code. + MT_SINGLEDP, + MT_MASTERQW, //c\n\0 + MT_MASTERQ2, //query + MT_MASTERDP //-1getservers %s 3 empty full\x0A +}; typedef enum{ diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index 5b117dc36..37e0729e9 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -1471,10 +1471,9 @@ void CLNQ_ParseServerData(void) //Doesn't change gamedir - use with caution. Host_EndGame ("Server returned version %i, not %i\nYou will need to use a different client.", protover, NQ_PROTOCOL_VERSION); } - if (MSG_ReadByte() > MAX_SCOREBOARD) + if (MSG_ReadByte() > MAX_CLIENTS) { - Con_TPrintf (TLC_BAD_MAXCLIENTS); - return; + Con_Printf ("Warning, this server supports more than 32 clients, additional clients will do bad things\n"); } cl.splitclients = 1; @@ -3745,7 +3744,7 @@ void CLNQ_ParseServerMessage (void) if (CL_ParseChat(s+1)) { CL_ParsePrint(s+1, 3); - Con_TPrintf (TL_ST, Translate(s)); + Con_Printf ("^3%s", Translate(s+1)); } } else @@ -3873,12 +3872,16 @@ void CLNQ_ParseServerMessage (void) case svc_updatename: Sbar_Changed (); i = MSG_ReadByte (); + if (i >= MAX_CLIENTS) + Host_EndGame ("CL_ParseServerMessage: svc_updatename > MAX_CLIENTS"); strcpy(cl.players[i].name, MSG_ReadString()); break; case svc_updatefrags: Sbar_Changed (); i = MSG_ReadByte (); + if (i >= MAX_CLIENTS) + Host_EndGame ("CL_ParseServerMessage: svc_updatefrags > MAX_CLIENTS"); cl.players[i].frags = MSG_ReadShort(); break; case svc_updatecolors: @@ -3886,8 +3889,8 @@ void CLNQ_ParseServerMessage (void) int a; Sbar_Changed (); i = MSG_ReadByte (); - if (i >= MAX_SCOREBOARD) - Host_Error ("CL_ParseServerMessage: svc_updatecolors > MAX_SCOREBOARD"); + if (i >= MAX_CLIENTS) + Host_EndGame ("CL_ParseServerMessage: svc_updatecolors > MAX_CLIENTS"); a = MSG_ReadByte (); //FIXME:!!!! diff --git a/engine/client/console.c b/engine/client/console.c index 8f51a0084..33cb96a0c 100644 --- a/engine/client/console.c +++ b/engine/client/console.c @@ -66,6 +66,7 @@ float con_cursorspeed = 4; cvar_t con_numnotifylines = {"con_notifylines","4"}; //max lines to show cvar_t con_notifytime = {"con_notifytime","3"}; //seconds +cvar_t con_centernotify = {"con_centernotify", "0"}; cvar_t con_displaypossabilities = {"con_displaypossabilities", "1"}; #define NUM_CON_TIMES 24 @@ -507,6 +508,7 @@ void Con_Init (void) // register our commands // Cvar_Register (&con_notifytime, "Console controls"); + Cvar_Register (&con_centernotify, "Console controls"); Cvar_Register (&con_numnotifylines, "Console controls"); Cvar_Register (&con_displaypossabilities, "Console controls"); @@ -960,6 +962,7 @@ void Con_DrawNotify (void) char *s; int skip; int maxlines; + int inset; int mask=CON_WHITEMASK; int maskstack[4]; @@ -979,25 +982,59 @@ void Con_DrawNotify (void) maxlines = NUM_CON_TIMES; v = 0; - for (i= con->current-maxlines+1 ; i<=con->current ; i++) + if (con_centernotify.value) { - if (i < 0) - continue; - time = con_times[i % NUM_CON_TIMES]; - if (time == 0) - continue; - time = realtime - time; - if (time > con_notifytime.value) - continue; - text = con->text + (i % con->totallines)*con->linewidth; - - clearnotify = 0; - scr_copytop = 1; + for (i= con->current-maxlines+1 ; i<=con->current ; i++) + { + if (i < 0) + continue; + time = con_times[i % NUM_CON_TIMES]; + if (time == 0) + continue; + time = realtime - time; + if (time > con_notifytime.value) + continue; + text = con->text + (i % con->totallines)*con->linewidth; + + clearnotify = 0; + scr_copytop = 1; - for (x = 0 ; x < con->linewidth ; x++) - Draw_ColouredCharacter ( (x+1)<<3, v, text[x]); + for (x = con->linewidth-1 ; x >= 0 ; x--) + { + if ((text[x]&0xff) != ' ') + break; + } + inset = con->linewidth*4-x*4; - v += 8; + for (x = 0 ; x < con->linewidth ; x++) + Draw_ColouredCharacter ( inset + ((x+1)<<3), v, text[x]); + + v += 8; + } + + } + else + { + for (i= con->current-maxlines+1 ; i<=con->current ; i++) + { + if (i < 0) + continue; + time = con_times[i % NUM_CON_TIMES]; + if (time == 0) + continue; + time = realtime - time; + if (time > con_notifytime.value) + continue; + text = con->text + (i % con->totallines)*con->linewidth; + + clearnotify = 0; + scr_copytop = 1; + + for (x = 0 ; x < con->linewidth ; x++) + Draw_ColouredCharacter ( (x+1)<<3, v, text[x]); + + v += 8; + } } diff --git a/engine/client/m_master.c b/engine/client/m_master.c index 2540e4e58..91e5ff700 100644 --- a/engine/client/m_master.c +++ b/engine/client/m_master.c @@ -115,10 +115,10 @@ qboolean M_IsFiltered(serverinfo_t *server) //figure out if we should filter a s #ifdef NQPROT if (sb_hidenetquake.value) #endif - if (server->special & SS_NETQUAKE) + if (server->special & (SS_NETQUAKE|SS_DARKPLACES)) return true; if (sb_hidequakeworld.value) - if (!(server->special & (SS_QUAKE2|SS_NETQUAKE))) + if (!(server->special & (SS_QUAKE2|SS_NETQUAKE|SS_DARKPLACES))) return true; if (sb_hideempty.value) if (!server->players) diff --git a/engine/client/net_master.c b/engine/client/net_master.c index a2209e142..53f18a706 100644 --- a/engine/client/net_master.c +++ b/engine/client/net_master.c @@ -49,7 +49,7 @@ typedef int SOCKET; cvar_t slist_cacheinfo = {"slist_cacheinfo", "0"}; //this proves dangerous, memory wise. cvar_t slist_writeserverstxt = {"slist_writeservers", "0"}; -void CL_MasterListParse(qboolean isq2); +void CL_MasterListParse(qboolean isq2, qboolean slashpad); void CL_QueryServers(void); int CL_ReadServerInfo(char *msg, int servertype, qboolean favorite); @@ -506,7 +506,7 @@ void Master_AddMaster (char *address, int type, char *description) for (mast = master; mast; mast = mast->next) { - if (NET_CompareAdr(mast->adr, adr)) //already exists. + if (NET_CompareAdr(mast->adr, adr) && mast->type == type) //already exists. return; } mast = Z_Malloc(sizeof(master_t)+strlen(description)); @@ -564,11 +564,15 @@ qboolean Master_LoadMasterList (char *filename, int defaulttype, int depth) servertype = MT_SINGLEQW; else if (!strcmp(com_token, "single:q2")) servertype = MT_SINGLEQ2; + else if (!strcmp(com_token, "single:dp")) + servertype = MT_SINGLEDP; else if (!strcmp(com_token, "single:nq") || !strcmp(com_token, "single:q1")) servertype = MT_SINGLENQ; else if (!strcmp(com_token, "single")) servertype = MT_SINGLEQW; + else if (!strcmp(com_token, "master:dp")) + servertype = MT_MASTERDP; else if (!strcmp(com_token, "master:qw")) servertype = MT_MASTERQW; else if (!strcmp(com_token, "master:q2")) @@ -582,6 +586,8 @@ qboolean Master_LoadMasterList (char *filename, int defaulttype, int depth) servertype = MT_BCASTQ2; else if (!strcmp(com_token, "bcast:nq")) servertype = MT_BCASTNQ; + else if (!strcmp(com_token, "bcast:dp")) + servertype = MT_BCASTDP; else if (!strcmp(com_token, "bcast")) servertype = MT_BCASTQW; @@ -753,10 +759,21 @@ int NET_CheckPollSockets(void) CL_ReadServerInfo(MSG_ReadString(), MT_SINGLEQ2, false); continue; } + else if (!strncmp(s, "getserversResponse\\", 19)) //parse a bit more... + { + msg_readcount = c+18-1; + CL_MasterListParse(SS_DARKPLACES, true); + continue; + } else if (!strncmp(s, "servers", 6)) //parse a bit more... { msg_readcount = c+7; - CL_MasterListParse(true); + CL_MasterListParse(SS_QUAKE2, false); + continue; + } + else if (!strcmp(s, "infoResponse")) //parse a bit more... + { + CL_ReadServerInfo(MSG_ReadString(), MT_SINGLEDP, false); continue; } msg_readcount = c; @@ -772,7 +789,7 @@ int NET_CheckPollSockets(void) if (c == M2C_MASTER_REPLY) //qw master reply. { - CL_MasterListParse(false); + CL_MasterListParse(false, false); continue; } } @@ -832,7 +849,6 @@ void SListOptionChanged(serverinfo_t *newserver) { if (selectedserver.inuse) { - char data[16]; serverinfo_t *oldserver; selectedserver.detail = NULL; @@ -870,9 +886,9 @@ void SListOptionChanged(serverinfo_t *newserver) strcpy(newserver->moreinfo->info, ""); Info_SetValueForKey(newserver->moreinfo->info, "hostname", newserver->name, sizeof(newserver->moreinfo->info)); - newserver->refreshtime = Sys_DoubleTime(); - sprintf(data, "%c%c%c%cstatus", 255, 255, 255, 255); - NET_SendPollPacket (strlen(data), data, newserver->adr); + + newserver->sends++; + Master_QueryServer(newserver); } } @@ -880,6 +896,7 @@ void SListOptionChanged(serverinfo_t *newserver) //don't try sending to servers we don't support void MasterInfo_Request(master_t *mast, qboolean evenifwedonthavethefiles) { + char *str; if (!mast) return; switch(mast->type) @@ -906,6 +923,15 @@ void MasterInfo_Request(master_t *mast, qboolean evenifwedonthavethefiles) NET_SendPollPacket(net_message.cursize, net_message.data, mast->adr); SZ_Clear(&net_message); break; + case MT_MASTERDP: + str = va("%c%c%c%cgetservers %s %u empty full\x0A\n", 255, 255, 255, 255, "Nexuiz", 3); + NET_SendPollPacket (strlen(str), str, mast->adr); + break; + case MT_SINGLEDP: + case MT_BCASTDP: + str = va("%c%c%c%cgetinfo", 255, 255, 255, 255); + NET_SendPollPacket (strlen(str), str, mast->adr); + break; #endif case MT_MASTERQW: NET_SendPollPacket (3, "c\n", mast->adr); @@ -944,6 +970,9 @@ void MasterInfo_WriteServers(void) case MT_MASTERQ2: typename = "master:q2"; break; + case MT_MASTERDP: + typename = "master:dp"; + break; case MT_BCASTQW: typename = "bcast:qw"; break; @@ -1033,6 +1062,13 @@ void MasterInfo_Begin(void) Master_AddMaster("192.246.40.37:27900", MT_MASTERQ2, "id q2 Master."); } + Master_AddMaster("ghdigital.com:27950", MT_MASTERDP, "DarkPlaces Master: Nexuiz"); + Master_AddMaster("dpmaster.deathmask.net:27950", MT_MASTERDP, "DarkPlaces Master: Nexuiz"); + Master_AddMaster("12.166.196.192:27950", MT_MASTERDP, "DarkPlaces Master: Nexuiz"); + + Master_AddMaster("255.255.255.255:26000", MT_BCASTDP, "Nearby DarkPlaces servers"); + + } for (mast = master; mast; mast=mast->next) @@ -1046,7 +1082,10 @@ void Master_QueryServer(serverinfo_t *server) char data[2048]; server->sends--; server->refreshtime = Sys_DoubleTime(); - sprintf(data, "%c%c%c%cstatus", 255, 255, 255, 255); + if (server->special & SS_DARKPLACES) + sprintf(data, "%c%c%c%cgetinfo", 255, 255, 255, 255); + else + sprintf(data, "%c%c%c%cstatus", 255, 255, 255, 255); NET_SendPollPacket (strlen(data), data, server->adr); } //send a packet to each server in sequence. @@ -1199,7 +1238,9 @@ int CL_ReadServerInfo(char *msg, int servertype, qboolean favorite) info->special |= SS_FTESERVER; - if (servertype == MT_SINGLEQ2) + if (servertype == MT_SINGLEDP) + info->special |= SS_DARKPLACES; + else if (servertype == MT_SINGLEQ2) info->special |= SS_QUAKE2; else if (servertype == MT_SINGLENQ) info->special |= SS_NETQUAKE; @@ -1218,7 +1259,7 @@ int CL_ReadServerInfo(char *msg, int servertype, qboolean favorite) info->tl = atoi(Info_ValueForKey(msg, "timelimit")); info->fl = atoi(Info_ValueForKey(msg, "fraglimit")); - if (servertype == MT_SINGLEQ2) + if (servertype == MT_SINGLEQ2 || servertype == MT_SINGLEDP) { Q_strncpyz(info->gamedir, Info_ValueForKey(msg, "gamename"), sizeof(info->gamedir)); Q_strncpyz(info->map, Info_ValueForKey(msg, "mapname"), sizeof(info->map)); @@ -1346,7 +1387,7 @@ int CL_ReadServerInfo(char *msg, int servertype, qboolean favorite) } //rewrite to scan for existing server instead of wiping all. -void CL_MasterListParse(qboolean isq2) +void CL_MasterListParse(int type, qboolean slashpad) { serverinfo_t *info; serverinfo_t *last, *old; @@ -1356,8 +1397,14 @@ void CL_MasterListParse(qboolean isq2) last = firstserver; - while(msg_readcount+1 < net_message.cursize) + while(msg_readcount+6 < net_message.cursize) { + if (slashpad) + { + if (MSG_ReadByte() != '\\') + break; + } + info = Z_Malloc(sizeof(serverinfo_t)); info->adr.type = NA_IP; info->adr.ip[0] = MSG_ReadByte(); @@ -1368,6 +1415,11 @@ void CL_MasterListParse(qboolean isq2) p1 = MSG_ReadByte(); p2 = MSG_ReadByte(); info->adr.port = (int)((short)(p1 + (p2<<8))); + if (!info->adr.port) + { + Z_Free(info); + break; + } if ((old = Master_InfoForServer(info->adr))) //remove if the server already exists. { old->sends = 1; //reset. @@ -1375,7 +1427,8 @@ void CL_MasterListParse(qboolean isq2) } else { - info->special = isq2?SS_QUAKE2:0; + info->sends = 1; + info->special = type; info->refreshtime = 0; sprintf(info->name, "%s", NET_AdrToString(info->adr)); diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index a20bce1cc..77d04d9dc 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -180,7 +180,7 @@ static void CSQC_InitFields(void) #define fieldentity(name) PR_RegisterFieldVar(csqcprogs, ev_entity, #name, (int)&((csqcentvars_t*)0)->name, -1) #define fieldstring(name) PR_RegisterFieldVar(csqcprogs, ev_string, #name, (int)&((csqcentvars_t*)0)->name, -1) #define fieldfunction(name) PR_RegisterFieldVar(csqcprogs, ev_function, #name, (int)&((csqcentvars_t*)0)->name, -1) -csqcfields +csqcfields //any *64->int32 casts are erroneous, it's biased off NULL. #undef fieldfloat #undef fieldvector #undef fieldentity @@ -190,7 +190,7 @@ csqcfields static csqcedict_t *csqcent[MAX_EDICTS]; -#define RETURN_SSTRING(s) (((int *)pr_globals)[OFS_RETURN] = PR_SetString(prinst, s)) //static - exe will not change it. +#define RETURN_SSTRING(s) (((string_t *)pr_globals)[OFS_RETURN] = PR_SetString(prinst, s)) //static - exe will not change it. char *PF_TempStr(void); static int csqcentsize; @@ -1655,6 +1655,7 @@ qboolean CSQC_DrawView(void) r_secondaryview = 0; + DropPunchAngle (0); if (cl.worldmodel) R_LessenStains(); diff --git a/engine/client/pr_menu.c b/engine/client/pr_menu.c index 062fd8ced..d98744719 100644 --- a/engine/client/pr_menu.c +++ b/engine/client/pr_menu.c @@ -718,7 +718,6 @@ void PF_gethostcachestring (progfuncs_t *prinst, struct globalvars_s *pr_globals //float gethostcacheindexforkey(string key) = #622; void PF_M_gethostcacheindexforkey(progfuncs_t *prinst, struct globalvars_s *pr_globals) { - int i; char *keyname = PR_GetStringOfs(prinst, OFS_PARM0); G_FLOAT(OFS_RETURN) = Master_KeyForName(keyname); diff --git a/engine/client/r_part.c b/engine/client/r_part.c index cdba2b106..f621f33e6 100644 --- a/engine/client/r_part.c +++ b/engine/client/r_part.c @@ -329,6 +329,29 @@ static int CheckAssosiation(char *name, int from) return orig; } +#ifdef RGLQUAKE +void P_LoadTexture(part_type_t *ptype, qboolean warn) +{ + if (strcmp(ptype->texname, "default")) + { + ptype->texturenum = Mod_LoadHiResTexture(ptype->texname, "particles", true, true, true); + + if (!ptype->texturenum) + { + if (warn) + Con_DPrintf("Couldn't load texture %s for particle effect %s\n", ptype->texname, ptype->name); + + if (strstr(ptype->texname, "glow") || strstr(ptype->texname, "ball")) + ptype->texturenum = balltexture; + else + ptype->texturenum = explosiontexture; + } + } + else + ptype->texturenum = explosiontexture; +} +#endif + //Uses FTE's multiline console stuff. //This is the function that loads the effect descriptions (via console). void P_ParticleEffect_f(void) @@ -821,18 +844,7 @@ void P_ParticleEffect_f(void) #ifdef RGLQUAKE if (qrenderer == QR_OPENGL) { - if (strcmp(ptype->texname, "default")) - { - ptype->texturenum = Mod_LoadHiResTexture(ptype->texname, "particles", true, true, true); - - if (!ptype->texturenum) - { - Con_DPrintf("Couldn't load texture %s for particle effect %s\n", ptype->texname, ptype->name); - ptype->texturenum = explosiontexture; - } - } - else - ptype->texturenum = explosiontexture; + P_LoadTexture(ptype, true); } #endif } @@ -1178,18 +1190,14 @@ void P_ClearParticles (void) { for (i = 0; i < numparticletypes; i++) { - if (*part_type[i].texname) - { - part_type[i].texturenum = Mod_LoadHiResTexture(part_type[i].texname, "particles", true, true, true); - if (!part_type[i].texturenum) - part_type[i].texturenum = explosiontexture; - } + P_LoadTexture(&part_type[i], false); } } #endif for (i = 0; i < numparticletypes; i++) { + part_type[i].clippeddecals = NULL; part_type[i].particles = NULL; part_type[i].beams = NULL; part_type[i].skytris = NULL; diff --git a/engine/client/renderer.c b/engine/client/renderer.c index 28ce6bc86..3a00c1de9 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -1553,7 +1553,7 @@ TRACE(("dbg: R_ApplyRenderer: clearing world\n")); { for (i = 0; i < MAX_MODELS; i++) { - if (*sv.model_precache[i] && (!strcmp(sv.model_precache[i] + strlen(sv.model_precache[i]) - 4, ".bsp") || i-1 < sv.worldmodel->numsubmodels)) + if (sv.model_precache[i] && *sv.model_precache[i] && (!strcmp(sv.model_precache[i] + strlen(sv.model_precache[i]) - 4, ".bsp") || i-1 < sv.worldmodel->numsubmodels)) sv.models[i] = Mod_FindName(sv.model_precache[i]); else sv.models[i] = NULL; diff --git a/engine/client/snd_dma.c b/engine/client/snd_dma.c index be9bcf4c3..8f314a0e5 100644 --- a/engine/client/snd_dma.c +++ b/engine/client/snd_dma.c @@ -736,8 +736,6 @@ void SND_Spatialize(soundcardinfo_t *sc, channel_t *ch) { scale = 1 + (dotright*sin(sc->yaw[i]*M_PI/180) + dotforward*cos(sc->yaw[i]*M_PI/180));// - dotup*cos(sc->pitch[0])*2; scale = (1.0 - dist) * scale * sc->dist[i]; -// if (scale < 0.5) -// scale = 0.5; ch->vol[i] = (int) (ch->master_vol * scale); if (ch->vol[i] < 0) ch->vol[i] = 0; diff --git a/engine/client/sys_win.c b/engine/client/sys_win.c index e085f4f46..21002da38 100644 --- a/engine/client/sys_win.c +++ b/engine/client/sys_win.c @@ -755,7 +755,7 @@ char *Sys_ConsoleInput (void) char *clipText, *textCopied; if (!hinput) - return; + return NULL; for ( ;; ) { diff --git a/engine/common/bothdefs.h b/engine/common/bothdefs.h index 86e0a9f64..22e9e00ec 100644 --- a/engine/common/bothdefs.h +++ b/engine/common/bothdefs.h @@ -290,9 +290,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // fall over #define ROLL 2 - -#define MAX_SCOREBOARD 16 // max numbers of players - #define SOUND_CHANNELS 8 diff --git a/engine/common/gl_q2bsp.c b/engine/common/gl_q2bsp.c index 918bbc117..d642d3b5d 100644 --- a/engine/common/gl_q2bsp.c +++ b/engine/common/gl_q2bsp.c @@ -320,7 +320,7 @@ static int mapisq3; cvar_t map_noareas = {"map_noareas", "1"}; //1 for lack of mod support. cvar_t map_noCurves = {"map_noCurves", "0", NULL, CVAR_CHEAT}; cvar_t map_autoopenportals = {"map_autoopenportals", "1"}; //1 for lack of mod support. -cvar_t r_subdivisions = {"r_subdivisions", "1"}; +cvar_t r_subdivisions = {"r_subdivisions", "2"}; int CM_NumInlineModels (void); q2cmodel_t *CM_InlineModel (char *name); @@ -5388,5 +5388,6 @@ void CM_Init(void) //register cvars. Cvar_Register(&map_noareas, MAPOPTIONS); Cvar_Register(&map_noCurves, MAPOPTIONS); Cvar_Register(&map_autoopenportals, MAPOPTIONS); + Cvar_Register(&r_subdivisions, MAPOPTIONS); } #endif diff --git a/engine/common/plugin.c b/engine/common/plugin.c index 80f570c9c..4323021bd 100644 --- a/engine/common/plugin.c +++ b/engine/common/plugin.c @@ -177,8 +177,8 @@ plugin_t *Plug_Load(char *file) newplug->next = plugs; plugs = newplug; - argarray = (long)"Plug_GetEngineFunction"; - VM_Call(newplug->vm, 0, Plug_FindBuiltin(NULL, ~0, &argarray)); + argarray = 0; + VM_Call(newplug->vm, 0, Plug_FindBuiltin("Plug_GetEngineFunction", ~0, &argarray)); if (newplug->reschange) VM_Call(newplug->vm, newplug->reschange, vid.width, vid.height); diff --git a/engine/common/pmove.c b/engine/common/pmove.c index ac6fa4216..41e6c2d07 100644 --- a/engine/common/pmove.c +++ b/engine/common/pmove.c @@ -624,14 +624,13 @@ void PM_AirMove (void) PM_Accelerate (wishdir, wishspeed, movevars.accelerate); pmove.velocity[2] -= movevars.entgravity * movevars.gravity * frametime; - if (!movevars.slidefix) - pmove.velocity[2] = 0; - - if (!pmove.velocity[0] && !pmove.velocity[1]) + if (!pmove.velocity[0] && !pmove.velocity[1] && !movevars.slidyslopes) { pmove.velocity[2] = 0; return; } + else if (!movevars.slidefix && !movevars.slidyslopes) + pmove.velocity[2] = 0; PM_StepSlideMove (); } diff --git a/engine/common/pmove.h b/engine/common/pmove.h index ea0601ec0..ded6c1704 100644 --- a/engine/common/pmove.h +++ b/engine/common/pmove.h @@ -92,6 +92,7 @@ typedef struct { qboolean slidefix; qboolean airstep; qboolean walljump; + qboolean slidyslopes; } movevars_t; diff --git a/engine/common/protocol.h b/engine/common/protocol.h index dfab2cabc..d1dbbf8ce 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -652,36 +652,6 @@ enum { // entity_state_t is the information conveyed from the server // in an update message -//FIXME: split the q2 vars. -#ifdef SERVERONLY -typedef struct entity_state_s -{ - int number; // edict index - - int flags; // nolerp, etc - vec3_t origin; - vec3_t angles; - int modelindex; - int frame; - int colormap; - int skinnum; - int effects; - -#ifdef PEXT_SCALE - float scale; -#endif -#ifdef PEXT_TRANS - float trans; -#endif -#ifdef PEXT_FATNESS - float fatness; -#endif - - qbyte hexen2flags; - qbyte abslight; - qbyte dpflags; -} entity_state_t; -#else typedef struct entity_state_s { int number; // edict index @@ -690,13 +660,13 @@ typedef struct entity_state_s vec3_t origin; vec3_t old_origin; //q2 vec3_t angles; - int modelindex; - int modelindex2; //q2 - int modelindex3; //q2 - int modelindex4; //q2 - int frame; - int colormap; - int skinnum; + unsigned short modelindex; + unsigned short modelindex2; //q2 + unsigned short modelindex3; //q2 + unsigned short modelindex4; //q2 + unsigned short frame; + unsigned short colormap; + unsigned short skinnum; int effects; int renderfx; //q2 int sound; //q2 @@ -716,8 +686,11 @@ typedef struct entity_state_s qbyte abslight; qbyte dpflags; qbyte solid; + + qbyte glowsize; + qbyte glowcolour; } entity_state_t; -#endif + #define MAX_EXTENDED_PACKET_ENTITIES 256 //sanity limit. #define MAX_STANDARD_PACKET_ENTITIES 64 // doesn't count nails diff --git a/engine/gl/gl_alias.c b/engine/gl/gl_alias.c index 6ada1b42b..c8d03d291 100644 --- a/engine/gl/gl_alias.c +++ b/engine/gl/gl_alias.c @@ -512,7 +512,7 @@ static qboolean R_GAliasBuildMesh(mesh_t *mesh, galiasinfo_t *inf, int frame1, i float *pose[4]; float mlerp; //minor lerp, poses within a group. - mlerp = cl.time*g1->rate; + mlerp = (cl.time-cl.lerpents[currententity->keynum].lerptime)*g1->rate; frame1=mlerp; frame2=frame1+1; mlerp-=frame1; @@ -526,7 +526,7 @@ static qboolean R_GAliasBuildMesh(mesh_t *mesh, galiasinfo_t *inf, int frame1, i if (plerp[l]>0) pose[l++] = (float *)((char *)g1 + g1->poseofs + sizeof(float)*inf->numbones*12*frame2); - mlerp = cl.time*g2->rate; + mlerp = (cl.time-cl.lerpents[currententity->keynum].lerptime)*g2->rate; frame1=mlerp; frame2=frame1+1; mlerp-=frame1; @@ -1067,6 +1067,25 @@ void GL_DrawAliasMesh_Sketch (mesh_t *mesh) #endif } +//called from sprite code. +/* +void GL_KnownState(void) +{ + extern int gldepthfunc; + qglDepthFunc(gldepthfunc); + qglDepthMask(1); + if (gldepthmin == 0.5) + qglCullFace ( GL_BACK ); + else + qglCullFace ( GL_FRONT ); + + GL_TexEnv(GL_MODULATE); + + qglEnable (GL_BLEND); + qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} +*/ + void GL_DrawAliasMesh (mesh_t *mesh, int texnum) { extern int gldepthfunc; @@ -1292,7 +1311,12 @@ void R_DrawGAliasModel (entity_t *e) qglDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin)); // glColor3f( 1,1,1); - if ((e->model->flags & EF_SPECIAL_TRANS)) //hexen2 flags. + if (e->flags & Q2RF_ADDATIVE) + { + qglEnable (GL_BLEND); + qglBlendFunc(GL_ONE, GL_ONE); + } + else if ((e->model->flags & EF_SPECIAL_TRANS)) //hexen2 flags. { qglEnable (GL_BLEND); qglBlendFunc (GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA); @@ -1304,21 +1328,17 @@ void R_DrawGAliasModel (entity_t *e) qglEnable (GL_BLEND); qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); e->alpha = r_wateralpha.value; -// qglColor4f( 1,1,1,r_wateralpha.value); } else if ((e->model->flags & EF_TRANSPARENT)) { qglEnable (GL_BLEND); qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -// qglColor3f( 1,1,1); } else if ((e->model->flags & EF_HOLEY)) { qglEnable (GL_ALPHA_TEST); // qglEnable (GL_BLEND); qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - -// qglColor3f( 1,1,1); } else if (e->alpha < 1) { @@ -1479,6 +1499,12 @@ void R_DrawGAliasModel (entity_t *e) else if (skin->shader) { meshbuffer_t mb; + int olddst = skin->shader->numpasses?skin->shader->passes[0].blenddst:0; + + if (e->flags & Q2RF_ADDATIVE && skin->shader->numpasses) + { //hack the shader into submition. + skin->shader->passes[0].blenddst = GL_ONE; + } mb.entity = &r_worldentity; mb.shader = skin->shader; @@ -1492,6 +1518,11 @@ void R_DrawGAliasModel (entity_t *e) R_PushMesh(&mesh, skin->shader->features | MF_NONBATCHED | MF_COLORS); R_RenderMeshBuffer ( &mb, false ); + + if (e->flags & Q2RF_ADDATIVE && skin->shader->numpasses) + { //hack the shader into submition. + skin->shader->passes[0].blenddst = olddst; + } } #endif else diff --git a/engine/gl/gl_draw.c b/engine/gl/gl_draw.c index 9fe392236..c98e635b3 100644 --- a/engine/gl/gl_draw.c +++ b/engine/gl/gl_draw.c @@ -3251,8 +3251,6 @@ void GL_Upload8Pal32 (qbyte *data, qbyte *pal, int width, int height, qboolean { qbyte *trans = uploadmemorybufferintermediate; int i, s; - qboolean noalpha; - int p; extern qbyte gammatable[256]; s = width*height; diff --git a/engine/gl/gl_ppl.c b/engine/gl/gl_ppl.c index c22c01739..30d658d6f 100644 --- a/engine/gl/gl_ppl.c +++ b/engine/gl/gl_ppl.c @@ -1749,22 +1749,22 @@ void PPL_BaseEntTextures(void) if (currententity->flags & Q2RF_EXTERNALMODEL) continue; -// j = currententity->keynum; -// while(j) -// { -// -// if (j == (cl.viewentity[r_refdef.currentplayernum]?cl.viewentity[r_refdef.currentplayernum]:(cl.playernum[r_refdef.currentplayernum]+1))) -// break; -// -// j = cl.lerpents[j].tagent; -// } -// if (j) -// continue; + j = currententity->keynum; + while(j) + { + + if (j == (cl.viewentity[r_refdef.currentplayernum]?cl.viewentity[r_refdef.currentplayernum]:(cl.playernum[r_refdef.currentplayernum]+1))) + break; -// if (cl.viewentity[r_refdef.currentplayernum] && currententity->keynum == cl.viewentity[r_refdef.currentplayernum]) -// continue; -// if (!Cam_DrawPlayer(0, currententity->keynum-1)) -// continue; + j = cl.lerpents[j].tagent; + } + if (j) + continue; + + if (cl.viewentity[r_refdef.currentplayernum] && currententity->keynum == cl.viewentity[r_refdef.currentplayernum]) + continue; + if (!Cam_DrawPlayer(0, currententity->keynum-1)) + continue; } if (currententity->flags & Q2RF_BEAM) diff --git a/engine/gl/gl_rmain.c b/engine/gl/gl_rmain.c index 1dcf72d6b..9e5b86a90 100644 --- a/engine/gl/gl_rmain.c +++ b/engine/gl/gl_rmain.c @@ -59,6 +59,7 @@ qboolean envmap; // true during envmap command capture int particletexture; // little dot for particles int explosiontexture; +int balltexture; int playertextures; // up to 16 color translated skins int mirrortexturenum; // quake texturenum, not gltexturenum @@ -503,6 +504,22 @@ void R_DrawSpriteModel (entity_t *e) GL_Bind(frame->gl_texturenum); + { + extern int gldepthfunc; + qglDepthFunc(gldepthfunc); + qglDepthMask(1); + if (gldepthmin == 0.5) + qglCullFace ( GL_BACK ); + else + qglCullFace ( GL_FRONT ); + + GL_TexEnv(GL_MODULATE); + + qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + qglDisable (GL_ALPHA_TEST); + qglDisable(GL_BLEND); + } + if (e->flags & Q2RF_ADDATIVE) { qglEnable(GL_BLEND); diff --git a/engine/gl/gl_rmisc.c b/engine/gl/gl_rmisc.c index 40971091e..35ee40b6d 100644 --- a/engine/gl/gl_rmisc.c +++ b/engine/gl/gl_rmisc.c @@ -127,8 +127,10 @@ static qbyte exptexture[16][16] = }; void R_InitParticleTexture (void) { +#define PARTICLETEXTURESIZE 64 int x,y; - qbyte data[16*16][4]; + float dx, dy, d; + qbyte data[PARTICLETEXTURESIZE*PARTICLETEXTURESIZE][4]; // // particle texture @@ -175,6 +177,26 @@ void R_InitParticleTexture (void) qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + + memset(data, 255, sizeof(data)); + for (y = 0;y < PARTICLETEXTURESIZE;y++) + { + dy = (y - 0.5f*PARTICLETEXTURESIZE) / (PARTICLETEXTURESIZE*0.5f-1); + for (x = 0;x < PARTICLETEXTURESIZE;x++) + { + dx = (x - 0.5f*PARTICLETEXTURESIZE) / (PARTICLETEXTURESIZE*0.5f-1); + d = 256 * (1 - (dx*dx+dy*dy)); + d = bound(0, d, 255); + data[y*PARTICLETEXTURESIZE+x][3] = (qbyte) d; + } + } + balltexture = texture_extension_number++; + GL_Bind(balltexture); + qglTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format, PARTICLETEXTURESIZE, PARTICLETEXTURESIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); + qglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } /* diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index 9a0e4bf09..94f676ecb 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -1051,7 +1051,7 @@ void Shader_Free (shader_t *shader) int i; shaderpass_t *pass; - if ( shader->flags & SHADER_SKY ) { + if ( shader->skydome ) { for ( i = 0; i < 5; i++ ) { if (shader->skydome->meshes[i].xyz_array) { @@ -1804,12 +1804,14 @@ void Shader_DefaultSkin(char *shortname, shader_t *s) { shaderpass_t *pass; pass = &s->passes[0]; - pass->flags = SHADER_PASS_DEPTHWRITE; + pass->flags = SHADER_PASS_BLEND|SHADER_PASS_DEPTHWRITE; pass->anim_frames[0] = Mod_LoadHiResTexture(shortname, NULL, true, true, true);//GL_FindImage (shortname, 0); pass->depthfunc = GL_LEQUAL; pass->rgbgen = RGB_GEN_LIGHTING_DIFFUSE; pass->numtcmods = 0; pass->tcgen = TC_GEN_BASE; + pass->blendsrc = GL_SRC_ALPHA; + pass->blenddst = GL_ONE_MINUS_SRC_ALPHA; pass->blendmode = GL_MODULATE; pass->numMergedPasses = 1; pass->flush = R_RenderMeshGeneric; @@ -1821,7 +1823,7 @@ void Shader_DefaultSkin(char *shortname, shader_t *s) s->numpasses = 1; s->numdeforms = 0; - s->flags = SHADER_DEPTHWRITE|SHADER_CULL_FRONT; + s->flags = SHADER_PASS_BLEND|SHADER_DEPTHWRITE|SHADER_CULL_FRONT; s->features = MF_STCOORDS|MF_NORMALS; s->sort = SHADER_SORT_OPAQUE; s->registration_sequence = 1;//fizme: registration_sequence; diff --git a/engine/gl/glquake.h b/engine/gl/glquake.h index 7edc2bc13..a69984155 100644 --- a/engine/gl/glquake.h +++ b/engine/gl/glquake.h @@ -193,6 +193,7 @@ extern int d_lightstylevalue[256]; // 8.8 fraction of base light value extern qboolean envmap; extern int particletexture; extern int explosiontexture; +extern int balltexture; extern int netgraphtexture; // netgraph texture extern int playertextures; diff --git a/engine/http/ftpserver.c b/engine/http/ftpserver.c index 394f01790..b84788388 100644 --- a/engine/http/ftpserver.c +++ b/engine/http/ftpserver.c @@ -47,7 +47,7 @@ #define ioctlsocket ioctl #endif - +int ftpfilelistsocket; char *COM_ParseOut (char *data, char *out, int outlen); @@ -134,7 +134,7 @@ void FTP_ServerShutdown(void) static int SendFileNameTo(char *fname, int size, void *param) { - int socket = (int)param; //64->32... this is safe due to where it's called from. It's just not so portable. + int socket = ftpfilelistsocket; //64->32... this is safe due to where it's called from. It's just not so portable. // int i; char buffer[256+1]; char *slash; @@ -565,7 +565,8 @@ iwboolean FTP_ServerThinkForConnection(FTPclient_t *cl) strcat(buffer, "*"); QueueMessage (cl, "125 Opening FAKE ASCII mode data connection for file.\r\n"); - COM_EnumerateFiles(buffer, SendFileNameTo, (void*)cl->datasock); //32->64 this is safe + ftpfilelistsocket = cl->datasock; + COM_EnumerateFiles(buffer, SendFileNameTo, NULL); QueueMessage (cl, "226 Transfer complete.\r\n"); diff --git a/engine/nqnet/net_main.c b/engine/nqnet/net_main.c index 40f9189e4..2c5b63a58 100644 --- a/engine/nqnet/net_main.c +++ b/engine/nqnet/net_main.c @@ -640,8 +640,8 @@ int NET_SendToAll(sizebuf_t *data, int blocktime) double start; int i; int count = 0; - qboolean state1 [MAX_SCOREBOARD]; - qboolean state2 [MAX_SCOREBOARD]; + qboolean state1 [MAX_CLIENTS]; + qboolean state2 [MAX_CLIENTS]; for (i=0, host_client = svs.clients ; i<32 ; i++, host_client++) { diff --git a/engine/qclib/execloop.h b/engine/qclib/execloop.h index 76d1348f0..3814e4f35 100644 --- a/engine/qclib/execloop.h +++ b/engine/qclib/execloop.h @@ -35,6 +35,9 @@ #error Bad cont size #endif +#define ENGINEPOINTER(p) ((char*)(p) - progfuncs->stringtable) +#define QCPOINTER(p) (eval_t *)(p->_int+progfuncs->stringtable) +#define QCPOINTERM(p) (eval_t *)((p)+progfuncs->stringtable) //rely upon just st { @@ -286,15 +289,15 @@ reeval: //store a value to a pointer case OP_STOREP_IF: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_float = (float)OPA->_int; break; case OP_STOREP_FI: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_int = (int)OPA->_float; break; case OP_STOREP_I: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_int = OPA->_int; break; case OP_STOREP_F: @@ -302,18 +305,18 @@ reeval: case OP_STOREP_FLD: // integers case OP_STOREP_S: case OP_STOREP_FNC: // pointers - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_int = OPA->_int; break; case OP_STOREP_V: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->vector[0] = OPA->vector[0]; ptr->vector[1] = OPA->vector[1]; ptr->vector[2] = OPA->vector[2]; break; case OP_STOREP_C: //store character in a string - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); *(unsigned char *)ptr = (char)OPA->_float; break; @@ -326,11 +329,11 @@ reeval: OPB->vector[2] *= OPA->_float; break; case OP_MULSTOREP_F: // e.f *= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float *= OPA->_float); break; case OP_MULSTOREP_V: // e.v *= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->vector[0] = (ptr->vector[0] *= OPA->_float); OPC->vector[0] = (ptr->vector[1] *= OPA->_float); OPC->vector[0] = (ptr->vector[2] *= OPA->_float); @@ -340,7 +343,7 @@ reeval: OPB->_float /= OPA->_float; break; case OP_DIVSTOREP_F: // e.f /= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float /= OPA->_float); break; @@ -353,11 +356,11 @@ reeval: OPB->vector[2] += OPA->vector[2]; break; case OP_ADDSTOREP_F: // e.f += f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float += OPA->_float); break; case OP_ADDSTOREP_V: // e.v += v - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->vector[0] = (ptr->vector[0] += OPA->vector[0]); OPC->vector[1] = (ptr->vector[1] += OPA->vector[1]); OPC->vector[2] = (ptr->vector[2] += OPA->vector[2]); @@ -372,11 +375,11 @@ reeval: OPB->vector[2] -= OPA->vector[2]; break; case OP_SUBSTOREP_F: // e.f -= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float -= OPA->_float); break; case OP_SUBSTOREP_V: // e.v -= v - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->vector[0] = (ptr->vector[0] -= OPA->vector[0]); OPC->vector[1] = (ptr->vector[1] -= OPA->vector[1]); OPC->vector[2] = (ptr->vector[2] -= OPA->vector[2]); @@ -394,7 +397,7 @@ reeval: pr_xstatement = st-pr_statements; PR_RunError (progfuncs, "assignment to read-only entity in %s", pr_xfunction->s_name); } - OPC->_int = (int)(((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust); + OPC->_int = ENGINEPOINTER((((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust)); break; //load a field to a value @@ -533,9 +536,9 @@ reeval: i -= externs->numglobalbuiltins; if (i >= current_progstate->numbuiltins) { - if (newf->first_statement == -0x7fffffff) - ((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals); - else +// if (newf->first_statement == -0x7fffffff) +// ((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals); +// else PR_RunError (progfuncs, "Bad builtin call number - %i", -newf->first_statement); } else @@ -651,7 +654,7 @@ reeval: //array/structure reading/riting. case OP_GLOBALADDRESS: - OPC->_int = (int)(&OPA->_int) + OPB->_int; + OPC->_int = ENGINEPOINTER(&OPA->_int + OPB->_int/4); break; case OP_POINTER_ADD: //pointer to 32 bit (remember to *3 for vectors) OPC->_int = OPA->_int + OPB->_int*4; @@ -683,7 +686,7 @@ reeval: OPC->_int = OPA->_int - OPB->_int; break; case OP_LOADP_C: //load character from a string - ptr = (eval_t *)(OPA->_int + (int)OPB->_float); + ptr = QCPOINTERM(OPA->_int + (int)OPB->_float); OPC->_float = *(unsigned char *)ptr; break; case OP_LOADP_I: @@ -692,12 +695,12 @@ reeval: case OP_LOADP_ENT: case OP_LOADP_S: case OP_LOADP_FNC: - ptr = (eval_t *)(OPA->_int + OPB->_int); + ptr = QCPOINTERM(OPA->_int + OPB->_int); OPC->_int = ptr->_int; break; case OP_LOADP_V: - ptr = (eval_t *)(OPA->_int + OPB->_int); + ptr = QCPOINTERM(OPA->_int + OPB->_int); OPC->vector[0] = ptr->vector[0]; OPC->vector[1] = ptr->vector[1]; OPC->vector[2] = ptr->vector[2]; @@ -756,14 +759,14 @@ reeval: OPB->_float = (float)((int)OPB->_float | (int)OPA->_float); break; case OP_BITSETP: // .b (+) a - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_float = (float)((int)ptr->_float | (int)OPA->_float); break; case OP_BITCLR: // b (-) a OPB->_float = (float)((int)OPB->_float & ~((int)OPA->_float)); break; case OP_BITCLRP: // .b (-) a - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_float = (float)((int)ptr->_float & ~((int)OPA->_float)); break; @@ -984,8 +987,8 @@ reeval: PR_RunError(progfuncs, "Progs boundcheck failed. Value is %i.", OPA->_int); } break; - case OP_PUSH: - OPC->_int = (int)&localstack[localstack_used+pr_spushed]; +/* case OP_PUSH: + OPC->_int = ENGINEPOINTER(&localstack[localstack_used+pr_spushed]); pr_spushed += OPA->_int; if (pr_spushed + localstack_used >= LOCALSTACK_SIZE) { @@ -1003,7 +1006,7 @@ reeval: PR_RunError(progfuncs, "Progs poped more than it pushed"); } break; - +*/ default: if (st->op & 0x8000) //break point! { @@ -1041,3 +1044,7 @@ reeval: #undef dstatement_t #undef sofs #undef uofs + +#undef ENGINEPOINTER +#undef QCPOINTER +#undef QCPOINTERM \ No newline at end of file diff --git a/engine/qclib/execloop16d.h b/engine/qclib/execloop16d.h index 76d1348f0..c42b03069 100644 --- a/engine/qclib/execloop16d.h +++ b/engine/qclib/execloop16d.h @@ -35,6 +35,9 @@ #error Bad cont size #endif +#define ENGINEPOINTER(p) ((char*)(p) - progfuncs->stringtable) +#define QCPOINTER(p) (eval_t *)(p->_int+progfuncs->stringtable) +#define QCPOINTERM(p) (eval_t *)((p)+progfuncs->stringtable) //rely upon just st { @@ -286,15 +289,15 @@ reeval: //store a value to a pointer case OP_STOREP_IF: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_float = (float)OPA->_int; break; case OP_STOREP_FI: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_int = (int)OPA->_float; break; case OP_STOREP_I: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_int = OPA->_int; break; case OP_STOREP_F: @@ -302,18 +305,18 @@ reeval: case OP_STOREP_FLD: // integers case OP_STOREP_S: case OP_STOREP_FNC: // pointers - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_int = OPA->_int; break; case OP_STOREP_V: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->vector[0] = OPA->vector[0]; ptr->vector[1] = OPA->vector[1]; ptr->vector[2] = OPA->vector[2]; break; case OP_STOREP_C: //store character in a string - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); *(unsigned char *)ptr = (char)OPA->_float; break; @@ -326,11 +329,11 @@ reeval: OPB->vector[2] *= OPA->_float; break; case OP_MULSTOREP_F: // e.f *= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float *= OPA->_float); break; case OP_MULSTOREP_V: // e.v *= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->vector[0] = (ptr->vector[0] *= OPA->_float); OPC->vector[0] = (ptr->vector[1] *= OPA->_float); OPC->vector[0] = (ptr->vector[2] *= OPA->_float); @@ -340,7 +343,7 @@ reeval: OPB->_float /= OPA->_float; break; case OP_DIVSTOREP_F: // e.f /= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float /= OPA->_float); break; @@ -353,11 +356,11 @@ reeval: OPB->vector[2] += OPA->vector[2]; break; case OP_ADDSTOREP_F: // e.f += f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float += OPA->_float); break; case OP_ADDSTOREP_V: // e.v += v - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->vector[0] = (ptr->vector[0] += OPA->vector[0]); OPC->vector[1] = (ptr->vector[1] += OPA->vector[1]); OPC->vector[2] = (ptr->vector[2] += OPA->vector[2]); @@ -372,11 +375,11 @@ reeval: OPB->vector[2] -= OPA->vector[2]; break; case OP_SUBSTOREP_F: // e.f -= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float -= OPA->_float); break; case OP_SUBSTOREP_V: // e.v -= v - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->vector[0] = (ptr->vector[0] -= OPA->vector[0]); OPC->vector[1] = (ptr->vector[1] -= OPA->vector[1]); OPC->vector[2] = (ptr->vector[2] -= OPA->vector[2]); @@ -394,7 +397,7 @@ reeval: pr_xstatement = st-pr_statements; PR_RunError (progfuncs, "assignment to read-only entity in %s", pr_xfunction->s_name); } - OPC->_int = (int)(((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust); + OPC->_int = ENGINEPOINTER((((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust)); break; //load a field to a value @@ -533,9 +536,9 @@ reeval: i -= externs->numglobalbuiltins; if (i >= current_progstate->numbuiltins) { - if (newf->first_statement == -0x7fffffff) - ((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals); - else +// if (newf->first_statement == -0x7fffffff) +// ((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals); +// else PR_RunError (progfuncs, "Bad builtin call number - %i", -newf->first_statement); } else @@ -651,7 +654,7 @@ reeval: //array/structure reading/riting. case OP_GLOBALADDRESS: - OPC->_int = (int)(&OPA->_int) + OPB->_int; + OPC->_int = ENGINEPOINTER(&OPA->_int + OPB->_int/4); break; case OP_POINTER_ADD: //pointer to 32 bit (remember to *3 for vectors) OPC->_int = OPA->_int + OPB->_int*4; @@ -683,7 +686,7 @@ reeval: OPC->_int = OPA->_int - OPB->_int; break; case OP_LOADP_C: //load character from a string - ptr = (eval_t *)(OPA->_int + (int)OPB->_float); + ptr = QCPOINTERM(OPA->_int + (int)OPB->_float); OPC->_float = *(unsigned char *)ptr; break; case OP_LOADP_I: @@ -692,12 +695,12 @@ reeval: case OP_LOADP_ENT: case OP_LOADP_S: case OP_LOADP_FNC: - ptr = (eval_t *)(OPA->_int + OPB->_int); + ptr = QCPOINTERM(OPA->_int + OPB->_int); OPC->_int = ptr->_int; break; case OP_LOADP_V: - ptr = (eval_t *)(OPA->_int + OPB->_int); + ptr = QCPOINTERM(OPA->_int + OPB->_int); OPC->vector[0] = ptr->vector[0]; OPC->vector[1] = ptr->vector[1]; OPC->vector[2] = ptr->vector[2]; @@ -756,14 +759,14 @@ reeval: OPB->_float = (float)((int)OPB->_float | (int)OPA->_float); break; case OP_BITSETP: // .b (+) a - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_float = (float)((int)ptr->_float | (int)OPA->_float); break; case OP_BITCLR: // b (-) a OPB->_float = (float)((int)OPB->_float & ~((int)OPA->_float)); break; case OP_BITCLRP: // .b (-) a - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_float = (float)((int)ptr->_float & ~((int)OPA->_float)); break; @@ -1041,3 +1044,7 @@ reeval: #undef dstatement_t #undef sofs #undef uofs + +#undef ENGINEPOINTER +#undef QCPOINTER +#undef QCPOINTERM \ No newline at end of file diff --git a/engine/qclib/execloop32.h b/engine/qclib/execloop32.h index 76d1348f0..c42b03069 100644 --- a/engine/qclib/execloop32.h +++ b/engine/qclib/execloop32.h @@ -35,6 +35,9 @@ #error Bad cont size #endif +#define ENGINEPOINTER(p) ((char*)(p) - progfuncs->stringtable) +#define QCPOINTER(p) (eval_t *)(p->_int+progfuncs->stringtable) +#define QCPOINTERM(p) (eval_t *)((p)+progfuncs->stringtable) //rely upon just st { @@ -286,15 +289,15 @@ reeval: //store a value to a pointer case OP_STOREP_IF: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_float = (float)OPA->_int; break; case OP_STOREP_FI: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_int = (int)OPA->_float; break; case OP_STOREP_I: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_int = OPA->_int; break; case OP_STOREP_F: @@ -302,18 +305,18 @@ reeval: case OP_STOREP_FLD: // integers case OP_STOREP_S: case OP_STOREP_FNC: // pointers - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_int = OPA->_int; break; case OP_STOREP_V: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->vector[0] = OPA->vector[0]; ptr->vector[1] = OPA->vector[1]; ptr->vector[2] = OPA->vector[2]; break; case OP_STOREP_C: //store character in a string - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); *(unsigned char *)ptr = (char)OPA->_float; break; @@ -326,11 +329,11 @@ reeval: OPB->vector[2] *= OPA->_float; break; case OP_MULSTOREP_F: // e.f *= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float *= OPA->_float); break; case OP_MULSTOREP_V: // e.v *= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->vector[0] = (ptr->vector[0] *= OPA->_float); OPC->vector[0] = (ptr->vector[1] *= OPA->_float); OPC->vector[0] = (ptr->vector[2] *= OPA->_float); @@ -340,7 +343,7 @@ reeval: OPB->_float /= OPA->_float; break; case OP_DIVSTOREP_F: // e.f /= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float /= OPA->_float); break; @@ -353,11 +356,11 @@ reeval: OPB->vector[2] += OPA->vector[2]; break; case OP_ADDSTOREP_F: // e.f += f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float += OPA->_float); break; case OP_ADDSTOREP_V: // e.v += v - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->vector[0] = (ptr->vector[0] += OPA->vector[0]); OPC->vector[1] = (ptr->vector[1] += OPA->vector[1]); OPC->vector[2] = (ptr->vector[2] += OPA->vector[2]); @@ -372,11 +375,11 @@ reeval: OPB->vector[2] -= OPA->vector[2]; break; case OP_SUBSTOREP_F: // e.f -= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float -= OPA->_float); break; case OP_SUBSTOREP_V: // e.v -= v - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->vector[0] = (ptr->vector[0] -= OPA->vector[0]); OPC->vector[1] = (ptr->vector[1] -= OPA->vector[1]); OPC->vector[2] = (ptr->vector[2] -= OPA->vector[2]); @@ -394,7 +397,7 @@ reeval: pr_xstatement = st-pr_statements; PR_RunError (progfuncs, "assignment to read-only entity in %s", pr_xfunction->s_name); } - OPC->_int = (int)(((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust); + OPC->_int = ENGINEPOINTER((((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust)); break; //load a field to a value @@ -533,9 +536,9 @@ reeval: i -= externs->numglobalbuiltins; if (i >= current_progstate->numbuiltins) { - if (newf->first_statement == -0x7fffffff) - ((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals); - else +// if (newf->first_statement == -0x7fffffff) +// ((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals); +// else PR_RunError (progfuncs, "Bad builtin call number - %i", -newf->first_statement); } else @@ -651,7 +654,7 @@ reeval: //array/structure reading/riting. case OP_GLOBALADDRESS: - OPC->_int = (int)(&OPA->_int) + OPB->_int; + OPC->_int = ENGINEPOINTER(&OPA->_int + OPB->_int/4); break; case OP_POINTER_ADD: //pointer to 32 bit (remember to *3 for vectors) OPC->_int = OPA->_int + OPB->_int*4; @@ -683,7 +686,7 @@ reeval: OPC->_int = OPA->_int - OPB->_int; break; case OP_LOADP_C: //load character from a string - ptr = (eval_t *)(OPA->_int + (int)OPB->_float); + ptr = QCPOINTERM(OPA->_int + (int)OPB->_float); OPC->_float = *(unsigned char *)ptr; break; case OP_LOADP_I: @@ -692,12 +695,12 @@ reeval: case OP_LOADP_ENT: case OP_LOADP_S: case OP_LOADP_FNC: - ptr = (eval_t *)(OPA->_int + OPB->_int); + ptr = QCPOINTERM(OPA->_int + OPB->_int); OPC->_int = ptr->_int; break; case OP_LOADP_V: - ptr = (eval_t *)(OPA->_int + OPB->_int); + ptr = QCPOINTERM(OPA->_int + OPB->_int); OPC->vector[0] = ptr->vector[0]; OPC->vector[1] = ptr->vector[1]; OPC->vector[2] = ptr->vector[2]; @@ -756,14 +759,14 @@ reeval: OPB->_float = (float)((int)OPB->_float | (int)OPA->_float); break; case OP_BITSETP: // .b (+) a - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_float = (float)((int)ptr->_float | (int)OPA->_float); break; case OP_BITCLR: // b (-) a OPB->_float = (float)((int)OPB->_float & ~((int)OPA->_float)); break; case OP_BITCLRP: // .b (-) a - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_float = (float)((int)ptr->_float & ~((int)OPA->_float)); break; @@ -1041,3 +1044,7 @@ reeval: #undef dstatement_t #undef sofs #undef uofs + +#undef ENGINEPOINTER +#undef QCPOINTER +#undef QCPOINTERM \ No newline at end of file diff --git a/engine/qclib/execloop32d.h b/engine/qclib/execloop32d.h index 76d1348f0..c42b03069 100644 --- a/engine/qclib/execloop32d.h +++ b/engine/qclib/execloop32d.h @@ -35,6 +35,9 @@ #error Bad cont size #endif +#define ENGINEPOINTER(p) ((char*)(p) - progfuncs->stringtable) +#define QCPOINTER(p) (eval_t *)(p->_int+progfuncs->stringtable) +#define QCPOINTERM(p) (eval_t *)((p)+progfuncs->stringtable) //rely upon just st { @@ -286,15 +289,15 @@ reeval: //store a value to a pointer case OP_STOREP_IF: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_float = (float)OPA->_int; break; case OP_STOREP_FI: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_int = (int)OPA->_float; break; case OP_STOREP_I: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_int = OPA->_int; break; case OP_STOREP_F: @@ -302,18 +305,18 @@ reeval: case OP_STOREP_FLD: // integers case OP_STOREP_S: case OP_STOREP_FNC: // pointers - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_int = OPA->_int; break; case OP_STOREP_V: - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->vector[0] = OPA->vector[0]; ptr->vector[1] = OPA->vector[1]; ptr->vector[2] = OPA->vector[2]; break; case OP_STOREP_C: //store character in a string - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); *(unsigned char *)ptr = (char)OPA->_float; break; @@ -326,11 +329,11 @@ reeval: OPB->vector[2] *= OPA->_float; break; case OP_MULSTOREP_F: // e.f *= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float *= OPA->_float); break; case OP_MULSTOREP_V: // e.v *= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->vector[0] = (ptr->vector[0] *= OPA->_float); OPC->vector[0] = (ptr->vector[1] *= OPA->_float); OPC->vector[0] = (ptr->vector[2] *= OPA->_float); @@ -340,7 +343,7 @@ reeval: OPB->_float /= OPA->_float; break; case OP_DIVSTOREP_F: // e.f /= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float /= OPA->_float); break; @@ -353,11 +356,11 @@ reeval: OPB->vector[2] += OPA->vector[2]; break; case OP_ADDSTOREP_F: // e.f += f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float += OPA->_float); break; case OP_ADDSTOREP_V: // e.v += v - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->vector[0] = (ptr->vector[0] += OPA->vector[0]); OPC->vector[1] = (ptr->vector[1] += OPA->vector[1]); OPC->vector[2] = (ptr->vector[2] += OPA->vector[2]); @@ -372,11 +375,11 @@ reeval: OPB->vector[2] -= OPA->vector[2]; break; case OP_SUBSTOREP_F: // e.f -= f - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->_float = (ptr->_float -= OPA->_float); break; case OP_SUBSTOREP_V: // e.v -= v - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); OPC->vector[0] = (ptr->vector[0] -= OPA->vector[0]); OPC->vector[1] = (ptr->vector[1] -= OPA->vector[1]); OPC->vector[2] = (ptr->vector[2] -= OPA->vector[2]); @@ -394,7 +397,7 @@ reeval: pr_xstatement = st-pr_statements; PR_RunError (progfuncs, "assignment to read-only entity in %s", pr_xfunction->s_name); } - OPC->_int = (int)(((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust); + OPC->_int = ENGINEPOINTER((((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust)); break; //load a field to a value @@ -533,9 +536,9 @@ reeval: i -= externs->numglobalbuiltins; if (i >= current_progstate->numbuiltins) { - if (newf->first_statement == -0x7fffffff) - ((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals); - else +// if (newf->first_statement == -0x7fffffff) +// ((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals); +// else PR_RunError (progfuncs, "Bad builtin call number - %i", -newf->first_statement); } else @@ -651,7 +654,7 @@ reeval: //array/structure reading/riting. case OP_GLOBALADDRESS: - OPC->_int = (int)(&OPA->_int) + OPB->_int; + OPC->_int = ENGINEPOINTER(&OPA->_int + OPB->_int/4); break; case OP_POINTER_ADD: //pointer to 32 bit (remember to *3 for vectors) OPC->_int = OPA->_int + OPB->_int*4; @@ -683,7 +686,7 @@ reeval: OPC->_int = OPA->_int - OPB->_int; break; case OP_LOADP_C: //load character from a string - ptr = (eval_t *)(OPA->_int + (int)OPB->_float); + ptr = QCPOINTERM(OPA->_int + (int)OPB->_float); OPC->_float = *(unsigned char *)ptr; break; case OP_LOADP_I: @@ -692,12 +695,12 @@ reeval: case OP_LOADP_ENT: case OP_LOADP_S: case OP_LOADP_FNC: - ptr = (eval_t *)(OPA->_int + OPB->_int); + ptr = QCPOINTERM(OPA->_int + OPB->_int); OPC->_int = ptr->_int; break; case OP_LOADP_V: - ptr = (eval_t *)(OPA->_int + OPB->_int); + ptr = QCPOINTERM(OPA->_int + OPB->_int); OPC->vector[0] = ptr->vector[0]; OPC->vector[1] = ptr->vector[1]; OPC->vector[2] = ptr->vector[2]; @@ -756,14 +759,14 @@ reeval: OPB->_float = (float)((int)OPB->_float | (int)OPA->_float); break; case OP_BITSETP: // .b (+) a - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_float = (float)((int)ptr->_float | (int)OPA->_float); break; case OP_BITCLR: // b (-) a OPB->_float = (float)((int)OPB->_float & ~((int)OPA->_float)); break; case OP_BITCLRP: // .b (-) a - ptr = (eval_t *)(OPB->_int); + ptr = QCPOINTER(OPB); ptr->_float = (float)((int)ptr->_float & ~((int)OPA->_float)); break; @@ -1041,3 +1044,7 @@ reeval: #undef dstatement_t #undef sofs #undef uofs + +#undef ENGINEPOINTER +#undef QCPOINTER +#undef QCPOINTERM \ No newline at end of file diff --git a/engine/qclib/initlib.c b/engine/qclib/initlib.c index 3c872ae13..c36e96312 100644 --- a/engine/qclib/initlib.c +++ b/engine/qclib/initlib.c @@ -76,6 +76,7 @@ void PRAddressableFlush(progfuncs_t *progfuncs, int totalammount) #else free(addressablehunk); addressablehunk = malloc(totalammount); //linux will allocate-on-use anyway, which is handy. +// memset(addressablehunk, 0xff, totalammount); #endif addressablesize = totalammount; } @@ -92,6 +93,7 @@ int PR_InitEnts(progfuncs_t *progfuncs, int max_ents) sv_edicts = PRHunkAlloc(progfuncs, externs->edictsize); prinst->edicttable[0] = sv_edicts; ((edictrun_t*)prinst->edicttable[0])->fields = PRAddressableAlloc(progfuncs, max_fields_size); + ED_ClearEdict(progfuncs, sv_edicts); sv_num_edicts = 1; return max_fields_size; diff --git a/engine/qclib/pr_edict.c b/engine/qclib/pr_edict.c index 2490ffd1c..f6ecc75c1 100644 --- a/engine/qclib/pr_edict.c +++ b/engine/qclib/pr_edict.c @@ -950,13 +950,17 @@ void ED_Count (progfuncs_t *progfuncs) ED_NewString ============= */ -char *ED_NewString (progfuncs_t *progfuncs, char *string) +char *ED_NewString (progfuncs_t *progfuncs, char *string, int minlength) { char *new, *new_p; int i,l; + + minlength++; l = strlen(string) + 1; - new = PRHunkAlloc (progfuncs, l); + if (l < minlength) + l = minlength; + new = PRAddressableAlloc (progfuncs, l); new_p = new; for (i=0 ; i< l ; i++) @@ -1023,7 +1027,7 @@ pbool ED_ParseEpair (progfuncs_t *progfuncs, void *base, ddefXX_t *key, char *s, switch (type) { case ev_string: - st = ED_NewString (progfuncs, s)-progfuncs->stringtable; + st = ED_NewString (progfuncs, s, 0)-progfuncs->stringtable; *(string_t *)d = st; break; @@ -1687,6 +1691,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags) Sys_Error("Edict was not allocated\n"); prinst->edicttable[num] = *(struct edict_s **)&ed = (void*)memalloc(externs->edictsize); ed->fields = PRAddressableAlloc(progfuncs, fields_size); + ED_ClearEdict(progfuncs, ed); ed->entnum = num; } } @@ -1780,6 +1785,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags) { prinst->edicttable[num] = *(struct edict_s **)&ed = (void*)memalloc(externs->edictsize); ed->fields = PRAddressableAlloc(progfuncs, fields_size); + ED_ClearEdict(progfuncs, ed); ed->entnum = num; ed->isfree = true; } @@ -1938,6 +1944,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags) { prinst->edicttable[numents] = *(struct edict_s **)&ed = (void*)memalloc(externs->edictsize); ed->fields = PRAddressableAlloc(progfuncs, fields_size); + ED_ClearEdict(progfuncs, ed); ed->entnum = numents; ed->isfree = true; } @@ -1963,6 +1970,7 @@ int LoadEnts(progfuncs_t *progfuncs, char *file, float killonspawnflags) { prinst->edicttable[num] = *(struct edict_s **)&ed = (void*)memalloc(externs->edictsize); ed->fields = PRAddressableAlloc(progfuncs, fields_size); + ED_ClearEdict(progfuncs, ed); ed->entnum = num; ed->isfree = true; } @@ -2173,6 +2181,40 @@ pbool PR_TestRecompile(progfuncs_t *progfuncs) return false; } +#ifdef _DEBUG +//this is for debugging. +//I'm using this to detect incorrect string types while converting 32bit string pointers with bias to bound indexes. +void PR_TestForWierdness(progfuncs_t *progfuncs) +{ + unsigned int i; + int e; + edictrun_t *ed; + for (i = 0; i < pr_progs->numglobaldefs; i++) + { + if ((pr_globaldefs16[i].type&~(DEF_SHARED|DEF_SAVEGLOBAL)) == ev_string) + { + if (G_INT(pr_globaldefs16[i].ofs) < 0 || G_INT(pr_globaldefs16[i].ofs) >= addressableused) + printf("String type irregularity on \"%s\" \"%s\"\n", pr_globaldefs16[i].s_name+progfuncs->stringtable, G_INT(pr_globaldefs16[i].ofs)+progfuncs->stringtable); + } + } + + for (i = 0; i < numfields; i++) + { + if ((field[i].type&~(DEF_SHARED|DEF_SAVEGLOBAL)) == ev_string) + { + for (e = 0; e < sv_num_edicts; e++) + { + ed = EDICT_NUM(progfuncs, e); + if (ed->isfree) + continue; + if (((int *)ed->fields)[field[i].ofs] < 0 || ((int *)ed->fields)[field[i].ofs] >= addressableused) + printf("String type irregularity \"%s\" \"%s\"\n", field[i].name, ((int *)ed->fields)[field[i].ofs]+progfuncs->stringtable); + } + } + } +} +#endif + char *decode(int complen, int len, int method, char *info, char *buffer); /* =============== diff --git a/engine/qclib/pr_exec.c b/engine/qclib/pr_exec.c index fde434785..fc48cc946 100644 --- a/engine/qclib/pr_exec.c +++ b/engine/qclib/pr_exec.c @@ -446,7 +446,7 @@ char *EvaluateDebugString(progfuncs_t *progfuncs, char *key) switch (def->type&~DEF_SAVEGLOBAL) { case ev_string: - *(string_t *)val = ED_NewString (progfuncs, assignment)-progfuncs->stringtable; + *(string_t *)val = ED_NewString (progfuncs, assignment, 0)-progfuncs->stringtable; break; case ev_float: @@ -565,7 +565,7 @@ int PR_ToggleBreakpoint(progfuncs_t *progfuncs, char *filename, int linenum, int for (f = pr_progstate[pn].functions, fl = 0; fl < pr_progstate[pn].progs->numfunctions; f++, fl++) { - if (!stricmp(f->s_file, filename)) + if (!stricmp(f->s_file+progfuncs->stringtable, filename)) { for (i = f->first_statement; ; i++) { @@ -713,7 +713,7 @@ int ShowStep(progfuncs_t *progfuncs, int statement) // return statement; // texture realcursortex; static int lastline = 0; -static char *lastfile = NULL; +static char *lastfile = 0; int pn = pr_typecurrent; int i; @@ -721,11 +721,11 @@ static char *lastfile = NULL; if (f && pr_progstate[pn].linenums && externs->useeditor) { - if (lastline == pr_progstate[pn].linenums[statement] && lastfile == f->s_file) + if (lastline == pr_progstate[pn].linenums[statement] && lastfile == f->s_file+progfuncs->stringtable) return statement; //no info/same line as last time lastline = pr_progstate[pn].linenums[statement]; - lastfile = f->s_file; + lastfile = f->s_file+progfuncs->stringtable; lastline = externs->useeditor(lastfile, lastline, 0, NULL); @@ -747,7 +747,7 @@ static char *lastfile = NULL; else if (f) //annoying. { if (externs->useeditor) - externs->useeditor(f->s_file, -1, 0, &f->s_name); + externs->useeditor(f->s_file+progfuncs->stringtable, -1, 0, NULL); return statement; } @@ -929,10 +929,6 @@ void PR_ExecuteProgram (progfuncs_t *progfuncs, func_t fnum) - - - - typedef struct { int fnum; int progsnum; diff --git a/engine/qclib/progsint.h b/engine/qclib/progsint.h index 7770b9cc3..55bfd5348 100644 --- a/engine/qclib/progsint.h +++ b/engine/qclib/progsint.h @@ -228,7 +228,7 @@ void PR_Profile_f (void); struct edict_s *ED_Alloc (progfuncs_t *progfuncs); void ED_Free (progfuncs_t *progfuncs, struct edict_s *ed); -char *ED_NewString (progfuncs_t *progfuncs, char *string); +char *ED_NewString (progfuncs_t *progfuncs, char *string, int minlength); // returns a copy of the string allocated from the server's string heap void ED_Print (progfuncs_t *progfuncs, struct edict_s *ed); diff --git a/engine/qclib/progslib.h b/engine/qclib/progslib.h index 3586f7ded..ebb021ae1 100644 --- a/engine/qclib/progslib.h +++ b/engine/qclib/progslib.h @@ -85,7 +85,7 @@ struct progfuncs_s { struct edict_s *(*restoreent) (progfuncs_t *prinst, char *buf, int *size, struct edict_s *ed); //will restore the entity that had it's values saved (can use NULL for ed) union eval_s *(*FindGlobal) (progfuncs_t *prinst, char *name, progsnum_t num); //find a pointer to the globals value - char *(*AddString) (progfuncs_t *prinst, char *val); //dump a string into the progs memory (for setting globals and whatnot) + char *(*AddString) (progfuncs_t *prinst, char *val, int minlength); //dump a string into the progs memory (for setting globals and whatnot) void *(*Tempmem) (progfuncs_t *prinst, int ammount, char *whatfor); //grab some mem for as long as the progs stays loaded (for strings) union eval_s *(*GetEdictFieldValue) (progfuncs_t *prinst, struct edict_s *ent, char *name, evalc_t *s); //get an entityvar (cache it) and return the possible values @@ -234,7 +234,7 @@ typedef union eval_s #define PR_FindFunction(pf, name, num) (*pf->FindFunction) (pf, name, num) #define PR_FindGlobal(pf, name, progs) (*pf->FindGlobal) (pf, name, progs) -#define PR_AddString(pf, ed) (*pf->AddString) (pf, ed) +#define PR_AddString(pf, ed, len) (*pf->AddString) (pf, ed, len) #define PR_Alloc(pf,size) (*pf->Tempmem) (pf, size) #define PROG_TO_EDICT(pf, ed) (*pf->ProgsToEdict) (pf, ed) @@ -259,7 +259,7 @@ typedef union eval_s #define PR_GetString(p,s) (s?s + p->stringtable:"") #define PR_GetStringOfs(p,o) (G_INT(o)?G_INT(o) + p->stringtable:"") #define PR_SetString(p, s) ((s&&*s)?(s - p->stringtable):0) -#define PR_NewString(p, s) (PR_AddString(p, s) - p->stringtable) +#define PR_NewString(p, s, l) (PR_AddString(p, s, l) - p->stringtable) #define ev_prog ev_integer diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index e4e8edac4..93e905ec1 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -806,6 +806,13 @@ void PR_BreakPoint_f(void) } +#ifdef _DEBUG +void QCLibTest(void) +{ + PR_TestForWierdness(svprogfuncs); +} +#endif + typedef char char32[32]; char32 sv_addonname[MAXADDONS]; void PR_Init(void) @@ -815,7 +822,9 @@ void PR_Init(void) Cmd_AddCommand ("decompile", PR_Decompile_f); Cmd_AddCommand ("compile", PR_Compile_f); Cmd_AddCommand ("applycompile", PR_ApplyCompilation_f); - +#ifdef _DEBUG + Cmd_AddCommand ("svtestprogs", QCLibTest); +#endif Cvar_Register(&pr_maxedicts, cvargroup_progs); Cvar_Register(&pr_imitatemvdsv, cvargroup_progs); Cvar_Register(&pr_fixbrokenqccarrays, cvargroup_progs); @@ -1393,7 +1402,7 @@ int PR_SizeOfFile(char *filename) prnumforfile=svs.numprogs-1; while(prnumforfile>=0) { - if ((qbyte *)svprogfuncs->filefromprogs(svprogfuncs, prnumforfile, filename, &com_filesize, NULL)==(qbyte *)0xffffffff) + if ((qbyte *)svprogfuncs->filefromprogs(svprogfuncs, prnumforfile, filename, &com_filesize, NULL)==(qbyte *)-1) return com_filesize; prnumforfile--; } @@ -1437,7 +1446,7 @@ char *PF_VarString (progfuncs_t *prinst, int first, globalvars_t *pr_globals) #define RETURN_SSTRING(s) (((int *)pr_globals)[OFS_RETURN] = PR_SetString(prinst, s)) //static - exe will not change it. #define RETURN_TSTRING(s) (((int *)pr_globals)[OFS_RETURN] = PR_SetString(prinst, s)) //temp (static but cycle buffers?) #define RETURN_CSTRING(s) (((int *)pr_globals)[OFS_RETURN] = PR_SetString(prinst, s)) //semi-permanant. (hash tables?) -#define RETURN_PSTRING(s) (((int *)pr_globals)[OFS_RETURN] = PR_NewString(prinst, s)) //permanant +#define RETURN_PSTRING(s) (((int *)pr_globals)[OFS_RETURN] = PR_NewString(prinst, s, 0)) //permanant /* =============================================================================== @@ -1459,6 +1468,7 @@ void PF_externcall (progfuncs_t *prinst, globalvars_t *pr_globals) //this func c int progsnum; char *funcname; int i; + string_t failedst = G_INT(OFS_PARM1); func_t f; progsnum = G_PROG(OFS_PARM0); @@ -1484,7 +1494,7 @@ void PF_externcall (progfuncs_t *prinst, globalvars_t *pr_globals) //this func c for (i = OFS_PARM0; i < OFS_PARM6; i+=3) VectorCopy(G_VECTOR(i+(1*3)), G_VECTOR(i)); - G_INT(OFS_PARM0) = (int)funcname; + G_INT(OFS_PARM0) = failedst; (*prinst->pr_trace)++; //continue debugging PR_ExecuteProgram(prinst, f); @@ -1768,11 +1778,11 @@ void PF_setmodel (progfuncs_t *prinst, struct globalvars_s *pr_globals) break; } } - if (i==MAX_MODELS || !*sv.model_precache[i]) + if (i==MAX_MODELS || !sv.model_precache[i]) { if (i!=MAX_MODELS && sv.state == ss_loading) { - Q_strncpyz(sv.model_precache[i], m, sizeof(sv.model_precache[i])); + sv.model_precache[i] = PR_AddString(prinst, m, 0); if (!strcmp(m + strlen(m) - 4, ".bsp")) sv.models[i] = Mod_FindName(sv.model_precache[i]); Con_Printf("WARNING: SV_ModelIndex: model %s not precached", m); @@ -3422,14 +3432,14 @@ void PF_precache_model (progfuncs_t *prinst, struct globalvars_s *pr_globals) for (i=1 ; i=sizeof(sv.model_precache[i])-1) + if (strlen(s)>=MAX_QPATH-1) //probably safest to keep this. { PR_BIError (prinst, "Precache name too long"); return; } - strcpy(sv.model_precache[i], s); + sv.model_precache[i] = PR_AddString(prinst, s, 0); if (!strcmp(s + strlen(s) - 4, ".bsp")) sv.models[i] = Mod_FindName(sv.model_precache[i]); @@ -5390,7 +5400,7 @@ void PF_strconv (progfuncs_t *prinst, struct globalvars_s *pr_globals) if (len >= MAXTEMPBUFFERLEN) len = MAXTEMPBUFFERLEN-1; - RETURN_SSTRING(result); + RETURN_SSTRING(((char*)result)); for (i = 0; i < len; i++, string++, result++) //do this backwards { @@ -8924,6 +8934,9 @@ void PR_RegisterFields(void) //it's just easier to do it this way. fieldentity(viewmodelforclient); fieldentity(exteriormodeltoclient); + fieldfloat(glowsize); + fieldfloat(glowcolor); + //UDC_EXTEFFECT... yuckie PR_RegisterFieldVar(svprogfuncs, ev_float, "fieldcolor", (int)&((entvars_t*)0)->seefcolour, -1); PR_RegisterFieldVar(svprogfuncs, ev_float, "fieldsizex", (int)&((entvars_t*)0)->seefsizex, -1); diff --git a/engine/server/progdefs.h b/engine/server/progdefs.h index 30a9f8d55..067ef7e67 100644 --- a/engine/server/progdefs.h +++ b/engine/server/progdefs.h @@ -201,6 +201,9 @@ typedef struct entvars_s int viewmodelforclient; int exteriormodeltoclient; + float glowsize; + float glowcolor; + //EXT_DIMENSION_VISIBLE float dimension_see; float dimension_seen; @@ -230,7 +233,6 @@ typedef struct entvars_s float abslight; //hexen2's force a lightlevel float hasted; //hexen2 uses this AS WELL as maxspeed - //csqc stuph. func_t SendEntity; float Version; diff --git a/engine/server/savegame.c b/engine/server/savegame.c index a54bb3d68..d3ae9fcb2 100644 --- a/engine/server/savegame.c +++ b/engine/server/savegame.c @@ -620,7 +620,7 @@ qboolean SV_LoadLevelCache(char *level, char *startspot, qboolean ignoreplayers) if (!ignoreplayers) { eval = PR_FindGlobal(svprogfuncs, "startspot", 0); - if (eval) eval->_int = (int)PR_NewString(svprogfuncs, startspot); + if (eval) eval->_int = (int)PR_NewString(svprogfuncs, startspot, 0); eval = PR_FindGlobal(svprogfuncs, "ClientReEnter", 0); if (eval) diff --git a/engine/server/server.h b/engine/server/server.h index 5159f3c6d..0bafcfef2 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -129,7 +129,7 @@ typedef struct }; #endif struct { - char model_precache[MAX_MODELS][MAX_QPATH]; // NULL terminated + char *model_precache[MAX_MODELS]; // NULL terminated char sound_precache[MAX_SOUNDS][MAX_QPATH]; // NULL terminated char image_precache[Q2MAX_IMAGES][MAX_QPATH]; char *lightstyles[MAX_LIGHTSTYLES]; @@ -379,8 +379,10 @@ typedef struct client_s #endif int playerclass; - char team[32]; - char name[32]; // for printing to other people + char teambuf[32]; + char *team; + char *name; + char namebuf[32]; // for printing to other people // extracted from userinfo int messagelevel; // for filtering printed messages diff --git a/engine/server/sv_chat.c b/engine/server/sv_chat.c index fafd00c01..b051c1c00 100644 --- a/engine/server/sv_chat.c +++ b/engine/server/sv_chat.c @@ -230,7 +230,7 @@ float SV_ChatFunc(const char *func) //parse a condition/function if (*com_token == ',') continue; if (com_tokentype == TTP_STRING) - G_INT(parm) = (int)PR_NewString(svprogfuncs, com_token); + G_INT(parm) = PR_NewString(svprogfuncs, com_token, 0); else if (!strcmp(com_token, "ent")) SetGlobalEdict(svprogfuncs, host_client->chat.edict, parm); else diff --git a/engine/server/sv_ents.c b/engine/server/sv_ents.c index 55d3bd099..f92a97b01 100644 --- a/engine/server/sv_ents.c +++ b/engine/server/sv_ents.c @@ -524,6 +524,9 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb if ( to->abslight != from->abslight && protext & PEXT_HEXEN2) evenmorebits |= U_ABSLIGHT; + if (to->glowsize) + to->dpflags |= 4; + if (to->dpflags) evenmorebits |= U_DPFLAGS; @@ -1708,7 +1711,10 @@ int glowsize, glowcolor; if (!(ent->baseline.trans == 1 && !ent->v->alpha)) bits |= DPU_ALPHA; if (ent->baseline.scale != ent->v->scale) - bits |= DPU_SCALE; + { + if (ent->v->scale != 0 || ent->baseline.scale != 1) + bits |= DPU_SCALE; + } if ((ent->baseline.effects&0xff00) != ((int)eff & 0xff00)) bits |= DPU_EFFECTS2; @@ -2336,10 +2342,9 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore if (state->effects & EF_FULLBRIGHT) { - state->abslight = 255; - state->hexen2flags |= MLS_ABSLIGHT; + state->hexen2flags |= MLS_FULLBRIGHT; } - if (progstype != PROG_QW) //don't send extra nq effects to a qw client. + if (progstype != PROG_QW && state->effects) //don't send extra nq effects to a qw client. { //EF_NODRAW doesn't draw the model. //The client still needs to know about it though, as it might have other effects on it. @@ -2354,7 +2359,7 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore state->modelindex = 0; } - state->effects &= EF_BRIGHTLIGHT | EF_DIMLIGHT; + state->effects &= EF_BRIGHTLIGHT | EF_DIMLIGHT | NQEF_ADDATIVE | EF_RED | EF_BLUE; } #ifdef PEXT_SCALE @@ -2365,6 +2370,9 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore if (!ent->v->alpha) state->trans = 1; + state->glowsize = ent->v->glowsize*0.25; + state->glowcolour = ent->v->glowcolor; + //QSG_DIMENSION_PLANES - if the only shared dimensions are ghost dimensions, Set half alpha. if (client->edict) if (((int)client->edict->v->dimension_see & (int)ent->v->dimension_ghost)) diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index e452ab87f..1996bd98e 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -242,8 +242,7 @@ void SVNQ_CreateBaseline (void) else { svent->baseline.colormap = 0; - svent->baseline.modelindex = - SV_ModelIndex(PR_GetString(svprogfuncs, svent->v->model)); + svent->baseline.modelindex = svent->v->modelindex; } svent->baseline.modelindex&=255; } @@ -768,12 +767,12 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us if (svs.gametype == GT_PROGS) { strcpy(sv.sound_precache[0], ""); - strcpy(sv.model_precache[0], ""); + sv.model_precache[0] = ""; - strcpy(sv.model_precache[1], sv.modelname); + sv.model_precache[1] = PR_AddString(svprogfuncs, sv.modelname, 0); for (i=1 ; inumsubmodels ; i++) { - strcpy(sv.model_precache[1+i], localmodels[i]); + sv.model_precache[1+i] = PR_AddString(svprogfuncs, localmodels[i], 0); sv.models[i+1] = Mod_ForName (localmodels[i], false); } @@ -799,6 +798,12 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us SCR_BeginLoadingPlaque(); #endif + for (i=0 ; iisfree = false; - ent->v->model = PR_SetString(svprogfuncs, sv.worldmodel->name); + ent->v->model = PR_NewString(svprogfuncs, sv.worldmodel->name, 0); ent->v->modelindex = 1; // world model ent->v->solid = SOLID_BSP; ent->v->movetype = MOVETYPE_PUSH; if (progstype == PROG_QW && pr_imitatemvdsv.value>0) { - ent->v->targetname = PR_SetString(svprogfuncs, "mvdsv"); - s = DISTRIBUTIONLONG; - ent->v->netname = PR_NewString(svprogfuncs, va("%s %f %s, build %d\nBuild date: " __DATE__ ", " __TIME__ "", DISTRIBUTIONLONG, VERSION, PLATFORM, build_number())); + ent->v->targetname = PR_NewString(svprogfuncs, "mvdsv", 0); + ent->v->netname = PR_NewString(svprogfuncs, va("%s %f %s, build %d\nBuild date: " __DATE__ ", " __TIME__ "", DISTRIBUTIONLONG, VERSION, PLATFORM, build_number()), 0); ent->v->impulse = 0;//QWE_VERNUM; ent->v->items = 103; } - pr_global_struct->mapname = PR_SetString(svprogfuncs, sv.name); + pr_global_struct->mapname = PR_NewString(svprogfuncs, sv.name, 0); // serverflags are for cross level information (sigils) pr_global_struct->serverflags = svs.serverflags; pr_global_struct->time = 0.1; //HACK!!!! A few QuakeC mods expect time to be non-zero in spawn funcs - like prydon gate... @@ -911,7 +923,7 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us else if (pr_nqglobal_struct->deathmatch) pr_global_struct->deathmatch = deathmatch.value; } - + if (progstype == PROG_QW) // run the frame start qc function to let progs check cvars SV_ProgStartFrame (); //prydon gate seems to fail because of this allowance @@ -1077,7 +1089,7 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us { eval_t *eval; eval = PR_FindGlobal(svprogfuncs, "startspot", 0); - if (eval) eval->string = PR_NewString(svprogfuncs, startspot); + if (eval) eval->string = PR_NewString(svprogfuncs, startspot, 0); } if (Cmd_AliasExist("f_svnewmap", RESTRICT_LOCAL)) diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index 54489c188..cde2cd9b3 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -1496,7 +1496,14 @@ void SVC_DirectConnect #endif - *newcl = temp; + { + char *n, *t; + n = newcl->name; + t = newcl->team; + *newcl = temp; + newcl->name = n; + newcl->team = t; + } newcl->zquake_extensions = atoi(Info_ValueForKey(newcl->userinfo, "*z_ext")); @@ -2918,6 +2925,7 @@ void SV_InitLocal (void) extern cvar_t pm_slidefix; extern cvar_t pm_airstep; extern cvar_t pm_walljump; + extern cvar_t pm_slidyslopes; SV_InitOperatorCommands (); SV_UserInit (); @@ -2980,6 +2988,7 @@ void SV_InitLocal (void) Cvar_Register (&pm_bunnyspeedcap, cvargroup_serverphysics); Cvar_Register (&pm_ktjump, cvargroup_serverphysics); Cvar_Register (&pm_slidefix, cvargroup_serverphysics); + Cvar_Register (&pm_slidyslopes, cvargroup_serverphysics); Cvar_Register (&pm_airstep, cvargroup_serverphysics); Cvar_Register (&pm_walljump, cvargroup_serverphysics); @@ -3327,7 +3336,7 @@ void SV_ExtractFromUserinfo (client_t *cl) val = Info_ValueForKey (cl->userinfo, "team"); val[40] = 0; //trim to smallish length now (to allow for adding more. - Q_strncpyz (cl->team, val, sizeof(cl->team)); + Q_strncpyz (cl->team, val, sizeof(cl->teambuf)); // name for C code val = Info_ValueForKey (cl->userinfo, "name"); @@ -3351,8 +3360,8 @@ void SV_ExtractFromUserinfo (client_t *cl) break; } if (i != MAX_CLIENTS) { // dup name - if (strlen(newname) > sizeof(cl->name) - 1) - newname[sizeof(cl->name) - 4] = 0; + if (strlen(newname) > sizeof(cl->namebuf) - 1) + newname[sizeof(cl->namebuf) - 4] = 0; p = newname; if (newname[0] == '(') @@ -3370,7 +3379,7 @@ void SV_ExtractFromUserinfo (client_t *cl) break; } - if (strncmp(newname, cl->name, sizeof(cl->name)-1)) + if (strncmp(newname, cl->name, sizeof(cl->namebuf)-1)) { if (cl->ismuted) SV_ClientTPrintf (cl, PRINT_HIGH, STL_NONAMEASMUTE); @@ -3394,7 +3403,7 @@ void SV_ExtractFromUserinfo (client_t *cl) { SV_BroadcastTPrintf (PRINT_HIGH, STL_CLIENTNAMECHANGE, cl->name, val); } - Q_strncpyz (cl->name, newname, sizeof(cl->name)); + Q_strncpyz (cl->name, newname, sizeof(cl->namebuf)); #ifdef SVRANKING diff --git a/engine/server/sv_phys.c b/engine/server/sv_phys.c index 71443008b..ca37ddf79 100644 --- a/engine/server/sv_phys.c +++ b/engine/server/sv_phys.c @@ -56,6 +56,7 @@ cvar_t sv_waterfriction = { "sv_waterfriction", "4"}; cvar_t pm_ktjump = {"pm_ktjump", "", NULL, CVAR_SERVERINFO}; cvar_t pm_bunnyspeedcap = {"pm_bunnyspeedcap", "", NULL, CVAR_SERVERINFO}; cvar_t pm_slidefix = {"pm_slidefix", "", NULL, CVAR_SERVERINFO}; +cvar_t pm_slidyslopes = {"pm_slidyslopes", "", NULL, CVAR_SERVERINFO}; cvar_t pm_airstep = {"pm_airstep", "", NULL, CVAR_SERVERINFO}; cvar_t pm_walljump = {"pm_walljump", "", NULL, CVAR_SERVERINFO}; @@ -1738,24 +1739,24 @@ void SV_Physics_Client (edict_t *ent, int num) if (!SV_CheckWater (ent) && ! ((int)ent->v->flags & FL_WATERJUMP) ) SV_AddGravity (ent, ent->v->gravity); - if (fabs(oldvel - ent->v->velocity[0])> 100) - Con_Printf("grav: %f -> %f\n", oldvel, ent->v->velocity[0]); +// if (fabs(oldvel - ent->v->velocity[0])> 100) +// Con_Printf("grav: %f -> %f\n", oldvel, ent->v->velocity[0]); - if (SV_TestEntityPosition(ent)) - Con_Printf("Player starts stuck\n"); +// if (SV_TestEntityPosition(ent)) +// Con_Printf("Player starts stuck\n"); SV_CheckStuck (ent); - if (SV_TestEntityPosition(ent)) - Con_Printf("becomes stuck\n"); +// if (SV_TestEntityPosition(ent)) +// Con_Printf("becomes stuck\n"); SV_WalkMove (ent); - if (SV_TestEntityPosition(ent)) - Con_Printf("Player ends stuck\n"); +// if (SV_TestEntityPosition(ent)) +// Con_Printf("Player ends stuck\n"); - if (fabs(oldvel - ent->v->velocity[0])> 100) - Con_Printf("walk: %f -> %f\n", oldvel, ent->v->velocity[0]); +// if (fabs(oldvel - ent->v->velocity[0])> 100) +// Con_Printf("walk: %f -> %f\n", oldvel, ent->v->velocity[0]); break; diff --git a/engine/server/sv_send.c b/engine/server/sv_send.c index e46c815ad..ecff1406a 100644 --- a/engine/server/sv_send.c +++ b/engine/server/sv_send.c @@ -1379,7 +1379,7 @@ void SV_UpdateToReliableMessages (void) { if (host_client->state != cs_spawned) { - if (!host_client->state && host_client->name[0]) //if this is a bot + if (!host_client->state && host_client->name && host_client->name[0]) //if this is a bot { if (host_client->old_frags != (int)host_client->edict->v->frags) { diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index 916b91697..b78b37def 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -69,6 +69,7 @@ cvar_t pr_allowbutton1 = {"pr_allowbutton1", "1", NULL, CVAR_LATCH}; extern cvar_t pm_bunnyspeedcap; extern cvar_t pm_ktjump; extern cvar_t pm_slidefix; +extern cvar_t pm_slidyslopes; extern cvar_t pm_airstep; extern cvar_t pm_walljump; @@ -778,11 +779,11 @@ void SV_Modellist_f (void) else { for (i = 1+n; - *sv.model_precache[i] && (((n&255)==0)||(host_client->netchan.message.cursize < (MAX_QWMSGLEN/2))); //make sure we don't send a 0 next... + sv.model_precache[i] && (((n&255)==0)||(host_client->netchan.message.cursize < (MAX_QWMSGLEN/2))); //make sure we don't send a 0 next... i++, n++) MSG_WriteString (&host_client->netchan.message, sv.model_precache[i]); - if (!*sv.model_precache[i]) + if (!sv.model_precache[i]) n = 0; } @@ -3038,7 +3039,7 @@ void SVNQ_Spawn_f (void) } else { - memset (&ent->v, 0, pr_edict_size-svprogparms.edictsize); + memset (ent->v, 0, pr_edict_size); ED_Spawned(ent); ent->v->colormap = NUM_FOR_EDICT(svprogfuncs, ent); @@ -3803,6 +3804,7 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) movevars.slidefix = (pm_slidefix.value != 0); movevars.airstep = (pm_airstep.value != 0); movevars.walljump = (pm_walljump.value); + movevars.slidyslopes = (pm_slidyslopes.value!=0); for (i=0 ; i<3 ; i++) { @@ -3956,6 +3958,7 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) movevars.slidefix = (pm_slidefix.value != 0); movevars.airstep = (pm_airstep.value != 0); movevars.walljump = (pm_walljump.value); + movevars.slidyslopes = (pm_slidyslopes.value!=0); if (sv_player->v->hasted) movevars.maxspeed*=sv_player->v->hasted;