if (strcmp(host_client->name, newName) != 0)
Con_Printf ("%s renamed to %s\n", host_client->name, newName);
strcpy (host_client->name, newName);
- host_client->edict->v->netname = host_client->name - pr_strings;
+ host_client->edict->v->netname = PR_SetString(host_client->name);
// send notification to all clients
if (sv.paused)
{
- SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v->netname);
+ SV_BroadcastPrintf ("%s paused the game\n", PR_GetString(sv_player->v->netname));
}
else
{
- SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v->netname);
+ SV_BroadcastPrintf ("%s unpaused the game\n", PR_GetString(sv_player->v->netname));
}
// send notification to all clients
memset (ent->v, 0, progs->entityfields * 4);
ent->v->colormap = NUM_FOR_EDICT(ent);
ent->v->team = (host_client->colors & 15) + 1;
- ent->v->netname = host_client->name - pr_strings;
+ ent->v->netname = PR_SetString(host_client->name);
if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
val->_float = host_client->pmodel;
for (i=0 ; i<sv.num_edicts ; i++)
{
e = EDICT_NUM(i);
- if ( !strcmp (pr_strings + e->v->classname, "viewthing") )
+ if (!strcmp (PR_GetString(e->v->classname), "viewthing"))
return e;
}
Con_Printf ("No viewthing on map\n");
##### Variables that you may want to modify #####
#choose the compiler you want to use
-CC=gcc-cvs
+CC=gcc
#recommended for: anyone not using ALSA 0.5
OBJ_SND=snd_oss.o snd_dma.o snd_mix.o snd_mem.o
edict_t *ed;
s = PF_VarString(0);
- Con_Printf ("======SERVER ERROR in %s:\n%s\n", pr_strings + pr_xfunction->s_name, s);
+ Con_Printf ("======SERVER ERROR in %s:\n%s\n", PR_GetString(pr_xfunction->s_name), s);
ed = PROG_TO_EDICT(pr_global_struct->self);
ED_Print (ed);
edict_t *ed;
s = PF_VarString(0);
- Con_Printf ("======OBJECT ERROR in %s:\n%s\n", pr_strings + pr_xfunction->s_name, s);
+ Con_Printf ("======OBJECT ERROR in %s:\n%s\n", PR_GetString(pr_xfunction->s_name), s);
ed = PROG_TO_EDICT(pr_global_struct->self);
ED_Print (ed);
ED_Free (ed);
{
edict_t *e;
float *min, *max;
-
+
e = G_EDICT(OFS_PARM0);
min = G_VECTOR(OFS_PARM1);
max = G_VECTOR(OFS_PARM2);
Host_Error ("no precache: %s\n", m);
- e->v->model = m - pr_strings;
+ e->v->model = PR_SetString(*check);
e->v->modelindex = i;
mod = sv.models[ (int)e->v->modelindex];
float num;
num = (rand ()&0x7fff) / ((float)0x7fff);
-
+
G_FLOAT(OFS_RETURN) = num;
}
s = PR_GetTempString();
// LordHavoc: ftos improvement
sprintf (s, "%g", v);
- G_INT(OFS_RETURN) = s - pr_strings;
+ G_INT(OFS_RETURN) = PR_SetString(s);
}
void PF_fabs (void)
char *s;
s = PR_GetTempString();
sprintf (s, "'%5.1f %5.1f %5.1f'", G_VECTOR(OFS_PARM0)[0], G_VECTOR(OFS_PARM0)[1], G_VECTOR(OFS_PARM0)[2]);
- G_INT(OFS_RETURN) = s - pr_strings;
+ G_INT(OFS_RETURN) = PR_SetString(s);
}
void PF_etos (void)
char *s;
s = PR_GetTempString();
sprintf (s, "entity %i", G_EDICTNUM(OFS_PARM0));
- G_INT(OFS_RETURN) = s - pr_strings;
+ G_INT(OFS_RETURN) = PR_SetString(s);
}
void PF_Spawn (void)
G_INT(OFS_RETURN) = 0;
if (!(surf = getsurface(G_EDICT(OFS_PARM0), G_FLOAT(OFS_PARM1))))
return;
- G_INT(OFS_RETURN) = surf->texinfo->texture->name - pr_strings;
+ G_INT(OFS_RETURN) = PR_SetString(surf->texinfo->texture->name);
}
//PF_getsurfacenearpoint, // #438 float(entity e, vector p) getsurfacenearpoint = #438;
void PF_getsurfacenearpoint(void)
for (i=0 ; i<progs->numfielddefs ; i++)
{
def = &pr_fielddefs[i];
- if (!strcmp(pr_strings + def->s_name,name) )
+ if (!strcmp(PR_GetString(def->s_name), name))
return def;
}
return NULL;
for (i=0 ; i<progs->numglobaldefs ; i++)
{
def = &pr_globaldefs[i];
- if (!strcmp(pr_strings + def->s_name,name) )
+ if (!strcmp(PR_GetString(def->s_name), name))
return def;
}
return NULL;
for (i=0 ; i<progs->numfunctions ; i++)
{
func = &pr_functions[i];
- if (!strcmp(pr_strings + func->s_name,name) )
+ if (!strcmp(PR_GetString(func->s_name), name))
return func;
}
return NULL;
switch (type)
{
case ev_string:
- sprintf (line, "%s", pr_strings + val->string);
+ sprintf (line, "%s", PR_GetString(val->string));
break;
case ev_entity:
n = NoCrash_NUM_FOR_EDICT(PROG_TO_EDICT(val->edict));
break;
case ev_function:
f = pr_functions + val->function;
- sprintf (line, "%s()", pr_strings + f->s_name);
+ sprintf (line, "%s()", PR_GetString(f->s_name));
break;
case ev_field:
def = ED_FieldAtOfs ( val->_int );
- sprintf (line, ".%s", pr_strings + def->s_name);
+ sprintf (line, ".%s", PR_GetString(def->s_name));
break;
case ev_void:
sprintf (line, "void");
switch (type)
{
case ev_string:
- sprintf (line, "%s", pr_strings + val->string);
+ sprintf (line, "%s", PR_GetString(val->string));
break;
case ev_entity:
sprintf (line, "%i", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict)));
break;
case ev_function:
f = pr_functions + val->function;
- sprintf (line, "%s", pr_strings + f->s_name);
+ sprintf (line, "%s", PR_GetString(f->s_name));
break;
case ev_field:
def = ED_FieldAtOfs ( val->_int );
// LordHavoc: parse the string a bit to turn special characters
// (like newline, specifically) into escape codes,
// this fixes saving games from various mods
- //sprintf (line, "%s", pr_strings + def->s_name);
- s = pr_strings + def->s_name;
+ //sprintf (line, "%s", PR_GetString(def->s_name));
+ s = PR_GetString(def->s_name);
for (i = 0;i < 4095 && *s;)
{
if (*s == '\n')
else
{
s = PR_ValueString (def->type, val);
- sprintf (line,"%i(%s)%s", ofs, pr_strings + def->s_name, s);
+ sprintf (line,"%i(%s)%s", ofs, PR_GetString(def->s_name), s);
}
i = strlen(line);
if (!def)
sprintf (line,"%i(?)", ofs);
else
- sprintf (line,"%i(%s)", ofs, pr_strings + def->s_name);
+ sprintf (line,"%i(%s)", ofs, PR_GetString(def->s_name));
i = strlen(line);
for ( ; i<20 ; i++)
for (i=1 ; i<progs->numfielddefs ; i++)
{
d = &pr_fielddefs[i];
- name = pr_strings + d->s_name;
+ name = PR_GetString(d->s_name);
if (name[strlen(name)-2] == '_')
continue; // skip _x, _y, _z vars
for (i=1 ; i<progs->numfielddefs ; i++)
{
d = &pr_fielddefs[i];
- name = pr_strings + d->s_name;
+ name = PR_GetString(d->s_name);
if (name[strlen(name)-2] == '_')
continue; // skip _x, _y, _z vars
if (type != ev_string && type != ev_float && type != ev_entity)
continue;
- name = pr_strings + def->s_name;
+ name = PR_GetString(def->s_name);
Qprintf (f,"\"%s\" ", name);
Qprintf (f,"\"%s\"\n", PR_UglyValueString(type, (eval_t *)&pr_globals[def->ofs]));
}
switch (key->type & ~DEF_SAVEGLOBAL)
{
case ev_string:
- *(string_t *)d = ED_NewString (s) - pr_strings;
+ *(string_t *)d = PR_SetString(ED_NewString(s));
break;
case ev_float:
}
// look for the spawn function
- func = ED_FindFunction ( pr_strings + ent->v->classname );
+ func = ED_FindFunction (PR_GetString(ent->v->classname));
if (!func)
{
{
pr_fielddefs[progs->numfielddefs].type = dpfields[i].type;
pr_fielddefs[progs->numfielddefs].ofs = progs->entityfields;
- pr_fielddefs[progs->numfielddefs].s_name = dpfields[i].string - pr_strings;
+ pr_fielddefs[progs->numfielddefs].s_name = PR_SetString(dpfields[i].string);
if (pr_fielddefs[progs->numfielddefs].type == ev_vector)
progs->entityfields += 3;
else
for (i = 1;i < progs->numfielddefs;i++)
{
d = &pr_fielddefs[i];
- name = pr_strings + d->s_name;
+ name = PR_GetString(d->s_name);
if (name[strlen(name)-2] == '_')
continue; // skip _x, _y, _z vars
v = (int *)((char *)ed->v + d->ofs*4);
for (i = 0;i < progs->numfielddefs;i++)
{
d = &pr_fielddefs[i];
- name = pr_strings + d->s_name;
+ name = PR_GetString(d->s_name);
if (name[strlen(name)-2] == '_')
continue; // skip _x, _y, _z vars
switch(d->type & ~DEF_SAVEGLOBAL)
return;
}
for (i = 0;i < progs->numglobaldefs;i++)
- Con_Printf("%s\n", (pr_strings + pr_globaldefs[i].s_name));
+ Con_Printf("%s\n", PR_GetString(pr_globaldefs[i].s_name));
Con_Printf("%i global variables, totalling %i bytes\n", progs->numglobals, progs->numglobals * 4);
}
if (!f)
Con_Printf ("<NULL FUNCTION>\n");
else
- Con_Printf ("%12s : %s : statement %i\n", pr_strings + f->s_file, pr_strings + f->s_name, pr_stack[i].s - f->first_statement);
+ Con_Printf ("%12s : %s : statement %i\n", PR_GetString(f->s_file), PR_GetString(f->s_name), pr_stack[i].s - f->first_statement);
}
}
if (best)
{
if (num < 10)
- Con_Printf ("%7i %s\n", best->profile, pr_strings+best->s_name);
+ Con_Printf ("%7i %s\n", best->profile, PR_GetString(best->s_name));
num++;
best->profile = 0;
}
return pr_stack[pr_depth].s;
}
+void PR_ReInitStrings (void);
void PR_Execute_ProgsLoaded(void)
{
// dump the stack
pr_depth = 0;
localstack_used = 0;
+ // reset the string table
+ PR_ReInitStrings();
}
/*
}
}
+// LordHavoc: grabbed these from QWSV, works around a gcc 2.95.3 compiler bug
+#define MAX_PRSTR 1024
+static char *pr_strtbl[MAX_PRSTR];
+static int num_prstr;
+
+char *PR_GetString (int num)
+{
+ return num >= 0 ? pr_strings + num : pr_strtbl[-num];
+}
+
+int PR_SetString (char *s)
+{
+ if (s >= pr_strings)
+ return (int) (s - pr_strings);
+ else
+ {
+ int i;
+ for (i = 0; i <= num_prstr; i++)
+ if (pr_strtbl[i] == s)
+ return -i;
+ if (num_prstr >= (MAX_PRSTR - 1))
+ Host_Error ("PR_Setstring: ran out of string table slots");
+ pr_strtbl[++num_prstr] = s;
+ return -num_prstr;
+ }
+}
+
+void PR_ReInitStrings (void)
+{
+ num_prstr = 0;
+}
OPC->_float = !OPA->vector[0] && !OPA->vector[1] && !OPA->vector[2];
break;
case OP_NOT_S:
- OPC->_float = !OPA->string || !pr_strings[OPA->string];
+ OPC->_float = !OPA->string || !*PR_GetString(OPA->string);
break;
case OP_NOT_FNC:
OPC->_float = !OPA->function;
OPC->_float = (OPA->vector[0] == OPB->vector[0]) && (OPA->vector[1] == OPB->vector[1]) && (OPA->vector[2] == OPB->vector[2]);
break;
case OP_EQ_S:
- OPC->_float = !strcmp(pr_strings+OPA->string,pr_strings+OPB->string);
+ OPC->_float = !strcmp(PR_GetString(OPA->string),PR_GetString(OPB->string));
break;
case OP_EQ_E:
OPC->_float = OPA->_int == OPB->_int;
OPC->_float = (OPA->vector[0] != OPB->vector[0]) || (OPA->vector[1] != OPB->vector[1]) || (OPA->vector[2] != OPB->vector[2]);
break;
case OP_NE_S:
- OPC->_float = strcmp(pr_strings+OPA->string,pr_strings+OPB->string);
+ OPC->_float = strcmp(PR_GetString(OPA->string),PR_GetString(OPB->string));
break;
case OP_NE_E:
OPC->_float = OPA->_int != OPB->_int;
#define G_EDICT(o) (PROG_TO_EDICT(*(int *)&pr_globals[o]))
#define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o))
#define G_VECTOR(o) (&pr_globals[o])
-#define G_STRING(o) (pr_strings + *(string_t *)&pr_globals[o])
+#define G_STRING(o) (PR_GetString(*(string_t *)&pr_globals[o]))
//#define G_FUNCTION(o) (*(func_t *)&pr_globals[o])
// FIXME: make these go away?
#define E_FLOAT(e,o) (((float*)e->v)[o])
//#define E_INT(e,o) (((int*)e->v)[o])
//#define E_VECTOR(e,o) (&((float*)e->v)[o])
-#define E_STRING(e,o) (pr_strings + *(string_t *)&((float*)e->v)[o])
+#define E_STRING(e,o) (PR_GetString(*(string_t *)&((float*)e->v)[o]))
extern int type_size[8];
void ED_PrintEdicts (void);
void ED_PrintNum (int ent);
+char *PR_GetString (int num);
+int PR_SetString (char *s);
+
#endif
else
MSG_WriteByte (&client->message, GAME_COOP);
- sprintf (message, pr_strings+sv.edicts->v->message);
+ sprintf (message, PR_GetString(sv.edicts->v->message));
MSG_WriteString (&client->message,message);
if (val->_float != 0)
bits |= U_GLOWTRAIL;
- if (ent->v->modelindex >= 0 && ent->v->modelindex < MAX_MODELS && pr_strings[ent->v->model])
+ if (ent->v->modelindex >= 0 && ent->v->modelindex < MAX_MODELS && *PR_GetString(ent->v->model))
{
model = sv.models[(int)ent->v->modelindex];
Mod_CheckLoaded(model);
}
modelindex = 0;
- if (ent->v->modelindex >= 0 && ent->v->modelindex < MAX_MODELS && pr_strings[ent->v->model])
+ if (ent->v->modelindex >= 0 && ent->v->modelindex < MAX_MODELS && *PR_GetString(ent->v->model))
{
modelindex = ent->v->modelindex;
model = sv.models[(int)ent->v->modelindex];
if (bits & SU_ARMOR)
MSG_WriteByte (msg, ent->v->armorvalue);
if (bits & SU_WEAPON)
- MSG_WriteByte (msg, SV_ModelIndex(pr_strings+ent->v->weaponmodel));
+ MSG_WriteByte (msg, SV_ModelIndex(PR_GetString(ent->v->weaponmodel)));
MSG_WriteShort (msg, ent->v->health);
MSG_WriteByte (msg, ent->v->currentammo);
//
SV_ClearWorld ();
- sv.sound_precache[0] = pr_strings;
+ sv.sound_precache[0] = "";
- sv.model_precache[0] = pr_strings;
+ sv.model_precache[0] = "";
sv.model_precache[1] = sv.modelname;
for (i = 1;i < sv.worldmodel->numsubmodels;i++)
{
ent = EDICT_NUM(0);
memset (ent->v, 0, progs->entityfields * 4);
ent->free = false;
- ent->v->model = sv.worldmodel->name - pr_strings;
+ ent->v->model = PR_SetString(sv.modelname);
ent->v->modelindex = 1; // world model
ent->v->solid = SOLID_BSP;
ent->v->movetype = MOVETYPE_PUSH;
else
pr_global_struct->deathmatch = deathmatch.integer;
- pr_global_struct->mapname = sv.name - pr_strings;
+ pr_global_struct->mapname = PR_SetString(sv.name);
// serverflags are for cross level information (sigils)
pr_global_struct->serverflags = svs.serverflags;
{
if (IS_NAN(ent->v->velocity[i]))
{
- Con_Printf ("Got a NaN velocity on %s\n", pr_strings + ent->v->classname);
+ Con_Printf ("Got a NaN velocity on %s\n", PR_GetString(ent->v->classname));
ent->v->velocity[i] = 0;
}
if (IS_NAN(ent->v->origin[i]))
{
- Con_Printf ("Got a NaN origin on %s\n", pr_strings + ent->v->classname);
+ Con_Printf ("Got a NaN origin on %s\n", PR_GetString(ent->v->classname));
ent->v->origin[i] = 0;
}
}