Fix sign issues with bswap

This commit is contained in:
GaryOderNichts 2021-08-19 18:58:32 +02:00
parent 912f2eb37f
commit d4ab86a1b8
11 changed files with 179 additions and 175 deletions

View File

@ -1299,13 +1299,13 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*uncompressedA
CAnimBlock *animBlock = GetAnimationBlock(buf+4);
if(animBlock){
if(animBlock->numAnims == 0){
animBlock->numAnims = BSWAP32(*(int*)buf);
animBlock->numAnims = BSWAP_I32(*(int*)buf);
animBlock->firstIndex = ms_numAnimations;
}
}else{
animBlock = &ms_aAnimBlocks[ms_numAnimBlocks++];
strncpy(animBlock->name, buf+4, MAX_ANIMBLOCK_NAME);
animBlock->numAnims = BSWAP32(*(int*)buf);
animBlock->numAnims = BSWAP_I32(*(int*)buf);
animBlock->firstIndex = ms_numAnimations;
}
@ -1349,7 +1349,7 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*uncompressedA
memLittle32(&info.size);
ROUNDSIZE(info.size);
RwStreamRead(stream, buf, info.size);
hier->numSequences = BSWAP32(*(int*)buf);
hier->numSequences = BSWAP_I32(*(int*)buf);
hier->sequences = new CAnimBlendSequence[hier->numSequences];
CAnimBlendSequence *seq = hier->sequences;
@ -1362,10 +1362,10 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*uncompressedA
memLittle32(&anim.size);
ROUNDSIZE(anim.size);
RwStreamRead(stream, buf, anim.size);
int numFrames = BSWAP32(*(int*)(buf+28));
int numFrames = BSWAP_I32(*(int*)(buf+28));
seq->SetName(buf);
if(anim.size == 44)
seq->SetBoneTag(BSWAP32(*(int*)(buf+40)));
seq->SetBoneTag(BSWAP_I32(*(int*)(buf+40)));
if(numFrames == 0)
continue;
@ -1387,53 +1387,53 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*uncompressedA
for(l = 0; l < numFrames; l++){
if(hasScale){
RwStreamRead(stream, buf, 0x2C);
CQuaternion rot(FLOATSWAP32(fbuf[0]), FLOATSWAP32(fbuf[1]), FLOATSWAP32(fbuf[2]), FLOATSWAP32(fbuf[3]));
CQuaternion rot(BSWAP_F32(fbuf[0]), BSWAP_F32(fbuf[1]), BSWAP_F32(fbuf[2]), BSWAP_F32(fbuf[3]));
rot.Invert();
CVector trans(FLOATSWAP32(fbuf[4]), FLOATSWAP32(fbuf[5]), FLOATSWAP32(fbuf[6]));
CVector trans(BSWAP_F32(fbuf[4]), BSWAP_F32(fbuf[5]), BSWAP_F32(fbuf[6]));
if(compressHier){
KeyFrameTransCompressed *kf = (KeyFrameTransCompressed*)seq->GetKeyFrameCompressed(l);
kf->SetRotation(rot);
kf->SetTranslation(trans);
// scaling ignored
kf->SetTime(FLOATSWAP32(fbuf[10])); // absolute time here
kf->SetTime(BSWAP_F32(fbuf[10])); // absolute time here
}else{
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l);
kf->rotation = rot;
kf->translation = trans;
// scaling ignored
kf->deltaTime = FLOATSWAP32(fbuf[10]); // absolute time here
kf->deltaTime = BSWAP_F32(fbuf[10]); // absolute time here
}
}else if(hasTranslation){
RwStreamRead(stream, buf, 0x20);
CQuaternion rot(FLOATSWAP32(fbuf[0]), FLOATSWAP32(fbuf[1]), FLOATSWAP32(fbuf[2]), FLOATSWAP32(fbuf[3]));
CQuaternion rot(BSWAP_F32(fbuf[0]), BSWAP_F32(fbuf[1]), BSWAP_F32(fbuf[2]), BSWAP_F32(fbuf[3]));
rot.Invert();
CVector trans(FLOATSWAP32(fbuf[4]), FLOATSWAP32(fbuf[5]), FLOATSWAP32(fbuf[6]));
CVector trans(BSWAP_F32(fbuf[4]), BSWAP_F32(fbuf[5]), BSWAP_F32(fbuf[6]));
if(compressHier){
KeyFrameTransCompressed *kf = (KeyFrameTransCompressed*)seq->GetKeyFrameCompressed(l);
kf->SetRotation(rot);
kf->SetTranslation(trans);
kf->SetTime(FLOATSWAP32(fbuf[7])); // absolute time here
kf->SetTime(BSWAP_F32(fbuf[7])); // absolute time here
}else{
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(l);
kf->rotation = rot;
kf->translation = trans;
kf->deltaTime = FLOATSWAP32(fbuf[7]); // absolute time here
kf->deltaTime = BSWAP_F32(fbuf[7]); // absolute time here
}
}else{
RwStreamRead(stream, buf, 0x14);
CQuaternion rot(FLOATSWAP32(fbuf[0]), FLOATSWAP32(fbuf[1]), FLOATSWAP32(fbuf[2]), FLOATSWAP32(fbuf[3]));
CQuaternion rot(BSWAP_F32(fbuf[0]), BSWAP_F32(fbuf[1]), BSWAP_F32(fbuf[2]), BSWAP_F32(fbuf[3]));
rot.Invert();
if(compressHier){
KeyFrameCompressed *kf = (KeyFrameCompressed*)seq->GetKeyFrameCompressed(l);
kf->SetRotation(rot);
kf->SetTime(FLOATSWAP32(fbuf[4])); // absolute time here
kf->SetTime(BSWAP_F32(fbuf[4])); // absolute time here
}else{
KeyFrame *kf = (KeyFrame*)seq->GetKeyFrame(l);
kf->rotation = rot;
kf->deltaTime = FLOATSWAP32(fbuf[4]); // absolute time here
kf->deltaTime = BSWAP_F32(fbuf[4]); // absolute time here
}
}
}

View File

@ -187,7 +187,7 @@ void CChannel::SetSampleData(void *_data, size_t _DataSize, int32 freq)
Data = malloc(DataSize);
memcpy(Data, _data, DataSize);
for (int i = 0; i < DataSize / sizeof(uint16); i++) {
((uint16*)Data)[i] = BSWAP16(((uint16*)Data)[i]);
((uint16*)Data)[i] = BSWAP_U16(((uint16*)Data)[i]);
}
#else
Data = _data;

