shithub: qk3

Download patch

ref: 7b8303673d908898d40ef36f03976c68c1bac489
parent: f6e305ace571c6844058c0ea0d468ac9c66cb878
author: qwx <>
date: Sun Jan 13 05:38:00 EST 2019

fix pointer conversions to shorter integer

--- a/code/qcommon/cm_polylib.c
+++ b/code/qcommon/cm_polylib.c
@@ -272,11 +272,11 @@
 */
 winding_t	*CopyWinding (winding_t *w)
 {
-	int			size;
+	intptr			size;
 	winding_t	*c;
 
 	c = AllocWinding (w->numpoints);
-	size = (int)((winding_t *)0)->p[w->numpoints];
+	size = (intptr)((winding_t *)0)->p[w->numpoints];
 	Com_Memcpy (c, w, size);
 	return c;
 }
--- a/code/qcommon/common.c
+++ b/code/qcommon/common.c
@@ -1502,7 +1502,7 @@
 		Com_Error( ERR_FATAL, "Hunk data failed to allocate %i megs", s_hunkTotal / (1024*1024) );
 	}
 	// cacheline align
-	s_hunkData = (byte *) ( ( (int)s_hunkData + 31 ) & ~31 );
+	s_hunkData = (byte *) ( ( (uintptr)s_hunkData + 31 ) & ~31 );
 	Hunk_Clear();
 
 	Cmd_AddCommand( "meminfo", Com_Meminfo_f );
--- a/code/qcommon/qcommon.h
+++ b/code/qcommon/qcommon.h
@@ -312,7 +312,7 @@
 } sharedTraps_t;
 
 void	VM_Init( void );
-vm_t	*VM_Create( const char *module, int (*systemCalls)(int *), 
+vm_t	*VM_Create( const char *module, intptr (*systemCalls)(int *), 
 				   vmInterpret_t interpret );
 // module should be bare: "cgame", not "cgame.dll" or "vm/cgame.qvm"
 
--- a/code/qcommon/vm.c
+++ b/code/qcommon/vm.c
@@ -362,7 +362,7 @@
 	// DLL's can't be restarted in place
 	if ( vm->dllHandle ) {
 		char	name[MAX_QPATH];
-	    int			(*systemCall)( int *parms );
+		intptr (*systemCall)(int*);
 		
 		systemCall = vm->systemCall;	
 		Q_strncpyz( name, vm->name, sizeof( name ) );
@@ -432,7 +432,7 @@
 
 #define	STACK_SIZE	0x20000
 
-vm_t *VM_Create( const char *module, int (*systemCalls)(int *), 
+vm_t *VM_Create( const char *module, intptr (*systemCalls)(int *), 
 				vmInterpret_t interpret ) {
 	vm_t		*vm;
 	vmHeader_t	*header;
--- a/code/qcommon/vm_interpreted.c
+++ b/code/qcommon/vm_interpreted.c
@@ -471,7 +471,7 @@
 
 				src = (int *)&image[ r0&dataMask ];
 				dest = (int *)&image[ r1&dataMask ];
-				if ( ( (int)src | (int)dest | count ) & 3 ) {
+				if ( ( (intptr)src | (intptr)dest | count ) & 3 ) {
 					Com_Error( ERR_DROP, "OP_BLOCK_COPY not dword aligned" );
 				}
 				count >>= 2;
--- a/code/qcommon/vm_local.h
+++ b/code/qcommon/vm_local.h
@@ -125,7 +125,7 @@
     // DO NOT MOVE OR CHANGE THESE WITHOUT CHANGING THE VM_OFFSET_* DEFINES
     // USED BY THE ASM CODE
     int			programStack;		// the vm may be recursively entered
-    int			(*systemCall)( int *parms );
+    intptr			(*systemCall)( int *parms );
 
 	//------------------------------------
    
--- a/code/server/sv_client.c
+++ b/code/server/sv_client.c
@@ -429,7 +429,7 @@
 	denied = (char *)VM_Call( gvm, GAME_CLIENT_CONNECT, clientNum, qtrue, qfalse ); // firstTime = qtrue
 	if ( denied ) {
 		// we can't just use VM_ArgPtr, because that is only valid inside a VM_Call
-		denied = VM_ExplicitArgPtr( gvm, (int)denied );
+		denied = VM_ExplicitArgPtr( gvm, (intptr)denied );
 
 		NET_OutOfBandPrint( NS_SERVER, &from, "print\n%s\n", denied );
 		Com_DPrintf ("Game rejected a connection: %s.\n", denied);
--- a/code/server/sv_game.c
+++ b/code/server/sv_game.c
@@ -328,7 +328,7 @@
 
 #define	VMF(x)	((float *)args)[x]
 
-int SV_GameSystemCalls( int *args ) {
+intptr SV_GameSystemCalls( int *args ) {
 	switch( args[0] ) {
 	case G_PRINT:
 		Com_Printf( "%s", VMA(1) );
@@ -842,7 +842,7 @@
 		return 0;
 
 	case TRAP_STRNCPY:
-		return (int)strncpy( VMA(1), VMA(2), args[3] );
+		return (intptr)strncpy( VMA(1), VMA(2), args[3] );
 
 	case TRAP_SIN:
 		return FloatAsInt( sin( VMF(1) ) );