diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/control/Script.cpp | 21 | ||||
-rw-r--r-- | src/control/Script.h | 22 | ||||
-rw-r--r-- | src/control/Script8.cpp | 31 | ||||
-rw-r--r-- | src/control/Script9.cpp | 2 | ||||
-rw-r--r-- | src/leeds/base/sList.h | 35 |
5 files changed, 99 insertions, 12 deletions
diff --git a/src/control/Script.cpp b/src/control/Script.cpp index a9df5799..17572531 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -11,6 +11,7 @@ #include "CivilianPed.h" #include "Clock.h" #include "CopPed.h" +#include "Coronas.h" #include "Debug.h" #include "DMAudio.h" #include "EmergencyPed.h" @@ -98,7 +99,7 @@ uint16 CTheScripts::NumberOfExclusiveMissionScripts; bool CTheScripts::bPlayerHasMetDebbieHarry; bool CTheScripts::bPlayerIsInTheStatium; int CTheScripts::AllowedCollision[MAX_ALLOWED_COLLISIONS]; -bool CTheScripts::FSDestroyedFlag; +int CTheScripts::FSDestroyedFlag; short* CTheScripts::SavedVarIndices; int CTheScripts::NumSaveVars; int gScriptsFile = -1; @@ -107,6 +108,9 @@ bool CTheScripts::InTheScripts; CRunningScript* pCurrent; uint16 CTheScripts::NumTrueGlobals; uint16 CTheScripts::MostGlobals; +CVector gVectorSetInLua; +int CTheScripts::NextScriptCoronaID; +base::cSList<script_corona> CTheScripts::mCoronas; #ifdef MISSION_REPLAY @@ -2620,6 +2624,14 @@ bool CTheScripts::Init(bool loaddata) memset(&UsedObjectArray[i].name, 0, sizeof(UsedObjectArray[i].name)); UsedObjectArray[i].index = 0; } +#if defined FIX_BUGS || (!defined GTA_PS2 && !defined GTA_PSP) + for (base::cSList<script_corona>::tSItem* i = CTheScripts::mCoronas.first; i;) { + base::cSList<script_corona>::tSItem* next = i->next; + delete i; + i = next; + } + CTheScripts::mCoronas.first = nil; +#endif NumberOfUsedObjects = 0; if (ScriptSpace) Shutdown(); @@ -2772,8 +2784,6 @@ void CTheScripts::Process() UseTextCommands = 0; } - // TODO: mCoronas - #ifdef MISSION_REPLAY static uint32 TimeToWaitTill; switch (AllowMissionReplay) { @@ -2833,6 +2843,11 @@ void CTheScripts::Process() if (script && !script->m_bIsActive) script = nil; } + InTheScripts = false; + for (base::cSList<script_corona>::tSItem* i = CTheScripts::mCoronas.first; i; i = i->next) { + CCoronas::RegisterCorona((uint32)(uintptr)i, i->item.r, i->item.g, i->item.b, 255, CVector(i->item.x, i->item.y, i->item.z), + -i->item.size, 450.0f, i->item.type, i->item.flareType, 1, 0, 0, 0.0f); + } DbgFlag = false; #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT PrintToLog("Script processing done, ScriptsUpdated: %d, CommandsExecuted: %d\n", ScriptsUpdated, CommandsExecuted); diff --git a/src/control/Script.h b/src/control/Script.h index 780440dd..c30768b3 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -4,6 +4,7 @@ #include "Ped.h" #include "PedType.h" #include "Text.h" +#include "sList.h" #include "Sprite2d.h" class CEntity; @@ -273,6 +274,20 @@ struct tBuildingSwap int32 m_nOldModel; }; +struct script_corona +{ + int id; + float x; + float y; + float z; + float size; + uint8 r; + uint8 g; + uint8 b; + int type; + int flareType; +}; + enum { VAR_LOCAL = 1, @@ -343,12 +358,14 @@ public: static int AllowedCollision[MAX_ALLOWED_COLLISIONS]; static short* SavedVarIndices; static int NumSaveVars; - static bool FSDestroyedFlag; + static int FSDestroyedFlag; static int NextProcessId; static bool InTheScripts; static CRunningScript* pCurrent; static uint16 NumTrueGlobals; static uint16 MostGlobals; + static base::cSList<script_corona> mCoronas; + static int NextScriptCoronaID; static bool Init(bool loaddata = false); static void Process(); @@ -468,6 +485,8 @@ public: static void SetObjectiveForAllPedsInCollective(int, eObjective); #endif + bool IsFortStauntonDestroyed() { return *(int32*)&ScriptSpace[FSDestroyedFlag] == 1; } + }; extern int ScriptParams[32]; @@ -665,4 +684,5 @@ extern int scriptToLoad; #endif extern int gScriptsFile; +extern CVector gVectorSetInLua; diff --git a/src/control/Script8.cpp b/src/control/Script8.cpp index 55a56b2f..53e39b68 100644 --- a/src/control/Script8.cpp +++ b/src/control/Script8.cpp @@ -601,19 +601,36 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_CREATE_SCRIPT_CORONA: { CollectParameters(&m_nIp, 9); - static bool bShowed = false; - if (!bShowed) { - debug("CREATE_SCRIPT_CORONA not implemented"); - bShowed = true; - } - SET_INTEGER_PARAM(0, -1); + base::cSList<script_corona>::tSItem* pCorona = new base::cSList<script_corona>::tSItem(); + pCorona->item.x = GET_FLOAT_PARAM(0); + pCorona->item.y = GET_FLOAT_PARAM(1); + pCorona->item.z = GET_FLOAT_PARAM(2); + pCorona->item.id = CTheScripts::NextScriptCoronaID++; + if (pCorona->item.z <= MAP_Z_LOW_LIMIT) + pCorona->item.z = CWorld::FindGroundZForCoord(pCorona->item.x, pCorona->item.y); + pCorona->item.size = GET_FLOAT_PARAM(3); + pCorona->item.r = GET_INTEGER_PARAM(6); + pCorona->item.g = GET_INTEGER_PARAM(7); + pCorona->item.b = GET_INTEGER_PARAM(8); + pCorona->item.type = GET_INTEGER_PARAM(4); + pCorona->item.flareType = GET_INTEGER_PARAM(5); + SET_INTEGER_PARAM(0, pCorona->item.id); + CTheScripts::mCoronas.Insert(pCorona); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_REMOVE_SCRIPT_CORONA: + { CollectParameters(&m_nIp, 1); - // TODO + for (base::cSList<script_corona>::tSItem* i = CTheScripts::mCoronas.first; i; i = i->next) { + if (i->item.id == GET_INTEGER_PARAM(0)) { + CTheScripts::mCoronas.Remove(i); + delete i; + break; + } + } return 0; + } case COMMAND_IS_BOAT_IN_WATER: { CollectParameters(&m_nIp, 1); diff --git a/src/control/Script9.cpp b/src/control/Script9.cpp index c936e68f..183f73e7 100644 --- a/src/control/Script9.cpp +++ b/src/control/Script9.cpp @@ -651,7 +651,7 @@ int8 CRunningScript::ProcessCommands1500To1599(int32 command) return 0; } case COMMAND_GET_VECTOR_FROM_MULTIPLAYER: - // SET_VECTOR_PARAM(0, gVectorSetInLua); + SET_VECTOR_PARAM(0, gVectorSetInLua); StoreParameters(&m_nIp, 3); return 0; case COMMAND_PRINT_HELP_ALWAYS: diff --git a/src/leeds/base/sList.h b/src/leeds/base/sList.h new file mode 100644 index 00000000..378d8e31 --- /dev/null +++ b/src/leeds/base/sList.h @@ -0,0 +1,35 @@ +#pragma once + +namespace base +{ + +template<typename T> +class cSList +{ +public: + struct tSItem + { + tSItem* next; + T item; + }; + // extra field on PS2 + tSItem* first; + + cSList() { first = nil; } + void Insert(tSItem* item) { tSItem* n = first; first = item; item->next = n; } + void Remove(tSItem* item) { + if (first == item) { + first = item->next; + return; + } + tSItem* i = first; + while (i && i->next != item) + i = i->next; + assert(i); + i->next = item->next; + + } + +}; + +}
\ No newline at end of file |