View File

@ -669,7 +669,7 @@ public:
size_t read = drwav_read_raw(&m_drWav, GetBufferSize(), buffer);
#ifdef BIGENDIAN
for (int i = 0; i < GetBufferSize() / sizeof(uint16); i++) {
((uint16*)buffer)[i] = BSWAP16(((uint16*)buffer)[i]);
((uint16*)buffer)[i] = BSWAP_U16(((uint16*)buffer)[i]);
}
#endif
return read;

View File

@ -128,10 +128,10 @@ COnscreenTimerEntry::Process()
return;
int32* timerPtr = CTheScripts::GetPointerToScriptVariable(m_nClockOffset);
int32 oldTime = BSWAP32(*timerPtr);
int32 oldTime = BSWAP_I32(*timerPtr);
if (m_bClockGoingDown) {
int32 newTime = oldTime - int32(CTimer::GetTimeStepInMilliseconds());
*timerPtr = BSWAP32(newTime);
*timerPtr = BSWAP_I32(newTime);
if (newTime < 0) {
*timerPtr = 0;
m_bClockProcessed = 0;
@ -146,13 +146,13 @@ COnscreenTimerEntry::Process()
}
}
else
*timerPtr = oldTime + int32(CTimer::GetTimeStepInMilliseconds());
*timerPtr = BSWAP_I32(oldTime + int32(CTimer::GetTimeStepInMilliseconds()));
}
void
COnscreenTimerEntry::ProcessForDisplayClock()
{
uint32 time = BSWAP32(*CTheScripts::GetPointerToScriptVariable(m_nClockOffset));
uint32 time = BSWAP_U32(*CTheScripts::GetPointerToScriptVariable(m_nClockOffset));
sprintf(m_aClockBuffer, "%02d:%02d", time / 1000 / 60 % 100,
time / 1000 % 60);
}
@ -160,6 +160,6 @@ COnscreenTimerEntry::ProcessForDisplayClock()
void
COnscreenCounterEntry::ProcessForDisplayCounter()
{
uint32 counter = BSWAP32(*CTheScripts::GetPointerToScriptVariable(m_nCounterOffset));
uint32 counter = BSWAP_U32(*CTheScripts::GetPointerToScriptVariable(m_nCounterOffset));
sprintf(m_aCounterBuffer, "%d", counter);
}

View File

