1
0
Fork 0
forked from fte/fteqw

64bit should compile properly now.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1038 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2005-05-20 03:32:53 +00:00
parent c4b668079c
commit 8641ac86f5
6 changed files with 60 additions and 43 deletions

View file

@ -191,7 +191,7 @@ csqcfields //any *64->int32 casts are erroneous, it's biased off NULL.
static csqcedict_t *csqcent[MAX_EDICTS];
#define RETURN_SSTRING(s) (((string_t *)pr_globals)[OFS_RETURN] = PR_SetString(prinst, s)) //static - exe will not change it.
char *PF_TempStr(void);
char *PF_TempStr(progfuncs_t *prinst);
static int csqcentsize;
@ -656,7 +656,7 @@ static void PF_cs_getstats(progfuncs_t *prinst, struct globalvars_s *pr_globals)
int stnum = G_FLOAT(OFS_PARM0);
char *out;
out = PF_TempStr();
out = PF_TempStr(prinst);
//the network protocol byteswaps
@ -890,7 +890,7 @@ static void PF_ReadCoord(progfuncs_t *prinst, struct globalvars_s *pr_globals)
static void PF_ReadString(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char *str = PF_TempStr();
char *str = PF_TempStr(prinst);
char *read = MSG_ReadString();
Q_strncpyz(str, read, MAXTEMPBUFFERLEN);
@ -1122,24 +1122,24 @@ static void PF_cs_getplayerkey (progfuncs_t *prinst, struct globalvars_s *pr_glo
{
CheckSendPings();
ret = PF_TempStr();
ret = PF_TempStr(prinst);
sprintf(ret, "%i", cl.players[pnum].ping);
}
else if (!strcmp(keyname, "frags"))
{
ret = PF_TempStr();
ret = PF_TempStr(prinst);
sprintf(ret, "%i", cl.players[pnum].frags);
}
else if (!strcmp(keyname, "pl")) //packet loss
{
CheckSendPings();
ret = PF_TempStr();
ret = PF_TempStr(prinst);
sprintf(ret, "%i", cl.players[pnum].pl);
}
else if (!strcmp(keyname, "entertime")) //packet loss
{
ret = PF_TempStr();
ret = PF_TempStr(prinst);
sprintf(ret, "%i", cl.players[pnum].entertime);
}
else
@ -1629,6 +1629,8 @@ qboolean CSQC_Init (unsigned int checksum)
return false;
}
PF_InitTempStrings(csqcprogs);
memset(csqcent, 0, sizeof(csqcent));
csqcentsize = PR_InitEnts(csqcprogs, pr_csmaxedicts.value);
@ -1703,7 +1705,7 @@ qboolean CSQC_ConsoleCommand(char *cmd)
if (!csqcprogs || !csqcg.console_command)
return false;
str = PF_TempStr();
str = PF_TempStr(csqcprogs);
Q_strncpyz(str, cmd, MAXTEMPBUFFERLEN);
pr_globals = PR_globals(csqcprogs, PR_CURRENT);
@ -1720,7 +1722,7 @@ qboolean CSQC_StuffCmd(char *cmd)
if (!csqcprogs || !csqcg.parse_stuffcmd)
return false;
str = PF_TempStr();
str = PF_TempStr(csqcprogs);
Q_strncpyz(str, cmd, MAXTEMPBUFFERLEN);
pr_globals = PR_globals(csqcprogs, PR_CURRENT);
@ -1736,7 +1738,7 @@ qboolean CSQC_CenterPrint(char *cmd)
if (!csqcprogs || !csqcg.parse_centerprint)
return false;
str = PF_TempStr();
str = PF_TempStr(csqcprogs);
Q_strncpyz(str, cmd, MAXTEMPBUFFERLEN);
pr_globals = PR_globals(csqcprogs, PR_CURRENT);

View file

@ -18,7 +18,7 @@ typedef struct menuedict_s
} menuedict_t;
#define RETURN_SSTRING(s) (((int *)pr_globals)[OFS_RETURN] = PR_SetString(prinst, s)) //static - exe will not change it.
char *PF_TempStr(void);
char *PF_TempStr(progfuncs_t *prinst);
#define MAXTEMPBUFFERLEN 4096
int menuentsize;
@ -551,7 +551,7 @@ int MP_TranslateDPtoFTECodes(int code);
void PF_CL_keynumtostring (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int code = G_FLOAT(OFS_PARM0);
char *keyname = PF_TempStr();
char *keyname = PF_TempStr(prinst);
code = MP_TranslateDPtoFTECodes (code);
@ -565,7 +565,7 @@ void PF_CL_findkeysforcommand (progfuncs_t *prinst, struct globalvars_s *pr_glob
{
char *cmdname = PR_GetStringOfs(prinst, OFS_PARM0);
int keynums[2];
char *keyname = PF_TempStr();
char *keyname = PF_TempStr(prinst);
M_FindKeysForCommand(cmdname, keynums);
@ -721,7 +721,7 @@ void PF_M_gethostcachenumber(progfuncs_t *prinst, struct globalvars_s *pr_global
}
void PF_gethostcachestring (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char *keyname = PF_TempStr();
char *keyname = PF_TempStr(prinst);
char *ret = "";
int keynum = G_FLOAT(OFS_PARM0);
int svnum = G_FLOAT(OFS_PARM1);
@ -926,7 +926,7 @@ void PF_altstr_prepare(progfuncs_t *prinst, struct globalvars_s *pr_globals)
instr = PR_GetStringOfs(prinst, OFS_PARM0 );
//VM_CheckEmptyString( instr );
outstr = PF_TempStr();
outstr = PF_TempStr(prinst);
for( out = outstr, in = instr, size = MAXTEMPBUFFERLEN - 1 ; size && *in ; size--, in++, out++ )
if( *in == '\'' ) {
@ -964,7 +964,7 @@ void PF_altstr_get(progfuncs_t *prinst, struct globalvars_s *pr_globals)
return;
}
outstr = PF_TempStr();
outstr = PF_TempStr(prinst);
for( out = outstr, size = MAXTEMPBUFFERLEN - 1 ; size && *pos ; size--, pos++, out++ )
if( *pos == '\\' ) {
if( !*++pos )
@ -997,7 +997,7 @@ void PF_altstr_set(progfuncs_t *prinst, struct globalvars_s *pr_globals)
str = PR_GetStringOfs(prinst, OFS_PARM2 );
//VM_CheckEmptyString( str );
outstr = out = PF_TempStr();
outstr = out = PF_TempStr(prinst);
for( num = num * 2 + 1, in = altstr; *in && num; *out++ = *in++ )
if( *in == '\\' && !*++in )
break;
@ -1356,6 +1356,8 @@ void MP_Init (void)
}
inmenuprogs++;
PF_InitTempStrings(menuprogs);
mp_time = (float*)PR_FindGlobal(menuprogs, "time", 0);
if (mp_time)
*mp_time = Sys_DoubleTime();

View file

@ -389,7 +389,10 @@ progfuncs_t deffuncs = {
0,
QC_RegisterFieldVar
QC_RegisterFieldVar,
0,
0
};
#undef printf

View file

@ -122,6 +122,9 @@ struct progfuncs_s {
int lastcalledbuiltinnumber;
int (*RegisterFieldVar) (progfuncs_t *prinst, unsigned int type, char *name, int requestedpos, int origionalofs);
char *tempstringbase;
int tempstringnum;
};
typedef struct progexterns_s {

View file

@ -63,6 +63,7 @@ int pr_teamfield;
void PR_ClearThreads(void);
void PR_fclose_progs(progfuncs_t*);
void PF_InitTempStrings(progfuncs_t *prinst);
typedef struct {
@ -666,7 +667,10 @@ progsnum_t AddProgs(char *name)
Con_Printf("Loaded %s\n", name);
if (!svs.numprogs)
{
PF_InitTempStrings(svprogfuncs);
PR_ResetBuiltins(progstype);
}
if ((f = PR_FindFunction (svprogfuncs, "VersionChat", num )))
{
@ -3232,19 +3236,23 @@ void PF_printv (progfuncs_t *prinst, struct globalvars_s *pr_globals)
#define MAX_TEMPSTRS 16
#define MAXTEMPBUFFERLEN 4096
char *PF_TempStr(void)
char *PF_TempStr(progfuncs_t *prinst)
{
static char pr_string_temparr[MAX_TEMPSTRS][MAXTEMPBUFFERLEN];
static int tempbuffernum;
if (tempbuffernum == MAX_TEMPSTRS)
tempbuffernum = 0;
return pr_string_temparr[tempbuffernum++];
if (prinst->tempstringnum == MAX_TEMPSTRS)
prinst->tempstringnum = 0;
return prinst->tempstringbase + (prinst->tempstringnum++)*MAXTEMPBUFFERLEN;
}
void PF_InitTempStrings(progfuncs_t *prinst)
{
prinst->tempstringbase = prinst->AddString(prinst, "", MAXTEMPBUFFERLEN*MAX_TEMPSTRS);
prinst->tempstringnum = 0;
}
void PF_ftos (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
float v;
char *pr_string_temp = PF_TempStr();
char *pr_string_temp = PF_TempStr(prinst);
v = G_FLOAT(OFS_PARM0);
if (v == (int)v)
@ -3257,7 +3265,7 @@ void PF_ftosp(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
float v;
int num;
char *pr_string_temp = PF_TempStr();
char *pr_string_temp = PF_TempStr(prinst);
v = G_FLOAT(OFS_PARM0);
num = G_FLOAT(OFS_PARM1);
@ -3292,7 +3300,7 @@ void PF_fabs (progfuncs_t *prinst, struct globalvars_s *pr_globals)
void PF_vtos (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char *pr_string_temp = PF_TempStr();
char *pr_string_temp = PF_TempStr(prinst);
sprintf (pr_string_temp, "'%5.1f %5.1f %5.1f'", G_VECTOR(OFS_PARM0)[0], G_VECTOR(OFS_PARM0)[1], G_VECTOR(OFS_PARM0)[2]);
RETURN_TSTRING(pr_string_temp);
}
@ -4956,7 +4964,7 @@ void PF_infokey (progfuncs_t *prinst, struct globalvars_s *pr_globals)
} else
value = "";
dest = PF_TempStr();
dest = PF_TempStr(prinst);
strcpy(dest, value);
RETURN_CSTRING(dest);
}
@ -5206,7 +5214,7 @@ void PF_substring (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int i, start, length;
char *s;
char *string = PF_TempStr();
char *string = PF_TempStr(prinst);
s = PR_GetStringOfs(prinst, OFS_PARM0);
start = G_FLOAT(OFS_PARM1);
@ -5312,7 +5320,7 @@ void PF_chr2str (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int i;
char *string = PF_TempStr();
char *string = PF_TempStr(prinst);
for (i = 0; i < *prinst->callargc; i++)
string[i] = G_FLOAT(OFS_PARM0 + i*3);
string[i] = '\0';
@ -5400,7 +5408,7 @@ void PF_strconv (progfuncs_t *prinst, struct globalvars_s *pr_globals)
unsigned char *string = PF_VarString(prinst, 3, pr_globals);
int len = strlen(string);
int i;
unsigned char *result = PF_TempStr();
unsigned char *result = PF_TempStr(prinst);
if (len >= MAXTEMPBUFFERLEN)
len = MAXTEMPBUFFERLEN-1;
@ -5477,7 +5485,7 @@ void PF_infoadd (progfuncs_t *prinst, struct globalvars_s *pr_globals)
char *value = PF_VarString(prinst, 2, pr_globals);
char *temp;
temp = PF_TempStr();
temp = PF_TempStr(prinst);
Q_strncpyz(temp, info, MAXTEMPBUFFERLEN);
Info_SetValueForStarKey(temp, key, value, MAXTEMPBUFFERLEN);
@ -5494,7 +5502,7 @@ void PF_infoget (progfuncs_t *prinst, struct globalvars_s *pr_globals)
key = Info_ValueForKey(info, key);
temp = PF_TempStr();
temp = PF_TempStr(prinst);
strcpy(temp, key);
RETURN_SSTRING(temp);
}
@ -5630,7 +5638,7 @@ void PF_fgets (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char c, *s, *o, *max;
int fnum = G_FLOAT(OFS_PARM0) - FIRST_QC_FILE_INDEX;
char *pr_string_temp = PF_TempStr();
char *pr_string_temp = PF_TempStr(prinst);
*pr_string_temp = '\0';
RETURN_SSTRING(pr_string_temp);
@ -5953,7 +5961,6 @@ lh_extension_t QSG_Extensions[] = {
{"DP_EF_FULLBRIGHT"}, //Rerouted to hexen2 support.
{"DP_EF_NODRAW"}, //implemented by sending it with no modelindex
{"DP_EF_RED"},
{"DP_EXTRA_TEMPSTRING"}, //ftos returns 16 temp buffers.
{"DP_HALFLIFE_MAP_CVAR"},
{"DP_MONSTERWALK"},
{"DP_MOVETYPEBOUNCEMISSILE"}, //I added the code for hexen2 support.
@ -5968,7 +5975,7 @@ lh_extension_t QSG_Extensions[] = {
{"DP_QC_FINDFLAGS", 1, NULL, {"findflags"}},
{"DP_QC_FINDCHAINFLAGS", 1, NULL, {"findchainflags"}},
{"DP_QC_FINDFLOAT", 1, NULL, {"findfloat"}},
//no support, just something I want... {"DP_QC_FS_SEARCH", 4, NULL, {"search_begin", "search_end", "search_getsize", "search_getfilename"}},
{"DP_QC_FS_SEARCH", 4, NULL, {"search_begin", "search_end", "search_getsize", "search_getfilename"}},
{"DP_QC_MINMAXBOUND", 3, NULL, {"min", "max", "bound"}},
{"DP_QC_MULTIPLETEMPSTRINGS"},
{"DP_QC_RANDOMVEC", 1, NULL, {"randomvec"}},
@ -6244,7 +6251,7 @@ void PF_Tokenize (progfuncs_t *prinst, struct globalvars_s *pr_globals) //84
}
void PF_ArgV (progfuncs_t *prinst, struct globalvars_s *pr_globals) //86 //string(float num) argv;
{
char *dest = PF_TempStr();
char *dest = PF_TempStr(prinst);
int i = G_FLOAT(OFS_PARM0);
if (i < 0)
{
@ -6279,7 +6286,7 @@ string substr(string str, float start, float len)
void PF_substr (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char *dest = PF_TempStr();
char *dest = PF_TempStr(prinst);
char *s;
int start, len, l;
@ -6315,7 +6322,7 @@ string strcat(string str1, string str2)
void PF_strcat (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char *dest = PF_TempStr();
char *dest = PF_TempStr(prinst);
char *src = PF_VarString(prinst, 0, pr_globals);
Q_strncpyz(dest, src, MAXTEMPBUFFERLEN);
RETURN_TSTRING(dest);
@ -6331,7 +6338,7 @@ string strcat(float pad, string str1, ...)
void PF_strpad (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char *dest = PF_TempStr();
char *dest = PF_TempStr(prinst);
int pad = G_FLOAT(OFS_PARM0);
char *src = PF_VarString(prinst, 1, pr_globals);
@ -6468,7 +6475,7 @@ void PF_calltimeofday (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
date_t date;
func_t f;
char *ret = PF_TempStr();
char *ret = PF_TempStr(prinst);
f = PR_FindFunction(svprogfuncs, "timeofday", PR_ANY);
if (f)
@ -6716,7 +6723,7 @@ static void PF_copyentity (progfuncs_t *prinst, struct globalvars_s *pr_globals)
void PF_etos (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char *s;
s = PF_TempStr();
s = PF_TempStr(prinst);
sprintf (s, "entity %i", G_EDICTNUM(prinst, OFS_PARM0));
G_INT(OFS_RETURN) = (int)PR_SetString(prinst, s);
}

View file

@ -122,7 +122,7 @@ qboolean SV_AddNailUpdate (edict_t *ent)
if (sv_nailhack.value)
return false;
demonails = true;
demonails = false;
if (numnails == MAX_NAILS)
return true;