Initial amd64 port

This commit is contained in:
mittorn 2018-12-05 23:57:05 +07:00
parent aed53c4fda
commit 298393b653
35 changed files with 443 additions and 196 deletions

View File

@ -349,9 +349,9 @@ Write demo header
*/ */
void CL_WriteDemoHeader( const char *name ) void CL_WriteDemoHeader( const char *name )
{ {
long copysize; int copysize;
long savepos; int savepos;
long curpos; int curpos;
Con_Printf( "recording to %s.\n", name ); Con_Printf( "recording to %s.\n", name );
cls.demofile = FS_Open( name, "wb", false ); cls.demofile = FS_Open( name, "wb", false );
@ -489,7 +489,7 @@ void CL_DrawDemoRecording( void )
{ {
char string[64]; char string[64];
rgba_t color = { 255, 255, 255, 255 }; rgba_t color = { 255, 255, 255, 255 };
long pos; int pos;
int len; int len;
if(!( host_developer.value && cls.demorecording )) if(!( host_developer.value && cls.demorecording ))

View File

@ -376,7 +376,7 @@ pfnPIC_Load
========= =========
*/ */
static HIMAGE pfnPIC_Load( const char *szPicName, const byte *image_buf, long image_size, long flags ) static HIMAGE pfnPIC_Load( const char *szPicName, const byte *image_buf, int image_size, int flags )
{ {
HIMAGE tx; HIMAGE tx;

View File

@ -78,7 +78,9 @@ byte *CL_CreateRawTextureFromPixels( texture_t *tx, size_t *size, int topcolor,
// fill header // fill header
if( !pin.name[0] ) Q_strncpy( pin.name, "#raw_remap_image.mdl", sizeof( pin.name )); if( !pin.name[0] ) Q_strncpy( pin.name, "#raw_remap_image.mdl", sizeof( pin.name ));
pin.flags = STUDIO_NF_COLORMAP; // just in case :-) pin.flags = STUDIO_NF_COLORMAP; // just in case :-)
pin.index = (int)(tx + 1); // pointer to pixels //pin.index = (int)(tx + 1); // pointer to pixels
// no more pointer-to-int-to-pointer casts
Image_SetMDLPointer( (byte*)((texture_t *)tx + 1) );
pin.width = tx->width; pin.width = tx->width;
pin.height = tx->height; pin.height = tx->height;
@ -102,7 +104,8 @@ void CL_DuplicateTexture( mstudiotexture_t *ptexture, int topcolor, int bottomco
gl_texture_t *glt; gl_texture_t *glt;
texture_t *tx = NULL; texture_t *tx = NULL;
char texname[128]; char texname[128];
int i, size, index; int i, index;
size_t size;
byte paletteBackup[768]; byte paletteBackup[768];
byte *raw, *pal; byte *raw, *pal;
@ -145,7 +148,8 @@ void CL_UpdateStudioTexture( mstudiotexture_t *ptexture, int topcolor, int botto
rgbdata_t *pic; rgbdata_t *pic;
texture_t *tx = NULL; texture_t *tx = NULL;
char texname[128], name[128], mdlname[128]; char texname[128], name[128], mdlname[128];
int i, size, index; int i, index;
size_t size;
byte paletteBackup[768]; byte paletteBackup[768];
byte *raw, *pal; byte *raw, *pal;
@ -430,4 +434,4 @@ void CL_ClearAllRemaps( void )
Mem_Free( clgame.remap_info ); Mem_Free( clgame.remap_info );
} }
clgame.remap_info = NULL; clgame.remap_info = NULL;
} }

View File

@ -242,7 +242,7 @@ qboolean SCR_PlayCinematic( const char *arg )
return true; return true;
} }
long SCR_GetAudioChunk( char *rawdata, long length ) int SCR_GetAudioChunk( char *rawdata, int length )
{ {
int r; int r;
@ -307,4 +307,4 @@ void SCR_FreeCinematic( void )
AVI_CloseVideo( cin_state ); AVI_CloseVideo( cin_state );
AVI_Shutdown(); AVI_Shutdown();
} }

View File

@ -548,8 +548,8 @@ typedef struct
ui_globalvars_t *globals; ui_globalvars_t *globals;
qboolean drawLogo; // set to TRUE if logo.avi missed or corrupted qboolean drawLogo; // set to TRUE if logo.avi missed or corrupted
long logo_xres; int logo_xres;
long logo_yres; int logo_yres;
float logo_length; float logo_length;
qboolean use_text_api; qboolean use_text_api;
@ -1058,7 +1058,7 @@ void Con_LoadHistory( void );
// //
void S_StreamRawSamples( int samples, int rate, int width, int channels, const byte *data ); void S_StreamRawSamples( int samples, int rate, int width, int channels, const byte *data );
void S_StreamAviSamples( void *Avi, int entnum, float fvol, float attn, float synctime ); void S_StreamAviSamples( void *Avi, int entnum, float fvol, float attn, float synctime );
void S_StartBackgroundTrack( const char *intro, const char *loop, long position, qboolean fullpath ); void S_StartBackgroundTrack( const char *intro, const char *loop, int position, qboolean fullpath );
void S_StopBackgroundTrack( void ); void S_StopBackgroundTrack( void );
void S_StreamSetPause( int pause ); void S_StreamSetPause( int pause );
void S_StartStreaming( void ); void S_StartStreaming( void );

View File

@ -3560,7 +3560,8 @@ static void R_StudioLoadTexture( model_t *mod, studiohdr_t *phdr, mstudiotexture
SetBits( flags, TF_NOMIPMAP ); SetBits( flags, TF_NOMIPMAP );
// NOTE: replace index with pointer to start of imagebuffer, ImageLib expected it // NOTE: replace index with pointer to start of imagebuffer, ImageLib expected it
ptexture->index = (int)((byte *)phdr) + ptexture->index; //ptexture->index = (int)((byte *)phdr) + ptexture->index;
Image_SetMDLPointer((byte *)phdr + ptexture->index);
size = sizeof( mstudiotexture_t ) + ptexture->width * ptexture->height + 768; size = sizeof( mstudiotexture_t ) + ptexture->width * ptexture->height + 768;
if( FBitSet( host.features, ENGINE_LOAD_DELUXEDATA ) && FBitSet( ptexture->flags, STUDIO_NF_MASKED )) if( FBitSet( host.features, ENGINE_LOAD_DELUXEDATA ) && FBitSet( ptexture->flags, STUDIO_NF_MASKED ))

View File

@ -733,7 +733,7 @@ void R_DrawWorldHull( void )
list_for_each_entry( poly, &hull->polys, chain ) list_for_each_entry( poly, &hull->polys, chain )
{ {
srand((unsigned long)poly); srand((unsigned int)poly);
pglColor3f( rand() % 256 / 255.0, rand() % 256 / 255.0, rand() % 256 / 255.0 ); pglColor3f( rand() % 256 / 255.0, rand() % 256 / 255.0, rand() % 256 / 255.0 );
pglBegin( GL_POLYGON ); pglBegin( GL_POLYGON );
for( i = 0; i < poly->numpoints; i++ ) for( i = 0; i < poly->numpoints; i++ )
@ -766,7 +766,7 @@ void R_DrawModelHull( void )
pglDisable( GL_TEXTURE_2D ); pglDisable( GL_TEXTURE_2D );
list_for_each_entry( poly, &hull->polys, chain ) list_for_each_entry( poly, &hull->polys, chain )
{ {
srand((unsigned long)poly); srand((unsigned int)poly);
pglColor3f( rand() % 256 / 255.0, rand() % 256 / 255.0, rand() % 256 / 255.0 ); pglColor3f( rand() % 256 / 255.0, rand() % 256 / 255.0, rand() % 256 / 255.0 );
pglBegin( GL_POLYGON ); pglBegin( GL_POLYGON );
for( i = 0; i < poly->numpoints; i++ ) for( i = 0; i < poly->numpoints; i++ )
@ -775,4 +775,4 @@ void R_DrawModelHull( void )
} }
pglEnable( GL_TEXTURE_2D ); pglEnable( GL_TEXTURE_2D );
pglDisable( GL_POLYGON_OFFSET_FILL ); pglDisable( GL_POLYGON_OFFSET_FILL );
} }

View File

@ -71,7 +71,7 @@ float S_GetMusicVolume( void )
S_StartBackgroundTrack S_StartBackgroundTrack
================= =================
*/ */
void S_StartBackgroundTrack( const char *introTrack, const char *mainTrack, long position, qboolean fullpath ) void S_StartBackgroundTrack( const char *introTrack, const char *mainTrack, int position, qboolean fullpath )
{ {
S_StopBackgroundTrack(); S_StopBackgroundTrack();
@ -341,4 +341,4 @@ void S_StreamSoundTrack( void )
} }
else break; // no more samples for this frame else break; // no more samples for this frame
} }
} }

View File

