Yet more 64-bit porting fixes.

This commit is contained in:
Knightmare66 2020-08-02 02:00:01 -04:00
parent 11b69f8437
commit 988347e7d2
13 changed files with 46 additions and 32 deletions

View file

@ -1071,7 +1071,7 @@ void CL_Rcon_f (void)
to.port = BigShort (PORT_SERVER);
}
NET_SendPacket (NS_CLIENT, strlen(message)+1, message, to);
NET_SendPacket (NS_CLIENT, (int)strlen(message)+1, message, to);
}

View file

@ -446,7 +446,8 @@ void DumpChunks(void)
memcpy (str, data_p, 4);
data_p += 4;
iff_chunk_len = GetLittleLong();
Com_Printf ("0x%x : %s (%d)\n", (int)(data_p - 4), str, iff_chunk_len);
// Com_Printf ("0x%x : %s (%d)\n", (int)(data_p - 4), str, iff_chunk_len);
Com_Printf ("0x%x : %s (%d)\n", (size_t)(data_p - 4), str, iff_chunk_len);
data_p += (iff_chunk_len + 1) & ~1;
} while (data_p < iff_end);
}

View file

@ -66,7 +66,9 @@ static size_t ovc_read (void *ptr, size_t size, size_t nmemb, void *datasource)
#ifdef OGG_DIRECT_FILE
return fread(ptr, 1, size * nmemb, track->file) / size;
#else
return FS_Read(ptr, size * nmemb, track->file) / size;
// return FS_Read(ptr, size * nmemb, track->file) / size;
// should use FS_FRead instead
return FS_FRead(ptr, size * nmemb, 1, track->file) / size;
#endif
}

View file