@ -2048,7 +2048,7 @@ void CRunningScript::CollectParameters(uint32* pIp, int16 total)
case ARGUMENT_GLOBALVAR:
varIndex = CTheScripts::Read2BytesFromScript(pIp);
script_assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace());
ScriptParams[i] = BSWAP32(*((int32*)&CTheScripts::ScriptSpace[varIndex]));
ScriptParams[i] = BSWAP_I32(*((int32*)&CTheScripts::ScriptSpace[varIndex]));
break;
case ARGUMENT_LOCALVAR:
varIndex = CTheScripts::Read2BytesFromScript(pIp);
@ -2085,7 +2085,7 @@ int CRunningScript::CollectParameterForDebug(char* buf, bool& var)
var = true;
sprintf(tmpstr, " $%d", varIndex / 4);
strcat(buf, tmpstr);
return BSWAP32(*((int32*)&CTheScripts::ScriptSpace[varIndex]));
return BSWAP_I32(*((int32*)&CTheScripts::ScriptSpace[varIndex]));
case ARGUMENT_LOCALVAR:
varIndex = CTheScripts::Read2BytesFromScript(&m_nIp);
script_assert(varIndex >= 0 && varIndex < ARRAY_SIZE(m_anLocalVariables));
@ -2135,7 +2135,7 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip)
case ARGUMENT_INT32:
return CTheScripts::Read4BytesFromScript(pIp);
case ARGUMENT_GLOBALVAR:
return BSWAP32(*((int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)]));
return BSWAP_I32(*((int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)]));
case ARGUMENT_LOCALVAR:
return m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)];
case ARGUMENT_INT8:
@ -2155,7 +2155,7 @@ void CRunningScript::StoreParameters(uint32* pIp, int16 number)
for (int16 i = 0; i < number; i++){
switch (CTheScripts::Read1ByteFromScript(pIp)) {
case ARGUMENT_GLOBALVAR:
*(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)] = BSWAP32(ScriptParams[i]);
*(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)] = BSWAP_I32(ScriptParams[i]);
break;
case ARGUMENT_LOCALVAR:
m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i];
@ -2456,7 +2456,7 @@ CRunningScript* CTheScripts::StartTestScript()
bool CTheScripts::IsPlayerOnAMission()
{
return OnAMissionFlag && BSWAP32(*(int32*)&ScriptSpace[OnAMissionFlag]) == 1;
return OnAMissionFlag && BSWAP_I32(*(int32*)&ScriptSpace[OnAMissionFlag]) == 1;
}
void CRunningScript::Process()
@ -2630,14 +2630,14 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
*ptr = BSWAP32(ScriptParams[0]);
*ptr = BSWAP_I32(ScriptParams[0]);
return 0;
}
case COMMAND_SET_VAR_FLOAT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
*(float*)ptr = FLOATSWAP32(*(float*)&ScriptParams[0]);
*(float*)ptr = BSWAP_F32(*(float*)&ScriptParams[0]);
return 0;
}
case COMMAND_SET_LVAR_INT:
@ -2661,7 +2661,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*ptr += ScriptParams[0];
#else
*ptr = BSWAP32(BSWAP32(*ptr) + ScriptParams[0]);
*ptr = BSWAP_I32(BSWAP_I32(*ptr) + ScriptParams[0]);
#endif
return 0;
}
@ -2672,7 +2672,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*(float*)ptr += *(float*)&ScriptParams[0];
#else
*(float*)ptr = FLOATSWAP32(FLOATSWAP32(*(float*)ptr ) + *(float*)&ScriptParams[0]);
*(float*)ptr = BSWAP_F32(BSWAP_F32(*(float*)ptr ) + *(float*)&ScriptParams[0]);
#endif
return 0;
}
@ -2697,7 +2697,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*ptr -= ScriptParams[0];
#else
*ptr = BSWAP32(BSWAP32(*ptr) - ScriptParams[0]);
*ptr = BSWAP_I32(BSWAP_I32(*ptr) - ScriptParams[0]);
#endif
return 0;
}
@ -2708,7 +2708,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*(float*)ptr -= *(float*)&ScriptParams[0];
#else
*(float*)ptr = FLOATSWAP32(FLOATSWAP32(*(float*)ptr ) - *(float*)&ScriptParams[0]);
*(float*)ptr = BSWAP_F32(BSWAP_F32(*(float*)ptr ) - *(float*)&ScriptParams[0]);
#endif
return 0;
}
@ -2733,7 +2733,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*ptr *= ScriptParams[0];
#else
*ptr = BSWAP32(BSWAP32(*ptr) * ScriptParams[0]);
*ptr = BSWAP_I32(BSWAP_I32(*ptr) * ScriptParams[0]);
#endif
return 0;
}
@ -2744,7 +2744,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*(float*)ptr *= *(float*)&ScriptParams[0];
#else
*(float*)ptr = FLOATSWAP32(FLOATSWAP32(*(float*)ptr ) * *(float*)&ScriptParams[0]);
*(float*)ptr = BSWAP_F32(BSWAP_F32(*(float*)ptr ) * *(float*)&ScriptParams[0]);
#endif
return 0;
}
@ -2769,7 +2769,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*ptr /= ScriptParams[0];
#else
*ptr = BSWAP32(BSWAP32(*ptr) / ScriptParams[0]);
*ptr = BSWAP_I32(BSWAP_I32(*ptr) / ScriptParams[0]);
#endif
return 0;
}
@ -2780,7 +2780,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*(float*)ptr /= *(float*)&ScriptParams[0];
#else
*(float*)ptr = FLOATSWAP32(FLOATSWAP32(*(float*)ptr ) / *(float*)&ScriptParams[0]);
*(float*)ptr = BSWAP_F32(BSWAP_F32(*(float*)ptr ) / *(float*)&ScriptParams[0]);
#endif
return 0;
}
@ -2802,7 +2802,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
UpdateCompareFlag(BSWAP32(*ptr) > ScriptParams[0]);
UpdateCompareFlag(BSWAP_I32(*ptr) > ScriptParams[0]);
return 0;
}
case COMMAND_IS_INT_LVAR_GREATER_THAN_NUMBER:
@ -2816,7 +2816,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(ScriptParams[0] > BSWAP32(*ptr));
UpdateCompareFlag(ScriptParams[0] > BSWAP_I32(*ptr));
return 0;
}
case COMMAND_IS_NUMBER_GREATER_THAN_INT_LVAR:
@ -2830,21 +2830,21 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(BSWAP32(*ptr1) > BSWAP32(*ptr2));
UpdateCompareFlag(BSWAP_I32(*ptr1) > BSWAP_I32(*ptr2));
return 0;
}
case COMMAND_IS_INT_LVAR_GREATER_THAN_INT_VAR:
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(*ptr1 > BSWAP32(*ptr2));
UpdateCompareFlag(*ptr1 > BSWAP_I32(*ptr2));
return 0;
}
case COMMAND_IS_INT_VAR_GREATER_THAN_INT_LVAR:
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
UpdateCompareFlag(BSWAP32(*ptr1) > *ptr2);
UpdateCompareFlag(BSWAP_I32(*ptr1) > *ptr2);
return 0;
}
case COMMAND_IS_INT_LVAR_GREATER_THAN_INT_LVAR:
@ -2858,7 +2858,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
UpdateCompareFlag(FLOATSWAP32(*(float*)ptr) > *(float*)&ScriptParams[0]);
UpdateCompareFlag(BSWAP_F32(*(float*)ptr) > *(float*)&ScriptParams[0]);
return 0;
}
case COMMAND_IS_FLOAT_LVAR_GREATER_THAN_NUMBER:
@ -2872,7 +2872,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(*(float*)&ScriptParams[0] > FLOATSWAP32(*(float*)ptr));
UpdateCompareFlag(*(float*)&ScriptParams[0] > BSWAP_F32(*(float*)ptr));
return 0;
}
case COMMAND_IS_NUMBER_GREATER_THAN_FLOAT_LVAR:
@ -2886,21 +2886,21 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(FLOATSWAP32(*(float*)ptr1) > FLOATSWAP32(*(float*)ptr2));
UpdateCompareFlag(BSWAP_F32(*(float*)ptr1) > BSWAP_F32(*(float*)ptr2));
return 0;
}
case COMMAND_IS_FLOAT_LVAR_GREATER_THAN_FLOAT_VAR:
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(*(float*)ptr1 > FLOATSWAP32(*(float*)ptr2));
UpdateCompareFlag(*(float*)ptr1 > BSWAP_F32(*(float*)ptr2));
return 0;
}
case COMMAND_IS_FLOAT_VAR_GREATER_THAN_FLOAT_LVAR:
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
UpdateCompareFlag(FLOATSWAP32(*(float*)ptr1) > *(float*)ptr2);
UpdateCompareFlag(BSWAP_F32(*(float*)ptr1) > *(float*)ptr2);
return 0;
}
case COMMAND_IS_FLOAT_LVAR_GREATER_THAN_FLOAT_LVAR:
@ -2914,7 +2914,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
UpdateCompareFlag(BSWAP32(*ptr) >= ScriptParams[0]);
UpdateCompareFlag(BSWAP_I32(*ptr) >= ScriptParams[0]);
return 0;
}
case COMMAND_IS_INT_LVAR_GREATER_OR_EQUAL_TO_NUMBER:
@ -2928,7 +2928,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(ScriptParams[0] >= BSWAP32(*ptr));
UpdateCompareFlag(ScriptParams[0] >= BSWAP_I32(*ptr));
return 0;
}
case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_INT_LVAR:
@ -2942,21 +2942,21 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(BSWAP32(*ptr1) >= BSWAP32(*ptr2));
UpdateCompareFlag(BSWAP_I32(*ptr1) >= BSWAP_I32(*ptr2));
return 0;
}
case COMMAND_IS_INT_LVAR_GREATER_OR_EQUAL_TO_INT_VAR:
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(*ptr1 >= BSWAP32(*ptr2));
UpdateCompareFlag(*ptr1 >= BSWAP_I32(*ptr2));
return 0;
}
case COMMAND_IS_INT_VAR_GREATER_OR_EQUAL_TO_INT_LVAR:
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
UpdateCompareFlag(BSWAP32(*ptr1) >= *ptr2);
UpdateCompareFlag(BSWAP_I32(*ptr1) >= *ptr2);
return 0;
}
case COMMAND_IS_INT_LVAR_GREATER_OR_EQUAL_TO_INT_LVAR:
@ -2970,7 +2970,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
UpdateCompareFlag(FLOATSWAP32(*(float*)ptr) >= *(float*)&ScriptParams[0]);
UpdateCompareFlag(BSWAP_F32(*(float*)ptr) >= *(float*)&ScriptParams[0]);
return 0;
}
case COMMAND_IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_NUMBER:
@ -2984,7 +2984,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(*(float*)&ScriptParams[0] >= FLOATSWAP32(*(float*)ptr));
UpdateCompareFlag(*(float*)&ScriptParams[0] >= BSWAP_F32(*(float*)ptr));
return 0;
}
case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_LVAR:
@ -2998,21 +2998,21 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(FLOATSWAP32(*(float*)ptr1) >= FLOATSWAP32(*(float*)ptr2));
UpdateCompareFlag(BSWAP_F32(*(float*)ptr1) >= BSWAP_F32(*(float*)ptr2));
return 0;
}
case COMMAND_IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_FLOAT_VAR:
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(*(float*)ptr1 >= FLOATSWAP32(*(float*)ptr2));
UpdateCompareFlag(*(float*)ptr1 >= BSWAP_F32(*(float*)ptr2));
return 0;
}
case COMMAND_IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_FLOAT_LVAR:
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
UpdateCompareFlag(FLOATSWAP32(*(float*)ptr1) >= *(float*)ptr2);
UpdateCompareFlag(BSWAP_F32(*(float*)ptr1) >= *(float*)ptr2);
return 0;
}
case COMMAND_IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_FLOAT_LVAR:
@ -3026,7 +3026,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
UpdateCompareFlag(BSWAP32(*ptr) == ScriptParams[0]);
UpdateCompareFlag(BSWAP_I32(*ptr) == ScriptParams[0]);
return 0;
}
case COMMAND_IS_INT_LVAR_EQUAL_TO_NUMBER:
@ -3040,14 +3040,14 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(BSWAP32(*ptr1) == BSWAP32(*ptr2));
UpdateCompareFlag(BSWAP_I32(*ptr1) == BSWAP_I32(*ptr2));
return 0;
}
case COMMAND_IS_INT_VAR_EQUAL_TO_INT_LVAR:
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
UpdateCompareFlag(BSWAP32(*ptr1) == *ptr2);
UpdateCompareFlag(BSWAP_I32(*ptr1) == *ptr2);
return 0;
}
case COMMAND_IS_INT_LVAR_EQUAL_TO_INT_LVAR:
@ -3066,7 +3066,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
UpdateCompareFlag(FLOATSWAP32(*(float*)ptr) == *(float*)&ScriptParams[0]);
UpdateCompareFlag(BSWAP_F32(*(float*)ptr) == *(float*)&ScriptParams[0]);
return 0;
}
case COMMAND_IS_FLOAT_LVAR_EQUAL_TO_NUMBER:
@ -3080,14 +3080,14 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(FLOATSWAP32(*(float*)ptr1) == FLOATSWAP32(*(float*)ptr2));
UpdateCompareFlag(BSWAP_F32(*(float*)ptr1) == BSWAP_F32(*(float*)ptr2));
return 0;
}
case COMMAND_IS_FLOAT_VAR_EQUAL_TO_FLOAT_LVAR:
{
int32* ptr1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
int32* ptr2 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
UpdateCompareFlag(FLOATSWAP32(*(float*)ptr1) == *(float*)ptr2);
UpdateCompareFlag(BSWAP_F32(*(float*)ptr1) == *(float*)ptr2);
return 0;
}
case COMMAND_IS_FLOAT_LVAR_EQUAL_TO_FLOAT_LVAR:
@ -3152,7 +3152,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
pNew->m_anLocalVariables[i] = *(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(&m_nIp)];
#else
pNew->m_anLocalVariables[i] = BSWAP32(*(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(&m_nIp)]);
pNew->m_anLocalVariables[i] = BSWAP_I32(*(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(&m_nIp)]);
#endif
break;
case ARGUMENT_LOCALVAR:
@ -3320,7 +3320,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*nScriptVar1 += *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
#else
*nScriptVar1 = BSWAP32(BSWAP32(*nScriptVar1) + BSWAP32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
*nScriptVar1 = BSWAP_I32(BSWAP_I32(*nScriptVar1) + BSWAP_I32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
#endif
return 0;
case COMMAND_ADD_INT_LVAR_TO_INT_VAR:
@ -3328,12 +3328,12 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*nScriptVar1 += *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
#else
*nScriptVar1 = BSWAP32(BSWAP32(*nScriptVar1) + *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
*nScriptVar1 = BSWAP_I32(BSWAP_I32(*nScriptVar1) + *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
#endif
return 0;
case COMMAND_ADD_INT_VAR_TO_INT_LVAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*nScriptVar1 += BSWAP32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*nScriptVar1 += BSWAP_I32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
case COMMAND_ADD_INT_LVAR_TO_INT_LVAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
@ -3344,7 +3344,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*fScriptVar1 += *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
#else
*fScriptVar1 = FLOATSWAP32(FLOATSWAP32(*fScriptVar1) + FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
*fScriptVar1 = BSWAP_F32(BSWAP_F32(*fScriptVar1) + BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
#endif
return 0;
case COMMAND_ADD_FLOAT_LVAR_TO_FLOAT_VAR:
@ -3352,12 +3352,12 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*fScriptVar1 += *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
#else
*fScriptVar1 = FLOATSWAP32(FLOATSWAP32(*fScriptVar1) + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
*fScriptVar1 = BSWAP_F32(BSWAP_F32(*fScriptVar1) + *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
#endif
return 0;
case COMMAND_ADD_FLOAT_VAR_TO_FLOAT_LVAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 += FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*fScriptVar1 += BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
case COMMAND_ADD_FLOAT_LVAR_TO_FLOAT_LVAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
@ -3368,7 +3368,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*nScriptVar1 -= GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
#else
*nScriptVar1 = BSWAP32(BSWAP32(*nScriptVar1) - BSWAP32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
*nScriptVar1 = BSWAP_I32(BSWAP_I32(*nScriptVar1) - BSWAP_I32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
#endif
return 0;
case COMMAND_SUB_INT_LVAR_FROM_INT_LVAR:
@ -3380,7 +3380,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
#ifndef BIGENDIAN
*fScriptVar1 -= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
#else
*fScriptVar1 = FLOATSWAP32(FLOATSWAP32(*fScriptVar1) - FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
*fScriptVar1 = BSWAP_F32(BSWAP_F32(*fScriptVar1) - BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
#endif
return 0;
case COMMAND_SUB_FLOAT_LVAR_FROM_FLOAT_LVAR:
@ -3404,31 +3404,31 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*nScriptVar1 -= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
#else
*nScriptVar1 = BSWAP32(BSWAP32(*nScriptVar1) - *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
*nScriptVar1 = BSWAP_I32(BSWAP_I32(*nScriptVar1) - *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
#endif
return 0;
case COMMAND_SUB_INT_VAR_FROM_INT_LVAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*nScriptVar1 -= BSWAP32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*nScriptVar1 -= BSWAP_I32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
case COMMAND_SUB_FLOAT_LVAR_FROM_FLOAT_VAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
#ifndef BIGENDIAN
*fScriptVar1 -= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
#else
*fScriptVar1 = FLOATSWAP32(FLOATSWAP32(*fScriptVar1) - *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
*fScriptVar1 = BSWAP_F32(BSWAP_F32(*fScriptVar1) - *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
#endif
return 0;
case COMMAND_SUB_FLOAT_VAR_FROM_FLOAT_LVAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 -= FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*fScriptVar1 -= BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
case COMMAND_MULT_INT_VAR_BY_INT_VAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
#ifndef BIGENDIAN
*nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
#else
*nScriptVar1 = BSWAP32(BSWAP32(*nScriptVar1) * BSWAP32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
*nScriptVar1 = BSWAP_I32(BSWAP_I32(*nScriptVar1) * BSWAP_I32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
#endif
return 0;
case COMMAND_MULT_INT_VAR_BY_INT_LVAR:
@ -3436,12 +3436,12 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
#else
*nScriptVar1 = BSWAP32(BSWAP32(*nScriptVar1) * *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
*nScriptVar1 = BSWAP_I32(BSWAP_I32(*nScriptVar1) * *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
#endif
return 0;
case COMMAND_MULT_INT_LVAR_BY_INT_VAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*nScriptVar1 *= BSWAP32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*nScriptVar1 *= BSWAP_I32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
case COMMAND_MULT_INT_LVAR_BY_INT_LVAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
@ -3452,7 +3452,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
#else
*fScriptVar1 = FLOATSWAP32(FLOATSWAP32(*fScriptVar1) * FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
*fScriptVar1 = BSWAP_F32(BSWAP_F32(*fScriptVar1) * BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
#endif
return 0;
case COMMAND_MULT_FLOAT_VAR_BY_FLOAT_LVAR:
@ -3460,12 +3460,12 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
#else
*fScriptVar1 = FLOATSWAP32(FLOATSWAP32(*fScriptVar1) * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
*fScriptVar1 = BSWAP_F32(BSWAP_F32(*fScriptVar1) * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
#endif
return 0;
case COMMAND_MULT_FLOAT_LVAR_BY_FLOAT_VAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 *= FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*fScriptVar1 *= BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
case COMMAND_MULT_FLOAT_LVAR_BY_FLOAT_LVAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
@ -3476,7 +3476,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
#else
*nScriptVar1 = BSWAP32(BSWAP32(*nScriptVar1) / BSWAP32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
*nScriptVar1 = BSWAP_I32(BSWAP_I32(*nScriptVar1) / BSWAP_I32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
#endif
return 0;
case COMMAND_DIV_INT_VAR_BY_INT_LVAR:
@ -3484,12 +3484,12 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
#else
*nScriptVar1 = BSWAP32(BSWAP32(*nScriptVar1) / *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
*nScriptVar1 = BSWAP_I32(BSWAP_I32(*nScriptVar1) / *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
#endif
return 0;
case COMMAND_DIV_INT_LVAR_BY_INT_VAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*nScriptVar1 /= BSWAP32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*nScriptVar1 /= BSWAP_I32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
case COMMAND_DIV_INT_LVAR_BY_INT_LVAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
@ -3500,7 +3500,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
#else
*fScriptVar1 = FLOATSWAP32(FLOATSWAP32(*fScriptVar1) / FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
*fScriptVar1 = BSWAP_F32(BSWAP_F32(*fScriptVar1) / BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL)));
#endif
return 0;
case COMMAND_DIV_FLOAT_VAR_BY_FLOAT_LVAR:
@ -3508,12 +3508,12 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
#else
*fScriptVar1 = FLOATSWAP32(FLOATSWAP32(*fScriptVar1) / *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
*fScriptVar1 = BSWAP_F32(BSWAP_F32(*fScriptVar1) / *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
#endif
return 0;
case COMMAND_DIV_FLOAT_LVAR_BY_FLOAT_VAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 /= FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*fScriptVar1 /= BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
case COMMAND_DIV_FLOAT_LVAR_BY_FLOAT_LVAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
@ -3526,7 +3526,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*(float*)ptr += CTimer::GetTimeStep() * *(float*)&ScriptParams[0];
#else
*(float*)ptr = FLOATSWAP32(FLOATSWAP32(*(float*)ptr) + (CTimer::GetTimeStep() * *(float*)&ScriptParams[0]));
*(float*)ptr = BSWAP_F32(BSWAP_F32(*(float*)ptr) + (CTimer::GetTimeStep() * *(float*)&ScriptParams[0]));
#endif
return 0;
}
@ -3542,7 +3542,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
#else
*fScriptVar1 = FLOATSWAP32(FLOATSWAP32(*fScriptVar1) + (CTimer::GetTimeStep() * FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL))));
*fScriptVar1 = BSWAP_F32(BSWAP_F32(*fScriptVar1) + (CTimer::GetTimeStep() * BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL))));
#endif
return 0;
#ifdef FIX_BUGS
@ -3554,7 +3554,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
#else
*fScriptVar1 = FLOATSWAP32(FLOATSWAP32(*fScriptVar1) + (CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL)));
*fScriptVar1 = BSWAP_F32(BSWAP_F32(*fScriptVar1) + (CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL)));
#endif
return 0;
#ifdef FIX_BUGS
@ -3563,7 +3563,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR:
#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 += CTimer::GetTimeStep() * FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*fScriptVar1 += CTimer::GetTimeStep() * BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_LVAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
@ -3576,7 +3576,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*(float*)ptr -= CTimer::GetTimeStep() * *(float*)&ScriptParams[0];
#else
*(float*)ptr = FLOATSWAP32(FLOATSWAP32(*(float*)ptr) - (CTimer::GetTimeStep() * *(float*)&ScriptParams[0]));
*(float*)ptr = BSWAP_F32(BSWAP_F32(*(float*)ptr) - (CTimer::GetTimeStep() * *(float*)&ScriptParams[0]));
#endif
return 0;
}
@ -3592,7 +3592,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
#else
*fScriptVar1 = FLOATSWAP32(FLOATSWAP32(*fScriptVar1) - (CTimer::GetTimeStep() * FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL))));
*fScriptVar1 = BSWAP_F32(BSWAP_F32(*fScriptVar1) - (CTimer::GetTimeStep() * BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL))));
#endif
return 0;
#ifdef FIX_BUGS // in SA it was fixed by reversing their order in enum
@ -3604,7 +3604,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
#ifndef BIGENDIAN
*fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
#else
*fScriptVar1 = FLOATSWAP32(FLOATSWAP32(*fScriptVar1) - (CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL)));
*fScriptVar1 = BSWAP_F32(BSWAP_F32(*fScriptVar1) - (CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL)));
#endif
return 0;
#ifdef FIX_BUGS
@ -3613,7 +3613,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR:
#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 -= CTimer::GetTimeStep() * FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*fScriptVar1 -= CTimer::GetTimeStep() * BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_LVAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
@ -3628,13 +3628,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_SET_VAR_INT_TO_LVAR_INT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = BSWAP32(*GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
*ptr = BSWAP_I32(*GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
return 0;
}
case COMMAND_SET_LVAR_INT_TO_VAR_INT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = BSWAP32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*ptr = BSWAP_I32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
}
case COMMAND_SET_LVAR_INT_TO_LVAR_INT:
@ -3652,13 +3652,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_SET_VAR_FLOAT_TO_LVAR_FLOAT:
{
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
*ptr = BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL));
return 0;
}
case COMMAND_SET_LVAR_FLOAT_TO_VAR_FLOAT:
{
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*ptr = BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
}
case COMMAND_SET_LVAR_FLOAT_TO_LVAR_FLOAT:
@ -3670,21 +3670,21 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_CSET_VAR_INT_TO_VAR_FLOAT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*ptr = BSWAP32(*ptr);
*ptr = BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*ptr = BSWAP_I32(*ptr);
return 0;
}
case COMMAND_CSET_VAR_INT_TO_LVAR_FLOAT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = BSWAP32(*ptr);
*ptr = BSWAP_I32(*ptr);
return 0;
}
case COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = FLOATSWAP32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*ptr = BSWAP_F32(*(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
}
case COMMAND_CSET_LVAR_INT_TO_LVAR_FLOAT:
@ -3696,21 +3696,21 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_CSET_VAR_FLOAT_TO_VAR_INT:
{
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = BSWAP32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*ptr = FLOATSWAP32(*ptr);
*ptr = BSWAP_I32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*ptr = BSWAP_F32(*ptr);
return 0;
}
case COMMAND_CSET_VAR_FLOAT_TO_LVAR_INT:
{
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = FLOATSWAP32(*ptr);
*ptr = BSWAP_F32(*ptr);
return 0;
}
case COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT:
{
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = BSWAP32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
*ptr = BSWAP_I32(*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL));
return 0;
}
case COMMAND_CSET_LVAR_FLOAT_TO_LVAR_INT:
@ -3722,7 +3722,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_ABS_VAR_INT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = BSWAP32(ABS(BSWAP32(*ptr)));
*ptr = BSWAP_I32(ABS(BSWAP_I32(*ptr)));
return 0;
}
case COMMAND_ABS_LVAR_INT:
@ -3734,7 +3734,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_ABS_VAR_FLOAT:
{
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = FLOATSWAP32(ABS(FLOATSWAP32(*ptr)));
*ptr = BSWAP_F32(ABS(BSWAP_F32(*ptr)));
return 0;
}
case COMMAND_ABS_LVAR_FLOAT:
@ -3750,16 +3750,16 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
CGeneral::GetRandomNumber();
CGeneral::GetRandomNumber(); /* To make it EXTRA random! */
#ifdef FIX_BUGS
*ptr = FLOATSWAP32(CGeneral::GetRandomNumberInRange(0.0f, 1.0f));
*ptr = BSWAP_F32(CGeneral::GetRandomNumberInRange(0.0f, 1.0f));
#else
*ptr = FLOATSWAP32(CGeneral::GetRandomNumber() / 65536.0f);
*ptr = BSWAP_F32(CGeneral::GetRandomNumber() / 65536.0f);
/* Between 0 and 0.5 on PC (oh well...), never used in original script. */
#endif
return 0;
}
case COMMAND_GENERATE_RANDOM_INT:
*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) = BSWAP32(CGeneral::GetRandomNumber());
*GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) = BSWAP_I32(CGeneral::GetRandomNumber());
return 0;
case COMMAND_CREATE_CHAR:
{

View File

@ -1696,7 +1696,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
UpdateCompareFlag(BSWAP32(*ptr) == ScriptParams[0]);
UpdateCompareFlag(BSWAP_I32(*ptr) == ScriptParams[0]);
return 0;
}
case COMMAND_IS_INT_LVAR_EQUAL_TO_CONSTANT:
@ -1786,7 +1786,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
*ptr = BSWAP32(ScriptParams[0]);
*ptr = BSWAP_I32(ScriptParams[0]);
return 0;
}
case COMMAND_SET_LVAR_INT_TO_CONSTANT:

View File

@ -38,7 +38,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
UpdateCompareFlag(BSWAP32(*ptr) > ScriptParams[0]);
UpdateCompareFlag(BSWAP_I32(*ptr) > ScriptParams[0]);
return 0;
}
case COMMAND_IS_INT_LVAR_GREATER_THAN_CONSTANT:
@ -52,7 +52,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(ScriptParams[0] > BSWAP32(*ptr));
UpdateCompareFlag(ScriptParams[0] > BSWAP_I32(*ptr));
return 0;
}
case COMMAND_IS_CONSTANT_GREATER_THAN_INT_LVAR:
@ -66,7 +66,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
UpdateCompareFlag(BSWAP32(*ptr) >= ScriptParams[0]);
UpdateCompareFlag(BSWAP_I32(*ptr) >= ScriptParams[0]);
return 0;
}
case COMMAND_IS_INT_LVAR_GREATER_OR_EQUAL_TO_CONSTANT:
@ -80,7 +80,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
UpdateCompareFlag(ScriptParams[0] >= BSWAP32(*ptr));
UpdateCompareFlag(ScriptParams[0] >= BSWAP_I32(*ptr));
return 0;
}
case COMMAND_IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_LVAR:

View File

@ -230,7 +230,7 @@ CFileLoader::LoadCollisionFileFirstTime(uint8 *buffer, uint32 size, uint8 colSlo
while(size > 8){
header = (ColHeader*)buffer;
modelsize = BSWAP32(header->size);
modelsize = BSWAP_U32(header->size);
#ifdef BIGENDIAN
if(header->ident != 'COLL')
#else
@ -268,7 +268,7 @@ CFileLoader::LoadCollisionFile(uint8 *buffer, uint32 size, uint8 colSlot)
while(size > 8){
header = (ColHeader*)buffer;
modelsize = BSWAP32(header->size);
modelsize = BSWAP_U32(header->size);
#ifdef BIGENDIAN
if(header->ident != 'COLL')
#else
@ -304,17 +304,17 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
{
int i;
model.boundingSphere.radius = FLOATSWAP32(*(float*)(buf));
model.boundingSphere.center.x = FLOATSWAP32(*(float*)(buf+4));
model.boundingSphere.center.y = FLOATSWAP32(*(float*)(buf+8));
model.boundingSphere.center.z = FLOATSWAP32(*(float*)(buf+12));
model.boundingBox.min.x = FLOATSWAP32(*(float*)(buf+16));
model.boundingBox.min.y = FLOATSWAP32(*(float*)(buf+20));
model.boundingBox.min.z = FLOATSWAP32(*(float*)(buf+24));
model.boundingBox.max.x = FLOATSWAP32(*(float*)(buf+28));
model.boundingBox.max.y = FLOATSWAP32(*(float*)(buf+32));
model.boundingBox.max.z = FLOATSWAP32(*(float*)(buf+36));
model.numSpheres = (int16) BSWAP16(*(uint16*)(buf+40));
model.boundingSphere.radius = BSWAP_F32(*(float*)(buf));
model.boundingSphere.center.x = BSWAP_F32(*(float*)(buf+4));
model.boundingSphere.center.y = BSWAP_F32(*(float*)(buf+8));
model.boundingSphere.center.z = BSWAP_F32(*(float*)(buf+12));
model.boundingBox.min.x = BSWAP_F32(*(float*)(buf+16));
model.boundingBox.min.y = BSWAP_F32(*(float*)(buf+20));
model.boundingBox.min.z = BSWAP_F32(*(float*)(buf+24));
model.boundingBox.max.x = BSWAP_F32(*(float*)(buf+28));
model.boundingBox.max.y = BSWAP_F32(*(float*)(buf+32));
model.boundingBox.max.z = BSWAP_F32(*(float*)(buf+36));
model.numSpheres = BSWAP_I16(*(uint16*)(buf+40));
buf += 44;
if(model.numSpheres > 0){
model.spheres = (CColSphere*)RwMalloc(model.numSpheres*sizeof(CColSphere));
@ -323,11 +323,11 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
#ifndef BIGENDIAN
model.spheres[i].Set(*(float*)buf, *(CVector*)(buf+4), buf[16], buf[17]);
#else
float radius = FLOATSWAP32(*(float*)buf);
float radius = BSWAP_F32(*(float*)buf);
CVector center = *(CVector*)(buf+4);
center.x = FLOATSWAP32(center.x);
center.y = FLOATSWAP32(center.y);
center.z = FLOATSWAP32(center.z);
center.x = BSWAP_F32(center.x);
center.y = BSWAP_F32(center.y);
center.z = BSWAP_F32(center.z);
model.spheres[i].Set(radius, center, buf[16], buf[17]);
#endif
buf += 20;
@ -335,7 +335,7 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
}else
model.spheres = nil;
model.numLines = (int16) BSWAP16(*(uint16*)buf);
model.numLines = BSWAP_I16(*(uint16*)buf);
buf += 4;
if(model.numLines > 0){
//model.lines = (CColLine*)RwMalloc(model.numLines*sizeof(CColLine));
@ -349,7 +349,7 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
model.numLines = 0;
model.lines = nil;
model.numBoxes = (int16) BSWAP16(*(uint16*)buf);
model.numBoxes = BSWAP_I16(*(uint16*)buf);
buf += 4;
if(model.numBoxes > 0){
model.boxes = (CColBox*)RwMalloc(model.numBoxes*sizeof(CColBox));
@ -359,13 +359,13 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
model.boxes[i].Set(*(CVector*)buf, *(CVector*)(buf+12), buf[24], buf[25]);
#else
CVector min = *(CVector*)buf;
min.x = FLOATSWAP32(min.x);
min.y = FLOATSWAP32(min.y);
min.z = FLOATSWAP32(min.z);
min.x = BSWAP_F32(min.x);
min.y = BSWAP_F32(min.y);
min.z = BSWAP_F32(min.z);
CVector max = *(CVector*)(buf+12);
max.x = FLOATSWAP32(max.x);
max.y = FLOATSWAP32(max.y);
max.z = FLOATSWAP32(max.z);
max.x = BSWAP_F32(max.x);
max.y = BSWAP_F32(max.y);
max.z = BSWAP_F32(max.z);
model.boxes[i].Set(min, max, buf[24], buf[25]);
#endif
buf += 28;
@ -373,7 +373,7 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
}else
model.boxes = nil;
int32 numVertices = (int16) BSWAP16(*(uint16*)buf);
int32 numVertices = BSWAP_I16(*(uint16*)buf);
buf += 4;
if(numVertices > 0){
model.vertices = (CompressedVector*)RwMalloc(numVertices*sizeof(CompressedVector));
@ -382,9 +382,9 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
#ifndef BIGENDIAN
model.vertices[i].Set(*(float*)buf, *(float*)(buf+4), *(float*)(buf+8));
#else
float x = FLOATSWAP32(*(float*)buf);
float y = FLOATSWAP32(*(float*)(buf+4));
float z = FLOATSWAP32(*(float*)(buf+8));
float x = BSWAP_F32(*(float*)buf);
float y = BSWAP_F32(*(float*)(buf+4));
float z = BSWAP_F32(*(float*)(buf+8));
model.vertices[i].Set(x, y, z);
#endif
#if 0
@ -398,7 +398,7 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
}else
model.vertices = nil;
model.numTriangles = (int16) BSWAP16(*(uint16*)buf);
model.numTriangles = BSWAP_I16(*(uint16*)buf);
buf += 4;
if(model.numTriangles > 0){
model.triangles = (CColTriangle*)RwMalloc(model.numTriangles*sizeof(CColTriangle));
@ -407,9 +407,9 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
#ifndef BIGENDIAN
model.triangles[i].Set(*(int32*)buf, *(int32*)(buf+4), *(int32*)(buf+8), buf[12]);
#else
int32 a = (int32) BSWAP32(*(uint32*)buf);
int32 b = (int32) BSWAP32(*(uint32*)(buf+4));
int32 c = (int32) BSWAP32(*(uint32*)(buf+8));
int32 a = BSWAP_I32(*(uint32*)buf);
int32 b = BSWAP_I32(*(uint32*)(buf+4));
int32 c = BSWAP_I32(*(uint32*)(buf+8));
model.triangles[i].Set(a, b, c, buf[12]);
#endif
buf += 16;

View File

@ -107,31 +107,35 @@ typedef uint16 bool16;
typedef uint32 bool32;
#ifdef BIGENDIAN
#define BSWAP32(x) __builtin_bswap32(x)
#define BSWAP16(x) __builtin_bswap16(x)
#define BSWAP_U32(x) __builtin_bswap32(x)
#define BSWAP_I32(x) ((int32_t) __builtin_bswap32(x))
#define BSWAP_U16(x) __builtin_bswap16(x)
#define BSWAP_I16(x) ((int16_t) __builtin_bswap16(x))
inline float _floatswap32(float f)
{
uint32 _swapval = BSWAP32(*(uint32*)&f);
uint32 _swapval = BSWAP_U32(*(uint32*)&f);
return *(float*)&_swapval;
}
#define FLOATSWAP32(x) _floatswap32(x)
#define BSWAP_F32(x) _floatswap32(x)
inline void _memLittle32(void* val)
{
*(uint32*)val = BSWAP32(*(uint32*)val);
*(uint32*)val = BSWAP_U32(*(uint32*)val);
}
#define memLittle32(val) _memLittle32(val)
inline void _memLittle16(void* val)
{
*(uint16*)val = BSWAP16(*(uint16*)val);
*(uint16*)val = BSWAP_U16(*(uint16*)val);
}
#define memLittle16(val) _memLittle16(val)
#else
#define BSWAP32(x) (x)
#define BSWAP16(x) (x)
#define FLOATSWAP32(x) (x)
#define BSWAP_U32(x) (x)
#define BSWAP_I32(x) (x)
#define BSWAP_U16(x) (x)
#define BSWAP_I16(x) (x)
#define BSWAP_F32(x) (x)
#define memLittle32(val)
#define memLittle16(val)
#endif

View File

@ -141,14 +141,14 @@ CWaterLevel::Initialise(Const char *pWaterDat)
#ifdef BIGENDIAN
memLittle32(&ms_nNoOfWaterLevels);
for (int i = 0; i < 48; i++)
ms_aWaterZs[i] = FLOATSWAP32(ms_aWaterZs[i]);
ms_aWaterZs[i] = BSWAP_F32(ms_aWaterZs[i]);
for (int i = 0; i < 48; i++)
{
CRect* r = &ms_aWaterRects[i];
r->left = FLOATSWAP32(r->left);
r->bottom = FLOATSWAP32(r->bottom);
r->right = FLOATSWAP32(r->right);
r->top = FLOATSWAP32(r->top);
r->left = BSWAP_F32(r->left);
r->bottom = BSWAP_F32(r->bottom);
r->right = BSWAP_F32(r->right);
r->top = BSWAP_F32(r->top);
}
#endif
}
@ -276,16 +276,16 @@ CWaterLevel::Initialise(Const char *pWaterDat)
if (hFile > 0)
{
#ifdef BIGENDIAN
ms_nNoOfWaterLevels = BSWAP32(ms_nNoOfWaterLevels);
ms_nNoOfWaterLevels = BSWAP_I32(ms_nNoOfWaterLevels);
for (int i = 0; i < 48; i++)
ms_aWaterZs[i] = FLOATSWAP32(ms_aWaterZs[i]);
ms_aWaterZs[i] = BSWAP_F32(ms_aWaterZs[i]);
for (int i = 0; i < 48; i++)
{
CRect* r = &ms_aWaterRects[i];
r->left = FLOATSWAP32(r->left);
r->bottom = FLOATSWAP32(r->bottom);
r->right = FLOATSWAP32(r->right);
r->top = FLOATSWAP32(r->top);
r->left = BSWAP_F32(r->left);
r->bottom = BSWAP_F32(r->bottom);
r->right = BSWAP_F32(r->right);
r->top = BSWAP_F32(r->top);
}
#endif
CFileMgr::Write(hFile, (char *)&ms_nNoOfWaterLevels, sizeof(ms_nNoOfWaterLevels));

View File

@ -471,8 +471,8 @@ CreateTxdImageForVideoCard()
dirInfo.size = size;
#else
// Save as little endian for consistancy
dirInfo.offset = BSWAP32(pos / CDSTREAM_SECTOR_SIZE);
dirInfo.size = BSWAP32(size);
dirInfo.offset = BSWAP_U32(pos / CDSTREAM_SECTOR_SIZE);
dirInfo.size = BSWAP_U32(size);
#endif
strncpy(dirInfo.name, filename, sizeof(dirInfo.name));
pDir->AddItem(dirInfo);