diff options
author | Nikolay Korolev <nickvnuk@gmail.com> | 2020-03-01 15:44:37 +0100 |
---|---|---|
committer | Nikolay Korolev <nickvnuk@gmail.com> | 2020-03-01 15:44:37 +0100 |
commit | 90ff2f73ebecc460d84a7ee43baf4174c86f847f (patch) | |
tree | 12f4fb4b4f71c5cf32c9fc8bc3f8cc1aa38b7e33 /src/control/Script.h | |
parent | save/load (diff) | |
parent | review fixes (diff) | |
download | re3-90ff2f73ebecc460d84a7ee43baf4174c86f847f.tar re3-90ff2f73ebecc460d84a7ee43baf4174c86f847f.tar.gz re3-90ff2f73ebecc460d84a7ee43baf4174c86f847f.tar.bz2 re3-90ff2f73ebecc460d84a7ee43baf4174c86f847f.tar.lz re3-90ff2f73ebecc460d84a7ee43baf4174c86f847f.tar.xz re3-90ff2f73ebecc460d84a7ee43baf4174c86f847f.tar.zst re3-90ff2f73ebecc460d84a7ee43baf4174c86f847f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/control/Script.h | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/src/control/Script.h b/src/control/Script.h index 5f3175f0..b6844b6c 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -292,11 +292,43 @@ public: static bool IsDebugOn() { return DbgFlag; }; static void InvertDebugFlag() { DbgFlag = !DbgFlag; } - static int32* GetPointerToScriptVariable(int32 offset) { return (int32*)&ScriptSpace[offset]; } + static int32* GetPointerToScriptVariable(int32 offset) { assert(offset >= 8 && offset < CTheScripts::GetSizeOfVariableSpace()); return (int32*)&ScriptSpace[offset]; } static void ResetCountdownToMakePlayerUnsafe() { CountdownToMakePlayerUnsafe = 0; } static bool IsCountdownToMakePlayerUnsafeOn() { return CountdownToMakePlayerUnsafe != 0; } + static int32 Read4BytesFromScript(uint32* pIp) { + int32 retval = ScriptSpace[*pIp + 3] << 24 | ScriptSpace[*pIp + 2] << 16 | ScriptSpace[*pIp + 1] << 8 | ScriptSpace[*pIp]; + *pIp += 4; + return retval; + } + static int16 Read2BytesFromScript(uint32* pIp) { + int16 retval = ScriptSpace[*pIp + 1] << 8 | ScriptSpace[*pIp]; + *pIp += 2; + return retval; + } + static int8 Read1ByteFromScript(uint32* pIp) { + int8 retval = ScriptSpace[*pIp]; + *pIp += 1; + return retval; + } + static float ReadFloatFromScript(uint32* pIp) { + return Read2BytesFromScript(pIp) / 16.0f; + } + static void ReadTextLabelFromScript(uint32* pIp, char* buf) { + strncpy(buf, (const char*)&CTheScripts::ScriptSpace[*pIp], KEY_LENGTH_IN_SCRIPT); + } + static wchar* GetTextByKeyFromScript(uint32* pIp) { + wchar* text = TheText.Get((const char*)&CTheScripts::ScriptSpace[*pIp]); + *pIp += KEY_LENGTH_IN_SCRIPT; + return text; + } + static int32 GetSizeOfVariableSpace() + { + uint32 tmp = 3; + return Read4BytesFromScript(&tmp); + } + private: static CRunningScript* StartNewScript(uint32); @@ -395,39 +427,6 @@ public: m_anLocalVariables[NUM_LOCAL_VARS + 1] += timeStep; } - static int32 Read4BytesFromScript(uint32* pIp) { - int32 retval = 0; - for (int i = 0; i < 4; i++) { - retval |= CTheScripts::ScriptSpace[(*pIp)++] << (8 * i); - } - return retval; - } - static int16 Read2BytesFromScript(uint32* pIp) { - int16 retval = 0; - for (int i = 0; i < 2; i++) { - retval |= CTheScripts::ScriptSpace[(*pIp)++] << (8 * i); - } - return retval; - } - static int8 Read1ByteFromScript(uint32* pIp) { - int8 retval = 0; - for (int i = 0; i < 1; i++) { - retval |= CTheScripts::ScriptSpace[(*pIp)++] << (8 * i); - } - return retval; - } - static float ReadFloatFromScript(uint32* pIp) { - return Read2BytesFromScript(pIp) / 16.0f; - } - static void ReadTextLabelFromScript(uint32* pIp, char* buf) { - strncpy(buf, (const char*)&CTheScripts::ScriptSpace[*pIp], KEY_LENGTH_IN_SCRIPT); - } - static wchar* GetTextByKeyFromScript(uint32* pIp) { - wchar* text = TheText.Get((const char*)&CTheScripts::ScriptSpace[*pIp]); - *pIp += KEY_LENGTH_IN_SCRIPT; - return text; - } - void Init(); void Process(); |