@ -395,7 +395,7 @@ void AddFunctionName (char *funcname, char *filename, tokenList_t *head)
return;
}
#if defined( __linux__ )
#if defined( __linux__ ) || defined (__FreeBSD__)
// the bad thing is, this doesn't preprocess .. on __linux__ this
// function is not implemented (q_math.c)
if ( !Q_stricmp( funcname, "BoxOnPlaneSide" ) ) {
@ -405,7 +405,7 @@ void AddFunctionName (char *funcname, char *filename, tokenList_t *head)
// NERVE - SMF - workaround for Graeme's predifined MACOSX functions
// TTimo - looks like linux version needs to escape those too
#if defined( _WIN32 ) || defined( __linux__ )
#if defined( _WIN32 ) || defined( __linux__ ) || defined (__FreeBSD__)
if ( !Q_stricmp(funcname, "qmax") ) {
return;
}
@ -415,7 +415,7 @@ void AddFunctionName (char *funcname, char *filename, tokenList_t *head)
#endif
// -NERVE - SMF
f = (replacefunc_t *) GetMemory( sizeof( replacefunc_t ) + strlen( funcname ) + 1 + 6 + strlen( filename ) + 1 );
f = (replacefunc_t *) GetMemory( sizeof( replacefunc_t ) + (int)strlen( funcname ) + 1 + 6 + (int)strlen( filename ) + 1 );
f->name = (char *) f + sizeof( replacefunc_t );
strcpy( f->name, funcname );
f->newname = (char *) f + sizeof( replacefunc_t ) + strlen( funcname ) + 1;

View file

@ -806,7 +806,7 @@ void PC_AddBuiltinDefines( source_t *source ) {
for ( i = 0; builtin[i].string; i++ )
{
define = (define_t *) GetMemory( sizeof( define_t ) + strlen( builtin[i].string ) + 1 );
define = (define_t *) GetMemory( sizeof( define_t ) + (int)strlen( builtin[i].string ) + 1 );
memset( define, 0, sizeof( define_t ) );
define->name = (char *) define + sizeof( define_t );
strcpy( define->name, builtin[i].string );
@ -830,7 +830,7 @@ void PC_AddBuiltinDefines( source_t *source ) {
int PC_ExpandBuiltinDefine( source_t *source, define_t *define,
token_t **firsttoken, token_t **lasttoken ) {
token_t token;
unsigned long t; // time_t t; //to prevent LCC warning
time_t t; // unsigned long prevents LCC warning
char *curtime;
memcpy( &token, &source->token, sizeof( token_t ) );
@ -853,7 +853,7 @@ int PC_ExpandBuiltinDefine( source_t *source, define_t *define,
{
strcpy( token.string, source->scriptstack->filename );
token.type = TT_NAME;
token.subtype = strlen( token.string );
token.subtype = (int)strlen( token.string );
*firsttoken = &token;
*lasttoken = &token;
break;
@ -868,7 +868,7 @@ int PC_ExpandBuiltinDefine( source_t *source, define_t *define,
strcat( token.string, "\"" );
free( curtime );
token.type = TT_NAME;
token.subtype = strlen( token.string );
token.subtype = (int)strlen( token.string );
*firsttoken = &token;
*lasttoken = &token;
break;
@ -882,7 +882,7 @@ int PC_ExpandBuiltinDefine( source_t *source, define_t *define,
strcat( token.string, "\"" );
free( curtime );
token.type = TT_NAME;
token.subtype = strlen( token.string );
token.subtype = (int)strlen( token.string );
*firsttoken = &token;
*lasttoken = &token;
break;
@ -1324,7 +1324,7 @@ int PC_Directive_define( source_t *source ) {
#endif //DEFINEHASHING
} //end if
//allocate define
define = (define_t *) GetMemory( sizeof( define_t ) + strlen( token.string ) + 1 );
define = (define_t *) GetMemory( sizeof( define_t ) + (int)strlen( token.string ) + 1 );
memset( define, 0, sizeof( define_t ) );
define->name = (char *) define + sizeof( define_t );
strcpy( define->name, token.string );
@ -1431,7 +1431,7 @@ define_t *PC_DefineFromString( char *string ) {
PC_InitTokenHeap();
script = LoadScriptMemory( string, strlen( string ), "*extern" );
script = LoadScriptMemory( string, (int)strlen( string ), "*extern" );
//create a new source
memset( &src, 0, sizeof( source_t ) );
strncpy( src.filename, "*extern", _MAX_PATH );
@ -1558,7 +1558,7 @@ define_t *PC_CopyDefine( source_t *source, define_t *define ) {
define_t *newdefine;
token_t *token, *newtoken, *lasttoken;
newdefine = (define_t *) GetMemory( sizeof( define_t ) + strlen( define->name ) + 1 );
newdefine = (define_t *) GetMemory( sizeof( define_t ) + (int)strlen( define->name ) + 1 );
//copy the define name
newdefine->name = (char *) newdefine + sizeof( define_t );
strcpy( newdefine->name, define->name );

View file

@ -813,7 +813,7 @@ int PS_ReadPunctuation( script_t *script, token_t *token ) {
punc = &script->punctuations[i];
#endif //PUNCTABLE
p = punc->p;
len = strlen( p );
len = (int)strlen( p );
//if the script contains at least as much characters as the punctuation
if ( script->script_p + len <= script->end_p ) {
//if the script contains the punctuation
@ -1274,7 +1274,7 @@ int ScriptSkipTo( script_t *script, char *value ) {
char firstchar;
firstchar = *value;
len = strlen( value );
len = (int)strlen( value );
do
{
if ( !PS_ReadWhiteSpace( script ) ) {

View file

@ -372,7 +372,7 @@ void MSG_WriteString (sizebuf_t *sb, char *s)
if (!s)
SZ_Write (sb, "", 1);
else
SZ_Write (sb, s, strlen(s)+1);
SZ_Write (sb, s, (int)strlen(s)+1);
}

View file

@ -984,7 +984,7 @@ int FS_Read (void *buffer, int size, fileHandle_t f)
while (remaining)
{
if (handle->file)
r = fread(buf, 1, remaining, handle->file);
r = (int)fread(buf, 1, remaining, handle->file);
else if (handle->zip)
r = unzReadCurrentFile(handle->zip, buf, remaining);
else
@ -1043,7 +1043,7 @@ int FS_FRead (void *buffer, int size, int count, fileHandle_t f)
while (remaining)
{
if (handle->file)
r = fread(buf, 1, remaining, handle->file);
r = (int)fread(buf, 1, remaining, handle->file);
else if (handle->zip)
r = unzReadCurrentFile(handle->zip, buf, remaining);
else
@ -1094,7 +1094,7 @@ int FS_Write (const void *buffer, int size, fileHandle_t f){
while (remaining)
{
if (handle->file)
w = fwrite(buf, 1, remaining, handle->file);
w = (int)fwrite(buf, 1, remaining, handle->file);
else if (handle->writeZip)
{
if (zipWriteInFileInZip(handle->writeZip, buf, remaining) == ZIP_OK)
@ -1684,7 +1684,7 @@ FS_CopyFile
void FS_CopyFile (char *src, char *dst)
{
FILE *f1, *f2;
int l;
size_t l;
byte buffer[65536];
Com_DPrintf ("FS_CopyFile (%s, %s)\n", src, dst);

View file

@ -1224,7 +1224,7 @@ void R_LoadPNG (char *filename, byte **pic, int *width, int *height)
// update the info structure
png_read_update_info( png, pnginfo );
r_png_handle->fRowBytes = png_get_rowbytes (png, pnginfo);
r_png_handle->fRowBytes = (int)png_get_rowbytes (png, pnginfo);
r_png_handle->bytesPerPixel = png_get_channels (png, pnginfo); // DL Added 30/08/2000
R_InitializePNGData ();

View file

@ -162,7 +162,7 @@ void Mod_Modellist_f (void)
{
int i;
model_t *mod;
int total;
size_t total;
total = 0;
VID_Printf (PRINT_ALL,"Loaded models:\n");

View file

@ -36,7 +36,8 @@ FIXME: this use of "area" is different from the bsp file use
// (type *)STRUCT_FROM_LINK(link_t *link, type, member)
// ent = STRUCT_FROM_LINK(link,entity_t,order)
// FIXME: remove this mess!
#define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m)))
//#define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m)))
#define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (size_t)&(((t *)0)->m)))
#define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area)

View file

@ -3266,7 +3266,7 @@ qboolean QGL_Init( const char *dllname )
qglGetPixelMapusv = dllGetPixelMapusv = GPA( "glGetPixelMapusv" );
qglGetPointerv = dllGetPointerv = GPA( "glGetPointerv" );
qglGetPolygonStipple = dllGetPolygonStipple = GPA( "glGetPolygonStipple" );
qglGetString = dllGetString = GPA( "glGetString" );
qglGetString = dllGetString = (const GLubyte *)GPA( "glGetString" );
qglGetTexEnvfv = dllGetTexEnvfv = GPA( "glGetTexEnvfv" );
qglGetTexEnviv = dllGetTexEnviv = GPA( "glGetTexEnviv" );
qglGetTexGendv = dllGetTexGendv = GPA( "glGetTexGendv" );
@ -3487,14 +3487,14 @@ qboolean QGL_Init( const char *dllname )
qglViewport = dllViewport = GPA( "glViewport" );
qwglCopyContext = GPA( "wglCopyContext" );
qwglCreateContext = GPA( "wglCreateContext" );
qwglCreateLayerContext = GPA( "wglCreateLayerContext" );
qwglCreateContext = (HGLRC)GPA( "wglCreateContext" );
qwglCreateLayerContext = (HGLRC)GPA( "wglCreateLayerContext" );
qwglDeleteContext = GPA( "wglDeleteContext" );
qwglDescribeLayerPlane = GPA( "wglDescribeLayerPlane" );
qwglGetCurrentContext = GPA( "wglGetCurrentContext" );
qwglGetCurrentDC = GPA( "wglGetCurrentDC" );
qwglGetCurrentContext = (HGLRC)GPA( "wglGetCurrentContext" );
qwglGetCurrentDC = (HDC)GPA( "wglGetCurrentDC" );
qwglGetLayerPaletteEntries = GPA( "wglGetLayerPaletteEntries" );
qwglGetProcAddress = GPA( "wglGetProcAddress" );
qwglGetProcAddress = (PROC *)GPA( "wglGetProcAddress" );
qwglMakeCurrent = GPA( "wglMakeCurrent" );
qwglRealizeLayerPalette = GPA( "wglRealizeLayerPalette" );
qwglSetLayerPaletteEntries = GPA( "wglSetLayerPaletteEntries" );

View file

@ -1413,8 +1413,18 @@ void *Sys_GetGameAPI (void *parms)
char name[MAX_OSPATH];
char *path;
char cwd[MAX_OSPATH];
#if defined _M_IX86
//Knightmare- changed DLL name for better cohabitation
#if defined (_M_X64) || defined (_M_AMD64) || defined (__x86_64__)
const char *gamename = "kmq2gamex64.dll";
#ifdef NDEBUG
const char *debugdir = "release";
#else
const char *debugdir = "debug";
#endif
#elif defined (_M_IX86)
// Knightmare- changed DLL name for better cohabitation
const char *gamename = "kmq2gamex86.dll";
#ifdef NDEBUG