1
0
Fork 0
forked from fte/fteqw

something complained about alignment.

This commit is contained in:
Shpoike 2024-12-28 14:21:48 +00:00
parent 0c5e912397
commit 778bbefc8f
2 changed files with 19 additions and 15 deletions

View file

@ -68,6 +68,8 @@ static int needcleanup;
//int fatbytes;
#define round64(size) ((size+7)&~7)
void SV_ExpandNackFrames(client_t *client, int require, client_frame_t **currentframeptr)
{
client_frame_t *newframes;
@ -76,24 +78,25 @@ void SV_ExpandNackFrames(client_t *client, int require, client_frame_t **current
int maxlog = require * 2; /*this is the max number of ents updated per frame. we can't track more, so...*/
if (maxlog > client->max_net_ents)
maxlog = client->max_net_ents;
ptr = Z_Malloc( sizeof(client_frame_t)*UPDATE_BACKUP+
sizeof(*client->pendingdeltabits)*client->max_net_ents+
sizeof(*client->pendingcsqcbits)*client->max_net_ents+
sizeof(newframes[i].resend)*maxlog*UPDATE_BACKUP);
ptr = Z_Malloc( round64(sizeof(client_frame_t)*UPDATE_BACKUP)+
round64(sizeof(*client->pendingdeltabits)*client->max_net_ents)+
round64(sizeof(*client->pendingcsqcbits)*client->max_net_ents)+
round64(sizeof(newframes[i].resend)*maxlog)*UPDATE_BACKUP);
newframes = (void*)ptr;
memcpy(newframes, client->frameunion.frames, sizeof(client_frame_t)*UPDATE_BACKUP);
ptr += sizeof(client_frame_t)*UPDATE_BACKUP;
ptr += round64(sizeof(client_frame_t)*UPDATE_BACKUP);
memcpy(ptr, client->pendingdeltabits, sizeof(*client->pendingdeltabits)*client->max_net_ents);
client->pendingdeltabits = (void*)ptr;
ptr += sizeof(*client->pendingdeltabits)*client->max_net_ents;
ptr += round64(sizeof(*client->pendingdeltabits)*client->max_net_ents);
memcpy(ptr, client->pendingcsqcbits, sizeof(*client->pendingcsqcbits)*client->max_net_ents);
client->pendingcsqcbits = (void*)ptr;
ptr += sizeof(*client->pendingcsqcbits)*client->max_net_ents;
ptr += round64(sizeof(*client->pendingcsqcbits)*client->max_net_ents);
for (i = 0; i < UPDATE_BACKUP; i++)
{
newframes[i].maxresend = maxlog;
newframes[i].qwentities.max_entities = 0;
newframes[i].resend = (void*)ptr;
ptr += round64(sizeof(newframes[i].resend)*maxlog);
newframes[i].numresend = client->frameunion.frames[i].numresend;
memcpy(newframes[i].resend, client->frameunion.frames[i].resend, sizeof(newframes[i].resend)*newframes[i].numresend);
newframes[i].senttime = realtime;

View file

@ -2341,25 +2341,26 @@ void SV_ClientProtocolExtensionsChanged(client_t *client)
if ((client->fteprotocolextensions2 & PEXT2_REPLACEMENTDELTAS) || ISDPCLIENT(client))
{
#define round64(size) ((size+7)&~7)
char *ptr;
int maxents = maxpacketentities*4; /*this is the max number of ents updated per frame. we can't track more, so...*/
if (maxents > client->max_net_ents)
maxents = client->max_net_ents;
ptr = Z_Malloc( sizeof(client_frame_t)*UPDATE_BACKUP+
sizeof(*client->pendingdeltabits)*client->max_net_ents+
sizeof(*client->pendingcsqcbits)*client->max_net_ents+
sizeof(*client->frameunion.frames[i].resend)*maxents*UPDATE_BACKUP);
ptr = Z_Malloc( round64(sizeof(client_frame_t)*UPDATE_BACKUP)+
round64(sizeof(*client->pendingdeltabits)*client->max_net_ents)+
round64(sizeof(*client->pendingcsqcbits)*client->max_net_ents)+
round64(sizeof(*client->frameunion.frames[i].resend)*maxents)*UPDATE_BACKUP);
client->frameunion.frames = (void*)ptr;
ptr += sizeof(*client->frameunion.frames)*UPDATE_BACKUP;
ptr += round64(sizeof(*client->frameunion.frames)*UPDATE_BACKUP);
client->pendingdeltabits = (void*)ptr;
ptr += sizeof(*client->pendingdeltabits)*client->max_net_ents;
ptr += round64(sizeof(*client->pendingdeltabits)*client->max_net_ents);
client->pendingcsqcbits = (void*)ptr;
ptr += sizeof(*client->pendingcsqcbits)*client->max_net_ents;
ptr += round64(sizeof(*client->pendingcsqcbits)*client->max_net_ents);
for (i = 0; i < UPDATE_BACKUP; i++)
{
client->frameunion.frames[i].maxresend = maxents;
client->frameunion.frames[i].resend = (void*)ptr;
ptr += sizeof(*client->frameunion.frames[i].resend)*maxents;
ptr += round64(sizeof(*client->frameunion.frames[i].resend)*maxents);
client->frameunion.frames[i].senttime = realtime;
}