64 bit float compatibility

This commit is contained in:
Pavol Marko 2004-04-22 08:13:52 +00:00
parent 607da4d4a2
commit 21287f4f3a
2 changed files with 20 additions and 24 deletions

View File

@ -30,8 +30,6 @@
*/ */
#include <string> #include <string>
#include <extdll.h>
#include <meta_api.h>
#include <time.h> #include <time.h>
#include "amxmodx.h" #include "amxmodx.h"
@ -73,8 +71,8 @@ static cell AMX_NATIVE_CALL emit_sound(AMX *amx, cell *params) /* 7 param */
int len; int len;
char* szSample = get_amxstring(amx,params[3],0,len); char* szSample = get_amxstring(amx,params[3],0,len);
float vol = *(float *)((void *)&params[4]); float vol = *(REAL *)((void *)&params[4]);
float att = *(float *)((void *)&params[5]); float att = *(REAL *)((void *)&params[5]);
int channel = params[2]; int channel = params[2];
int pitch = params[7]; int pitch = params[7];
int flags = params[6]; int flags = params[6];
@ -239,13 +237,13 @@ static cell AMX_NATIVE_CALL set_hudmessage(AMX *amx, cell *params) /* 11 param
g_hudset.r1 = params[1]; g_hudset.r1 = params[1];
g_hudset.g1 = params[2]; g_hudset.g1 = params[2];
g_hudset.b1 = params[3]; g_hudset.b1 = params[3];
g_hudset.x = *(float *)((void *)&params[4]); g_hudset.x = *(REAL *)((void *)&params[4]);
g_hudset.y = *(float *)((void *)&params[5]); g_hudset.y = *(REAL *)((void *)&params[5]);
g_hudset.effect = params[6]; g_hudset.effect = params[6];
g_hudset.fxTime = *(float *)((void *)&params[7]); g_hudset.fxTime = *(REAL *)((void *)&params[7]);
g_hudset.holdTime = *(float *)((void *)&params[8]); g_hudset.holdTime = *(REAL *)((void *)&params[8]);
g_hudset.fadeinTime = *(float *)((void *)&params[9]); g_hudset.fadeinTime = *(REAL *)((void *)&params[9]);
g_hudset.fadeoutTime = *(float *)((void *)&params[10]); g_hudset.fadeoutTime = *(REAL *)((void *)&params[10]);
g_hudset.channel = params[11]; g_hudset.channel = params[11];
return 1; return 1;
} }
@ -1000,14 +998,14 @@ static cell AMX_NATIVE_CALL get_cvar_string(AMX *amx, cell *params) /* 3 param *
static cell AMX_NATIVE_CALL get_cvar_float(AMX *amx, cell *params) /* 1 param */ static cell AMX_NATIVE_CALL get_cvar_float(AMX *amx, cell *params) /* 1 param */
{ {
int ilen; int ilen;
float pFloat = CVAR_GET_FLOAT(get_amxstring(amx,params[1],0,ilen)); REAL pFloat = CVAR_GET_FLOAT(get_amxstring(amx,params[1],0,ilen));
return *(cell*)((void *)&pFloat); return *(cell*)((void *)&pFloat);
} }
static cell AMX_NATIVE_CALL set_cvar_float(AMX *amx, cell *params) /* 2 param */ static cell AMX_NATIVE_CALL set_cvar_float(AMX *amx, cell *params) /* 2 param */
{ {
int ilen; int ilen;
CVAR_SET_FLOAT(get_amxstring(amx,params[1],0,ilen),*(float *)((void *)&params[2])); CVAR_SET_FLOAT(get_amxstring(amx,params[1],0,ilen),*(REAL *)((void *)&params[2]));
return 1; return 1;
} }
@ -1275,7 +1273,7 @@ static cell AMX_NATIVE_CALL read_data(AMX *amx, cell *params) /* 3 param */
return set_amxstring(amx,params[2], g_events.getArgString( params[1] ),*get_amxaddr(amx,params[3])); return set_amxstring(amx,params[2], g_events.getArgString( params[1] ),*get_amxaddr(amx,params[3]));
default: default:
cell *fCell = get_amxaddr(amx,params[2]); cell *fCell = get_amxaddr(amx,params[2]);
float *pFloat = (float *)((void *)fCell); float *pFloat = (REAL *)((void *)fCell);
*pFloat = g_events.getArgFloat( params[1] ); *pFloat = g_events.getArgFloat( params[1] );
return (int)(*pFloat); return (int)(*pFloat);
} }
@ -1423,7 +1421,7 @@ static cell AMX_NATIVE_CALL get_maxplayers(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_gametime(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_gametime(AMX *amx, cell *params)
{ {
float pFloat = gpGlobals->time; REAL pFloat = gpGlobals->time;
return *(cell*)((void *)&pFloat); return *(cell*)((void *)&pFloat);
} }
@ -1522,7 +1520,7 @@ static cell AMX_NATIVE_CALL set_task(AMX *amx, cell *params) /* 2 param */
return 0; return 0;
} }
float base = *(float *)((void *)&params[1]); float base = *(REAL *)((void *)&params[1]);
if ( base < 0.1 ) if ( base < 0.1 )
base = 0.1; base = 0.1;
@ -1562,7 +1560,7 @@ static cell AMX_NATIVE_CALL register_cvar(AMX *amx, cell *params) /* 3 param */
{ {
CPluginMngr::CPlugin *plugin = g_plugins.findPluginFast(amx); CPluginMngr::CPlugin *plugin = g_plugins.findPluginFast(amx);
CCVar* cvar = new CCVar( temp , plugin->getName() , params[3] , CCVar* cvar = new CCVar( temp , plugin->getName() , params[3] ,
*(float *)((void *)&params[4]) ); *(REAL *)((void *)&params[4]) );
if ( cvar == 0 ) if ( cvar == 0 )
return 0; return 0;
@ -1845,9 +1843,9 @@ static cell AMX_NATIVE_CALL get_distance(AMX *amx, cell *params) /* 2 param */
static cell AMX_NATIVE_CALL random_float(AMX *amx, cell *params) /* 2 param */ static cell AMX_NATIVE_CALL random_float(AMX *amx, cell *params) /* 2 param */
{ {
float one = *(float *)((void *)&params[1]); float one = *(REAL *)((void *)&params[1]);
float two = *(float *)((void *)&params[2]); float two = *(REAL *)((void *)&params[2]);
float fRnd = RANDOM_FLOAT(one,two); REAL fRnd = RANDOM_FLOAT(one,two);
return *(cell*)((void *)&fRnd); return *(cell*)((void *)&fRnd);
} }
@ -1888,7 +1886,7 @@ static cell AMX_NATIVE_CALL get_user_aiming(AMX *amx, cell *params) /* 4 param *
cell *cpId = get_amxaddr(amx,params[2]); cell *cpId = get_amxaddr(amx,params[2]);
cell *cpBody = get_amxaddr(amx,params[3]); cell *cpBody = get_amxaddr(amx,params[3]);
cell fCell; cell fCell;
float *pFloat = (float *)((void *)&fCell); float *pFloat = (REAL *)((void *)&fCell);
*pFloat = 0.0; *pFloat = 0.0;
if (pPlayer->ingame) { if (pPlayer->ingame) {
edict_t* edict = pPlayer->pEdict; edict_t* edict = pPlayer->pEdict;

View File

@ -29,8 +29,6 @@
* version. * version.
*/ */
#include <extdll.h>
#include <meta_api.h>
#include <ctype.h> #include <ctype.h>
#include "amxmodx.h" #include "amxmodx.h"
@ -78,7 +76,7 @@ char* format_amxstring(AMX *amx, cell *params, int parm,int& len)
arg = buffer[1]; arg = buffer[1];
switch(*(ptr-1)){ switch(*(ptr-1)){
case 's': sprintf(arg,format,get_amxstring(amx, params[parm++],2,len)); break; case 's': sprintf(arg,format,get_amxstring(amx, params[parm++],2,len)); break;
case 'f': case 'g': sprintf(arg,format,*(float*)get_amxaddr(amx, params[parm++])); break; case 'f': case 'g': sprintf(arg,format,(float)*(REAL*)get_amxaddr(amx, params[parm++])); break;
default: sprintf(arg,format,(int)*get_amxaddr(amx, params[parm++])); default: sprintf(arg,format,(int)*get_amxaddr(amx, params[parm++]));
} }
while(*arg) *dest++=*arg++; while(*arg) *dest++=*arg++;
@ -427,7 +425,7 @@ float fo_getargfloat(AMX *amx, int pos)
unsigned char *data =amx->base+(int)((AMX_HEADER *)amx->base)->dat; unsigned char *data =amx->base+(int)((AMX_HEADER *)amx->base)->dat;
cell value = * (cell *)(data+(int)amx->frm+(pos+3)*sizeof(cell)); cell value = * (cell *)(data+(int)amx->frm+(pos+3)*sizeof(cell));
cell number = *(cell *)(data+(int)value); cell number = *(cell *)(data+(int)value);
return *(float *)((void *)&number); return *(REAL *)((void *)&number);
} }
char* fo_getargstr(AMX *amx, int swap, int pos) char* fo_getargstr(AMX *amx, int swap, int pos)