diff options
author | Sergeanur <s.anureev@yandex.ua> | 2019-10-21 00:08:26 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2019-10-21 00:11:47 +0200 |
commit | e35780df43d5bd17f1e2a6ae731a63d034d1c5c4 (patch) | |
tree | 3c5fdc960e7e7db354ae15ef55f74f810c7a3a61 | |
parent | Full CPager (diff) | |
download | re3-e35780df43d5bd17f1e2a6ae731a63d034d1c5c4.tar re3-e35780df43d5bd17f1e2a6ae731a63d034d1c5c4.tar.gz re3-e35780df43d5bd17f1e2a6ae731a63d034d1c5c4.tar.bz2 re3-e35780df43d5bd17f1e2a6ae731a63d034d1c5c4.tar.lz re3-e35780df43d5bd17f1e2a6ae731a63d034d1c5c4.tar.xz re3-e35780df43d5bd17f1e2a6ae731a63d034d1c5c4.tar.zst re3-e35780df43d5bd17f1e2a6ae731a63d034d1c5c4.zip |
Diffstat (limited to '')
-rw-r--r-- | src/control/Script.cpp | 12 | ||||
-rw-r--r-- | src/core/ControllerConfig.cpp | 1 | ||||
-rw-r--r-- | src/core/ControllerConfig.h | 62 | ||||
-rw-r--r-- | src/text/Messages.cpp | 863 | ||||
-rw-r--r-- | src/text/Messages.h | 58 | ||||
-rw-r--r-- | src/text/Pager.cpp | 18 | ||||
-rw-r--r-- | src/text/Pager.h | 7 |
7 files changed, 950 insertions, 71 deletions
diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 777acb12..ced06f1e 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -662,12 +662,12 @@ void CRunningScript::Process() if (!CPad::GetPad(0)->GetCrossJustDown()) return; m_nWakeTime = 0; - for (int i = 0; i < 6; i++){ /* TODO: add constant for number of messages */ - if (CMessages::BIGMessages[i].m_Current.m_pText) - CMessages::BIGMessages[i].m_Current.m_nStartTime = 0; - if (CMessages::BriefMessages[0].m_pText) - CMessages::BriefMessages[0].m_nStartTime = 0; + for (int i = 0; i < NUMBIGMESSAGES; i++){ + if (CMessages::BIGMessages[i].m_Stack[0].m_pText != nil) + CMessages::BIGMessages[i].m_Stack[0].m_nStartTime = 0; } + if (CMessages::BriefMessages[0].m_pText != nil) + CMessages::BriefMessages[0].m_nStartTime = 0; } int8 CRunningScript::ProcessOneCommand() @@ -2183,7 +2183,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command) wchar* key = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); m_nIp += 8; CollectParameters(&m_nIp, 2); - CMessages::AddMessage(key, ScriptParams[0], ScriptParams[1]); + CMessages::AddMessageSoon(key, ScriptParams[0], ScriptParams[1]); return 0; } case COMMAND_CLEAR_PRINTS: diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index e3a586b2..6eef4d3d 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -22,6 +22,7 @@ WRAPPER void CControllerConfigManager::ClearSimButtonPressCheckers() { EAXJMP(0x WRAPPER void CControllerConfigManager::AffectPadFromKeyBoard() { EAXJMP(0x58D0C0); } WRAPPER void CControllerConfigManager::AffectPadFromMouse() { EAXJMP(0x58D1A0); } WRAPPER void CControllerConfigManager::ClearSettingsAssociatedWithAction(int, int) { EAXJMP(0x58EB40); } +WRAPPER void CControllerConfigManager::GetWideStringOfCommandKeys(uint16, wchar*, uint16) { EAXJMP(0x58F460); } void CControllerConfigManager::LoadSettings(int32 file) { diff --git a/src/core/ControllerConfig.h b/src/core/ControllerConfig.h index b064a381..ab17577b 100644 --- a/src/core/ControllerConfig.h +++ b/src/core/ControllerConfig.h @@ -9,10 +9,64 @@ enum eControllerType OPTIONAL_EXTRA, MOUSE, JOYSTICK, + TOTAL_CONTROLLER_TYPES +}; + +enum e_ControllerAction
+{
+ PED_FIREWEAPON = 0,
+ PED_CYCLE_WEAPON_RIGHT,
+ PED_CYCLE_WEAPON_LEFT,
+ GO_FORWARD,
+ GO_BACK,
+ GO_LEFT,
+ GO_RIGHT,
+ PED_SNIPER_ZOOM_IN,
+ PED_SNIPER_ZOOM_OUT,
+ VEHICLE_ENTER_EXIT,
+ CAMERA_CHANGE_VIEW_ALL_SITUATIONS,
+ PED_JUMPING,
+ PED_SPRINT,
+ PED_LOOKBEHIND,
+ //PED_DUCK, // VC
+ //PED_ANSWER_PHONE, // VC
+ VEHICLE_ACCELERATE,
+ VEHICLE_BRAKE,
+ VEHICLE_CHANGE_RADIO_STATION,
+ VEHICLE_HORN,
+ TOGGLE_SUBMISSIONS,
+ VEHICLE_HANDBRAKE,
+ PED_1RST_PERSON_LOOK_LEFT,
+ PED_1RST_PERSON_LOOK_RIGHT,
+ VEHICLE_LOOKLEFT,
+ VEHICLE_LOOKRIGHT,
+ VEHICLE_LOOKBEHIND,
+ VEHICLE_TURRETLEFT,
+ VEHICLE_TURRETRIGHT,
+ VEHICLE_TURRETUP,
+ VEHICLE_TURRETDOWN,
+ PED_CYCLE_TARGET_LEFT,
+ PED_CYCLE_TARGET_RIGHT,
+ PED_CENTER_CAMERA_BEHIND_PLAYER,
+ PED_LOCK_TARGET,
+ NETWORK_TALK,
+ PED_1RST_PERSON_LOOK_UP,
+ PED_1RST_PERSON_LOOK_DOWN,
+
+ CONTROLLERACTION_36, // unk, unused?
+
+ TOGGLE_DPAD,
+ SWITCH_DEBUG_CAM_ON,
+ TAKE_SCREEN_SHOT,
+ SHOW_MOUSE_POINTER_TOGGLE,
+
+ TOTAL_CONTROL_ACTIONS
}; class CMouseControllerState; +#define ACTIONNAME_LENGTH 40 + class CControllerConfigManager { public: @@ -23,16 +77,13 @@ public: }; bool firstCapture; - char _pad0[3]; DIJOYSTATE2 m_OldState; DIJOYSTATE2 m_NewState; - wchar m_aActionNames[41][40]; + wchar m_aActionNames[TOTAL_CONTROL_ACTIONS][ACTIONNAME_LENGTH]; bool m_aButtonStates[17]; - char _pad1[3]; - tControllerConfigBind m_aSettings[41][4]; + tControllerConfigBind m_aSettings[TOTAL_CONTROL_ACTIONS][TOTAL_CONTROLLER_TYPES]; uint8 m_aSimCheckers[4][4]; bool m_bMouseAssociated; - char _pad2[3]; void UpdateJoyButtonState(int padnumber); void UpdateJoyInConfigMenus_ButtonDown(int button, int padnumber); @@ -52,6 +103,7 @@ public: void AffectPadFromMouse(); void ClearSettingsAssociatedWithAction(int, int); + void GetWideStringOfCommandKeys(uint16, wchar*, uint16); }; VALIDATE_SIZE(CControllerConfigManager, 0x143C); diff --git a/src/text/Messages.cpp b/src/text/Messages.cpp index 9b5342ac..83369b84 100644 --- a/src/text/Messages.cpp +++ b/src/text/Messages.cpp @@ -1,26 +1,845 @@ +#define DIRECTINPUT_VERSION 0x0800 +#include "dinput.h" + #include "common.h" #include "patcher.h" #include "Messages.h" +#include "RwHelper.h" +#include "Hud.h" +#include "User.h" +#include "Timer.h" +#include "Text.h" + +#include "ControllerConfig.h" + +tMessage(&CMessages::BriefMessages)[NUMBRIEFMESSAGES] = *(tMessage(*)[NUMBRIEFMESSAGES])*(uintptr*)0x8786E0; +tPreviousBrief(&CMessages::PreviousBriefs)[NUMPREVIOUSBRIEFS] = *(tPreviousBrief(*)[NUMPREVIOUSBRIEFS])*(uintptr*)0x713C08; +tBigMessage(&CMessages::BIGMessages)[NUMBIGMESSAGES] = *(tBigMessage(*)[NUMBIGMESSAGES])*(uintptr*)0x773628; + +void +CMessages::Init() +{
+ ClearMessages();
+
+ for (int32 i = 0; i < NUMPREVIOUSBRIEFS; i++) { + PreviousBriefs[i].m_pText = nil; + PreviousBriefs[i].m_pString = nil; + } +} + +uint16 +CMessages::GetWideStringLength(wchar *src) +{
+ uint16 length = 0;
+ while (*(src++)) length++;
+ return length; +} + +void +CMessages::WideStringCopy(wchar *dst, wchar *src, uint16 size) +{
+ int32 i = 0;
+ if (src) { + while (i < size - 1) {
+ if (!src[i]) break;
+ dst[i] = src[i];
+ i++;
+ } + } else { + while (i < size - 1)
+ dst[i++] = '\0'; + } + dst[i] = '\0'; +} -WRAPPER void CMessages::Display(void) { EAXJMP(0x529800); } -WRAPPER void CMessages::ClearAllMessagesDisplayedByGame(void) { EAXJMP(0x52B670); } -WRAPPER int CMessages::WideStringCopy(wchar* dst, wchar* src, unsigned short size) { EAXJMP(0x5294B0); } -WRAPPER char CMessages::WideStringCompare(wchar* str1, wchar* str2, unsigned short size) { EAXJMP(0x529510); } -WRAPPER void CMessages::InsertNumberInString(wchar* src, int n1, int n2, int n3, int n4, int n5, int n6, wchar* dst) { EAXJMP(0x52A1A0); } -WRAPPER void CMessages::InsertPlayerControlKeysInString(wchar* src) { EAXJMP(0x52A490); } -WRAPPER int CMessages::GetWideStringLength(wchar* src) { EAXJMP(0x529490); } -WRAPPER void CMessages::AddBigMessage(wchar* key, uint32 time, uint16 pos) { EAXJMP(0x529EB0); } -WRAPPER void CMessages::AddBigMessageWithNumber(wchar* key, uint32 time, uint16 pos, int n1, int n2, int n3, int n4, int n5, int n6) { EAXJMP(0x52AD10); } -WRAPPER void CMessages::AddBigMessageWithNumberQ(wchar* key, uint32 time, uint16 pos, int n1, int n2, int n3, int n4, int n5, int n6) { EAXJMP(0x52AE00); } -WRAPPER void CMessages::AddMessage(wchar* key, uint32 time, uint16 pos) { EAXJMP(0x529900); } -WRAPPER void CMessages::AddMessageJumpQ(wchar* key, uint32 time, uint16 pos) { EAXJMP(0x529A10); } -WRAPPER void CMessages::AddMessageSoon(wchar* key, uint32 time, uint16 pos) { EAXJMP(0x529AF0); } -WRAPPER void CMessages::AddMessageWithNumber(wchar* key, uint32 time, uint16 pos, int n1, int n2, int n3, int n4, int n5, int n6) { EAXJMP(0x52A850); } -WRAPPER void CMessages::AddMessageJumpQWithNumber(wchar* key, uint32 time, uint16 pos, int n1, int n2, int n3, int n4, int n5, int n6) { EAXJMP(0x52A9A0); } -WRAPPER void CMessages::AddMessageSoonWithNumber(wchar* key, uint32 time, uint16 pos, int n1, int n2, int n3, int n4, int n5, int n6) { EAXJMP(0x52AAC0); } -WRAPPER void CMessages::ClearMessages() { EAXJMP(0x529CE0); } -WRAPPER void CMessages::Init() { EAXJMP(0x529310); } -WRAPPER void CMessages::Process() { EAXJMP(0x529580); } -tPreviousBrief *CMessages::PreviousBriefs = (tPreviousBrief *)0x713C08; -tMessage *CMessages::BriefMessages = (tMessage *)0x8786E0; -tBigMessage *CMessages::BIGMessages = (tBigMessage *)0x773628; +bool
+CMessages::WideStringCompare(wchar *str1, wchar *str2, uint16 size)
+{
+ uint16 len1 = GetWideStringLength(str1);
+ uint16 len2 = GetWideStringLength(str2);
+ if (len1 != len2 && (len1 < size || len2 < size))
+ return false;
+
+ for (int32 i = 0; i < size; i++) {
+ if (!str1[i])
+ break;
+
+ if (str1[i] != str2[i])
+ return false;
+ }
+ return true;
+}
+
+void
+CMessages::Process()
+{
+ for (int32 style = 0; style < 6; style++) {
+ if (BIGMessages[style].m_Stack[0].m_pText != nil && CTimer::GetTimeInMilliseconds() > BIGMessages[style].m_Stack[0].m_nTime + BIGMessages[style].m_Stack[0].m_nStartTime) {
+ BIGMessages[style].m_Stack[0].m_pText = nil;
+
+ int32 i = 0;
+ while (i < 3) {
+ if (BIGMessages[style].m_Stack[i + 1].m_pText == nil) break;
+ BIGMessages[style].m_Stack[i] = BIGMessages[style].m_Stack[i + 1];
+ i++;
+ }
+
+ BIGMessages[style].m_Stack[i].m_pText = nil;
+ BIGMessages[style].m_Stack[0].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ }
+ }
+
+ if (BriefMessages[0].m_pText != nil && CTimer::GetTimeInMilliseconds() > BriefMessages[0].m_nTime + BriefMessages[0].m_nStartTime) {
+ BriefMessages[0].m_pText = nil;
+ int32 i = 0;
+ while (i < NUMBRIEFMESSAGES-1) {
+ if (BriefMessages[i + 1].m_pText == nil)
+ break;
+
+ BriefMessages[i] = BriefMessages[i + 1];
+ i++;
+ }
+ CMessages::BriefMessages[i].m_pText = nil;
+ CMessages::BriefMessages[0].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ if (BriefMessages[0].m_pText != nil)
+ AddToPreviousBriefArray(
+ BriefMessages[0].m_pText,
+ BriefMessages[0].m_nNumber[0],
+ BriefMessages[0].m_nNumber[1],
+ BriefMessages[0].m_nNumber[2],
+ BriefMessages[0].m_nNumber[3],
+ BriefMessages[0].m_nNumber[4],
+ BriefMessages[0].m_nNumber[5],
+ BriefMessages[0].m_pString);
+ }
+}
+
+void
+CMessages::Display()
+{
+ wchar outstr[260];
+
+ DefinedState();
+
+ for (int32 i = 0; i < NUMBIGMESSAGES; i++) {
+ InsertNumberInString(
+ BIGMessages[i].m_Stack[0].m_pText,
+ BIGMessages[i].m_Stack[0].m_nNumber[0],
+ BIGMessages[i].m_Stack[0].m_nNumber[1],
+ BIGMessages[i].m_Stack[0].m_nNumber[2],
+ BIGMessages[i].m_Stack[0].m_nNumber[3],
+ BIGMessages[i].m_Stack[0].m_nNumber[4],
+ BIGMessages[i].m_Stack[0].m_nNumber[5],
+ outstr);
+ InsertStringInString(outstr, BIGMessages[i].m_Stack[0].m_pString);
+ InsertPlayerControlKeysInString(outstr);
+ CHud::SetBigMessage(outstr, i);
+ }
+
+ InsertNumberInString(
+ BriefMessages[0].m_pText,
+ BriefMessages[0].m_nNumber[0],
+ BriefMessages[0].m_nNumber[1],
+ BriefMessages[0].m_nNumber[2],
+ BriefMessages[0].m_nNumber[3],
+ BriefMessages[0].m_nNumber[4],
+ BriefMessages[0].m_nNumber[5],
+ outstr);
+ InsertStringInString(outstr, BriefMessages[0].m_pString);
+ InsertPlayerControlKeysInString(outstr);
+ CHud::SetMessage(outstr);
+}
+
+void
+CMessages::AddMessage(wchar *msg, uint32 time, uint16 flag)
+{
+ wchar outstr[514];
+
+ WideStringCopy(outstr, msg, 256);
+ InsertPlayerControlKeysInString(outstr);
+ GetWideStringLength(outstr); // unused, was assert?
+
+ int32 i = 0;
+ while (i < NUMBRIEFMESSAGES && BriefMessages[i].m_pText != nil)
+ i++;
+ if (i >= NUMBRIEFMESSAGES) return;
+
+ BriefMessages[i].m_pText = msg;
+ BriefMessages[i].m_nFlag = flag;
+ BriefMessages[i].m_nTime = time;
+ BriefMessages[i].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BriefMessages[i].m_nNumber[0] = -1;
+ BriefMessages[i].m_nNumber[1] = -1;
+ BriefMessages[i].m_nNumber[2] = -1;
+ BriefMessages[i].m_nNumber[3] = -1;
+ BriefMessages[i].m_nNumber[4] = -1;
+ BriefMessages[i].m_nNumber[5] = -1;
+ BriefMessages[i].m_pString = nil;
+ if (i == 0)
+ AddToPreviousBriefArray(
+ BriefMessages[0].m_pText,
+ BriefMessages[0].m_nNumber[0],
+ BriefMessages[0].m_nNumber[1],
+ BriefMessages[0].m_nNumber[2],
+ BriefMessages[0].m_nNumber[3],
+ BriefMessages[0].m_nNumber[4],
+ BriefMessages[0].m_nNumber[5],
+ BriefMessages[0].m_pString);
+}
+
+void
+CMessages::AddMessageJumpQ(wchar *msg, uint32 time, uint16 flag)
+{
+ wchar outstr[514];
+
+ WideStringCopy(outstr, msg, 256);
+ InsertPlayerControlKeysInString(outstr);
+ GetWideStringLength(outstr); // unused, was assert?
+
+ BriefMessages[0].m_pText = msg;
+ BriefMessages[0].m_nFlag = flag;
+ BriefMessages[0].m_nTime = time;
+ BriefMessages[0].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BriefMessages[0].m_nNumber[0] = -1;
+ BriefMessages[0].m_nNumber[1] = -1;
+ BriefMessages[0].m_nNumber[2] = -1;
+ BriefMessages[0].m_nNumber[3] = -1;
+ BriefMessages[0].m_nNumber[4] = -1;
+ BriefMessages[0].m_nNumber[5] = -1;
+ BriefMessages[0].m_pString = nil;
+ AddToPreviousBriefArray(msg, -1, -1, -1, -1, -1, -1, 0);
+}
+
+void
+CMessages::AddMessageSoon(wchar *msg, uint32 time, uint16 flag)
+{
+ wchar outstr[520];
+
+ WideStringCopy(outstr, msg, 256);
+ InsertPlayerControlKeysInString(outstr);
+ GetWideStringLength(outstr); // unused, was assert?
+ if (BriefMessages[0].m_pText != nil) {
+ for (int i = NUMBRIEFMESSAGES-1; i > 1; i--)
+ BriefMessages[i] = BriefMessages[i-1];
+
+ BriefMessages[1].m_pText = msg;
+ BriefMessages[1].m_nFlag = flag;
+ BriefMessages[1].m_nTime = time;
+ BriefMessages[1].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BriefMessages[1].m_nNumber[0] = -1;
+ BriefMessages[1].m_nNumber[1] = -1;
+ BriefMessages[1].m_nNumber[2] = -1;
+ BriefMessages[1].m_nNumber[3] = -1;
+ BriefMessages[1].m_nNumber[4] = -1;
+ BriefMessages[1].m_nNumber[5] = -1;
+ BriefMessages[1].m_pString = nil;
+ }else{
+ BriefMessages[0].m_pText = msg;
+ BriefMessages[0].m_nFlag = flag;
+ BriefMessages[0].m_nTime = time;
+ BriefMessages[0].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BriefMessages[0].m_nNumber[0] = -1;
+ BriefMessages[0].m_nNumber[1] = -1;
+ BriefMessages[0].m_nNumber[2] = -1;
+ BriefMessages[0].m_nNumber[3] = -1;
+ BriefMessages[0].m_nNumber[4] = -1;
+ BriefMessages[0].m_nNumber[5] = -1;
+ BriefMessages[0].m_pString = nil;
+ AddToPreviousBriefArray(msg, -1, -1, -1, -1, -1, -1, nil);
+ }
+}
+
+void
+CMessages::ClearMessages()
+{
+ for (int32 i = 0; i < NUMBIGMESSAGES; i++) { + for (int32 j = 0; j < 4; j++) { + BIGMessages[i].m_Stack[j].m_pText = nil; + BIGMessages[i].m_Stack[j].m_pString = nil; + } + }
+ ClearSmallMessagesOnly();
+}
+
+void
+CMessages::ClearSmallMessagesOnly()
+{
+ for (int32 i = 0; i < NUMBRIEFMESSAGES; i++) {
+ BriefMessages[i].m_pText = nil;
+ BriefMessages[i].m_pString = nil;
+ }
+}
+
+void
+CMessages::AddBigMessage(wchar *msg, uint32 time, uint16 style)
+{
+ wchar outstr[514];
+
+ WideStringCopy(outstr, msg, 256);
+ InsertPlayerControlKeysInString(outstr);
+ GetWideStringLength(outstr); // unused, was assert?
+ BIGMessages[style].m_Stack[0].m_pText = msg;
+ BIGMessages[style].m_Stack[0].m_nFlag = 0;
+ BIGMessages[style].m_Stack[0].m_nTime = time;
+ BIGMessages[style].m_Stack[0].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BIGMessages[style].m_Stack[0].m_nNumber[0] = -1;
+ BIGMessages[style].m_Stack[0].m_nNumber[1] = -1;
+ BIGMessages[style].m_Stack[0].m_nNumber[2] = -1;
+ BIGMessages[style].m_Stack[0].m_nNumber[3] = -1;
+ BIGMessages[style].m_Stack[0].m_nNumber[4] = -1;
+ BIGMessages[style].m_Stack[0].m_nNumber[5] = -1;
+ BIGMessages[style].m_Stack[0].m_pString = nil;
+}
+void
+CMessages::AddBigMessageQ(wchar *msg, uint32 time, uint16 style)
+{
+ wchar outstr[518];
+
+ WideStringCopy(outstr, msg, 256);
+ InsertPlayerControlKeysInString(outstr);
+ GetWideStringLength(outstr); // unused, was assert?
+ int32 i = 0;
+ while (i < 4 && BIGMessages[style].m_Stack[i].m_pText != nil)
+ i++;
+
+ if (i >= 4) return;
+
+ BIGMessages[style].m_Stack[i].m_pText = msg;
+ BIGMessages[style].m_Stack[i].m_nFlag = 0;
+ BIGMessages[style].m_Stack[i].m_nTime = time;
+ BIGMessages[style].m_Stack[i].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BIGMessages[style].m_Stack[i].m_nNumber[0] = -1;
+ BIGMessages[style].m_Stack[i].m_nNumber[1] = -1;
+ BIGMessages[style].m_Stack[i].m_nNumber[2] = -1;
+ BIGMessages[style].m_Stack[i].m_nNumber[3] = -1;
+ BIGMessages[style].m_Stack[i].m_nNumber[4] = -1;
+ BIGMessages[style].m_Stack[i].m_nNumber[5] = -1;
+ BIGMessages[style].m_Stack[i].m_pString = nil;
+}
+
+void
+CMessages::AddToPreviousBriefArray(wchar *text, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6, wchar *string)
+{
+ int32 i = 0;
+ while (i < NUMPREVIOUSBRIEFS) {
+ if (PreviousBriefs[i].m_pText == nil)
+ break;
+ if (PreviousBriefs[i].m_nNumber[0] == n1
+ && PreviousBriefs[i].m_nNumber[1] == n2
+ && PreviousBriefs[i].m_nNumber[2] == n3
+ && PreviousBriefs[i].m_nNumber[3] == n4
+ && PreviousBriefs[i].m_nNumber[4] == n5
+ && PreviousBriefs[i].m_nNumber[5] == n6
+ && PreviousBriefs[i].m_pText == text
+ && PreviousBriefs[i].m_pString == string)
+ return;
+
+ i++;
+ }
+
+ if (i != 0) {
+ if (i == NUMPREVIOUSBRIEFS) i -= 2;
+ else i--;
+
+ while (i >= 0) {
+ PreviousBriefs[i + 1] = PreviousBriefs[i];
+ i--;
+ }
+ }
+ PreviousBriefs[0].m_pText = text;
+ PreviousBriefs[0].m_nNumber[0] = n1;
+ PreviousBriefs[0].m_nNumber[1] = n2;
+ PreviousBriefs[0].m_nNumber[2] = n3;
+ PreviousBriefs[0].m_nNumber[3] = n4;
+ PreviousBriefs[0].m_nNumber[4] = n5;
+ PreviousBriefs[0].m_nNumber[5] = n6;
+ PreviousBriefs[0].m_pString = string;
+}
+
+void
+CMessages::InsertNumberInString(wchar *str, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6, wchar *outstr)
+{
+ char numStr[12];
+ wchar wNumStr[18];
+
+ if (str == nil) {
+ *outstr = '\0';
+ return;
+ }
+
+ int32 size = GetWideStringLength(str);
+
+ int32 i = 0;
+
+ for (int32 c = 0; c < size;) {
+ if (str[c] == '~' && str[c + 1] == '1' && str[c + 2] == '~') {
+ switch (i) {
+ case 0: sprintf(numStr, "%d", n1); break;
+ case 1: sprintf(numStr, "%d", n2); break;
+ case 2: sprintf(numStr, "%d", n3); break;
+ case 3: sprintf(numStr, "%d", n4); break;
+ case 4: sprintf(numStr, "%d", n5); break;
+ case 5: sprintf(numStr, "%d", n6); break;
+ }
+ i++;
+ AsciiToUnicode(numStr, wNumStr);
+
+ int j = 0;
+ while (wNumStr[j] != '\0')
+ *(outstr++) = wNumStr[j++];
+
+ c += 3;
+ } else {
+ *(outstr++) = str[c++];
+ }
+ }
+ *outstr = '\0';
+}
+
+void
+CMessages::InsertStringInString(wchar *str1, wchar *str2)
+{
+ wchar tempstr[264];
+
+ if (!str1 || !str2) return;
+
+ int32 str1_size = GetWideStringLength(str1);
+ int32 str2_size = GetWideStringLength(str2);
+ int32 total_size = str1_size + str2_size;
+
+ wchar *_str1 = str1;
+ uint16 i;
+ for (i = 0; i < total_size; ) {
+ if (_str1[0] == '~' && _str1[1] == 'a' && _str1[1] == '~') {
+ _str1 += 3;
+ for (int j = 0; j < str2_size; j++) {
+ tempstr[i++] = str2[j];
+ }
+ } else {
+ tempstr[i++] = *(_str1++);
+ }
+ }
+ tempstr[i] = '\0';
+
+ for (i = 0; i < total_size; i++)
+ str1[i] = tempstr[i];
+
+ while (i < 256)
+ str1[i++] = '\0';
+}
+
+void
+CMessages::InsertPlayerControlKeysInString(wchar *str)
+{
+ uint16 i;
+ wchar outstr[256];
+ wchar keybuf[264];
+
+ if (!str) return;
+ uint16 strSize = CMessages::GetWideStringLength(str);
+ memset(keybuf, 0, 256*sizeof(wchar));
+
+ wchar *_outstr = outstr;
+ for (i = 0; i < strSize;) {
+ if (str[i] == '~' && str[i + 1] == 'k' && str[i + 2] == '~') {
+ i += 4;
+ for (int32 cont = 0; cont < TOTAL_CONTROL_ACTIONS; cont++) {
+ uint16 contSize = GetWideStringLength(ControlsManager.m_aActionNames[cont]);
+ if (contSize != 0) {
+ if (WideStringCompare(&str[i], ControlsManager.m_aActionNames[cont], contSize)) {
+ ControlsManager.GetWideStringOfCommandKeys(cont, keybuf, 256);
+ uint16 keybuf_size = GetWideStringLength(keybuf);
+ for (uint16 j = 0; j < keybuf_size; j++) {
+ *(_outstr++) = keybuf[j];
+ keybuf[j] = '\0';
+ }
+ i += contSize + 1;
+ }
+ }
+ }
+ } else {
+ *(_outstr++) = str[i++];
+ }
+ }
+ *_outstr = '\0';
+
+ for (i = 0; i < CMessages::GetWideStringLength(outstr); i++)
+ str[i] = outstr[i];
+
+ while (i < 256)
+ str[i++] = '\0';
+}
+
+void
+CMessages::AddMessageWithNumber(wchar *str, uint32 time, uint16 flag, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6)
+{
+ wchar outstr[520];
+
+ InsertNumberInString(str, n1, n2, n3, n4, n5, n6, outstr);
+ InsertPlayerControlKeysInString(outstr);
+ GetWideStringLength(outstr); // unused
+
+ uint16 i = 0;
+ while (i < NUMBRIEFMESSAGES && BriefMessages[i].m_pText)
+ i++;
+
+ if (i >= NUMBRIEFMESSAGES) return;
+
+ BriefMessages[i].m_pText = str;
+ BriefMessages[i].m_nFlag = flag;
+ BriefMessages[i].m_nTime = time;
+ BriefMessages[i].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BriefMessages[i].m_nNumber[0] = n1;
+ BriefMessages[i].m_nNumber[1] = n2;
+ BriefMessages[i].m_nNumber[2] = n3;
+ BriefMessages[i].m_nNumber[3] = n4;
+ BriefMessages[i].m_nNumber[4] = n5;
+ BriefMessages[i].m_nNumber[5] = n6;
+ BriefMessages[i].m_pString = nil;
+ if (i == 0)
+ AddToPreviousBriefArray(
+ BriefMessages[0].m_pText,
+ BriefMessages[0].m_nNumber[0],
+ BriefMessages[0].m_nNumber[1],
+ BriefMessages[0].m_nNumber[2],
+ BriefMessages[0].m_nNumber[3],
+ BriefMessages[0].m_nNumber[4],
+ BriefMessages[0].m_nNumber[5],
+ BriefMessages[0].m_pString);
+}
+
+void
+CMessages::AddMessageJumpQWithNumber(wchar *str, uint32 time, uint16 flag, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6)
+{
+ wchar outstr[520];
+
+ InsertNumberInString(str, n1, n2, n3, n4, n5, n6, outstr);
+ InsertPlayerControlKeysInString(outstr);
+ GetWideStringLength(outstr);
+ BriefMessages[0].m_pText = str;
+ BriefMessages[0].m_nFlag = flag;
+ BriefMessages[0].m_nTime = time;
+ BriefMessages[0].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BriefMessages[0].m_nNumber[0] = n1;
+ BriefMessages[0].m_nNumber[1] = n2;
+ BriefMessages[0].m_nNumber[2] = n3;
+ BriefMessages[0].m_nNumber[3] = n4;
+ BriefMessages[0].m_nNumber[4] = n5;
+ BriefMessages[0].m_nNumber[5] = n6;
+ BriefMessages[0].m_pString = nil;
+ AddToPreviousBriefArray(str, n1, n2, n3, n4, n5, n6, nil);
+}
+
+void
+CMessages::AddMessageSoonWithNumber(wchar *str, uint32 time, uint16 flag, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6)
+{
+ wchar outstr[520]; // is unused, bug?
+
+ InsertNumberInString(str, n1, n2, n3, n4, n5, n6, outstr);
+ InsertPlayerControlKeysInString(outstr);
+ GetWideStringLength(outstr);
+ if (BriefMessages[0].m_pText != nil) {
+ for (int32 i = NUMBRIEFMESSAGES-1; i > 1; i--)
+ BriefMessages[i] = BriefMessages[i-1];
+
+ BriefMessages[1].m_pText = str;
+ BriefMessages[1].m_nFlag = flag;
+ BriefMessages[1].m_nTime = time;
+ BriefMessages[1].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BriefMessages[1].m_nNumber[0] = n1;
+ BriefMessages[1].m_nNumber[1] = n2;
+ BriefMessages[1].m_nNumber[2] = n3;
+ BriefMessages[1].m_nNumber[3] = n4;
+ BriefMessages[1].m_nNumber[4] = n5;
+ BriefMessages[1].m_nNumber[5] = n6;
+ BriefMessages[1].m_pString = nil;
+ } else {
+ BriefMessages[0].m_pText = str;
+ BriefMessages[0].m_nFlag = flag;
+ BriefMessages[0].m_nTime = time;
+ BriefMessages[0].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BriefMessages[0].m_nNumber[0] = n1;
+ BriefMessages[0].m_nNumber[1] = n2;
+ BriefMessages[0].m_nNumber[2] = n3;
+ BriefMessages[0].m_nNumber[3] = n4;
+ BriefMessages[0].m_nNumber[4] = n5;
+ BriefMessages[0].m_nNumber[5] = n6;
+ BriefMessages[0].m_pString = nil;
+ AddToPreviousBriefArray(str, n1, n2, n3, n4, n5, n6, nil);
+ }
+}
+
+void
+CMessages::AddBigMessageWithNumber(wchar *str, uint32 time, uint16 style, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6)
+{
+ wchar outstr[520]; // is unused, bug?
+
+ InsertNumberInString(str, n1, n2, n3, n4, n5, n6, outstr);
+ InsertPlayerControlKeysInString(outstr);
+ GetWideStringLength(outstr);
+ BIGMessages[style].m_Stack[0].m_pText = str;
+ BIGMessages[style].m_Stack[0].m_nFlag = 0;
+ BIGMessages[style].m_Stack[0].m_nTime = time;
+ BIGMessages[style].m_Stack[0].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BIGMessages[style].m_Stack[0].m_nNumber[0] = n1;
+ BIGMessages[style].m_Stack[0].m_nNumber[1] = n2;
+ BIGMessages[style].m_Stack[0].m_nNumber[2] = n3;
+ BIGMessages[style].m_Stack[0].m_nNumber[3] = n4;
+ BIGMessages[style].m_Stack[0].m_nNumber[4] = n5;
+ BIGMessages[style].m_Stack[0].m_nNumber[5] = n6;
+ BIGMessages[style].m_Stack[0].m_pString = nil;
+}
+
+void
+CMessages::AddBigMessageWithNumberQ(wchar *str, uint32 time, uint16 style, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6)
+{
+ wchar outstr[520]; // is unused, bug?
+
+ CMessages::InsertNumberInString(str, n1, n2, n3, n4, n5, n6, outstr);
+ CMessages::InsertPlayerControlKeysInString(outstr);
+ CMessages::GetWideStringLength(outstr);
+ int32 i = 0;
+
+ while (i < 4 && CMessages::BIGMessages[style].m_Stack[i].m_pText)
+ i++;
+
+ if (i >= 4) return;
+
+ BIGMessages[style].m_Stack[i].m_pText = str;
+ BIGMessages[style].m_Stack[i].m_nFlag = 0;
+ BIGMessages[style].m_Stack[i].m_nTime = time;
+ BIGMessages[style].m_Stack[i].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BIGMessages[style].m_Stack[i].m_nNumber[0] = n1;
+ BIGMessages[style].m_Stack[i].m_nNumber[1] = n2;
+ BIGMessages[style].m_Stack[i].m_nNumber[2] = n3;
+ BIGMessages[style].m_Stack[i].m_nNumber[3] = n4;
+ BIGMessages[style].m_Stack[i].m_nNumber[4] = n5;
+ BIGMessages[style].m_Stack[i].m_nNumber[5] = n6;
+ BIGMessages[style].m_Stack[i].m_pString = nil;
+}
+
+void
+CMessages::AddMessageWithString(wchar *text, uint32 time, uint16 flag, wchar *str)
+{
+ wchar outstr[516]; // is unused, bug?
+
+ WideStringCopy(outstr, text, 256);
+ InsertStringInString(outstr, str);
+ InsertPlayerControlKeysInString(outstr);
+ GetWideStringLength(outstr);
+
+ int32 i = 0;
+ while (i < NUMBRIEFMESSAGES && BriefMessages[i].m_pText != nil)
+ i++;
+
+ if (i >= NUMBRIEFMESSAGES) return;
+
+ BriefMessages[i].m_pText = text;
+ BriefMessages[i].m_nFlag = flag;
+ BriefMessages[i].m_nTime = time;
+ BriefMessages[i].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BriefMessages[i].m_nNumber[0] = -1;
+ BriefMessages[i].m_nNumber[1] = -1;
+ BriefMessages[i].m_nNumber[2] = -1;
+ BriefMessages[i].m_nNumber[3] = -1;
+ BriefMessages[i].m_nNumber[4] = -1;
+ BriefMessages[i].m_nNumber[5] = -1;
+ BriefMessages[i].m_pString = str;
+ if (i == 0)
+ AddToPreviousBriefArray(
+ BriefMessages[0].m_pText,
+ BriefMessages[0].m_nNumber[0],
+ BriefMessages[0].m_nNumber[1],
+ BriefMessages[0].m_nNumber[2],
+ BriefMessages[0].m_nNumber[3],
+ BriefMessages[0].m_nNumber[4],
+ BriefMessages[0].m_nNumber[5],
+ BriefMessages[0].m_pString);
+}
+
+void
+CMessages::AddMessageJumpQWithString(wchar *text, uint32 time, uint16 flag, wchar *str)
+{
+ wchar outstr[516];
+
+ WideStringCopy(outstr, text, 256);
+ InsertStringInString(outstr, str);
+ InsertPlayerControlKeysInString(outstr);
+ GetWideStringLength(outstr);
+ BriefMessages[0].m_pText = text;
+ BriefMessages[0].m_nFlag = flag;
+ BriefMessages[0].m_nTime = time;
+ BriefMessages[0].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ BriefMessages[0].m_nNumber[0] = -1;
+ BriefMessages[0].m_nNumber[1] = -1;
+ BriefMessages[0].m_nNumber[2] = -1;
+ BriefMessages[0].m_nNumber[3] = -1;
+ BriefMessages[0].m_nNumber[4] = -1;
+ BriefMessages[0].m_nNumber[5] = -1;
+ BriefMessages[0].m_pString = str;
+ AddToPreviousBriefArray(text, -1, -1, -1, -1, -1, -1, str);
+}
+
+void
+CMessages::ClearThisPrint(wchar *str)
+{
+ bool equal;
+ wchar *v4;
+ wchar *v5;
+
+ do {
+ equal = false;
+ uint16 i = 0;
+ while (i < NUMBRIEFMESSAGES) {
+ if (BriefMessages[i].m_pText == nil)
+ break;
+
+ v4 = str;
+ v5 = BriefMessages[i].m_pText;
+ while (*v5 == *v4 && !equal) {
+ ++v4;
+ ++v5;
+ if (!*v4 && !*v5)
+ equal = true;
+ }
+
+ if (equal) break;
+ i++;
+ }
+
+ if (equal) {
+ if (i != 0) {
+ BriefMessages[i].m_pText = nil;
+ while (i < NUMBRIEFMESSAGES-1) {
+ if (BriefMessages[i + 1].m_pText == nil)
+ break;
+
+ BriefMessages[i] = BriefMessages[i + 1];
+ i++;
+ }
+ BriefMessages[i].m_pText = nil;
+ } else {
+ BriefMessages[0].m_pText = nil;
+ while (i < NUMBRIEFMESSAGES-1) {
+ if (BriefMessages[i + 1].m_pText == nil)
+ break;
+ BriefMessages[i] = BriefMessages[i + 1];
+ i++;
+ }
+ BriefMessages[i].m_pText = nil;
+ BriefMessages[0].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ if (BriefMessages[0].m_pText == nil)
+ AddToPreviousBriefArray(
+ BriefMessages[0].m_pText,
+ BriefMessages[0].m_nNumber[0],
+ BriefMessages[0].m_nNumber[1],
+ BriefMessages[0].m_nNumber[2],
+ BriefMessages[0].m_nNumber[3],
+ BriefMessages[0].m_nNumber[4],
+ BriefMessages[0].m_nNumber[5],
+ BriefMessages[0].m_pString);
+ }
+ }
+ } while (equal);
+}
+
+void
+CMessages::ClearThisBigPrint(wchar *str)
+{
+ bool equal;
+ wchar *v4;
+ wchar *v5;
+
+ do
+ {
+ uint16 i = 0;
+ equal = false;
+ uint16 style = 0;
+ while (style < NUMBIGMESSAGES)
+ {
+ if (i >= 4)
+ break;
+ if (CMessages::BIGMessages[style].m_Stack[i].m_pText == nil || equal)
+ break;
+
+ v5 = CMessages::BIGMessages[style].m_Stack[i].m_pText;
+ v4 = str;
+ while (*v5 == *v4 && !equal) {
+ ++v4;
+ ++v5;
+ if (!*v4 && !*v5)
+ equal = true;
+ }
+
+ if (!equal && ++i == 4) {
+ i = 0;
+ style++;
+ }
+ }
+ if (equal) {
+ if (i != 0) {
+ BIGMessages[style].m_Stack[i].m_pText = nil;
+ while (i < 3) {
+ if (BIGMessages[style].m_Stack[i + 1].m_pText == nil)
+ break;
+ BIGMessages[style].m_Stack[i] = BIGMessages[style].m_Stack[i + 1];
+ i++;
+ }
+ BIGMessages[style].m_Stack[i].m_pText = nil;
+ } else {
+ BIGMessages[style].m_Stack[0].m_pText = 0;
+ i = 0;
+ while (i < 3) {
+ if (BIGMessages[style].m_Stack[i + 1].m_pText == nil)
+ break;
+ BIGMessages[style].m_Stack[i] = BIGMessages[style].m_Stack[i + 1];
+ i++;
+ }
+ BIGMessages[style].m_Stack[i].m_pText = nil;
+ BIGMessages[style].m_Stack[0].m_nStartTime = CTimer::GetTimeInMilliseconds();
+ }
+ }
+ } while (equal);
+}
+
+void
+CMessages::ClearAllMessagesDisplayedByGame()
+{
+ ClearMessages();
+ for (int32 i = 0; i < NUMPREVIOUSBRIEFS; i++) {
+ PreviousBriefs[i].m_pText = nil;
+ PreviousBriefs[i].m_pString = nil;
+ }
+ CHud::GetRidOfAllHudMessages();
+ CUserDisplay::Pager.ClearMessages();
+}
+
+STARTPATCHES
+ InjectHook(0x529310, CMessages::Init, PATCH_JUMP);
+ InjectHook(0x529490, CMessages::GetWideStringLength, PATCH_JUMP);
+ InjectHook(0x5294B0, CMessages::WideStringCopy, PATCH_JUMP);
+ InjectHook(0x529510, CMessages::WideStringCompare, PATCH_JUMP);
+ InjectHook(0x529580, CMessages::Process, PATCH_JUMP);
+ InjectHook(0x529800, CMessages::Display, PATCH_JUMP);
+ InjectHook(0x529900, CMessages::AddMessage, PATCH_JUMP);
+ InjectHook(0x529A10, CMessages::AddMessageJumpQ, PATCH_JUMP);
+ InjectHook(0x529AF0, CMessages::AddMessageSoon, PATCH_JUMP);
+ InjectHook(0x529CE0, CMessages::ClearMessages, PATCH_JUMP);
+ InjectHook(0x529E00, CMessages::ClearSmallMessagesOnly, PATCH_JUMP);
+ InjectHook(0x529EB0, CMessages::AddBigMessage, PATCH_JUMP);
+ InjectHook(0x529F60, CMessages::AddBigMessageQ, PATCH_JUMP);
+ InjectHook(0x52A040, CMessages::AddToPreviousBriefArray, PATCH_JUMP);
+ InjectHook(0x52A1A0, CMessages::InsertNumberInString, PATCH_JUMP);
+ InjectHook(0x52A300, CMessages::InsertStringInString, PATCH_JUMP);
+ InjectHook(0x52A490, CMessages::InsertPlayerControlKeysInString, PATCH_JUMP);
+ InjectHook(0x52A850, CMessages::AddMessageWithNumber, PATCH_JUMP);
+ InjectHook(0x52A9A0, CMessages::AddMessageJumpQWithNumber, PATCH_JUMP);
+ InjectHook(0x52AAC0, CMessages::AddMessageSoonWithNumber, PATCH_JUMP);
+ InjectHook(0x52AD10, CMessages::AddBigMessageWithNumber, PATCH_JUMP);
+ InjectHook(0x52AE00, CMessages::AddBigMessageWithNumberQ, PATCH_JUMP);
+ InjectHook(0x52AF30, CMessages::AddMessageWithString, PATCH_JUMP);
+ InjectHook(0x52B050, CMessages::AddMessageJumpQWithString, PATCH_JUMP);
+ InjectHook(0x52B140, CMessages::ClearThisPrint, PATCH_JUMP);
+ InjectHook(0x52B3C0, CMessages::ClearThisBigPrint, PATCH_JUMP);
+ InjectHook(0x52B670, CMessages::ClearAllMessagesDisplayedByGame, PATCH_JUMP);
+ENDPATCHES
\ No newline at end of file diff --git a/src/text/Messages.h b/src/text/Messages.h index 7caf5786..fac2c2af 100644 --- a/src/text/Messages.h +++ b/src/text/Messages.h @@ -4,9 +4,6 @@ struct tMessage { wchar *m_pText; uint16 m_nFlag; -private: - int8 _pad6[2]; -public: uint32 m_nTime; uint32 m_nStartTime; int32 m_nNumber[6]; @@ -15,8 +12,7 @@ public: struct tBigMessage { - tMessage m_Current; - tMessage m_Stack[3]; + tMessage m_Stack[4]; }; struct tPreviousBrief @@ -26,31 +22,43 @@ struct tPreviousBrief wchar *m_pString; }; +#define NUMBRIEFMESSAGES 8 +#define NUMBIGMESSAGES 6 +#define NUMPREVIOUSBRIEFS 5 + class CMessages { public: - static tPreviousBrief *PreviousBriefs; - static tMessage *BriefMessages; - static tBigMessage *BIGMessages; + static tMessage(&BriefMessages)[NUMBRIEFMESSAGES]; + static tBigMessage(&BIGMessages)[NUMBIGMESSAGES]; + static tPreviousBrief(&PreviousBriefs)[NUMPREVIOUSBRIEFS]; public: + static void Init(void); + static uint16 GetWideStringLength(wchar *src); + static void WideStringCopy(wchar *dst, wchar *src, uint16 size); + static bool WideStringCompare(wchar *str1, wchar *str2, uint16 size); + static void Process(void); static void Display(void); + static void AddMessage(wchar *key, uint32 time, uint16 pos); + static void AddMessageJumpQ(wchar *key, uint32 time, uint16 pos); + static void AddMessageSoon(wchar *key, uint32 time, uint16 pos); + static void ClearMessages(void); + static void ClearSmallMessagesOnly(void); + static void AddBigMessage(wchar *key, uint32 time, uint16 pos); + static void AddBigMessageQ(wchar *key, uint32 time, uint16 pos); + static void AddToPreviousBriefArray(wchar *text, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6, wchar *string); + static void InsertNumberInString(wchar *src, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6, wchar *dst); + static void InsertStringInString(wchar *str1, wchar *str2); + static void InsertPlayerControlKeysInString(wchar *src); + static void AddMessageWithNumber(wchar *key, uint32 time, uint16 pos, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6); + static void AddMessageJumpQWithNumber(wchar *key, uint32 time, uint16 pos, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6); + static void AddMessageSoonWithNumber(wchar *key, uint32 time, uint16 pos, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6); + static void AddBigMessageWithNumber(wchar *key, uint32 time, uint16 pos, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6); + static void AddBigMessageWithNumberQ(wchar *key, uint32 time, uint16 pos, int32 n1, int32 n2, int32 n3, int32 n4, int32 n5, int32 n6); + static void AddMessageWithString(wchar *text, uint32 time, uint16 flag, wchar *str); + static void AddMessageJumpQWithString(wchar *text, uint32 time, uint16 flag, wchar *str); + static void ClearThisPrint(wchar *str); + static void ClearThisBigPrint(wchar *str); static void ClearAllMessagesDisplayedByGame(void); - static int WideStringCopy(wchar* dst, wchar* src, unsigned short size); - static char WideStringCompare(wchar* str1, wchar* str2, unsigned short size); - static void InsertNumberInString(wchar* src, int n1, int n2, int n3, int n4, int n5, int n6, wchar* dst); - static void InsertPlayerControlKeysInString(wchar* src); - static int GetWideStringLength(wchar *src); - static void AddBigMessage(wchar* key, uint32 time, uint16 pos); - static void AddBigMessageWithNumber(wchar* key, uint32 time, uint16 pos, int n1, int n2, int n3, int n4, int n5, int n6); - static void AddBigMessageWithNumberQ(wchar* key, uint32 time, uint16 pos, int n1, int n2, int n3, int n4, int n5, int n6); - static void AddMessage(wchar* key, uint32 time, uint16 pos); - static void AddMessageJumpQ(wchar* key, uint32 time, uint16 pos); - static void AddMessageSoon(wchar* key, uint32 time, uint16 pos); - static void AddMessageWithNumber(wchar* key, uint32 time, uint16 pos, int n1, int n2, int n3, int n4, int n5, int n6); - static void AddMessageJumpQWithNumber(wchar* key, uint32 time, uint16 pos, int n1, int n2, int n3, int n4, int n5, int n6); - static void AddMessageSoonWithNumber(wchar* key, uint32 time, uint16 pos, int n1, int n2, int n3, int n4, int n5, int n6); - static void ClearMessages(); - static void Init(); - static void Process(); }; diff --git a/src/text/Pager.cpp b/src/text/Pager.cpp index d20be45d..68caca9a 100644 --- a/src/text/Pager.cpp +++ b/src/text/Pager.cpp @@ -19,12 +19,12 @@ CPager::Process() if (m_messages[0].m_pText != nil && m_messages[0].m_nCurrentPosition >= (int32)m_messages[0].m_nStringLength) {
m_messages[0].m_pText = nil;
uint16 i = 0;
- while (i < 7) {
+ while (i < NUMPAGERMESSAGES-1) {
if (m_messages[i + 1].m_pText == nil) break;
m_messages[i] = m_messages[i + 1];
}
m_messages[i].m_pText = nil;
- if (m_messages[0].m_pText)
+ if (m_messages[0].m_pText != nil)
CMessages::AddToPreviousBriefArray(
m_messages[0].m_pText,
m_messages[0].m_nNumber[0],
@@ -56,7 +56,7 @@ CPager::Display() wchar *pText = m_messages[0].m_pText;
uint16 i = 0;
- if (pText) {
+ if (pText != nil) {
CMessages::InsertNumberInString(
pText,
m_messages[0].m_nNumber[0],
@@ -86,12 +86,12 @@ void CPager::AddMessage(wchar *str, uint16 speed, uint16 priority, uint16 a5)
{
uint16 size = CMessages::GetWideStringLength(str);
- for (int i = 0; i < 8; i++) {
+ for (int32 i = 0; i < NUMPAGERMESSAGES; i++) {
if (m_messages[i].m_pText) {
if (m_messages[i].m_nPriority >= priority)
continue;
- for (int j = 7; j > i; j--)
+ for (int j = NUMPAGERMESSAGES-1; j > i; j--)
m_messages[j] = m_messages[j-1];
}
@@ -130,12 +130,12 @@ CPager::AddMessageWithNumber(wchar *str, int32 n1, int32 n2, int32 n3, int32 n4, CMessages::InsertNumberInString(str, n1, n2, n3, n4, n5, n6, nstr);
uint16 size = CMessages::GetWideStringLength(nstr);
- for (int i = 0; i < 8; i++) {
+ for (int32 i = 0; i < NUMPAGERMESSAGES; i++) {
if (m_messages[i].m_pText) {
if (m_messages[i].m_nPriority >= priority)
continue;
- for (int j = 7; j > i; j--)
+ for (int j = NUMPAGERMESSAGES-1; j > i; j--)
m_messages[j] = m_messages[j - 1];
}
@@ -170,14 +170,14 @@ CPager::AddMessageWithNumber(wchar *str, int32 n1, int32 n2, int32 n3, int32 n4, void
CPager::ClearMessages()
{
- for (int i = 0; i < 8; i++)
+ for (int32 i = 0; i < NUMPAGERMESSAGES; i++)
m_messages[i].m_pText = nil;
}
void
CPager::RestartCurrentMessage()
{
- if (m_messages[0].m_pText) {
+ if (m_messages[0].m_pText != nil) {
m_messages[0].m_nCurrentPosition = -(m_nNumDisplayLetters + 10);
m_messages[0].m_nTimeToChangePosition = CTimer::GetTimeInMilliseconds() + m_messages[0].m_nSpeedMs;
}
diff --git a/src/text/Pager.h b/src/text/Pager.h index 90291c74..727eeb24 100644 --- a/src/text/Pager.h +++ b/src/text/Pager.h @@ -8,16 +8,15 @@ struct PagerMessage { uint16 m_nPriority;
uint32 m_nTimeToChangePosition;
int16 field_10;
-private:
- char _pad12[2];
-public:
int32 m_nNumber[6];
}; +#define NUMPAGERMESSAGES 8 + class CPager { int16 m_nNumDisplayLetters;
- PagerMessage m_messages[8]; + PagerMessage m_messages[NUMPAGERMESSAGES]; public:
void Init(); void Process(); |