From af6e132b37e8b7e89e4c0c7a52e5bb81e4b1b9a8 Mon Sep 17 00:00:00 2001 From: bigbossbro08 Date: Sun, 10 May 2020 19:54:37 +0600 Subject: defined out asserts. --- src/control/AutoPilot.h | 5 ++++- src/control/Garages.h | 2 ++ src/control/PathFind.h | 7 +++++++ src/control/Phones.h | 2 ++ src/control/Pickups.h | 2 ++ src/control/Replay.h | 3 +++ 6 files changed, 20 insertions(+), 1 deletion(-) (limited to 'src/control') diff --git a/src/control/AutoPilot.h b/src/control/AutoPilot.h index 345f4cb4..1528db46 100644 --- a/src/control/AutoPilot.h +++ b/src/control/AutoPilot.h @@ -119,4 +119,7 @@ public: #endif }; -static_assert(sizeof(CAutoPilot) == 0x70, "CAutoPilot: error"); \ No newline at end of file + +#ifdef CHECK_STRUCT_SIZES +static_assert(sizeof(CAutoPilot) == 0x70, "CAutoPilot: error"); +#endif \ No newline at end of file diff --git a/src/control/Garages.h b/src/control/Garages.h index 3105f72d..95e7ba5c 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -172,7 +172,9 @@ class CGarage friend class CCamera; }; +#ifdef CHECK_STRUCT_SIZES static_assert(sizeof(CGarage) == 140, "CGarage"); +#endif class CGarages { diff --git a/src/control/PathFind.h b/src/control/PathFind.h index 8049ea52..d812ac32 100644 --- a/src/control/PathFind.h +++ b/src/control/PathFind.h @@ -41,7 +41,10 @@ struct CPedPathNode CPedPathNode* prev; CPedPathNode* next; }; + +#ifdef CHECK_STRUCT_SIZES static_assert(sizeof(CPedPathNode) == 0x10, "CPedPathNode: error"); +#endif class CPedPath { public: @@ -221,7 +224,11 @@ public: void DisplayPathData(void); }; + + +#ifdef CHECK_STRUCT_SIZES static_assert(sizeof(CPathFind) == 0x49bf4, "CPathFind: error"); +#endif extern CPathFind ThePaths; diff --git a/src/control/Phones.h b/src/control/Phones.h index 7fbf403f..01ed370e 100644 --- a/src/control/Phones.h +++ b/src/control/Phones.h @@ -32,7 +32,9 @@ public: ~CPhone() { } }; +#ifdef CHECK_STRUCT_SIZES static_assert(sizeof(CPhone) == 0x34, "CPhone: error"); +#endif class CPhoneInfo { public: diff --git a/src/control/Pickups.h b/src/control/Pickups.h index 11da5f54..f4e5e560 100644 --- a/src/control/Pickups.h +++ b/src/control/Pickups.h @@ -47,7 +47,9 @@ private: void Remove(); }; +#ifdef CHECK_STRUCT_SIZES static_assert(sizeof(CPickup) == 0x1C, "CPickup: error"); +#endif struct tPickupMessage { diff --git a/src/control/Replay.h b/src/control/Replay.h index bf70a28a..ec39def8 100644 --- a/src/control/Replay.h +++ b/src/control/Replay.h @@ -108,7 +108,10 @@ class CReplay CMatrix camera_pos; CVector player_pos; }; + +#ifdef CHECK_STRUCT_SIZES static_assert(sizeof(tGeneralPacket) == 88, "tGeneralPacket: error"); +#endif struct tClockPacket { -- cgit v1.2.3 From c798e1bacdaabaf140ff3904948fd7cec46c09bb Mon Sep 17 00:00:00 2001 From: bigbossbro08 Date: Sun, 10 May 2020 21:49:33 +0600 Subject: Fixed typos and made all assert functions optional --- src/control/AutoPilot.h | 4 +--- src/control/Garages.h | 6 ++---- src/control/OnscreenTimer.h | 4 ++-- src/control/PathFind.h | 9 ++------- src/control/Phones.h | 4 +--- src/control/Pickups.h | 4 +--- src/control/Replay.h | 20 +++++++++----------- src/control/SceneEdit.cpp | 2 ++ src/control/Script.cpp | 10 ++++++++++ src/control/Script.h | 4 ++-- 10 files changed, 32 insertions(+), 35 deletions(-) (limited to 'src/control') diff --git a/src/control/AutoPilot.h b/src/control/AutoPilot.h index 1528db46..337a93c1 100644 --- a/src/control/AutoPilot.h +++ b/src/control/AutoPilot.h @@ -120,6 +120,4 @@ public: }; -#ifdef CHECK_STRUCT_SIZES -static_assert(sizeof(CAutoPilot) == 0x70, "CAutoPilot: error"); -#endif \ No newline at end of file +VALIDATE_SIZE(CAutoPilot, 0x70); diff --git a/src/control/Garages.h b/src/control/Garages.h index 95e7ba5c..00020eb3 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -75,7 +75,7 @@ public: CVehicle* RestoreCar(); }; -static_assert(sizeof(CStoredCar) == 0x28, "CStoredCar"); +VALIDATE_SIZE(CStoredCar, 0x28); #define SWITCH_GARAGE_DISTANCE_CLOSE 40.0f @@ -172,9 +172,7 @@ class CGarage friend class CCamera; }; -#ifdef CHECK_STRUCT_SIZES -static_assert(sizeof(CGarage) == 140, "CGarage"); -#endif +VALIDATE_SIZE(CGarage, 140); class CGarages { diff --git a/src/control/OnscreenTimer.h b/src/control/OnscreenTimer.h index fb139266..3ef7764a 100644 --- a/src/control/OnscreenTimer.h +++ b/src/control/OnscreenTimer.h @@ -26,7 +26,7 @@ public: void ProcessForDisplayCounter(); }; -static_assert(sizeof(COnscreenTimerEntry) == 0x74, "COnscreenTimerEntry: error"); +VALIDATE_SIZE(COnscreenTimerEntry, 0x74); class COnscreenTimer { @@ -46,4 +46,4 @@ public: void AddClock(uint32 offset, char* text); }; -static_assert(sizeof(COnscreenTimer) == 0x78, "COnscreenTimer: error"); \ No newline at end of file +VALIDATE_SIZE(COnscreenTimer, 0x78); diff --git a/src/control/PathFind.h b/src/control/PathFind.h index d812ac32..bbfdf7b7 100644 --- a/src/control/PathFind.h +++ b/src/control/PathFind.h @@ -42,9 +42,7 @@ struct CPedPathNode CPedPathNode* next; }; -#ifdef CHECK_STRUCT_SIZES -static_assert(sizeof(CPedPathNode) == 0x10, "CPedPathNode: error"); -#endif +VALIDATE_SIZE(CPedPathNode, 0x10); class CPedPath { public: @@ -225,10 +223,7 @@ public: void DisplayPathData(void); }; - -#ifdef CHECK_STRUCT_SIZES -static_assert(sizeof(CPathFind) == 0x49bf4, "CPathFind: error"); -#endif +VALIDATE_SIZE(CPathFind, 0x49bf4); extern CPathFind ThePaths; diff --git a/src/control/Phones.h b/src/control/Phones.h index 01ed370e..14d47ed1 100644 --- a/src/control/Phones.h +++ b/src/control/Phones.h @@ -32,9 +32,7 @@ public: ~CPhone() { } }; -#ifdef CHECK_STRUCT_SIZES -static_assert(sizeof(CPhone) == 0x34, "CPhone: error"); -#endif +VALIDATE_SIZE(CPhone, 0x34); class CPhoneInfo { public: diff --git a/src/control/Pickups.h b/src/control/Pickups.h index f4e5e560..b05f5db7 100644 --- a/src/control/Pickups.h +++ b/src/control/Pickups.h @@ -47,9 +47,7 @@ private: void Remove(); }; -#ifdef CHECK_STRUCT_SIZES -static_assert(sizeof(CPickup) == 0x1C, "CPickup: error"); -#endif +VALIDATE_SIZE(CPickup, 0x1C); struct tPickupMessage { diff --git a/src/control/Replay.h b/src/control/Replay.h index ec39def8..66bee3bf 100644 --- a/src/control/Replay.h +++ b/src/control/Replay.h @@ -109,9 +109,7 @@ class CReplay CVector player_pos; }; -#ifdef CHECK_STRUCT_SIZES - static_assert(sizeof(tGeneralPacket) == 88, "tGeneralPacket: error"); -#endif + VALIDATE_SIZE(tGeneralPacket, 88); struct tClockPacket { @@ -121,7 +119,7 @@ class CReplay private: uint8 __align; }; - static_assert(sizeof(tClockPacket) == 4, "tClockPacket: error"); + VALIDATE_SIZE(tClockPacket, 4); struct tWeatherPacket { @@ -130,14 +128,14 @@ class CReplay uint8 new_weather; float interpolation; }; - static_assert(sizeof(tWeatherPacket) == 8, "tWeatherPacket: error"); + VALIDATE_SIZE(tWeatherPacket, 8); struct tTimerPacket { uint8 type; uint32 timer; }; - static_assert(sizeof(tTimerPacket) == 8, "tTimerPacket: error"); + VALIDATE_SIZE(tTimerPacket, 8); struct tPedHeaderPacket { @@ -148,7 +146,7 @@ class CReplay private: uint8 __align[3]; }; - static_assert(sizeof(tPedHeaderPacket) == 8, "tPedHeaderPacket: error"); + VALIDATE_SIZE(tPedHeaderPacket, 8); struct tBulletTracePacket { @@ -159,7 +157,7 @@ class CReplay CVector inf; CVector sup; }; - static_assert(sizeof(tBulletTracePacket) == 28, "tBulletTracePacket: error"); + VALIDATE_SIZE(tBulletTracePacket, 28); struct tEndOfFramePacket { @@ -167,7 +165,7 @@ class CReplay private: uint8 __align[3]; }; - static_assert(sizeof(tEndOfFramePacket) == 4, "tEndOfFramePacket: error"); + VALIDATE_SIZE(tEndOfFramePacket, 4); struct tPedUpdatePacket { @@ -180,7 +178,7 @@ class CReplay int8 assoc_group_id; uint8 weapon_model; }; - static_assert(sizeof(tPedUpdatePacket) == 40, "tPedUpdatePacket: error"); + VALIDATE_SIZE(tPedUpdatePacket, 40); struct tVehicleUpdatePacket { @@ -205,7 +203,7 @@ class CReplay uint8 primary_color; uint8 secondary_color; }; - static_assert(sizeof(tVehicleUpdatePacket) == 48, "tVehicleUpdatePacket: error"); + VALIDATE_SIZE(tVehicleUpdatePacket, 48); private: static uint8 Mode; diff --git a/src/control/SceneEdit.cpp b/src/control/SceneEdit.cpp index c8b4242e..54f4dd3a 100644 --- a/src/control/SceneEdit.cpp +++ b/src/control/SceneEdit.cpp @@ -68,7 +68,9 @@ static const char* pCommandStrings[] = { "Save Movie", "Load Movie", "Play Movie", "END" }; +#ifdef CHECK_STRUCT_SIZES static_assert(ARRAY_SIZE(pCommandStrings) == CSceneEdit::MOVIE_TOTAL_COMMANDS, "Scene edit: not all commands have names"); +#endif static int32 NextValidModelId(int32 mi, int32 step) { diff --git a/src/control/Script.cpp b/src/control/Script.cpp index a274c289..df3a489a 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -11205,7 +11205,9 @@ INITSAVEBUF WriteSaveBuf(buf, varSpace); for (uint32 i = 0; i < varSpace; i++) WriteSaveBuf(buf, ScriptSpace[i]); +#ifdef CHECK_STRUCT_SIZES static_assert(SCRIPT_DATA_SIZE == 968, "CTheScripts::SaveAllScripts"); +#endif uint32 script_data_size = SCRIPT_DATA_SIZE; WriteSaveBuf(buf, script_data_size); WriteSaveBuf(buf, OnAMissionFlag); @@ -11631,12 +11633,16 @@ void CRunningScript::Save(uint8*& buf) for (int i = 0; i < 8; i++) WriteSaveBuf(buf, m_abScriptName[i]); WriteSaveBuf(buf, m_nIp); +#ifdef CHECK_STRUCT_SIZES static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6"); +#endif for (int i = 0; i < MAX_STACK_DEPTH; i++) WriteSaveBuf(buf, m_anStack[i]); WriteSaveBuf(buf, m_nStackPointer); SkipSaveBuf(buf, 2); +#ifdef CHECK_STRUCT_SIZES static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18"); +#endif for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++) WriteSaveBuf(buf, m_anLocalVariables[i]); WriteSaveBuf(buf, m_bCondResult); @@ -11662,12 +11668,16 @@ void CRunningScript::Load(uint8*& buf) for (int i = 0; i < 8; i++) m_abScriptName[i] = ReadSaveBuf(buf); m_nIp = ReadSaveBuf(buf); +#ifdef CHECK_STRUCT_SIZES static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6"); +#endif for (int i = 0; i < MAX_STACK_DEPTH; i++) m_anStack[i] = ReadSaveBuf(buf); m_nStackPointer = ReadSaveBuf(buf); SkipSaveBuf(buf, 2); +#ifdef CHECK_STRUCT_SIZES static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18"); +#endif for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++) m_anLocalVariables[i] = ReadSaveBuf(buf); m_bCondResult = ReadSaveBuf(buf); diff --git a/src/control/Script.h b/src/control/Script.h index 01cad269..acab66cc 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -27,7 +27,7 @@ struct intro_script_rectangle ~intro_script_rectangle() { } }; -static_assert(sizeof(intro_script_rectangle) == 0x18, "Script.h: error"); +VALIDATE_SIZE(intro_script_rectangle, 0x18); enum { SCRIPT_TEXT_MAX_LENGTH = 500 @@ -78,7 +78,7 @@ struct intro_text_line } }; -static_assert(sizeof(intro_text_line) == 0x414, "Script.h: error"); +VALIDATE_SIZE(intro_text_line, 0x414); struct script_sphere_struct { -- cgit v1.2.3