Apply 4140 update

This commit is contained in:
Alibek Omarov
2018-06-09 01:28:35 +03:00
parent 9bab7d222a
commit 814b7eda07
76 changed files with 1397 additions and 529 deletions
+2 -2
View File
@@ -340,7 +340,7 @@ void SV_ConnectClient( netadr_t from )
sv.current_client = newcl;
newcl->edict = EDICT_NUM( (newcl - svs.clients) + 1 );
newcl->challenge = challenge; // save challenge for checksumming
newcl->frames = (client_frame_t *)Z_Malloc( sizeof( client_frame_t ) * SV_UPDATE_BACKUP );
newcl->frames = (client_frame_t *)Z_Calloc( sizeof( client_frame_t ) * SV_UPDATE_BACKUP );
newcl->userid = g_userid++; // create unique userid
newcl->state = cs_connected;
@@ -2252,7 +2252,7 @@ void SV_ParseResourceList( sv_client_t *cl, sizebuf_t *msg )
for( i = 0; i < total; i++ )
{
resource = Z_Malloc( sizeof( resource_t ) );
resource = Z_Calloc( sizeof( resource_t ) );
Q_strncpy( resource->szFileName, MSG_ReadString( msg ), sizeof( resource->szFileName ));
resource->type = MSG_ReadByte( msg );
resource->nIndex = MSG_ReadShort( msg );
+15 -9
View File
@@ -609,7 +609,7 @@ void SV_RestartDecals( void )
if( !SV_Active( )) return;
// g-cont. add space for studiodecals if present
host.decalList = (decallist_t *)Z_Malloc( sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
host.decalList = (decallist_t *)Z_Calloc( sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
host.numdecals = R_CreateDecalList( host.decalList );
// remove decals from map
@@ -692,7 +692,7 @@ void SV_WriteEntityPatch( const char *filename )
char *entities = NULL;
FS_Seek( f, lumpofs, SEEK_SET );
entities = (char *)Z_Malloc( lumplen + 1 );
entities = (char *)Z_Calloc( lumplen + 1 );
FS_Read( f, entities, lumplen );
FS_WriteFile( va( "maps/%s.ent", filename ), entities, lumplen );
Con_Printf( "Write 'maps/%s.ent'\n", filename );
@@ -760,7 +760,7 @@ static char *SV_ReadEntityScript( const char *filename, int *flags )
if( !ents && lumplen >= 32 )
{
FS_Seek( f, lumpofs, SEEK_SET );
ents = Z_Malloc( lumplen + 1 );
ents = Z_Calloc( lumplen + 1 );
FS_Read( f, ents, lumplen );
}
FS_Close( f ); // all done
@@ -2011,8 +2011,14 @@ int SV_BuildSoundMsg( sizebuf_t *msg, edict_t *ent, int chan, const char *sample
if( sample[0] == '!' && Q_isdigit( sample + 1 ))
{
SetBits( flags, SND_SENTENCE );
sound_idx = Q_atoi( sample + 1 );
if( sound_idx >= MAX_SOUNDS )
{
SetBits( flags, SND_SENTENCE|SND_SEQUENCE );
sound_idx -= MAX_SOUNDS;
}
else SetBits( flags, SND_SENTENCE );
}
else if( sample[0] == '#' && Q_isdigit( sample + 1 ))
{
@@ -2922,7 +2928,7 @@ void *pfnPvAllocEntPrivateData( edict_t *pEdict, long cb )
if( cb > 0 )
{
// a poke646 have memory corrupt in somewhere - this is trashed last sixteen bytes :(
pEdict->pvPrivateData = Mem_Alloc( svgame.mempool, (cb + 15) & ~15 );
pEdict->pvPrivateData = Mem_Calloc( svgame.mempool, (cb + 15) & ~15 );
}
return pEdict->pvPrivateData;
@@ -2962,7 +2968,7 @@ string_t SV_AllocString( const char *szString )
l = Q_strlen( szString ) + 1;
out = out_p = Mem_Alloc( svgame.stringspool, l );
out = out_p = Mem_Calloc( svgame.stringspool, l );
for( i = 0; i < l; i++ )
{
if( szString[i] == '\\' && i < l - 1 )
@@ -4094,7 +4100,7 @@ void pfnEndSection( const char *pszSection )
{
if( !Q_stricmp( "oem_end_credits", pszSection ))
Host_Credits ();
else Cbuf_AddText( va( "endgame \"%s\"\n", pszSection ));
else Cbuf_AddText( "\ndisconnect\n" );
}
/*
@@ -4860,8 +4866,8 @@ qboolean SV_LoadProgs( const char *name )
svgame.globals->maxEntities = GI->max_edicts;
svgame.globals->maxClients = svs.maxclients;
svgame.edicts = Mem_Alloc( svgame.mempool, sizeof( edict_t ) * GI->max_edicts );
svs.baselines = Z_Malloc( sizeof( entity_state_t ) * GI->max_edicts );
svgame.edicts = Mem_Calloc( svgame.mempool, sizeof( edict_t ) * GI->max_edicts );
svs.baselines = Z_Calloc( sizeof( entity_state_t ) * GI->max_edicts );
svgame.numEntities = svs.maxclients + 1; // clients + world
for( i = 0, e = svgame.edicts; i < GI->max_edicts; i++, e++ )
+2 -2
View File
@@ -1943,7 +1943,7 @@ static char **pfnGetFilesList( const char *pattern, int *numFiles, int gamediron
static void *pfnMem_Alloc( size_t cb, const char *filename, const int fileline )
{
return _Mem_Alloc( svgame.mempool, cb, filename, fileline );
return _Mem_Alloc( svgame.mempool, cb, true, filename, fileline );
}
static void pfnMem_Free( void *mem, const char *filename, const int fileline )
@@ -1979,7 +1979,7 @@ const byte *pfnLoadImagePixels( const char *filename, int *width, int *height )
if( !pic ) return NULL;
buffer = Mem_Alloc( svgame.mempool, pic->size );
buffer = Mem_Malloc( svgame.mempool, pic->size );
if( buffer ) memcpy( buffer, pic->buffer, pic->size );
if( width ) *width = pic->width;
if( height ) *height = pic->height;
+1 -1
View File
@@ -177,7 +177,7 @@ void SV_GetTrueOrigin( sv_client_t *cl, int edictnum, vec3_t origin )
return;
if( svgame.interp[edictnum-1].active && svgame.interp[edictnum-1].moving )
VectorCopy( svgame.interp[edictnum-1].newpos, origin );
VectorCopy( svgame.interp[edictnum-1].oldpos, origin );
}
void SV_GetTrueMinMax( sv_client_t *cl, int edictnum, vec3_t mins, vec3_t maxs )
+6 -6
View File
@@ -266,7 +266,7 @@ static void InitEntityTable( SAVERESTOREDATA *pSaveData, int entityCount )
ENTITYTABLE *pTable;
int i;
pSaveData->pTable = Mem_Alloc( host.mempool, sizeof( ENTITYTABLE ) * entityCount );
pSaveData->pTable = Mem_Calloc( host.mempool, sizeof( ENTITYTABLE ) * entityCount );
pSaveData->tableCount = entityCount;
// setup entitytable
@@ -604,8 +604,8 @@ static SAVERESTOREDATA *SaveInit( int size, int tokenCount )
{
SAVERESTOREDATA *pSaveData;
pSaveData = Mem_Alloc( host.mempool, sizeof( SAVERESTOREDATA ) + size );
pSaveData->pTokens = (char **)Mem_Alloc( host.mempool, tokenCount * sizeof( char* ));
pSaveData = Mem_Calloc( host.mempool, sizeof( SAVERESTOREDATA ) + size );
pSaveData->pTokens = (char **)Mem_Calloc( host.mempool, tokenCount * sizeof( char* ));
pSaveData->tokenCount = tokenCount;
pSaveData->pBaseData = (char *)(pSaveData + 1); // skip the save structure);
@@ -1108,7 +1108,7 @@ static void SaveClientState( SAVERESTOREDATA *pSaveData, const char *level, int
memset( &header, 0, sizeof( header ));
// g-cont. add space for studiodecals if present
decalList = (decallist_t *)Z_Malloc( sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
decalList = (decallist_t *)Z_Calloc( sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
// initialize client header
header.decalCount = R_CreateDecalList( decalList );
@@ -2220,14 +2220,14 @@ qboolean SV_GetSaveComment( const char *savename, char *comment )
return 0;
}
pSaveData = (char *)Mem_Alloc( host.mempool, size );
pSaveData = (char *)Mem_Malloc( host.mempool, size );
FS_Read( f, pSaveData, size );
pData = pSaveData;
// allocate a table for the strings, and parse the table
if( tokenSize > 0 )
{
pTokenList = Mem_Alloc( host.mempool, tokenCount * sizeof( char* ));
pTokenList = Mem_Calloc( host.mempool, tokenCount * sizeof( char* ));
// make sure the token strings pointed to by the pToken hashtable.
for( i = 0; i < tokenCount; i++ )