From 203dff9165d473d030d8945ef80f1c12350662cf Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 9 Jan 2021 20:33:21 +0300 Subject: [PATCH] script --- src/animation/CutsceneMgr.cpp | 2 ++ src/control/Script.cpp | 6 ++--- src/control/Script3.cpp | 6 ++--- src/control/Script4.cpp | 15 ++++++------ src/control/Script6.cpp | 4 ---- src/control/Script7.cpp | 21 +++++++++++++++-- src/control/Script8.cpp | 44 ++++++++++++++++++++++++----------- src/core/Game.cpp | 2 +- src/text/Text.cpp | 2 +- src/vehicles/Bike.cpp | 2 +- 10 files changed, 68 insertions(+), 36 deletions(-) diff --git a/src/animation/CutsceneMgr.cpp b/src/animation/CutsceneMgr.cpp index eeec2728..88c73661 100644 --- a/src/animation/CutsceneMgr.cpp +++ b/src/animation/CutsceneMgr.cpp @@ -431,6 +431,7 @@ CCutsceneMgr::DeleteCutsceneData(void) } ms_numCutsceneObjs = 0; + /* TODO!!! tmp hack for (int i = MI_SPECIAL01; i < MI_SPECIAL21; i++) { CBaseModelInfo *minfo = CModelInfo::GetModelInfo(i); CColModel *colModel = minfo->GetColModel(); @@ -439,6 +440,7 @@ CCutsceneMgr::DeleteCutsceneData(void) minfo->SetColModel(&CTempColModels::ms_colModelPed1); } } + */ if (ms_animLoaded) CAnimManager::RemoveLastAnimFile(); diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 5fbf5779..df851daa 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -2385,7 +2385,7 @@ int32* GetPointerToScriptVariableForDebug(CRunningScript* pScript, uint32* pIp, script_assert(size > 0); script_assert(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id] < size); uint8 index = Min(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id], size - 1); - sprintf(tmpstr, " $%d[%d@]", ((int)(type - ARGUMENT_GLOBAL_ARRAY) << 8) + index_in_block, index_id); + sprintf(tmpstr, " $%d[%d@ (%d)]", ((int)(type - ARGUMENT_GLOBAL_ARRAY) << 8) + index_in_block, index_id, pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id]); strcat(buf, tmpstr); return (int32*)&CTheScripts::ScriptSpace[4 * (((int)(type - ARGUMENT_GLOBAL_ARRAY) << 8) + index + index_in_block)]; } @@ -2401,7 +2401,7 @@ int32* GetPointerToScriptVariableForDebug(CRunningScript* pScript, uint32* pIp, script_assert(size > 0); script_assert(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id] < size); uint8 index = Min(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id], size - 1); - sprintf(tmpstr, " %d@[%d@]", (type - ARGUMENT_LOCAL_ARRAY), index_id); + sprintf(tmpstr, " %d@[%d@ (%d)]", (type - ARGUMENT_LOCAL_ARRAY), index_id, pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id]); strcat(buf, tmpstr); return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL_ARRAY) + index]; } @@ -2412,7 +2412,7 @@ int32* GetPointerToScriptVariableForDebug(CRunningScript* pScript, uint32* pIp, } else { assert(type >= ARGUMENT_TIMER); - sprintf(tmpstr, " TIMER%d@", (type - ARGUMENT_LOCAL_ARRAY)); + sprintf(tmpstr, " TIMER%d@", (type - ARGUMENT_TIMER)); strcat(buf, tmpstr); return &pScript->m_anLocalVariables[NUM_LOCAL_VARS + 8 + (type - ARGUMENT_TIMER)]; // why 8? } diff --git a/src/control/Script3.cpp b/src/control/Script3.cpp index 26e1187d..0134df00 100644 --- a/src/control/Script3.cpp +++ b/src/control/Script3.cpp @@ -1787,10 +1787,9 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) pBoat->AutoPilot.m_nCruiseSpeed = *(float*)&ScriptParams[1]; return 0; } - /* case COMMAND_GET_RANDOM_CHAR_IN_AREA: { - CollectParameters(&m_nIp, 4); + CollectParameters(&m_nIp, 7); int ped_handle = -1; CVector pos = FindPlayerCoors(); float x1 = *(float*)&ScriptParams[0]; @@ -1814,7 +1813,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) continue; // if (pPed->GetModelIndex() == MI_SCUM_WOM || pPed->GetModelIndex() == MI_SCUM_MAN) // continue; - if (!ThisIsAValidRandomPed(pPed->m_nPedType)) + if (!ThisIsAValidRandomPed(pPed->m_nPedType, ScriptParams[5], ScriptParams[6], ScriptParams[7])) // TODO continue; if (pPed->bIsLeader || pPed->m_leader) continue; @@ -1836,7 +1835,6 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) StoreParameters(&m_nIp, 1); return 0; } - */ case COMMAND_GET_RANDOM_CHAR_IN_ZONE: { char zone[KEY_LENGTH_IN_SCRIPT]; diff --git a/src/control/Script4.cpp b/src/control/Script4.cpp index 64928e7a..a8cc9b9c 100644 --- a/src/control/Script4.cpp +++ b/src/control/Script4.cpp @@ -954,7 +954,10 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) pPed->WarpPedIntoCar(pVehicle); return 0; } - //case COMMAND_SWITCH_CAR_RADIO: + case COMMAND_SWITCH_CAR_RADIO: + CollectParameters(&m_nIp, 1); + DMAudio.ChangeMusicMode(ScriptParams[0]); + return 0; //case COMMAND_SET_AUDIO_STREAM: case COMMAND_PRINT_WITH_2_NUMBERS_BIG: { @@ -1418,7 +1421,6 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) pVehicle->m_bSirenOrAlarm = ScriptParams[1] != 0; return 0; } - /* case COMMAND_SWITCH_PED_ROADS_ON_ANGLED: { CollectParameters(&m_nIp, 7); @@ -1441,7 +1443,6 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) ThePaths.SwitchRoadsInAngledArea(*(float*)&ScriptParams[0], *(float*)&ScriptParams[1], *(float*)&ScriptParams[2], *(float*)&ScriptParams[3], *(float*)&ScriptParams[4], *(float*)&ScriptParams[5], *(float*)&ScriptParams[6], 1, 0); return 0; - */ case COMMAND_SET_CAR_WATERTIGHT: { CollectParameters(&m_nIp, 2); @@ -1967,12 +1968,10 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) CWorld::Add(car); return 0; } - /* case COMMAND_IS_COLLISION_IN_MEMORY: CollectParameters(&m_nIp, 1); UpdateCompareFlag(CCollision::ms_collisionInMemory == ScriptParams[0]); return 0; - */ case COMMAND_SET_WANTED_MULTIPLIER: CollectParameters(&m_nIp, 1); FindPlayerPed()->m_pWanted->m_fCrimeSensitivity = *(float*)&ScriptParams[0]; @@ -2042,7 +2041,8 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_HAS_MISSION_AUDIO_LOADED: { CollectParameters(&m_nIp, 1); - UpdateCompareFlag(DMAudio.GetMissionAudioLoadingStatus(ScriptParams[0] - 1) == 1); + //UpdateCompareFlag(DMAudio.GetMissionAudioLoadingStatus(ScriptParams[0] - 1) == 1); + UpdateCompareFlag(true); // TODO return 0; } case COMMAND_PLAY_MISSION_AUDIO: @@ -2052,7 +2052,8 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_HAS_MISSION_AUDIO_FINISHED: { CollectParameters(&m_nIp, 1); - UpdateCompareFlag(DMAudio.IsMissionAudioSampleFinished(ScriptParams[0] - 1)); + //UpdateCompareFlag(DMAudio.IsMissionAudioSampleFinished(ScriptParams[0] - 1)); // TODO + UpdateCompareFlag(true); return 0; } case COMMAND_GET_CLOSEST_CAR_NODE_WITH_HEADING: diff --git a/src/control/Script6.cpp b/src/control/Script6.cpp index 8915a089..02427eed 100644 --- a/src/control/Script6.cpp +++ b/src/control/Script6.cpp @@ -83,7 +83,6 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { switch (command) { //case COMMAND_FLASH_RADAR_BLIP: - /* case COMMAND_IS_CHAR_IN_CONTROL: { CollectParameters(&m_nIp, 1); @@ -91,7 +90,6 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) UpdateCompareFlag(pPed->IsPedInControl()); return 0; } - */ case COMMAND_SET_GENERATE_CARS_AROUND_CAMERA: CollectParameters(&m_nIp, 1); CCarCtrl::bCarsGeneratedAroundCamera = (ScriptParams[0] != 0); @@ -525,7 +523,6 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) StoreParameters(&m_nIp, 1); return 0; } - /* case COMMAND_MARK_ROADS_BETWEEN_LEVELS: { CollectParameters(&m_nIp, 6); @@ -574,7 +571,6 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) ThePaths.PedMarkRoadsBetweenLevelsInArea(infX, supX, infY, supY, infZ, supZ); return 0; } - */ case COMMAND_SET_CAR_AVOID_LEVEL_TRANSITIONS: { CollectParameters(&m_nIp, 2); diff --git a/src/control/Script7.cpp b/src/control/Script7.cpp index 344ea2c7..220a7c4d 100644 --- a/src/control/Script7.cpp +++ b/src/control/Script7.cpp @@ -816,7 +816,12 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) //case COMMAND_HAS_CHAR_BEEN_DAMAGED_BY_CAR: //case COMMAND_HAS_CAR_BEEN_DAMAGED_BY_CHAR: //case COMMAND_HAS_CAR_BEEN_DAMAGED_BY_CAR: - //case COMMAND_GET_RADIO_CHANNEL: + case COMMAND_GET_RADIO_CHANNEL: + { + // TODO + ScriptParams[0] = -1; + StoreParameters(&m_nIp, 1); + } //case COMMAND_DISPLAY_TEXT_WITH_3_NUMBERS: //case COMMAND_IS_CAR_DROWNING_IN_WATER: case COMMAND_IS_CHAR_DROWNING_IN_WATER: @@ -1327,7 +1332,19 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) CollectParameters(&m_nIp, 1); UpdateCompareFlag(CPools::GetPedPool()->GetAt(ScriptParams[0]) != 0); return 0; - //case COMMAND_DOES_VEHICLE_EXIST: + case COMMAND_DOES_VEHICLE_EXIST: + { + // TODO + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + bool bExist = false; + if (pVehicle) { + int index = CPools::GetVehiclePool()->GetJustIndex_NoFreeAssert(pVehicle); + bExist = (index >= 0 && index <= NUMVEHICLES); // TODO: FIX_BUGS + } + UpdateCompareFlag(bExist); + return 0; + } //case COMMAND_ADD_SHORT_RANGE_BLIP_FOR_CONTACT_POINT: case COMMAND_ADD_SHORT_RANGE_SPRITE_BLIP_FOR_CONTACT_POINT: { diff --git a/src/control/Script8.cpp b/src/control/Script8.cpp index 63102d24..f41ef8a4 100644 --- a/src/control/Script8.cpp +++ b/src/control/Script8.cpp @@ -421,7 +421,10 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) script_assert(false); return 0; case COMMAND_1451: - script_assert(false); + CollectParameters(&m_nIp, 1); + // TODO (GET_PAD_BUTTON_STATE) + ScriptParams[0] = 0; + StoreParameters(&m_nIp, 1); return 0; case COMMAND_1452: script_assert(false); @@ -518,7 +521,8 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) script_assert(false); return 0; case COMMAND_1479: - script_assert(false); + CollectParameters(&m_nIp, 2); + // TODO (SET_CHAR_ONLY_ENTER_BACK_DOOR) return 0; case COMMAND_1480: script_assert(false); @@ -644,7 +648,8 @@ int8 CRunningScript::ProcessCommands1500To1599(int32 command) script_assert(false); return 0; case COMMAND_1518: - script_assert(false); + // TODO (?) + UpdateCompareFlag(true); return 0; case COMMAND_1519: CollectParameters(&m_nIp, 1); @@ -768,7 +773,8 @@ int8 CRunningScript::ProcessCommands1500To1599(int32 command) script_assert(false); return 0; case COMMAND_1558: - script_assert(false); + UpdateCompareFlag(false); + // TODO return 0; case COMMAND_1559: script_assert(false); @@ -778,7 +784,8 @@ int8 CRunningScript::ProcessCommands1500To1599(int32 command) UpdateCompareFlag(false); return 0; case COMMAND_1561: - script_assert(false); + // TODO (check, SET_FS_DESTROYED_FLAG) + CTheScripts::FSDestroyedFlag = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) - (int32*)CTheScripts::ScriptSpace; return 0; case COMMAND_1562: script_assert(false); @@ -796,7 +803,8 @@ int8 CRunningScript::ProcessCommands1500To1599(int32 command) script_assert(false); return 0; case COMMAND_1567: - script_assert(false); + CollectParameters(&m_nIp, 1); + // TODO (BUILD_WORLD_GEOMETRY) return 0; case COMMAND_1568: script_assert(false); @@ -927,7 +935,8 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command) script_assert(false); return 0; case COMMAND_1607: - script_assert(false); + CollectParameters(&m_nIp, 1); + // TODO (SET_TOTAL_CARS_FOR_EXPORT) return 0; case COMMAND_1608: script_assert(false); @@ -951,10 +960,11 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command) script_assert(false); return 0; case COMMAND_1615: - script_assert(false); + // TODO (GET_DEVELOPER_FLAG?) + UpdateCompareFlag(false); return 0; case COMMAND_1616: - script_assert(false); + // TODO (SET_DEVELOPER_FLAG) return 0; case COMMAND_1617: script_assert(false); @@ -969,8 +979,12 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command) script_assert(false); return 0; case COMMAND_1621: - script_assert(false); + { + wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CollectParameters(&m_nIp, 2); + // TODO (SET_SUBTITLE_TEXT) return 0; + } case COMMAND_1622: script_assert(false); return 0; @@ -1035,7 +1049,8 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command) // TODO (LOCK_GARAGE?) return 0; case COMMAND_1641: - script_assert(false); + // TODO + UpdateCompareFlag(true); return 0; case COMMAND_1642: script_assert(false); @@ -1054,14 +1069,17 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command) // TODO (DISABLE_PAUSE_MENU?) return 0; case COMMAND_1647: - script_assert(false); + CollectParameters(&m_nIp, 1); + // TODO (IS_CHANNEL_PLAYING?) + UpdateCompareFlag(false); return 0; case COMMAND_1648: CollectParameters(&m_nIp, 3); // TODO (SET_CLOCK_EVENT_WARNING); return 0; case COMMAND_1649: - script_assert(false); + CollectParameters(&m_nIp, 3); + // TODO (SET_EXTRA_COLOUR_DIRECTION) return 0; case COMMAND_1650: script_assert(false); diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 636eed42..c5154bd4 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -901,7 +901,7 @@ void CGame::Process(void) if (!CReplay::IsPlayingBack()) CCranes::UpdateCranes(); CClouds::Update(); - CMovingThings::Update(); + //CMovingThings::Update(); // TODO CWaterCannons::Update(); CUserDisplay::Process(); CReplay::Update(); diff --git a/src/text/Text.cpp b/src/text/Text.cpp index a11acd26..fd1659dc 100644 --- a/src/text/Text.cpp +++ b/src/text/Text.cpp @@ -247,7 +247,7 @@ CText::LoadMissionText(char *MissionTableName) CFileMgr::SetDir("TEXT"); switch (FrontEndMenuManager.m_PrefsLanguage) { case CMenuManager::LANGUAGE_AMERICAN: - sprintf(filename, "AMERICAN.GXT"); + sprintf(filename, "ENGLISH.GXT"); break; case CMenuManager::LANGUAGE_FRENCH: sprintf(filename, "FRENCH.GXT"); diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp index 19e95a6e..531128be 100644 --- a/src/vehicles/Bike.cpp +++ b/src/vehicles/Bike.cpp @@ -83,7 +83,7 @@ CBike::CBike(int32 id, uint8 CreatedBy) case MI_SANCHEZ: m_bikeAnimType = ASSOCGRP_BIKE_DIRT; break; - default: assert(0 && "invalid bike model ID"); + default: m_bikeAnimType = ASSOCGRP_BIKE_STANDARD; //assert(0 && "invalid bike model ID"); // TODO } m_vehType = VEHICLE_TYPE_BIKE;