mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Use references in some gamevar stuff
git-svn-id: https://svn.eduke32.com/eduke32@6853 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
f903aac29f
commit
21c9f6dd7e
2 changed files with 101 additions and 107 deletions
|
@ -623,21 +623,21 @@ int __fastcall Gv_GetVar(int gameVar, int spriteNum, int playerNum)
|
||||||
return *insptr++;
|
return *insptr++;
|
||||||
|
|
||||||
int invertResult = !!(gameVar & (MAXGAMEVARS << 1));
|
int invertResult = !!(gameVar & (MAXGAMEVARS << 1));
|
||||||
|
gamevar_t & var = aGameVars[gameVar &= (MAXGAMEVARS - 1)];
|
||||||
|
|
||||||
if ((gameVar & ~(MAXGAMEVARS << 1)) >= g_gameVarCount)
|
if ((gameVar & ~(MAXGAMEVARS << 1)) >= g_gameVarCount)
|
||||||
goto special;
|
goto special;
|
||||||
|
|
||||||
gameVar &= (MAXGAMEVARS - 1);
|
|
||||||
|
|
||||||
int returnValue, varFlags;
|
int returnValue, varFlags;
|
||||||
varFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK);
|
varFlags = var.flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK);
|
||||||
|
|
||||||
if (varFlags == GAMEVAR_PERACTOR)
|
if (varFlags == GAMEVAR_PERACTOR)
|
||||||
{
|
{
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned) spriteNum >= MAXSPRITES)) goto badindex;
|
if (EDUKE32_PREDICT_FALSE((unsigned) spriteNum >= MAXSPRITES)) goto badindex;
|
||||||
returnValue = aGameVars[gameVar].pValues[spriteNum];
|
returnValue = var.pValues[spriteNum];
|
||||||
}
|
}
|
||||||
else if (!varFlags) returnValue = aGameVars[gameVar].global;
|
else if (!varFlags) returnValue = var.global;
|
||||||
else if (varFlags == GAMEVAR_PERPLAYER)
|
else if (varFlags == GAMEVAR_PERPLAYER)
|
||||||
{
|
{
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned) playerNum >= MAXPLAYERS))
|
if (EDUKE32_PREDICT_FALSE((unsigned) playerNum >= MAXPLAYERS))
|
||||||
|
@ -645,17 +645,14 @@ int __fastcall Gv_GetVar(int gameVar, int spriteNum, int playerNum)
|
||||||
spriteNum = playerNum;
|
spriteNum = playerNum;
|
||||||
goto badindex;
|
goto badindex;
|
||||||
}
|
}
|
||||||
returnValue = aGameVars[gameVar].pValues[playerNum];
|
returnValue = var.pValues[playerNum];
|
||||||
}
|
}
|
||||||
else switch (varFlags)
|
else switch (varFlags)
|
||||||
{
|
{
|
||||||
case GAMEVAR_INT32PTR: returnValue = *(int32_t *)aGameVars[gameVar].global; break;
|
case GAMEVAR_INT32PTR: returnValue = *(int32_t *)var.global; break;
|
||||||
case GAMEVAR_INT16PTR: returnValue = *(int16_t *)aGameVars[gameVar].global; break;
|
case GAMEVAR_INT16PTR: returnValue = *(int16_t *)var.global; break;
|
||||||
case GAMEVAR_UINT8PTR: returnValue = *(char *)aGameVars[gameVar].global; break;
|
case GAMEVAR_UINT8PTR: returnValue = *(char *)var.global; break;
|
||||||
case GAMEVAR_Q16PTR:
|
case GAMEVAR_Q16PTR: returnValue = var.flags & GAMEVAR_SPECIAL ? *(int32_t *)var.global : fix16_to_int(*(fix16_t *)var.global); break;
|
||||||
returnValue = aGameVars[gameVar].flags & GAMEVAR_SPECIAL ? *(int32_t *)aGameVars[gameVar].global
|
|
||||||
: fix16_to_int(*(fix16_t *)aGameVars[gameVar].global);
|
|
||||||
break;
|
|
||||||
default: EDUKE32_UNREACHABLE_SECTION(returnValue = 0; break);
|
default: EDUKE32_UNREACHABLE_SECTION(returnValue = 0; break);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -779,7 +776,7 @@ badarrayindex:
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
badindex:
|
badindex:
|
||||||
CON_ERRPRINTF("Gv_GetVar(): invalid index %d for \"%s\"\n", spriteNum, aGameVars[gameVar].szLabel);
|
CON_ERRPRINTF("Gv_GetVar(): invalid index %d for \"%s\"\n", spriteNum, var.szLabel);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -787,32 +784,31 @@ badindex:
|
||||||
|
|
||||||
void __fastcall Gv_SetVar(int const gameVar, int const newValue, int const spriteNum, int const playerNum)
|
void __fastcall Gv_SetVar(int const gameVar, int const newValue, int const spriteNum, int const playerNum)
|
||||||
{
|
{
|
||||||
int const varFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
|
gamevar_t & var = aGameVars[gameVar];
|
||||||
|
int const varFlags = var.flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned)gameVar >= (unsigned)g_gameVarCount)) goto badvarid;
|
if (EDUKE32_PREDICT_FALSE((unsigned)gameVar >= (unsigned)g_gameVarCount)) goto badvarid;
|
||||||
|
|
||||||
if (!varFlags) aGameVars[gameVar].global=newValue;
|
if (!varFlags) var.global=newValue;
|
||||||
else if (varFlags == GAMEVAR_PERPLAYER)
|
else if (varFlags == GAMEVAR_PERPLAYER)
|
||||||
{
|
{
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned) playerNum > MAXPLAYERS-1)) goto badindex;
|
if (EDUKE32_PREDICT_FALSE((unsigned) playerNum > MAXPLAYERS-1)) goto badindex;
|
||||||
// for the current player
|
// for the current player
|
||||||
aGameVars[gameVar].pValues[playerNum]=newValue;
|
var.pValues[playerNum]=newValue;
|
||||||
}
|
}
|
||||||
else if (varFlags == GAMEVAR_PERACTOR)
|
else if (varFlags == GAMEVAR_PERACTOR)
|
||||||
{
|
{
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned) spriteNum > MAXSPRITES-1)) goto badindex;
|
if (EDUKE32_PREDICT_FALSE((unsigned) spriteNum > MAXSPRITES-1)) goto badindex;
|
||||||
aGameVars[gameVar].pValues[spriteNum]=newValue;
|
var.pValues[spriteNum]=newValue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (varFlags)
|
switch (varFlags)
|
||||||
{
|
{
|
||||||
case GAMEVAR_INT32PTR: *((int32_t *)aGameVars[gameVar].global) = (int32_t)newValue; break;
|
case GAMEVAR_INT32PTR: *((int32_t *)var.global) = (int32_t)newValue; break;
|
||||||
case GAMEVAR_INT16PTR: *((int16_t *)aGameVars[gameVar].global) = (int16_t)newValue; break;
|
case GAMEVAR_INT16PTR: *((int16_t *)var.global) = (int16_t)newValue; break;
|
||||||
case GAMEVAR_UINT8PTR: *((uint8_t *)aGameVars[gameVar].global) = (uint8_t)newValue; break;
|
case GAMEVAR_UINT8PTR: *((uint8_t *)var.global) = (uint8_t)newValue; break;
|
||||||
case GAMEVAR_Q16PTR:
|
case GAMEVAR_Q16PTR: *(fix16_t *)var.global = var.flags & GAMEVAR_SPECIAL ? (int32_t)newValue : fix16_from_int((int16_t)newValue);
|
||||||
*(fix16_t *)aGameVars[gameVar].global
|
|
||||||
= aGameVars[gameVar].flags & GAMEVAR_SPECIAL ? (int32_t)newValue : fix16_from_int((int16_t)newValue);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -825,8 +821,8 @@ badvarid:
|
||||||
|
|
||||||
badindex:
|
badindex:
|
||||||
CON_ERRPRINTF("Gv_SetVar(): invalid index (%d) for gamevar %s from sprite %d, player %d\n",
|
CON_ERRPRINTF("Gv_SetVar(): invalid index (%d) for gamevar %s from sprite %d, player %d\n",
|
||||||
aGameVars[gameVar].flags & GAMEVAR_PERACTOR ? spriteNum : playerNum,
|
var.flags & GAMEVAR_PERACTOR ? spriteNum : playerNum,
|
||||||
aGameVars[gameVar].szLabel,vm.spriteNum,vm.playerNum);
|
var.szLabel,vm.spriteNum,vm.playerNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -994,28 +990,24 @@ int __fastcall Gv_GetVarX(int gameVar)
|
||||||
returnValue = Gv_GetSpecialVarX(gameVar);
|
returnValue = Gv_GetSpecialVarX(gameVar);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gameVar &= MAXGAMEVARS-1;
|
gamevar_t &var = aGameVars[gameVar &= MAXGAMEVARS - 1];
|
||||||
|
int const varFlags = var.flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
|
||||||
|
|
||||||
int const varFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
|
if (!varFlags) returnValue = var.global;
|
||||||
|
|
||||||
if (!varFlags) returnValue = aGameVars[gameVar].global;
|
|
||||||
else if (varFlags == GAMEVAR_PERPLAYER)
|
else if (varFlags == GAMEVAR_PERPLAYER)
|
||||||
{
|
{
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned) vm.playerNum >= MAXPLAYERS))
|
if (EDUKE32_PREDICT_FALSE((unsigned) vm.playerNum >= MAXPLAYERS))
|
||||||
goto perr;
|
goto perr;
|
||||||
returnValue = aGameVars[gameVar].pValues[vm.playerNum];
|
returnValue = var.pValues[vm.playerNum];
|
||||||
}
|
}
|
||||||
else if (varFlags == GAMEVAR_PERACTOR)
|
else if (varFlags == GAMEVAR_PERACTOR)
|
||||||
returnValue = aGameVars[gameVar].pValues[vm.spriteNum];
|
returnValue = var.pValues[vm.spriteNum];
|
||||||
else switch (varFlags)
|
else switch (varFlags)
|
||||||
{
|
{
|
||||||
case GAMEVAR_INT32PTR: returnValue = (*(int32_t *)aGameVars[gameVar].global); break;
|
case GAMEVAR_INT32PTR: returnValue = (*(int32_t *)var.global); break;
|
||||||
case GAMEVAR_INT16PTR: returnValue = (*(int16_t *)aGameVars[gameVar].global); break;
|
case GAMEVAR_INT16PTR: returnValue = (*(int16_t *)var.global); break;
|
||||||
case GAMEVAR_UINT8PTR: returnValue = (*(uint8_t *)aGameVars[gameVar].global); break;
|
case GAMEVAR_UINT8PTR: returnValue = (*(uint8_t *)var.global); break;
|
||||||
case GAMEVAR_Q16PTR:
|
case GAMEVAR_Q16PTR: returnValue = var.flags & GAMEVAR_SPECIAL ? *(int32_t *)var.global : fix16_to_int(*(fix16_t *)var.global); break;
|
||||||
returnValue = aGameVars[gameVar].flags & GAMEVAR_SPECIAL ? *(int32_t *)aGameVars[gameVar].global
|
|
||||||
: fix16_to_int(*(fix16_t *)aGameVars[gameVar].global);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1049,30 +1041,28 @@ void __fastcall Gv_GetManyVars(int const numVars, int32_t * const outBuf)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
gameVar &= MAXGAMEVARS - 1;
|
|
||||||
|
|
||||||
int const varFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK);
|
gamevar_t &var = aGameVars[gameVar &= MAXGAMEVARS - 1];
|
||||||
int value = aGameVars[gameVar].global;
|
|
||||||
|
int const varFlags = var.flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK);
|
||||||
|
int value = var.global;
|
||||||
|
|
||||||
if (varFlags == GAMEVAR_PERPLAYER)
|
if (varFlags == GAMEVAR_PERPLAYER)
|
||||||
{
|
{
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= MAXPLAYERS))
|
if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= MAXPLAYERS))
|
||||||
goto perr;
|
goto perr;
|
||||||
value = aGameVars[gameVar].pValues[vm.playerNum];
|
value = var.pValues[vm.playerNum];
|
||||||
}
|
}
|
||||||
else if (varFlags == GAMEVAR_PERACTOR)
|
else if (varFlags == GAMEVAR_PERACTOR)
|
||||||
value = aGameVars[gameVar].pValues[vm.spriteNum];
|
value = var.pValues[vm.spriteNum];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (varFlags)
|
switch (varFlags)
|
||||||
{
|
{
|
||||||
case GAMEVAR_INT32PTR: value = *(int32_t *)aGameVars[gameVar].global; break;
|
case GAMEVAR_INT32PTR: value = *(int32_t *)var.global; break;
|
||||||
case GAMEVAR_INT16PTR: value = *(int16_t *)aGameVars[gameVar].global; break;
|
case GAMEVAR_INT16PTR: value = *(int16_t *)var.global; break;
|
||||||
case GAMEVAR_UINT8PTR: value = *(uint8_t *)aGameVars[gameVar].global; break;
|
case GAMEVAR_UINT8PTR: value = *(uint8_t *)var.global; break;
|
||||||
case GAMEVAR_Q16PTR:
|
case GAMEVAR_Q16PTR: value = var.flags & GAMEVAR_SPECIAL ? *(int32_t *)var.global : fix16_to_int(*(fix16_t *)var.global); break;
|
||||||
value = aGameVars[gameVar].flags & GAMEVAR_SPECIAL ? *(int32_t *)aGameVars[gameVar].global
|
|
||||||
: fix16_to_int(*(fix16_t *)aGameVars[gameVar].global);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1086,36 +1076,34 @@ void __fastcall Gv_GetManyVars(int const numVars, int32_t * const outBuf)
|
||||||
|
|
||||||
void __fastcall Gv_SetVarX(int const gameVar, int const newValue)
|
void __fastcall Gv_SetVarX(int const gameVar, int const newValue)
|
||||||
{
|
{
|
||||||
int const varFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
|
gamevar_t & var = aGameVars[gameVar];
|
||||||
|
int const varFlags = var.flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
|
||||||
|
|
||||||
if (!varFlags) aGameVars[gameVar].global = newValue;
|
if (!varFlags) var.global = newValue;
|
||||||
else if (varFlags == GAMEVAR_PERPLAYER)
|
else if (varFlags == GAMEVAR_PERPLAYER)
|
||||||
{
|
{
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= MAXPLAYERS)) goto badindex;
|
if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= MAXPLAYERS)) goto badindex;
|
||||||
aGameVars[gameVar].pValues[vm.playerNum] = newValue;
|
var.pValues[vm.playerNum] = newValue;
|
||||||
}
|
}
|
||||||
else if (varFlags == GAMEVAR_PERACTOR)
|
else if (varFlags == GAMEVAR_PERACTOR)
|
||||||
{
|
{
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned)vm.spriteNum >= MAXSPRITES)) goto badindex;
|
if (EDUKE32_PREDICT_FALSE((unsigned)vm.spriteNum >= MAXSPRITES)) goto badindex;
|
||||||
aGameVars[gameVar].pValues[vm.spriteNum] = newValue;
|
var.pValues[vm.spriteNum] = newValue;
|
||||||
}
|
}
|
||||||
else switch (varFlags)
|
else switch (varFlags)
|
||||||
{
|
{
|
||||||
case GAMEVAR_INT32PTR: *(int32_t *)aGameVars[gameVar].global = (int32_t)newValue; break;
|
case GAMEVAR_INT32PTR: *(int32_t *)var.global = (int32_t)newValue; break;
|
||||||
case GAMEVAR_INT16PTR: *(int16_t *)aGameVars[gameVar].global = (int16_t)newValue; break;
|
case GAMEVAR_INT16PTR: *(int16_t *)var.global = (int16_t)newValue; break;
|
||||||
case GAMEVAR_UINT8PTR: *(uint8_t *)aGameVars[gameVar].global = (uint8_t)newValue; break;
|
case GAMEVAR_UINT8PTR: *(uint8_t *)var.global = (uint8_t)newValue; break;
|
||||||
case GAMEVAR_Q16PTR:
|
case GAMEVAR_Q16PTR: *(fix16_t *)var.global = var.flags & GAMEVAR_SPECIAL ? (int32_t)newValue : fix16_from_int((int16_t)newValue); break;
|
||||||
*(fix16_t *)aGameVars[gameVar].global
|
|
||||||
= aGameVars[gameVar].flags & GAMEVAR_SPECIAL ? (int32_t)newValue : fix16_from_int((int16_t)newValue);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
badindex:
|
badindex:
|
||||||
CON_ERRPRINTF("Gv_SetVar(): invalid index (%d) for gamevar %s\n",
|
CON_ERRPRINTF("Gv_SetVar(): invalid index (%d) for gamevar %s\n",
|
||||||
aGameVars[gameVar].flags & GAMEVAR_PERACTOR ? vm.spriteNum : vm.playerNum,
|
var.flags & GAMEVAR_PERACTOR ? vm.spriteNum : vm.playerNum,
|
||||||
aGameVars[gameVar].szLabel);
|
var.szLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Gv_GetVarByLabel(const char *szGameLabel, int const defaultValue, int const spriteNum, int const playerNum)
|
int Gv_GetVarByLabel(const char *szGameLabel, int const defaultValue, int const spriteNum, int const playerNum)
|
||||||
|
@ -1131,14 +1119,16 @@ static intptr_t *Gv_GetVarDataPtr(const char *szGameLabel)
|
||||||
if (EDUKE32_PREDICT_FALSE(gameVar < 0))
|
if (EDUKE32_PREDICT_FALSE(gameVar < 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (aGameVars[gameVar].flags & (GAMEVAR_PERACTOR | GAMEVAR_PERPLAYER))
|
gamevar_t & var = aGameVars[gameVar];
|
||||||
|
|
||||||
|
if (var.flags & (GAMEVAR_PERACTOR | GAMEVAR_PERPLAYER))
|
||||||
{
|
{
|
||||||
if (EDUKE32_PREDICT_FALSE(!aGameVars[gameVar].pValues))
|
if (EDUKE32_PREDICT_FALSE(!var.pValues))
|
||||||
CON_ERRPRINTF("Gv_GetVarDataPtr(): INTERNAL ERROR: NULL array !!!\n");
|
CON_ERRPRINTF("Gv_GetVarDataPtr(): INTERNAL ERROR: NULL array !!!\n");
|
||||||
return aGameVars[gameVar].pValues;
|
return var.pValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
return &(aGameVars[gameVar].global);
|
return &(var.global);
|
||||||
}
|
}
|
||||||
#endif // !defined LUNATIC
|
#endif // !defined LUNATIC
|
||||||
|
|
||||||
|
|
|
@ -158,44 +158,48 @@ void Gv_Init(void);
|
||||||
void Gv_FinalizeWeaponDefaults(void);
|
void Gv_FinalizeWeaponDefaults(void);
|
||||||
|
|
||||||
#if !defined LUNATIC
|
#if !defined LUNATIC
|
||||||
#define VM_GAMEVAR_OPERATOR(func, operator) \
|
#define VM_GAMEVAR_OPERATOR(func, operator) \
|
||||||
static FORCE_INLINE void __fastcall func(int const id, int32_t const operand) \
|
static FORCE_INLINE void __fastcall func(int const id, int32_t const operand) \
|
||||||
{ \
|
{ \
|
||||||
switch (aGameVars[id].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) \
|
gamevar_t &var = aGameVars[id]; \
|
||||||
{ \
|
\
|
||||||
default: aGameVars[id].global operator operand; break; \
|
switch (var.flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) \
|
||||||
case GAMEVAR_PERPLAYER: \
|
{ \
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum > MAXPLAYERS - 1)) \
|
default: var.global operator operand; break; \
|
||||||
break; \
|
case GAMEVAR_PERPLAYER: \
|
||||||
aGameVars[id].pValues[vm.playerNum] operator operand; \
|
if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum > MAXPLAYERS - 1)) \
|
||||||
break; \
|
break; \
|
||||||
case GAMEVAR_PERACTOR: \
|
var.pValues[vm.playerNum] operator operand; \
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned)vm.spriteNum > MAXSPRITES - 1)) \
|
break; \
|
||||||
break; \
|
case GAMEVAR_PERACTOR: \
|
||||||
aGameVars[id].pValues[vm.spriteNum] operator operand; \
|
if (EDUKE32_PREDICT_FALSE((unsigned)vm.spriteNum > MAXSPRITES - 1)) \
|
||||||
break; \
|
break; \
|
||||||
case GAMEVAR_INT32PTR: *(int32_t *)aGameVars[id].global operator(int32_t) operand; break; \
|
var.pValues[vm.spriteNum] operator operand; \
|
||||||
case GAMEVAR_INT16PTR: *(int16_t *)aGameVars[id].global operator(int16_t) operand; break; \
|
break; \
|
||||||
case GAMEVAR_UINT8PTR: *(uint8_t *)aGameVars[id].global operator(uint8_t) operand; break; \
|
case GAMEVAR_INT32PTR: *(int32_t *)var.global operator(int32_t) operand; break; \
|
||||||
case GAMEVAR_Q16PTR: \
|
case GAMEVAR_INT16PTR: *(int16_t *)var.global operator(int16_t) operand; break; \
|
||||||
{ \
|
case GAMEVAR_UINT8PTR: *(uint8_t *)var.global operator(uint8_t) operand; break; \
|
||||||
Fix16 *pfix = (Fix16 *)aGameVars[id].global; \
|
case GAMEVAR_Q16PTR: \
|
||||||
*pfix operator(int16_t) operand; \
|
{ \
|
||||||
break; \
|
Fix16 *pfix = (Fix16 *)var.global; \
|
||||||
} \
|
*pfix operator(int16_t) operand; \
|
||||||
} \
|
break; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__arm__) || defined(LIBDIVIDE_ALWAYS)
|
#if defined(__arm__) || defined(LIBDIVIDE_ALWAYS)
|
||||||
static FORCE_INLINE void __fastcall Gv_DivVar(int const id, int32_t const operand)
|
static FORCE_INLINE void __fastcall Gv_DivVar(int const id, int32_t const operand)
|
||||||
{
|
{
|
||||||
if (EDUKE32_PREDICT_FALSE((aGameVars[id].flags & GAMEVAR_PERPLAYER && (unsigned) vm.playerNum > MAXPLAYERS - 1) ||
|
gamevar_t &var = aGameVars[id];
|
||||||
(aGameVars[id].flags & GAMEVAR_PERACTOR && (unsigned) vm.spriteNum > MAXSPRITES - 1)))
|
|
||||||
|
if (EDUKE32_PREDICT_FALSE((var.flags & GAMEVAR_PERPLAYER && (unsigned) vm.playerNum > MAXPLAYERS - 1) ||
|
||||||
|
(var.flags & GAMEVAR_PERACTOR && (unsigned) vm.spriteNum > MAXSPRITES - 1)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static libdivide_s32_t sdiv;
|
static libdivide_s32_t sdiv;
|
||||||
static int32_t lastValue;
|
static int32_t lastValue;
|
||||||
intptr_t *iptr = &aGameVars[id].global;
|
intptr_t *iptr = &var.global;
|
||||||
bool const foundInTable = (unsigned) operand < DIVTABLESIZE;
|
bool const foundInTable = (unsigned) operand < DIVTABLESIZE;
|
||||||
libdivide_s32_t *dptr = foundInTable ? (libdivide_s32_t *) &divtable32[operand] : &sdiv;
|
libdivide_s32_t *dptr = foundInTable ? (libdivide_s32_t *) &divtable32[operand] : &sdiv;
|
||||||
|
|
||||||
|
@ -205,33 +209,33 @@ static FORCE_INLINE void __fastcall Gv_DivVar(int const id, int32_t const operan
|
||||||
sdiv = libdivide_s32_gen((lastValue = operand));
|
sdiv = libdivide_s32_gen((lastValue = operand));
|
||||||
|
|
||||||
skip:
|
skip:
|
||||||
switch (aGameVars[id].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK))
|
switch (var.flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK))
|
||||||
{
|
{
|
||||||
case GAMEVAR_PERPLAYER: iptr = &aGameVars[id].pValues[vm.playerNum];
|
case GAMEVAR_PERPLAYER: iptr = &var.pValues[vm.playerNum];
|
||||||
default: break;
|
default: break;
|
||||||
case GAMEVAR_PERACTOR: iptr = &aGameVars[id].pValues[vm.spriteNum]; break;
|
case GAMEVAR_PERACTOR: iptr = &var.pValues[vm.spriteNum]; break;
|
||||||
case GAMEVAR_INT32PTR:
|
case GAMEVAR_INT32PTR:
|
||||||
{
|
{
|
||||||
int32_t & var = *(int32_t *)aGameVars[id].global;
|
int32_t & value = *(int32_t *)var.global;
|
||||||
var = (int32_t)libdivide_s32_do(var, dptr);
|
value = (int32_t)libdivide_s32_do(value, dptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case GAMEVAR_INT16PTR:
|
case GAMEVAR_INT16PTR:
|
||||||
{
|
{
|
||||||
int16_t & var = *(int16_t *)aGameVars[id].global;
|
int16_t & value = *(int16_t *)var.global;
|
||||||
var = (int16_t)libdivide_s32_do(var, dptr);
|
value = (int16_t)libdivide_s32_do(value, dptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case GAMEVAR_UINT8PTR:
|
case GAMEVAR_UINT8PTR:
|
||||||
{
|
{
|
||||||
uint8_t & var = *(uint8_t *)aGameVars[id].global;
|
uint8_t & value = *(uint8_t *)var.global;
|
||||||
var = (uint8_t)libdivide_s32_do(var, dptr);
|
value = (uint8_t)libdivide_s32_do(value, dptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case GAMEVAR_Q16PTR:
|
case GAMEVAR_Q16PTR:
|
||||||
{
|
{
|
||||||
fix16_t & var = *(fix16_t *)aGameVars[id].global;
|
fix16_t & value = *(fix16_t *)var.global;
|
||||||
var = fix16_div(var, fix16_from_int(operand));
|
value = fix16_div(value, fix16_from_int(operand));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue