diff options
Diffstat (limited to 'src/control')
-rw-r--r-- | src/control/OnscreenTimer.cpp | 16 | ||||
-rw-r--r-- | src/control/Script.cpp | 1276 | ||||
-rw-r--r-- | src/control/Script.h | 333 |
3 files changed, 1201 insertions, 424 deletions
diff --git a/src/control/OnscreenTimer.cpp b/src/control/OnscreenTimer.cpp index 1677df06..5406522c 100644 --- a/src/control/OnscreenTimer.cpp +++ b/src/control/OnscreenTimer.cpp @@ -106,18 +106,18 @@ void COnscreenTimerEntry::Process() { return; } - uint32* timerPtr = (uint32*)&CTheScripts::ScriptSpace[m_nTimerOffset]; - uint32 oldTime = *timerPtr; - int32 newTime = int32(oldTime - uint32(20.0f * CTimer::GetTimeStep())); + int32* timerPtr = CTheScripts::GetPointerToScriptVariable(m_nTimerOffset); + int32 oldTime = *timerPtr; + int32 newTime = oldTime - int32(CTimer::GetTimeStepInSeconds() * 1000); if(newTime < 0) { *timerPtr = 0; m_bTimerProcessed = 0; m_nTimerOffset = 0; m_aTimerText[0] = 0; } else { - *timerPtr = (uint32)newTime; - uint32 oldTimeSeconds = oldTime / 1000; - if(oldTimeSeconds <= 11 && newTime / 1000 != oldTimeSeconds) { + *timerPtr = newTime; + int32 oldTimeSeconds = oldTime / 1000; + if(oldTimeSeconds < 12 && newTime / 1000 != oldTimeSeconds) { DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, newTime / 1000); } } @@ -144,13 +144,13 @@ bool COnscreenTimerEntry::ProcessForDisplay() { } void COnscreenTimerEntry::ProcessForDisplayClock() { - uint32 time = *(uint32*)&CTheScripts::ScriptSpace[m_nTimerOffset]; + uint32 time = *CTheScripts::GetPointerToScriptVariable(m_nTimerOffset); sprintf(m_bTimerBuffer, "%02d:%02d", time / 1000 / 60, time / 1000 % 60); } void COnscreenTimerEntry::ProcessForDisplayCounter() { - uint32 counter = *(uint32*)&CTheScripts::ScriptSpace[m_nCounterOffset]; + uint32 counter = *CTheScripts::GetPointerToScriptVariable(m_nCounterOffset); sprintf(m_bCounterBuffer, "%d", counter); } diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 3d8807d8..3e4c7e8f 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -75,10 +75,10 @@ #define SPHERE_MARKER_PULSE_FRACTION 0.1f #ifdef USE_PRECISE_MEASUREMENT_CONVERTION -#define METERS_IN_FEET 0.3048f +#define METERS_IN_FOOT 0.3048f #define FEET_IN_METER 3.28084f #else -#define METERS_IN_FEET 0.3f +#define METERS_IN_FOOT 0.3f #define FEET_IN_METER 3.33f #endif @@ -383,25 +383,25 @@ void CRunningScript::CollectParameters(uint32* pIp, int16 total) { for (int16 i = 0; i < total; i++){ float tmp; - switch (CTheScripts::Read1ByteFromScript(pIp)) + switch (Read1ByteFromScript(pIp)) { case ARGUMENT_INT32: - ScriptParams[i] = CTheScripts::Read4BytesFromScript(pIp); + ScriptParams[i] = Read4BytesFromScript(pIp); break; case ARGUMENT_GLOBALVAR: - ScriptParams[i] = *((int32*)&CTheScripts::ScriptSpace[CTheScripts::Read2BytesFromScript(pIp)]); + ScriptParams[i] = *((int32*)&CTheScripts::ScriptSpace[Read2BytesFromScript(pIp)]); break; case ARGUMENT_LOCALVAR: - ScriptParams[i] = m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)]; + ScriptParams[i] = m_anLocalVariables[Read2BytesFromScript(pIp)]; break; case ARGUMENT_INT8: - ScriptParams[i] = CTheScripts::Read1ByteFromScript(pIp); + ScriptParams[i] = Read1ByteFromScript(pIp); break; case ARGUMENT_INT16: - ScriptParams[i] = CTheScripts::Read2BytesFromScript(pIp); + ScriptParams[i] = Read2BytesFromScript(pIp); break; case ARGUMENT_FLOAT: - tmp = CTheScripts::ReadFloatFromScript(pIp); + tmp = ReadFloatFromScript(pIp); ScriptParams[i] = *(int32*)&tmp; break; default: @@ -415,20 +415,20 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip) { uint32* pIp = &ip; float tmp; - switch (CTheScripts::Read1ByteFromScript(pIp)) + switch (Read1ByteFromScript(pIp)) { case ARGUMENT_INT32: - return CTheScripts::Read4BytesFromScript(pIp); + return Read4BytesFromScript(pIp); case ARGUMENT_GLOBALVAR: - return *((int32*)&CTheScripts::ScriptSpace[CTheScripts::Read2BytesFromScript(pIp)]); + return *((int32*)&CTheScripts::ScriptSpace[Read2BytesFromScript(pIp)]); case ARGUMENT_LOCALVAR: - return m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)]; + return m_anLocalVariables[Read2BytesFromScript(pIp)]; case ARGUMENT_INT8: - return CTheScripts::Read1ByteFromScript(pIp); + return Read1ByteFromScript(pIp); case ARGUMENT_INT16: - return CTheScripts::Read2BytesFromScript(pIp); + return Read2BytesFromScript(pIp); case ARGUMENT_FLOAT: - tmp = CTheScripts::ReadFloatFromScript(pIp); + tmp = ReadFloatFromScript(pIp); return *(int32*)&tmp; default: assert(0); @@ -439,12 +439,12 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip) void CRunningScript::StoreParameters(uint32* pIp, int16 number) { for (int16 i = 0; i < number; i++){ - switch (CTheScripts::Read1ByteFromScript(pIp)) { + switch (Read1ByteFromScript(pIp)) { case ARGUMENT_GLOBALVAR: - *(int32*)&CTheScripts::ScriptSpace[CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i]; + *(int32*)&CTheScripts::ScriptSpace[Read2BytesFromScript(pIp)] = ScriptParams[i]; break; case ARGUMENT_LOCALVAR: - m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i]; + m_anLocalVariables[Read2BytesFromScript(pIp)] = ScriptParams[i]; break; default: assert(0); @@ -454,14 +454,14 @@ void CRunningScript::StoreParameters(uint32* pIp, int16 number) int32 *CRunningScript::GetPointerToScriptVariable(uint32* pIp, int16 type) { - switch (CTheScripts::Read1ByteFromScript(pIp)) + switch (Read1ByteFromScript(pIp)) { case ARGUMENT_GLOBALVAR: assert(type == VAR_GLOBAL); - return (int32*)&CTheScripts::ScriptSpace[CTheScripts::Read2BytesFromScript(pIp)]; + return (int32*)&CTheScripts::ScriptSpace[Read2BytesFromScript(pIp)]; case ARGUMENT_LOCALVAR: assert(type == VAR_LOCAL); - return &m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)]; + return &m_anLocalVariables[Read2BytesFromScript(pIp)]; default: assert(0); } @@ -472,7 +472,7 @@ void CRunningScript::Init() { strcpy(m_abScriptName, "noname"); next = prev = nil; - m_nIp = 0; + SetIP(0); for (int i = 0; i < MAX_STACK_DEPTH; i++) m_anStack[i] = 0; m_nStackPointer = 0; @@ -510,27 +510,6 @@ int open_script() } #endif -void CTextLine::Reset() -{ - m_fScaleX = 0.48f; - m_fScaleY = 1.12f; - m_sColor = CRGBA(225, 225, 225, 255); - m_bJustify = false; - m_bRightJustify = false; - m_bCentered = false; - m_bBackground = false; - m_bBackgroundOnly = false; - m_fWrapX = 182.0f; /* TODO: scaling as bugfix */ - m_fCenterSize = 640.0f; /* --||-- */ - m_sBackgroundColor = CRGBA(128, 128, 128, 128); - m_bTextProportional = true; - m_bTextBeforeFade = false; - m_nFont = 2; /* enum? */ - m_fAtX = 0.0f; - m_fAtY = 0.0f; - memset(&m_Text, 0, sizeof(m_Text)); -} - void CTheScripts::Init() { for (int i = 0; i < SIZE_SCRIPT_SPACE; i++) @@ -698,7 +677,7 @@ void CRunningScript::Process() if (m_bIsMissionScript) DoDeatharrestCheck(); if (m_bMissionFlag && CTheScripts::FailCurrentMission == 1 && m_nStackPointer == 1) - m_nIp = m_anStack[--m_nStackPointer]; + SetIP(m_anStack[--m_nStackPointer]); if (CTimer::GetTimeInMilliseconds() >= m_nWakeTime){ while (!ProcessOneCommand()) ; @@ -720,7 +699,7 @@ void CRunningScript::Process() int8 CRunningScript::ProcessOneCommand() { ++CTheScripts::CommandsExecuted; - int32 command = CTheScripts::Read2BytesFromScript(&m_nIp); + int32 command = Read2BytesFromScript(&m_nIp); m_bNotFlag = (command & 0x8000); command &= 0x7FFF; if (command < 100) @@ -1248,27 +1227,27 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) CollectParameters(&m_nIp, 1); assert(ScriptParams[0] >= 0); CRunningScript* pNew = CTheScripts::StartNewScript(ScriptParams[0]); - int8 type = CTheScripts::Read1ByteFromScript(&m_nIp); + int8 type = Read1ByteFromScript(&m_nIp); float tmp; - for (int i = 0; type != ARGUMENT_END; type = CTheScripts::Read1ByteFromScript(&m_nIp), i++) { + for (int i = 0; type != ARGUMENT_END; type = Read1ByteFromScript(&m_nIp), i++) { switch (type) { case ARGUMENT_INT32: - pNew->m_anLocalVariables[i] = CTheScripts::Read4BytesFromScript(&m_nIp); + pNew->m_anLocalVariables[i] = Read4BytesFromScript(&m_nIp); break; case ARGUMENT_GLOBALVAR: - pNew->m_anLocalVariables[i] = *(int32*)&CTheScripts::ScriptSpace[CTheScripts::Read2BytesFromScript(&m_nIp)]; + pNew->m_anLocalVariables[i] = *(int32*)&CTheScripts::ScriptSpace[Read2BytesFromScript(&m_nIp)]; break; case ARGUMENT_LOCALVAR: - pNew->m_anLocalVariables[i] = m_anLocalVariables[CTheScripts::Read2BytesFromScript(&m_nIp)]; + pNew->m_anLocalVariables[i] = m_anLocalVariables[Read2BytesFromScript(&m_nIp)]; break; case ARGUMENT_INT8: - pNew->m_anLocalVariables[i] = CTheScripts::Read1ByteFromScript(&m_nIp); + pNew->m_anLocalVariables[i] = Read1ByteFromScript(&m_nIp); break; case ARGUMENT_INT16: - pNew->m_anLocalVariables[i] = CTheScripts::Read2BytesFromScript(&m_nIp); + pNew->m_anLocalVariables[i] = Read2BytesFromScript(&m_nIp); break; case ARGUMENT_FLOAT: - tmp = CTheScripts::ReadFloatFromScript(&m_nIp); + tmp = ReadFloatFromScript(&m_nIp); pNew->m_anLocalVariables[i] = *(int32*)&tmp; break; default: @@ -1296,7 +1275,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) CollectParameters(&m_nIp, 4); int32 index = ScriptParams[0]; assert(index < 1); /* Constant? Also no more double player glitch */ - debug("&&&&&&&&&&&&&Creating player: %d\n", index); + printf("&&&&&&&&&&&&&Creating player: %d\n", index); if (!CStreaming::HasModelLoaded(MI_PLAYER)) { CStreaming::RequestSpecialModel(MI_PLAYER, "player", STREAMFLAGS_DONT_REMOVE | STREAMFLAGS_DEPENDENCY); CStreaming::LoadAllRequestedModels(false); @@ -1434,33 +1413,6 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) return -1; } -void CRunningScript::UpdateCompareFlag(bool flag) -{ - if (m_bNotFlag) - flag = !flag; - if (m_nAndOrState == ANDOR_NONE){ - m_bCondResult = flag; - return; - } - if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8){ - m_bCondResult &= flag; - if (m_nAndOrState == ANDS_1){ - m_nAndOrState = ANDOR_NONE; - return; - } - }else if (m_nAndOrState >= ORS_1 && m_nAndOrState <= ORS_8){ - m_bCondResult |= flag; - if (m_nAndOrState == ORS_1) { - m_nAndOrState = ANDOR_NONE; - return; - } - }else{ - return; - } - m_nAndOrState--; -} - - int8 CRunningScript::ProcessCommands100To199(int32 command) { switch (command) { @@ -2717,7 +2669,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) CollectParameters(&m_nIp, 1); CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]]; char label[12]; - CTheScripts::ReadTextLabelFromScript(&m_nIp, label); + ReadTextLabelFromScript(&m_nIp, label); int zoneToCheck = CTheZones::FindZoneByLabelAndReturnIndex(label); if (zoneToCheck != -1) m_nIp += KEY_LENGTH_IN_SCRIPT; /* why only if zone != 1? */ @@ -3008,7 +2960,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) } case COMMAND_ADD_PAGER_MESSAGE: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 3); CUserDisplay::Pager.AddMessage(text, ScriptParams[0], ScriptParams[1], ScriptParams[2]); return 0; @@ -3017,21 +2969,21 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); m_nIp++; - CUserDisplay::OnscnTimer.AddClock(CTheScripts::Read2BytesFromScript(&m_nIp), nil); + CUserDisplay::OnscnTimer.AddClock(Read2BytesFromScript(&m_nIp), nil); return 0; } case COMMAND_CLEAR_ONSCREEN_TIMER: { assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); m_nIp++; - CUserDisplay::OnscnTimer.ClearClock(CTheScripts::Read2BytesFromScript(&m_nIp)); + CUserDisplay::OnscnTimer.ClearClock(Read2BytesFromScript(&m_nIp)); return 0; } case COMMAND_DISPLAY_ONSCREEN_COUNTER: { assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); m_nIp++; - int32 counter = CTheScripts::Read2BytesFromScript(&m_nIp); + int32 counter = Read2BytesFromScript(&m_nIp); CollectParameters(&m_nIp, 1); CUserDisplay::OnscnTimer.AddCounter(counter, ScriptParams[0], nil); return 0; @@ -3040,13 +2992,13 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); m_nIp++; - CUserDisplay::OnscnTimer.ClearCounter(CTheScripts::Read2BytesFromScript(&m_nIp)); + CUserDisplay::OnscnTimer.ClearCounter(Read2BytesFromScript(&m_nIp)); return 0; } case COMMAND_SET_ZONE_CAR_INFO: { char label[12]; - CTheScripts::ReadTextLabelFromScript(&m_nIp, label); + ReadTextLabelFromScript(&m_nIp, label); m_nIp += KEY_LENGTH_IN_SCRIPT; CollectParameters(&m_nIp, 16); int zone = CTheZones::FindZoneByLabelAndReturnIndex(label); @@ -3069,7 +3021,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); assert(pPed); char label[12]; - CTheScripts::ReadTextLabelFromScript(&m_nIp, label); + ReadTextLabelFromScript(&m_nIp, label); int zone = CTheZones::FindZoneByLabelAndReturnIndex(label); if (zone != -1) m_nIp += KEY_LENGTH_IN_SCRIPT; @@ -3080,7 +3032,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_SET_CAR_DENSITY: { char label[12]; - CTheScripts::ReadTextLabelFromScript(&m_nIp, label); + ReadTextLabelFromScript(&m_nIp, label); int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label); m_nIp += 8; CollectParameters(&m_nIp, 2); @@ -3094,7 +3046,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_SET_PED_DENSITY: { char label[12]; - CTheScripts::ReadTextLabelFromScript(&m_nIp, label); + ReadTextLabelFromScript(&m_nIp, label); int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label); m_nIp += KEY_LENGTH_IN_SCRIPT; CollectParameters(&m_nIp, 2); @@ -3137,7 +3089,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_SET_ZONE_PED_INFO: { char label[12]; - CTheScripts::ReadTextLabelFromScript(&m_nIp, label); + ReadTextLabelFromScript(&m_nIp, label); m_nIp += KEY_LENGTH_IN_SCRIPT; CollectParameters(&m_nIp, 10); int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label); @@ -3429,11 +3381,11 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_GET_CAMERA_POSITION_ALONG_SPLINE: */ case COMMAND_DECLARE_MISSION_FLAG: - CTheScripts::OnAMissionFlag = CTheScripts::Read2BytesFromScript(&++m_nIp); + CTheScripts::OnAMissionFlag = Read2BytesFromScript(&++m_nIp); return 0; case COMMAND_DECLARE_MISSION_FLAG_FOR_CONTACT: CollectParameters(&m_nIp, 1); - CTheScripts::OnAMissionForContactFlag[ScriptParams[0]] = CTheScripts::Read2BytesFromScript(&++m_nIp); + CTheScripts::OnAMissionForContactFlag[ScriptParams[0]] = Read2BytesFromScript(&++m_nIp); return 0; case COMMAND_DECLARE_BASE_BRIEF_ID_FOR_CONTACT: CollectParameters(&m_nIp, 2); @@ -4239,21 +4191,21 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) } case COMMAND_PRINT_WITH_NUMBER_BIG: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 3); CMessages::AddBigMessageWithNumber(text, ScriptParams[1], ScriptParams[2] - 1, ScriptParams[0], -1, -1, -1, -1, -1); return 0; } case COMMAND_PRINT_WITH_NUMBER: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 3); CMessages::AddMessageWithNumber(text, ScriptParams[1], ScriptParams[2], ScriptParams[0], -1, -1, -1, -1, -1); return 0; } case COMMAND_PRINT_WITH_NUMBER_NOW: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 3); CMessages::AddMessageJumpQWithNumber(text, ScriptParams[1], ScriptParams[2], ScriptParams[0], -1, -1, -1, -1, -1); return 0; @@ -4443,7 +4395,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) } case COMMAND_ADD_PAGER_MESSAGE_WITH_NUMBER: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 4); CUserDisplay::Pager.AddMessageWithNumber(text, ScriptParams[0], -1, -1, -1, -1, -1, ScriptParams[1], ScriptParams[2], ScriptParams[3]); @@ -4451,7 +4403,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) } case COMMAND_START_KILL_FRENZY: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 8); CDarkel::StartFrenzy((eWeaponType)ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], text, ScriptParams[4], ScriptParams[5], @@ -4628,14 +4580,14 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) } case COMMAND_PRINT_BIG_Q: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 2); CMessages::AddBigMessageQ(text, ScriptParams[0], ScriptParams[1] - 1); return 0; } case COMMAND_PRINT_WITH_NUMBER_BIG_Q: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 3); CMessages::AddBigMessageWithNumberQ(text, ScriptParams[1], ScriptParams[2] - 1, ScriptParams[0], -1, -1, -1, -1, -1); @@ -5152,14 +5104,14 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_SET_REPEATED_PHONE_MESSAGE: { CollectParameters(&m_nIp, 1); - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text, nil, nil, nil, nil, nil); return 0; } case COMMAND_SET_PHONE_MESSAGE: { CollectParameters(&m_nIp, 1); - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text, nil, nil, nil, nil, nil); return 0; } @@ -5716,7 +5668,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) CollectParameters(&m_nIp, 2); assert(m_nStackPointer < MAX_STACK_DEPTH); m_anStack[m_nStackPointer++] = m_nIp; - m_nIp = ScriptParams[0]; + SetIP(ScriptParams[0]); // ScriptParams[1] == filename return 0; } @@ -6229,105 +6181,105 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) } case COMMAND_PRINT_WITH_2_NUMBERS: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 4); CMessages::AddMessageWithNumber(text, ScriptParams[2], ScriptParams[3], ScriptParams[0], ScriptParams[1], -1, -1, -1, -1); return 0; } case COMMAND_PRINT_WITH_2_NUMBERS_NOW: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 4); CMessages::AddMessageJumpQWithNumber(text, ScriptParams[2], ScriptParams[3], ScriptParams[0], ScriptParams[1], -1, -1, -1, -1); return 0; } case COMMAND_PRINT_WITH_2_NUMBERS_SOON: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 4); CMessages::AddMessageSoonWithNumber(text, ScriptParams[2], ScriptParams[3], ScriptParams[0], ScriptParams[1], -1, -1, -1, -1); return 0; } case COMMAND_PRINT_WITH_3_NUMBERS: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 5); CMessages::AddMessageWithNumber(text, ScriptParams[3], ScriptParams[4], ScriptParams[0], ScriptParams[1], ScriptParams[2], -1, -1, -1); return 0; } case COMMAND_PRINT_WITH_3_NUMBERS_NOW: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 5); CMessages::AddMessageJumpQWithNumber(text, ScriptParams[3], ScriptParams[4], ScriptParams[0], ScriptParams[1], ScriptParams[2], -1, -1, -1); return 0; } case COMMAND_PRINT_WITH_3_NUMBERS_SOON: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 5); CMessages::AddMessageSoonWithNumber(text, ScriptParams[3], ScriptParams[4], ScriptParams[0], ScriptParams[1], ScriptParams[2], -1, -1, -1); return 0; } case COMMAND_PRINT_WITH_4_NUMBERS: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 6); CMessages::AddMessageWithNumber(text, ScriptParams[4], ScriptParams[5], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], -1, -1); return 0; } case COMMAND_PRINT_WITH_4_NUMBERS_NOW: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 6); CMessages::AddMessageJumpQWithNumber(text, ScriptParams[4], ScriptParams[5], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], -1, -1); return 0; } case COMMAND_PRINT_WITH_4_NUMBERS_SOON: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 6); CMessages::AddMessageSoonWithNumber(text, ScriptParams[4], ScriptParams[5], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], -1, -1); return 0; } case COMMAND_PRINT_WITH_5_NUMBERS: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 7); CMessages::AddMessageWithNumber(text, ScriptParams[5], ScriptParams[6], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], -1); return 0; } case COMMAND_PRINT_WITH_5_NUMBERS_NOW: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 7); CMessages::AddMessageJumpQWithNumber(text, ScriptParams[5], ScriptParams[6], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], -1); return 0; } case COMMAND_PRINT_WITH_5_NUMBERS_SOON: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 7); CMessages::AddMessageSoonWithNumber(text, ScriptParams[5], ScriptParams[6], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], -1); return 0; } case COMMAND_PRINT_WITH_6_NUMBERS: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 8); CMessages::AddMessageWithNumber(text, ScriptParams[6], ScriptParams[7], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], ScriptParams[5]); return 0; } case COMMAND_PRINT_WITH_6_NUMBERS_NOW: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 8); CMessages::AddMessageJumpQWithNumber(text, ScriptParams[6], ScriptParams[7], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], ScriptParams[5]); return 0; } case COMMAND_PRINT_WITH_6_NUMBERS_SOON: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 8); CMessages::AddMessageSoonWithNumber(text, ScriptParams[6], ScriptParams[7], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], ScriptParams[5]); return 0; @@ -6523,7 +6475,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_SET_ZONE_GROUP: { char zone[KEY_LENGTH_IN_SCRIPT]; - CTheScripts::ReadTextLabelFromScript(&m_nIp, zone); + ReadTextLabelFromScript(&m_nIp, zone); m_nIp += KEY_LENGTH_IN_SCRIPT; CollectParameters(&m_nIp, 2); int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone); @@ -6585,7 +6537,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_GET_RANDOM_CAR_OF_TYPE_IN_ZONE: { char zone[KEY_LENGTH_IN_SCRIPT]; - CTheScripts::ReadTextLabelFromScript(&m_nIp, zone); + ReadTextLabelFromScript(&m_nIp, zone); int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone); if (zone_id != -1) m_nIp += KEY_LENGTH_IN_SCRIPT; @@ -6784,7 +6736,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_DISPLAY_TEXT: { CollectParameters(&m_nIp, 2); - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = *(float*)&ScriptParams[0]; CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = *(float*)&ScriptParams[1]; uint16 len = CMessages::GetWideStringLength(text); @@ -7029,7 +6981,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); assert(pPed); char name[KEY_LENGTH_IN_SCRIPT]; - CTheScripts::ReadTextLabelFromScript(&m_nIp, name); + ReadTextLabelFromScript(&m_nIp, name); for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++) name[i] = tolower(name[i]); int mi = pPed->GetModelIndex(); @@ -7091,7 +7043,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 1); char zone[KEY_LENGTH_IN_SCRIPT]; - CTheScripts::ReadTextLabelFromScript(&m_nIp, zone); + ReadTextLabelFromScript(&m_nIp, zone); int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone); if (zone_id != -1) m_nIp += KEY_LENGTH_IN_SCRIPT; @@ -7272,7 +7224,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) } case COMMAND_START_KILL_FRENZY_HEADSHOT: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 8); CDarkel::StartFrenzy((eWeaponType)ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], text, ScriptParams[4], ScriptParams[5], @@ -7326,35 +7278,35 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) //case COMMAND_SET_AUDIO_STREAM: case COMMAND_PRINT_WITH_2_NUMBERS_BIG: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 4); CMessages::AddBigMessageWithNumber(text, ScriptParams[2], ScriptParams[3] - 1, ScriptParams[0], ScriptParams[1], -1, -1, -1, -1); return 0; } case COMMAND_PRINT_WITH_3_NUMBERS_BIG: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 5); CMessages::AddBigMessageWithNumber(text, ScriptParams[3], ScriptParams[4] - 1, ScriptParams[0], ScriptParams[1], ScriptParams[2], -1, -1, -1); return 0; } case COMMAND_PRINT_WITH_4_NUMBERS_BIG: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 6); CMessages::AddBigMessageWithNumber(text, ScriptParams[4], ScriptParams[5] - 1, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], -1, -1); return 0; } case COMMAND_PRINT_WITH_5_NUMBERS_BIG: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 7); CMessages::AddBigMessageWithNumber(text, ScriptParams[5], ScriptParams[6] - 1, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], -1); return 0; } case COMMAND_PRINT_WITH_6_NUMBERS_BIG: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 8); CMessages::AddBigMessageWithNumber(text, ScriptParams[6], ScriptParams[7] - 1, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], ScriptParams[5]); return 0; @@ -7376,8 +7328,8 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) return 0; case COMMAND_PRINT_STRING_IN_STRING: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* string = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); + wchar* string = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 2); CMessages::AddMessageWithString(text, ScriptParams[0], ScriptParams[1], string); return 0; @@ -7432,54 +7384,54 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_SET_2_REPEATED_PHONE_MESSAGES: { CollectParameters(&m_nIp, 1); - wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text1 = GetTextByKeyFromScript(&m_nIp); + wchar* text2 = GetTextByKeyFromScript(&m_nIp); gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, nil, nil, nil, nil); return 0; } case COMMAND_SET_2_PHONE_MESSAGES: { CollectParameters(&m_nIp, 1); - wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text1 = GetTextByKeyFromScript(&m_nIp); + wchar* text2 = GetTextByKeyFromScript(&m_nIp); gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, nil, nil, nil, nil); return 0; } case COMMAND_SET_3_REPEATED_PHONE_MESSAGES: { CollectParameters(&m_nIp, 1); - wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text1 = GetTextByKeyFromScript(&m_nIp); + wchar* text2 = GetTextByKeyFromScript(&m_nIp); + wchar* text3 = GetTextByKeyFromScript(&m_nIp); gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, text3, nil, nil, nil); return 0; } case COMMAND_SET_3_PHONE_MESSAGES: { CollectParameters(&m_nIp, 1); - wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text1 = GetTextByKeyFromScript(&m_nIp); + wchar* text2 = GetTextByKeyFromScript(&m_nIp); + wchar* text3 = GetTextByKeyFromScript(&m_nIp); gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, text3, nil, nil, nil); return 0; } case COMMAND_SET_4_REPEATED_PHONE_MESSAGES: { CollectParameters(&m_nIp, 1); - wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text1 = GetTextByKeyFromScript(&m_nIp); + wchar* text2 = GetTextByKeyFromScript(&m_nIp); + wchar* text3 = GetTextByKeyFromScript(&m_nIp); + wchar* text4 = GetTextByKeyFromScript(&m_nIp); gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, text3, text4, nil, nil); return 0; } case COMMAND_SET_4_PHONE_MESSAGES: { CollectParameters(&m_nIp, 1); - wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text1 = GetTextByKeyFromScript(&m_nIp); + wchar* text2 = GetTextByKeyFromScript(&m_nIp); + wchar* text3 = GetTextByKeyFromScript(&m_nIp); + wchar* text4 = GetTextByKeyFromScript(&m_nIp); gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, text3, text4, nil, nil); return 0; } @@ -7556,8 +7508,8 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) switch (command) { case COMMAND_PRINT_STRING_IN_STRING_NOW: { - wchar* source = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* pstr = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* source = GetTextByKeyFromScript(&m_nIp); + wchar* pstr = GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 2); CMessages::AddMessageJumpQWithString(source, ScriptParams[0], ScriptParams[1], pstr); return 0; @@ -7566,46 +7518,46 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_SET_5_REPEATED_PHONE_MESSAGES: { CollectParameters(&m_nIp, 1); - wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text5 = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text1 = GetTextByKeyFromScript(&m_nIp); + wchar* text2 = GetTextByKeyFromScript(&m_nIp); + wchar* text3 = GetTextByKeyFromScript(&m_nIp); + wchar* text4 = GetTextByKeyFromScript(&m_nIp); + wchar* text5 = GetTextByKeyFromScript(&m_nIp); gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, text3, text4, text5, nil); return 0; } case COMMAND_SET_5_PHONE_MESSAGES: { CollectParameters(&m_nIp, 1); - wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text5 = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text1 = GetTextByKeyFromScript(&m_nIp); + wchar* text2 = GetTextByKeyFromScript(&m_nIp); + wchar* text3 = GetTextByKeyFromScript(&m_nIp); + wchar* text4 = GetTextByKeyFromScript(&m_nIp); + wchar* text5 = GetTextByKeyFromScript(&m_nIp); gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, text3, text4, text5, nil); return 0; } case COMMAND_SET_6_REPEATED_PHONE_MESSAGES: { CollectParameters(&m_nIp, 1); - wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text5 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text6 = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text1 = GetTextByKeyFromScript(&m_nIp); + wchar* text2 = GetTextByKeyFromScript(&m_nIp); + wchar* text3 = GetTextByKeyFromScript(&m_nIp); + wchar* text4 = GetTextByKeyFromScript(&m_nIp); + wchar* text5 = GetTextByKeyFromScript(&m_nIp); + wchar* text6 = GetTextByKeyFromScript(&m_nIp); gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, text3, text4, text5, text6); return 0; } case COMMAND_SET_6_PHONE_MESSAGES: { CollectParameters(&m_nIp, 1); - wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text5 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - wchar* text6 = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text1 = GetTextByKeyFromScript(&m_nIp); + wchar* text2 = GetTextByKeyFromScript(&m_nIp); + wchar* text3 = GetTextByKeyFromScript(&m_nIp); + wchar* text4 = GetTextByKeyFromScript(&m_nIp); + wchar* text5 = GetTextByKeyFromScript(&m_nIp); + wchar* text6 = GetTextByKeyFromScript(&m_nIp); gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, text3, text4, text5, text6); return 0; } @@ -8109,7 +8061,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_STRING: { assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR); - int16 var = CTheScripts::Read2BytesFromScript(&m_nIp); + int16 var = Read2BytesFromScript(&m_nIp); wchar* text = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); // ??? strncpy(onscreen_str, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); m_nIp += KEY_LENGTH_IN_SCRIPT; @@ -8119,7 +8071,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_DISPLAY_ONSCREEN_COUNTER_WITH_STRING: { assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR); - int16 var = CTheScripts::Read2BytesFromScript(&m_nIp); + int16 var = Read2BytesFromScript(&m_nIp); CollectParameters(&m_nIp, 1); wchar* text = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); // ??? strncpy(onscreen_str, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); @@ -8335,13 +8287,13 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) } case COMMAND_CLEAR_THIS_PRINT: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CMessages::ClearThisPrint(text); return 0; } case COMMAND_CLEAR_THIS_BIG_PRINT: { - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CMessages::ClearThisBigPrint(text); return 0; } @@ -8431,7 +8383,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) m_nIp += KEY_LENGTH_IN_SCRIPT; return 0; } - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CHud::SetHelpMessage(text, false); return 0; } @@ -8831,7 +8783,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 1); float fMeterValue = *(float*)&ScriptParams[0]; - float fFeetValue = fMeterValue / METERS_IN_FEET; + float fFeetValue = fMeterValue / METERS_IN_FOOT; *(float*)&ScriptParams[0] = fFeetValue; StoreParameters(&m_nIp, 1); return 0; @@ -9172,7 +9124,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) CTimer::Update(); return 0; case COMMAND_LOAD_SPLASH_SCREEN: - CTheScripts::ReadTextLabelFromScript(&m_nIp, tmp); + ReadTextLabelFromScript(&m_nIp, tmp); for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++) tmp[i] = tolower(tmp[i]); m_nIp += 8; @@ -9274,7 +9226,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) } case COMMAND_TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME: { - CTheScripts::ReadTextLabelFromScript(&m_nIp, tmp); + ReadTextLabelFromScript(&m_nIp, tmp); for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++) tmp[i] = tolower(tmp[i]); m_nIp += 8; @@ -9292,7 +9244,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_DISPLAY_TEXT_WITH_NUMBER: { CollectParameters(&m_nIp, 2); - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = *(float*)&ScriptParams[0]; CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = *(float*)&ScriptParams[1]; CollectParameters(&m_nIp, 1); @@ -9303,7 +9255,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_DISPLAY_TEXT_WITH_2_NUMBERS: { CollectParameters(&m_nIp, 2); - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + wchar* text = GetTextByKeyFromScript(&m_nIp); CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = *(float*)&ScriptParams[0]; CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = *(float*)&ScriptParams[1]; CollectParameters(&m_nIp, 2); @@ -9716,33 +9668,13 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) return -1; } -int16 CRunningScript::GetPadState(uint16 pad, uint16 button) +int32 CTheScripts::GetNewUniqueScriptSphereIndex(int32 index) { - CPad* pPad = CPad::GetPad(pad); - switch (button){ - case 0: return pPad->NewState.LeftStickX; - case 1: return pPad->NewState.LeftStickY; - case 2: return pPad->NewState.RightStickX; - case 3: return pPad->NewState.RightStickY; - case 4: return pPad->NewState.LeftShoulder1; - case 5: return pPad->NewState.LeftShoulder2; - case 6: return pPad->NewState.RightShoulder1; - case 7: return pPad->NewState.RightShoulder2; - case 8: return pPad->NewState.DPadUp; - case 9: return pPad->NewState.DPadDown; - case 10: return pPad->NewState.DPadLeft; - case 11: return pPad->NewState.DPadRight; - case 12: return pPad->NewState.Start; - case 13: return pPad->NewState.Select; - case 14: return pPad->NewState.Square; - case 15: return pPad->NewState.Triangle; - case 16: return pPad->NewState.Cross; - case 17: return pPad->NewState.Circle; - case 18: return pPad->NewState.LeftShock; - case 19: return pPad->NewState.RightShock; - default: break; - } - return 0; + if (ScriptSphereArray[index].m_Index >= 0xFFFE) + ScriptSphereArray[index].m_Index = 1; + else + ScriptSphereArray[index].m_Index++; + return (uint16)index | ScriptSphereArray[index].m_Index << 16; } int32 CTheScripts::GetActualScriptSphereIndex(int32 index) @@ -9757,6 +9689,15 @@ int32 CTheScripts::GetActualScriptSphereIndex(int32 index) return array_idx; } +void CTheScripts::DrawScriptSpheres() +{ + for (int i = 0; i < MAX_NUM_SCRIPT_SPHERES; i++) { + if (ScriptSphereArray[i].m_bInUse) + C3dMarkers::PlaceMarkerSet(ScriptSphereArray[i].m_Id, 4, ScriptSphereArray[i].m_vecCenter, ScriptSphereArray[i].m_fRadius, + SPHERE_MARKER_R, SPHERE_MARKER_G, SPHERE_MARKER_B, SPHERE_MARKER_A, SPHERE_MARKER_PULSE_PERIOD, SPHERE_MARKER_PULSE_FRACTION, 0); + } +} + int32 CTheScripts::AddScriptSphere(int32 id, CVector pos, float radius) { int16 i = 0; @@ -9775,15 +9716,6 @@ int32 CTheScripts::AddScriptSphere(int32 id, CVector pos, float radius) return GetNewUniqueScriptSphereIndex(i); } -int32 CTheScripts::GetNewUniqueScriptSphereIndex(int32 index) -{ - if (ScriptSphereArray[index].m_Index >= 0xFFFE) - ScriptSphereArray[index].m_Index = 1; - else - ScriptSphereArray[index].m_Index++; - return (uint16)index | ScriptSphereArray[index].m_Index << 16; -} - void CTheScripts::RemoveScriptSphere(int32 index) { index = GetActualScriptSphereIndex(index); @@ -9793,9 +9725,39 @@ void CTheScripts::RemoveScriptSphere(int32 index) ScriptSphereArray[index].m_Id = 0; } -bool CTheScripts::IsVehicleStopped(CVehicle* pVehicle) +void CTheScripts::AddToBuildingSwapArray(CBuilding* pBuilding, int32 old_model, int32 new_model) { - return 0.01f * CTimer::GetTimeStep() >= pVehicle->m_fDistanceTravelled; + int i = 0; + bool found = false; + while (i < MAX_NUM_BUILDING_SWAPS && !found) { + if (BuildingSwapArray[i].m_pBuilding == pBuilding) + found = true; + else + i++; + } + if (found) { + if (BuildingSwapArray[i].m_nOldModel == new_model) { + BuildingSwapArray[i].m_pBuilding = nil; + BuildingSwapArray[i].m_nOldModel = BuildingSwapArray[i].m_nNewModel = -1; + } + else { + BuildingSwapArray[i].m_nNewModel = new_model; + } + } + else { + i = 0; + while (i < MAX_NUM_BUILDING_SWAPS && !found) { + if (BuildingSwapArray[i].m_pBuilding == nil) + found = true; + else + i++; + } + if (found) { + BuildingSwapArray[i].m_pBuilding = pBuilding; + BuildingSwapArray[i].m_nNewModel = new_model; + BuildingSwapArray[i].m_nOldModel = old_model; + } + } } void CTheScripts::AddToInvisibilitySwapArray(CEntity* pEntity, bool remove) @@ -9825,93 +9787,851 @@ void CTheScripts::AddToInvisibilitySwapArray(CEntity* pEntity, bool remove) } } -void CTheScripts::AddToBuildingSwapArray(CBuilding* pBuilding, int32 old_model, int32 new_model) +void CTheScripts::UndoBuildingSwaps() { - int i = 0; - bool found = false; - while (i < MAX_NUM_BUILDING_SWAPS && !found) { - if (BuildingSwapArray[i].m_pBuilding == pBuilding) - found = true; - else - i++; - } - if (found) { - if (BuildingSwapArray[i].m_nOldModel == new_model) { + for (int i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) { + if (BuildingSwapArray[i].m_pBuilding) { + BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nOldModel); BuildingSwapArray[i].m_pBuilding = nil; BuildingSwapArray[i].m_nOldModel = BuildingSwapArray[i].m_nNewModel = -1; - }else{ - BuildingSwapArray[i].m_nNewModel = new_model; + } + } +} + +void CTheScripts::UndoEntityVisibilitySettings() +{ + for (int i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) { + if (InvisibilitySettingArray[i]) { + InvisibilitySettingArray[i]->bIsVisible = true; + InvisibilitySettingArray[i] = nil; + } + } +} + +void CRunningScript::UpdateCompareFlag(bool flag) +{ + if (m_bNotFlag) + flag = !flag; + if (m_nAndOrState == ANDOR_NONE) { + m_bCondResult = flag; + return; + } + if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8) { + m_bCondResult &= flag; + if (m_nAndOrState == ANDS_1) { + m_nAndOrState = ANDOR_NONE; + return; + } + } + else if (m_nAndOrState >= ORS_1 && m_nAndOrState <= ORS_8) { + m_bCondResult |= flag; + if (m_nAndOrState == ORS_1) { + m_nAndOrState = ANDOR_NONE; + return; } } else { - i = 0; - while (i < MAX_NUM_BUILDING_SWAPS && !found) { - if (BuildingSwapArray[i].m_pBuilding == nil) - found = true; - else - i++; + return; + } + m_nAndOrState--; +} + +void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug, decided = false; + float X, Y, Z, dX, dY, dZ; + switch (command) { + case COMMAND_LOCATE_PLAYER_ANY_MEANS_3D: + case COMMAND_LOCATE_PLAYER_ON_FOOT_3D: + case COMMAND_LOCATE_PLAYER_IN_CAR_3D: + case COMMAND_LOCATE_STOPPED_PLAYER_ANY_MEANS_3D: + case COMMAND_LOCATE_STOPPED_PLAYER_ON_FOOT_3D: + case COMMAND_LOCATE_STOPPED_PLAYER_IN_CAR_3D: + b3D = true; + break; + default: + b3D = false; + break; + } + CollectParameters(pIp, b3D ? 8 : 6); + CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; + switch (command) { + case COMMAND_LOCATE_STOPPED_PLAYER_ANY_MEANS_2D: + case COMMAND_LOCATE_STOPPED_PLAYER_ANY_MEANS_3D: + case COMMAND_LOCATE_STOPPED_PLAYER_IN_CAR_2D: + case COMMAND_LOCATE_STOPPED_PLAYER_IN_CAR_3D: + case COMMAND_LOCATE_STOPPED_PLAYER_ON_FOOT_2D: + case COMMAND_LOCATE_STOPPED_PLAYER_ON_FOOT_3D: + if (!CTheScripts::IsPlayerStopped(pPlayerInfo)) { + result = false; + decided = true; } - if (found) { - BuildingSwapArray[i].m_pBuilding = pBuilding; - BuildingSwapArray[i].m_nNewModel = new_model; - BuildingSwapArray[i].m_nOldModel = old_model; + break; + default: + break; + } + X = *(float*)&ScriptParams[1]; + Y = *(float*)&ScriptParams[2]; + if (b3D) { + Z = *(float*)&ScriptParams[3]; + dX = *(float*)&ScriptParams[4]; + dY = *(float*)&ScriptParams[5]; + dZ = *(float*)&ScriptParams[6]; + debug = ScriptParams[7]; + } else { + dX = *(float*)&ScriptParams[3]; + dY = *(float*)&ScriptParams[4]; + debug = ScriptParams[5]; + } + if (!decided) { + CVector pos = pPlayerInfo->GetPos(); + result = false; + bool in_area; + if (b3D) { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y && + Z - dZ <= pos.z && + Z + dZ >= pos.z; + } else { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y; + } + if (in_area) { + switch (command) { + case COMMAND_LOCATE_PLAYER_ANY_MEANS_2D: + case COMMAND_LOCATE_PLAYER_ANY_MEANS_3D: + case COMMAND_LOCATE_STOPPED_PLAYER_ANY_MEANS_2D: + case COMMAND_LOCATE_STOPPED_PLAYER_ANY_MEANS_3D: + result = true; + break; + case COMMAND_LOCATE_PLAYER_ON_FOOT_2D: + case COMMAND_LOCATE_PLAYER_ON_FOOT_3D: + case COMMAND_LOCATE_STOPPED_PLAYER_ON_FOOT_2D: + case COMMAND_LOCATE_STOPPED_PLAYER_ON_FOOT_3D: + result = !pPlayerInfo->m_pPed->bInVehicle; + break; + case COMMAND_LOCATE_PLAYER_IN_CAR_2D: + case COMMAND_LOCATE_PLAYER_IN_CAR_3D: + case COMMAND_LOCATE_STOPPED_PLAYER_IN_CAR_2D: + case COMMAND_LOCATE_STOPPED_PLAYER_IN_CAR_3D: + result = pPlayerInfo->m_pPed->bInVehicle; + break; + default: + assert(false); + break; + } + } + } + UpdateCompareFlag(result); + if (debug) + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : -100.0f); + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); + else + CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); + } +} + +void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug; + float X, Y, Z, dX, dY, dZ; + switch (command) { + case COMMAND_LOCATE_PLAYER_ANY_MEANS_CHAR_3D: + case COMMAND_LOCATE_PLAYER_ON_FOOT_CHAR_3D: + case COMMAND_LOCATE_PLAYER_IN_CAR_CHAR_3D: + b3D = true; + break; + default: + b3D = false; + break; + } + CollectParameters(pIp, b3D ? 6 : 5); + CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; + CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + assert(pTarget); + CVector pos = pPlayerInfo->GetPos(); + if (pTarget->bInVehicle) { + X = pTarget->m_pMyVehicle->GetPosition().x; + Y = pTarget->m_pMyVehicle->GetPosition().y; + Z = pTarget->m_pMyVehicle->GetPosition().z; + } else { + X = pTarget->GetPosition().x; + Y = pTarget->GetPosition().y; + Z = pTarget->GetPosition().z; + } + dX = *(float*)&ScriptParams[2]; + dY = *(float*)&ScriptParams[3]; + if (b3D) { + dZ = *(float*)&ScriptParams[4]; + debug = ScriptParams[5]; + } + else { + debug = ScriptParams[5]; + } + result = false; + bool in_area; + if (b3D) { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y && + Z - dZ <= pos.z && + Z + dZ >= pos.z; + } + else { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y; + } + if (in_area) { + switch (command) { + case COMMAND_LOCATE_PLAYER_ANY_MEANS_CHAR_2D: + case COMMAND_LOCATE_PLAYER_ANY_MEANS_CHAR_3D: + result = true; + break; + case COMMAND_LOCATE_PLAYER_ON_FOOT_CHAR_2D: + case COMMAND_LOCATE_PLAYER_ON_FOOT_CHAR_3D: + result = !pPlayerInfo->m_pPed->bInVehicle; + break; + case COMMAND_LOCATE_PLAYER_IN_CAR_CHAR_2D: + case COMMAND_LOCATE_PLAYER_IN_CAR_CHAR_3D: + result = pPlayerInfo->m_pPed->bInVehicle; + break; + default: + assert(false); + break; + } + } + UpdateCompareFlag(result); + if (debug) +#ifdef FIX_BUGS + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : -100.0f); +#else + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, X - dX, Y - dY, X + dX, Y + dX, b3D ? Z : -100.0f); +#endif + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); + else + CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); + } +} + +void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug; + float X, Y, Z, dX, dY, dZ; + switch (command) { + case COMMAND_LOCATE_PLAYER_ANY_MEANS_CAR_3D: + case COMMAND_LOCATE_PLAYER_ON_FOOT_CAR_3D: + case COMMAND_LOCATE_PLAYER_IN_CAR_CAR_3D: + b3D = true; + break; + default: + b3D = false; + break; + } + CollectParameters(pIp, b3D ? 6 : 5); + CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; + CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + assert(pTarget); + CVector pos = pPlayerInfo->GetPos(); + X = pTarget->GetPosition().x; + Y = pTarget->GetPosition().y; + Z = pTarget->GetPosition().z; + dX = *(float*)&ScriptParams[2]; + dY = *(float*)&ScriptParams[3]; + if (b3D) { + dZ = *(float*)&ScriptParams[4]; + debug = ScriptParams[5]; + } + else { + debug = ScriptParams[4]; + } + result = false; + bool in_area; + if (b3D) { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y && + Z - dZ <= pos.z && + Z + dZ >= pos.z; + } + else { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y; + } + if (in_area) { + switch (command) { + case COMMAND_LOCATE_PLAYER_ANY_MEANS_CAR_2D: + case COMMAND_LOCATE_PLAYER_ANY_MEANS_CAR_3D: + result = true; + break; + case COMMAND_LOCATE_PLAYER_ON_FOOT_CAR_2D: + case COMMAND_LOCATE_PLAYER_ON_FOOT_CAR_3D: + result = !pPlayerInfo->m_pPed->bInVehicle; + break; + case COMMAND_LOCATE_PLAYER_IN_CAR_CHAR_2D: + case COMMAND_LOCATE_PLAYER_IN_CAR_CHAR_3D: + result = pPlayerInfo->m_pPed->bInVehicle; + break; + default: + assert(false); + break; + } + } + UpdateCompareFlag(result); + if (debug) + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : -100.0f); + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); + else + CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); + } +} + +void CRunningScript::LocateCharCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug, decided = false; + float X, Y, Z, dX, dY, dZ; + switch (command) { + case COMMAND_LOCATE_CHAR_ANY_MEANS_3D: + case COMMAND_LOCATE_CHAR_ON_FOOT_3D: + case COMMAND_LOCATE_CHAR_IN_CAR_3D: + case COMMAND_LOCATE_STOPPED_CHAR_ANY_MEANS_3D: + case COMMAND_LOCATE_STOPPED_CHAR_ON_FOOT_3D: + case COMMAND_LOCATE_STOPPED_CHAR_IN_CAR_3D: + b3D = true; + break; + default: + b3D = false; + break; + } + CollectParameters(pIp, b3D ? 8 : 6); + CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + assert(pPed); + CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); + switch (command) { + case COMMAND_LOCATE_STOPPED_CHAR_ANY_MEANS_2D: + case COMMAND_LOCATE_STOPPED_CHAR_ANY_MEANS_3D: + case COMMAND_LOCATE_STOPPED_CHAR_IN_CAR_2D: + case COMMAND_LOCATE_STOPPED_CHAR_IN_CAR_3D: + case COMMAND_LOCATE_STOPPED_CHAR_ON_FOOT_2D: + case COMMAND_LOCATE_STOPPED_CHAR_ON_FOOT_3D: + if (!CTheScripts::IsPedStopped(pPed)) { + result = false; + decided = true; + } + break; + default: + break; + } + X = *(float*)&ScriptParams[1]; + Y = *(float*)&ScriptParams[2]; + if (b3D) { + Z = *(float*)&ScriptParams[3]; + dX = *(float*)&ScriptParams[4]; + dY = *(float*)&ScriptParams[5]; + dZ = *(float*)&ScriptParams[6]; + debug = ScriptParams[7]; + } + else { + dX = *(float*)&ScriptParams[3]; + dY = *(float*)&ScriptParams[4]; + debug = ScriptParams[5]; + } + if (!decided) { + result = false; + bool in_area; + if (b3D) { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y && + Z - dZ <= pos.z && + Z + dZ >= pos.z; + } + else { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y; + } + if (in_area) { + switch (command) { + case COMMAND_LOCATE_CHAR_ANY_MEANS_2D: + case COMMAND_LOCATE_CHAR_ANY_MEANS_3D: + case COMMAND_LOCATE_STOPPED_CHAR_ANY_MEANS_2D: + case COMMAND_LOCATE_STOPPED_CHAR_ANY_MEANS_3D: + result = true; + break; + case COMMAND_LOCATE_CHAR_ON_FOOT_2D: + case COMMAND_LOCATE_CHAR_ON_FOOT_3D: + case COMMAND_LOCATE_STOPPED_CHAR_ON_FOOT_2D: + case COMMAND_LOCATE_STOPPED_CHAR_ON_FOOT_3D: + result = !pPed->bInVehicle; + break; + case COMMAND_LOCATE_CHAR_IN_CAR_2D: + case COMMAND_LOCATE_CHAR_IN_CAR_3D: + case COMMAND_LOCATE_STOPPED_CHAR_IN_CAR_2D: + case COMMAND_LOCATE_STOPPED_CHAR_IN_CAR_3D: + result = pPed->bInVehicle; + break; + default: + assert(false); + break; + } + } + } + UpdateCompareFlag(result); + if (debug) + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : -100.0f); + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); + else + CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); + } +} + +void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug; + float X, Y, Z, dX, dY, dZ; + switch (command) { + case COMMAND_LOCATE_CHAR_ANY_MEANS_CHAR_3D: + case COMMAND_LOCATE_CHAR_ON_FOOT_CHAR_3D: + case COMMAND_LOCATE_CHAR_IN_CAR_CHAR_3D: + b3D = true; + break; + default: + b3D = false; + break; + } + CollectParameters(pIp, b3D ? 6 : 5); + CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + assert(pPed); + CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + assert(pTarget); + CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); + if (pTarget->bInVehicle) { + X = pTarget->m_pMyVehicle->GetPosition().x; + Y = pTarget->m_pMyVehicle->GetPosition().y; + Z = pTarget->m_pMyVehicle->GetPosition().z; + } + else { + X = pTarget->GetPosition().x; + Y = pTarget->GetPosition().y; + Z = pTarget->GetPosition().z; + } + dX = *(float*)&ScriptParams[2]; + dY = *(float*)&ScriptParams[3]; + if (b3D) { + dZ = *(float*)&ScriptParams[4]; + debug = ScriptParams[5]; + } + else { + debug = ScriptParams[4]; + } + result = false; + bool in_area; + if (b3D) { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y && + Z - dZ <= pos.z && + Z + dZ >= pos.z; + } + else { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y; + } + if (in_area) { + switch (command) { + case COMMAND_LOCATE_CHAR_ANY_MEANS_CHAR_2D: + case COMMAND_LOCATE_CHAR_ANY_MEANS_CHAR_3D: + result = true; + break; + case COMMAND_LOCATE_CHAR_ON_FOOT_CHAR_2D: + case COMMAND_LOCATE_CHAR_ON_FOOT_CHAR_3D: + result = !pPed->bInVehicle; + break; + case COMMAND_LOCATE_CHAR_IN_CAR_CHAR_2D: + case COMMAND_LOCATE_CHAR_IN_CAR_CHAR_3D: + result = pPed->bInVehicle; + break; + default: + assert(false); + break; + } + } + UpdateCompareFlag(result); + if (debug) +#ifdef FIX_BUGS + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : -100.0f); +#else + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, X - dX, Y - dY, X + dX, Y + dX, b3D ? Z : -100.0f); +#endif + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); + else + CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); + } +} + +void CRunningScript::LocateCharCarCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug; + float X, Y, Z, dX, dY, dZ; + switch (command) { + case COMMAND_LOCATE_CHAR_ANY_MEANS_CAR_3D: + case COMMAND_LOCATE_CHAR_ON_FOOT_CAR_3D: + case COMMAND_LOCATE_CHAR_IN_CAR_CAR_3D: + b3D = true; + break; + default: + b3D = false; + break; + } + CollectParameters(pIp, b3D ? 6 : 5); + CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + assert(pPed); + CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + assert(pTarget); + CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); + X = pTarget->GetPosition().x; + Y = pTarget->GetPosition().y; + Z = pTarget->GetPosition().z; + dX = *(float*)&ScriptParams[2]; + dY = *(float*)&ScriptParams[3]; + if (b3D) { + dZ = *(float*)&ScriptParams[4]; + debug = ScriptParams[5]; + } + else { + debug = ScriptParams[4]; + } + result = false; + bool in_area; + if (b3D) { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y && + Z - dZ <= pos.z && + Z + dZ >= pos.z; + } + else { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y; + } + if (in_area) { + switch (command) { + case COMMAND_LOCATE_CHAR_ANY_MEANS_CAR_2D: + case COMMAND_LOCATE_CHAR_ANY_MEANS_CAR_3D: + result = true; + break; + case COMMAND_LOCATE_CHAR_ON_FOOT_CAR_2D: + case COMMAND_LOCATE_CHAR_ON_FOOT_CAR_3D: + result = !pPed->bInVehicle; + break; + case COMMAND_LOCATE_CHAR_IN_CAR_CHAR_2D: + case COMMAND_LOCATE_CHAR_IN_CAR_CHAR_3D: + result = pPed->bInVehicle; + break; + default: + assert(false); + break; } } + UpdateCompareFlag(result); + if (debug) + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : -100.0f); + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); + else + CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); + } +} + +void CRunningScript::LocateCharObjectCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug; + float X, Y, Z, dX, dY, dZ; + switch (command) { + case COMMAND_LOCATE_CHAR_ANY_MEANS_OBJECT_3D: + case COMMAND_LOCATE_CHAR_ON_FOOT_OBJECT_3D: + case COMMAND_LOCATE_CHAR_IN_CAR_OBJECT_3D: + b3D = true; + break; + default: + b3D = false; + break; + } + CollectParameters(pIp, b3D ? 6 : 5); + CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + assert(pPed); + CObject* pTarget = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + assert(pTarget); + CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); + X = pTarget->GetPosition().x; + Y = pTarget->GetPosition().y; + Z = pTarget->GetPosition().z; + dX = *(float*)&ScriptParams[2]; + dY = *(float*)&ScriptParams[3]; + if (b3D) { + dZ = *(float*)&ScriptParams[4]; + debug = ScriptParams[5]; + } + else { + debug = ScriptParams[4]; + } + result = false; + bool in_area; + if (b3D) { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y && + Z - dZ <= pos.z && + Z + dZ >= pos.z; + } + else { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y; + } + if (in_area) { + switch (command) { + case COMMAND_LOCATE_CHAR_ANY_MEANS_OBJECT_2D: + case COMMAND_LOCATE_CHAR_ANY_MEANS_OBJECT_3D: + result = true; + break; + case COMMAND_LOCATE_CHAR_ON_FOOT_OBJECT_2D: + case COMMAND_LOCATE_CHAR_ON_FOOT_OBJECT_3D: + result = !pPed->bInVehicle; + break; + case COMMAND_LOCATE_CHAR_IN_CAR_OBJECT_2D: + case COMMAND_LOCATE_CHAR_IN_CAR_OBJECT_3D: + result = pPed->bInVehicle; + break; + default: + assert(false); + break; + } + } + UpdateCompareFlag(result); + if (debug) + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : -100.0f); + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); + else + CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); + } +} + +void CRunningScript::LocateCarCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug, decided = false; + float X, Y, Z, dX, dY, dZ; + switch (command) { + case COMMAND_LOCATE_CAR_3D: + case COMMAND_LOCATE_STOPPED_CAR_3D: + b3D = true; + break; + default: + b3D = false; + break; + } + CollectParameters(pIp, b3D ? 8 : 6); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + assert(pVehicle); + CVector pos = pVehicle->GetPosition(); + switch (command) { + case COMMAND_LOCATE_STOPPED_CAR_2D: + case COMMAND_LOCATE_STOPPED_CAR_3D: + if (!CTheScripts::IsVehicleStopped(pVehicle)) { + result = false; + decided = true; + } + break; + default: + break; + } + X = *(float*)&ScriptParams[1]; + Y = *(float*)&ScriptParams[2]; + if (b3D) { + Z = *(float*)&ScriptParams[3]; + dX = *(float*)&ScriptParams[4]; + dY = *(float*)&ScriptParams[5]; + dZ = *(float*)&ScriptParams[6]; + debug = ScriptParams[7]; + } + else { + dX = *(float*)&ScriptParams[3]; + dY = *(float*)&ScriptParams[4]; + debug = ScriptParams[5]; + } + if (!decided) { + result = false; + bool in_area; + if (b3D) { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y && + Z - dZ <= pos.z && + Z + dZ >= pos.z; + } + else { + in_area = X - dX <= pos.x && + X + dX >= pos.x && + Y - dY <= pos.y && + Y + dY >= pos.y; + } + result = in_area; + } + UpdateCompareFlag(result); + if (debug) + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : -100.0f); + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); + else + CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); + } +} + +void CRunningScript::LocateSniperBulletCommand(int32 command, uint32* pIp) +{ + bool b3D, result, debug; + float X, Y, Z, dX, dY, dZ; + switch (command) { + case COMMAND_LOCATE_SNIPER_BULLET_3D: + b3D = true; + break; + default: + b3D = false; + break; + } + CollectParameters(pIp, b3D ? 7 : 5); + X = *(float*)&ScriptParams[0]; + Y = *(float*)&ScriptParams[1]; + if (b3D) { + Z = *(float*)&ScriptParams[2]; + dX = *(float*)&ScriptParams[3]; + dY = *(float*)&ScriptParams[4]; + dZ = *(float*)&ScriptParams[5]; + debug = ScriptParams[6]; + } + else { + dX = *(float*)&ScriptParams[2]; + dY = *(float*)&ScriptParams[3]; + debug = ScriptParams[4]; + } + result = CBulletInfo::TestForSniperBullet(X - dX, X + dX, Y - dY, Y + dY, b3D ? Z - dZ : -1000.0f, b3D ? Z + dZ : 1000.0f); + UpdateCompareFlag(result); + if (debug) + CTheScripts::HighlightImportantArea((uint32)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : -100.0f); + if (CTheScripts::DbgFlag) { + if (b3D) + CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); + else + CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); + } } -WRAPPER void CRunningScript::LocatePlayerCommand(int32, uint32*) { EAXJMP(0x44FE10); } -WRAPPER void CRunningScript::LocatePlayerCharCommand(int32, uint32*) { EAXJMP(0x4501E0); } -WRAPPER void CRunningScript::LocatePlayerCarCommand(int32, uint32*) { EAXJMP(0x450540); } -WRAPPER void CRunningScript::LocateCharCommand(int32, uint32*) { EAXJMP(0x450870); } -WRAPPER void CRunningScript::LocateCharCharCommand(int32, uint32*) { EAXJMP(0x450BF0); } -WRAPPER void CRunningScript::LocateCharCarCommand(int32, uint32*) { EAXJMP(0x450F30); } -WRAPPER void CRunningScript::LocateCharObjectCommand(int32, uint32*) { EAXJMP(0x451260); } -WRAPPER void CRunningScript::LocateCarCommand(int32, uint32*) { EAXJMP(0x451590); } -WRAPPER void CRunningScript::LocateSniperBulletCommand(int32, uint32*) { EAXJMP(0x4518A0); } WRAPPER void CRunningScript::PlayerInAreaCheckCommand(int32, uint32*) { EAXJMP(0x451A60); } WRAPPER void CRunningScript::PlayerInAngledAreaCheckCommand(int32, uint32*) { EAXJMP(0x451E50); } WRAPPER void CRunningScript::CharInAreaCheckCommand(int32, uint32*) { EAXJMP(0x4523B0); } WRAPPER void CRunningScript::CarInAreaCheckCommand(int32, uint32*) { EAXJMP(0x452750); } - -WRAPPER void CTheScripts::DrawScriptSpheres() { EAXJMP(0x44FAC0); } WRAPPER void CRunningScript::DoDeatharrestCheck() { EAXJMP(0x452A30); } + +int16 CRunningScript::GetPadState(uint16 pad, uint16 button) +{ + CPad* pPad = CPad::GetPad(pad); + switch (button) { + case 0: return pPad->NewState.LeftStickX; + case 1: return pPad->NewState.LeftStickY; + case 2: return pPad->NewState.RightStickX; + case 3: return pPad->NewState.RightStickY; + case 4: return pPad->NewState.LeftShoulder1; + case 5: return pPad->NewState.LeftShoulder2; + case 6: return pPad->NewState.RightShoulder1; + case 7: return pPad->NewState.RightShoulder2; + case 8: return pPad->NewState.DPadUp; + case 9: return pPad->NewState.DPadDown; + case 10: return pPad->NewState.DPadLeft; + case 11: return pPad->NewState.DPadRight; + case 12: return pPad->NewState.Start; + case 13: return pPad->NewState.Select; + case 14: return pPad->NewState.Square; + case 15: return pPad->NewState.Triangle; + case 16: return pPad->NewState.Cross; + case 17: return pPad->NewState.Circle; + case 18: return pPad->NewState.LeftShock; + case 19: return pPad->NewState.RightShock; + default: break; + } + return 0; +} + WRAPPER void CTheScripts::DrawDebugSquare(float, float, float, float) { EAXJMP(0x452D00); } +WRAPPER void CTheScripts::DrawDebugAngledSquare(float, float, float, float, float, float, float, float) { EAXJMP(0x452F00); } WRAPPER void CTheScripts::DrawDebugCube(float, float, float, float, float, float) { EAXJMP(0x453100); } +WRAPPER void CTheScripts::DrawDebugAngledCube(float, float, float, float, float, float, float, float, float, float) { EAXJMP(0x4532F0); } WRAPPER void CTheScripts::ScriptDebugLine3D(float x1, float y1, float z1, float x2, float y2, float z2, int col, int col2) { EAXJMP(0x4534E0); } +WRAPPER void CTheScripts::RenderTheScriptDebugLines() { EAXJMP(0x453550); } +WRAPPER void CTheScripts::SaveAllScripts(uint8*, uint32*) { EAXJMP(0x4535E0); } +WRAPPER void CTheScripts::LoadAllScripts(uint8*, uint32) { EAXJMP(0x453B30); } WRAPPER void CTheScripts::ClearSpaceForMissionEntity(const CVector&, CEntity*) { EAXJMP(0x454060); } WRAPPER void CTheScripts::HighlightImportantArea(uint32, float, float, float, float, float) { EAXJMP(0x454320); } +WRAPPER void CTheScripts::HighlightImportantAngledArea(uint32, float, float, float, float, float, float, float, float, float) { EAXJMP(0x454430); } +WRAPPER bool CTheScripts::IsPedStopped(CPed*) { EAXJMP(0x454670); } +WRAPPER bool CTheScripts::IsPlayerStopped(CPlayerInfo*) { EAXJMP(0x4546C0); } + +bool CTheScripts::IsVehicleStopped(CVehicle* pVehicle) +{ + return 0.01f * CTimer::GetTimeStep() >= pVehicle->m_fDistanceTravelled; +} + WRAPPER void CTheScripts::CleanUpThisVehicle(CVehicle*) { EAXJMP(0x4548D0); } WRAPPER void CTheScripts::CleanUpThisPed(CPed*) { EAXJMP(0x4547A0); } WRAPPER void CTheScripts::CleanUpThisObject(CObject*) { EAXJMP(0x454910); } WRAPPER void CTheScripts::ReadObjectNamesFromScript() { EAXJMP(0x454960); } WRAPPER void CTheScripts::UpdateObjectIndices() { EAXJMP(0x454AD0); } WRAPPER void CTheScripts::ReadMultiScriptFileOffsetsFromScript() { EAXJMP(0x454BC0); } -WRAPPER bool CTheScripts::IsPedStopped(CPed*) { EAXJMP(0x454670); } -WRAPPER bool CTheScripts::IsPlayerStopped(CPlayerInfo*) { EAXJMP(0x4546C0); } STARTPATCHES -InjectHook(0x437AE0, &CMissionCleanup::Init, PATCH_JUMP); -InjectHook(0x437BA0, &CMissionCleanup::AddEntityToList, PATCH_JUMP); -InjectHook(0x437BD0, &CMissionCleanup::RemoveEntityFromList, PATCH_JUMP); -InjectHook(0x437C10, &CMissionCleanup::Process, PATCH_JUMP); -InjectHook(0x437DC0, &CUpsideDownCarCheck::Init, PATCH_JUMP); -InjectHook(0x437EE0, &CUpsideDownCarCheck::UpdateTimers, PATCH_JUMP); -InjectHook(0x437F80, &CUpsideDownCarCheck::AreAnyCarsUpsideDown, PATCH_JUMP); -InjectHook(0x437FB0, &CUpsideDownCarCheck::AddCarToCheck, PATCH_JUMP); -InjectHook(0x437FE0, &CUpsideDownCarCheck::RemoveCarFromCheck, PATCH_JUMP); -InjectHook(0x438010, &CUpsideDownCarCheck::HasCarBeenUpsideDownForAWhile, PATCH_JUMP); -InjectHook(0x438050, &CStuckCarCheck::Init, PATCH_JUMP); -InjectHook(0x4380A0, &CStuckCarCheck::Process, PATCH_JUMP); -InjectHook(0x4381C0, &CStuckCarCheck::AddCarToCheck, PATCH_JUMP); -InjectHook(0x438240, &CStuckCarCheck::RemoveCarFromCheck, PATCH_JUMP); -InjectHook(0x4382A0, &CStuckCarCheck::HasCarBeenStuckForAWhile, PATCH_JUMP); -InjectHook(0x4382E0, &CRunningScript::CollectParameters, PATCH_JUMP); -InjectHook(0x438460, &CRunningScript::CollectNextParameterWithoutIncreasingPC, PATCH_JUMP); -InjectHook(0x4385A0, &CRunningScript::StoreParameters, PATCH_JUMP); -InjectHook(0x438640, &CRunningScript::GetPointerToScriptVariable, PATCH_JUMP); InjectHook(0x438790, &CTheScripts::Init, PATCH_JUMP); -InjectHook(0x439000, &CTheScripts::StartNewScript, PATCH_JUMP); InjectHook(0x439040, &CTheScripts::Process, PATCH_JUMP); InjectHook(0x439400, &CTheScripts::StartTestScript, PATCH_JUMP); InjectHook(0x439410, &CTheScripts::IsPlayerOnAMission, PATCH_JUMP); +InjectHook(0x44FD10, &CTheScripts::UndoBuildingSwaps, PATCH_JUMP); +InjectHook(0x44FD60, &CTheScripts::UndoEntityVisibilitySettings, PATCH_JUMP); +//InjectHook(0x4534E0, &CTheScripts::ScriptDebugLine3D, PATCH_JUMP); +//InjectHook(0x453550, &CTheScripts::RenderTheScriptDebugLines, PATCH_JUMP); +//InjectHook(0x4535E0, &CTheScripts::SaveAllScripts, PATCH_JUMP); +//InjectHook(0x453B30, &CTheScripts::LoadAllScripts, PATCH_JUMP); +//InjectHook(0x454060, &CTheScripts::ClearSpaceForMissionEntity, PATCH_JUMP); ENDPATCHES diff --git a/src/control/Script.h b/src/control/Script.h index aa6f7e58..5533c417 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -11,6 +11,8 @@ class CPed; class CObject; class CPlayerInfo; +class CRunningScript; + #define KEY_LENGTH_IN_SCRIPT 8 struct CScriptRectangle @@ -48,7 +50,26 @@ struct CTextLine float m_fAtY; wchar m_Text[SCRIPT_TEXT_MAX_LENGTH]; - void Reset(); + void Reset() + { + m_fScaleX = 0.48f; + m_fScaleY = 1.12f; + m_sColor = CRGBA(225, 225, 225, 255); + m_bJustify = false; + m_bRightJustify = false; + m_bCentered = false; + m_bBackground = false; + m_bBackgroundOnly = false; + m_fWrapX = 182.0f; /* TODO: scaling as bugfix */ + m_fCenterSize = 640.0f; /* --||-- */ + m_sBackgroundColor = CRGBA(128, 128, 128, 128); + m_bTextProportional = true; + m_bTextBeforeFade = false; + m_nFont = 2; /* enum? */ + m_fAtX = 0.0f; + m_fAtY = 0.0f; + memset(&m_Text, 0, sizeof(m_Text)); + } }; static_assert(sizeof(CTextLine) == 0x414, "Script.h: error"); @@ -63,123 +84,6 @@ struct CScriptSphere }; enum { - MAX_STACK_DEPTH = 6, - NUM_LOCAL_VARS = 16, - NUM_TIMERS = 2 -}; - -class CRunningScript -{ - CRunningScript *next; - CRunningScript *prev; - char m_abScriptName[8]; - uint32 m_nIp; - uint32 m_anStack[MAX_STACK_DEPTH]; - uint16 m_nStackPointer; - int32 m_anLocalVariables[NUM_LOCAL_VARS + NUM_TIMERS]; - bool m_bCondResult; - bool m_bIsMissionScript; - bool m_bSkipWakeTime; - uint32 m_nWakeTime; - uint16 m_nAndOrState; - bool m_bNotFlag; - bool m_bDeatharrestEnabled; - bool m_bDeatharrestExecuted; - bool m_bMissionFlag; - -public: - void SetIP(uint32 ip) { m_nIp = ip; } - CRunningScript* GetNext() { return next; } - void UpdateTimers(float timeStep){ - m_anLocalVariables[NUM_LOCAL_VARS] += timeStep; - m_anLocalVariables[NUM_LOCAL_VARS + 1] += timeStep; - } - - bool ThisIsAValidRandomPed(uint32 pedtype){ - switch (pedtype){ - case PEDTYPE_CIVMALE: - case PEDTYPE_CIVFEMALE: - case PEDTYPE_GANG1: - case PEDTYPE_GANG2: - case PEDTYPE_GANG3: - case PEDTYPE_GANG4: - case PEDTYPE_GANG5: - case PEDTYPE_GANG6: - case PEDTYPE_GANG7: - case PEDTYPE_GANG8: - case PEDTYPE_GANG9: - case PEDTYPE_CRIMINAL: - case PEDTYPE_PROSTITUTE: - return true; - default: - return false; - } - } - - float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; } - - void CollectParameters(uint32*, int16); - int32 CollectNextParameterWithoutIncreasingPC(uint32); - int32* GetPointerToScriptVariable(uint32*, int16); - void StoreParameters(uint32*, int16); - void Init(); - void RemoveScriptFromList(CRunningScript**); - void AddScriptToList(CRunningScript**); - void Process(); - int8 ProcessOneCommand(); - void DoDeatharrestCheck(); - int8 ProcessCommands0To99(int32); - int8 ProcessCommands100To199(int32); - int8 ProcessCommands200To299(int32); - int8 ProcessCommands300To399(int32); - int8 ProcessCommands400To499(int32); - int8 ProcessCommands500To599(int32); - int8 ProcessCommands600To699(int32); - int8 ProcessCommands700To799(int32); - int8 ProcessCommands800To899(int32); - int8 ProcessCommands900To999(int32); - int8 ProcessCommands1000To1099(int32); -#ifndef GTA_PS2 - int8 ProcessCommands1100To1199(int32); -#endif - void UpdateCompareFlag(bool); - int16 GetPadState(uint16, uint16); - void LocatePlayerCommand(int32, uint32*); - void LocatePlayerCharCommand(int32, uint32*); - void LocatePlayerCarCommand(int32, uint32*); - void LocateCharCommand(int32, uint32*); - void LocateCharCharCommand(int32, uint32*); - void LocateCharCarCommand(int32, uint32*); - void LocateCharObjectCommand(int32, uint32*); - void LocateCarCommand(int32, uint32*); - void LocateSniperBulletCommand(int32, uint32*); - void PlayerInAreaCheckCommand(int32, uint32*); - void PlayerInAngledAreaCheckCommand(int32, uint32*); - void CharInAreaCheckCommand(int32, uint32*); - void CarInAreaCheckCommand(int32, uint32*); -private: - enum { - ANDOR_NONE = 0, - ANDS_1 = 1, - ANDS_2, - ANDS_3, - ANDS_4, - ANDS_5, - ANDS_6, - ANDS_7, - ANDS_8, - ORS_1 = 21, - ORS_2, - ORS_3, - ORS_4, - ORS_5, - ORS_6, - ORS_7, - ORS_8 - }; -}; - -enum { CLEANUP_UNUSED = 0, CLEANUP_CAR, CLEANUP_CHAR, @@ -318,7 +222,6 @@ enum { class CTheScripts { -public: static uint8(&ScriptSpace)[SIZE_SCRIPT_SPACE]; static CRunningScript(&ScriptsArray)[MAX_NUM_SCRIPTS]; static int32(&BaseBriefIdForContact)[MAX_NUM_CONTACTS]; @@ -358,16 +261,40 @@ public: static bool &UseTextCommands; static uint16 &CommandsExecuted; static uint16 &ScriptsUpdated; + public: - static void ScriptDebugLine3D(float x1, float y1, float z1, float x2, float y2, float z2, int col, int col2); - static void CleanUpThisVehicle(CVehicle*); - static void CleanUpThisPed(CPed*); - static void CleanUpThisObject(CObject*); static void Init(); - static CRunningScript* StartNewScript(uint32); static void Process(); + static CRunningScript* StartTestScript(); static bool IsPlayerOnAMission(); + static void ClearSpaceForMissionEntity(const CVector&, CEntity*); + + static void UndoBuildingSwaps(); + static void UndoEntityVisibilitySettings(); + + static void ScriptDebugLine3D(float x1, float y1, float z1, float x2, float y2, float z2, int col, int col2); + static void RenderTheScriptDebugLines(); + + static void SaveAllScripts(uint8*, uint32*); + static void LoadAllScripts(uint8*, uint32); + + static bool IsDebugOn() { return DbgFlag; }; + static void InvertDebugFlag() { DbgFlag = !DbgFlag; } + + static int32* GetPointerToScriptVariable(int32 offset) { return (int32*)&ScriptSpace[offset]; } + + static void ResetCountdownToMakePlayerUnsafe() { CountdownToMakePlayerUnsafe = 0; } + static bool IsCountdownToMakePlayerUnsafeOn() { return CountdownToMakePlayerUnsafe != 0; } + +private: + + static CRunningScript* StartNewScript(uint32); + + static void CleanUpThisVehicle(CVehicle*); + static void CleanUpThisPed(CPed*); + static void CleanUpThisObject(CObject*); + static bool IsPedStopped(CPed*); static bool IsPlayerStopped(CPlayerInfo*); static bool IsVehicleStopped(CVehicle*); @@ -376,10 +303,13 @@ public: static void UpdateObjectIndices(); static void ReadMultiScriptFileOffsetsFromScript(); static void DrawScriptSpheres(); - static void ClearSpaceForMissionEntity(const CVector&, CEntity*); static void HighlightImportantArea(uint32, float, float, float, float, float); + static void HighlightImportantAngledArea(uint32, float, float, float, float, float, float, float, float, float); static void DrawDebugSquare(float, float, float, float); + static void DrawDebugAngledSquare(float, float, float, float, float, float, float, float); static void DrawDebugCube(float, float, float, float, float, float); + static void DrawDebugAngledCube(float, float, float, float, float, float, float, float, float, float); + static void AddToInvisibilitySwapArray(CEntity*, bool); static void AddToBuildingSwapArray(CBuilding*, int32, int32); @@ -388,36 +318,163 @@ public: static int32 GetNewUniqueScriptSphereIndex(int32 index); static void RemoveScriptSphere(int32 index); - static int32 Read4BytesFromScript(uint32* pIp){ + friend class CRunningScript; + friend class CHud; + friend void CMissionCleanup::Process(); +}; + + +enum { + MAX_STACK_DEPTH = 6, + NUM_LOCAL_VARS = 16, + NUM_TIMERS = 2 +}; + +class CRunningScript +{ + enum { + ANDOR_NONE = 0, + ANDS_1 = 1, + ANDS_2, + ANDS_3, + ANDS_4, + ANDS_5, + ANDS_6, + ANDS_7, + ANDS_8, + ORS_1 = 21, + ORS_2, + ORS_3, + ORS_4, + ORS_5, + ORS_6, + ORS_7, + ORS_8 + }; + + CRunningScript* next; + CRunningScript* prev; + char m_abScriptName[8]; + uint32 m_nIp; + uint32 m_anStack[MAX_STACK_DEPTH]; + uint16 m_nStackPointer; + int32 m_anLocalVariables[NUM_LOCAL_VARS + NUM_TIMERS]; + bool m_bCondResult; + bool m_bIsMissionScript; + bool m_bSkipWakeTime; + uint32 m_nWakeTime; + uint16 m_nAndOrState; + bool m_bNotFlag; + bool m_bDeatharrestEnabled; + bool m_bDeatharrestExecuted; + bool m_bMissionFlag; + +public: + void SetIP(uint32 ip) { m_nIp = ip; } + CRunningScript* GetNext() const { return next; } + void UpdateTimers(float timeStep) { + m_anLocalVariables[NUM_LOCAL_VARS] += timeStep; + m_anLocalVariables[NUM_LOCAL_VARS + 1] += timeStep; + } + + static int32 Read4BytesFromScript(uint32* pIp) { int32 retval = 0; - for (int i = 0; i < 4; i++){ - retval |= ScriptSpace[(*pIp)++] << (8 * i); + for (int i = 0; i < 4; i++) { + retval |= CTheScripts::ScriptSpace[(*pIp)++] << (8 * i); } return retval; } - static int16 Read2BytesFromScript(uint32* pIp){ + static int16 Read2BytesFromScript(uint32* pIp) { int16 retval = 0; - for (int i = 0; i < 2; i++){ - retval |= ScriptSpace[(*pIp)++] << (8 * i); + for (int i = 0; i < 2; i++) { + retval |= CTheScripts::ScriptSpace[(*pIp)++] << (8 * i); } return retval; } - static int8 Read1ByteFromScript(uint32* pIp){ + static int8 Read1ByteFromScript(uint32* pIp) { int8 retval = 0; - for (int i = 0; i < 1; i++){ - retval |= ScriptSpace[(*pIp)++] << (8 * i); + for (int i = 0; i < 1; i++) { + retval |= CTheScripts::ScriptSpace[(*pIp)++] << (8 * i); } return retval; } - static float ReadFloatFromScript(uint32* pIp){ + static float ReadFloatFromScript(uint32* pIp) { return Read2BytesFromScript(pIp) / 16.0f; } - static void ReadTextLabelFromScript(uint32* pIp, char* buf){ - strncpy(buf, (const char*)&ScriptSpace[*pIp], KEY_LENGTH_IN_SCRIPT); + static void ReadTextLabelFromScript(uint32* pIp, char* buf) { + strncpy(buf, (const char*)&CTheScripts::ScriptSpace[*pIp], KEY_LENGTH_IN_SCRIPT); } static wchar* GetTextByKeyFromScript(uint32* pIp) { - wchar* text = TheText.Get((const char*)&ScriptSpace[*pIp]); + wchar* text = TheText.Get((const char*)&CTheScripts::ScriptSpace[*pIp]); *pIp += KEY_LENGTH_IN_SCRIPT; return text; } + + void Init(); + void Process(); + + void RemoveScriptFromList(CRunningScript**); + void AddScriptToList(CRunningScript**); + +private: + void CollectParameters(uint32*, int16); + int32 CollectNextParameterWithoutIncreasingPC(uint32); + int32* GetPointerToScriptVariable(uint32*, int16); + void StoreParameters(uint32*, int16); + + int8 ProcessOneCommand(); + void DoDeatharrestCheck(); + void UpdateCompareFlag(bool); + int16 GetPadState(uint16, uint16); + + int8 ProcessCommands0To99(int32); + int8 ProcessCommands100To199(int32); + int8 ProcessCommands200To299(int32); + int8 ProcessCommands300To399(int32); + int8 ProcessCommands400To499(int32); + int8 ProcessCommands500To599(int32); + int8 ProcessCommands600To699(int32); + int8 ProcessCommands700To799(int32); + int8 ProcessCommands800To899(int32); + int8 ProcessCommands900To999(int32); + int8 ProcessCommands1000To1099(int32); +#ifndef GTA_PS2 + int8 ProcessCommands1100To1199(int32); +#endif + void LocatePlayerCommand(int32, uint32*); + void LocatePlayerCharCommand(int32, uint32*); + void LocatePlayerCarCommand(int32, uint32*); + void LocateCharCommand(int32, uint32*); + void LocateCharCharCommand(int32, uint32*); + void LocateCharCarCommand(int32, uint32*); + void LocateCharObjectCommand(int32, uint32*); + void LocateCarCommand(int32, uint32*); + void LocateSniperBulletCommand(int32, uint32*); + void PlayerInAreaCheckCommand(int32, uint32*); + void PlayerInAngledAreaCheckCommand(int32, uint32*); + void CharInAreaCheckCommand(int32, uint32*); + void CarInAreaCheckCommand(int32, uint32*); + + float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; } + + bool ThisIsAValidRandomPed(uint32 pedtype) { + switch (pedtype) { + case PEDTYPE_CIVMALE: + case PEDTYPE_CIVFEMALE: + case PEDTYPE_GANG1: + case PEDTYPE_GANG2: + case PEDTYPE_GANG3: + case PEDTYPE_GANG4: + case PEDTYPE_GANG5: + case PEDTYPE_GANG6: + case PEDTYPE_GANG7: + case PEDTYPE_GANG8: + case PEDTYPE_GANG9: + case PEDTYPE_CRIMINAL: + case PEDTYPE_PROSTITUTE: + return true; + default: + return false; + } + } }; |