Skip to content

Commit f81e893

Browse files
committed
remove client_t.gentity and SV_GentityNum
We need to use the gentityMapper instead, to properly handle QVM.
1 parent 105647d commit f81e893

File tree

7 files changed

+8
-30
lines changed

7 files changed

+8
-30
lines changed

codemp/icarus/GameInterface.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,17 @@ bool ICARUS_ValidEnt( sharedEntityMapper_t *ent )
307307
//and while this allows us to read it on our "fake" entity here, we can't modify pointers like this. We can however do
308308
//something completely hackish such as the following.
309309
assert(ent->s->number >= 0 && ent->s->number < MAX_GENTITIES);
310-
sharedEntity_t *trueEntity = SV_GentityNum(ent->s->number);
311310

312311
//This works because we're modifying the actual shared game vm data and turning one pointer into another.
313312
//While these pointers both look like garbage to us in here, they are not.
314313
if ( VM_IsCurrentQVM() )
315314
{
316-
sharedEntity_qvm_t *trueEntityQVM = (sharedEntity_qvm_t*)trueEntity;
317-
trueEntityQVM->script_targetname = trueEntityQVM->targetname;
315+
*ent->script_targetname.qvm = *ent->targetname.qvm;
316+
}
317+
else
318+
{
319+
*ent->script_targetname.native = *ent->targetname.native;
318320
}
319-
else trueEntity->script_targetname = trueEntity->targetname;
320321
return true;
321322
}
322323
}

codemp/server/server.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ typedef struct client_s {
153153
int lastMessageNum; // for delta compression
154154
int lastClientCommand; // reliable client message sequence
155155
char lastClientCommandString[MAX_STRING_CHARS];
156-
sharedEntity_t *gentity; // SV_GentityNum(clientnum)
157-
sharedEntityMapper_t *gentityMapper;
156+
sharedEntityMapper_t *gentityMapper; // SV_GentityMapperNum(clientnum)
158157
char name[MAX_NAME_LENGTH]; // extracted from userinfo, high bits masked
159158

160159
// downloading
@@ -381,12 +380,10 @@ void SV_SendClientSnapshot( client_t *client );
381380
//
382381
int SV_NumForGentity( const sharedEntity_t *ent );
383382
int SV_NumForGentityMapper( const sharedEntityMapper_t *ent );
384-
sharedEntity_t *SV_GentityNum( int num );
385383
sharedEntityMapper_t *SV_GentityMapperNum( int num );
386384
playerState_t *SV_GameClientNum( int num );
387385
svEntity_t *SV_SvEntityForGentity( sharedEntity_t *gEnt );
388386
svEntity_t *SV_SvEntityForGentityMapper( sharedEntityMapper_t *gEnt );
389-
sharedEntity_t *SV_GEntityForSvEntity( svEntity_t *svEnt );
390387
sharedEntityMapper_t *SV_GEntityMapperForSvEntity( svEntity_t *svEnt );
391388
sharedEntityMapper_t *SV_GEntityMapperForGentity( const sharedEntity_t *gEnt );
392389
void SV_InitGameProgs ( void );

codemp/server/sv_bot.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ int SV_BotAllocateClient(void) {
201201
return -1;
202202
}
203203

204-
cl->gentity = SV_GentityNum( i );
205204
cl->gentityMapper = SV_GentityMapperNum( i );
206205
cl->gentityMapper->s->number = i;
207206
cl->state = CS_ACTIVE;
@@ -264,8 +263,8 @@ void BotDrawDebugPolygons(void (*drawPoly)(int color, int numPoints, float *poin
264263
if (bot_reachability->integer) parm0 |= 2;
265264
if (bot_groundonly->integer) parm0 |= 4;
266265
botlib_export->BotLibVarSet("bot_highlightarea", bot_highlightarea->string);
267-
botlib_export->Test(parm0, NULL, svs.clients[0].gentity->r.currentOrigin,
268-
svs.clients[0].gentity->r.currentAngles);
266+
botlib_export->Test(parm0, NULL, svs.clients[0].gentityMapper->r->currentOrigin,
267+
svs.clients[0].gentityMapper->r->currentAngles);
269268
} //end if
270269
//draw all debug polys
271270
for (i = 0; i < bot_maxdebugpolys; i++) {

codemp/server/sv_client.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ void SV_DirectConnect( netadr_t from ) {
302302
// this is the only place a client_t is ever initialized
303303
*newcl = temp;
304304
clientNum = newcl - svs.clients;
305-
newcl->gentity = SV_GentityNum( clientNum );
306305
newcl->gentityMapper = SV_GentityMapperNum( clientNum );
307306

308307
// save the challenge
@@ -560,7 +559,6 @@ void SV_ClientEnterWorld( client_t *client, usercmd_t *cmd ) {
560559

561560
// set up the entity for the client
562561
clientNum = client - svs.clients;
563-
client->gentity = SV_GentityNum( clientNum );
564562
client->gentityMapper = SV_GentityMapperNum( clientNum );
565563
client->gentityMapper->s->number = clientNum;
566564

codemp/server/sv_game.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ int SV_NumForGentityMapper( const sharedEntityMapper_t *ent ) {
4747
return ent - sv.gentitiesMapper;
4848
}
4949

50-
sharedEntity_t *SV_GentityNum( int num ) {
51-
sharedEntity_t *ent;
52-
53-
ent = (sharedEntity_t *)((byte *)sv.gentities + sv.gentitySize*(num));
54-
55-
return ent;
56-
}
57-
5850
sharedEntityMapper_t *SV_GentityMapperNum( int num ) {
5951
if ( num < 0 || num >= (int)ARRAY_LEN(sv.gentitiesMapper) ) return NULL;
6052
return &sv.gentitiesMapper[num];
@@ -82,13 +74,6 @@ svEntity_t *SV_SvEntityForGentityMapper( sharedEntityMapper_t *gEnt ) {
8274
return &sv.svEntities[ gEnt->s->number ];
8375
}
8476

85-
sharedEntity_t *SV_GEntityForSvEntity( svEntity_t *svEnt ) {
86-
int num;
87-
88-
num = svEnt - sv.svEntities;
89-
return SV_GentityNum( num );
90-
}
91-
9277
sharedEntityMapper_t *SV_GEntityMapperForSvEntity( svEntity_t *svEnt ) {
9378
int num;
9479

codemp/server/sv_gameapi.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3017,7 +3017,6 @@ void SV_InitGame( qboolean restart ) {
30173017
// clear level pointers
30183018
sv.entityParsePoint = CM_EntityString();
30193019
for ( i=0, cl=svs.clients; i<sv_maxclients->integer; i++, cl++ ) {
3020-
cl->gentity = NULL;
30213020
cl->gentityMapper = NULL;
30223021
}
30233022

codemp/server/sv_init.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,6 @@ Ghoul2 Insert End
673673
client->state = CS_ACTIVE;
674674
client->gentityMapper = SV_GentityMapperNum( i );
675675
client->gentityMapper->s->number = i;
676-
client->gentity = SV_GentityNum( i );
677676

678677
client->deltaMessage = -1;
679678
client->nextSnapshotTime = svs.time; // generate a snapshot immediately

0 commit comments

Comments
 (0)