diff options
Diffstat (limited to 'src/control/Script.cpp')
-rw-r--r-- | src/control/Script.cpp | 1482 |
1 files changed, 946 insertions, 536 deletions
diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 735c2c6f..038eff6d 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -49,18 +49,20 @@ #include "Timecycle.h" #include "TxdStore.h" #include "Bike.h" +#include "memoryManager.h" #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT #include <stdarg.h> #endif -//--MIAMI: file done +//--LCS: file done except TODOs and command table -uint8 CTheScripts::ScriptSpace[SIZE_SCRIPT_SPACE]; +uint8* CTheScripts::ScriptSpace; CRunningScript CTheScripts::ScriptsArray[MAX_NUM_SCRIPTS]; intro_text_line CTheScripts::IntroTextLines[MAX_NUM_INTRO_TEXT_LINES]; intro_script_rectangle CTheScripts::IntroRectangles[MAX_NUM_INTRO_RECTANGLES]; CSprite2d CTheScripts::ScriptSprites[MAX_NUM_SCRIPT_SRPITES]; script_sphere_struct CTheScripts::ScriptSphereArray[MAX_NUM_SCRIPT_SPHERES]; +tCollectiveData CTheScripts::CollectiveArray[MAX_NUM_COLLECTIVES]; tUsedObject CTheScripts::UsedObjectArray[MAX_NUM_USED_OBJECTS]; int32 CTheScripts::MultiScriptArray[MAX_NUM_MISSION_SCRIPTS]; tBuildingSwap CTheScripts::BuildingSwapArray[MAX_NUM_BUILDING_SWAPS]; @@ -96,10 +98,16 @@ uint32 CTheScripts::LastMissionPassedTime; uint16 CTheScripts::NumberOfExclusiveMissionScripts; bool CTheScripts::bPlayerHasMetDebbieHarry; bool CTheScripts::bPlayerIsInTheStatium; -#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) -int16 CTheScripts::CardStack[CARDS_IN_DECK * MAX_DECKS]; -int16 CTheScripts::CardStackPosition; -#endif +int CTheScripts::AllowedCollision[MAX_ALLOWED_COLLISIONS]; +bool CTheScripts::FSDestroyedFlag; +short* CTheScripts::SavedVarIndices; +int CTheScripts::NumSaveVars; +int gScriptsFile = -1; +int CTheScripts::NextProcessId = 1; +bool CTheScripts::InTheScripts; +CRunningScript* pCurrent; +uint16 CTheScripts::NumTrueGlobals; +uint16 CTheScripts::MostGlobals; #ifdef MISSION_REPLAY @@ -225,7 +233,7 @@ const tScriptCommandData commands[] = { REGISTER_COMMAND(COMMAND_GOSUB, INPUT_ARGUMENTS(ARGTYPE_LABEL,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_RETURN, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_LINE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_CREATE_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), REGISTER_COMMAND(COMMAND_GET_PLAYER_COORDINATES, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), REGISTER_COMMAND(COMMAND_SET_PLAYER_COORDINATES, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_IS_PLAYER_IN_AREA_2D, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_BOOL,), OUTPUT_ARGUMENTS(), true, -1, ""), @@ -284,16 +292,16 @@ const tScriptCommandData commands[] = { REGISTER_COMMAND(COMMAND_SET_LVAR_INT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ="), REGISTER_COMMAND(COMMAND_CSET_VAR_INT_TO_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), REGISTER_COMMAND(COMMAND_CSET_VAR_FLOAT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), - REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), - REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), + REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, 0, " =#"), + REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, 0, " =#"), REGISTER_COMMAND(COMMAND_CSET_VAR_INT_TO_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), REGISTER_COMMAND(COMMAND_CSET_VAR_FLOAT_TO_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), - REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), - REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " =#"), - REGISTER_COMMAND(COMMAND_ABS_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"), - REGISTER_COMMAND(COMMAND_ABS_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"), - REGISTER_COMMAND(COMMAND_ABS_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"), - REGISTER_COMMAND(COMMAND_ABS_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"), + REGISTER_COMMAND(COMMAND_CSET_LVAR_INT_TO_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, 0, " =#"), + REGISTER_COMMAND(COMMAND_CSET_LVAR_FLOAT_TO_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, 0, " =#"), + REGISTER_COMMAND(COMMAND_ABS_VAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"), + REGISTER_COMMAND(COMMAND_ABS_LVAR_INT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"), + REGISTER_COMMAND(COMMAND_ABS_VAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"), + REGISTER_COMMAND(COMMAND_ABS_LVAR_FLOAT, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, 0, " ABS"), REGISTER_COMMAND(COMMAND_GENERATE_RANDOM_FLOAT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), REGISTER_COMMAND(COMMAND_GENERATE_RANDOM_INT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), REGISTER_COMMAND(COMMAND_CREATE_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_PED_HANDLE,), false, -1, ""), @@ -356,6 +364,11 @@ const tScriptCommandData commands[] = { REGISTER_COMMAND(COMMAND_WHILE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_WHILENOT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_ENDWHILE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_214, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_215, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_216, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_217, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_218, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_ANDOR, INPUT_ARGUMENTS(ARGTYPE_ANDOR,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_LAUNCH_MISSION, INPUT_ARGUMENTS(ARGTYPE_LABEL,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_MISSION_HAS_FINISHED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), @@ -922,8 +935,8 @@ const tScriptCommandData commands[] = { REGISTER_COMMAND(COMMAND_PRINT_WITH_6_NUMBERS_NOW, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_PRINT_WITH_6_NUMBERS_SOON, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_SET_CHAR_OBJ_FOLLOW_CHAR_IN_FORMATION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_PLAYER_MADE_PROGRESS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_SET_PROGRESS_TOTAL, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PLAYER_MADE_PROGRESS, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PROGRESS_TOTAL, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_REGISTER_JUMP_DISTANCE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_REGISTER_JUMP_HEIGHT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_REGISTER_JUMP_FLIPS, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), @@ -1578,39 +1591,222 @@ const tScriptCommandData commands[] = { REGISTER_COMMAND(COMMAND_REGISTER_FIRE_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_IS_AUSTRALIAN_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), REGISTER_COMMAND(COMMAND_DISARM_CAR_BOMB, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), -#if (defined GTAVC_JP_PATCH || defined SUPPORT_JAPANESE_SCRIPT) REGISTER_COMMAND(COMMAND_IS_JAPANESE_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), -#elif (!defined GTA_PS2) - REGISTER_COMMAND(COMMAND_SET_ONSCREEN_COUNTER_FLASH_WHEN_FIRST_DISPLAYED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), -#endif -#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) - REGISTER_COMMAND(COMMAND_SHUFFLE_CARD_DECKS, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_FETCH_NEXT_CARD, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""), - REGISTER_COMMAND(COMMAND_GET_OBJECT_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), false, -1, ""), - REGISTER_COMMAND(COMMAND_IS_DEBUG_CAMERA_ON, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), - REGISTER_COMMAND(COMMAND_ADD_TO_OBJECT_ROTATION_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_SET_OBJECT_ROTATION_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_IS_OBJECT_STATIC, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""), - REGISTER_COMMAND(COMMAND_GET_ANGLE_BETWEEN_2D_VECTORS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ), false, -1, ""), - REGISTER_COMMAND(COMMAND_DO_2D_RECTANGLES_COLLIDE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), true, -1, ""), - REGISTER_COMMAND(COMMAND_GET_OBJECT_ROTATION_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), false, -1, ""), - REGISTER_COMMAND(COMMAND_ADD_VELOCITY_RELATIVE_TO_OBJECT_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_GET_OBJECT_SPEED, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ), false, -1, ""), -#endif -#if (defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT) - REGISTER_COMMAND(COMMAND_MARK_CUTSCENE_START, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_MARK_CUTSCENE_END, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_CUTSCENE_SCROLL, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), -#elif (defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) - REGISTER_COMMAND(COMMAND_IS_MISSION_SKIP, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""), - REGISTER_COMMAND(COMMAND_SET_IN_AMMUNATION, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_DO_SAVE_GAME, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_IS_RETRY, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""), - REGISTER_COMMAND(COMMAND_DUMMY, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_MARK_CUTSCENE_START, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_MARK_CUTSCENE_END, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_CUTSCENE_SCROLL, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), -#endif + REGISTER_COMMAND(COMMAND_1442, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1443, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1444, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1445, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1446, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1447, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1448, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1449, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1450, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1451, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1452, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1453, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CALL, INPUT_ARGUMENTS(ARGTYPE_FUNCTION, ), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_NOTCALL, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1456, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1457, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1458, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1459, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1460, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1461, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1462, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1463, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1464, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1465, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1466, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1467, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1468, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1469, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1470, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1471, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1472, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1473, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1474, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1475, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1476, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1477, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1478, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1479, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1480, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1481, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1482, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1483, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1484, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1485, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1486, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1487, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1488, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1489, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1490, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1491, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1492, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1493, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1494, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1495, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1496, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1497, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1498, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1499, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1500, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1501, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1502, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1503, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1504, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1505, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1506, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1507, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1508, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1509, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1510, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1511, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1512, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1513, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1514, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1515, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1516, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1517, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1518, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1519, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1520, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1521, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1522, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1523, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1524, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1525, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1526, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1527, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1528, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1529, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1530, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1531, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1532, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1533, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1534, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1535, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1536, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1537, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1538, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1539, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1540, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1541, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1542, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1543, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1544, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1545, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1546, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1547, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1548, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1549, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1550, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1551, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1552, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1553, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1554, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1555, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1556, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1557, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1558, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1559, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1560, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_1561, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1562, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1563, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1564, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1565, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1566, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1567, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1568, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1569, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_1570, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1571, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1572, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1573, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1574, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1575, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1576, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1577, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1578, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1579, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1580, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1581, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1582, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1583, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1584, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1585, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1586, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1587, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1588, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1589, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1590, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1591, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1592, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1593, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1594, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1595, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1596, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1597, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1598, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1599, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1600, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1601, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1602, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1603, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1604, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1605, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1606, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1607, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1608, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1609, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1610, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1611, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1612, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1613, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1614, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1615, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1616, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1617, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1618, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1619, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1620, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1621, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1622, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1623, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1624, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1625, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1626, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1627, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1628, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1629, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1630, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1631, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1632, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1633, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1634, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1635, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1636, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1637, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1638, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1639, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1640, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1641, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1642, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1643, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1644, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1645, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1646, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1647, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1648, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1649, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1650, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1651, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1652, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1653, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1654, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1655, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1656, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), }; #undef REGISTER_COMMAND #undef INPUT_ARGUMENTS @@ -1683,6 +1879,23 @@ cleanup_entity_struct* CMissionCleanup::FindFree() return nil; } +void SleepThisPed(cleanup_entity_struct* pCleanup, CPed* pPed) +{ + printf("*** SLEEPING PED %i %i\n", pCleanup->id, pPed->GetModelIndex()); + if (!pPed->GetIsStatic()) + pPed->RemoveFromMovingList(); + pPed->bIsStaticWaitingForCollision = true; +} + +void WakeThisPed(cleanup_entity_struct* pCleanup, CPed* pPed) +{ + printf("*** WAKING UP PED %i %i\n", pCleanup->id, pPed->GetModelIndex()); + pPed->bIsStaticWaitingForCollision = false; + if (!pPed->bIsStatic) + pPed->AddToMovingList(); + +} + void CMissionCleanup::AddEntityToList(int32 id, uint8 type) { cleanup_entity_struct* pNew = FindFree(); @@ -1752,46 +1965,100 @@ void CMissionCleanup::CheckIfCollisionHasLoadedForMissionObjects() { CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(m_sEntities[i].id); if (pVehicle) { - if (pVehicle->bIsStaticWaitingForCollision) { - if (CColStore::HasCollisionLoaded(pVehicle->GetPosition())) { - pVehicle->bIsStaticWaitingForCollision = false; + eLevelName level = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition()); + if (level == LEVEL_GENERIC) + level = CGame::currLevel; + if (!CColStore::HasCollisionLoaded(level)) { + if (!pVehicle->bIsStaticWaitingForCollision) { + if (!pVehicle->IsHeli() && !pVehicle->IsPlane() && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI && + pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE) { + printf("*** SLEEPING VEHICLE %i %i\n", m_sEntities[i].id, pVehicle->GetModelIndex()); if (!pVehicle->GetIsStatic()) - pVehicle->AddToMovingList(); + pVehicle->RemoveFromMovingList(); + pVehicle->bIsStaticWaitingForCollision = true; + } } } - } - break; - } - case CLEANUP_CHAR: - { - CPed* pPed = CPools::GetPedPool()->GetAt(m_sEntities[i].id); - if (pPed) { - if (pPed->bIsStaticWaitingForCollision) { - if (CColStore::HasCollisionLoaded(pPed->GetPosition())) { - pPed->bIsStaticWaitingForCollision = false; - if (!pPed->GetIsStatic()) - pPed->AddToMovingList(); + else { + if (pVehicle->bIsStaticWaitingForCollision) { + printf("*** WAKING UP VEHICLE %i %i\n", m_sEntities[i].id, pVehicle->GetModelIndex()); + pVehicle->bIsStaticWaitingForCollision = false; + if (!pVehicle->bIsStatic) + pVehicle->AddToMovingList(); } } } - break; } + break; case CLEANUP_OBJECT: - { CObject* pObject = CPools::GetObjectPool()->GetAt(m_sEntities[i].id); if (pObject) { - if (pObject->bIsStaticWaitingForCollision) { - if (CColStore::HasCollisionLoaded(pObject->GetPosition())) { - pObject->bIsStaticWaitingForCollision = false; + eLevelName level = CTheZones::GetLevelFromPosition(&pObject->GetPosition()); + if (level == LEVEL_GENERIC) + level = CGame::currLevel; + if (!CColStore::HasCollisionLoaded(level)) { + if (!pObject->bIsStaticWaitingForCollision) { if (!pObject->GetIsStatic()) + pObject->RemoveFromMovingList(); + pObject->bIsStaticWaitingForCollision = true; + } + } + else { + if (pObject->bIsStaticWaitingForCollision) { + pObject->bIsStaticWaitingForCollision = false; + if (!pObject->bIsStatic) pObject->AddToMovingList(); } } } - break; } - default: - break; + } + for (int i = 0; i < MAX_CLEANUP; i++) { + switch (m_sEntities[i].type) { + case CLEANUP_CHAR: + { + CPed* pPed = CPools::GetPedPool()->GetAt(m_sEntities[i].id); + if (pPed) { + eLevelName level = CTheZones::GetLevelFromPosition(&pPed->GetPosition()); + if (level == LEVEL_GENERIC) + level = CGame::currLevel; + if (!pPed->bIsStaticWaitingForCollision) { + if (pPed->bInVehicle) { + if (pPed->m_pMyVehicle->GetIsStatic()) { + SleepThisPed(&m_sEntities[i], pPed); + continue; + } + } + if (!CColStore::HasCollisionLoaded(level)) { + if (pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() || + pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic()) + SleepThisPed(&m_sEntities[i], pPed); + } + } + else { + if (!pPed->bInVehicle) { + if (CColStore::HasCollisionLoaded(level)) { + if (!(pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() || + pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic())) + WakeThisPed(&m_sEntities[i], pPed); + } + } + else { + if (!pPed->m_pMyVehicle->GetIsStatic()) { + WakeThisPed(&m_sEntities[i], pPed); + continue; + } + if (CColStore::HasCollisionLoaded(level)) { + if (!(pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() || + pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic())) + WakeThisPed(&m_sEntities[i], pPed); + } + } + } + + } + } + break; } } } @@ -1803,6 +2070,8 @@ void CMissionCleanup::Process() CCarCtrl::CarDensityMultiplier = 1.0f; CPed::nThreatReactionRangeMultiplier = 1; CPed::nEnterCarRangeMultiplier = 1; + for (int i = 0; i < MAX_ALLOWED_COLLISIONS; i++) + CTheScripts::AllowedCollision[i] = 0; FindPlayerPed()->m_pWanted->m_fCrimeSensitivity = 1.0f; CRoadBlocks::ClearScriptRoadBlocks(); CRouteNode::Initialise(); @@ -1810,20 +2079,19 @@ void CMissionCleanup::Process() TheCamera.Restore(); TheCamera.SetWideScreenOff(); CSpecialFX::bLiftCam = false; - CSpecialFX::bVideoCam = false; - CTimeCycle::StopExtraColour(0); + // TODO(LCS): CHud::m_ClockEventWarningMinutes = 0; + // TODO(LCS): CHud::m_ClockEventFlashTimer = 0; + CTimeCycle::StopExtraColour(0); // TODO: thiscall for (int i = 0; i < MISSION_AUDIO_SLOTS; i++) DMAudio.ClearMissionAudio(i); CWeather::ReleaseWeather(); for (int i = 0; i < NUM_OF_SPECIAL_CHARS; i++) CStreaming::SetMissionDoesntRequireSpecialChar(i); - for (int i = 0; i < NUM_OF_CUTSCENE_OBJECTS; i++) - CStreaming::SetMissionDoesntRequireModel(MI_CUTOBJ01 + i); CStreaming::ms_disableStreaming = false; - CHud::m_ItemToFlash = -1; - CHud::SetHelpMessage(nil, false); + if (CHud::m_ItemToFlash != ITEM_ARMOUR && CHud::m_ItemToFlash != ITEM_HEALTH) + CHud::m_ItemToFlash = -1; + CHud::SetHelpMessage(nil, false); // nil, false, false, true TODO(LCS) CUserDisplay::OnscnTimer.m_bDisabled = false; - CTheScripts::RemoveScriptTextureDictionary(); CWorld::Players[0].m_pPed->m_pWanted->m_bIgnoredByCops = false; CWorld::Players[0].m_pPed->m_pWanted->m_bIgnoredByEveryone = false; CWorld::Players[0].MakePlayerSafe(false); @@ -1831,10 +2099,11 @@ void CMissionCleanup::Process() CWorld::Players[0].m_pPed->m_nDrunkCountdown = 0; CPad::GetPad(0)->SetDrunkInputDelay(0); CWorld::Players[0].m_bDriveByAllowed = true; + CPad::GetPad(0)->unk_B4 = 1.0f; + CPad::GetPad(0)->unk_B8 = 0.5f; DMAudio.ShutUpPlayerTalking(0); CVehicle::bDisableRemoteDetonation = false; CVehicle::bDisableRemoteDetonationOnContact = false; - CGameLogic::ClearShortCut(); CTheScripts::RiotIntensity = 0; CTheScripts::StoreVehicleIndex = -1; CTheScripts::StoreVehicleWasRandom = true; @@ -1872,6 +2141,10 @@ void CMissionCleanup::Process() m_sEntities[i].type = CLEANUP_UNUSED; m_nCount--; } + for (int i = 1; i < NUMSTREAMINFO; i++) { + if (CStreaming::IsScriptOwnedModel(i)) + CStreaming::SetMissionDoesntRequireModel(i); + } } /* NB: CUpsideDownCarCheck is not used by actual script at all @@ -1894,7 +2167,7 @@ bool CUpsideDownCarCheck::IsCarUpsideDown(int32 id) bool CUpsideDownCarCheck::IsCarUpsideDown(CVehicle* pVehicle) { - assert(pVehicle); + script_assert(pVehicle); return pVehicle->GetUp().z <= UPSIDEDOWN_UP_THRESHOLD && pVehicle->GetMoveSpeed().Magnitude() < UPSIDEDOWN_MOVE_SPEED_THRESHOLD && pVehicle->GetTurnSpeed().Magnitude() < UPSIDEDOWN_TURN_SPEED_THRESHOLD; @@ -2033,109 +2306,157 @@ bool CStuckCarCheck::HasCarBeenStuckForAWhile(int32 id) return false; } -void CRunningScript::CollectParameters(uint32* pIp, int16 total) +void CRunningScript::CollectParameters(uint32* pIp, int16 total, int* pParameters) { - for (int16 i = 0; i < total; i++){ - uint16 varIndex; + while (total--){ switch (CTheScripts::Read1ByteFromScript(pIp)) { - case ARGUMENT_INT32: - case ARGUMENT_FLOAT: - ScriptParams[i] = CTheScripts::Read4BytesFromScript(pIp); + case ARGUMENT_END: + return; + case ARGUMENT_INT_ZERO: + *pParameters = 0; + break; + case ARGUMENT_FLOAT_ZERO: + *pParameters = 0; + break; + case ARGUMENT_FLOAT_1BYTE: + *pParameters = (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 24; break; - case ARGUMENT_GLOBALVAR: - varIndex = CTheScripts::Read2BytesFromScript(pIp); - script_assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace()); - ScriptParams[i] = *((int32*)&CTheScripts::ScriptSpace[varIndex]); + case ARGUMENT_FLOAT_2BYTES: + *pParameters = (uint32)(uint16)CTheScripts::Read2BytesFromScript(pIp) << 16; break; - case ARGUMENT_LOCALVAR: - varIndex = CTheScripts::Read2BytesFromScript(pIp); - script_assert(varIndex >= 0 && varIndex < ARRAY_SIZE(m_anLocalVariables)); - ScriptParams[i] = m_anLocalVariables[varIndex]; + case ARGUMENT_FLOAT_3BYTES: + *pParameters = (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 8; + *pParameters |= (uint32)(uint16)CTheScripts::Read2BytesFromScript(pIp) << 16; + break; + case ARGUMENT_INT32: + case ARGUMENT_FLOAT: + *pParameters = CTheScripts::Read4BytesFromScript(pIp); break; case ARGUMENT_INT8: - ScriptParams[i] = CTheScripts::Read1ByteFromScript(pIp); + *pParameters = CTheScripts::Read1ByteFromScript(pIp); break; case ARGUMENT_INT16: - ScriptParams[i] = CTheScripts::Read2BytesFromScript(pIp); + *pParameters = CTheScripts::Read2BytesFromScript(pIp); break; default: - script_assert(0); + *pIp -= 1; + *pParameters = *GetPointerToScriptVariable(pIp, 0); break; } + pParameters++; } } #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT -int CRunningScript::CollectParameterForDebug(char* buf, bool& var) +int32* GetPointerToScriptVariableForDebug(CRunningScript* pScript, uint32* pIp, char* buf) { - uint16 varIndex; char tmpstr[24]; + uint8 type = CTheScripts::Read1ByteFromScript(pIp); + if (type >= ARGUMENT_GLOBAL_ARRAY) { + uint8 index_in_block = CTheScripts::Read1ByteFromScript(pIp); + uint8 index_id = CTheScripts::Read1ByteFromScript(pIp); + uint8 size = CTheScripts::Read1ByteFromScript(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@ (%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)]; + } + else if (type >= ARGUMENT_GLOBAL) { + uint8 index_in_block = CTheScripts::Read1ByteFromScript(pIp); + sprintf(tmpstr, " $%d", ((int)(type - ARGUMENT_GLOBAL) << 8) + index_in_block); + strcat(buf, tmpstr); + return (int32*)&CTheScripts::ScriptSpace[4 * (((int)(type - ARGUMENT_GLOBAL) << 8) + index_in_block)]; + } + else if (type >= ARGUMENT_LOCAL_ARRAY) { + uint8 index_id = CTheScripts::Read1ByteFromScript(pIp); + uint8 size = CTheScripts::Read1ByteFromScript(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@ (%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]; + } + else if (type >= ARGUMENT_LOCAL) { + sprintf(tmpstr, " %d@", (type - ARGUMENT_LOCAL)); + strcat(buf, tmpstr); + return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL)]; + } + else if (type >= ARGUMENT_TIMER) { + sprintf(tmpstr, " TIMER%d@", (type - ARGUMENT_TIMER)); + strcat(buf, tmpstr); + return &pScript->m_anLocalVariables[NUM_LOCAL_VARS + 8 + (type - ARGUMENT_TIMER)]; // why 8? + } + script_assert(false && "wrong type for variable"); + return nil; +} + +int CRunningScript::CollectParameterForDebug(char* buf, bool& var) +{ var = false; + int tmp; switch (CTheScripts::Read1ByteFromScript(&m_nIp)) { + case ARGUMENT_END: + return 0; // TODO(LCS) + case ARGUMENT_INT_ZERO: + return 0; + case ARGUMENT_FLOAT_ZERO: + return 0; + case ARGUMENT_FLOAT_1BYTE: + return (uint32)(uint8)CTheScripts::Read1ByteFromScript(&m_nIp) << 24; + case ARGUMENT_FLOAT_2BYTES: + return (uint32)(uint16)CTheScripts::Read2BytesFromScript(&m_nIp) << 16; + case ARGUMENT_FLOAT_3BYTES: + tmp = (uint32)(uint8)CTheScripts::Read1ByteFromScript(&m_nIp) << 8; + tmp |= (uint32)(uint16)CTheScripts::Read2BytesFromScript(&m_nIp) << 16; + return tmp; case ARGUMENT_INT32: case ARGUMENT_FLOAT: return CTheScripts::Read4BytesFromScript(&m_nIp); - case ARGUMENT_GLOBALVAR: - varIndex = CTheScripts::Read2BytesFromScript(&m_nIp); - script_assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace()); - var = true; - sprintf(tmpstr, " $%d", varIndex / 4); - strcat(buf, tmpstr); - return *((int32*)&CTheScripts::ScriptSpace[varIndex]); - case ARGUMENT_LOCALVAR: - varIndex = CTheScripts::Read2BytesFromScript(&m_nIp); - script_assert(varIndex >= 0 && varIndex < ARRAY_SIZE(m_anLocalVariables)); - var = true; - sprintf(tmpstr, " %d@", varIndex); - strcat(buf, tmpstr); - return m_anLocalVariables[varIndex]; case ARGUMENT_INT8: return CTheScripts::Read1ByteFromScript(&m_nIp); case ARGUMENT_INT16: return CTheScripts::Read2BytesFromScript(&m_nIp); default: - PrintToLog("%s - script assertion failed in CollectParameterForDebug", buf); - script_assert(0); - break; + var = true; + --m_nIp; + return *GetPointerToScriptVariableForDebug(this, &m_nIp, buf); } return 0; } void CRunningScript::GetStoredParameterForDebug(char* buf) { - uint16 varIndex; - char tmpstr[24]; - switch (CTheScripts::Read1ByteFromScript(&m_nIp)) { - case ARGUMENT_GLOBALVAR: - varIndex = CTheScripts::Read2BytesFromScript(&m_nIp); - sprintf(tmpstr, " $%d", varIndex / 4); - strcat(buf, tmpstr); - break; - case ARGUMENT_LOCALVAR: - varIndex = CTheScripts::Read2BytesFromScript(&m_nIp); - sprintf(tmpstr, " %d@", varIndex); - strcat(buf, tmpstr); - break; - default: - PrintToLog("%s - script_assertion failed in GetStoredParameterForDebug", buf); - script_assert(0); - } + GetPointerToScriptVariableForDebug(this, &m_nIp, buf); } #endif int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip) { uint32* pIp = &ip; + int tmp; switch (CTheScripts::Read1ByteFromScript(pIp)) { + case ARGUMENT_END: + return 0; // TODO(LCS) + case ARGUMENT_INT_ZERO: + return 0; + case ARGUMENT_FLOAT_ZERO: + return 0; + case ARGUMENT_FLOAT_1BYTE: + return (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 24; + case ARGUMENT_FLOAT_2BYTES: + return (uint32)(uint16)CTheScripts::Read2BytesFromScript(pIp) << 16; + case ARGUMENT_FLOAT_3BYTES: + tmp = (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 8; + tmp |= (uint32)(uint16)CTheScripts::Read2BytesFromScript(pIp) << 16; + return tmp; case ARGUMENT_INT32: return CTheScripts::Read4BytesFromScript(pIp); - case ARGUMENT_GLOBALVAR: - return *((int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)]); - case ARGUMENT_LOCALVAR: - return m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)]; case ARGUMENT_INT8: return CTheScripts::Read1ByteFromScript(pIp); case ARGUMENT_INT16: @@ -2143,7 +2464,8 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip) case ARGUMENT_FLOAT: return CTheScripts::Read4BytesFromScript(pIp); default: - script_assert(0); + (*pIp)--; + return *GetPointerToScriptVariable(pIp, 0); } return -1; } @@ -2151,38 +2473,61 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip) void CRunningScript::StoreParameters(uint32* pIp, int16 number) { for (int16 i = 0; i < number; i++){ - switch (CTheScripts::Read1ByteFromScript(pIp)) { - case ARGUMENT_GLOBALVAR: - *(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i]; - break; - case ARGUMENT_LOCALVAR: - m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i]; - break; - default: - script_assert(0); - } + *GetPointerToScriptVariable(pIp, 0) = ScriptParams[i]; } } +int32* GetPointerToScriptVariable(CRunningScript* pScript, uint32* pIp) +{ + uint8 type = CTheScripts::Read1ByteFromScript(pIp); + if (type >= ARGUMENT_GLOBAL_ARRAY) { + uint8 index_in_block = CTheScripts::Read1ByteFromScript(pIp); + uint8 index_id = CTheScripts::Read1ByteFromScript(pIp); + uint8 size = CTheScripts::Read1ByteFromScript(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); + return (int32*)&CTheScripts::ScriptSpace[4 * (((int)(type - ARGUMENT_GLOBAL_ARRAY) << 8) + index + index_in_block)]; + } + else if (type >= ARGUMENT_GLOBAL) { + uint8 index_in_block = CTheScripts::Read1ByteFromScript(pIp); + return (int32*)&CTheScripts::ScriptSpace[4 * (((int)(type - ARGUMENT_GLOBAL) << 8) + index_in_block)]; + } + else if (type >= ARGUMENT_LOCAL_ARRAY) { + uint8 index_id = CTheScripts::Read1ByteFromScript(pIp); + uint8 size = CTheScripts::Read1ByteFromScript(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); + return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL_ARRAY) + index]; + } + else if (type >= ARGUMENT_LOCAL) { + return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL)]; + } + else if (type >= ARGUMENT_TIMER) { + return &pScript->m_anLocalVariables[NUM_LOCAL_VARS + 8 + (type - ARGUMENT_TIMER)]; + } + script_assert(false && "wrong type for variable"); + return nil; +} + int32 *CRunningScript::GetPointerToScriptVariable(uint32* pIp, int16 type) { - switch (CTheScripts::Read1ByteFromScript(pIp)) - { - case ARGUMENT_GLOBALVAR: - script_assert(type == VAR_GLOBAL); - return (int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)]; - case ARGUMENT_LOCALVAR: - script_assert(type == VAR_LOCAL); - return &m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)]; - default: - script_assert(0); + return ::GetPointerToScriptVariable(this, pIp); +} + +int CTheScripts::GetSaveVarIndex(int var) +{ + for (int i = 0; i < NumSaveVars; i++) { + if (SavedVarIndices[i] == var) + return i; } - return nil; + return -1; } void CRunningScript::Init() { - strcpy(m_abScriptName, "noname"); + sprintf(m_abScriptName, "id%02i", m_nId); next = prev = nil; SetIP(0); for (int i = 0; i < MAX_STACK_DEPTH; i++) @@ -2193,13 +2538,28 @@ void CRunningScript::Init() m_bCondResult = false; m_bIsMissionScript = false; m_bSkipWakeTime = false; - for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++) + for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++) m_anLocalVariables[i] = 0; m_nAndOrState = 0; m_bNotFlag = false; m_bDeatharrestEnabled = true; m_bDeatharrestExecuted = false; m_bMissionFlag = false; + m_nLocalsPointer = 0; +} + +void CTheScripts::Shutdown() +{ + if (gScriptsFile != -1) { + CFileMgr::CloseFile(gScriptsFile); + gScriptsFile = -1; + } + if (ScriptSpace) { + base::cMainMemoryManager::Instance()->Free(ScriptSpace); + ScriptSpace = nil; + FSDestroyedFlag = false; + OnAMissionFlag = 0; + } } #ifdef USE_DEBUG_SCRIPT_LOADER @@ -2229,10 +2589,10 @@ int open_script() } #endif -void CTheScripts::Init() +bool CTheScripts::Init(bool loaddata) { - for (int i = 0; i < SIZE_SCRIPT_SPACE; i++) - ScriptSpace[i] = 0; + bool retval = false; + printf("CTheScripts::Init\n"); pActiveScripts = pIdleScripts = nil; for (int i = 0; i < MAX_NUM_SCRIPTS; i++){ ScriptsArray[i].Init(); @@ -2241,25 +2601,38 @@ void CTheScripts::Init() MissionCleanUp.Init(); UpsideDownCars.Init(); StuckCars.Init(); - CFileMgr::SetDir("data"); -#ifdef USE_DEBUG_SCRIPT_LOADER - int mainf = open_script(); -#else - int mainf = CFileMgr::OpenFile("main.scm", "rb"); -#endif - CFileMgr::Read(mainf, (char*)ScriptSpace, SIZE_MAIN_SCRIPT); - CFileMgr::CloseFile(mainf); - CFileMgr::SetDir(""); StoreVehicleIndex = -1; StoreVehicleWasRandom = true; OnAMissionFlag = 0; LastMissionPassedTime = (uint32)-1; + for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) { + CollectiveArray[i].colIndex = -1; + CollectiveArray[i].pedIndex = 0; + } + NextFreeCollectiveIndex = 0; LastRandomPedId = -1; for (int i = 0; i < MAX_NUM_USED_OBJECTS; i++){ memset(&UsedObjectArray[i].name, 0, sizeof(UsedObjectArray[i].name)); UsedObjectArray[i].index = 0; } NumberOfUsedObjects = 0; + if (ScriptSpace) + Shutdown(); + CFileMgr::SetDir("DATA"); +#ifdef USE_DEBUG_SCRIPT_LOADER + int mainf = open_script(); +#else + int mainf = CFileMgr::OpenFile("main.scm", "rb"); +#endif + CFileMgr::Read(mainf, (char*)&MainScriptSize, sizeof(MainScriptSize)); + int nLargestMissionSize = 0; + CFileMgr::Read(mainf, (char*)&nLargestMissionSize, sizeof(nLargestMissionSize)); + // some cSmallHeap shit - TODO + ScriptSpace = (uint8*)base::cMainMemoryManager::Instance()->Allocate(MainScriptSize + nLargestMissionSize); + memset(ScriptSpace, 0, MainScriptSize + nLargestMissionSize); + CFileMgr::Read(mainf, (char*)ScriptSpace, MainScriptSize); + gScriptsFile = mainf; + CFileMgr::SetDir(""); ReadObjectNamesFromScript(); UpdateObjectIndices(); bAlreadyRunningAMissionScript = false; @@ -2269,11 +2642,10 @@ void CTheScripts::Init() NumberOfExclusiveMissionScripts = 0; NumberOfMissionScripts = 0; LargestMissionScriptSize = 0; - MainScriptSize = 0; ReadMultiScriptFileOffsetsFromScript(); FailCurrentMission = 0; DbgFlag = false; - NumScriptDebugLines = 0; + //NumScriptDebugLines = 0; RiotIntensity = 0; bPlayerHasMetDebbieHarry = false; bPlayerIsInTheStatium = false; @@ -2297,7 +2669,7 @@ void CTheScripts::Init() IntroRectangles[i].m_sColor = CRGBA(255, 255, 255, 255); } NumberOfIntroRectanglesThisFrame = 0; - RemoveScriptTextureDictionary(); + //RemoveScriptTextureDictionary(); // TODO(LCS) - probably not needed for (int i = 0; i < MAX_NUM_BUILDING_SWAPS; i++){ BuildingSwapArray[i].m_pBuilding = nil; BuildingSwapArray[i].m_nNewModel = -1; @@ -2305,6 +2677,12 @@ void CTheScripts::Init() } for (int i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) InvisibilitySettingArray[i] = nil; + if (loaddata) { + printf("loaddata = true\n"); + //retval = GenericLoad(); // TODO + } + for (int i = 0; i < MAX_ALLOWED_COLLISIONS; i++) + AllowedCollision[i] = 0; #if defined USE_ADVANCED_SCRIPT_DEBUG_OUTPUT && SCRIPT_LOG_FILE_LEVEL == 2 CFileMgr::SetDirMyDocuments(); @@ -2315,8 +2693,10 @@ void CTheScripts::Init() PrintToLog(init_msg); CFileMgr::SetDir(""); #endif + return retval; } +/* void CTheScripts::RemoveScriptTextureDictionary() { for (int i = 0; i < ARRAY_SIZE(CTheScripts::ScriptSprites); i++) @@ -2325,6 +2705,7 @@ void CTheScripts::RemoveScriptTextureDictionary() if (slot != -1) CTxdStore::RemoveTxd(slot); } +*/ void CRunningScript::RemoveScriptFromList(CRunningScript** ppScript) { @@ -2350,6 +2731,7 @@ CRunningScript* CTheScripts::StartNewScript(uint32 ip) CRunningScript* pNew = pIdleScripts; script_assert(pNew); pNew->RemoveScriptFromList(&pIdleScripts); + pNew->m_nId = NextProcessId++; pNew->Init(); pNew->SetIP(ip); pNew->AddScriptToList(&pActiveScripts); @@ -2361,6 +2743,8 @@ void CTheScripts::Process() { if (CReplay::IsPlayingBack()) return; + if (!ScriptSpace) + return; CommandsExecuted = 0; ScriptsUpdated = 0; float timeStep = CTimer::GetTimeStepInMilliseconds(); @@ -2383,6 +2767,8 @@ void CTheScripts::Process() UseTextCommands = 0; } + // TODO: mCoronas + #ifdef MISSION_REPLAY static uint32 TimeToWaitTill; switch (AllowMissionReplay) { @@ -2432,6 +2818,7 @@ void CTheScripts::Process() #endif CRunningScript* script = pActiveScripts; + InTheScripts = true; while (script != nil){ CRunningScript* next = script->GetNext(); ++ScriptsUpdated; @@ -2466,6 +2853,7 @@ void CRunningScript::Process() #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT PrintToLog("\n\nProcessing script %s (id %d)\n\n", m_abScriptName, this - CTheScripts::ScriptsArray); #endif + pCurrent = this; if (m_bIsMissionScript) DoDeatharrestCheck(); if (m_bMissionFlag && CTheScripts::FailCurrentMission == 1 && m_nStackPointer == 1) @@ -2498,32 +2886,57 @@ int8 CRunningScript::ProcessOneCommand() #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT char commandInfo[1024]; uint32 ip = m_nIp; + uint8 nInputParams; + uint8 nOutputParameters; + uint8 nLocalsOffset; if (command < ARRAY_SIZE(commands)) { script_assert(commands[command].id == command); - sprintf(commandInfo, m_nIp >= SIZE_MAIN_SCRIPT ? "M<%5d> " : "<%6d> ", m_nIp >= SIZE_MAIN_SCRIPT ? m_nIp - SIZE_MAIN_SCRIPT : m_nIp); + sprintf(commandInfo, m_nIp >= CTheScripts::MainScriptSize ? "M<%5d> " : "<%6d> ", m_nIp >= CTheScripts::MainScriptSize ? m_nIp - CTheScripts::MainScriptSize : m_nIp); if (m_bNotFlag) strcat(commandInfo, "NOT "); if (commands[command].position == -1) strcat(commandInfo, commands[command].name + sizeof("COMMAND_") - 1); - for (int i = 0; commands[command].input[i] != ARGTYPE_NONE; i++) { + if (commands[command].input[0] == ARGTYPE_FUNCTION) { char tmp[32]; bool var = false; - int value; - switch (commands[command].input[i]) { - case ARGTYPE_INT: - case ARGTYPE_PED_HANDLE: - case ARGTYPE_VEHICLE_HANDLE: - case ARGTYPE_OBJECT_HANDLE: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%d)" : " %d", value); break; - case ARGTYPE_FLOAT: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%.3f)" : " %.3f", *(float*)&value); break; - case ARGTYPE_STRING: sprintf(tmp, " '%s'", (const char*)&CTheScripts::ScriptSpace[m_nIp]); m_nIp += KEY_LENGTH_IN_SCRIPT; break; - case ARGTYPE_LABEL: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%s(%d))" : " %s(%d)", value >= 0 ? "G" : "L", abs(value)); break; - case ARGTYPE_BOOL: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%s)" : " %s", value ? "TRUE" : "FALSE"); break; - case ARGTYPE_ANDOR: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, " %d %ss", (value + 1) % 10, value / 10 == 0 ? "AND" : "OR"); break; - default: script_assert(0); - } + nInputParams = CTheScripts::Read1ByteFromScript(&m_nIp); + nOutputParameters = CTheScripts::Read1ByteFromScript(&m_nIp); + nLocalsOffset = CTheScripts::Read1ByteFromScript(&m_nIp); + int value = CollectParameterForDebug(commandInfo, var); + sprintf(tmp, var ? " (%s(%d))" : " %s(%d)", value >= 0 ? "G" : "L", abs(value)); strcat(commandInfo, tmp); - if (commands[command].position == i) - strcat(commandInfo, commands[command].name_override); + strcat(commandInfo, "{"); + for (int i = 0; i < nInputParams; i++) { + if (i != 0) + strcat(commandInfo, ", "); + value = CollectParameterForDebug(commandInfo, var); + sprintf(tmp, var ? "(%d)" : "%d", value); + strcat(commandInfo, tmp); + + } + strcat(commandInfo, "}"); + } + else { + for (int i = 0; commands[command].input[i] != ARGTYPE_NONE; i++) { + char tmp[32]; + bool var = false; + int value; + switch (commands[command].input[i]) { + case ARGTYPE_INT: + case ARGTYPE_PED_HANDLE: + case ARGTYPE_VEHICLE_HANDLE: + case ARGTYPE_OBJECT_HANDLE: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%d)" : " %d", value); break; + case ARGTYPE_FLOAT: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%.3f)" : " %.3f", *(float*)&value); break; + case ARGTYPE_STRING: sprintf(tmp, " '%s'", (const char*)&CTheScripts::ScriptSpace[m_nIp]); m_nIp += KEY_LENGTH_IN_SCRIPT; break; + case ARGTYPE_LABEL: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%s(%d))" : " %s(%d)", value >= 0 ? "G" : "L", abs(value)); break; + case ARGTYPE_BOOL: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%s)" : " %s", value ? "TRUE" : "FALSE"); break; + case ARGTYPE_ANDOR: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, " %d %ss", (value + 1) % 10, value / 10 == 0 ? "AND" : "OR"); break; + default: script_assert(0); + } + strcat(commandInfo, tmp); + if (commands[command].position == i) + strcat(commandInfo, commands[command].name_override); + } } uint32 t = m_nIp; m_nIp = ip; @@ -2534,32 +2947,36 @@ int8 CRunningScript::ProcessOneCommand() retval = ProcessCommands0To99(command); else if (command < 200) retval = ProcessCommands100To199(command); - else if (command < 300) + else if (command < 305) retval = ProcessCommands200To299(command); - else if (command < 400) + else if (command < 405) retval = ProcessCommands300To399(command); - else if (command < 500) + else if (command < 505) retval = ProcessCommands400To499(command); - else if (command < 600) + else if (command < 605) retval = ProcessCommands500To599(command); - else if (command < 700) + else if (command < 705) retval = ProcessCommands600To699(command); - else if (command < 800) + else if (command < 805) retval = ProcessCommands700To799(command); - else if (command < 900) + else if (command < 905) retval = ProcessCommands800To899(command); - else if (command < 1000) + else if (command < 1005) retval = ProcessCommands900To999(command); - else if (command < 1100) + else if (command < 1105) retval = ProcessCommands1000To1099(command); - else if (command < 1200) + else if (command < 1205) retval = ProcessCommands1100To1199(command); - else if (command < 1300) + else if (command < 1305) retval = ProcessCommands1200To1299(command); - else if (command < 1400) + else if (command < 1405) retval = ProcessCommands1300To1399(command); - else if (command < 1500) + else if (command < 1497) retval = ProcessCommands1400To1499(command); + else if (command < 1600) + retval = ProcessCommands1500To1599(command); + else if (command < 1700) + retval = ProcessCommands1600To1699(command); #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT if (command < ARRAY_SIZE(commands)) { if (commands[command].cond || commands[command].output[0] != ARGTYPE_NONE) { @@ -2569,15 +2986,17 @@ int8 CRunningScript::ProcessOneCommand() uint32 t = m_nIp; m_nIp = ip; ip = t; - for (int i = 0; commands[command].output[i] != ARGTYPE_NONE; i++) { - char tmp[32]; - switch (commands[command].output[i]) { - case ARGTYPE_INT: - case ARGTYPE_PED_HANDLE: - case ARGTYPE_VEHICLE_HANDLE: - case ARGTYPE_OBJECT_HANDLE: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%d)", ScriptParams[i]); strcat(commandInfo, tmp); break; - case ARGTYPE_FLOAT: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%8.3f)", *(float*)&ScriptParams[i]); strcat(commandInfo, tmp); break; - default: script_assert(0 && "Script only returns INTs and FLOATs"); + if (commands[command].input[0] != ARGTYPE_FUNCTION) { + for (int i = 0; commands[command].output[i] != ARGTYPE_NONE; i++) { + char tmp[32]; + switch (commands[command].output[i]) { + case ARGTYPE_INT: + case ARGTYPE_PED_HANDLE: + case ARGTYPE_VEHICLE_HANDLE: + case ARGTYPE_OBJECT_HANDLE: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%d)", ScriptParams[i]); strcat(commandInfo, tmp); break; + case ARGTYPE_FLOAT: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%8.3f)", *(float*)&ScriptParams[i]); strcat(commandInfo, tmp); break; + default: script_assert(0 && "Script only returns INTs and FLOATs"); + } } } m_nIp = ip; @@ -2606,16 +3025,18 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) float *fScriptVar1; int *nScriptVar1; switch (command) { + /* case COMMAND_NOP: return 0; + */ case COMMAND_WAIT: CollectParameters(&m_nIp, 1); - m_nWakeTime = CTimer::GetTimeInMilliseconds() + ScriptParams[0]; + m_nWakeTime = CTimer::GetTimeInMilliseconds() + GET_INTEGER_PARAM(0); m_bSkipWakeTime = false; return 1; case COMMAND_GOTO: CollectParameters(&m_nIp, 1); - SetIP(ScriptParams[0] >= 0 ? ScriptParams[0] : SIZE_MAIN_SCRIPT - ScriptParams[0]); + SetIP(GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0)); /* Known issue: GOTO to 0. It might have been "better" to use > instead of >= */ /* simply because it never makes sense to jump to start of the script */ /* but jumping to start of a custom mission is an issue for simple mission-like scripts */ @@ -2624,174 +3045,174 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) return 0; case COMMAND_SHAKE_CAM: CollectParameters(&m_nIp, 1); - CamShakeNoPos(&TheCamera, ScriptParams[0] / 1000.0f); + CamShakeNoPos(&TheCamera, GET_INTEGER_PARAM(0) / 1000.0f); return 0; case COMMAND_SET_VAR_INT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *ptr = ScriptParams[0]; + *ptr = GET_INTEGER_PARAM(0); return 0; } case COMMAND_SET_VAR_FLOAT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr = *(float*)&ScriptParams[0]; + *(float*)ptr = GET_FLOAT_PARAM(0); return 0; } case COMMAND_SET_LVAR_INT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *ptr = ScriptParams[0]; + *ptr = GET_INTEGER_PARAM(0); return 0; } case COMMAND_SET_LVAR_FLOAT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr = *(float*)&ScriptParams[0]; + *(float*)ptr = GET_FLOAT_PARAM(0); return 0; } case COMMAND_ADD_VAL_TO_INT_VAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *ptr += ScriptParams[0]; + *ptr += GET_INTEGER_PARAM(0); return 0; } case COMMAND_ADD_VAL_TO_FLOAT_VAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr += *(float*)&ScriptParams[0]; + *(float*)ptr += GET_FLOAT_PARAM(0); return 0; } case COMMAND_ADD_VAL_TO_INT_LVAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *ptr += ScriptParams[0]; + *ptr += GET_INTEGER_PARAM(0); return 0; } case COMMAND_ADD_VAL_TO_FLOAT_LVAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr += *(float*)&ScriptParams[0]; + *(float*)ptr += GET_FLOAT_PARAM(0); return 0; } case COMMAND_SUB_VAL_FROM_INT_VAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *ptr -= ScriptParams[0]; + *ptr -= GET_INTEGER_PARAM(0); return 0; } case COMMAND_SUB_VAL_FROM_FLOAT_VAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr -= *(float*)&ScriptParams[0]; + *(float*)ptr -= GET_FLOAT_PARAM(0); return 0; } case COMMAND_SUB_VAL_FROM_INT_LVAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *ptr -= ScriptParams[0]; + *ptr -= GET_INTEGER_PARAM(0); return 0; } case COMMAND_SUB_VAL_FROM_FLOAT_LVAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr -= *(float*)&ScriptParams[0]; + *(float*)ptr -= GET_FLOAT_PARAM(0); return 0; } case COMMAND_MULT_INT_VAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *ptr *= ScriptParams[0]; + *ptr *= GET_INTEGER_PARAM(0); return 0; } case COMMAND_MULT_FLOAT_VAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr *= *(float*)&ScriptParams[0]; + *(float*)ptr *= GET_FLOAT_PARAM(0); return 0; } case COMMAND_MULT_INT_LVAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *ptr *= ScriptParams[0]; + *ptr *= GET_INTEGER_PARAM(0); return 0; } case COMMAND_MULT_FLOAT_LVAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr *= *(float*)&ScriptParams[0]; + *(float*)ptr *= GET_FLOAT_PARAM(0); return 0; } case COMMAND_DIV_INT_VAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *ptr /= ScriptParams[0]; + *ptr /= GET_INTEGER_PARAM(0); return 0; } case COMMAND_DIV_FLOAT_VAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr /= *(float*)&ScriptParams[0]; + *(float*)ptr /= GET_FLOAT_PARAM(0); return 0; } case COMMAND_DIV_INT_LVAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *ptr /= ScriptParams[0]; + *ptr /= GET_INTEGER_PARAM(0); return 0; } case COMMAND_DIV_FLOAT_LVAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr /= *(float*)&ScriptParams[0]; + *(float*)ptr /= GET_FLOAT_PARAM(0); return 0; } case COMMAND_IS_INT_VAR_GREATER_THAN_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr > ScriptParams[0]); + UpdateCompareFlag(*ptr > GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_LVAR_GREATER_THAN_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr > ScriptParams[0]); + UpdateCompareFlag(*ptr > GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_NUMBER_GREATER_THAN_INT_VAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); - UpdateCompareFlag(ScriptParams[0] > *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) > *ptr); return 0; } case COMMAND_IS_NUMBER_GREATER_THAN_INT_LVAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); - UpdateCompareFlag(ScriptParams[0] > *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) > *ptr); return 0; } case COMMAND_IS_INT_VAR_GREATER_THAN_INT_VAR: @@ -2826,28 +3247,28 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*(float*)ptr > *(float*)&ScriptParams[0]); + UpdateCompareFlag(*(float*)ptr > GET_FLOAT_PARAM(0)); return 0; } case COMMAND_IS_FLOAT_LVAR_GREATER_THAN_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*(float*)ptr > *(float*)&ScriptParams[0]); + UpdateCompareFlag(*(float*)ptr > GET_FLOAT_PARAM(0)); return 0; } case COMMAND_IS_NUMBER_GREATER_THAN_FLOAT_VAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); - UpdateCompareFlag(*(float*)&ScriptParams[0] > *(float*)ptr); + UpdateCompareFlag(GET_FLOAT_PARAM(0) > *(float*)ptr); return 0; } case COMMAND_IS_NUMBER_GREATER_THAN_FLOAT_LVAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); - UpdateCompareFlag(*(float*)&ScriptParams[0] > *(float*)ptr); + UpdateCompareFlag(GET_FLOAT_PARAM(0) > *(float*)ptr); return 0; } case COMMAND_IS_FLOAT_VAR_GREATER_THAN_FLOAT_VAR: @@ -2882,28 +3303,28 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr >= ScriptParams[0]); + UpdateCompareFlag(*ptr >= GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_LVAR_GREATER_OR_EQUAL_TO_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr >= ScriptParams[0]); + UpdateCompareFlag(*ptr >= GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_INT_VAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); - UpdateCompareFlag(ScriptParams[0] >= *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) >= *ptr); return 0; } case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_INT_LVAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); - UpdateCompareFlag(ScriptParams[0] >= *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) >= *ptr); return 0; } case COMMAND_IS_INT_VAR_GREATER_OR_EQUAL_TO_INT_VAR: @@ -2938,28 +3359,28 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*(float*)ptr >= *(float*)&ScriptParams[0]); + UpdateCompareFlag(*(float*)ptr >= GET_FLOAT_PARAM(0)); return 0; } case COMMAND_IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*(float*)ptr >= *(float*)&ScriptParams[0]); + UpdateCompareFlag(*(float*)ptr >= GET_FLOAT_PARAM(0)); return 0; } case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_VAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); - UpdateCompareFlag(*(float*)&ScriptParams[0] >= *(float*)ptr); + UpdateCompareFlag(GET_FLOAT_PARAM(0) >= *(float*)ptr); return 0; } case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_LVAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); - UpdateCompareFlag(*(float*)&ScriptParams[0] >= *(float*)ptr); + UpdateCompareFlag(GET_FLOAT_PARAM(0) >= *(float*)ptr); return 0; } case COMMAND_IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_FLOAT_VAR: @@ -2994,14 +3415,14 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr == ScriptParams[0]); + UpdateCompareFlag(*ptr == GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_LVAR_EQUAL_TO_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr == ScriptParams[0]); + UpdateCompareFlag(*ptr == GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_VAR_EQUAL_TO_INT_VAR: @@ -3034,14 +3455,14 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*(float*)ptr == *(float*)&ScriptParams[0]); + UpdateCompareFlag(*(float*)ptr == GET_FLOAT_PARAM(0)); return 0; } case COMMAND_IS_FLOAT_LVAR_EQUAL_TO_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*(float*)ptr == *(float*)&ScriptParams[0]); + UpdateCompareFlag(*(float*)ptr == GET_FLOAT_PARAM(0)); return 0; } case COMMAND_IS_FLOAT_VAR_EQUAL_TO_FLOAT_VAR: @@ -3070,17 +3491,15 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) //case COMMAND_IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_VAR: //case COMMAND_IS_FLOAT_LVAR_NOT_EQUAL_TO_FLOAT_LVAR: //case COMMAND_IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_LVAR: - /* case COMMAND_GOTO_IF_TRUE: CollectParameters(&m_nIp, 1); if (m_bCondResult) - SetIP(ScriptParams[0] >= 0 ? ScriptParams[0] : SIZE_MAIN_SCRIPT - ScriptParams[0]); + SetIP(GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0)); return 0; - */ case COMMAND_GOTO_IF_FALSE: CollectParameters(&m_nIp, 1); if (!m_bCondResult) - SetIP(ScriptParams[0] >= 0 ? ScriptParams[0] : SIZE_MAIN_SCRIPT - ScriptParams[0]); + SetIP(GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0)); /* Check COMMAND_GOTO note. */ return 0; case COMMAND_TERMINATE_THIS_SCRIPT: @@ -3106,47 +3525,19 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) case COMMAND_START_NEW_SCRIPT: { CollectParameters(&m_nIp, 1); - script_assert(ScriptParams[0] >= 0); - CRunningScript* pNew = CTheScripts::StartNewScript(ScriptParams[0]); - m_bIsActive = true; - int8 type = CTheScripts::Read1ByteFromScript(&m_nIp); - float tmp; - for (int i = 0; type != ARGUMENT_END; type = CTheScripts::Read1ByteFromScript(&m_nIp), i++) { - switch (type) { - case ARGUMENT_INT32: - pNew->m_anLocalVariables[i] = CTheScripts::Read4BytesFromScript(&m_nIp); - break; - case ARGUMENT_GLOBALVAR: - pNew->m_anLocalVariables[i] = *(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(&m_nIp)]; - break; - case ARGUMENT_LOCALVAR: - pNew->m_anLocalVariables[i] = m_anLocalVariables[CTheScripts::Read2BytesFromScript(&m_nIp)]; - break; - case ARGUMENT_INT8: - pNew->m_anLocalVariables[i] = CTheScripts::Read1ByteFromScript(&m_nIp); - break; - case ARGUMENT_INT16: - pNew->m_anLocalVariables[i] = CTheScripts::Read2BytesFromScript(&m_nIp); - break; - case ARGUMENT_FLOAT: - tmp = CTheScripts::ReadFloatFromScript(&m_nIp); - pNew->m_anLocalVariables[i] = *(int32*)&tmp; - break; - default: - break; - } - } + script_assert(GET_INTEGER_PARAM(0) >= 0); + CRunningScript* pNew = CTheScripts::StartNewScript(GET_INTEGER_PARAM(0)); + CollectParameters(&m_nIp, NUM_LOCAL_VARS, pNew->m_anLocalVariables); return 0; } case COMMAND_GOSUB: CollectParameters(&m_nIp, 1); script_assert(m_nStackPointer < MAX_STACK_DEPTH); m_anStack[m_nStackPointer++] = m_nIp; - SetIP(ScriptParams[0] >= 0 ? ScriptParams[0] : SIZE_MAIN_SCRIPT - ScriptParams[0]); + SetIP(GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0)); return 0; case COMMAND_RETURN: - script_assert(m_nStackPointer > 0); /* No more SSU */ - SetIP(m_anStack[--m_nStackPointer]); + ReturnFromGosubOrFunction(); return 0; case COMMAND_LINE: CollectParameters(&m_nIp, 6); @@ -3155,7 +3546,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) case COMMAND_CREATE_PLAYER: { CollectParameters(&m_nIp, 4); - int32 index = ScriptParams[0]; + int32 index = GET_INTEGER_PARAM(0); script_assert(index < NUMPLAYERS); printf("&&&&&&&&&&&&&Creating player: %d\n", index); if (!CStreaming::HasModelLoaded(MI_PLAYER)) { @@ -3165,14 +3556,14 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) CPlayerPed::SetupPlayerPed(index); CWorld::Players[index].m_pPed->CharCreatedBy = MISSION_CHAR; CPlayerPed::DeactivatePlayerPed(index); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += CWorld::Players[index].m_pPed->GetDistanceFromCentreOfMassToBaseOfModel(); CWorld::Players[index].m_pPed->SetPosition(pos); CTheScripts::ClearSpaceForMissionEntity(pos, CWorld::Players[index].m_pPed); CPlayerPed::ReactivatePlayerPed(index); - ScriptParams[0] = index; + SET_INTEGER_PARAM(0, index); StoreParameters(&m_nIp, 1); return 0; } @@ -3180,23 +3571,23 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) { CVector pos; CollectParameters(&m_nIp, 1); - if (CWorld::Players[ScriptParams[0]].m_pPed->bInVehicle) - pos = CWorld::Players[ScriptParams[0]].m_pPed->m_pMyVehicle->GetPosition(); + if (CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->bInVehicle && CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->m_pMyVehicle) + pos = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->m_pMyVehicle->GetPosition(); else - pos = CWorld::Players[ScriptParams[0]].m_pPed->GetPosition(); - *(CVector*)&ScriptParams[0] = pos; + pos = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->GetPosition(); + SET_VECTOR_PARAM(0, pos); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_SET_PLAYER_COORDINATES: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[1]; - int index = ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(1); + int index = GET_INTEGER_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CPlayerPed* ped = CWorld::Players[index].m_pPed; - if (ped->bInVehicle) { + if (ped->bInVehicle && ped->m_pMyVehicle) { pos.z += ped->m_pMyVehicle->GetDistanceFromCentreOfMassToBaseOfModel(); ped->m_pMyVehicle->Teleport(pos); // removed dumb stuff that was present here CTheScripts::ClearSpaceForMissionEntity(pos, ped->m_pMyVehicle); @@ -3244,39 +3635,43 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) case COMMAND_IS_PLAYER_IN_AREA_2D: { CollectParameters(&m_nIp, 6); - CPlayerPed* ped = CWorld::Players[ScriptParams[0]].m_pPed; - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float x2 = *(float*)&ScriptParams[3]; - float y2 = *(float*)&ScriptParams[4]; + CPlayerPed* ped = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float x2 = GET_FLOAT_PARAM(3); + float y2 = GET_FLOAT_PARAM(4); if (!ped->bInVehicle) UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2)); else UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2)); - if (ScriptParams[5]) + if (GET_INTEGER_PARAM(5)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); + */ return 0; } case COMMAND_IS_PLAYER_IN_AREA_3D: { CollectParameters(&m_nIp, 8); - CPlayerPed* ped = CWorld::Players[ScriptParams[0]].m_pPed; - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float z1 = *(float*)&ScriptParams[3]; - float x2 = *(float*)&ScriptParams[4]; - float y2 = *(float*)&ScriptParams[5]; - float z2 = *(float*)&ScriptParams[6]; + CPlayerPed* ped = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float z1 = GET_FLOAT_PARAM(3); + float x2 = GET_FLOAT_PARAM(4); + float y2 = GET_FLOAT_PARAM(5); + float z2 = GET_FLOAT_PARAM(6); if (ped->bInVehicle) UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); else UpdateCompareFlag(ped->IsWithinArea(x1, y1, z1, x2, y2, z2)); - if (ScriptParams[7]) + if (GET_INTEGER_PARAM(7)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); + */ return 0; } case COMMAND_ADD_INT_VAR_TO_INT_VAR: @@ -3423,33 +3818,25 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr += CTimer::GetTimeStep() * *(float*)&ScriptParams[0]; + *(float*)ptr += CTimer::GetTimeStep() * GET_FLOAT_PARAM(0); return 0; } case COMMAND_ADD_TIMED_VAL_TO_FLOAT_LVAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr += CTimer::GetTimeStep() * *(float*)&ScriptParams[0]; + *(float*)ptr += CTimer::GetTimeStep() * GET_FLOAT_PARAM(0); return 0; } case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_VAR: fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; -#ifdef FIX_BUGS case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR: -#else - case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR: -#endif fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; -#ifdef FIX_BUGS case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR: -#else - case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR: -#endif fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; @@ -3461,33 +3848,25 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr -= CTimer::GetTimeStep() * *(float*)&ScriptParams[0]; + *(float*)ptr -= CTimer::GetTimeStep() * GET_FLOAT_PARAM(0); return 0; } case COMMAND_SUB_TIMED_VAL_FROM_FLOAT_LVAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr -= CTimer::GetTimeStep() * *(float*)&ScriptParams[0]; + *(float*)ptr -= CTimer::GetTimeStep() * GET_FLOAT_PARAM(0); return 0; } case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_VAR: fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; -#ifdef FIX_BUGS // in SA it was fixed by reversing their order in enum case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR: -#else - case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR: -#endif fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; -#ifdef FIX_BUGS case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR: -#else - case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR: -#endif fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; @@ -3636,46 +4015,46 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_CREATE_CHAR: { CollectParameters(&m_nIp, 5); - switch (ScriptParams[1]) { + switch (GET_INTEGER_PARAM(1)) { case MI_COP: - if (ScriptParams[0] == PEDTYPE_COP) - ScriptParams[1] = COP_STREET; + if (GET_INTEGER_PARAM(0) == PEDTYPE_COP) + SET_INTEGER_PARAM(1, COP_STREET); break; case MI_SWAT: - if (ScriptParams[0] == PEDTYPE_COP) - ScriptParams[1] = COP_SWAT; + if (GET_INTEGER_PARAM(0) == PEDTYPE_COP) + SET_INTEGER_PARAM(1, COP_SWAT); break; case MI_FBI: - if (ScriptParams[0] == PEDTYPE_COP) - ScriptParams[1] = COP_FBI; + if (GET_INTEGER_PARAM(0) == PEDTYPE_COP) + SET_INTEGER_PARAM(1, COP_FBI); break; case MI_ARMY: - if (ScriptParams[0] == PEDTYPE_COP) - ScriptParams[1] = COP_ARMY; + if (GET_INTEGER_PARAM(0) == PEDTYPE_COP) + SET_INTEGER_PARAM(1, COP_ARMY); break; case MI_MEDIC: - if (ScriptParams[0] == PEDTYPE_EMERGENCY) - ScriptParams[1] = PEDTYPE_EMERGENCY; + if (GET_INTEGER_PARAM(0) == PEDTYPE_EMERGENCY) + SET_INTEGER_PARAM(1, PEDTYPE_EMERGENCY); break; case MI_FIREMAN: - if (ScriptParams[0] == PEDTYPE_FIREMAN) - ScriptParams[1] = PEDTYPE_FIREMAN; + if (GET_INTEGER_PARAM(0) == PEDTYPE_FIREMAN) + SET_INTEGER_PARAM(1, PEDTYPE_FIREMAN); break; default: break; } CPed* ped; - if (ScriptParams[0] == PEDTYPE_COP) - ped = new CCopPed((eCopType)ScriptParams[1]); - else if (ScriptParams[0] == PEDTYPE_EMERGENCY || ScriptParams[0] == PEDTYPE_FIREMAN) - ped = new CEmergencyPed(ScriptParams[1]); + if (GET_INTEGER_PARAM(0) == PEDTYPE_COP) + ped = new CCopPed((eCopType)GET_INTEGER_PARAM(1)); + else if (GET_INTEGER_PARAM(0) == PEDTYPE_EMERGENCY || GET_INTEGER_PARAM(0) == PEDTYPE_FIREMAN) + ped = new CEmergencyPed(GET_INTEGER_PARAM(1)); else - ped = new CCivilianPed((ePedType)ScriptParams[0], ScriptParams[1]); + ped = new CCivilianPed((ePedType)GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); ped->CharCreatedBy = MISSION_CHAR; ped->bRespondsToThreats = false; ped->bAllowMedicsToReviveMe = false; ped->bIsPlayerFriend = false; - CVector pos = *(CVector*)&ScriptParams[2]; + CVector pos = GET_VECTOR_PARAM(2); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += 1.0f; @@ -3687,29 +4066,29 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) CWorld::Add(ped); ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos); CPopulation::ms_nTotalMissionPeds++; - ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped); + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(ped)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_DELETE_CHAR: { CollectParameters(&m_nIp, 1); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); CTheScripts::RemoveThisPed(ped); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_CHAR_WANDER_DIR: { CollectParameters(&m_nIp, 2); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); ped->ClearAll(); - int8 path = ScriptParams[1]; - if (ScriptParams[1] < 0 || ScriptParams[1] > 7) + int8 path = GET_INTEGER_PARAM(1); + if (GET_INTEGER_PARAM(1) < 0 || GET_INTEGER_PARAM(1) > 7) // Max number GetRandomNumberInRange returns is max-1 #ifdef FIX_BUGS path = CGeneral::GetRandomNumberInRange(0, 8); @@ -3724,19 +4103,19 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_CHAR_FOLLOW_PATH: { CollectParameters(&m_nIp, 6); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); if (ped->GetPedState() == PED_ATTACK || ped->GetPedState() == PED_FIGHT || !ped->IsPedInControl()) return 0; - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - float radius = *(float*)&ScriptParams[4]; + float radius = GET_FLOAT_PARAM(4); eMoveState state; - switch (ScriptParams[5]) { + switch (GET_INTEGER_PARAM(5)) { case 0: state = PEDMOVE_WALK; break; case 1: state = PEDMOVE_RUN; break; - default: assert(0); + default: state = PEDMOVE_WALK; break; } ped->ClearAll(); ped->m_pathNodeTimer = 0; @@ -3746,7 +4125,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_CHAR_SET_IDLE: { CollectParameters(&m_nIp, 1); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); ped->bScriptObjectiveCompleted = false; ped->SetObjective(OBJECTIVE_WAIT_ON_FOOT); @@ -3755,7 +4134,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_GET_CHAR_COORDINATES: { CollectParameters(&m_nIp, 1); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); CVehicle* vehicle; CVector pos; @@ -3768,21 +4147,21 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) pos = vehicle->GetPosition(); else pos = ped->GetPosition(); - *(CVector*)&ScriptParams[0] = pos; + SET_VECTOR_PARAM(0, pos); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_SET_CHAR_COORDINATES: { CollectParameters(&m_nIp, 4); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); CVehicle* vehicle; if (ped->bInVehicle) vehicle = ped->m_pMyVehicle; else vehicle = nil; - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); // removed dumb stuff again @@ -3805,72 +4184,74 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) } return 0; } - /* case COMMAND_IS_CHAR_STILL_ALIVE: { CollectParameters(&m_nIp, 1); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); - UpdateCompareFlag(ped && ped->GetPedState() != PED_DEAD && ped->GetPedState() != PED_DIE); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + UpdateCompareFlag(ped && !ped->DyingOrDead()); return 0; } - */ case COMMAND_IS_CHAR_IN_AREA_2D: { CollectParameters(&m_nIp, 6); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); CVehicle* vehicle; if (ped->bInVehicle) vehicle = ped->m_pMyVehicle; else vehicle = nil; - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float x2 = *(float*)&ScriptParams[3]; - float y2 = *(float*)&ScriptParams[4]; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float x2 = GET_FLOAT_PARAM(3); + float y2 = GET_FLOAT_PARAM(4); if (vehicle) UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2)); else UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2)); - if (ScriptParams[5]) + if (GET_INTEGER_PARAM(5)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); + */ return 0; } case COMMAND_IS_CHAR_IN_AREA_3D: { CollectParameters(&m_nIp, 8); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); CVehicle* vehicle; if (ped->bInVehicle) vehicle = ped->m_pMyVehicle; else vehicle = nil; - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float z1 = *(float*)&ScriptParams[3]; - float x2 = *(float*)&ScriptParams[4]; - float y2 = *(float*)&ScriptParams[5]; - float z2 = *(float*)&ScriptParams[6]; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float z1 = GET_FLOAT_PARAM(3); + float x2 = GET_FLOAT_PARAM(4); + float y2 = GET_FLOAT_PARAM(5); + float z2 = GET_FLOAT_PARAM(6); if (vehicle) UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); else UpdateCompareFlag(ped->IsWithinArea(x1, y1, z1, x2, y2, z2)); - if (ScriptParams[7]) + if (GET_INTEGER_PARAM(7)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); + */ return 0; } case COMMAND_CREATE_CAR: { CollectParameters(&m_nIp, 4); int32 handle; - if (CModelInfo::IsBoatModel(ScriptParams[0])) { - CBoat* boat = new CBoat(ScriptParams[0], MISSION_VEHICLE); - CVector pos = *(CVector*)&ScriptParams[1]; + if (CModelInfo::IsBoatModel(GET_INTEGER_PARAM(0))) { + CBoat* boat = new CBoat(GET_INTEGER_PARAM(0), MISSION_VEHICLE); + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += boat->GetDistanceFromCentreOfMassToBaseOfModel(); @@ -3889,13 +4270,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) else { CVehicle* car; - if (!CModelInfo::IsBikeModel(ScriptParams[0])) - car = new CAutomobile(ScriptParams[0], MISSION_VEHICLE); + if (!CModelInfo::IsBikeModel(GET_INTEGER_PARAM(0))) + car = new CAutomobile(GET_INTEGER_PARAM(0), MISSION_VEHICLE); else { - car = new CBike(ScriptParams[0], MISSION_VEHICLE); + car = new CBike(GET_INTEGER_PARAM(0), MISSION_VEHICLE); ((CBike*)(car))->bIsStanding = true; } - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel(); @@ -3910,14 +4291,14 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) car->AutoPilot.m_nCruiseSpeed = car->AutoPilot.m_fMaxTrafficSpeed = 9.0f; car->AutoPilot.m_nCurrentLane = car->AutoPilot.m_nNextLane = 0; car->bEngineOn = false; - car->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos); + car->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos); // TODO: gpTheZones car->bHasBeenOwnedByPlayer = true; if (m_bIsMissionScript) car->bIsStaticWaitingForCollision = true; CWorld::Add(car); handle = CPools::GetVehiclePool()->GetIndex(car); } - ScriptParams[0] = handle; + SET_INTEGER_PARAM(0, handle); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) CTheScripts::MissionCleanUp.AddEntityToList(handle, CLEANUP_CAR); @@ -3926,25 +4307,26 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_DELETE_CAR: { CollectParameters(&m_nIp, 1); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); if (car) { CWorld::Remove(car); CWorld::RemoveReferencesToDeletedObject(car); delete car; } if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CAR); + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_CAR); return 0; } case COMMAND_CAR_GOTO_COORDINATES: { CollectParameters(&m_nIp, 4); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel(); + uint8 nOldMission = car->AutoPilot.m_nCarMission; if (CCarCtrl::JoinCarWithRoadSystemGotoCoors(car, pos, false)) car->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_STRAIGHT; else @@ -3952,13 +4334,14 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) car->SetStatus(STATUS_PHYSICS); car->bEngineOn = true; car->AutoPilot.m_nCruiseSpeed = Max(1, car->AutoPilot.m_nCruiseSpeed); - car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); + if (nOldMission != car->AutoPilot.m_nCarMission) + car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); return 0; } case COMMAND_CAR_WANDER_RANDOMLY: { CollectParameters(&m_nIp, 1); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); CCarCtrl::JoinCarWithRoadSystem(car); car->AutoPilot.m_nCarMission = MISSION_CRUISE; @@ -3970,7 +4353,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_CAR_SET_IDLE: { CollectParameters(&m_nIp, 1); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); car->AutoPilot.m_nCarMission = MISSION_NONE; return 0; @@ -3978,18 +4361,18 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_GET_CAR_COORDINATES: { CollectParameters(&m_nIp, 1); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); - *(CVector*)&ScriptParams[0] = car->GetPosition(); + SET_VECTOR_PARAM(0, car->GetPosition()); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_SET_CAR_COORDINATES: { CollectParameters(&m_nIp, 4); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel(); @@ -4035,80 +4418,84 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) } return 0; } - /* case COMMAND_IS_CAR_STILL_ALIVE: { CollectParameters(&m_nIp, 1); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(car && car->GetStatus() != STATUS_WRECKED && (car->IsBoat() || !car->bIsInWater)); return 0; } - */ case COMMAND_SET_CAR_CRUISE_SPEED: { CollectParameters(&m_nIp, 2); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); #if defined MISSION_REPLAY && defined SIMPLIER_MISSIONS - car->AutoPilot.m_nCruiseSpeed = *(float*)&ScriptParams[1]; + car->AutoPilot.m_nCruiseSpeed = GET_FLOAT_PARAM(1); if (missionRetryScriptIndex == 40 && car->GetModelIndex() == MI_CHEETAH) // Turismo car->AutoPilot.m_nCruiseSpeed = 8 * car->AutoPilot.m_nCruiseSpeed / 10; car->AutoPilot.m_nCruiseSpeed = Min(car->AutoPilot.m_nCruiseSpeed, 60.0f * car->pHandling->Transmission.fMaxCruiseVelocity); #else - car->AutoPilot.m_nCruiseSpeed = Min(*(float*)&ScriptParams[1], 60.0f * car->pHandling->Transmission.fMaxCruiseVelocity); + car->AutoPilot.m_nCruiseSpeed = Min(GET_FLOAT_PARAM(1), 60.0f * car->pHandling->Transmission.fMaxCruiseVelocity); #endif return 0; } case COMMAND_SET_CAR_DRIVING_STYLE: { CollectParameters(&m_nIp, 2); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); - car->AutoPilot.m_nDrivingStyle = (uint8)ScriptParams[1]; + car->AutoPilot.m_nDrivingStyle = (uint8)GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_CAR_MISSION: { CollectParameters(&m_nIp, 2); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); - car->AutoPilot.m_nCarMission = (uint8)ScriptParams[1]; - car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); + if ((uint8)GET_INTEGER_PARAM(1) != car->AutoPilot.m_nCarMission) { + car->AutoPilot.m_nCarMission = (uint8)GET_INTEGER_PARAM(1); + car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); + } car->bEngineOn = true; return 0; } case COMMAND_IS_CAR_IN_AREA_2D: { CollectParameters(&m_nIp, 6); - CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(vehicle); - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float x2 = *(float*)&ScriptParams[3]; - float y2 = *(float*)&ScriptParams[4]; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float x2 = GET_FLOAT_PARAM(3); + float y2 = GET_FLOAT_PARAM(4); UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, x2, y2)); - if (ScriptParams[5]) + if (GET_INTEGER_PARAM(5)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); + */ return 0; } case COMMAND_IS_CAR_IN_AREA_3D: { CollectParameters(&m_nIp, 8); - CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(vehicle); - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float z1 = *(float*)&ScriptParams[3]; - float x2 = *(float*)&ScriptParams[4]; - float y2 = *(float*)&ScriptParams[5]; - float z2 = *(float*)&ScriptParams[6]; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float z1 = GET_FLOAT_PARAM(3); + float x2 = GET_FLOAT_PARAM(4); + float y2 = GET_FLOAT_PARAM(5); + float z2 = GET_FLOAT_PARAM(6); UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); - if (ScriptParams[7]) + if (GET_INTEGER_PARAM(7)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); + */ return 0; } case COMMAND_SPECIAL_0: @@ -4129,72 +4516,72 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) AllowMissionReplay = 1; #endif CollectParameters(&m_nIp, 2); - CMessages::AddBigMessage(key, ScriptParams[0], ScriptParams[1] - 1); + CMessages::AddBigMessage(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1) - 1); return 0; } case COMMAND_PRINT: { wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 2); - CMessages::AddMessage(key, ScriptParams[0], ScriptParams[1]); + CMessages::AddMessage(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; } case COMMAND_PRINT_NOW: { wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 2); - CMessages::AddMessageJumpQ(key, ScriptParams[0], ScriptParams[1]); + CMessages::AddMessageJumpQ(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; } - /* case COMMAND_PRINT_SOON: { wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 2); - CMessages::AddMessageSoon(key, ScriptParams[0], ScriptParams[1]); + CMessages::AddMessageSoon(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; } - */ case COMMAND_CLEAR_PRINTS: CMessages::ClearMessages(); return 0; case COMMAND_GET_TIME_OF_DAY: - ScriptParams[0] = CClock::GetHours(); - ScriptParams[1] = CClock::GetMinutes(); + SET_INTEGER_PARAM(0, CClock::GetHours()); + SET_INTEGER_PARAM(1, CClock::GetMinutes()); StoreParameters(&m_nIp, 2); return 0; case COMMAND_SET_TIME_OF_DAY: CollectParameters(&m_nIp, 2); - CClock::SetGameClock(ScriptParams[0], ScriptParams[1]); + CClock::SetGameClock(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_GET_MINUTES_TO_TIME_OF_DAY: CollectParameters(&m_nIp, 2); - ScriptParams[0] = CClock::GetGameClockMinutesUntil(ScriptParams[0], ScriptParams[1]); + SET_INTEGER_PARAM(0, CClock::GetGameClockMinutesUntil(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1))); StoreParameters(&m_nIp, 1); return 0; case COMMAND_IS_POINT_ON_SCREEN: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= -100) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - UpdateCompareFlag(TheCamera.IsSphereVisible(pos, *(float*)&ScriptParams[3])); + UpdateCompareFlag(TheCamera.IsSphereVisible(pos, GET_FLOAT_PARAM(3))); return 0; } + /* case COMMAND_DEBUG_ON: CTheScripts::DbgFlag = true; return 0; case COMMAND_DEBUG_OFF: CTheScripts::DbgFlag = false; return 0; - /* + */ case COMMAND_RETURN_TRUE: UpdateCompareFlag(true); + ReturnFromGosubOrFunction(); return 0; case COMMAND_RETURN_FALSE: UpdateCompareFlag(false); + ReturnFromGosubOrFunction(); return 0; - */ //case COMMAND_VAR_INT: default: script_assert(0); @@ -4221,10 +4608,15 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_WHILE: case COMMAND_WHILENOT: case COMMAND_ENDWHILE: + case COMMAND_214: + case COMMAND_215: + case COMMAND_216: + case COMMAND_217: + case COMMAND_218: */ case COMMAND_ANDOR: CollectParameters(&m_nIp, 1); - m_nAndOrState = ScriptParams[0]; + m_nAndOrState = GET_INTEGER_PARAM(0); if (m_nAndOrState == ANDOR_NONE){ m_bCondResult = false; // pointless }else if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8){ @@ -4240,7 +4632,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_LAUNCH_MISSION: { CollectParameters(&m_nIp, 1); - CRunningScript* pNew = CTheScripts::StartNewScript(ScriptParams[0]); + CRunningScript* pNew = CTheScripts::StartNewScript(GET_INTEGER_PARAM(0)); pNew->m_bIsMissionScript = true; return 0; } @@ -4254,7 +4646,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_STORE_CAR_CHAR_IS_IN: { CollectParameters(&m_nIp, 1); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); CVehicle* pCurrent = nil; if (ped->bInVehicle) { @@ -4299,14 +4691,14 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) break; } } - ScriptParams[0] = CTheScripts::StoreVehicleIndex; + SET_INTEGER_PARAM(0, CTheScripts::StoreVehicleIndex); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_STORE_CAR_PLAYER_IS_IN: { CollectParameters(&m_nIp, 1); - CPed* ped = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* ped = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(ped); if (!ped->bInVehicle) return 0; // No value written to output variable @@ -4350,15 +4742,15 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) break; } } - ScriptParams[0] = CTheScripts::StoreVehicleIndex; + SET_INTEGER_PARAM(0, CTheScripts::StoreVehicleIndex); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_IS_CHAR_IN_CAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CVehicle* pCheckedVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CVehicle* pCheckedVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); CVehicle* pActualVehicle = pPed->bInVehicle ? pPed->m_pMyVehicle : nil; UpdateCompareFlag(pActualVehicle && pActualVehicle == pCheckedVehicle); return 0; @@ -4366,51 +4758,51 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_IS_PLAYER_IN_CAR: { CollectParameters(&m_nIp, 2); - CVehicle* pCheckedVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CVehicle* pCheckedVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle == pCheckedVehicle); return 0; } case COMMAND_IS_CHAR_IN_MODEL: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); CVehicle* pActualVehicle = pPed->bInVehicle ? pPed->m_pMyVehicle : nil; - UpdateCompareFlag(pActualVehicle && pActualVehicle->GetModelIndex() == ScriptParams[1]); + UpdateCompareFlag(pActualVehicle && pActualVehicle->GetModelIndex() == GET_INTEGER_PARAM(1)); return 0; } case COMMAND_IS_PLAYER_IN_MODEL: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetModelIndex() == ScriptParams[1]); + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetModelIndex() == GET_INTEGER_PARAM(1)); return 0; } case COMMAND_IS_CHAR_IN_ANY_CAR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle); return 0; } case COMMAND_IS_PLAYER_IN_ANY_CAR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle); return 0; } case COMMAND_IS_BUTTON_PRESSED: { CollectParameters(&m_nIp, 2); - UpdateCompareFlag(GetPadState(ScriptParams[0], ScriptParams[1]) != 0); + UpdateCompareFlag(GetPadState(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)) != 0); return 0; } /* case COMMAND_GET_PAD_STATE: { CollectParameters(&m_nIp, 1); - ScriptParams[0] = GetPadState(ScriptParams[0], ScriptParams[1]); + SET_INTEGER_PARAM(0, GetPadState(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1))); StoreParameters(&m_nIp, 1); return 0; } @@ -4470,10 +4862,10 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_CREATE_OBJECT: { CollectParameters(&m_nIp, 4); - int mi = ScriptParams[0] >= 0 ? ScriptParams[0] : CTheScripts::UsedObjectArray[-ScriptParams[0]].index; + int mi = GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::UsedObjectArray[-GET_INTEGER_PARAM(0)].index; CObject* pObj = new CObject(mi, false); pObj->ObjectCreatedBy = MISSION_OBJECT; - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += pObj->GetDistanceFromCentreOfMassToBaseOfModel(); @@ -4481,73 +4873,70 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) pObj->SetOrientation(0.0f, 0.0f, 0.0f); pObj->GetMatrix().UpdateRW(); pObj->UpdateRwFrame(); - CBaseModelInfo* pModelInfo = CModelInfo::GetModelInfo(mi); - if (pModelInfo->IsBuilding() && ((CSimpleModelInfo*)pModelInfo)->m_isBigBuilding) - pObj->SetupBigBuilding(); CTheScripts::ClearSpaceForMissionEntity(pos, pObj); CWorld::Add(pObj); - ScriptParams[0] = CPools::GetObjectPool()->GetIndex(pObj); + SET_INTEGER_PARAM(0, CPools::GetObjectPool()->GetIndex(pObj)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_OBJECT); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_OBJECT); return 0; } case COMMAND_DELETE_OBJECT: { CollectParameters(&m_nIp, 1); - CObject* pObj = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObj = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); if (pObj){ CWorld::Remove(pObj); CWorld::RemoveReferencesToDeletedObject(pObj); delete pObj; } if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_OBJECT); + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_OBJECT); return 0; } case COMMAND_ADD_SCORE: CollectParameters(&m_nIp, 2); - CWorld::Players[ScriptParams[0]].m_nMoney += ScriptParams[1]; - if (CWorld::Players[ScriptParams[0]].m_nMoney < 0) - CWorld::Players[ScriptParams[0]].m_nMoney = 0; + CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney += GET_INTEGER_PARAM(1); + if (CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney < 0) + CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney = 0; return 0; case COMMAND_IS_SCORE_GREATER: CollectParameters(&m_nIp, 2); - UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_nMoney > ScriptParams[1]); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney > GET_INTEGER_PARAM(1)); return 0; case COMMAND_STORE_SCORE: CollectParameters(&m_nIp, 1); - ScriptParams[0] = CWorld::Players[ScriptParams[0]].m_nMoney; + SET_INTEGER_PARAM(0, CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney); StoreParameters(&m_nIp, 1); return 0; case COMMAND_GIVE_REMOTE_CONTROLLED_CAR_TO_PLAYER: { CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CRemote::GivePlayerRemoteControlledCar(pos.x, pos.y, pos.z, DEGTORAD(*(float*)&ScriptParams[4]), MI_RCBANDIT); + CRemote::GivePlayerRemoteControlledCar(pos.x, pos.y, pos.z, DEGTORAD(GET_FLOAT_PARAM(4)), MI_RCBANDIT); return 0; } case COMMAND_ALTER_WANTED_LEVEL: CollectParameters(&m_nIp, 2); - CWorld::Players[ScriptParams[0]].m_pPed->SetWantedLevel(ScriptParams[1]); + CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->SetWantedLevel(GET_INTEGER_PARAM(1)); return 0; case COMMAND_ALTER_WANTED_LEVEL_NO_DROP: CollectParameters(&m_nIp, 2); - CWorld::Players[ScriptParams[0]].m_pPed->SetWantedLevelNoDrop(ScriptParams[1]); + CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->SetWantedLevelNoDrop(GET_INTEGER_PARAM(1)); return 0; case COMMAND_IS_WANTED_LEVEL_GREATER: CollectParameters(&m_nIp, 2); - UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_pPed->m_pWanted->m_nWantedLevel > ScriptParams[1]); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->m_pWanted->m_nWantedLevel > GET_INTEGER_PARAM(1)); return 0; case COMMAND_CLEAR_WANTED_LEVEL: CollectParameters(&m_nIp, 1); - CWorld::Players[ScriptParams[0]].m_pPed->SetWantedLevel(0); + CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->SetWantedLevel(0); return 0; case COMMAND_SET_DEATHARREST_STATE: CollectParameters(&m_nIp, 1); - m_bDeatharrestEnabled = (ScriptParams[0] == 1); + m_bDeatharrestEnabled = (GET_INTEGER_PARAM(0) == 1); return 0; case COMMAND_HAS_DEATHARREST_BEEN_EXECUTED: UpdateCompareFlag(m_bDeatharrestExecuted); @@ -4556,51 +4945,54 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_ADD_AMMO_TO_PLAYER: { CollectParameters(&m_nIp, 3); - CWorld::Players[ScriptParams[0]].m_pPed->GrantAmmo((eWeaponType)ScriptParams[1], ScriptParams[2]); + CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->GrantAmmo((eWeaponType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } */ case COMMAND_ADD_AMMO_TO_CHAR: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->GrantAmmo((eWeaponType)ScriptParams[1], ScriptParams[2]); + pPed->GrantAmmo((eWeaponType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } //case COMMAND_ADD_AMMO_TO_CAR: - //case COMMAND_IS_PLAYER_STILL_ALIVE: + case COMMAND_IS_PLAYER_STILL_ALIVE: + CollectParameters(&m_nIp, 1); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_WBState != WBSTATE_WASTED); + return 0; case COMMAND_IS_PLAYER_DEAD: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_WBState == WBSTATE_WASTED); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_WBState == WBSTATE_WASTED); return 0; case COMMAND_IS_CHAR_DEAD: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - UpdateCompareFlag(!pPed || pPed->DyingOrDead()); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + UpdateCompareFlag(!pPed || pPed->DyingOrDead() || pPed->m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE); return 0; } case COMMAND_IS_CAR_DEAD: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(!pVehicle || pVehicle->GetStatus() == STATUS_WRECKED || pVehicle->bIsDrowning); return 0; } case COMMAND_SET_CHAR_THREAT_SEARCH: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->m_fearFlags |= ScriptParams[1]; + pPed->m_fearFlags |= GET_INTEGER_PARAM(1); return 0; } //case COMMAND_SET_CHAR_THREAT_REACTION: case COMMAND_SET_CHAR_OBJ_NO_OBJ: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->ClearObjective(); @@ -4613,7 +5005,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_IS_PLAYER_IN_ZONE: { CollectParameters(&m_nIp, 1); - CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]]; + CPlayerInfo* pPlayer = &CWorld::Players[GET_INTEGER_PARAM(0)]; char label[12]; CTheScripts::ReadTextLabelFromScript(&m_nIp, label); int zoneToCheck = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_DEFAULT); @@ -4626,15 +5018,15 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) } case COMMAND_IS_PLAYER_PRESSING_HORN: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_pPed->GetPedState() == PED_DRIVING && - CPad::GetPad(ScriptParams[0])->GetHorn()); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->GetPedState() == PED_DRIVING && + CPad::GetPad(GET_INTEGER_PARAM(0))->GetHorn()); return 0; case COMMAND_HAS_CHAR_SPOTTED_PLAYER: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - UpdateCompareFlag(pPed->OurPedCanSeeThisOne(CWorld::Players[ScriptParams[1]].m_pPed)); + UpdateCompareFlag(pPed->OurPedCanSeeThisOne(CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed)); return 0; } //case COMMAND_ORDER_CHAR_TO_BACKDOOR: @@ -4642,7 +5034,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_IS_CHAR_OBJECTIVE_PASSED: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->bScriptObjectiveCompleted); return 0; @@ -4654,43 +5046,43 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_CREATE_CHAR_INSIDE_CAR: { CollectParameters(&m_nIp, 3); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - switch (ScriptParams[2]) { + switch (GET_INTEGER_PARAM(2)) { case MI_COP: - if (ScriptParams[1] == PEDTYPE_COP) - ScriptParams[2] = COP_STREET; + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + SET_INTEGER_PARAM(2, COP_STREET); break; case MI_SWAT: - if (ScriptParams[1] == PEDTYPE_COP) - ScriptParams[2] = COP_SWAT; + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + SET_INTEGER_PARAM(2, COP_SWAT); break; case MI_FBI: - if (ScriptParams[1] == PEDTYPE_COP) - ScriptParams[2] = COP_FBI; + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + SET_INTEGER_PARAM(2, COP_FBI); break; case MI_ARMY: - if (ScriptParams[1] == PEDTYPE_COP) - ScriptParams[2] = COP_ARMY; + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + SET_INTEGER_PARAM(2, COP_ARMY); break; case MI_MEDIC: - if (ScriptParams[1] == PEDTYPE_EMERGENCY) - ScriptParams[2] = PEDTYPE_EMERGENCY; + if (GET_INTEGER_PARAM(1) == PEDTYPE_EMERGENCY) + SET_INTEGER_PARAM(2, PEDTYPE_EMERGENCY); break; case MI_FIREMAN: - if (ScriptParams[1] == PEDTYPE_FIREMAN) - ScriptParams[2] = PEDTYPE_FIREMAN; + if (GET_INTEGER_PARAM(1) == PEDTYPE_FIREMAN) + SET_INTEGER_PARAM(2, PEDTYPE_FIREMAN); break; default: break; } CPed* pPed; - if (ScriptParams[1] == PEDTYPE_COP) - pPed = new CCopPed((eCopType)ScriptParams[2]); - else if (ScriptParams[1] == PEDTYPE_EMERGENCY || ScriptParams[1] == PEDTYPE_FIREMAN) - pPed = new CEmergencyPed(ScriptParams[2]); + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + pPed = new CCopPed((eCopType)GET_INTEGER_PARAM(2)); + else if (GET_INTEGER_PARAM(1) == PEDTYPE_EMERGENCY || GET_INTEGER_PARAM(1) == PEDTYPE_FIREMAN) + pPed = new CEmergencyPed(GET_INTEGER_PARAM(2)); else - pPed = new CCivilianPed((ePedType)ScriptParams[1], ScriptParams[2]); + pPed = new CCivilianPed((ePedType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); pPed->CharCreatedBy = MISSION_CHAR; pPed->bRespondsToThreats = false; pPed->bAllowMedicsToReviveMe = false; @@ -4700,7 +5092,6 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) pPed->SetPosition(pVehicle->GetPosition()); pPed->SetOrientation(0.0f, 0.0f, 0.0f); pPed->SetPedState(PED_DRIVING); - CPopulation::ms_nTotalMissionPeds++; script_assert(!pVehicle->pDriver); pVehicle->pDriver = pPed; pVehicle->pDriver->RegisterReference((CEntity**)&pVehicle->pDriver); @@ -4715,17 +5106,18 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) pPed->AddInCarAnims(pVehicle, true); pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition()); CWorld::Add(pPed); - ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed); + CPopulation::ms_nTotalMissionPeds++; + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(pPed)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_WARP_PLAYER_FROM_CAR_TO_COORD: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[1]; - CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]]; + CVector pos = GET_VECTOR_PARAM(1); + CPlayerInfo* pPlayer = &CWorld::Players[GET_INTEGER_PARAM(0)]; if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); if (pPlayer->m_pPed->bInVehicle){ @@ -4768,6 +5160,24 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) return -1; } +void CRunningScript::ReturnFromGosubOrFunction() +{ + uint32 val = m_nIp = m_anStack[--m_nStackPointer]; + if (!(m_nIp & BIT(STACKVALUE_IS_FUNCTION_CALL_BIT))) + return; + if (m_nIp & BIT(STACKVALUE_INVERT_RETURN_BIT)) + m_bCondResult = !m_bCondResult; + m_nIp = m_nIp & STACKVALUE_IP_MASK; + uint8 nInputParameters = CTheScripts::Read1ByteFromScript(&m_nIp); + uint8 nOutputParameters = CTheScripts::Read1ByteFromScript(&m_nIp); + uint8 nLocalsOffset = CTheScripts::Read1ByteFromScript(&m_nIp); + for (int i = 0; i < nOutputParameters; i++) + ScriptParams[i] = m_anLocalVariables[m_nLocalsPointer + nInputParameters]; + m_nIp += val >> STACKVALUE_IP_PARAMS_OFFSET; + m_nLocalsPointer -= nLocalsOffset; + StoreParameters(&m_nIp, nOutputParameters); +} + #ifdef MISSION_REPLAY bool CRunningScript::CanAllowMissionReplay() @@ -4848,9 +5258,9 @@ CTheScripts::SwitchToMission(int32 mission) int handle = CFileMgr::OpenFile("data\\main.scm", "rb"); #endif CFileMgr::Seek(handle, offset, 0); - CFileMgr::Read(handle, (const char*)&CTheScripts::ScriptSpace[SIZE_MAIN_SCRIPT], SIZE_MISSION_SCRIPT); + CFileMgr::Read(handle, (const char*)&CTheScripts::ScriptSpace[CTheScripts::MainScriptSize], CTheScripts::MainScriptSize); CFileMgr::CloseFile(handle); - CRunningScript* pMissionScript = CTheScripts::StartNewScript(SIZE_MAIN_SCRIPT); + CRunningScript* pMissionScript = CTheScripts::StartNewScript(CTheScripts::MainScriptSize); CTimer::Resume(); pMissionScript->m_bIsMissionScript = true; pMissionScript->m_bMissionFlag = true; |