unsigned short pr_crc;
-mempool_t *progs_mempool;
-mempool_t *edictstring_mempool;
+mempool_t *serverprogs_mempool;
int type_size[8] = {1,sizeof(string_t)/4,1,3,1,1,sizeof(func_t)/4,sizeof(void *)/4};
int eval_button6;
int eval_button7;
int eval_button8;
+int eval_buttonuse;
+int eval_buttonchat;
int eval_glow_size;
int eval_glow_trail;
int eval_glow_color;
int eval_color;
int eval_style;
int eval_pflags;
+int eval_cursor_active;
+int eval_cursor_screen;
+int eval_cursor_trace_start;
+int eval_cursor_trace_endpos;
+int eval_cursor_trace_ent;
+int eval_colormod;
+int eval_playermodel;
+int eval_playerskin;
mfunction_t *SV_PlayerPhysicsQC;
mfunction_t *EndFrameQC;
eval_button6 = FindFieldOffset("button6");
eval_button7 = FindFieldOffset("button7");
eval_button8 = FindFieldOffset("button8");
+ eval_buttonuse = FindFieldOffset("buttonuse");
+ eval_buttonchat = FindFieldOffset("buttonchat");
eval_glow_size = FindFieldOffset("glow_size");
eval_glow_trail = FindFieldOffset("glow_trail");
eval_glow_color = FindFieldOffset("glow_color");
eval_color = FindFieldOffset("color");
eval_style = FindFieldOffset("style");
eval_pflags = FindFieldOffset("pflags");
+ eval_cursor_active = FindFieldOffset("cursor_active");
+ eval_cursor_screen = FindFieldOffset("cursor_screen");
+ eval_cursor_trace_start = FindFieldOffset("cursor_trace_start");
+ eval_cursor_trace_endpos = FindFieldOffset("cursor_trace_endpos");
+ eval_cursor_trace_ent = FindFieldOffset("cursor_trace_ent");
+ eval_colormod = FindFieldOffset("colormod");
+ eval_playermodel = FindFieldOffset("playermodel");
+ eval_playerskin = FindFieldOffset("playerskin");
// LordHavoc: allowing QuakeC to override the player movement code
SV_PlayerPhysicsQC = ED_FindFunction ("SV_PlayerPhysics");
num = NUM_FOR_EDICT(e) - 1;
if (num >= 0 && num < svs.maxclients)
{
+ eval_t *val;
+ // set colormap and team on newly created player entity
e->v->colormap = num + 1;
e->v->team = (svs.clients[num].colors & 15) + 1;
+ // set netname/clientcolors back to client values so that
+ // DP_SV_CLIENTNAME and DPV_SV_CLIENTCOLORS will not immediately
+ // reset them
e->v->netname = PR_SetString(svs.clients[num].name);
+ if ((val = GETEDICTFIELDVALUE(e, eval_clientcolors)))
+ val->_float = svs.clients[num].colors;
+ // NEXUIZ_PLAYERMODEL and NEXUIZ_PLAYERSKIN
+ if( eval_playermodel )
+ GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PR_SetString(svs.clients[num].playermodel);
+ if( eval_playerskin )
+ GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PR_SetString(svs.clients[num].playerskin);
}
}
//n = NoCrash_NUM_FOR_EDICT(PROG_TO_EDICT(val->edict));
n = val->edict;
if (n < 0 || n >= MAX_EDICTS)
- snprintf (line, sizeof (line), "entity %i (invalid!)", n);
+ dpsnprintf (line, sizeof (line), "entity %i (invalid!)", n);
else
- snprintf (line, sizeof (line), "entity %i", n);
+ dpsnprintf (line, sizeof (line), "entity %i", n);
break;
case ev_function:
f = pr_functions + val->function;
- snprintf (line, sizeof (line), "%s()", PR_GetString(f->s_name));
+ dpsnprintf (line, sizeof (line), "%s()", PR_GetString(f->s_name));
break;
case ev_field:
def = ED_FieldAtOfs ( val->_int );
- snprintf (line, sizeof (line), ".%s", PR_GetString(def->s_name));
+ dpsnprintf (line, sizeof (line), ".%s", PR_GetString(def->s_name));
break;
case ev_void:
- snprintf (line, sizeof (line), "void");
+ dpsnprintf (line, sizeof (line), "void");
break;
case ev_float:
// LordHavoc: changed from %5.1f to %10.4f
- snprintf (line, sizeof (line), "%10.4f", val->_float);
+ dpsnprintf (line, sizeof (line), "%10.4f", val->_float);
break;
case ev_vector:
// LordHavoc: changed from %5.1f to %10.4f
- snprintf (line, sizeof (line), "'%10.4f %10.4f %10.4f'", val->vector[0], val->vector[1], val->vector[2]);
+ dpsnprintf (line, sizeof (line), "'%10.4f %10.4f %10.4f'", val->vector[0], val->vector[1], val->vector[2]);
break;
case ev_pointer:
- snprintf (line, sizeof (line), "pointer");
+ dpsnprintf (line, sizeof (line), "pointer");
break;
default:
- snprintf (line, sizeof (line), "bad type %i", type);
+ dpsnprintf (line, sizeof (line), "bad type %i", type);
break;
}
line[i] = '\0';
break;
case ev_entity:
- snprintf (line, sizeof (line), "%i", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict)));
+ dpsnprintf (line, sizeof (line), "%i", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict)));
break;
case ev_function:
f = pr_functions + val->function;
break;
case ev_field:
def = ED_FieldAtOfs ( val->_int );
- snprintf (line, sizeof (line), ".%s", PR_GetString(def->s_name));
+ dpsnprintf (line, sizeof (line), ".%s", PR_GetString(def->s_name));
break;
case ev_void:
- snprintf (line, sizeof (line), "void");
+ dpsnprintf (line, sizeof (line), "void");
break;
case ev_float:
- snprintf (line, sizeof (line), "%f", val->_float);
+ dpsnprintf (line, sizeof (line), "%f", val->_float);
break;
case ev_vector:
- snprintf (line, sizeof (line), "%f %f %f", val->vector[0], val->vector[1], val->vector[2]);
+ dpsnprintf (line, sizeof (line), "%f %f %f", val->vector[0], val->vector[1], val->vector[2]);
break;
default:
- snprintf (line, sizeof (line), "bad type %i", type);
+ dpsnprintf (line, sizeof (line), "bad type %i", type);
break;
}
val = (void *)&pr_globals[ofs];
def = ED_GlobalAtOfs(ofs);
if (!def)
- snprintf (line, sizeof (line), "%i(?)", ofs);
+ dpsnprintf (line, sizeof (line), "%i(?)", ofs);
else
{
s = PR_ValueString (def->type, val);
- snprintf (line, sizeof (line), "%i(%s)%s", ofs, PR_GetString(def->s_name), s);
+ dpsnprintf (line, sizeof (line), "%i(%s)%s", ofs, PR_GetString(def->s_name), s);
}
i = strlen(line);
def = ED_GlobalAtOfs(ofs);
if (!def)
- snprintf (line, sizeof (line), "%i(?)", ofs);
+ dpsnprintf (line, sizeof (line), "%i(?)", ofs);
else
- snprintf (line, sizeof (line), "%i(%s)", ofs, PR_GetString(def->s_name));
+ dpsnprintf (line, sizeof (line), "%i(%s)", ofs, PR_GetString(def->s_name));
i = strlen(line);
for ( ; i<20 ; i++)
}
tempstring[0] = 0;
- snprintf (tempstring, sizeof (tempstring), "\nEDICT %i:\n", NUM_FOR_EDICT(ed));
+ dpsnprintf (tempstring, sizeof (tempstring), "\nEDICT %i:\n", NUM_FOR_EDICT(ed));
for (i=1 ; i<progs->numfielddefs ; i++)
{
d = &pr_fielddefs[i];
int i,l;
l = strlen(string) + 1;
- new = Mem_Alloc(edictstring_mempool, l);
+ new = PR_Alloc(l);
new_p = new;
for (i=0 ; i< l ; i++)
i++;
if (string[i] == 'n')
*new_p++ = '\n';
+ else if (string[i] == 'r')
+ *new_p++ = '\r';
else
*new_p++ = '\\';
}
Con_DPrintf("ED_ParseEpair: Can't find field %s\n", s);
return false;
}
- val->_int = G_INT(def->ofs);
+ //val->_int = G_INT(def->ofs); // AK Please check this - seems to be an org. quake bug
+ val->_int = def->ofs;
break;
case ev_function:
{
char temp[32];
strlcpy (temp, com_token, sizeof (temp));
- snprintf (com_token, sizeof (com_token), "0 %s 0", temp);
+ dpsnprintf (com_token, sizeof (com_token), "0 %s 0", temp);
}
if (!ED_ParseEpair(ent, key, com_token))
parsed++;
// remove things from different skill levels or deathmatch
- if (deathmatch.integer)
+ if (gamemode != GAME_TRANSFUSION) //Transfusion does this in QC
{
- if (((int)ent->v->spawnflags & SPAWNFLAG_NOT_DEATHMATCH))
+ if (deathmatch.integer)
+ {
+ if (((int)ent->v->spawnflags & SPAWNFLAG_NOT_DEATHMATCH))
+ {
+ ED_Free (ent);
+ inhibited++;
+ continue;
+ }
+ }
+ else if ((current_skill <= 0 && ((int)ent->v->spawnflags & SPAWNFLAG_NOT_EASY ))
+ || (current_skill == 1 && ((int)ent->v->spawnflags & SPAWNFLAG_NOT_MEDIUM))
+ || (current_skill >= 2 && ((int)ent->v->spawnflags & SPAWNFLAG_NOT_HARD )))
{
ED_Free (ent);
inhibited++;
continue;
}
}
- else if ((current_skill == 0 && ((int)ent->v->spawnflags & SPAWNFLAG_NOT_EASY ))
- || (current_skill == 1 && ((int)ent->v->spawnflags & SPAWNFLAG_NOT_MEDIUM))
- || (current_skill >= 2 && ((int)ent->v->spawnflags & SPAWNFLAG_NOT_HARD )))
- {
- ED_Free (ent);
- inhibited++;
- continue;
- }
-
//
// immediately call spawn function
//
}
pr_global_struct->self = EDICT_TO_PROG(ent);
- PR_ExecuteProgram (func - pr_functions, "");
+ PR_ExecuteProgram (func - pr_functions, "QC function spawn is missing");
spawned++;
if (ent->e->free)
died++;
dpfield_t dpfields[] =
{
- {ev_float, "gravity"},
+ {ev_entity, "cursor_trace_ent"},
+ {ev_entity, "drawonlytoclient"},
+ {ev_entity, "exteriormodeltoclient"},
+ {ev_entity, "nodrawtoclient"},
+ {ev_entity, "tag_entity"},
+ {ev_entity, "viewmodelforclient"},
+ {ev_float, "alpha"},
+ {ev_float, "ammo_cells1"},
+ {ev_float, "ammo_lava_nails"},
+ {ev_float, "ammo_multi_rockets"},
+ {ev_float, "ammo_nails1"},
+ {ev_float, "ammo_plasma"},
+ {ev_float, "ammo_rockets1"},
+ {ev_float, "ammo_shells1"},
{ev_float, "button3"},
{ev_float, "button4"},
{ev_float, "button5"},
{ev_float, "button6"},
{ev_float, "button7"},
{ev_float, "button8"},
+ {ev_float, "buttonchat"},
+ {ev_float, "buttonuse"},
+ {ev_float, "clientcolors"},
+ {ev_float, "cursor_active"},
+ {ev_float, "fullbright"},
+ {ev_float, "glow_color"},
{ev_float, "glow_size"},
{ev_float, "glow_trail"},
- {ev_float, "glow_color"},
- {ev_float, "items2"},
- {ev_float, "scale"},
- {ev_float, "alpha"},
- {ev_float, "renderamt"},
- {ev_float, "rendermode"},
- {ev_float, "fullbright"},
- {ev_float, "ammo_shells1"},
- {ev_float, "ammo_nails1"},
- {ev_float, "ammo_lava_nails"},
- {ev_float, "ammo_rockets1"},
- {ev_float, "ammo_multi_rockets"},
- {ev_float, "ammo_cells1"},
- {ev_float, "ammo_plasma"},
+ {ev_float, "gravity"},
{ev_float, "idealpitch"},
- {ev_float, "pitch_speed"},
- {ev_entity, "viewmodelforclient"},
- {ev_entity, "nodrawtoclient"},
- {ev_entity, "exteriormodeltoclient"},
- {ev_entity, "drawonlytoclient"},
+ {ev_float, "items2"},
+ {ev_float, "light_lev"},
+ {ev_float, "pflags"},
{ev_float, "ping"},
- {ev_vector, "movement"},
+ {ev_float, "pitch_speed"},
{ev_float, "pmodel"},
- {ev_vector, "punchvector"},
- {ev_float, "clientcolors"},
- {ev_entity, "tag_entity"},
- {ev_float, "tag_index"},
- {ev_float, "light_lev"},
- {ev_float, "color"},
+ {ev_float, "renderamt"}, // HalfLife support
+ {ev_float, "rendermode"}, // HalfLife support
+ {ev_float, "scale"},
{ev_float, "style"},
- {ev_float, "pflags"}
+ {ev_float, "tag_index"},
+ {ev_float, "viewzoom"},
+ {ev_vector, "color"},
+ {ev_vector, "colormod"},
+ {ev_vector, "cursor_screen"},
+ {ev_vector, "cursor_trace_endpos"},
+ {ev_vector, "cursor_trace_start"},
+ {ev_vector, "movement"},
+ {ev_vector, "punchvector"},
+ {ev_string, "playermodel"},
+ {ev_string, "playerskin"}
};
/*
===============
*/
extern void PR_Cmd_Reset (void);
-void PR_LoadProgs (void)
+void PR_LoadProgs (const char *progsname)
{
int i;
dstatement_t *st;
ddef_t *infielddefs;
dfunction_t *dfunctions;
+ if (!progsname || !*progsname)
+ Host_Error("PR_LoadProgs: passed empty progsname");
+
// flush the non-C variable lookup cache
for (i=0 ; i<GEFV_CACHESIZE ; i++)
gefvCache[i].field[0] = 0;
- Mem_EmptyPool(progs_mempool);
- Mem_EmptyPool(edictstring_mempool);
+ PR_FreeAll();
- progs = (dprograms_t *)FS_LoadFile ("progs.dat", progs_mempool, false);
+ progs = (dprograms_t *)FS_LoadFile (progsname, serverprogs_mempool, false);
if (!progs)
- Host_Error ("PR_LoadProgs: couldn't load progs.dat");
+ Host_Error ("PR_LoadProgs: couldn't load %s", progsname);
Con_DPrintf("Programs occupy %iK.\n", fs_filesize/1024);
// we need to expand the fielddefs list to include all the engine fields,
// so allocate a new place for it
infielddefs = (ddef_t *)((qbyte *)progs + progs->ofs_fielddefs);
- pr_fielddefs = Mem_Alloc(progs_mempool, (progs->numfielddefs + DPFIELDS) * sizeof(ddef_t));
+ pr_fielddefs = PR_Alloc((progs->numfielddefs + DPFIELDS) * sizeof(ddef_t));
+ pr_functions = PR_Alloc(sizeof(mfunction_t) * progs->numfunctions);
pr_statements = (dstatement_t *)((qbyte *)progs + progs->ofs_statements);
pr_statements[i].c = LittleShort(pr_statements[i].c);
}
- pr_functions = Mem_Alloc(progs_mempool, sizeof(mfunction_t) * progs->numfunctions);
for (i = 0;i < progs->numfunctions;i++)
{
pr_functions[i].first_statement = LittleLong (dfunctions[i].first_statement);
strlcat (tempstring, "pointer ", sizeof (tempstring));
break;
default:
- snprintf (tempstring2, sizeof (tempstring2), "bad type %i ", d->type & ~DEF_SAVEGLOBAL);
+ dpsnprintf (tempstring2, sizeof (tempstring2), "bad type %i ", d->type & ~DEF_SAVEGLOBAL);
strlcat (tempstring, tempstring2, sizeof (tempstring));
break;
}
strcat (tempstring, name);
for (j = strlen(name);j < 25;j++)
strcat(tempstring, " ");
- snprintf (tempstring2, sizeof (tempstring2), "%5d", counts[i]);
+ dpsnprintf (tempstring2, sizeof (tempstring2), "%5d", counts[i]);
strlcat (tempstring, tempstring2, sizeof (tempstring));
strlcat (tempstring, "\n", sizeof (tempstring));
if (strlen(tempstring) >= 4096)
Cvar_RegisterVariable (&pr_boundscheck);
Cvar_RegisterVariable (&pr_traceqc);
- progs_mempool = Mem_AllocPool("progs.dat", 0, NULL);
- edictstring_mempool = Mem_AllocPool("edict strings", 0, NULL);
+ serverprogs_mempool = Mem_AllocPool("server progs", 0, NULL);
PR_Cmd_Init();
}
+/*
+===============
+PR_Shutdown
+===============
+*/
+extern void PR_Cmd_Shutdown(void);
+void PR_Shutdown (void)
+{
+ PR_Cmd_Shutdown();
+
+ Mem_FreePool(&serverprogs_mempool);
+}
+
+void *PR_Alloc(size_t buffersize)
+{
+ return Mem_Alloc(serverprogs_mempool, buffersize);
+}
+
+void PR_Free(void *buffer)
+{
+ Mem_Free(buffer);
+}
+
+void PR_FreeAll(void)
+{
+ progs = NULL;
+ pr_fielddefs = NULL;
+ pr_functions = NULL;
+ Mem_EmptyPool(serverprogs_mempool);
+}
+
// LordHavoc: turned EDICT_NUM into a #define for speed reasons
edict_t *EDICT_NUM_ERROR(int n, char *filename, int fileline)
{