1
0
Fork 0
forked from fte/fteqw

fix a couple of serious issues molgrum reported.

fix dedicated server to integrate inside fteqcc.
fix bug with jump being released.
fix fteqcc always using 32bit output.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5086 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2017-03-30 18:37:16 +00:00
parent 492feafd1d
commit c46f6a3a53
12 changed files with 158 additions and 73 deletions

View file

@ -723,9 +723,11 @@ static void CL_EntStateToPlayerState(player_state_t *plstate, entity_state_t *st
vec3_t a;
int pmtype;
qboolean onground = plstate->onground;
qboolean jumpheld = plstate->jump_held;
vec3_t vel;
VectorCopy(plstate->velocity, vel);
memset(plstate, 0, sizeof(*plstate));
plstate->jump_held = jumpheld;
switch(state->u.q1.pmovetype)
{

View file

@ -1838,7 +1838,7 @@ void INS_Commands (void)
K_AUX9, //left trigger
K_AUX10 //right trigger
};
static const int dinputjbuttons[32] =
static const int mmjbuttons[32] =
{
K_JOY1,
K_JOY2,
@ -1908,10 +1908,10 @@ void INS_Commands (void)
for (i=0 ; i < joy->numbuttons ; i++)
{
if ( (buttonstate & (1<<i)) && !(joy->oldbuttonstate & (1<<i)) )
Key_Event (joy->devid, dinputjbuttons[i], 0, true);
Key_Event (joy->devid, mmjbuttons[i], 0, true);
if ( !(buttonstate & (1<<i)) && (joy->oldbuttonstate & (1<<i)) )
Key_Event (joy->devid, dinputjbuttons[i], 0, false);
Key_Event (joy->devid, mmjbuttons[i], 0, false);
}
}
joy->oldbuttonstate = buttonstate;

View file

@ -305,7 +305,6 @@ qboolean QCExternalDebuggerCommand(char *text)
int QDECL QCEditor (pubprogfuncs_t *prinst, const char *filename, int *line, int *statement, char *reason, pbool fatal)
{
#ifndef SERVERONLY
#if defined(_WIN32) && !defined(FTE_SDL) && !defined(_XBOX)
if (isPlugin >= 2)
{
@ -318,7 +317,11 @@ int QDECL QCEditor (pubprogfuncs_t *prinst, const char *filename, int *line, int
return DEBUG_TRACE_ABORT;
return DEBUG_TRACE_OFF;
}
#ifdef SERVERONLY
SV_GetConsoleCommands();
#else
Sys_SendKeyEvents();
#endif
debuggerresume = -1;
debuggerresumeline = *line;
if (debuggerwnd)
@ -331,9 +334,21 @@ int QDECL QCEditor (pubprogfuncs_t *prinst, const char *filename, int *line, int
else
printf("qcstep \"%s\":%i\n", filename, *line);
fflush(stdout);
INS_UpdateGrabs(false, false);
debuggerinstance = prinst;
debuggerfile = filename;
#ifdef SERVERONLY
if (reason)
{
printf("Debugger triggered at \"%s\":%i, %s\n", filename, *line, reason);
PR_StackTrace(prinst, 1);
}
while(debuggerresume == -1 && !wantquit)
{
Sleep(10);
SV_GetConsoleCommands();
}
#else
INS_UpdateGrabs(false, false);
if (reason)
Con_Footerf(NULL, false, "^bDebugging: %s", reason);
else
@ -359,6 +374,7 @@ int QDECL QCEditor (pubprogfuncs_t *prinst, const char *filename, int *line, int
}
}
Con_Footerf(NULL, false, "");
#endif
*line = debuggerresumeline;
debuggerinstance = NULL;
debuggerfile = NULL;
@ -367,7 +383,6 @@ int QDECL QCEditor (pubprogfuncs_t *prinst, const char *filename, int *line, int
return debuggerresume;
}
#endif
#endif
#ifdef TEXTEDITOR
return QCLibEditor(prinst, filename, line, statement, reason, fatal);

View file

@ -327,7 +327,11 @@ void VARGS Z_FreeTags(int tag)
#define SIZE_MAX ((size_t)-1)
#endif
#ifdef USE_MSVCRT_DEBUG
qboolean ZF_ReallocElementsNamed(void **ptr, size_t *elements, size_t newelements, size_t elementsize, const char *file, int line)
#else
qboolean ZF_ReallocElements(void **ptr, size_t *elements, size_t newelements, size_t elementsize)
#endif
{
void *n;
size_t oldsize;
@ -340,7 +344,11 @@ qboolean ZF_ReallocElements(void **ptr, size_t *elements, size_t newelements, si
oldsize = *elements * elementsize;
newsize = newelements * elementsize;
#ifdef USE_MSVCRT_DEBUG
n = BZ_ReallocNamed(*ptr, newsize, file, line);
#else
n = BZ_Realloc(*ptr, newsize);
#endif
if (!n)
return false;
if (newsize > oldsize)

View file

@ -96,6 +96,7 @@ void *VARGS Z_TagMalloc (int size, int tag);
void VARGS Z_TagFree(void *ptr);
void VARGS Z_FreeTags(int tag);
qboolean ZF_ReallocElements(void **ptr, size_t *elements, size_t newelements, size_t elementsize); //returns false on error
qboolean ZF_ReallocElementsNamed(void **ptr, size_t *elements, size_t newelements, size_t elementsize, char *file, int line); //returns false on error
#define Z_ReallocElements(ptr,elements,newelements,elementsize) do{if (!ZF_ReallocElements(ptr,elements,newelements,elementsize))Sys_Error("Z_ReallocElements failed (%s %i)\n", __FILE__, __LINE__);}while(0) //returns false on error
//Big Zone: allowed to fail, doesn't clear. The expectation is a large file, rather than sensitive data structures.
@ -128,6 +129,7 @@ void ZG_FreeGroup(zonegroup_t *ctx);
#define ZF_Malloc(size) ZF_MallocNamed(size, __FILE__, __LINE__)
#define BZF_Realloc(ptr, size) BZF_ReallocNamed(ptr, size, __FILE__, __LINE__)
#define ZG_Malloc(ctx, size) ZG_MallocNamed(ctx, size, __FILE__, __LINE__)
#define ZF_ReallocElements(p,e,n,s) ZF_ReallocElementsNamed(p,e,n,s,__FILE__,__LINE__)
#endif
#define Z_StrDup(s) strcpy(Z_Malloc(strlen(s)+1), s)

View file

@ -7633,7 +7633,7 @@ QCC_ref_t *QCC_PR_RefTerm (QCC_ref_t *retbuf, unsigned int exprflags)
QCC_PR_ParseWarning(WARN_ASSIGNMENTTOCONSTANT, "Assignment to constant %s", QCC_GetSRefName(e));
QCC_PR_ParsePrintSRef(WARN_ASSIGNMENTTOCONSTANT, e);
}
if (e.sym->temp)
if (e.sym->temp && r->type == REF_GLOBAL)
QCC_PR_ParseWarning(WARN_ASSIGNMENTTOCONSTANT, "Hey! That's a temp! ++ operators cannot work on temps!");
switch (r->cast->type)
{

View file

@ -1225,6 +1225,22 @@ const char *QCC_FileForStatement(int st)
}
return ret;
}
const char *QCC_FunctionForStatement(int st)
{
const char *ret = "???";
int i;
for (i = 0; i < numfunctions; i++)
{
if (functions[i].code > 0)
{
if (st < functions[i].code)
break;
ret = functions[i].filen;
}
}
return ret;
}
CompilerConstant_t *QCC_PR_CheckCompConstDefined(char *def);
@ -1242,7 +1258,7 @@ pbool QCC_WriteData (int crc)
int *statement_linenums;
void *funcdata;
size_t funcdatasize;
pbool bigjumps;
const char *bigjumps = NULL;
extern char *basictypenames[];
@ -1283,14 +1299,15 @@ pbool QCC_WriteData (int crc)
for (i=0 ; i<numstatements ; i++)
{
if (!statements[i].a.sym && (statements[i].a.ofs > 0x7fff || statements[i].a.ofs < 0x7fff))
if (!statements[i].a.sym && ((int)statements[i].a.ofs > 0x7fff || (int)statements[i].a.ofs < -0x7fff))
break;
if (!statements[i].a.sym && (statements[i].a.ofs > 0x7fff || statements[i].a.ofs < 0x7fff))
if (!statements[i].a.sym && ((int)statements[i].a.ofs > 0x7fff || (int)statements[i].a.ofs < -0x7fff))
break;
if (!statements[i].a.sym && (statements[i].a.ofs > 0x7fff || statements[i].a.ofs < 0x7fff))
if (!statements[i].a.sym && ((int)statements[i].a.ofs > 0x7fff || (int)statements[i].a.ofs < -0x7fff))
break;
}
bigjumps = i<numstatements;
if (i < numstatements)
bigjumps = QCC_FunctionForStatement(i);
switch (qcc_targetformat)
{
@ -1301,7 +1318,7 @@ pbool QCC_WriteData (int crc)
if (bigjumps)
{
printf("Forcing target to FTE32 due to large functions\n");
printf("Forcing target to FTE32 due to large function %s\n", bigjumps);
outputsttype = PST_FTE32;
}
else if (numpr_globals > 65530)
@ -1340,7 +1357,7 @@ pbool QCC_WriteData (int crc)
{
if (bigjumps)
{
printf("Using 32 bit target due to large functions\n");
printf("Using 32 bit target due to large function %s\n", bigjumps);
outputsttype = PST_FTE32;
}
else if (numpr_globals > 65530)

View file

@ -2937,7 +2937,7 @@ void PF_centerprint_Internal (int entnum, qboolean plaque, const char *s)
if (entnum < 1 || entnum > sv.allocated_client_slots)
{
Con_TPrintf ("tried to sprint to a non-client\n");
PR_RunWarning(sv.world.progs, "tried to centerprint to a non-client\n");
return;
}
@ -9027,7 +9027,7 @@ int PF_ForceInfoKey_Internal(unsigned int entnum, const char *key, const char *v
svs.clients[entnum-1].spectator = ns;
}
SV_BroadcastUserinfoChange(host_client, SV_UserInfoIsBasic(key), key, value);
SV_BroadcastUserinfoChange(&svs.clients[entnum-1], SV_UserInfoIsBasic(key), key, value);
}
return 1;
@ -9066,6 +9066,7 @@ static void QCBUILTIN PF_setcolors (pubprogfuncs_t *prinst, struct globalvars_s
client_t *client;
int entnum, i;
char number[8];
char *key = NULL;
entnum = G_EDICTNUM(prinst, OFS_PARM0);
i = G_FLOAT(OFS_PARM1);
@ -9078,31 +9079,26 @@ static void QCBUILTIN PF_setcolors (pubprogfuncs_t *prinst, struct globalvars_s
client = &svs.clients[entnum-1];
client->edict->v->team = (i & 15) + 1;
#ifdef NQPROT
MSG_WriteByte (&sv.nqreliable_datagram, svc_updatecolors);
MSG_WriteByte (&sv.nqreliable_datagram, entnum - 1);
MSG_WriteByte (&sv.nqreliable_datagram, i);
#endif
sprintf(number, "%i", i>>4);
if (!strcmp(number, Info_ValueForKey(client->userinfo, "topcolor")))
{
Info_SetValueForKey(client->userinfo, "topcolor", number, sizeof(client->userinfo));
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, entnum-1);
MSG_WriteString (&sv.reliable_datagram, "topcolor");
MSG_WriteString (&sv.reliable_datagram, number);
key = "topcolor";
}
sprintf(number, "%i", i&15);
if (!strcmp(number, Info_ValueForKey(client->userinfo, "bottomcolor")))
{
Info_SetValueForKey(client->userinfo, "bottomcolor", number, sizeof(client->userinfo));
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, entnum-1);
MSG_WriteString (&sv.reliable_datagram, "bottomcolor");
MSG_WriteString (&sv.reliable_datagram, number);
key = key?"*bothcolours":"bottomcolor";
}
SV_ExtractFromUserinfo (client, true);
if (key)
{ //something changed at least.
SV_BroadcastUserinfoChange(client, true, key, NULL);
}
}
static void ParamNegateFix ( float * xx, float * yy, int Zone )

View file

@ -1548,7 +1548,6 @@ static void SV_ForceName_f (void)
{
client_t *cl;
int clnum=-1;
int i;
while((cl = SV_GetClientForString(Cmd_Argv(1), &clnum)))
{
@ -1556,12 +1555,7 @@ static void SV_ForceName_f (void)
SV_LogPlayer(cl, "name forced");
SV_ExtractFromUserinfo(cl, true);
Q_strncpyz(cl->name, Cmd_Argv(2), sizeof(cl->namebuf));
i = cl - svs.clients;
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, i);
MSG_WriteString (&sv.reliable_datagram, "name");
MSG_WriteString (&sv.reliable_datagram, cl->name);
SV_BroadcastUserinfoChange(cl, true, "name", cl->name);
return;
}

View file

@ -2807,16 +2807,7 @@ void SV_UpdateToReliableMessages (void)
Info_SetValueForKey(host_client->userinfo, "bottomcolor", va("%i", (int)host_client->edict->xv->clientcolors&15), sizeof(host_client->userinfo));
{
SV_ExtractFromUserinfo (host_client, true); //this will take care of nq for us anyway.
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, i);
MSG_WriteString (&sv.reliable_datagram, "topcolor");
MSG_WriteString (&sv.reliable_datagram, Info_ValueForKey(host_client->userinfo, "topcolor"));
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, i);
MSG_WriteString (&sv.reliable_datagram, "bottomcolor");
MSG_WriteString (&sv.reliable_datagram, Info_ValueForKey(host_client->userinfo, "bottomcolor"));
SV_BroadcastUserinfoChange(host_client, true, "*bothcolours", NULL);
}
}
#endif
@ -2837,10 +2828,7 @@ void SV_UpdateToReliableMessages (void)
if (strcmp(oname, host_client->name))
{
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, i);
MSG_WriteString (&sv.reliable_datagram, "name");
MSG_WriteString (&sv.reliable_datagram, host_client->name);
SV_BroadcastUserinfoChange(host_client, true, "name", host_client->name);
}
#ifdef QCGC
@ -3025,18 +3013,42 @@ void SV_UpdateToReliableMessages (void)
//a single userinfo value was changed.
//*bothcolours sends out both topcolor and bottomcolor, with a single svc_updatecolors in nq
static void SV_SendUserinfoChange(client_t *to, client_t *about, qboolean isbasic, const char *key, const char *newval)
{
int playernum = about - svs.clients;
if (playernum > to->max_net_clients)
return;
if (!newval)
newval = Info_ValueForKey(about->userinfo, key);
if (ISQWCLIENT(to))
{
if (isbasic || (to->fteprotocolextensions & PEXT_BIGUSERINFOS))
{
ClientReliableWrite_Begin(to, svc_setinfo, 4+strlen(key)+strlen(newval));
ClientReliableWrite_Byte(to, playernum);
ClientReliableWrite_String(to, key);
ClientReliableWrite_String(to, newval);
if (ISQWCLIENT(to) && !strcmp(key, "*bothcolours"))
{
newval = Info_ValueForKey(about->userinfo, "topcolor");
ClientReliableWrite_Begin(to, svc_setinfo, 4+strlen(key)+strlen(newval));
ClientReliableWrite_Byte(to, playernum);
ClientReliableWrite_String(to, "topcolor");
ClientReliableWrite_String(to, Info_ValueForKey(about->userinfo, "topcolor"));
newval = Info_ValueForKey(about->userinfo, "bottomcolor");
ClientReliableWrite_Begin(to, svc_setinfo, 4+strlen(key)+strlen(newval));
ClientReliableWrite_Byte(to, playernum);
ClientReliableWrite_String(to, "bottomcolor");
ClientReliableWrite_String(to, newval);
}
else
{
ClientReliableWrite_Begin(to, svc_setinfo, 4+strlen(key)+strlen(newval));
ClientReliableWrite_Byte(to, playernum);
ClientReliableWrite_String(to, key);
ClientReliableWrite_String(to, newval);
}
}
}
#ifdef NQPROT
@ -3058,7 +3070,7 @@ static void SV_SendUserinfoChange(client_t *to, client_t *about, qboolean isbasi
ClientReliableWrite_Byte(to, playernum);
ClientReliableWrite_String(to, newval);
}
else if (!strcmp(key, "topcolor") || !strcmp(key, "bottomcolor"))
else if (!strcmp(key, "topcolor") || !strcmp(key, "bottomcolor") || !strcmp(key, "*bothcolours"))
{ //due to these being combined, nq players get double colour change notifications...
int tc = atoi(Info_ValueForKey(about->userinfo, "topcolor"));
int bc = atoi(Info_ValueForKey(about->userinfo, "bottomcolor"));
@ -3086,6 +3098,8 @@ void SV_BroadcastUserinfoChange(client_t *about, qboolean isbasic, const char *k
{
client_t *client;
int j;
if (!newval)
newval = Info_ValueForKey(about->userinfo, key);
for (j = 0; j < svs.allocated_client_slots; j++)
{
client = svs.clients+j;

View file

@ -905,8 +905,8 @@ char *Sys_ConsoleInput (void)
{
if (!GetMessage (&msg, NULL, 0, 0))
return NULL;
TranslateMessage (&msg);
DispatchMessage (&msg);
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return NULL;
}
@ -955,6 +955,55 @@ char *Sys_ConsoleInput (void)
}
#endif
if (isPlugin)
{
DWORD avail;
static char text[256], *nl;
static int textpos = 0;
HANDLE input = GetStdHandle(STD_INPUT_HANDLE);
if (!PeekNamedPipe(input, NULL, 0, NULL, &avail, NULL))
{
wantquit = true;
Cmd_ExecuteString("quit force", RESTRICT_LOCAL);
}
else if (avail)
{
if (avail > sizeof(text)-1-textpos)
avail = sizeof(text)-1-textpos;
if (ReadFile(input, text+textpos, avail, &avail, NULL))
{
textpos += avail;
if (textpos > sizeof(text)-1)
Sys_Error("No.");
}
}
while (textpos)
{
text[textpos] = 0;
nl = strchr(text, '\n');
if (nl)
{
*nl++ = 0;
if (coninput_len)
{
putch ('\r');
putch (']');
}
coninput_len = 0;
Q_strncpyz(coninput_text, text, sizeof(coninput_text));
memmove(text, nl, textpos - (nl - text));
textpos -= (nl - text);
return coninput_text;
}
else
break;
}
}
// read a line out
while (_kbhit())
{

View file

@ -2932,7 +2932,7 @@ static int SV_LocateDownload(const char *name, flocation_t *loc, char **replacem
}
//mvdsv demo downloading support. demos/ -> demodir (sets up the server paths)
if (Q_strncasecmp(name, "demos/", 6))
if (!Q_strncasecmp(name, "demos/", 6))
{
Q_snprintfz(tmpname, sizeof(tmpname), "%s/%s", sv_demoDir.string, name+6);
name = tmpname;
@ -5569,22 +5569,14 @@ static void SVNQ_NQColour_f (void)
if (strcmp(val, Info_ValueForKey(host_client->userinfo, "topcolor")))
{
Info_SetValueForKey(host_client->userinfo, "topcolor", val, sizeof(host_client->userinfo));
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
MSG_WriteString (&sv.reliable_datagram, "topcolor");
MSG_WriteString (&sv.reliable_datagram, Info_ValueForKey(host_client->userinfo, "topcolor"));
SV_BroadcastUserinfoChange(host_client, true, "topcolor", NULL);
}
val = va("%i", bottom);
if (strcmp(val, Info_ValueForKey(host_client->userinfo, "bottomcolor")))
{
Info_SetValueForKey(host_client->userinfo, "bottomcolor", val, sizeof(host_client->userinfo));
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
MSG_WriteString (&sv.reliable_datagram, "bottomcolor");
MSG_WriteString (&sv.reliable_datagram, Info_ValueForKey(host_client->userinfo, "bottomcolor"));
SV_BroadcastUserinfoChange(host_client, true, "bottomcolor", NULL);
}
switch(bottom)
@ -5602,11 +5594,7 @@ static void SVNQ_NQColour_f (void)
if (strcmp(val, Info_ValueForKey(host_client->userinfo, "team")))
{
Info_SetValueForKey(host_client->userinfo, "team", val, sizeof(host_client->userinfo));
MSG_WriteByte (&sv.reliable_datagram, svc_setinfo);
MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
MSG_WriteString (&sv.reliable_datagram, "team");
MSG_WriteString (&sv.reliable_datagram, Info_ValueForKey(host_client->userinfo, "team"));
SV_BroadcastUserinfoChange(host_client, true, "team", NULL);
}
SV_ExtractFromUserinfo (host_client, true);