Support for qqshka's ktx api version 16.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6145 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2021-12-20 10:07:55 +00:00
parent cfb1814be3
commit 423b549fa8
4 changed files with 38 additions and 16 deletions

View file

@ -6342,6 +6342,8 @@ char *PF_infokey_Internal (int entnum, const char *key)
{ {
if (pr_imitatemvdsv.value && !strcmp(key, "*version")) if (pr_imitatemvdsv.value && !strcmp(key, "*version"))
value = "2.40"; value = "2.40";
else if (!strcmp(key, "modelname")) //for compat with mvdsv.
value = sv.modelname;
else else
{ {
if ((value = InfoBuf_ValueForKey(&svs.info, key)) == NULL || !*value) if ((value = InfoBuf_ValueForKey(&svs.info, key)) == NULL || !*value)

View file

@ -47,11 +47,11 @@ oh, wait, ktx no longer supports those properly.
13: 2009/june gamecode no longer aware of edict_t data (just 'qc' fields). 13: 2009/june gamecode no longer aware of edict_t data (just 'qc' fields).
14: 2017/march gamedata_t.maxentities added 14: 2017/march gamedata_t.maxentities added
15: 2017/june for-64bit string indirection changes. added GAME_CLEAR_EDICT. 15: 2017/june for-64bit string indirection changes. added GAME_CLEAR_EDICT.
16: wasted_edict_t_size is finally 0 16: wasted_edict_t_size is finally 0, mod is responsible for querying all strings.
*/ */
#define GAME_API_VERSION 15 #define GAME_API_VERSION 16
#define GAME_API_VERSION_MIN 8 #define GAME_API_VERSION_MIN 8
#define MAX_Q1QVM_EDICTS 768 //according to ktx at api version 12 (fte's protocols go to 2048) #define MAX_Q1QVM_EDICTS 768 //according to ktx at api version 12 (fte's protocols go to 2048). removed in v14.
#define MAPNAME_LEN 64 #define MAPNAME_LEN 64
void PR_SV_FillWorldGlobals(world_t *w); void PR_SV_FillWorldGlobals(world_t *w);
@ -448,7 +448,10 @@ static void Q1QVMED_ClearEdict (edict_t *e, qboolean wipe)
{ {
int num = e->entnum; int num = e->entnum;
if (wipe) if (wipe)
{
memset (e->v, 0, sv.world.edict_size - wasted_edict_t_size); memset (e->v, 0, sv.world.edict_size - wasted_edict_t_size);
memset (e->xv, 0, sizeof(*e->xv));
}
if (qvm_api_version >= 15) if (qvm_api_version >= 15)
{ {
int oself = pr_global_struct->self; int oself = pr_global_struct->self;
@ -515,8 +518,9 @@ static edict_t *QDECL Q1QVMPF_EntAlloc(pubprogfuncs_t *pf, pbool object, size_t
sv.world.num_edicts++; sv.world.num_edicts++;
e = (edict_t*)Q1QVMPF_EdictNum(pf, i); e = (edict_t*)Q1QVMPF_EdictNum(pf, i);
// new ents come ready wiped // new ents come ready wiped (unless 15 in which case we need to give the gamecode a chance to set safe defaults)
// Q1QVMED_ClearEdict (e, false); if (qvm_api_version >= 15)
Q1QVMED_ClearEdict (e, false);
ED_Spawned((struct edict_s *) e, false); ED_Spawned((struct edict_s *) e, false);
@ -1901,16 +1905,16 @@ static qintptr_t QVM_VisibleTo (void *offset, quintptr_t mask, const qintptr_t *
{ {
unsigned int a0 = VM_LONG(arg[0]); unsigned int a0 = VM_LONG(arg[0]);
unsigned int a1 = VM_LONG(arg[1]); unsigned int a1 = VM_LONG(arg[1]);
if (a0 < sv.world.num_edicts || a1 < sv.world.num_edicts) if (a0 < sv.world.num_edicts && a1 < sv.world.num_edicts)
{ {
pvscache_t *viewer = &q1qvmprogfuncs.edicttable[a0]->pvsinfo; pvscache_t *viewer = &q1qvmprogfuncs.edicttable[a0]->pvsinfo;
pvscache_t *viewee = &q1qvmprogfuncs.edicttable[a1]->pvsinfo; pvscache_t *viewee = &q1qvmprogfuncs.edicttable[a1]->pvsinfo;
if (viewer->num_leafs && viewee->num_leafs) if (viewer->num_leafs && viewee->num_leafs)
{ {
unsigned int i; unsigned int i;
int areas[] = {2,viewer->areanum, viewer->areanum2};
for (i = 0; i < viewer->num_leafs; i++) for (i = 0; i < viewer->num_leafs; i++)
{ {
int areas[] = {2,viewer->areanum, viewer->areanum2};
qbyte *pvs = sv.world.worldmodel->funcs.ClusterPVS(sv.world.worldmodel, viewer->leafnums[i], NULL, PVM_FAST); qbyte *pvs = sv.world.worldmodel->funcs.ClusterPVS(sv.world.worldmodel, viewer->leafnums[i], NULL, PVM_FAST);
if (sv.world.worldmodel->funcs.EdictInFatPVS(sv.world.worldmodel, viewee, pvs, areas)) if (sv.world.worldmodel->funcs.EdictInFatPVS(sv.world.worldmodel, viewee, pvs, areas))
return true; //viewer can see viewee return true; //viewer can see viewee
@ -2331,9 +2335,15 @@ qboolean PR_LoadQ1QVM(void)
return false; return false;
} }
//in version 13, the actual edict_t struct is gone, and there's a pointer to it in its place (which is unusable, and changes depending on modes). if (qvm_api_version >= 16)
if (qvm_api_version) { //version 16 finally removed the last remnant of the server's state from the qvm.
wasted_edict_t_size = 0;
}
else if (qvm_api_version >= 13)
{
//in version 13, the actual edict_t struct is gone, and there's a pointer to it in its place (which is unusable, and changes depending on modes).
wasted_edict_t_size = (VM_NonNative(q1qvm)?sizeof(int):sizeof(void*)); wasted_edict_t_size = (VM_NonNative(q1qvm)?sizeof(int):sizeof(void*));
}
else else
{ {
//fte/qclib has split edict_t and entvars_t. //fte/qclib has split edict_t and entvars_t.
@ -2488,8 +2498,8 @@ qboolean PR_LoadQ1QVM(void)
} }
pr_global_struct->self = 0; pr_global_struct->self = 0;
if (qvm_api_version == 15)
Q1QVMPF_SetStringGlobal(sv.world.progs, &gvars->mapname, svs.name, MAPNAME_LEN); Q1QVMPF_SetStringGlobal(sv.world.progs, &gvars->mapname, svs.name, MAPNAME_LEN);
} }
else else
{ {
@ -2508,7 +2518,12 @@ qboolean PR_LoadQ1QVM(void)
void Q1QVM_ClientConnect(client_t *cl) void Q1QVM_ClientConnect(client_t *cl)
{ {
if (qvm_api_version >= 15 && !VM_NonNative(q1qvm)) if (qvm_api_version >= 16)
{
Q_strncpyz(cl->namebuf, cl->name, sizeof(cl->namebuf));
cl->name = cl->namebuf;
}
else if (qvm_api_version >= 15 && !VM_NonNative(q1qvm))
{ {
Q_strncpyz(cl->namebuf, cl->name, sizeof(cl->namebuf)); Q_strncpyz(cl->namebuf, cl->name, sizeof(cl->namebuf));
Q1QVMPF_SetStringField(sv.world.progs, cl->edict, &cl->edict->v->netname, cl->namebuf, true); Q1QVMPF_SetStringField(sv.world.progs, cl->edict, &cl->edict->v->netname, cl->namebuf, true);
@ -2593,14 +2608,14 @@ qboolean Q1QVM_ClientSay(edict_t *player, qboolean team)
return washandled; return washandled;
} }
qboolean Q1QVM_UserInfoChanged(edict_t *player) qboolean Q1QVM_UserInfoChanged(edict_t *player, qboolean after)
{ //mod will use G_CMD_ARGV to get argv1+argv2 to read the info that is changing. { //mod will use G_CMD_ARGV to get argv1+argv2 to read the info that is changing.
if (!q1qvm) if (!q1qvm)
return false; return false;
pr_global_struct->time = sv.world.physicstime; pr_global_struct->time = sv.world.physicstime;
pr_global_struct->self = Q1QVMPF_EdictToProgs(svprogfuncs, player); pr_global_struct->self = Q1QVMPF_EdictToProgs(svprogfuncs, player);
return VM_Call(q1qvm, GAME_CLIENT_USERINFO_CHANGED, 0, 0, 0); return VM_Call(q1qvm, GAME_CLIENT_USERINFO_CHANGED, after, 0, 0);
} }
void Q1QVM_PlayerPreThink(void) void Q1QVM_PlayerPreThink(void)

View file

@ -149,7 +149,7 @@ qboolean PR_LoadQ1QVM(void);
void Q1QVM_ClientConnect(struct client_s *cl); void Q1QVM_ClientConnect(struct client_s *cl);
qboolean Q1QVM_GameConsoleCommand(void); qboolean Q1QVM_GameConsoleCommand(void);
qboolean Q1QVM_ClientSay(edict_t *player, qboolean team); qboolean Q1QVM_ClientSay(edict_t *player, qboolean team);
qboolean Q1QVM_UserInfoChanged(edict_t *player); qboolean Q1QVM_UserInfoChanged(edict_t *player, qboolean after);
void Q1QVM_PlayerPreThink(void); void Q1QVM_PlayerPreThink(void);
void Q1QVM_RunPlayerThink(void); void Q1QVM_RunPlayerThink(void);
void Q1QVM_PostThink(void); void Q1QVM_PostThink(void);

View file

@ -4680,7 +4680,7 @@ void SV_SetInfo_f (void)
} }
#ifdef VM_Q1 #ifdef VM_Q1
if (Q1QVM_UserInfoChanged(sv_player)) if (Q1QVM_UserInfoChanged(sv_player, false))
return; return;
#endif #endif
@ -4760,6 +4760,11 @@ void SV_SetInfo_f (void)
PR_ClientUserInfoChanged(key, oldval, InfoBuf_ValueForKey(&host_client->userinfo, key)); PR_ClientUserInfoChanged(key, oldval, InfoBuf_ValueForKey(&host_client->userinfo, key));
} }
} }
#ifdef VM_Q1
Q1QVM_UserInfoChanged(sv_player, true);
#endif
Z_Free(key); Z_Free(key);
Z_Free(val); Z_Free(val);
} }