fixed some arithmetic

This commit is contained in:
Nikolay Korolev 2020-06-07 15:07:36 +03:00
parent 31569d512c
commit be2291e44c

View File

@ -1552,11 +1552,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
case COMMAND_MULT_INT_LVAR_BY_INT_VAR: case COMMAND_MULT_INT_VAR_BY_INT_LVAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0; return 0;
case COMMAND_MULT_INT_VAR_BY_INT_LVAR: case COMMAND_MULT_INT_LVAR_BY_INT_VAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
@ -1568,11 +1568,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
case COMMAND_MULT_FLOAT_LVAR_BY_FLOAT_VAR: case COMMAND_MULT_FLOAT_VAR_BY_FLOAT_LVAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0; return 0;
case COMMAND_MULT_FLOAT_VAR_BY_FLOAT_LVAR: case COMMAND_MULT_FLOAT_LVAR_BY_FLOAT_VAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
@ -1584,11 +1584,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
case COMMAND_DIV_INT_LVAR_BY_INT_VAR: case COMMAND_DIV_INT_VAR_BY_INT_LVAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0; return 0;
case COMMAND_DIV_INT_VAR_BY_INT_LVAR: case COMMAND_DIV_INT_LVAR_BY_INT_VAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
@ -1600,11 +1600,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
case COMMAND_DIV_FLOAT_LVAR_BY_FLOAT_VAR: case COMMAND_DIV_FLOAT_VAR_BY_FLOAT_LVAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0; return 0;
case COMMAND_DIV_FLOAT_VAR_BY_FLOAT_LVAR: case COMMAND_DIV_FLOAT_LVAR_BY_FLOAT_VAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
@ -1630,11 +1630,19 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
#ifdef FIX_BUGS
case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR:
#else
case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR: case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR:
#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0; return 0;
#ifdef FIX_BUGS
case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR:
#else
case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR: case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR:
#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
@ -1660,11 +1668,19 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
#ifdef FIX_BUGS // in SA it was fixed by reversing their order in enum
case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR:
#else
case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR: case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR:
#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0; return 0;
#ifdef FIX_BUGS
case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR:
#else
case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR: case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR:
#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
@ -1678,13 +1694,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
*ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
} }
case COMMAND_SET_LVAR_INT_TO_VAR_INT: case COMMAND_SET_VAR_INT_TO_LVAR_INT:
{ {
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0; return 0;
} }
case COMMAND_SET_VAR_INT_TO_LVAR_INT: case COMMAND_SET_LVAR_INT_TO_VAR_INT:
{ {
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
@ -1702,13 +1718,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
*ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
} }
case COMMAND_SET_LVAR_FLOAT_TO_VAR_FLOAT: case COMMAND_SET_VAR_FLOAT_TO_LVAR_FLOAT:
{ {
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0; return 0;
} }
case COMMAND_SET_VAR_FLOAT_TO_LVAR_FLOAT: case COMMAND_SET_LVAR_FLOAT_TO_VAR_FLOAT:
{ {
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
@ -1726,13 +1742,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
*ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
} }
case COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT: case COMMAND_CSET_VAR_INT_TO_LVAR_FLOAT:
{ {
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0; return 0;
} }
case COMMAND_CSET_VAR_INT_TO_LVAR_FLOAT: case COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT:
{ {
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
@ -1750,13 +1766,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
*ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0; return 0;
} }
case COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT: case COMMAND_CSET_VAR_FLOAT_TO_LVAR_INT:
{ {
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0; return 0;
} }
case COMMAND_CSET_VAR_FLOAT_TO_LVAR_INT: case COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT:
{ {
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);