@ -606,7 +606,7 @@ void VOX_ReadSentenceFile( const char *psentenceFileName )
{ {
char c, *pch, *pFileData; char c, *pch, *pFileData;
char *pchlast, *pSentenceData; char *pchlast, *pSentenceData;
int fileSize; size_t fileSize;
// load file // load file
pFileData = (char *)FS_LoadFile( psentenceFileName, &fileSize, false ); pFileData = (char *)FS_LoadFile( psentenceFileName, &fileSize, false );
@ -684,4 +684,4 @@ void VOX_Init( void )
void VOX_Shutdown( void ) void VOX_Shutdown( void )
{ {
g_numSentences = 0; g_numSentences = 0;
} }

View File

@ -325,16 +325,18 @@ void CL_TextMessageParse( byte *pMemFile, int fileSize )
// copy Name heap // copy Name heap
pNameHeap = ((char *)clgame.titles) + messageSize; pNameHeap = ((char *)clgame.titles) + messageSize;
memcpy( pNameHeap, nameHeap, nameHeapSize ); memcpy( pNameHeap, nameHeap, nameHeapSize );
nameOffset = pNameHeap - clgame.titles[0].pName; //nameOffset = pNameHeap - clgame.titles[0].pName; //undefined on amd64
// copy text & fixup pointers // copy text & fixup pointers
pCurrentText = pNameHeap + nameHeapSize; pCurrentText = pNameHeap + nameHeapSize;
for( i = 0; i < messageCount; i++ ) for( i = 0; i < messageCount; i++ )
{ {
clgame.titles[i].pName += nameOffset; // adjust name pointer (parallel buffer) clgame.titles[i].pName = pNameHeap; // adjust name pointer (parallel buffer)
Q_strcpy( pCurrentText, clgame.titles[i].pMessage ); // copy text over Q_strcpy( pCurrentText, clgame.titles[i].pMessage ); // copy text over
clgame.titles[i].pMessage = pCurrentText; clgame.titles[i].pMessage = pCurrentText;
pNameHeap += Q_strlen( pNameHeap ) + 1;
pCurrentText += Q_strlen( pCurrentText ) + 1; pCurrentText += Q_strlen( pCurrentText ) + 1;
} }
@ -342,4 +344,4 @@ void CL_TextMessageParse( byte *pMemFile, int fileSize )
Con_DPrintf( S_ERROR "TextMessage: overflow text message buffer!\n" ); Con_DPrintf( S_ERROR "TextMessage: overflow text message buffer!\n" );
clgame.numTitles = messageCount; clgame.numTitles = messageCount;
} }

View File

@ -45,7 +45,7 @@ void DBG_AssertFunction( qboolean fExpr, const char* szExpr, const char* szFile,
} }
#endif // DEBUG #endif // DEBUG
static long idum = 0; static int idum = 0;
#define MAX_RANDOM_RANGE 0x7FFFFFFFUL #define MAX_RANDOM_RANGE 0x7FFFFFFFUL
#define IA 16807 #define IA 16807
@ -58,12 +58,12 @@ static long idum = 0;
#define AM (1.0 / IM) #define AM (1.0 / IM)
#define RNMX (1.0 - EPS) #define RNMX (1.0 - EPS)
static long lran1( void ) static int lran1( void )
{ {
static long iy = 0; static int iy = 0;
static long iv[NTAB]; static int iv[NTAB];
int j; int j;
long k; int k;
if( idum <= 0 || !iy ) if( idum <= 0 || !iy )
{ {
@ -100,7 +100,7 @@ static float fran1( void )
return temp; return temp;
} }
void COM_SetRandomSeed( long lSeed ) void COM_SetRandomSeed( int lSeed )
{ {
if( lSeed ) idum = lSeed; if( lSeed ) idum = lSeed;
else idum = -time( NULL ); else idum = -time( NULL );
@ -1009,7 +1009,7 @@ byte* COM_LoadFileForMe( const char *filename, int *pLength )
{ {
string name; string name;
byte *file, *pfile; byte *file, *pfile;
long iLength; size_t iLength;
if( !COM_CheckString( filename )) if( !COM_CheckString( filename ))
{ {
@ -1052,11 +1052,11 @@ byte *COM_LoadFile( const char *filename, int usehunk, int *pLength )
/* /*
============= =============
COM_LoadFile COM_SaveFile
============= =============
*/ */
int COM_SaveFile( const char *filename, const void *data, long len ) int COM_SaveFile( const char *filename, const void *data, int len )
{ {
// check for empty filename // check for empty filename
if( !COM_CheckString( filename )) if( !COM_CheckString( filename ))
@ -1222,8 +1222,8 @@ int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCom
if( filename1 && filename2 ) if( filename1 && filename2 )
{ {
long ft1 = FS_FileTime( filename1, false ); int ft1 = FS_FileTime( filename1, false );
long ft2 = FS_FileTime( filename2, false ); int ft2 = FS_FileTime( filename2, false );
// one of files is missing // one of files is missing
if( ft1 == -1 || ft2 == -1 ) if( ft1 == -1 || ft2 == -1 )

View File

@ -545,9 +545,9 @@ const char *FS_GetDiskPath( const char *name, qboolean gamedironly );
const char *COM_FileWithoutPath( const char *in ); const char *COM_FileWithoutPath( const char *in );
byte *W_LoadLump( wfile_t *wad, const char *lumpname, size_t *lumpsizeptr, const char type ); byte *W_LoadLump( wfile_t *wad, const char *lumpname, size_t *lumpsizeptr, const char type );
void W_Close( wfile_t *wad ); void W_Close( wfile_t *wad );
byte *FS_LoadFile( const char *path, long *filesizeptr, qboolean gamedironly ); byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly );
byte *FS_LoadDirectFile( const char *path, long *filesizeptr ); byte *FS_LoadDirectFile( const char *path, fs_offset_t *filesizeptr );
qboolean FS_WriteFile( const char *filename, const void *data, long len ); qboolean FS_WriteFile( const char *filename, const void *data, fs_offset_t len );
qboolean COM_ParseVector( char **pfile, float *v, size_t size ); qboolean COM_ParseVector( char **pfile, float *v, size_t size );
void COM_NormalizeAngles( vec3_t angles ); void COM_NormalizeAngles( vec3_t angles );
int COM_FileSize( const char *filename ); int COM_FileSize( const char *filename );
@ -557,14 +557,14 @@ int COM_CheckString( const char *string );
int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare ); int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare );
search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly ); search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly );
file_t *FS_Open( const char *filepath, const char *mode, qboolean gamedironly ); file_t *FS_Open( const char *filepath, const char *mode, qboolean gamedironly );
long FS_Write( file_t *file, const void *data, size_t datasize ); fs_offset_t FS_Write( file_t *file, const void *data, size_t datasize );
long FS_Read( file_t *file, void *buffer, size_t buffersize ); fs_offset_t FS_Read( file_t *file, void *buffer, size_t buffersize );
int FS_VPrintf( file_t *file, const char *format, va_list ap ); int FS_VPrintf( file_t *file, const char *format, va_list ap );
int FS_Seek( file_t *file, long offset, int whence ); int FS_Seek( file_t *file, fs_offset_t offset, int whence );
int FS_Gets( file_t *file, byte *string, size_t bufsize ); int FS_Gets( file_t *file, byte *string, size_t bufsize );
int FS_Printf( file_t *file, const char *format, ... ) _format( 2 ); int FS_Printf( file_t *file, const char *format, ... ) _format( 2 );
long FS_FileSize( const char *filename, qboolean gamedironly ); fs_offset_t FS_FileSize( const char *filename, qboolean gamedironly );
long FS_FileTime( const char *filename, qboolean gamedironly ); int FS_FileTime( const char *filename, qboolean gamedironly );
int FS_Print( file_t *file, const char *msg ); int FS_Print( file_t *file, const char *msg );
qboolean FS_Rename( const char *oldname, const char *newname ); qboolean FS_Rename( const char *oldname, const char *newname );
int FS_FileExists( const char *filename, int gamedironly ); int FS_FileExists( const char *filename, int gamedironly );
@ -573,11 +573,11 @@ qboolean FS_FileCopy( file_t *pOutput, file_t *pInput, int fileSize );
qboolean FS_Delete( const char *path ); qboolean FS_Delete( const char *path );
int FS_UnGetc( file_t *file, byte c ); int FS_UnGetc( file_t *file, byte c );
void COM_StripExtension( char *path ); void COM_StripExtension( char *path );
long FS_Tell( file_t *file ); fs_offset_t FS_Tell( file_t *file );
qboolean FS_Eof( file_t *file ); qboolean FS_Eof( file_t *file );
int FS_Close( file_t *file ); int FS_Close( file_t *file );
int FS_Getc( file_t *file ); int FS_Getc( file_t *file );
long FS_FileLength( file_t *f ); fs_offset_t FS_FileLength( file_t *f );
/* /*
======================================================================== ========================================================================
@ -704,6 +704,7 @@ void Image_PaletteTranslate( byte *palSrc, int top, int bottom, int pal_size );
void Image_SetForceFlags( uint flags ); // set image force flags on loading void Image_SetForceFlags( uint flags ); // set image force flags on loading
size_t Image_DXTGetLinearSize( int type, int width, int height, int depth ); size_t Image_DXTGetLinearSize( int type, int width, int height, int depth );
void Image_ClearForceFlags( void ); void Image_ClearForceFlags( void );
void Image_SetMDLPointer( byte *p );
/* /*
======================================================================== ========================================================================
@ -763,9 +764,9 @@ wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size )
void FS_FreeSound( wavdata_t *pack ); void FS_FreeSound( wavdata_t *pack );
stream_t *FS_OpenStream( const char *filename ); stream_t *FS_OpenStream( const char *filename );
wavdata_t *FS_StreamInfo( stream_t *stream ); wavdata_t *FS_StreamInfo( stream_t *stream );
long FS_ReadStream( stream_t *stream, int bytes, void *buffer ); int FS_ReadStream( stream_t *stream, int bytes, void *buffer );
long FS_SetStreamPos( stream_t *stream, long newpos ); int FS_SetStreamPos( stream_t *stream, int newpos );
long FS_GetStreamPos( stream_t *stream ); int FS_GetStreamPos( stream_t *stream );
void FS_FreeStream( stream_t *stream ); void FS_FreeStream( stream_t *stream );
qboolean Sound_Process( wavdata_t **wav, int rate, int width, uint flags ); qboolean Sound_Process( wavdata_t **wav, int rate, int width, uint flags );
uint Sound_GetApproxWavePlayLen( const char *filepath ); uint Sound_GetApproxWavePlayLen( const char *filepath );
@ -784,7 +785,7 @@ const char *Q_buildcommit( void );
// //
qboolean Host_IsQuakeCompatible( void ); qboolean Host_IsQuakeCompatible( void );
void EXPORT Host_Shutdown( void ); void EXPORT Host_Shutdown( void );
int Host_CompareFileTime( long ft1, long ft2 ); int Host_CompareFileTime( int ft1, int ft2 );
void Host_NewInstance( const char *name, const char *finalmsg ); void Host_NewInstance( const char *name, const char *finalmsg );
void Host_EndGame( qboolean abort, const char *message, ... ) _format( 2 ); void Host_EndGame( qboolean abort, const char *message, ... ) _format( 2 );
void Host_AbortCurrentFrame( void ); void Host_AbortCurrentFrame( void );
@ -842,7 +843,7 @@ cvar_t *pfnCvar_RegisterClientVariable( const char *szName, const char *szValue,
cvar_t *pfnCvar_RegisterGameUIVariable( const char *szName, const char *szValue, int flags ); cvar_t *pfnCvar_RegisterGameUIVariable( const char *szName, const char *szValue, int flags );
char *COM_MemFgets( byte *pMemFile, int fileSize, int *filePos, char *pBuffer, int bufferSize ); char *COM_MemFgets( byte *pMemFile, int fileSize, int *filePos, char *pBuffer, int bufferSize );
void COM_HexConvert( const char *pszInput, int nInputLength, byte *pOutput ); void COM_HexConvert( const char *pszInput, int nInputLength, byte *pOutput );
int COM_SaveFile( const char *filename, const void *data, long len ); int COM_SaveFile( const char *filename, const void *data, int len );
byte* COM_LoadFileForMe( const char *filename, int *pLength ); byte* COM_LoadFileForMe( const char *filename, int *pLength );
qboolean COM_IsSafeFileToDownload( const char *filename ); qboolean COM_IsSafeFileToDownload( const char *filename );
cvar_t *pfnCVarGetPointer( const char *szVarName ); cvar_t *pfnCVarGetPointer( const char *szVarName );
@ -986,7 +987,7 @@ struct cmdalias_s *Cmd_AliasGetList( void );
char *Cmd_GetName( struct cmd_s *cmd ); char *Cmd_GetName( struct cmd_s *cmd );
struct pmtrace_s *PM_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe ); struct pmtrace_s *PM_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe );
void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch ); void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch );
void SV_StartMusic( const char *curtrack, const char *looptrack, long position ); void SV_StartMusic( const char *curtrack, const char *looptrack, int position );
void SV_CreateDecal( sizebuf_t *msg, const float *origin, int decalIndex, int entityIndex, int modelIndex, int flags, float scale ); void SV_CreateDecal( sizebuf_t *msg, const float *origin, int decalIndex, int entityIndex, int modelIndex, int flags, float scale );
void Log_Printf( const char *fmt, ... ) _format( 1 ); void Log_Printf( const char *fmt, ... ) _format( 1 );
struct sizebuf_s *SV_GetReliableDatagram( void ); struct sizebuf_s *SV_GetReliableDatagram( void );
@ -1043,7 +1044,7 @@ void SCR_Init( void );
void SCR_UpdateScreen( void ); void SCR_UpdateScreen( void );
void SCR_BeginLoadingPlaque( qboolean is_background ); void SCR_BeginLoadingPlaque( qboolean is_background );
void SCR_CheckStartupVids( void ); void SCR_CheckStartupVids( void );
long SCR_GetAudioChunk( char *rawdata, long length ); int SCR_GetAudioChunk( char *rawdata, int length );
wavdata_t *SCR_GetMovieInfo( void ); wavdata_t *SCR_GetMovieInfo( void );
void SCR_Shutdown( void ); void SCR_Shutdown( void );
void Con_Print( const char *txt ); void Con_Print( const char *txt );
@ -1061,7 +1062,7 @@ void Info_WriteVars( file_t *f );
void Info_Print( const char *s ); void Info_Print( const char *s );
void Cmd_WriteVariables( file_t *f ); void Cmd_WriteVariables( file_t *f );
int Cmd_CheckMapsList( int fRefresh ); int Cmd_CheckMapsList( int fRefresh );
void COM_SetRandomSeed( long lSeed ); void COM_SetRandomSeed( int lSeed );
int COM_RandomLong( int lMin, int lMax ); int COM_RandomLong( int lMin, int lMax );
float COM_RandomFloat( float fMin, float fMax ); float COM_RandomFloat( float fMin, float fMax );
qboolean LZSS_IsCompressed( const byte *source ); qboolean LZSS_IsCompressed( const byte *source );

View File

@ -63,7 +63,7 @@ void COM_ClearCustomizationList( customization_t *pHead, qboolean bCleanDecals )
qboolean COM_CreateCustomization( customization_t *pListHead, resource_t *pResource, int playernumber, int flags, customization_t **pOut, int *nLumps ) qboolean COM_CreateCustomization( customization_t *pListHead, resource_t *pResource, int playernumber, int flags, customization_t **pOut, int *nLumps )
{ {
qboolean bError = false; qboolean bError = false;
long checksize = 0; size_t checksize = 0;
customization_t *pCust; customization_t *pCust;
if( pOut ) *pOut = NULL; if( pOut ) *pOut = NULL;

View File

@ -68,13 +68,13 @@ typedef struct wadtype_s
typedef struct file_s typedef struct file_s
{ {
int handle; // file descriptor int handle; // file descriptor
long real_length; // uncompressed file size (for files opened in "read" mode) fs_offset_t real_length; // uncompressed file size (for files opened in "read" mode)
long position; // current position in the file fs_offset_t position; // current position in the file
long offset; // offset into the package (0 if external file) fs_offset_t offset; // offset into the package (0 if external file)
int ungetc; // single stored character from ungetc, cleared to EOF when read int ungetc; // single stored character from ungetc, cleared to EOF when read
time_t filetime; // pak, wad or real filetime time_t filetime; // pak, wad or real filetime
// contents buffer // contents buffer
long buff_ind, buff_len; // buffer current index and length fs_offset_t buff_ind, buff_len; // buffer current index and length
byte buff[FILE_BUFF_SIZE]; // intermediate buffer byte buff[FILE_BUFF_SIZE]; // intermediate buffer
} file_t; } file_t;
@ -123,11 +123,11 @@ qboolean fs_caseinsensitive = true; // try to search missing files
static void FS_InitMemory( void ); static void FS_InitMemory( void );
static searchpath_t *FS_FindFile( const char *name, int *index, qboolean gamedironly ); static searchpath_t *FS_FindFile( const char *name, int *index, qboolean gamedironly );
static dlumpinfo_t *W_FindLump( wfile_t *wad, const char *name, const char matchtype ); static dlumpinfo_t *W_FindLump( wfile_t *wad, const char *name, const char matchtype );
static dpackfile_t *FS_AddFileToPack( const char* name, pack_t *pack, long offset, long size ); static dpackfile_t *FS_AddFileToPack( const char* name, pack_t *pack, fs_offset_t offset, fs_offset_t size );
static byte *W_LoadFile( const char *path, long *filesizeptr, qboolean gamedironly ); static byte *W_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly );
static wfile_t *W_Open( const char *filename, int *errorcode ); static wfile_t *W_Open( const char *filename, int *errorcode );
static qboolean FS_SysFolderExists( const char *path ); static qboolean FS_SysFolderExists( const char *path );
static long FS_SysFileTime( const char *filename ); static int FS_SysFileTime( const char *filename );
static char W_TypeFromExt( const char *lumpname ); static char W_TypeFromExt( const char *lumpname );
static const char *W_ExtFromType( char lumptype ); static const char *W_ExtFromType( char lumptype );
static void FS_Purge( file_t* file ); static void FS_Purge( file_t* file );
@ -389,7 +389,7 @@ FS_AddFileToPack
Add a file to the list of files contained into a package Add a file to the list of files contained into a package
==================== ====================
*/ */
static dpackfile_t *FS_AddFileToPack( const char *name, pack_t *pack, long offset, long size ) static dpackfile_t *FS_AddFileToPack( const char *name, pack_t *pack, fs_offset_t offset, fs_offset_t size )
{ {
int left, right, middle; int left, right, middle;
dpackfile_t *pfile; dpackfile_t *pfile;
@ -1705,7 +1705,7 @@ FS_SysFileTime
Internal function used to determine filetime Internal function used to determine filetime
==================== ====================
*/ */
static long FS_SysFileTime( const char *filename ) static int FS_SysFileTime( const char *filename )
{ {
struct stat buf; struct stat buf;
@ -2154,9 +2154,9 @@ FS_Write
Write "datasize" bytes into a file Write "datasize" bytes into a file
==================== ====================
*/ */
long FS_Write( file_t *file, const void *data, size_t datasize ) fs_offset_t FS_Write( file_t *file, const void *data, size_t datasize )
{ {
long result; fs_offset_t result;
if( !file ) return 0; if( !file ) return 0;
@ -2168,7 +2168,7 @@ long FS_Write( file_t *file, const void *data, size_t datasize )
FS_Purge( file ); FS_Purge( file );
// write the buffer and update the position // write the buffer and update the position
result = write( file->handle, data, (long)datasize ); result = write( file->handle, data, (fs_offset_t)datasize );
file->position = lseek( file->handle, 0, SEEK_CUR ); file->position = lseek( file->handle, 0, SEEK_CUR );
if( file->real_length < file->position ) if( file->real_length < file->position )
@ -2186,10 +2186,10 @@ FS_Read
Read up to "buffersize" bytes from a file Read up to "buffersize" bytes from a file
==================== ====================
*/ */
long FS_Read( file_t *file, void *buffer, size_t buffersize ) fs_offset_t FS_Read( file_t *file, void *buffer, size_t buffersize )
{ {
long count, done; fs_offset_t count, done;
long nb; fs_offset_t nb;
// nothing to copy // nothing to copy
if( buffersize == 0 ) return 1; if( buffersize == 0 ) return 1;
@ -2209,7 +2209,7 @@ long FS_Read( file_t *file, void *buffer, size_t buffersize )
{ {
count = file->buff_len - file->buff_ind; count = file->buff_len - file->buff_ind;
done += ((long)buffersize > count ) ? count : (long)buffersize; done += ((fs_offset_t)buffersize > count ) ? count : (fs_offset_t)buffersize;
memcpy( buffer, &file->buff[file->buff_ind], done ); memcpy( buffer, &file->buff[file->buff_ind], done );
file->buff_ind += done; file->buff_ind += done;
@ -2226,8 +2226,8 @@ long FS_Read( file_t *file, void *buffer, size_t buffersize )
// if we have a lot of data to get, put them directly into "buffer" // if we have a lot of data to get, put them directly into "buffer"
if( buffersize > sizeof( file->buff ) / 2 ) if( buffersize > sizeof( file->buff ) / 2 )
{ {
if( count > (long)buffersize ) if( count > (fs_offset_t)buffersize )
count = (long)buffersize; count = (fs_offset_t)buffersize;
lseek( file->handle, file->offset + file->position, SEEK_SET ); lseek( file->handle, file->offset + file->position, SEEK_SET );
nb = read (file->handle, &((byte *)buffer)[done], count ); nb = read (file->handle, &((byte *)buffer)[done], count );
@ -2241,8 +2241,8 @@ long FS_Read( file_t *file, void *buffer, size_t buffersize )
} }
else else
{ {
if( count > (long)sizeof( file->buff )) if( count > (fs_offset_t)sizeof( file->buff ))
count = (long)sizeof( file->buff ); count = (fs_offset_t)sizeof( file->buff );
lseek( file->handle, file->offset + file->position, SEEK_SET ); lseek( file->handle, file->offset + file->position, SEEK_SET );
nb = read( file->handle, file->buff, count ); nb = read( file->handle, file->buff, count );
@ -2252,7 +2252,7 @@ long FS_Read( file_t *file, void *buffer, size_t buffersize )
file->position += nb; file->position += nb;
// copy the requested data in "buffer" (as much as we can) // copy the requested data in "buffer" (as much as we can)
count = (long)buffersize > file->buff_len ? file->buff_len : (long)buffersize; count = (fs_offset_t)buffersize > file->buff_len ? file->buff_len : (fs_offset_t)buffersize;
memcpy( &((byte *)buffer)[done], file->buff, count ); memcpy( &((byte *)buffer)[done], file->buff, count );
file->buff_ind = count; file->buff_ind = count;
done += count; done += count;
@ -2303,7 +2303,7 @@ Print a string into a file
int FS_VPrintf( file_t *file, const char *format, va_list ap ) int FS_VPrintf( file_t *file, const char *format, va_list ap )
{ {
int len; int len;
long buff_size = MAX_SYSPATH; fs_offset_t buff_size = MAX_SYSPATH;
char *tempbuff; char *tempbuff;
if( !file ) return 0; if( !file ) return 0;
@ -2402,7 +2402,7 @@ FS_Seek
Move the position index in a file Move the position index in a file
==================== ====================
*/ */
int FS_Seek( file_t *file, long offset, int whence ) int FS_Seek( file_t *file, fs_offset_t offset, int whence )
{ {
// compute the file offset // compute the file offset
switch( whence ) switch( whence )
@ -2446,7 +2446,7 @@ FS_Tell
Give the current position in a file Give the current position in a file
==================== ====================
*/ */
long FS_Tell( file_t *file ) fs_offset_t FS_Tell( file_t *file )
{ {
if( !file ) return 0; if( !file ) return 0;
return file->position - file->buff_len + file->buff_ind; return file->position - file->buff_len + file->buff_ind;
@ -2487,11 +2487,11 @@ Filename are relative to the xash directory.
Always appends a 0 byte. Always appends a 0 byte.
============ ============
*/ */
byte *FS_LoadFile( const char *path, long *filesizeptr, qboolean gamedironly ) byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly )
{ {
file_t *file; file_t *file;
byte *buf = NULL; byte *buf = NULL;
long filesize = 0; fs_offset_t filesize = 0;
file = FS_Open( path, "rb", gamedironly ); file = FS_Open( path, "rb", gamedironly );
@ -2522,11 +2522,11 @@ Filename are relative to the xash directory.
Always appends a 0 byte. Always appends a 0 byte.
============ ============
*/ */
byte *FS_LoadDirectFile( const char *path, long *filesizeptr ) byte *FS_LoadDirectFile( const char *path, fs_offset_t *filesizeptr )
{ {
file_t *file; file_t *file;
byte *buf = NULL; byte *buf = NULL;
long filesize = 0; fs_offset_t filesize = 0;
file = FS_SysOpen( path, "rb" ); file = FS_SysOpen( path, "rb" );
@ -2556,7 +2556,7 @@ FS_WriteFile
The filename will be prefixed by the current game directory The filename will be prefixed by the current game directory
============ ============
*/ */
qboolean FS_WriteFile( const char *filename, const void *data, long len ) qboolean FS_WriteFile( const char *filename, const void *data, fs_offset_t len )
{ {
file_t *file; file_t *file;
@ -2724,7 +2724,7 @@ FS_FileSize
return size of file in bytes return size of file in bytes
================== ==================
*/ */
long FS_FileSize( const char *filename, qboolean gamedironly ) fs_offset_t FS_FileSize( const char *filename, qboolean gamedironly )
{ {
int length = -1; // in case file was missed int length = -1; // in case file was missed
file_t *fp; file_t *fp;
@ -2749,7 +2749,7 @@ FS_FileLength
return size of file in bytes return size of file in bytes
================== ==================
*/ */
long FS_FileLength( file_t *f ) fs_offset_t FS_FileLength( file_t *f )
{ {
if( !f ) return 0; if( !f ) return 0;
return f->real_length; return f->real_length;
@ -2762,7 +2762,7 @@ FS_FileTime
return time of creation file in seconds return time of creation file in seconds
================== ==================
*/ */
long FS_FileTime( const char *filename, qboolean gamedironly ) int FS_FileTime( const char *filename, qboolean gamedironly )
{ {
searchpath_t *search; searchpath_t *search;
int pack_ind; int pack_ind;
@ -3253,7 +3253,7 @@ W_ReadLump
reading lump into temp buffer reading lump into temp buffer
=========== ===========
*/ */
byte *W_ReadLump( wfile_t *wad, dlumpinfo_t *lump, long *lumpsizeptr ) byte *W_ReadLump( wfile_t *wad, dlumpinfo_t *lump, fs_offset_t *lumpsizeptr )
{ {
size_t oldpos, size = 0; size_t oldpos, size = 0;
byte *buf; byte *buf;
@ -3454,7 +3454,7 @@ W_LoadFile
loading lump into the tmp buffer loading lump into the tmp buffer
=========== ===========
*/ */
static byte *W_LoadFile( const char *path, long *lumpsizeptr, qboolean gamedironly ) static byte *W_LoadFile( const char *path, fs_offset_t *lumpsizeptr, qboolean gamedironly )
{ {
searchpath_t *search; searchpath_t *search;
int index; int index;

View File

@ -57,7 +57,7 @@ convar_t *host_framerate;
convar_t *con_gamemaps; convar_t *con_gamemaps;
convar_t *build, *ver; convar_t *build, *ver;
int Host_CompareFileTime( long ft1, long ft2 ) int Host_CompareFileTime( int ft1, int ft2 )
{ {
if( ft1 < ft2 ) if( ft1 < ft2 )
{ {

View File

@ -48,20 +48,20 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, size_t filesize )
buf_p = (byte *)buffer; buf_p = (byte *)buffer;
bhdr.id[0] = *buf_p++; bhdr.id[0] = *buf_p++;
bhdr.id[1] = *buf_p++; // move pointer bhdr.id[1] = *buf_p++; // move pointer
bhdr.fileSize = *(long *)buf_p; buf_p += 4; bhdr.fileSize = *(int *)buf_p; buf_p += 4;
bhdr.reserved0 = *(long *)buf_p; buf_p += 4; bhdr.reserved0 = *(int *)buf_p; buf_p += 4;
bhdr.bitmapDataOffset = *(long *)buf_p; buf_p += 4; bhdr.bitmapDataOffset = *(int *)buf_p; buf_p += 4;
bhdr.bitmapHeaderSize = *(long *)buf_p; buf_p += 4; bhdr.bitmapHeaderSize = *(int *)buf_p; buf_p += 4;
bhdr.width = *(long *)buf_p; buf_p += 4; bhdr.width = *(int *)buf_p; buf_p += 4;
bhdr.height = *(long *)buf_p; buf_p += 4; bhdr.height = *(int *)buf_p; buf_p += 4;
bhdr.planes = *(short *)buf_p; buf_p += 2; bhdr.planes = *(short *)buf_p; buf_p += 2;
bhdr.bitsPerPixel = *(short *)buf_p; buf_p += 2; bhdr.bitsPerPixel = *(short *)buf_p; buf_p += 2;
bhdr.compression = *(long *)buf_p; buf_p += 4; bhdr.compression = *(int *)buf_p; buf_p += 4;
bhdr.bitmapDataSize = *(long *)buf_p; buf_p += 4; bhdr.bitmapDataSize = *(int *)buf_p; buf_p += 4;
bhdr.hRes = *(long *)buf_p; buf_p += 4; bhdr.hRes = *(int *)buf_p; buf_p += 4;
bhdr.vRes = *(long *)buf_p; buf_p += 4; bhdr.vRes = *(int *)buf_p; buf_p += 4;
bhdr.colors = *(long *)buf_p; buf_p += 4; bhdr.colors = *(int *)buf_p; buf_p += 4;
bhdr.importantColors = *(long *)buf_p; buf_p += 4; bhdr.importantColors = *(int *)buf_p; buf_p += 4;
// bogus file header check // bogus file header check
if( bhdr.reserved0 != 0 ) return false; if( bhdr.reserved0 != 0 ) return false;

View File

@ -213,7 +213,8 @@ rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size )
const char *ext = COM_FileExtension( filename ); const char *ext = COM_FileExtension( filename );
string path, loadname, sidename; string path, loadname, sidename;
qboolean anyformat = true; qboolean anyformat = true;
int i, filesize = 0; int i;
size_t filesize = 0;
const loadpixformat_t *format; const loadpixformat_t *format;
const cubepack_t *cmap; const cubepack_t *cmap;
byte *f; byte *f;
@ -488,4 +489,4 @@ rgbdata_t *FS_CopyImage( rgbdata_t *in )
} }
return out; return out;
} }

View File

@ -129,6 +129,19 @@ qboolean Image_LoadFNT( const char *name, const byte *buffer, size_t filesize )
return Image_AddIndexedImageToPack( fin, image.width, image.height ); return Image_AddIndexedImageToPack( fin, image.width, image.height );
} }
/*
======================
Image_SetMDLPointer
Transfer buffer pointer before Image_LoadMDL
======================
*/
static void *g_mdltexdata;
void Image_SetMDLPointer(byte *p)
{
g_mdltexdata = p;
}
/* /*
============ ============
Image_LoadMDL Image_LoadMDL
@ -147,7 +160,9 @@ qboolean Image_LoadMDL( const char *name, const byte *buffer, size_t filesize )
image.width = pin->width; image.width = pin->width;
image.height = pin->height; image.height = pin->height;
pixels = image.width * image.height; pixels = image.width * image.height;
fin = (byte *)pin->index; // setup buffer fin = (byte *)g_mdltexdata;
ASSERT(fin);
g_mdltexdata = NULL;
if( !Image_ValidSize( name )) if( !Image_ValidSize( name ))
return false; return false;
@ -496,4 +511,4 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, size_t filesize )
image.depth = 1; image.depth = 1;
return Image_AddIndexedImageToPack( fin, image.width, image.height ); return Image_AddIndexedImageToPack( fin, image.width, image.height );
} }

View File

@ -67,8 +67,8 @@ GNU General Public License for more details.
#define Q_min( a, b ) (((a) < (b)) ? (a) : (b)) #define Q_min( a, b ) (((a) < (b)) ? (a) : (b))
#define Q_max( a, b ) (((a) > (b)) ? (a) : (b)) #define Q_max( a, b ) (((a) > (b)) ? (a) : (b))
#define Q_recip( a ) ((float)(1.0f / (float)(a))) #define Q_recip( a ) ((float)(1.0f / (float)(a)))
#define Q_floor( a ) ((float)(long)(a)) #define Q_floor( a ) ((float)(int)(a))
#define Q_ceil( a ) ((float)(long)((a) + 1)) #define Q_ceil( a ) ((float)(int)((a) + 1))
#define Q_round( x, y ) (floor( x / y + 0.5 ) * y ) #define Q_round( x, y ) (floor( x / y + 0.5 ) * y )
#define Q_rint(x) ((x) < 0 ? ((int)((x)-0.5f)) : ((int)((x)+0.5f))) #define Q_rint(x) ((x) < 0 ? ((int)((x)-0.5f)) : ((int)((x)+0.5f)))
#define IS_NAN(x) (((*(int *)&x) & (255<<23)) == (255<<23)) #define IS_NAN(x) (((*(int *)&x) & (255<<23)) == (255<<23))
@ -199,4 +199,4 @@ extern const matrix3x4 matrix3x4_identity;
extern const matrix4x4 matrix4x4_identity; extern const matrix4x4 matrix4x4_identity;
extern const float m_bytenormals[NUMVERTEXNORMALS][3]; extern const float m_bytenormals[NUMVERTEXNORMALS][3];
#endif//MATHLIB_H #endif//MATHLIB_H

View File

@ -1528,7 +1528,7 @@ static void Mod_LoadEntities( dbspmodel_t *bmod )
if( bmod->isworld ) if( bmod->isworld )
{ {
char entfilename[MAX_QPATH]; char entfilename[MAX_QPATH];
long entpatchsize; int entpatchsize;
size_t ft1, ft2; size_t ft1, ft2;
// world is check for entfile too // world is check for entfile too

View File

@ -602,7 +602,7 @@ void *R_StudioGetAnim( studiohdr_t *m_pStudioHeader, model_t *m_pSubModel, mstud
pseqgroup = (mstudioseqgroup_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqgroupindex) + pseqdesc->seqgroup; pseqgroup = (mstudioseqgroup_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqgroupindex) + pseqdesc->seqgroup;
if( pseqdesc->seqgroup == 0 ) if( pseqdesc->seqgroup == 0 )
return ((byte *)m_pStudioHeader + pseqgroup->data + pseqdesc->animindex); return ((byte *)m_pStudioHeader + pseqdesc->animindex);
paSequences = (cache_user_t *)m_pSubModel->submodels; paSequences = (cache_user_t *)m_pSubModel->submodels;
@ -914,7 +914,7 @@ void Mod_StudioComputeBounds( void *buffer, vec3_t mins, vec3_t maxs, qboolean i
pseqgroup = (mstudioseqgroup_t *)((byte *)pstudiohdr + pstudiohdr->seqgroupindex) + pseqdesc->seqgroup; pseqgroup = (mstudioseqgroup_t *)((byte *)pstudiohdr + pstudiohdr->seqgroupindex) + pseqdesc->seqgroup;
if( pseqdesc->seqgroup == 0 ) if( pseqdesc->seqgroup == 0 )
panim = (mstudioanim_t *)((byte *)pstudiohdr + pseqgroup->data + pseqdesc->animindex); panim = (mstudioanim_t *)((byte *)pstudiohdr + pseqdesc->animindex);
else continue; else continue;
for( j = 0; j < pstudiohdr->numbones; j++ ) for( j = 0; j < pstudiohdr->numbones; j++ )

View File

@ -165,7 +165,7 @@ void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits )
dword iCurBitMasked; dword iCurBitMasked;
int nBitsWritten; int nBitsWritten;
Assert(( iDWord * 4 + sizeof( long )) <= (uint)MSG_GetMaxBytes( sb )); Assert(( iDWord * 4 + sizeof( int )) <= (uint)MSG_GetMaxBytes( sb ));
iCurBitMasked = iCurBit & 31; iCurBitMasked = iCurBit & 31;
((dword *)sb->pData)[iDWord] &= BitWriteMasks[iCurBitMasked][nBitsLeft]; ((dword *)sb->pData)[iDWord] &= BitWriteMasks[iCurBitMasked][nBitsLeft];
@ -304,12 +304,12 @@ void MSG_WriteVec3Angles( sizebuf_t *sb, const float *fa )
void MSG_WriteBitFloat( sizebuf_t *sb, float val ) void MSG_WriteBitFloat( sizebuf_t *sb, float val )
{ {
long intVal; int intVal;
Assert( sizeof( long ) == sizeof( float )); Assert( sizeof( int ) == sizeof( float ));
Assert( sizeof( float ) == 4 ); Assert( sizeof( float ) == 4 );
intVal = *((long *)&val ); intVal = *((int *)&val );
MSG_WriteUBitLong( sb, intVal, 32 ); MSG_WriteUBitLong( sb, intVal, 32 );
} }
@ -360,9 +360,9 @@ void MSG_WriteWord( sizebuf_t *sb, int val )
MSG_WriteUBitLong( sb, val, sizeof( word ) << 3 ); MSG_WriteUBitLong( sb, val, sizeof( word ) << 3 );
} }
void MSG_WriteLong( sizebuf_t *sb, long val ) void MSG_WriteLong( sizebuf_t *sb, int val )
{ {
MSG_WriteSBitLong( sb, val, sizeof( long ) << 3 ); MSG_WriteSBitLong( sb, val, sizeof( int ) << 3 );
} }
void MSG_WriteDword( sizebuf_t *sb, dword val ) void MSG_WriteDword( sizebuf_t *sb, dword val )
@ -456,10 +456,10 @@ uint MSG_ReadUBitLong( sizebuf_t *sb, int numbits )
float MSG_ReadBitFloat( sizebuf_t *sb ) float MSG_ReadBitFloat( sizebuf_t *sb )
{ {
long val; int val;
int bit, byte; int bit, byte;
Assert( sizeof( float ) == sizeof( long )); Assert( sizeof( float ) == sizeof( int ));
Assert( sizeof( float ) == 4 ); Assert( sizeof( float ) == 4 );
if( MSG_Overflow( sb, 32 )) if( MSG_Overflow( sb, 32 ))
@ -617,9 +617,9 @@ void MSG_ReadVec3Angles( sizebuf_t *sb, vec3_t fa )
} }
long MSG_ReadLong( sizebuf_t *sb ) int MSG_ReadLong( sizebuf_t *sb )
{ {
return MSG_ReadSBitLong( sb, sizeof( long ) << 3 ); return MSG_ReadSBitLong( sb, sizeof( int ) << 3 );
} }
dword MSG_ReadDword( sizebuf_t *sb ) dword MSG_ReadDword( sizebuf_t *sb )
@ -685,4 +685,4 @@ void MSG_ExciseBits( sizebuf_t *sb, int startbit, int bitstoremove )
MSG_SeekToBit( sb, startbit, SEEK_SET ); MSG_SeekToBit( sb, startbit, SEEK_SET );
sb->nDataBits -= bitstoremove; sb->nDataBits -= bitstoremove;
} }

View File

@ -86,7 +86,7 @@ void MSG_WriteChar( sizebuf_t *sb, int val );
void MSG_WriteByte( sizebuf_t *sb, int val ); void MSG_WriteByte( sizebuf_t *sb, int val );
void MSG_WriteShort( sizebuf_t *sb, int val ); void MSG_WriteShort( sizebuf_t *sb, int val );
void MSG_WriteWord( sizebuf_t *sb, int val ); void MSG_WriteWord( sizebuf_t *sb, int val );
void MSG_WriteLong( sizebuf_t *sb, long val ); void MSG_WriteLong( sizebuf_t *sb, int val );
void MSG_WriteDword( sizebuf_t *sb, dword val ); void MSG_WriteDword( sizebuf_t *sb, dword val );
void MSG_WriteCoord( sizebuf_t *sb, float val ); void MSG_WriteCoord( sizebuf_t *sb, float val );
void MSG_WriteFloat( sizebuf_t *sb, float val ); void MSG_WriteFloat( sizebuf_t *sb, float val );
@ -123,7 +123,7 @@ int MSG_ReadChar( sizebuf_t *sb );
int MSG_ReadByte( sizebuf_t *sb ); int MSG_ReadByte( sizebuf_t *sb );
int MSG_ReadShort( sizebuf_t *sb ); int MSG_ReadShort( sizebuf_t *sb );
int MSG_ReadWord( sizebuf_t *sb ); int MSG_ReadWord( sizebuf_t *sb );
long MSG_ReadLong( sizebuf_t *sb ); int MSG_ReadLong( sizebuf_t *sb );
dword MSG_ReadDword( sizebuf_t *sb ); dword MSG_ReadDword( sizebuf_t *sb );
float MSG_ReadCoord( sizebuf_t *sb ); float MSG_ReadCoord( sizebuf_t *sb );
float MSG_ReadFloat( sizebuf_t *sb ); float MSG_ReadFloat( sizebuf_t *sb );
@ -132,4 +132,4 @@ void MSG_ReadVec3Angles( sizebuf_t *sb, vec3_t fa );
qboolean MSG_ReadBytes( sizebuf_t *sb, void *pOut, int nBytes ); qboolean MSG_ReadBytes( sizebuf_t *sb, void *pOut, int nBytes );
char *MSG_ReadStringExt( sizebuf_t *sb, qboolean bLine ); char *MSG_ReadStringExt( sizebuf_t *sb, qboolean bLine );
#endif//NET_BUFFER_H #endif//NET_BUFFER_H

View File

@ -258,7 +258,7 @@ typedef struct
float fakelag; // cached fakelag value float fakelag; // cached fakelag value
LONGPACKET split; LONGPACKET split;
int split_flags[NET_MAX_FRAGMENTS]; int split_flags[NET_MAX_FRAGMENTS];
long sequence_number; int sequence_number;
int ip_sockets[NS_COUNT]; int ip_sockets[NS_COUNT];
qboolean initialized; qboolean initialized;
qboolean threads_initialized; qboolean threads_initialized;

View File

@ -30,7 +30,7 @@ GNU General Public License for more details.
#define svc_print 8 // [byte] id [string] null terminated string #define svc_print 8 // [byte] id [string] null terminated string
#define svc_stufftext 9 // [string] stuffed into client's console buffer #define svc_stufftext 9 // [string] stuffed into client's console buffer
#define svc_setangle 10 // [angle angle angle] set the view angle to this absolute value #define svc_setangle 10 // [angle angle angle] set the view angle to this absolute value
#define svc_serverdata 11 // [long] protocol ... #define svc_serverdata 11 // [int] protocol ...
#define svc_lightstyle 12 // [index][pattern][float] #define svc_lightstyle 12 // [index][pattern][float]
#define svc_updateuserinfo 13 // [byte] playernum, [string] userinfo #define svc_updateuserinfo 13 // [byte] playernum, [string] userinfo
#define svc_deltatable 14 // [table header][...] #define svc_deltatable 14 // [table header][...]
@ -77,7 +77,7 @@ GNU General Public License for more details.
// reserved // reserved
#define svc_resourcelocation 56 // [string] #define svc_resourcelocation 56 // [string]
#define svc_querycvarvalue 57 // [string] #define svc_querycvarvalue 57 // [string]
#define svc_querycvarvalue2 58 // [string][long] (context) #define svc_querycvarvalue2 58 // [string][int] (context)
#define svc_lastmsg 58 // start user messages at this point #define svc_lastmsg 58 // start user messages at this point
// client to server // client to server
@ -183,8 +183,8 @@ GNU General Public License for more details.
#define PROTOCOL_VERSION_QUAKE 15 #define PROTOCOL_VERSION_QUAKE 15
// listed only unmatched ops // listed only unmatched ops
#define svc_updatestat 3 // [byte] [long] (svc_event) #define svc_updatestat 3 // [byte] [int] (svc_event)
#define svc_version 4 // [long] server version (svc_changing) #define svc_version 4 // [int] server version (svc_changing)
#define svc_updatename 13 // [byte] [string] (svc_updateuserinfo) #define svc_updatename 13 // [byte] [string] (svc_updateuserinfo)
#define svc_updatefrags 14 // [byte] [short] (svc_deltatable) #define svc_updatefrags 14 // [byte] [short] (svc_deltatable)
#define svc_stopsound 16 // <see code> (svc_resource) #define svc_stopsound 16 // <see code> (svc_resource)
@ -243,4 +243,4 @@ GNU General Public License for more details.
extern const char *svc_strings[svc_lastmsg+1]; extern const char *svc_strings[svc_lastmsg+1];
extern const char *clc_strings[clc_lastmsg+1]; extern const char *clc_strings[clc_lastmsg+1];
#endif//NET_PROTOCOL_H #endif//NET_PROTOCOL_H

View File

@ -59,7 +59,7 @@ wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size )
const char *ext = COM_FileExtension( filename ); const char *ext = COM_FileExtension( filename );
string path, loadname; string path, loadname;
qboolean anyformat = true; qboolean anyformat = true;
int filesize = 0; size_t filesize = 0;
const loadwavfmt_t *format; const loadwavfmt_t *format;
byte *f; byte *f;
@ -223,7 +223,7 @@ FS_ReadStream
extract stream as wav-data and put into buffer, move file pointer extract stream as wav-data and put into buffer, move file pointer
================ ================
*/ */
long FS_ReadStream( stream_t *stream, int bytes, void *buffer ) int FS_ReadStream( stream_t *stream, int bytes, void *buffer )
{ {
if( !stream || !stream->format || !stream->format->readfunc ) if( !stream || !stream->format || !stream->format->readfunc )
return 0; return 0;
@ -241,7 +241,7 @@ FS_GetStreamPos
get stream position (in bytes) get stream position (in bytes)
================ ================
*/ */
long FS_GetStreamPos( stream_t *stream ) int FS_GetStreamPos( stream_t *stream )
{ {
if( !stream || !stream->format || !stream->format->getposfunc ) if( !stream || !stream->format || !stream->format->getposfunc )
return -1; return -1;
@ -256,7 +256,7 @@ FS_SetStreamPos
set stream position (in bytes) set stream position (in bytes)
================ ================
*/ */
long FS_SetStreamPos( stream_t *stream, long newpos ) int FS_SetStreamPos( stream_t *stream, int newpos )
{ {
if( !stream || !stream->format || !stream->format->setposfunc ) if( !stream || !stream->format || !stream->format->setposfunc )
return -1; return -1;
@ -277,4 +277,4 @@ void FS_FreeStream( stream_t *stream )
return; return;
stream->format->freefunc( stream ); stream->format->freefunc( stream );
} }

View File

@ -32,12 +32,12 @@ typedef struct
} wavinfo_t; } wavinfo_t;
// custom stdio // custom stdio
typedef long (*pfread)( void *handle, void *buf, size_t count ); typedef int (*pfread)( void *handle, void *buf, size_t count );
typedef long (*pfseek)( void *handle, long offset, int whence ); typedef int (*pfseek)( void *handle, int offset, int whence );
extern void *create_decoder( int *error ); extern void *create_decoder( int *error );
extern int feed_mpeg_header( void *mpg, const char *data, long bufsize, long streamsize, wavinfo_t *sc ); extern int feed_mpeg_header( void *mpg, const char *data, int bufsize, int streamsize, wavinfo_t *sc );
extern int feed_mpeg_stream( void *mpg, const char *data, long bufsize, char *outbuf, size_t *outsize ); extern int feed_mpeg_stream( void *mpg, const char *data, int bufsize, char *outbuf, size_t *outsize );
extern int open_mpeg_stream( void *mpg, void *file, pfread f_read, pfseek f_seek, wavinfo_t *sc ); extern int open_mpeg_stream( void *mpg, void *file, pfread f_read, pfseek f_seek, wavinfo_t *sc );
extern int read_mpeg_stream( void *mpg, char *outbuf, size_t *outsize ); extern int read_mpeg_stream( void *mpg, char *outbuf, size_t *outsize );
extern int get_stream_pos( void *mpg ); extern int get_stream_pos( void *mpg );
@ -205,7 +205,7 @@ Stream_ReadMPG
assume stream is valid assume stream is valid
================= =================
*/ */
long Stream_ReadMPG( stream_t *stream, long needBytes, void *buffer ) int Stream_ReadMPG( stream_t *stream, int needBytes, void *buffer )
{ {
// buffer handling // buffer handling
int bytesWritten = 0; int bytesWritten = 0;
@ -216,7 +216,7 @@ long Stream_ReadMPG( stream_t *stream, long needBytes, void *buffer )
while( 1 ) while( 1 )
{ {
byte *data; byte *data;
long outsize; int outsize;
if( !stream->buffsize ) if( !stream->buffsize )
{ {
@ -253,7 +253,7 @@ Stream_SetPosMPG
assume stream is valid assume stream is valid
================= =================
*/ */
long Stream_SetPosMPG( stream_t *stream, long newpos ) int Stream_SetPosMPG( stream_t *stream, int newpos )
{ {
if( set_stream_pos( stream->ptr, newpos ) != -1 ) if( set_stream_pos( stream->ptr, newpos ) != -1 )
{ {
@ -273,7 +273,7 @@ Stream_GetPosMPG
assume stream is valid assume stream is valid
================= =================
*/ */
long Stream_GetPosMPG( stream_t *stream ) int Stream_GetPosMPG( stream_t *stream )
{ {
return get_stream_pos( stream->ptr ); return get_stream_pos( stream->ptr );
} }
@ -300,4 +300,4 @@ void Stream_FreeMPG( stream_t *stream )
} }
Mem_Free( stream ); Mem_Free( stream );
} }

View File

@ -403,7 +403,7 @@ Stream_ReadWAV
assume stream is valid assume stream is valid
================= =================
*/ */
long Stream_ReadWAV( stream_t *stream, long bytes, void *buffer ) int Stream_ReadWAV( stream_t *stream, int bytes, void *buffer )
{ {
int remaining; int remaining;
@ -426,7 +426,7 @@ Stream_SetPosWAV
assume stream is valid assume stream is valid
================= =================
*/ */
long Stream_SetPosWAV( stream_t *stream, long newpos ) int Stream_SetPosWAV( stream_t *stream, int newpos )
{ {
// NOTE: stream->pos it's real file position without header size // NOTE: stream->pos it's real file position without header size
if( FS_Seek( stream->file, stream->buffsize + newpos, SEEK_SET ) != -1 ) if( FS_Seek( stream->file, stream->buffsize + newpos, SEEK_SET ) != -1 )
@ -445,7 +445,7 @@ Stream_GetPosWAV
assume stream is valid assume stream is valid
================= =================
*/ */
long Stream_GetPosWAV( stream_t *stream ) int Stream_GetPosWAV( stream_t *stream )
{ {
return stream->pos; return stream->pos;
} }
@ -462,4 +462,4 @@ void Stream_FreeWAV( stream_t *stream )
if( stream->file ) if( stream->file )
FS_Close( stream->file ); FS_Close( stream->file );
Mem_Free( stream ); Mem_Free( stream );
} }

View File

@ -34,9 +34,9 @@ typedef struct streamfmt_s
const char *ext; const char *ext;
stream_t *(*openfunc)( const char *filename ); stream_t *(*openfunc)( const char *filename );
long (*readfunc)( stream_t *stream, long bytes, void *buffer ); int (*readfunc)( stream_t *stream, int bytes, void *buffer );
long (*setposfunc)( stream_t *stream, long newpos ); int (*setposfunc)( stream_t *stream, int newpos );
long (*getposfunc)( stream_t *stream ); int (*getposfunc)( stream_t *stream );
void (*freefunc)( stream_t *stream ); void (*freefunc)( stream_t *stream );
} streamfmt_t; } streamfmt_t;
@ -95,14 +95,14 @@ typedef struct stream_s
typedef struct typedef struct
{ {
int riff_id; // 'RIFF' int riff_id; // 'RIFF'
long rLen; int rLen;
int wave_id; // 'WAVE' int wave_id; // 'WAVE'
int fmt_id; // 'fmt ' int fmt_id; // 'fmt '
long pcm_header_len; // varies... int pcm_header_len; // varies...
short wFormatTag; short wFormatTag;
short nChannels; // 1,2 for stereo data is (l,r) pairs short nChannels; // 1,2 for stereo data is (l,r) pairs
long nSamplesPerSec; int nSamplesPerSec;
long nAvgBytesPerSec; int nAvgBytesPerSec;
short nBlockAlign; short nBlockAlign;
short nBitsPerSample; short nBitsPerSample;
} wavehdr_t; } wavehdr_t;
@ -110,7 +110,7 @@ typedef struct
typedef struct typedef struct
{ {
int data_id; // 'data' or 'fact' int data_id; // 'data' or 'fact'
long dLen; int dLen;
} chunkhdr_t; } chunkhdr_t;
extern sndlib_t sound; extern sndlib_t sound;
@ -124,14 +124,14 @@ qboolean Sound_LoadMPG( const char *name, const byte *buffer, size_t filesize );
// stream operate // stream operate
// //
stream_t *Stream_OpenWAV( const char *filename ); stream_t *Stream_OpenWAV( const char *filename );
long Stream_ReadWAV( stream_t *stream, long bytes, void *buffer ); int Stream_ReadWAV( stream_t *stream, int bytes, void *buffer );
long Stream_SetPosWAV( stream_t *stream, long newpos ); int Stream_SetPosWAV( stream_t *stream, int newpos );
long Stream_GetPosWAV( stream_t *stream ); int Stream_GetPosWAV( stream_t *stream );
void Stream_FreeWAV( stream_t *stream ); void Stream_FreeWAV( stream_t *stream );
stream_t *Stream_OpenMPG( const char *filename ); stream_t *Stream_OpenMPG( const char *filename );
long Stream_ReadMPG( stream_t *stream, long bytes, void *buffer ); int Stream_ReadMPG( stream_t *stream, int bytes, void *buffer );
long Stream_SetPosMPG( stream_t *stream, long newpos ); int Stream_SetPosMPG( stream_t *stream, int newpos );
long Stream_GetPosMPG( stream_t *stream ); int Stream_GetPosMPG( stream_t *stream );
void Stream_FreeMPG( stream_t *stream ); void Stream_FreeMPG( stream_t *stream );
#endif//SOUNDLIB_H #endif//SOUNDLIB_H

View File

@ -287,7 +287,7 @@ typedef struct KeyValueData_s
char *szClassName; // in: entity classname char *szClassName; // in: entity classname
char *szKeyName; // in: name of key char *szKeyName; // in: name of key
char *szValue; // in: value of key char *szValue; // in: value of key
long fHandled; // out: DLL sets to true if key-value pair was understood int fHandled; // out: DLL sets to true if key-value pair was understood
} KeyValueData; } KeyValueData;

View File

@ -592,6 +592,11 @@ edict_t* SV_CreateNamedEntity( edict_t *ent, string_t className );
string_t SV_AllocString( const char *szValue ); string_t SV_AllocString( const char *szValue );
string_t SV_MakeString( const char *szValue ); string_t SV_MakeString( const char *szValue );
const char *SV_GetString( string_t iString ); const char *SV_GetString( string_t iString );
void SV_SetStringArrayMode( qboolean dynamic );
void SV_EmptyStringPool( void );
#ifdef XASH_64BIT
void SV_PrintStr64Stats_f( void );
#endif
sv_client_t *SV_ClientFromEdict( const edict_t *pEdict, qboolean spawned_only ); sv_client_t *SV_ClientFromEdict( const edict_t *pEdict, qboolean spawned_only );
int SV_MapIsValid( const char *filename, const char *spawn_entity, const char *landmark_name ); int SV_MapIsValid( const char *filename, const char *spawn_entity, const char *landmark_name );
void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch ); void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch );
@ -613,7 +618,6 @@ void SV_RestartStaticEnts( void );
int pfnGetCurrentPlayer( void ); int pfnGetCurrentPlayer( void );
edict_t *SV_EdictNum( int n ); edict_t *SV_EdictNum( int n );
char *SV_Localinfo( void ); char *SV_Localinfo( void );
// //
// sv_log.c // sv_log.c
// //

View File

@ -2049,7 +2049,7 @@ void SV_TSourceEngineQuery( netadr_t from )
MSG_WriteString( &buf, GI->game_url ); MSG_WriteString( &buf, GI->game_url );
MSG_WriteString( &buf, GI->update_url ); MSG_WriteString( &buf, GI->update_url );
MSG_WriteByte( &buf, 0 ); MSG_WriteByte( &buf, 0 );
MSG_WriteLong( &buf, (long)GI->version ); MSG_WriteLong( &buf, (int)GI->version );
MSG_WriteLong( &buf, GI->size ); MSG_WriteLong( &buf, GI->size );
if( GI->gamemode == 2 ) if( GI->gamemode == 2 )

View File

@ -571,7 +571,7 @@ void SV_RestartAmbientSounds( void )
soundlist_t soundInfo[256]; soundlist_t soundInfo[256];
string curtrack, looptrack; string curtrack, looptrack;
int i, nSounds; int i, nSounds;
long position; int position;
if( !SV_Active( )) return; if( !SV_Active( )) return;
@ -2152,7 +2152,7 @@ SV_StartMusic
================= =================
*/ */
void SV_StartMusic( const char *curtrack, const char *looptrack, long position ) void SV_StartMusic( const char *curtrack, const char *looptrack, int position )
{ {
MSG_BeginServerCmd( &sv.multicast, svc_stufftext ); MSG_BeginServerCmd( &sv.multicast, svc_stufftext );
MSG_WriteString( &sv.multicast, va( "music \"%s\" \"%s\" %li\n", curtrack, looptrack, position )); MSG_WriteString( &sv.multicast, va( "music \"%s\" \"%s\" %li\n", curtrack, looptrack, position ));
@ -2964,41 +2964,248 @@ void *pfnPvEntPrivateData( edict_t *pEdict )
return NULL; return NULL;
} }
#ifdef XASH_64BIT
static struct str64_s
{
size_t maxstringarray;
qboolean allowdup;
char *staticstringarray;
char *pstringarray;
char *pstringarraystatic;
char *pstringbase;
char *poldstringbase;
char *plast;
qboolean dynamic;
size_t maxalloc;
size_t numdups;
size_t numoverflows;
size_t totalalloc;
} str64;
#endif
/*
==================
SV_EmptyStringPool
Free strings on server stop. Reset string pointer on 64 bits
==================
*/
void SV_EmptyStringPool( void )
{
#ifdef XASH_64BIT
if( str64.dynamic ) // switch only after array fill (more space for multiplayer games)
str64.pstringbase = str64.pstringarray;
else
{
str64.pstringbase = str64.poldstringbase = str64.pstringarraystatic;
str64.plast = str64.pstringbase + 1;
}
#else
Mem_EmptyPool( svgame.stringspool );
#endif
}
/*
===============
SV_SetStringArrayMode
use different arrays on 64 bit platforms
set dynamic after complete server spawn
this helps not to lose strings that belongs to static game part
===============
*/
void SV_SetStringArrayMode( qboolean dynamic )
{
#ifdef XASH_64BIT
Con_Reportf( "SV_SetStringArrayMode(%d) %d\n", dynamic, str64.dynamic );
if( dynamic == str64.dynamic )
return;
str64.dynamic = dynamic;
SV_EmptyStringPool();
#endif
}
#ifdef XASH_64BIT
#ifndef _WIN32
#define USE_MMAP
#include <sys/mman.h>
#endif
#endif
/*
==================
SV_AllocStringPool
alloc string pool on 32bit platforms
alloc string array near the server library on 64bit platforms if possible
alloc string array somewhere if not (MAKE_STRING will not work. Always call ALLOC_STRING instead, or crash)
this case need patched game dll with MAKE_STRING checking ptrdiff size
==================
*/
void SV_AllocStringPool( void )
{
#ifdef XASH_64BIT
void *ptr = NULL;
string lenstr;
Con_Reportf( "SV_AllocStringPool()\n" );
if( Sys_GetParmFromCmdLine( "-str64alloc", lenstr ) )
{
str64.maxstringarray = Q_atoi( lenstr );
if( str64.maxstringarray < 1024 || str64.maxstringarray >= INT_MAX )
str64.maxstringarray = 65536;
}
else str64.maxstringarray = 65536;
if( Sys_CheckParm( "-str64dup" ) )
str64.allowdup = true;
#ifdef USE_MMAP
{
size_t pagesize = sysconf( _SC_PAGESIZE );
int arrlen = (str64.maxstringarray * 2) & ~(pagesize - 1);
void *base = svgame.dllFuncs.pfnGameInit;
void *start = svgame.hInstance - arrlen;
while( start - base > INT_MIN )
{
void *mapptr = mmap((void*)((unsigned long)start & ~(pagesize - 1)), arrlen, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0 );
if( mapptr && mapptr != (void*)-1 && mapptr - base > INT_MIN && mapptr - base < INT_MAX )
{
ptr = mapptr;
break;
}
if( mapptr ) munmap( mapptr, arrlen );
start -= arrlen;
}
if( !ptr )
{
start = base;
while( start - base < INT_MAX )
{
void *mapptr = mmap((void*)((unsigned long)start & ~(pagesize - 1)), arrlen, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0 );
if( mapptr && mapptr != (void*)-1 && mapptr - base > INT_MIN && mapptr - base < INT_MAX )
{
ptr = mapptr;
break;
}
if( mapptr ) munmap( mapptr, arrlen );
start += arrlen;
}
}
if( ptr )
{
Con_Reportf( "SV_AllocStringPool: Allocated string array near the server library: %p %p\n", base, ptr );
}
else
{
Con_Reportf( "SV_AllocStringPool: Failed to allocate string array near the server library!\n" );
ptr = str64.staticstringarray = Mem_Calloc(host.mempool, str64.maxstringarray * 2);
}
}
#else
ptr = str64.staticstringarray = Mem_Calloc(host.mempool, str64.maxstringarray * 2);
#endif
str64.pstringarray = ptr;
str64.pstringarraystatic = ptr + str64.maxstringarray;
str64.pstringbase = str64.poldstringbase = ptr;
str64.plast = ptr + 1;
svgame.globals->pStringBase = ptr;
#else
svgame.stringspool = Mem_AllocPool( "Server Strings" );
svgame.globals->pStringBase = "";
#endif
}
void SV_FreeStringPool( void )
{
#ifdef XASH_64BIT
Con_Reportf( "SV_FreeStringPool()\n" );
if( str64.pstringarray != str64.staticstringarray )
munmap( str64.pstringarray, (str64.maxstringarray * 2) & ~(sysconf( _SC_PAGESIZE ) - 1) );
else
Mem_Free( str64.staticstringarray );
#else
Mem_FreePool( &svgame.stringspool );
#endif
}
/* /*
============= =============
SV_AllocString SV_AllocString
allocate new engine string allocate new engine string
on 64bit platforms find in array string if deduplication enabled (default)
if not found, add to array
use -str64dup to disable deduplication, -str64alloc to set array size
============= =============
*/ */
string_t SV_AllocString( const char *szString ) string_t GAME_EXPORT SV_AllocString( const char *szValue )
{ {
char *out, *out_p; const char *newString = NULL;
int i, l;
if( svgame.physFuncs.pfnAllocString != NULL ) if( svgame.physFuncs.pfnAllocString != NULL )
return svgame.physFuncs.pfnAllocString( szString ); return svgame.physFuncs.pfnAllocString( szValue );
#ifdef XASH_64BIT
int cmp = 1;
if( !COM_CheckString( szString )) if( !str64.allowdup )
return 0; for( newString = str64.poldstringbase + 1; newString < str64.plast && ( cmp = Q_strcmp( newString, szValue ) ); newString += Q_strlen( newString ) + 1 );
l = Q_strlen( szString ) + 1; if( cmp )
out = out_p = Mem_Calloc( svgame.stringspool, l );
for( i = 0; i < l; i++ )
{ {
if( szString[i] == '\\' && i < l - 1 ) uint len = Q_strlen( szValue );
{
i++;
if( szString[i] == 'n')
*out_p++ = '\n';
else *out_p++ = '\\';
}
else *out_p++ = szString[i];
}
return out - svgame.globals->pStringBase; if( str64.plast - str64.poldstringbase + len + 2 > str64.maxstringarray )
} {
str64.plast = str64.pstringbase + 1;
str64.poldstringbase = str64.pstringbase;
str64.numoverflows++;
}
//MsgDev( D_NOTE, "SV_AllocString: %ld %s\n", str64.plast - svgame.globals->pStringBase, szValue );
memcpy( str64.plast, szValue, len + 1 );
str64.totalalloc += len + 1;
newString = str64.plast;
str64.plast += len + 1;
}
else
str64.numdups++;
//MsgDev( D_NOTE, "SV_AllocString: dup %ld %s\n", newString - svgame.globals->pStringBase, szValue );
if( newString - str64.pstringarray > str64.maxalloc )
str64.maxalloc = newString - str64.pstringarray;
return newString - svgame.globals->pStringBase;
#else
newString = _copystring( svgame.stringspool, szValue, __FILE__, __LINE__ );
return newString - svgame.globals->pStringBase;
#endif
}
#ifdef XASH_64BIT
void SV_PrintStr64Stats_f( void )
{
Msg( "====================\n" );
Msg( "64 bit string pool statistics\n" );
Msg( "====================\n" );
Msg( "string array size: %lu\n", str64.maxstringarray );
Msg( "total alloc %lu\n", str64.totalalloc );
Msg( "maximum array usage: %lu\n", str64.maxalloc );
Msg( "overflow counter: %lu\n", str64.numoverflows );
Msg( "dup string counter: %lu\n", str64.numdups );
}
#endif
/* /*
============= =============
@ -3011,9 +3218,18 @@ string_t SV_MakeString( const char *szValue )
{ {
if( svgame.physFuncs.pfnMakeString != NULL ) if( svgame.physFuncs.pfnMakeString != NULL )
return svgame.physFuncs.pfnMakeString( szValue ); return svgame.physFuncs.pfnMakeString( szValue );
#ifdef XASH_64BIT
{
long long ptrdiff = szValue - svgame.globals->pStringBase;
if( ptrdiff > INT_MAX || ptrdiff < INT_MIN )
return SV_AllocString(szValue);
else
return (int)ptrdiff;
}
#else
return szValue - svgame.globals->pStringBase; return szValue - svgame.globals->pStringBase;
} #endif
}
/* /*
============= =============
@ -4745,7 +4961,7 @@ void SV_UnloadProgs( void )
Delta_Shutdown (); Delta_Shutdown ();
Mod_ClearUserData (); Mod_ClearUserData ();
Mem_FreePool( &svgame.stringspool ); SV_FreeStringPool();
if( svgame.dllFuncs2.pfnGameShutdown != NULL ) if( svgame.dllFuncs2.pfnGameShutdown != NULL )
svgame.dllFuncs2.pfnGameShutdown (); svgame.dllFuncs2.pfnGameShutdown ();
@ -4892,7 +5108,7 @@ qboolean SV_LoadProgs( const char *name )
e->free = true; // mark all edicts as freed e->free = true; // mark all edicts as freed
Cvar_FullSet( "host_gameloaded", "1", FCVAR_READ_ONLY ); Cvar_FullSet( "host_gameloaded", "1", FCVAR_READ_ONLY );
svgame.stringspool = Mem_AllocPool( "Server Strings" ); SV_AllocStringPool();
// fire once // fire once
Con_Printf( "Dll loaded for game ^2\"%s\"\n", svgame.dllFuncs.pfnGetGameDescription( )); Con_Printf( "Dll loaded for game ^2\"%s\"\n", svgame.dllFuncs.pfnGetGameDescription( ));

View File

@ -514,6 +514,8 @@ void SV_ActivateServer( int runPhysics )
svgame.globals->time = sv.time; svgame.globals->time = sv.time;
svgame.dllFuncs.pfnServerActivate( svgame.edicts, svgame.numEntities, svs.maxclients ); svgame.dllFuncs.pfnServerActivate( svgame.edicts, svgame.numEntities, svs.maxclients );
SV_SetStringArrayMode( true );
// parse user-specified resources // parse user-specified resources
SV_CreateGenericResources(); SV_CreateGenericResources();
@ -616,7 +618,7 @@ void SV_DeactivateServer( void )
SV_ClearPhysEnts (); SV_ClearPhysEnts ();
Mem_EmptyPool( svgame.stringspool ); SV_EmptyStringPool();
for( i = 0; i < svs.maxclients; i++ ) for( i = 0; i < svs.maxclients; i++ )
{ {
@ -914,6 +916,7 @@ State machine exec new map
*/ */
void SV_ExecLoadLevel( void ) void SV_ExecLoadLevel( void )
{ {
SV_SetStringArrayMode( false );
if( SV_SpawnServer( GameState->levelName, NULL, GameState->backgroundMap )) if( SV_SpawnServer( GameState->levelName, NULL, GameState->backgroundMap ))
{ {
SV_SpawnEntities( GameState->levelName ); SV_SpawnEntities( GameState->levelName );

View File

@ -2133,7 +2133,7 @@ used for reload game after player death
const char *SV_GetLatestSave( void ) const char *SV_GetLatestSave( void )
{ {
static char savename[MAX_QPATH]; static char savename[MAX_QPATH];
long newest = 0, ft; int newest = 0, ft;
int i, found = 0; int i, found = 0;
search_t *t; search_t *t;