Fix up some KTX issues (mostly bot related).

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6246 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2022-05-28 17:59:17 +00:00
parent f996ff5fc8
commit 255ce795a0
12 changed files with 101 additions and 52 deletions

View file

@ -4251,7 +4251,7 @@ void CL_LinkPacketEntities (void)
if (cl.model_precache_vwep[0] && state->modelindex2 < MAX_VWEP_MODELS)
{
if (state->modelindex == cl_playerindex && cl.model_precache_vwep[0]->loadstate == MLS_LOADED &&
cl.model_precache_vwep[state->modelindex2] && cl.model_precache_vwep[state->modelindex2]->loadstate == MLS_LOADED)
state->modelindex2 && cl.model_precache_vwep[state->modelindex2] && cl.model_precache_vwep[state->modelindex2]->loadstate == MLS_LOADED)
{
model = cl.model_precache_vwep[0];
model2 = cl.model_precache_vwep[state->modelindex2];

View file

@ -1691,7 +1691,7 @@ TRACE(("dbg: R_ApplyRenderer: clearing world\n"));
if (sv.world.worldmodel->loadstate != MLS_LOADED)
SV_UnspawnServer();
else if (svs.gametype == GT_PROGS)
else if (svs.gametype == GT_PROGS || svs.gametype == GT_Q1QVM)
{
for (i = 0; i < MAX_PRECACHE_MODELS; i++)
{

View file

@ -2179,7 +2179,7 @@ void R_DrawNameTags(void)
}
else
#endif
if (w && w->progs)
if (w && w->progs && svs.gametype == GT_PROGS)
{
int best = 0;
float bestscore = 0, score = 0;

View file

@ -1097,7 +1097,7 @@ void MSG_WriteUInt64 (sizebuf_t *sb, quint64_t c)
qbyte *buf;
int b = 0;
quint64_t l = 128;
while (c > l-1u)
while (c > l-1u && b < 8)
{ //count the extra bytes we need
b++;
l <<= 7; //each byte we add gains 8 bits, but we spend one on length.

View file

@ -1801,7 +1801,7 @@ void NPP_QWFlush(void)
int i;
for (i = 0, cl = svs.clients; i < sv.allocated_client_slots; i++, cl++)
{
if (cl->state == cs_spawned && !ISQWCLIENT(cl))
if (cl->state == cs_spawned && ISNQCLIENT(cl))
{
vec3_t org, ang;

View file

@ -877,14 +877,32 @@ static qintptr_t QVM_SetModel (void *offset, quintptr_t mask, const qintptr_t *a
}
static qintptr_t QVM_BPrint (void *offset, quintptr_t mask, const qintptr_t *arg)
{
SV_BroadcastPrintf(arg[0], "%s", (char*)VM_POINTER(arg[1]));
unsigned int flags = VM_LONG(arg[2]);
if (qvm_api_version < 13)
flags = 0; //added mid-v12, resulting in undefined values with early-12 mods.
SV_BroadcastPrint(flags, arg[0], (char*)VM_POINTER(arg[1]));
return 0;
}
static qintptr_t QVM_SPrint (void *offset, quintptr_t mask, const qintptr_t *arg)
{
if ((unsigned)VM_LONG(arg[0])-1u >= sv.allocated_client_slots)
unsigned int clnum = VM_LONG(arg[0])-1;
int level = VM_LONG(arg[1]);
const char *text = VM_POINTER(arg[2]);
unsigned int flags = VM_LONG(arg[3]);
#define SPRINT_IGNOREINDEMO ( 1<<0) // do not put such message in mvd demo
client_t *cl = &svs.clients[clnum];
if (clnum >= sv.allocated_client_slots)
return 0;
SV_ClientPrintf(&svs.clients[VM_LONG(arg[0])-1], VM_LONG(arg[1]), "%s", (char*)VM_POINTER(arg[2]));
if (qvm_api_version < 13)
flags = 0; //added mid-v12, resulting in undefined values with early-12 mods.
if (flags & SPRINT_IGNOREINDEMO)
{
if (level >= cl->messagelevel)
SV_PrintToClient(cl, level, text);
}
else
SV_ClientPrintf(cl, level, "%s", text);
return 0;
}
static qintptr_t QVM_CenterPrint (void *offset, quintptr_t mask, const qintptr_t *arg)
@ -2375,7 +2393,7 @@ qboolean PR_LoadQ1QVM(void)
if (!q1qvm)
{
if (!com_gamedirnativecode.ival && COM_FCheckExists(va("%s"ARCH_DL_POSTFIX, fname)))
Con_Printf(CON_WARNING"%s"ARCH_DL_POSTFIX" exists, but is blocked from loading due to known bugs in other engines. If this is from a safe source then either ^aset com_nogamedirnativecode 0^a or rename to eg %s%s_%s"ARCH_DL_POSTFIX"\n", fname, ((host_parms.binarydir && *host_parms.binarydir)?host_parms.binarydir:host_parms.basedir), fname, FS_GetGamedir(false));
Con_Printf(CON_WARNING"%s"ARCH_DL_POSTFIX" exists, but is blocked from loading due to known bugs in other engines. If this is from a safe source then either ^aset com_gamedirnativecode 1^a or rename to eg %s%s_%s"ARCH_DL_POSTFIX"\n", fname, ((host_parms.binarydir && *host_parms.binarydir)?host_parms.binarydir:host_parms.basedir), fname, FS_GetGamedir(false));
if (svprogfuncs == &q1qvmprogfuncs)
sv.world.progs = svprogfuncs = NULL;
return false;

View file

@ -1300,6 +1300,12 @@ void SV_StuffcmdToClient_Unreliable(client_t *cl, const char *string);
void VARGS SV_ClientPrintf (client_t *cl, int level, const char *fmt, ...) LIKEPRINTF(3);
void VARGS SV_ClientTPrintf (client_t *cl, int level, translation_t text, ...);
void VARGS SV_BroadcastPrintf (int level, const char *fmt, ...) LIKEPRINTF(2);
void SV_BroadcastPrint (unsigned int flags, int level, const char *text);
//flags exposed to ktx.
#define BPRINT_IGNOREINDEMO (1<<0) // broad cast print will be not put in demo
#define BPRINT_IGNORECLIENTS (1<<1) // broad cast print will not be seen by clients, but may be seen in demo
//#define BPRINT_QTVONLY (1<<2) // if broad cast print goes to demo, then it will be only qtv sream, but not file
#define BPRINT_IGNORECONSOLE (1<<3) // broad cast print will not be put in server console
void VARGS SV_BroadcastTPrintf (int level, translation_t fmt, ...);
void VARGS SV_BroadcastCommand (const char *fmt, ...) LIKEPRINTF(1);
void SV_SendMessagesToAll (void);

View file

@ -1726,6 +1726,11 @@ MSV_OpenUserDatabase();
host_client = &svs.clients[i];
if (host_client->state == cs_connected && host_client->protocol == SCP_BAD)
{
if (svs.gametype == GT_Q1QVM)
{ //ktx expects its bots to drop for each map change.
SV_DropClient(host_client);
continue;
}
sv_player = host_client->edict;
SV_ExtractFromUserinfo(host_client, true);
SV_SpawnParmsToQC(host_client);

View file

@ -1699,6 +1699,10 @@ qboolean SV_MVD_Record (mvddest_t *dest)
demo.datagram.data = demo.datagram_data;
demo.datagram.prim = demo.recorder.netchan.netprim;
demo.recorder.netchan.message.maxsize = sizeof(demo.recorder.netchan.message_buf);
demo.recorder.netchan.message.data = demo.recorder.netchan.message_buf;
demo.recorder.netchan.message.prim = demo.recorder.netchan.netprim;
if (sv_demoExtensions.ival == 2 || !*sv_demoExtensions.string)
{ /*more limited subset supported by ezquake, but not fuhquake/fodquake. sorry.*/
demo.recorder.fteprotocolextensions = /*PEXT_CHUNKEDDOWNLOADS|*/PEXT_256PACKETENTITIES|/*PEXT_FLOATCOORDS|*/PEXT_MODELDBL|PEXT_ENTITYDBL|PEXT_ENTITYDBL2|PEXT_SPAWNSTATIC2;
@ -1863,7 +1867,6 @@ void SV_MVD_SendInitialGamestate(mvddest_t *dest)
demo.recorder.prespawn_stage = PRESPAWN_SERVERINFO;
demo.recorder.prespawn_idx = 0;
demo.recorder.netchan.message = buf;
while (demo.recorder.prespawn_stage != PRESPAWN_COMPLETED)
{
if (demo.recorder.prespawn_stage == PRESPAWN_MAPCHECK)
@ -1877,7 +1880,6 @@ void SV_MVD_SendInitialGamestate(mvddest_t *dest)
SV_SendClientPrespawnInfo(&demo.recorder);
SV_MVD_WriteReliables(false);
}
memset(&demo.recorder.netchan.message, 0, sizeof(demo.recorder.netchan.message));
// send current status of all other players
@ -3092,8 +3094,8 @@ void SV_MVDInfoRemove_f (void)
}
void SV_MVDInfo_f (void)
{
static void SV_MVDInfo_f (void)
{ //callable by client, so be careful.
int len;
char buf[64];
vfsfile_t *f = NULL;
@ -3138,7 +3140,7 @@ void SV_MVDInfo_f (void)
for(;;)
{
len = VFS_READ (f, buf, sizeof(buf)-1);
if (len < 0)
if (len <= 0)
break;
buf[len] = 0;
Con_Printf("%s", buf);
@ -3146,7 +3148,12 @@ void SV_MVDInfo_f (void)
VFS_CLOSE(f);
}
void SV_UserMVDInfo_f (void)
{
SV_BeginRedirect(RD_CLIENT, host_client->language);
SV_MVDInfo_f();
SV_EndRedirect();
}

View file

@ -2611,7 +2611,7 @@ qboolean SV_Physics (void)
memset(&ucmd, 0, sizeof(ucmd));
for (i = 0; i < sv.allocated_client_slots; i++)
{
if (svs.clients[i].state > cs_zombie && svs.clients[i].protocol == SCP_BAD && svs.clients[i].msecs >= 1000/77)
if (svs.clients[i].state > cs_zombie && svs.clients[i].protocol == SCP_BAD && svs.clients[i].msecs >= 1000.0/77)
{ //then this is a bot
oldhost = host_client;
oldplayer = sv_player;

View file

@ -329,10 +329,7 @@ void VARGS SV_ClientPrintf (client_t *cl, int level, const char *fmt, ...)
}
#endif
if (cl->controller)
SV_PrintToClient(cl->controller, level, string);
else
SV_PrintToClient(cl, level, string);
SV_PrintToClient(cl, level, string);
}
void VARGS SV_ClientTPrintf (client_t *cl, int level, translation_t stringnum, ...)
@ -371,44 +368,41 @@ SV_BroadcastPrintf
Sends text to all active clients
=================
*/
void VARGS SV_BroadcastPrintf (int level, const char *fmt, ...)
void SV_BroadcastPrint (unsigned int flags, int level, const char *string)
{
va_list argptr;
char string[1024];
client_t *cl;
int i;
va_start (argptr,fmt);
vsnprintf (string,sizeof(string)-1, fmt,argptr);
va_end (argptr);
if(strlen(string) >= sizeof(string))
Sys_Error("SV_BroadcastPrintf: Buffer stomped\n");
//pretend to print on the server, but not to the client's console
Sys_Printf ("%s", string); // print to the system console
Log_String(LOG_CONSOLE, string); //dump into log
for (i=0, cl = svs.clients ; i<svs.allocated_client_slots ; i++, cl++)
if (!(flags & BPRINT_IGNORECONSOLE))
{
if (level < cl->messagelevel)
continue;
if (!cl->state)
continue;
if (cl->protocol == SCP_BAD)
continue;
//pretend to print on the server, but not to the client's console
Sys_Printf ("%s", string); // print to the system console
Log_String(LOG_CONSOLE, string); //dump into log
}
if (cl == sv.skipbprintclient) //silence bprints about the player in ClientConnect. NQ completely wipes the buffer after clientconnect, which is what traditionally hides it.
continue;
if (!(flags & BPRINT_IGNORECLIENTS))
{
for (i=0, cl = svs.clients ; i<svs.allocated_client_slots ; i++, cl++)
{
if (level < cl->messagelevel)
continue;
if (!cl->state)
continue;
if (cl->protocol == SCP_BAD)
continue;
if (cl->controller)
continue;
if (cl == sv.skipbprintclient) //silence bprints about the player in ClientConnect. NQ completely wipes the buffer after clientconnect, which is what traditionally hides it.
continue;
SV_PrintToClient(cl, level, string);
if (cl->controller)
continue;
SV_PrintToClient(cl, level, string);
}
}
#ifdef MVD_RECORDING
if (sv.mvdrecording)
if (sv.mvdrecording && !(flags&BPRINT_IGNOREINDEMO))
{
sizebuf_t *msg = MVDWrite_Begin (dem_all, 0, strlen(string)+3);
MSG_WriteByte (msg, svc_print);
@ -418,6 +412,18 @@ void VARGS SV_BroadcastPrintf (int level, const char *fmt, ...)
#endif
}
void VARGS SV_BroadcastPrintf (int level, const char *fmt, ...)
{
va_list argptr;
char string[1024];
va_start (argptr,fmt);
vsnprintf (string,sizeof(string)-1, fmt,argptr);
va_end (argptr);
if(strlen(string) >= sizeof(string))
Sys_Error("SV_BroadcastPrintf: Buffer stomped\n");
SV_BroadcastPrint(0, level, string);
}
void VARGS SV_BroadcastTPrintf (int level, translation_t stringnum, ...)
{
@ -3510,6 +3516,8 @@ void SV_SendClientMessages (void)
SZ_Clear (&c->netchan.message);
SZ_Clear (&c->datagram);
c->num_backbuf = 0;
if (c->edict)
c->edict->v->fixangle = FIXANGLE_NO;
continue;
}

View file

@ -5975,6 +5975,10 @@ static void SVNQ_Begin_f (void)
SV_RunCmd (&host_client->lastcmd, false);
SV_PostRunCmd();
host_client->lastruncmd = sv.time*1000;
#ifdef MVD_RECORDING
SV_MVD_AutoRecord();
#endif
}
static void SVNQ_PreSpawn_f (void)
{
@ -6281,8 +6285,8 @@ void SV_Pext_f(void)
void SV_MVDList_f (void);
void SV_MVDInfo_f (void);
void SV_UserMVDList_f (void);
void SV_UserMVDInfo_f (void);
typedef struct
{
char *name;
@ -6335,7 +6339,7 @@ ucmd_t ucmds[] =
{"demolist", SV_UserCmdMVDList_f},
{"dlist", SV_UserCmdMVDList_f}, //apparently people are too lazy to type.
//mvdsv has 4 more variants, for 6 total doing the same thing.
{"demoinfo", SV_MVDInfo_f},
{"demoinfo", SV_UserMVDInfo_f},
{"dl", SV_DemoDownload_f},
#endif
{"stopdownload",SV_StopDownload_f},
@ -7452,9 +7456,9 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse)
sv.world.physicstime = ptime;
}
if (host_client->state && host_client->protocol == SCP_BAD)
if (host_client->state && host_client->protocol == SCP_BAD && svs.gametype != GT_Q1QVM)
{
//botclients update their movement during prethink. make sure we use that stuff.
//botclients update their movement during prethink. make sure we use that stuff. ktx has a builtin.
ucmd->angles[0] = (int)(sv_player->v->v_angle[0] * (65535/360.0f));
ucmd->angles[1] = (int)(sv_player->v->v_angle[1] * (65535/360.0f));
ucmd->angles[2] = (int)(sv_player->v->v_angle[2] * (65535/360.0f));
@ -7553,6 +7557,7 @@ if (sv_player->v->health > 0 && before && !after )
#endif
pmove.world = NULL;
if (host_client->state && host_client->protocol != SCP_BAD)
{
vec3_t delta;
delta[0] = pmove.angles[0] - SHORT2ANGLE(pmove.cmd.angles[0]);