From 321e7388b7ed9119b4a4f2be4f457689ea9a9b48 Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Fri, 20 Sep 2024 15:22:33 -0400 Subject: [PATCH 1/6] Rename stores.cpp global variables --- Source/control.cpp | 2 +- Source/controls/game_controls.cpp | 8 +- Source/controls/plrctrls.cpp | 4 +- Source/controls/touch/event_handlers.cpp | 2 +- Source/controls/touch/renderers.cpp | 2 +- Source/diablo.cpp | 40 +- Source/engine/render/scrollrt.cpp | 4 +- Source/inv.cpp | 2 +- Source/items.cpp | 82 +- Source/loadsave.cpp | 12 +- Source/qol/chatlog.cpp | 2 +- Source/qol/itemlabels.cpp | 6 +- Source/qol/stash.cpp | 2 +- Source/stores.cpp | 1182 +++++++++++----------- Source/stores.h | 26 +- Source/track.cpp | 2 +- test/fixtures/memory_map/game.txt | 4 +- test/stores_test.cpp | 20 +- 18 files changed, 701 insertions(+), 701 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 5cfdec301be..7766cb40bad 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -686,7 +686,7 @@ bool IsLevelUpButtonVisible() if (ControlMode == ControlTypes::VirtualGamepad) { return false; } - if (stextflag != TalkID::None || IsStashOpen) { + if (activeStore != TalkID::None || IsStashOpen) { return false; } if (QuestLogIsOpen && GetLeftPanel().contains(GetMainPanel().position + Displacement { 0, -74 })) { diff --git a/Source/controls/game_controls.cpp b/Source/controls/game_controls.cpp index 8799de89f4c..ebd08d39bf9 100644 --- a/Source/controls/game_controls.cpp +++ b/Source/controls/game_controls.cpp @@ -134,7 +134,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game if (ControllerActionHeld == GameActionType_NONE) { ControllerActionHeld = GameActionType_PRIMARY_ACTION; } - } else if (sgpCurrentMenu != nullptr || stextflag != TalkID::None || QuestLogIsOpen) { + } else if (sgpCurrentMenu != nullptr || activeStore != TalkID::None || QuestLogIsOpen) { *action = GameActionSendKey { SDLK_RETURN, false }; } else { *action = GameActionSendKey { SDLK_SPACE, false }; @@ -171,12 +171,12 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game return true; } if (VirtualGamepadState.healthButton.isHeld && VirtualGamepadState.healthButton.didStateChange) { - if (!QuestLogIsOpen && !SpellbookFlag && stextflag == TalkID::None) + if (!QuestLogIsOpen && !SpellbookFlag && activeStore == TalkID::None) *action = GameAction(GameActionType_USE_HEALTH_POTION); return true; } if (VirtualGamepadState.manaButton.isHeld && VirtualGamepadState.manaButton.didStateChange) { - if (!QuestLogIsOpen && !SpellbookFlag && stextflag == TalkID::None) + if (!QuestLogIsOpen && !SpellbookFlag && activeStore == TalkID::None) *action = GameAction(GameActionType_USE_MANA_POTION); return true; } @@ -196,7 +196,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game SDL_Keycode translation = SDLK_UNKNOWN; - if (gmenu_is_active() || stextflag != TalkID::None) + if (gmenu_is_active() || activeStore != TalkID::None) translation = TranslateControllerButtonToGameMenuKey(ctrlEvent.button); else if (inGameMenu) translation = TranslateControllerButtonToMenuKey(ctrlEvent.button); diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index 1f586ffca1d..dd37cbd89c0 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -65,7 +65,7 @@ quest_id pcursquest = Q_INVALID; */ bool InGameMenu() { - return stextflag != TalkID::None + return activeStore != TalkID::None || HelpFlag || ChatLogFlag || ChatFlag @@ -1347,7 +1347,7 @@ HandleLeftStickOrDPadFn GetLeftStickOrDPadGameUIHandler() if (QuestLogIsOpen) { return &QuestLogMove; } - if (stextflag != TalkID::None) { + if (activeStore != TalkID::None) { return &StoreMove; } return nullptr; diff --git a/Source/controls/touch/event_handlers.cpp b/Source/controls/touch/event_handlers.cpp index a08f656ac53..0f4c9dde0fd 100644 --- a/Source/controls/touch/event_handlers.cpp +++ b/Source/controls/touch/event_handlers.cpp @@ -63,7 +63,7 @@ bool HandleGameMenuInteraction(const SDL_Event &event) bool HandleStoreInteraction(const SDL_Event &event) { - if (stextflag == TalkID::None) + if (activeStore == TalkID::None) return false; if (event.type == SDL_FINGERDOWN) CheckStoreBtn(); diff --git a/Source/controls/touch/renderers.cpp b/Source/controls/touch/renderers.cpp index 5790a299ecf..5a1d0fff2f1 100644 --- a/Source/controls/touch/renderers.cpp +++ b/Source/controls/touch/renderers.cpp @@ -430,7 +430,7 @@ VirtualGamepadButtonType PrimaryActionButtonRenderer::GetButtonType() VirtualGamepadButtonType PrimaryActionButtonRenderer::GetTownButtonType() { - if (stextflag != TalkID::None || pcursmonst != -1) + if (activeStore != TalkID::None || pcursmonst != -1) return GetTalkButtonType(virtualPadButton->isHeld); return GetBlankButtonType(virtualPadButton->isHeld); } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index ee39fa8b4aa..46450c6e9e5 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -353,7 +353,7 @@ void LeftMouseDown(uint16_t modState) return; } - if (stextflag != TalkID::None) { + if (activeStore != TalkID::None) { CheckStoreBtn(); return; } @@ -417,7 +417,7 @@ void LeftMouseUp(uint16_t modState) } if (LevelButtonDown) CheckLevelButtonUp(); - if (stextflag != TalkID::None) + if (activeStore != TalkID::None) ReleaseStoreBtn(); } @@ -439,7 +439,7 @@ void RightMouseDown(bool isShiftHeld) doom_close(); return; } - if (stextflag != TalkID::None) + if (activeStore != TalkID::None) return; if (SpellSelectFlag) { SetSpell(); @@ -576,7 +576,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) if ((modState & KMOD_ALT) != 0) { sgOptions.Graphics.fullscreen.SetValue(!IsFullScreen()); SaveOptions(); - } else if (stextflag != TalkID::None) { + } else if (activeStore != TalkID::None) { StoreEnter(); } else if (QuestLogIsOpen) { QuestlogEnter(); @@ -585,7 +585,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) } return; case SDLK_UP: - if (stextflag != TalkID::None) { + if (activeStore != TalkID::None) { StoreUp(); } else if (QuestLogIsOpen) { QuestlogUp(); @@ -600,7 +600,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) } return; case SDLK_DOWN: - if (stextflag != TalkID::None) { + if (activeStore != TalkID::None) { StoreDown(); } else if (QuestLogIsOpen) { QuestlogDown(); @@ -615,14 +615,14 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) } return; case SDLK_PAGEUP: - if (stextflag != TalkID::None) { + if (activeStore != TalkID::None) { StorePrior(); } else if (ChatLogFlag) { ChatLogScrollTop(); } return; case SDLK_PAGEDOWN: - if (stextflag != TalkID::None) { + if (activeStore != TalkID::None) { StoreNext(); } else if (ChatLogFlag) { ChatLogScrollBottom(); @@ -643,7 +643,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) void HandleMouseButtonDown(Uint8 button, uint16_t modState) { - if (stextflag != TalkID::None && (button == SDL_BUTTON_X1 + if (activeStore != TalkID::None && (button == SDL_BUTTON_X1 #if !SDL_VERSION_ATLEAST(2, 0, 0) || button == 8 #endif @@ -752,7 +752,7 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState) #if SDL_VERSION_ATLEAST(2, 0, 0) case SDL_MOUSEWHEEL: if (event.wheel.y > 0) { // Up - if (stextflag != TalkID::None) { + if (activeStore != TalkID::None) { StoreUp(); } else if (QuestLogIsOpen) { QuestlogUp(); @@ -766,7 +766,7 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState) sgOptions.Keymapper.KeyPressed(MouseScrollUpButton); } } else if (event.wheel.y < 0) { // down - if (stextflag != TalkID::None) { + if (activeStore != TalkID::None) { StoreDown(); } else if (QuestLogIsOpen) { QuestlogDown(); @@ -1492,7 +1492,7 @@ void HelpKeyPressed() { if (HelpFlag) { HelpFlag = false; - } else if (stextflag != TalkID::None) { + } else if (activeStore != TalkID::None) { InfoString = StringOrView {}; AddInfoBoxString(_("No help available")); /// BUGFIX: message isn't displayed AddInfoBoxString(_("while in stores")); @@ -1516,7 +1516,7 @@ void HelpKeyPressed() void InventoryKeyPressed() { - if (stextflag != TalkID::None) + if (activeStore != TalkID::None) return; invflag = !invflag; if (!IsLeftPanelOpen() && CanPanelsCoverView()) { @@ -1537,7 +1537,7 @@ void InventoryKeyPressed() void CharacterSheetKeyPressed() { - if (stextflag != TalkID::None) + if (activeStore != TalkID::None) return; if (!IsRightPanelOpen() && CanPanelsCoverView()) { if (CharFlag) { // We are closing the character sheet @@ -1555,7 +1555,7 @@ void CharacterSheetKeyPressed() void QuestLogKeyPressed() { - if (stextflag != TalkID::None) + if (activeStore != TalkID::None) return; if (!QuestLogIsOpen) { StartQuestlog(); @@ -1580,7 +1580,7 @@ void QuestLogKeyPressed() void DisplaySpellsKeyPressed() { - if (stextflag != TalkID::None) + if (activeStore != TalkID::None) return; CloseCharPanel(); QuestLogIsOpen = false; @@ -1596,7 +1596,7 @@ void DisplaySpellsKeyPressed() void SpellBookKeyPressed() { - if (stextflag != TalkID::None) + if (activeStore != TalkID::None) return; SpellbookFlag = !SpellbookFlag; if (!IsLeftPanelOpen() && CanPanelsCoverView()) { @@ -1761,7 +1761,7 @@ void InitKeymapActions() SDLK_F3, [] { gamemenu_load_game(false); }, nullptr, - [&]() { return !gbIsMultiplayer && gbValidSaveFile && stextflag == TalkID::None && IsGameRunning(); }); + [&]() { return !gbIsMultiplayer && gbValidSaveFile && activeStore == TalkID::None && IsGameRunning(); }); #ifndef NOEXIT sgOptions.Keymapper.AddAction( "QuitGame", @@ -2328,7 +2328,7 @@ void InitPadmapActions() ControllerButton_NONE, [] { gamemenu_load_game(false); }, nullptr, - [&]() { return !gbIsMultiplayer && gbValidSaveFile && stextflag == TalkID::None && IsGameRunning(); }); + [&]() { return !gbIsMultiplayer && gbValidSaveFile && activeStore == TalkID::None && IsGameRunning(); }); sgOptions.Padmapper.AddAction( "Item Highlighting", N_("Item highlighting"), @@ -2778,7 +2778,7 @@ bool PressEscKey() rv = true; } - if (stextflag != TalkID::None) { + if (activeStore != TalkID::None) { StoreESC(); rv = true; } diff --git a/Source/engine/render/scrollrt.cpp b/Source/engine/render/scrollrt.cpp index 7f86355e07d..19b4e695dce 100644 --- a/Source/engine/render/scrollrt.cpp +++ b/Source/engine/render/scrollrt.cpp @@ -613,7 +613,7 @@ void DrawItem(const Surface &out, int8_t itemIndex, Point targetBufferPosition, const Item &item = Items[itemIndex]; const ClxSprite sprite = item.AnimInfo.currentSprite(); const Point position = targetBufferPosition + item.getRenderingOffset(sprite); - if (stextflag == TalkID::None && (itemIndex == pcursitem || AutoMapShowItems)) { + if (activeStore == TalkID::None && (itemIndex == pcursitem || AutoMapShowItems)) { ClxDrawOutlineSkipColorZero(out, GetOutlineColor(item, false), position, sprite); } ClxDrawLight(out, position, sprite, lightTableIndex); @@ -1197,7 +1197,7 @@ void DrawView(const Surface &out, Point startPosition) DrawMonsterHealthBar(out); DrawFloatingNumbers(out, startPosition, offset); - if (stextflag != TalkID::None && !qtextflag) + if (activeStore != TalkID::None && !qtextflag) DrawSText(out); if (invflag) { DrawInv(out); diff --git a/Source/inv.cpp b/Source/inv.cpp index 89a6f53aa1a..87fc1d67495 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -2007,7 +2007,7 @@ bool UseInvItem(int cii) return true; if (pcurs != CURSOR_HAND) return true; - if (stextflag != TalkID::None) + if (activeStore != TalkID::None) return true; if (cii < INVITEM_INV_FIRST) return false; diff --git a/Source/items.cpp b/Source/items.cpp index 5851bb88d91..39f4fd3b3e7 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -4374,7 +4374,7 @@ void SpawnSmith(int lvl) int iCnt = RandomIntBetween(10, maxItems); for (int i = 0; i < iCnt; i++) { - Item &newItem = smithitem[i]; + Item &newItem = smithItem[i]; do { newItem = {}; @@ -4388,40 +4388,40 @@ void SpawnSmith(int lvl) newItem._iIdentified = true; } for (int i = iCnt; i < SMITH_ITEMS; i++) - smithitem[i].clear(); + smithItem[i].clear(); - SortVendor(smithitem + PinnedItemCount); + SortVendor(smithItem + PinnedItemCount); } void SpawnPremium(const Player &player) { int lvl = player.getCharacterLevel(); int maxItems = gbIsHellfire ? SMITH_PREMIUM_ITEMS : 6; - if (numpremium < maxItems) { + if (numPremiumItems < maxItems) { for (int i = 0; i < maxItems; i++) { - if (premiumitems[i].isEmpty()) { - int plvl = premiumlevel + (gbIsHellfire ? premiumLvlAddHellfire[i] : premiumlvladd[i]); - SpawnOnePremium(premiumitems[i], plvl, player); + if (premiumItem[i].isEmpty()) { + int plvl = premiumItemLevel + (gbIsHellfire ? premiumLvlAddHellfire[i] : premiumlvladd[i]); + SpawnOnePremium(premiumItem[i], plvl, player); } } - numpremium = maxItems; + numPremiumItems = maxItems; } - while (premiumlevel < lvl) { - premiumlevel++; + while (premiumItemLevel < lvl) { + premiumItemLevel++; if (gbIsHellfire) { // Discard first 3 items and shift next 10 - std::move(&premiumitems[3], &premiumitems[12] + 1, &premiumitems[0]); - SpawnOnePremium(premiumitems[10], premiumlevel + premiumLvlAddHellfire[10], player); - premiumitems[11] = premiumitems[13]; - SpawnOnePremium(premiumitems[12], premiumlevel + premiumLvlAddHellfire[12], player); - premiumitems[13] = premiumitems[14]; - SpawnOnePremium(premiumitems[14], premiumlevel + premiumLvlAddHellfire[14], player); + std::move(&premiumItem[3], &premiumItem[12] + 1, &premiumItem[0]); + SpawnOnePremium(premiumItem[10], premiumItemLevel + premiumLvlAddHellfire[10], player); + premiumItem[11] = premiumItem[13]; + SpawnOnePremium(premiumItem[12], premiumItemLevel + premiumLvlAddHellfire[12], player); + premiumItem[13] = premiumItem[14]; + SpawnOnePremium(premiumItem[14], premiumItemLevel + premiumLvlAddHellfire[14], player); } else { // Discard first 2 items and shift next 3 - std::move(&premiumitems[2], &premiumitems[4] + 1, &premiumitems[0]); - SpawnOnePremium(premiumitems[3], premiumlevel + premiumlvladd[3], player); - premiumitems[4] = premiumitems[5]; - SpawnOnePremium(premiumitems[5], premiumlevel + premiumlvladd[5], player); + std::move(&premiumItem[2], &premiumItem[4] + 1, &premiumItem[0]); + SpawnOnePremium(premiumItem[3], premiumItemLevel + premiumlvladd[3], player); + premiumItem[4] = premiumItem[5]; + SpawnOnePremium(premiumItem[5], premiumItemLevel + premiumlvladd[5], player); } } } @@ -4439,7 +4439,7 @@ void SpawnWitch(int lvl) const int maxValue = gbIsHellfire ? 200000 : 140000; for (int i = 0; i < WITCH_ITEMS; i++) { - Item &item = witchitem[i]; + Item &item = witchItem[i]; item = {}; if (i < PinnedItemCount) { @@ -4490,7 +4490,7 @@ void SpawnWitch(int lvl) item._iIdentified = true; } - SortVendor(witchitem + PinnedItemCount); + SortVendor(witchItem + PinnedItemCount); } void SpawnBoy(int lvl) @@ -4509,19 +4509,19 @@ void SpawnBoy(int lvl) dexterity += dexterity / 5; magic += magic / 5; - if (boylevel >= (lvl / 2) && !boyitem.isEmpty()) + if (boyItemLevel >= (lvl / 2) && !boyItem.isEmpty()) return; do { keepgoing = false; - boyitem = {}; - boyitem._iSeed = AdvanceRndSeed(); - SetRndSeed(boyitem._iSeed); + boyItem = {}; + boyItem._iSeed = AdvanceRndSeed(); + SetRndSeed(boyItem._iSeed); _item_indexes itype = RndBoyItem(*MyPlayer, lvl); - GetItemAttrs(boyitem, itype, lvl); - GetItemBonus(*MyPlayer, boyitem, lvl, 2 * lvl, true, true); + GetItemAttrs(boyItem, itype, lvl); + GetItemBonus(*MyPlayer, boyItem, lvl, 2 * lvl, true, true); if (!gbIsHellfire) { - if (boyitem._iIvalue > 90000) { + if (boyItem._iIvalue > 90000) { keepgoing = true; // prevent breaking the do/while loop too early by failing hellfire's condition in while continue; } @@ -4530,7 +4530,7 @@ void SpawnBoy(int lvl) ivalue = 0; - ItemType itemType = boyitem._itype; + ItemType itemType = boyItem._itype; switch (itemType) { case ItemType::LightArmor: @@ -4596,15 +4596,15 @@ void SpawnBoy(int lvl) } } while (keepgoing || (( - boyitem._iIvalue > 200000 - || boyitem._iMinStr > strength - || boyitem._iMinMag > magic - || boyitem._iMinDex > dexterity - || boyitem._iIvalue < ivalue) + boyItem._iIvalue > 200000 + || boyItem._iMinStr > strength + || boyItem._iMinMag > magic + || boyItem._iMinDex > dexterity + || boyItem._iIvalue < ivalue) && count < 250)); - boyitem._iCreateInfo = lvl | CF_BOY; - boyitem._iIdentified = true; - boylevel = lvl / 2; + boyItem._iCreateInfo = lvl | CF_BOY; + boyItem._iIdentified = true; + boyItemLevel = lvl / 2; } void SpawnHealer(int lvl) @@ -4613,8 +4613,8 @@ void SpawnHealer(int lvl) constexpr std::array<_item_indexes, PinnedItemCount + 1> PinnedItemTypes = { IDI_HEAL, IDI_FULLHEAL, IDI_RESURRECT }; const auto itemCount = static_cast(RandomIntBetween(10, gbIsHellfire ? 19 : 17)); - for (size_t i = 0; i < sizeof(healitem) / sizeof(healitem[0]); ++i) { - Item &item = healitem[i]; + for (size_t i = 0; i < sizeof(healerItem) / sizeof(healerItem[0]); ++i) { + Item &item = healerItem[i]; item = {}; if (i < PinnedItemCount || (gbIsMultiplayer && i == PinnedItemCount)) { @@ -4638,7 +4638,7 @@ void SpawnHealer(int lvl) item._iIdentified = true; } - SortVendor(healitem + PinnedItemCount); + SortVendor(healerItem + PinnedItemCount); } void MakeGoldStack(Item &goldItem, int value) diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 9cb06faae6b..0420dfbc146 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -867,7 +867,7 @@ void LoadItem(LoadHelper &file, Item &item) void LoadPremium(LoadHelper &file, int i) { - LoadAndValidateItemData(file, premiumitems[i]); + LoadAndValidateItemData(file, premiumItem[i]); } void LoadQuest(LoadHelper *file, int i) @@ -2523,8 +2523,8 @@ void LoadGame(bool firstflag) memset(dLight, 0, sizeof(dLight)); } - numpremium = file.NextBE(); - premiumlevel = file.NextBE(); + numPremiumItems = file.NextBE(); + premiumItemLevel = file.NextBE(); for (int i = 0; i < giNumberOfSmithPremiumItems; i++) LoadPremium(file, i); @@ -2786,11 +2786,11 @@ void SaveGameData(SaveWriter &saveWriter) } } - file.WriteBE(numpremium); - file.WriteBE(premiumlevel); + file.WriteBE(numPremiumItems); + file.WriteBE(premiumItemLevel); for (int i = 0; i < giNumberOfSmithPremiumItems; i++) - SaveItem(file, premiumitems[i]); + SaveItem(file, premiumItem[i]); file.WriteLE(AutomapActive ? 1 : 0); file.WriteBE(AutoMapScale); diff --git a/Source/qol/chatlog.cpp b/Source/qol/chatlog.cpp index 5e0da7a12b3..47e5293482c 100644 --- a/Source/qol/chatlog.cpp +++ b/Source/qol/chatlog.cpp @@ -96,7 +96,7 @@ void ToggleChatLog() if (ChatLogFlag) { ChatLogFlag = false; } else { - stextflag = TalkID::None; + activeStore = TalkID::None; CloseInventory(); CloseCharPanel(); SpellbookFlag = false; diff --git a/Source/qol/itemlabels.cpp b/Source/qol/itemlabels.cpp index 7a485129e29..b43346311cd 100644 --- a/Source/qol/itemlabels.cpp +++ b/Source/qol/itemlabels.cpp @@ -98,7 +98,7 @@ void ResetItemlabelHighlighted() bool IsHighlightingLabelsEnabled() { - return stextflag == TalkID::None && highlightKeyPressed != *sgOptions.Gameplay.showItemLabels; + return activeStore == TalkID::None && highlightKeyPressed != *sgOptions.Gameplay.showItemLabels; } void AddItemToLabelQueue(int id, Point position) @@ -193,7 +193,7 @@ void DrawItemNameLabels(const Surface &out) if (!gmenu_is_active() && PauseMode == 0 && !MyPlayerIsDead - && stextflag == TalkID::None + && activeStore == TalkID::None && IsMouseOverGameArea() && LastMouseButtonAction == MouseActionType::None) { isLabelHighlighted = true; @@ -201,7 +201,7 @@ void DrawItemNameLabels(const Surface &out) pcursitem = label.id; } } - if (pcursitem == label.id && stextflag == TalkID::None) + if (pcursitem == label.id && activeStore == TalkID::None) FillRect(clippedOut, label.pos.x, label.pos.y, label.width, labelHeight, PAL8_BLUE + 6); else DrawHalfTransparentRectTo(clippedOut, label.pos.x, label.pos.y, label.width, labelHeight); diff --git a/Source/qol/stash.cpp b/Source/qol/stash.cpp index a8c77c21c79..9e0299186c2 100644 --- a/Source/qol/stash.cpp +++ b/Source/qol/stash.cpp @@ -462,7 +462,7 @@ bool UseStashItem(uint16_t c) return true; if (pcurs != CURSOR_HAND) return true; - if (stextflag != TalkID::None) + if (activeStore != TalkID::None) return true; Item *item = &Stash.stashList[c]; diff --git a/Source/stores.cpp b/Source/stores.cpp index 5af51f51067..315882334d4 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -32,38 +32,38 @@ namespace devilution { -TalkID stextflag; +TalkID activeStore; -int storenumh; -int8_t storehidx[48]; -Item storehold[48]; +int currentItemIndex; +int8_t playerItemIndexes[48]; +Item playerItem[48]; -Item smithitem[SMITH_ITEMS]; -int numpremium; -int premiumlevel; -Item premiumitems[SMITH_PREMIUM_ITEMS]; +Item smithItem[SMITH_ITEMS]; +int numPremiumItems; +int premiumItemLevel; +Item premiumItem[SMITH_PREMIUM_ITEMS]; -Item healitem[20]; +Item healerItem[20]; -Item witchitem[WITCH_ITEMS]; +Item witchItem[WITCH_ITEMS]; -int boylevel; -Item boyitem; +int boyItemLevel; +Item boyItem; namespace { /** The current towner being interacted with */ -_talker_id talker; +_talker_id townerId; /** Is the current dialog full size */ -bool stextsize; +bool isTextFullSize; /** Number of text lines in the current dialog */ -int stextsmax; -/** Remember currently selected text line from stext while displaying a dialog */ -int stextlhold; -/** Currently selected text line from stext */ -int stextsel; +int numTextLines; +/** Remember currently selected text line from textLine while displaying a dialog */ +int oldTextLine; +/** Currently selected text line from textLine */ +int currentTextLine; struct STextStruct { enum Type : uint8_t { @@ -98,31 +98,31 @@ struct STextStruct { }; /** Text lines */ -STextStruct stext[STORE_LINES]; +STextStruct textLine[STORE_LINES]; /** Whether to render the player's gold amount in the top left */ -bool RenderGold; +bool renderGold; /** Does the current panel have a scrollbar */ -bool stextscrl; +bool hasScrollbar; /** Remember last scroll position */ -int stextvhold; +int oldScrollPos; /** Scroll position */ -int stextsval; +int scrollPos; /** Next scroll position */ -int stextdown; +int nextScrollPos; /** Previous scroll position */ -int stextup; +int previousScrollPos; /** Countdown for the push state of the scroll up button */ -int8_t stextscrlubtn; +int8_t countdownScrollUp; /** Countdown for the push state of the scroll down button */ -int8_t stextscrldbtn; +int8_t countdownScrollDown; /** Remember current store while displaying a dialog */ -TalkID stextshold; +TalkID oldActiveStore; /** Temporary item used to hold the item being traded */ -Item StoreItem; +Item tempItem; /** Maps from towner IDs to NPC names. */ const char *const TownerNames[] = { @@ -159,7 +159,7 @@ constexpr int LargeTextHeight = 18; int BackButtonLine() { if (IsSmallFontTall()) { - return stextscrl ? 21 : 20; + return hasScrollbar ? 21 : 20; } return 22; } @@ -176,19 +176,19 @@ int TextHeight() void CalculateLineHeights() { - stext[0].y = 0; + textLine[0].y = 0; if (IsSmallFontTall()) { for (int i = 1; i < STORE_LINES; ++i) { // Space out consecutive text lines, unless they are both selectable (never the case currently). - if (stext[i].hasText() && stext[i - 1].hasText() && !(stext[i].isSelectable() && stext[i - 1].isSelectable())) { - stext[i].y = stext[i - 1].y + LargeTextHeight; + if (textLine[i].hasText() && textLine[i - 1].hasText() && !(textLine[i].isSelectable() && textLine[i - 1].isSelectable())) { + textLine[i].y = textLine[i - 1].y + LargeTextHeight; } else { - stext[i].y = i * LargeLineHeight; + textLine[i].y = i * LargeLineHeight; } } } else { for (int i = 1; i < STORE_LINES; ++i) { - stext[i].y = i * SmallLineHeight; + textLine[i].y = i * SmallLineHeight; } } } @@ -205,11 +205,11 @@ void DrawSSlider(const Surface &out, int y1, int y2) const Point uiPosition = GetUIRectangle().position; int yd1 = y1 * 12 + 44 + uiPosition.y; int yd2 = y2 * 12 + 44 + uiPosition.y; - if (stextscrlubtn != -1) + if (countdownScrollUp != -1) ClxDraw(out, { uiPosition.x + 601, yd1 }, (*pSTextSlidCels)[11]); else ClxDraw(out, { uiPosition.x + 601, yd1 }, (*pSTextSlidCels)[9]); - if (stextscrldbtn != -1) + if (countdownScrollDown != -1) ClxDraw(out, { uiPosition.x + 601, yd2 }, (*pSTextSlidCels)[10]); else ClxDraw(out, { uiPosition.x + 601, yd2 }, (*pSTextSlidCels)[8]); @@ -218,12 +218,12 @@ void DrawSSlider(const Surface &out, int y1, int y2) for (; yd3 < yd2; yd3 += 12) { ClxDraw(out, { uiPosition.x + 601, yd3 }, (*pSTextSlidCels)[13]); } - if (stextsel == BackButtonLine()) - yd3 = stextlhold; + if (currentTextLine == BackButtonLine()) + yd3 = oldTextLine; else - yd3 = stextsel; - if (storenumh > 1) - yd3 = 1000 * (stextsval + ((yd3 - stextup) / 4)) / (storenumh - 1) * (y2 * 12 - y1 * 12 - 24) / 1000; + yd3 = currentTextLine; + if (currentItemIndex > 1) + yd3 = 1000 * (scrollPos + ((yd3 - previousScrollPos) / 4)) / (currentItemIndex - 1) * (y2 * 12 - y1 * 12 - 24) / 1000; else yd3 = 0; ClxDraw(out, { uiPosition.x + 601, (y1 + 1) * 12 + 44 + uiPosition.y + yd3 }, (*pSTextSlidCels)[12]); @@ -231,37 +231,37 @@ void DrawSSlider(const Surface &out, int y1, int y2) void AddSLine(size_t y) { - stext[y]._sx = 0; - stext[y]._syoff = 0; - stext[y].text.clear(); - stext[y].text.shrink_to_fit(); - stext[y].type = STextStruct::Divider; - stext[y].cursId = -1; - stext[y].cursIndent = false; + textLine[y]._sx = 0; + textLine[y]._syoff = 0; + textLine[y].text.clear(); + textLine[y].text.shrink_to_fit(); + textLine[y].type = STextStruct::Divider; + textLine[y].cursId = -1; + textLine[y].cursIndent = false; } void AddSTextVal(size_t y, int val) { - stext[y]._sval = val; + textLine[y]._sval = val; } void AddSText(uint8_t x, size_t y, std::string_view text, UiFlags flags, bool sel, int cursId = -1, bool cursIndent = false) { - stext[y]._sx = x; - stext[y]._syoff = 0; - stext[y].text.clear(); - stext[y].text.append(text); - stext[y].flags = flags; - stext[y].type = sel ? STextStruct::Selectable : STextStruct::Label; - stext[y].cursId = cursId; - stext[y].cursIndent = cursIndent; + textLine[y]._sx = x; + textLine[y]._syoff = 0; + textLine[y].text.clear(); + textLine[y].text.append(text); + textLine[y].flags = flags; + textLine[y].type = sel ? STextStruct::Selectable : STextStruct::Label; + textLine[y].cursId = cursId; + textLine[y].cursIndent = cursIndent; } void AddOptionsBackButton() { const int line = BackButtonLine(); AddSText(0, line, _("Back"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); - stext[line]._syoff = IsSmallFontTall() ? 0 : 6; + textLine[line]._syoff = IsSmallFontTall() ? 0 : 6; } void AddItemListBackButton(bool selectable = false) @@ -273,7 +273,7 @@ void AddItemListBackButton(bool selectable = false) } else { AddSLine(line - 1); AddSText(0, line, text, UiFlags::ColorWhite | UiFlags::AlignCenter, selectable); - stext[line]._syoff = 6; + textLine[line]._syoff = 6; } } @@ -351,7 +351,7 @@ bool StoreAutoPlace(Item &item, bool persistItem) void ScrollVendorStore(Item *itemData, int storeLimit, int idx, int selling = true) { ClearSText(5, 21); - stextup = 5; + previousScrollPos = 5; for (int l = 5; l < 20 && idx < storeLimit; l += 4) { const Item &item = itemData[idx]; @@ -360,24 +360,24 @@ void ScrollVendorStore(Item *itemData, int storeLimit, int idx, int selling = tr AddSText(20, l, item.getName(), itemColor, true, item._iCurs, true); AddSTextVal(l, item._iIdentified ? item._iIvalue : item._ivalue); PrintStoreItem(item, l + 1, itemColor, true); - stextdown = l; + nextScrollPos = l; } else { l -= 4; } idx++; } if (selling) { - if (stextsel != -1 && !stext[stextsel].isSelectable() && stextsel != BackButtonLine()) - stextsel = stextdown; + if (currentTextLine != -1 && !textLine[currentTextLine].isSelectable() && currentTextLine != BackButtonLine()) + currentTextLine = nextScrollPos; } else { - stextsmax = std::max(static_cast(storeLimit) - 4, 0); + numTextLines = std::max(static_cast(storeLimit) - 4, 0); } } void StartSmith() { - stextsize = false; - stextscrl = false; + isTextFullSize = false; + hasScrollbar = false; AddSText(0, 1, _("Welcome to the"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 3, _("Blacksmith's shop"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 7, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); @@ -388,12 +388,12 @@ void StartSmith() AddSText(0, 18, _("Repair items"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSText(0, 20, _("Leave the shop"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSLine(5); - storenumh = 20; + currentItemIndex = 20; } void ScrollSmithBuy(int idx) { - ScrollVendorStore(smithitem, static_cast(std::size(smithitem)), idx); + ScrollVendorStore(smithItem, static_cast(std::size(smithItem)), idx); } uint32_t TotalPlayerGold() @@ -409,67 +409,67 @@ bool PlayerCanAfford(int price) void StartSmithBuy() { - stextsize = true; - stextscrl = true; - stextsval = 0; + isTextFullSize = true; + hasScrollbar = true; + scrollPos = 0; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("I have these items for sale:"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollSmithBuy(stextsval); + ScrollSmithBuy(scrollPos); AddItemListBackButton(); - storenumh = 0; - for (Item &item : smithitem) { + currentItemIndex = 0; + for (Item &item : smithItem) { if (item.isEmpty()) continue; item._iStatFlag = MyPlayer->CanUseItem(item); - storenumh++; + currentItemIndex++; } - stextsmax = std::max(storenumh - 4, 0); + numTextLines = std::max(currentItemIndex - 4, 0); } void ScrollSmithPremiumBuy(int boughtitems) { int idx = 0; for (; boughtitems != 0; idx++) { - if (!premiumitems[idx].isEmpty()) + if (!premiumItem[idx].isEmpty()) boughtitems--; } - ScrollVendorStore(premiumitems, static_cast(std::size(premiumitems)), idx); + ScrollVendorStore(premiumItem, static_cast(std::size(premiumItem)), idx); } bool StartSmithPremiumBuy() { - storenumh = 0; - for (Item &item : premiumitems) { + currentItemIndex = 0; + for (Item &item : premiumItem) { if (item.isEmpty()) continue; item._iStatFlag = MyPlayer->CanUseItem(item); - storenumh++; + currentItemIndex++; } - if (storenumh == 0) { + if (currentItemIndex == 0) { StartStore(TalkID::Smith); - stextsel = 14; + currentTextLine = 14; return false; } - stextsize = true; - stextscrl = true; - stextsval = 0; + isTextFullSize = true; + hasScrollbar = true; + scrollPos = 0; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("I have these premium items for sale:"), UiFlags::ColorWhitegold, false); AddSLine(3); AddItemListBackButton(); - stextsmax = std::max(storenumh - 4, 0); + numTextLines = std::max(currentItemIndex - 4, 0); - ScrollSmithPremiumBuy(stextsval); + ScrollSmithPremiumBuy(scrollPos); return true; } @@ -506,73 +506,73 @@ bool SmithSellOk(int i) void ScrollSmithSell(int idx) { - ScrollVendorStore(storehold, storenumh, idx, false); + ScrollVendorStore(playerItem, currentItemIndex, idx, false); } void StartSmithSell() { - stextsize = true; + isTextFullSize = true; bool sellOk = false; - storenumh = 0; + currentItemIndex = 0; - for (auto &item : storehold) { + for (auto &item : playerItem) { item.clear(); } const Player &myPlayer = *MyPlayer; for (int8_t i = 0; i < myPlayer._pNumInv; i++) { - if (storenumh >= 48) + if (currentItemIndex >= 48) break; if (SmithSellOk(i)) { sellOk = true; - storehold[storenumh] = myPlayer.InvList[i]; + playerItem[currentItemIndex] = myPlayer.InvList[i]; - if (storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) - storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; + if (playerItem[currentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && playerItem[currentItemIndex]._iIdentified) + playerItem[currentItemIndex]._ivalue = playerItem[currentItemIndex]._iIvalue; - storehold[storenumh]._ivalue = std::max(storehold[storenumh]._ivalue / 4, 1); - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh] = i; - storenumh++; + playerItem[currentItemIndex]._ivalue = std::max(playerItem[currentItemIndex]._ivalue / 4, 1); + playerItem[currentItemIndex]._iIvalue = playerItem[currentItemIndex]._ivalue; + playerItemIndexes[currentItemIndex] = i; + currentItemIndex++; } } for (int i = 0; i < MaxBeltItems; i++) { - if (storenumh >= 48) + if (currentItemIndex >= 48) break; if (SmithSellOk(-(i + 1))) { sellOk = true; - storehold[storenumh] = myPlayer.SpdList[i]; + playerItem[currentItemIndex] = myPlayer.SpdList[i]; - if (storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) - storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; + if (playerItem[currentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && playerItem[currentItemIndex]._iIdentified) + playerItem[currentItemIndex]._ivalue = playerItem[currentItemIndex]._iIvalue; - storehold[storenumh]._ivalue = std::max(storehold[storenumh]._ivalue / 4, 1); - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh] = -(i + 1); - storenumh++; + playerItem[currentItemIndex]._ivalue = std::max(playerItem[currentItemIndex]._ivalue / 4, 1); + playerItem[currentItemIndex]._iIvalue = playerItem[currentItemIndex]._ivalue; + playerItemIndexes[currentItemIndex] = -(i + 1); + currentItemIndex++; } } if (!sellOk) { - stextscrl = false; + hasScrollbar = false; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("You have nothing I want."), UiFlags::ColorWhitegold, false); AddSLine(3); AddItemListBackButton(/*selectable=*/true); return; } - stextscrl = true; - stextsval = 0; - stextsmax = myPlayer._pNumInv; + hasScrollbar = true; + scrollPos = 0; + numTextLines = myPlayer._pNumInv; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("Which item is for sale?"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollSmithSell(stextsval); + ScrollSmithSell(scrollPos); AddItemListBackButton(); } @@ -597,10 +597,10 @@ bool SmithRepairOk(int i) void StartSmithRepair() { - stextsize = true; - storenumh = 0; + isTextFullSize = true; + currentItemIndex = 0; - for (auto &item : storehold) { + for (auto &item : playerItem) { item.clear(); } @@ -627,32 +627,32 @@ void StartSmithRepair() } for (int i = 0; i < myPlayer._pNumInv; i++) { - if (storenumh >= 48) + if (currentItemIndex >= 48) break; if (SmithRepairOk(i)) { AddStoreHoldRepair(&myPlayer.InvList[i], i); } } - if (storenumh == 0) { - stextscrl = false; + if (currentItemIndex == 0) { + hasScrollbar = false; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("You have nothing to repair."), UiFlags::ColorWhitegold, false); AddSLine(3); AddItemListBackButton(/*selectable=*/true); return; } - stextscrl = true; - stextsval = 0; - stextsmax = myPlayer._pNumInv; + hasScrollbar = true; + scrollPos = 0; + numTextLines = myPlayer._pNumInv; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("Repair which item?"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollSmithSell(stextsval); + ScrollSmithSell(scrollPos); AddItemListBackButton(); } @@ -674,8 +674,8 @@ void FillManaPlayer() void StartWitch() { FillManaPlayer(); - stextsize = false; - stextscrl = false; + isTextFullSize = false; + hasScrollbar = false; AddSText(0, 2, _("Witch's shack"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 9, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 12, _("Talk to Adria"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); @@ -684,12 +684,12 @@ void StartWitch() AddSText(0, 18, _("Recharge staves"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSText(0, 20, _("Leave the shack"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSLine(5); - storenumh = 20; + currentItemIndex = 20; } void ScrollWitchBuy(int idx) { - ScrollVendorStore(witchitem, static_cast(std::size(witchitem)), idx); + ScrollVendorStore(witchItem, static_cast(std::size(witchItem)), idx); } void WitchBookLevel(Item &bookItem) @@ -710,27 +710,27 @@ void WitchBookLevel(Item &bookItem) void StartWitchBuy() { - stextsize = true; - stextscrl = true; - stextsval = 0; - stextsmax = 20; + isTextFullSize = true; + hasScrollbar = true; + scrollPos = 0; + numTextLines = 20; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("I have these items for sale:"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollWitchBuy(stextsval); + ScrollWitchBuy(scrollPos); AddItemListBackButton(); - storenumh = 0; - for (Item &item : witchitem) { + currentItemIndex = 0; + for (Item &item : witchItem) { if (item.isEmpty()) continue; WitchBookLevel(item); item._iStatFlag = MyPlayer->CanUseItem(item); - storenumh++; + currentItemIndex++; } - stextsmax = std::max(storenumh - 4, 0); + numTextLines = std::max(currentItemIndex - 4, 0); } bool WitchSellOk(int i) @@ -761,54 +761,54 @@ bool WitchSellOk(int i) void StartWitchSell() { - stextsize = true; + isTextFullSize = true; bool sellok = false; - storenumh = 0; + currentItemIndex = 0; - for (auto &item : storehold) { + for (auto &item : playerItem) { item.clear(); } const Player &myPlayer = *MyPlayer; for (int i = 0; i < myPlayer._pNumInv; i++) { - if (storenumh >= 48) + if (currentItemIndex >= 48) break; if (WitchSellOk(i)) { sellok = true; - storehold[storenumh] = myPlayer.InvList[i]; + playerItem[currentItemIndex] = myPlayer.InvList[i]; - if (storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) - storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; + if (playerItem[currentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && playerItem[currentItemIndex]._iIdentified) + playerItem[currentItemIndex]._ivalue = playerItem[currentItemIndex]._iIvalue; - storehold[storenumh]._ivalue = std::max(storehold[storenumh]._ivalue / 4, 1); - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh] = i; - storenumh++; + playerItem[currentItemIndex]._ivalue = std::max(playerItem[currentItemIndex]._ivalue / 4, 1); + playerItem[currentItemIndex]._iIvalue = playerItem[currentItemIndex]._ivalue; + playerItemIndexes[currentItemIndex] = i; + currentItemIndex++; } } for (int i = 0; i < MaxBeltItems; i++) { - if (storenumh >= 48) + if (currentItemIndex >= 48) break; if (!myPlayer.SpdList[i].isEmpty() && WitchSellOk(-(i + 1))) { sellok = true; - storehold[storenumh] = myPlayer.SpdList[i]; + playerItem[currentItemIndex] = myPlayer.SpdList[i]; - if (storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) - storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; + if (playerItem[currentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && playerItem[currentItemIndex]._iIdentified) + playerItem[currentItemIndex]._ivalue = playerItem[currentItemIndex]._iIvalue; - storehold[storenumh]._ivalue = std::max(storehold[storenumh]._ivalue / 4, 1); - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh] = -(i + 1); - storenumh++; + playerItem[currentItemIndex]._ivalue = std::max(playerItem[currentItemIndex]._ivalue / 4, 1); + playerItem[currentItemIndex]._iIvalue = playerItem[currentItemIndex]._ivalue; + playerItemIndexes[currentItemIndex] = -(i + 1); + currentItemIndex++; } } if (!sellok) { - stextscrl = false; + hasScrollbar = false; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("You have nothing I want."), UiFlags::ColorWhitegold, false); AddSLine(3); @@ -816,14 +816,14 @@ void StartWitchSell() return; } - stextscrl = true; - stextsval = 0; - stextsmax = myPlayer._pNumInv; + hasScrollbar = true; + scrollPos = 0; + numTextLines = myPlayer._pNumInv; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("Which item is for sale?"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollSmithSell(stextsval); + ScrollSmithSell(scrollPos); AddItemListBackButton(); } @@ -844,21 +844,21 @@ bool WitchRechargeOk(int i) void AddStoreHoldRecharge(Item itm, int8_t i) { - storehold[storenumh] = itm; - storehold[storenumh]._ivalue += GetSpellData(itm._iSpell).staffCost(); - storehold[storenumh]._ivalue = storehold[storenumh]._ivalue * (storehold[storenumh]._iMaxCharges - storehold[storenumh]._iCharges) / (storehold[storenumh]._iMaxCharges * 2); - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh] = i; - storenumh++; + playerItem[currentItemIndex] = itm; + playerItem[currentItemIndex]._ivalue += GetSpellData(itm._iSpell).staffCost(); + playerItem[currentItemIndex]._ivalue = playerItem[currentItemIndex]._ivalue * (playerItem[currentItemIndex]._iMaxCharges - playerItem[currentItemIndex]._iCharges) / (playerItem[currentItemIndex]._iMaxCharges * 2); + playerItem[currentItemIndex]._iIvalue = playerItem[currentItemIndex]._ivalue; + playerItemIndexes[currentItemIndex] = i; + currentItemIndex++; } void StartWitchRecharge() { - stextsize = true; + isTextFullSize = true; bool rechargeok = false; - storenumh = 0; + currentItemIndex = 0; - for (auto &item : storehold) { + for (auto &item : playerItem) { item.clear(); } @@ -871,7 +871,7 @@ void StartWitchRecharge() } for (int i = 0; i < myPlayer._pNumInv; i++) { - if (storenumh >= 48) + if (currentItemIndex >= 48) break; if (WitchRechargeOk(i)) { rechargeok = true; @@ -880,48 +880,48 @@ void StartWitchRecharge() } if (!rechargeok) { - stextscrl = false; + hasScrollbar = false; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("You have nothing to recharge."), UiFlags::ColorWhitegold, false); AddSLine(3); AddItemListBackButton(/*selectable=*/true); return; } - stextscrl = true; - stextsval = 0; - stextsmax = myPlayer._pNumInv; + hasScrollbar = true; + scrollPos = 0; + numTextLines = myPlayer._pNumInv; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("Recharge which item?"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollSmithSell(stextsval); + ScrollSmithSell(scrollPos); AddItemListBackButton(); } void StoreNoMoney() { - StartStore(stextshold); - stextscrl = false; - stextsize = true; - RenderGold = true; + StartStore(oldActiveStore); + hasScrollbar = false; + isTextFullSize = true; + renderGold = true; ClearSText(5, 23); AddSText(0, 14, _("You do not have enough gold"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); } void StoreNoRoom() { - StartStore(stextshold); - stextscrl = false; + StartStore(oldActiveStore); + hasScrollbar = false; ClearSText(5, 23); AddSText(0, 14, _("You do not have enough room in inventory"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); } void StoreConfirm(Item &item) { - StartStore(stextshold); - stextscrl = false; + StartStore(oldActiveStore); + hasScrollbar = false; ClearSText(5, 23); UiFlags itemColor = item.getTextColorWithStatCheck(); @@ -931,7 +931,7 @@ void StoreConfirm(Item &item) std::string_view prompt; - switch (stextshold) { + switch (oldActiveStore) { case TalkID::BoyBuy: prompt = _("Do we have a deal?"); break; @@ -955,7 +955,7 @@ void StoreConfirm(Item &item) prompt = _("Are you sure you want to repair this item?"); break; default: - app_fatal(StrCat("Unknown store dialog ", static_cast(stextshold))); + app_fatal(StrCat("Unknown store dialog ", static_cast(oldActiveStore))); } AddSText(0, 15, prompt, UiFlags::ColorWhite | UiFlags::AlignCenter, false); AddSText(0, 18, _("Yes"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); @@ -964,11 +964,11 @@ void StoreConfirm(Item &item) void StartBoy() { - stextsize = false; - stextscrl = false; + isTextFullSize = false; + hasScrollbar = false; AddSText(0, 2, _("Wirt the Peg-legged boy"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSLine(5); - if (!boyitem.isEmpty()) { + if (!boyItem.isEmpty()) { AddSText(0, 8, _("Talk to Wirt"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); AddSText(0, 12, _("I have something for sale,"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 14, _("but it will cost 50 gold"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); @@ -983,21 +983,21 @@ void StartBoy() void SStartBoyBuy() { - stextsize = true; - stextscrl = false; + isTextFullSize = true; + hasScrollbar = false; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("I have this item for sale:"), UiFlags::ColorWhitegold, false); AddSLine(3); - boyitem._iStatFlag = MyPlayer->CanUseItem(boyitem); - UiFlags itemColor = boyitem.getTextColorWithStatCheck(); - AddSText(20, 10, boyitem.getName(), itemColor, true, boyitem._iCurs, true); + boyItem._iStatFlag = MyPlayer->CanUseItem(boyItem); + UiFlags itemColor = boyItem.getTextColorWithStatCheck(); + AddSText(20, 10, boyItem.getName(), itemColor, true, boyItem._iCurs, true); if (gbIsHellfire) - AddSTextVal(10, boyitem._iIvalue - (boyitem._iIvalue / 4)); + AddSTextVal(10, boyItem._iIvalue - (boyItem._iIvalue / 4)); else - AddSTextVal(10, boyitem._iIvalue + (boyitem._iIvalue / 2)); - PrintStoreItem(boyitem, 11, itemColor, true); + AddSTextVal(10, boyItem._iIvalue + (boyItem._iIvalue / 2)); + PrintStoreItem(boyItem, 11, itemColor, true); { // Add a Leave button. Unlike the other item list back buttons, @@ -1005,7 +1005,7 @@ void SStartBoyBuy() const int line = BackButtonLine(); AddSLine(line - 1); AddSText(0, line, _("Leave"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); - stext[line]._syoff = 6; + textLine[line]._syoff = 6; } } @@ -1024,8 +1024,8 @@ void HealPlayer() void StartHealer() { HealPlayer(); - stextsize = false; - stextscrl = false; + isTextFullSize = false; + hasScrollbar = false; AddSText(0, 1, _("Welcome to the"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 3, _("Healer's home"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 9, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); @@ -1033,43 +1033,43 @@ void StartHealer() AddSText(0, 14, _("Buy items"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSText(0, 18, _("Leave Healer's home"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSLine(5); - storenumh = 20; + currentItemIndex = 20; } void ScrollHealerBuy(int idx) { - ScrollVendorStore(healitem, static_cast(std::size(healitem)), idx); + ScrollVendorStore(healerItem, static_cast(std::size(healerItem)), idx); } void StartHealerBuy() { - stextsize = true; - stextscrl = true; - stextsval = 0; + isTextFullSize = true; + hasScrollbar = true; + scrollPos = 0; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("I have these items for sale:"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollHealerBuy(stextsval); + ScrollHealerBuy(scrollPos); AddItemListBackButton(); - storenumh = 0; - for (Item &item : healitem) { + currentItemIndex = 0; + for (Item &item : healerItem) { if (item.isEmpty()) continue; item._iStatFlag = MyPlayer->CanUseItem(item); - storenumh++; + currentItemIndex++; } - stextsmax = std::max(storenumh - 4, 0); + numTextLines = std::max(currentItemIndex - 4, 0); } void StartStoryteller() { - stextsize = false; - stextscrl = false; + isTextFullSize = false; + hasScrollbar = false; AddSText(0, 2, _("The Town Elder"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 9, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 12, _("Talk to Cain"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); @@ -1091,20 +1091,20 @@ bool IdItemOk(Item *i) void AddStoreHoldId(Item itm, int8_t i) { - storehold[storenumh] = itm; - storehold[storenumh]._ivalue = 100; - storehold[storenumh]._iIvalue = 100; - storehidx[storenumh] = i; - storenumh++; + playerItem[currentItemIndex] = itm; + playerItem[currentItemIndex]._ivalue = 100; + playerItem[currentItemIndex]._iIvalue = 100; + playerItemIndexes[currentItemIndex] = i; + currentItemIndex++; } void StartStorytellerIdentify() { bool idok = false; - stextsize = true; - storenumh = 0; + isTextFullSize = true; + currentItemIndex = 0; - for (auto &item : storehold) { + for (auto &item : playerItem) { item.clear(); } @@ -1153,7 +1153,7 @@ void StartStorytellerIdentify() } for (int i = 0; i < myPlayer._pNumInv; i++) { - if (storenumh >= 48) + if (currentItemIndex >= 48) break; auto &item = myPlayer.InvList[i]; if (IdItemOk(&item)) { @@ -1163,31 +1163,31 @@ void StartStorytellerIdentify() } if (!idok) { - stextscrl = false; + hasScrollbar = false; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("You have nothing to identify."), UiFlags::ColorWhitegold, false); AddSLine(3); AddItemListBackButton(/*selectable=*/true); return; } - stextscrl = true; - stextsval = 0; - stextsmax = myPlayer._pNumInv; + hasScrollbar = true; + scrollPos = 0; + numTextLines = myPlayer._pNumInv; - RenderGold = true; + renderGold = true; AddSText(20, 1, _("Identify which item?"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollSmithSell(stextsval); + ScrollSmithSell(scrollPos); AddItemListBackButton(); } void StartStorytellerIdentifyShow(Item &item) { - StartStore(stextshold); - stextscrl = false; + StartStore(oldActiveStore); + hasScrollbar = false; ClearSText(5, 23); UiFlags itemColor = item.getTextColorWithStatCheck(); @@ -1202,12 +1202,12 @@ void StartTalk() { int la; - stextsize = false; - stextscrl = false; - AddSText(0, 2, fmt::format(fmt::runtime(_("Talk to {:s}")), _(TownerNames[talker])), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); + isTextFullSize = false; + hasScrollbar = false; + AddSText(0, 2, fmt::format(fmt::runtime(_("Talk to {:s}")), _(TownerNames[townerId])), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSLine(5); if (gbIsSpawn) { - AddSText(0, 10, fmt::format(fmt::runtime(_("Talking to {:s}")), _(TownerNames[talker])), UiFlags::ColorWhite | UiFlags::AlignCenter, false); + AddSText(0, 10, fmt::format(fmt::runtime(_("Talking to {:s}")), _(TownerNames[townerId])), UiFlags::ColorWhite | UiFlags::AlignCenter, false); AddSText(0, 12, _("is not available"), UiFlags::ColorWhite | UiFlags::AlignCenter, false); AddSText(0, 14, _("in the shareware"), UiFlags::ColorWhite | UiFlags::AlignCenter, false); AddSText(0, 16, _("version"), UiFlags::ColorWhite | UiFlags::AlignCenter, false); @@ -1217,7 +1217,7 @@ void StartTalk() int sn = 0; for (auto &quest : Quests) { - if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[talker][quest._qidx] != TEXT_NONE && quest._qlog) + if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[townerId][quest._qidx] != TEXT_NONE && quest._qlog) sn++; } @@ -1232,7 +1232,7 @@ void StartTalk() int sn2 = sn - 2; for (auto &quest : Quests) { - if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[talker][quest._qidx] != TEXT_NONE && quest._qlog) { + if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[townerId][quest._qidx] != TEXT_NONE && quest._qlog) { AddSText(0, sn, _(QuestsData[quest._qidx]._qlstr), UiFlags::ColorWhite | UiFlags::AlignCenter, true); sn += la; } @@ -1243,49 +1243,49 @@ void StartTalk() void StartTavern() { - stextsize = false; - stextscrl = false; + isTextFullSize = false; + hasScrollbar = false; AddSText(0, 1, _("Welcome to the"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 3, _("Rising Sun"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 9, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 12, _("Talk to Ogden"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); AddSText(0, 18, _("Leave the tavern"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSLine(5); - storenumh = 20; + currentItemIndex = 20; } void StartBarmaid() { - stextsize = false; - stextscrl = false; + isTextFullSize = false; + hasScrollbar = false; AddSText(0, 2, _("Gillian"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 9, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 12, _("Talk to Gillian"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); AddSText(0, 14, _("Access Storage"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSText(0, 18, _("Say goodbye"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSLine(5); - storenumh = 20; + currentItemIndex = 20; } void StartDrunk() { - stextsize = false; - stextscrl = false; + isTextFullSize = false; + hasScrollbar = false; AddSText(0, 2, _("Farnham the Drunk"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 9, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 12, _("Talk to Farnham"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); AddSText(0, 18, _("Say Goodbye"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSLine(5); - storenumh = 20; + currentItemIndex = 20; } void SmithEnter() { - switch (stextsel) { + switch (currentTextLine) { case 10: - talker = TOWN_SMITH; - stextlhold = 10; - stextshold = TalkID::Smith; + townerId = TOWN_SMITH; + oldTextLine = 10; + oldActiveStore = TalkID::Smith; StartStore(TalkID::Gossip); break; case 12: @@ -1301,7 +1301,7 @@ void SmithEnter() StartStore(TalkID::SmithRepair); break; case 20: - stextflag = TalkID::None; + activeStore = TalkID::None; break; } } @@ -1315,42 +1315,42 @@ void SmithBuyItem(Item &item) if (item._iMagical == ITEM_QUALITY_NORMAL) item._iIdentified = false; StoreAutoPlace(item, true); - int idx = stextvhold + ((stextlhold - stextup) / 4); + int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); if (idx == SMITH_ITEMS - 1) { - smithitem[SMITH_ITEMS - 1].clear(); + smithItem[SMITH_ITEMS - 1].clear(); } else { - for (; !smithitem[idx + 1].isEmpty(); idx++) { - smithitem[idx] = std::move(smithitem[idx + 1]); + for (; !smithItem[idx + 1].isEmpty(); idx++) { + smithItem[idx] = std::move(smithItem[idx + 1]); } - smithitem[idx].clear(); + smithItem[idx].clear(); } CalcPlrInv(*MyPlayer, true); } void SmithBuyEnter() { - if (stextsel == BackButtonLine()) { + if (currentTextLine == BackButtonLine()) { StartStore(TalkID::Smith); - stextsel = 12; + currentTextLine = 12; return; } - stextlhold = stextsel; - stextvhold = stextsval; - stextshold = TalkID::SmithBuy; + oldTextLine = currentTextLine; + oldScrollPos = scrollPos; + oldActiveStore = TalkID::SmithBuy; - int idx = stextsval + ((stextsel - stextup) / 4); - if (!PlayerCanAfford(smithitem[idx]._iIvalue)) { + int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); + if (!PlayerCanAfford(smithItem[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(smithitem[idx], false)) { + if (!StoreAutoPlace(smithItem[idx], false)) { StartStore(TalkID::NoRoom); return; } - StoreItem = smithitem[idx]; + tempItem = smithItem[idx]; StartStore(TalkID::Confirm); } @@ -1364,52 +1364,52 @@ void SmithBuyPItem(Item &item) item._iIdentified = false; StoreAutoPlace(item, true); - int idx = stextvhold + ((stextlhold - stextup) / 4); + int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); int xx = 0; for (int i = 0; idx >= 0; i++) { - if (!premiumitems[i].isEmpty()) { + if (!premiumItem[i].isEmpty()) { idx--; xx = i; } } - premiumitems[xx].clear(); - numpremium--; + premiumItem[xx].clear(); + numPremiumItems--; SpawnPremium(*MyPlayer); } void SmithPremiumBuyEnter() { - if (stextsel == BackButtonLine()) { + if (currentTextLine == BackButtonLine()) { StartStore(TalkID::Smith); - stextsel = 14; + currentTextLine = 14; return; } - stextshold = TalkID::SmithPremiumBuy; - stextlhold = stextsel; - stextvhold = stextsval; + oldActiveStore = TalkID::SmithPremiumBuy; + oldTextLine = currentTextLine; + oldScrollPos = scrollPos; - int xx = stextsval + ((stextsel - stextup) / 4); + int xx = scrollPos + ((currentTextLine - previousScrollPos) / 4); int idx = 0; for (int i = 0; xx >= 0; i++) { - if (!premiumitems[i].isEmpty()) { + if (!premiumItem[i].isEmpty()) { xx--; idx = i; } } - if (!PlayerCanAfford(premiumitems[idx]._iIvalue)) { + if (!PlayerCanAfford(premiumItem[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(premiumitems[idx], false)) { + if (!StoreAutoPlace(premiumItem[idx], false)) { StartStore(TalkID::NoRoom); return; } - StoreItem = premiumitems[idx]; + tempItem = premiumItem[idx]; StartStore(TalkID::Confirm); } @@ -1434,18 +1434,18 @@ void StoreSellItem() { Player &myPlayer = *MyPlayer; - int idx = stextvhold + ((stextlhold - stextup) / 4); - if (storehidx[idx] >= 0) - myPlayer.RemoveInvItem(storehidx[idx]); + int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); + if (playerItemIndexes[idx] >= 0) + myPlayer.RemoveInvItem(playerItemIndexes[idx]); else - myPlayer.RemoveSpdBarItem(-(storehidx[idx] + 1)); - - int cost = storehold[idx]._iIvalue; - storenumh--; - if (idx != storenumh) { - while (idx < storenumh) { - storehold[idx] = storehold[idx + 1]; - storehidx[idx] = storehidx[idx + 1]; + myPlayer.RemoveSpdBarItem(-(playerItemIndexes[idx] + 1)); + + int cost = playerItem[idx]._iIvalue; + currentItemIndex--; + if (idx != currentItemIndex) { + while (idx < currentItemIndex) { + playerItem[idx] = playerItem[idx + 1]; + playerItemIndexes[idx] = playerItemIndexes[idx + 1]; idx++; } } @@ -1457,24 +1457,24 @@ void StoreSellItem() void SmithSellEnter() { - if (stextsel == BackButtonLine()) { + if (currentTextLine == BackButtonLine()) { StartStore(TalkID::Smith); - stextsel = 16; + currentTextLine = 16; return; } - stextlhold = stextsel; - stextshold = TalkID::SmithSell; - stextvhold = stextsval; + oldTextLine = currentTextLine; + oldActiveStore = TalkID::SmithSell; + oldScrollPos = scrollPos; - int idx = stextsval + ((stextsel - stextup) / 4); + int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); - if (!StoreGoldFit(storehold[idx])) { + if (!StoreGoldFit(playerItem[idx])) { StartStore(TalkID::NoRoom); return; } - StoreItem = storehold[idx]; + tempItem = playerItem[idx]; StartStore(TalkID::Confirm); } @@ -1483,10 +1483,10 @@ void SmithSellEnter() */ void SmithRepairItem(int price) { - int idx = stextvhold + ((stextlhold - stextup) / 4); - storehold[idx]._iDurability = storehold[idx]._iMaxDur; + int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); + playerItem[idx]._iDurability = playerItem[idx]._iMaxDur; - int8_t i = storehidx[idx]; + int8_t i = playerItemIndexes[idx]; Player &myPlayer = *MyPlayer; @@ -1509,34 +1509,34 @@ void SmithRepairItem(int price) void SmithRepairEnter() { - if (stextsel == BackButtonLine()) { + if (currentTextLine == BackButtonLine()) { StartStore(TalkID::Smith); - stextsel = 18; + currentTextLine = 18; return; } - stextshold = TalkID::SmithRepair; - stextlhold = stextsel; - stextvhold = stextsval; + oldActiveStore = TalkID::SmithRepair; + oldTextLine = currentTextLine; + oldScrollPos = scrollPos; - int idx = stextsval + ((stextsel - stextup) / 4); + int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); - if (!PlayerCanAfford(storehold[idx]._iIvalue)) { + if (!PlayerCanAfford(playerItem[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - StoreItem = storehold[idx]; + tempItem = playerItem[idx]; StartStore(TalkID::Confirm); } void WitchEnter() { - switch (stextsel) { + switch (currentTextLine) { case 12: - stextlhold = 12; - talker = TOWN_WITCH; - stextshold = TalkID::Witch; + oldTextLine = 12; + townerId = TOWN_WITCH; + oldActiveStore = TalkID::Witch; StartStore(TalkID::Gossip); break; case 14: @@ -1549,7 +1549,7 @@ void WitchEnter() StartStore(TalkID::WitchRecharge); break; case 20: - stextflag = TalkID::None; + activeStore = TalkID::None; break; } } @@ -1559,7 +1559,7 @@ void WitchEnter() */ void WitchBuyItem(Item &item) { - int idx = stextvhold + ((stextlhold - stextup) / 4); + int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); if (idx < 3) item._iSeed = AdvanceRndSeed(); @@ -1569,12 +1569,12 @@ void WitchBuyItem(Item &item) if (idx >= 3) { if (idx == WITCH_ITEMS - 1) { - witchitem[WITCH_ITEMS - 1].clear(); + witchItem[WITCH_ITEMS - 1].clear(); } else { - for (; !witchitem[idx + 1].isEmpty(); idx++) { - witchitem[idx] = std::move(witchitem[idx + 1]); + for (; !witchItem[idx + 1].isEmpty(); idx++) { + witchItem[idx] = std::move(witchItem[idx + 1]); } - witchitem[idx].clear(); + witchItem[idx].clear(); } } @@ -1583,52 +1583,52 @@ void WitchBuyItem(Item &item) void WitchBuyEnter() { - if (stextsel == BackButtonLine()) { + if (currentTextLine == BackButtonLine()) { StartStore(TalkID::Witch); - stextsel = 14; + currentTextLine = 14; return; } - stextlhold = stextsel; - stextvhold = stextsval; - stextshold = TalkID::WitchBuy; + oldTextLine = currentTextLine; + oldScrollPos = scrollPos; + oldActiveStore = TalkID::WitchBuy; - int idx = stextsval + ((stextsel - stextup) / 4); + int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); - if (!PlayerCanAfford(witchitem[idx]._iIvalue)) { + if (!PlayerCanAfford(witchItem[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(witchitem[idx], false)) { + if (!StoreAutoPlace(witchItem[idx], false)) { StartStore(TalkID::NoRoom); return; } - StoreItem = witchitem[idx]; + tempItem = witchItem[idx]; StartStore(TalkID::Confirm); } void WitchSellEnter() { - if (stextsel == BackButtonLine()) { + if (currentTextLine == BackButtonLine()) { StartStore(TalkID::Witch); - stextsel = 16; + currentTextLine = 16; return; } - stextlhold = stextsel; - stextshold = TalkID::WitchSell; - stextvhold = stextsval; + oldTextLine = currentTextLine; + oldActiveStore = TalkID::WitchSell; + oldScrollPos = scrollPos; - int idx = stextsval + ((stextsel - stextup) / 4); + int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); - if (!StoreGoldFit(storehold[idx])) { + if (!StoreGoldFit(playerItem[idx])) { StartStore(TalkID::NoRoom); return; } - StoreItem = storehold[idx]; + tempItem = playerItem[idx]; StartStore(TalkID::Confirm); } @@ -1637,12 +1637,12 @@ void WitchSellEnter() */ void WitchRechargeItem(int price) { - int idx = stextvhold + ((stextlhold - stextup) / 4); - storehold[idx]._iCharges = storehold[idx]._iMaxCharges; + int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); + playerItem[idx]._iCharges = playerItem[idx]._iMaxCharges; Player &myPlayer = *MyPlayer; - int8_t i = storehidx[idx]; + int8_t i = playerItemIndexes[idx]; if (i < 0) { myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges = myPlayer.InvBody[INVLOC_HAND_LEFT]._iMaxCharges; NetSendCmdChItem(true, INVLOC_HAND_LEFT); @@ -1657,34 +1657,34 @@ void WitchRechargeItem(int price) void WitchRechargeEnter() { - if (stextsel == BackButtonLine()) { + if (currentTextLine == BackButtonLine()) { StartStore(TalkID::Witch); - stextsel = 18; + currentTextLine = 18; return; } - stextshold = TalkID::WitchRecharge; - stextlhold = stextsel; - stextvhold = stextsval; + oldActiveStore = TalkID::WitchRecharge; + oldTextLine = currentTextLine; + oldScrollPos = scrollPos; - int idx = stextsval + ((stextsel - stextup) / 4); + int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); - if (!PlayerCanAfford(storehold[idx]._iIvalue)) { + if (!PlayerCanAfford(playerItem[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - StoreItem = storehold[idx]; + tempItem = playerItem[idx]; StartStore(TalkID::Confirm); } void BoyEnter() { - if (!boyitem.isEmpty() && stextsel == 18) { + if (!boyItem.isEmpty() && currentTextLine == 18) { if (!PlayerCanAfford(50)) { - stextshold = TalkID::Boy; - stextlhold = 18; - stextvhold = stextsval; + oldActiveStore = TalkID::Boy; + oldTextLine = 18; + oldScrollPos = scrollPos; StartStore(TalkID::NoMoney); } else { TakePlrsMoney(50); @@ -1693,14 +1693,14 @@ void BoyEnter() return; } - if ((stextsel != 8 && !boyitem.isEmpty()) || (stextsel != 12 && boyitem.isEmpty())) { - stextflag = TalkID::None; + if ((currentTextLine != 8 && !boyItem.isEmpty()) || (currentTextLine != 12 && boyItem.isEmpty())) { + activeStore = TalkID::None; return; } - talker = TOWN_PEGBOY; - stextshold = TalkID::Boy; - stextlhold = stextsel; + townerId = TOWN_PEGBOY; + oldActiveStore = TalkID::Boy; + oldTextLine = currentTextLine; StartStore(TalkID::Gossip); } @@ -1708,10 +1708,10 @@ void BoyBuyItem(Item &item) { TakePlrsMoney(item._iIvalue); StoreAutoPlace(item, true); - boyitem.clear(); - stextshold = TalkID::Boy; + boyItem.clear(); + oldActiveStore = TalkID::Boy; CalcPlrInv(*MyPlayer, true); - stextlhold = 12; + oldTextLine = 12; } /** @@ -1719,7 +1719,7 @@ void BoyBuyItem(Item &item) */ void HealerBuyItem(Item &item) { - int idx = stextvhold + ((stextlhold - stextup) / 4); + int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); if (!gbIsMultiplayer) { if (idx < 2) item._iSeed = AdvanceRndSeed(); @@ -1740,46 +1740,46 @@ void HealerBuyItem(Item &item) if (idx < 3) return; } - idx = stextvhold + ((stextlhold - stextup) / 4); + idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); if (idx == 19) { - healitem[19].clear(); + healerItem[19].clear(); } else { - for (; !healitem[idx + 1].isEmpty(); idx++) { - healitem[idx] = std::move(healitem[idx + 1]); + for (; !healerItem[idx + 1].isEmpty(); idx++) { + healerItem[idx] = std::move(healerItem[idx + 1]); } - healitem[idx].clear(); + healerItem[idx].clear(); } CalcPlrInv(*MyPlayer, true); } void BoyBuyEnter() { - if (stextsel != 10) { - stextflag = TalkID::None; + if (currentTextLine != 10) { + activeStore = TalkID::None; return; } - stextshold = TalkID::BoyBuy; - stextvhold = stextsval; - stextlhold = 10; - int price = boyitem._iIvalue; + oldActiveStore = TalkID::BoyBuy; + oldScrollPos = scrollPos; + oldTextLine = 10; + int price = boyItem._iIvalue; if (gbIsHellfire) - price -= boyitem._iIvalue / 4; + price -= boyItem._iIvalue / 4; else - price += boyitem._iIvalue / 2; + price += boyItem._iIvalue / 2; if (!PlayerCanAfford(price)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(boyitem, false)) { + if (!StoreAutoPlace(boyItem, false)) { StartStore(TalkID::NoRoom); return; } - StoreItem = boyitem; - StoreItem._iIvalue = price; + tempItem = boyItem; + tempItem._iIvalue = price; StartStore(TalkID::Confirm); } @@ -1787,7 +1787,7 @@ void StorytellerIdentifyItem(Item &item) { Player &myPlayer = *MyPlayer; - int8_t idx = storehidx[((stextlhold - stextup) / 4) + stextvhold]; + int8_t idx = playerItemIndexes[((oldTextLine - previousScrollPos) / 4) + oldScrollPos]; if (idx < 0) { if (idx == -1) myPlayer.InvBody[INVLOC_HEAD]._iIdentified = true; @@ -1813,8 +1813,8 @@ void StorytellerIdentifyItem(Item &item) void ConfirmEnter(Item &item) { - if (stextsel == 18) { - switch (stextshold) { + if (currentTextLine == 18) { + switch (oldActiveStore) { case TalkID::SmithBuy: SmithBuyItem(item); break; @@ -1849,117 +1849,117 @@ void ConfirmEnter(Item &item) } } - StartStore(stextshold); + StartStore(oldActiveStore); - if (stextsel == BackButtonLine()) + if (currentTextLine == BackButtonLine()) return; - stextsel = stextlhold; - stextsval = std::min(stextvhold, stextsmax); + currentTextLine = oldTextLine; + scrollPos = std::min(oldScrollPos, numTextLines); - while (stextsel != -1 && !stext[stextsel].isSelectable()) { - stextsel--; + while (currentTextLine != -1 && !textLine[currentTextLine].isSelectable()) { + currentTextLine--; } } void HealerEnter() { - switch (stextsel) { + switch (currentTextLine) { case 12: - stextlhold = 12; - talker = TOWN_HEALER; - stextshold = TalkID::Healer; + oldTextLine = 12; + townerId = TOWN_HEALER; + oldActiveStore = TalkID::Healer; StartStore(TalkID::Gossip); break; case 14: StartStore(TalkID::HealerBuy); break; case 18: - stextflag = TalkID::None; + activeStore = TalkID::None; break; } } void HealerBuyEnter() { - if (stextsel == BackButtonLine()) { + if (currentTextLine == BackButtonLine()) { StartStore(TalkID::Healer); - stextsel = 14; + currentTextLine = 14; return; } - stextlhold = stextsel; - stextvhold = stextsval; - stextshold = TalkID::HealerBuy; + oldTextLine = currentTextLine; + oldScrollPos = scrollPos; + oldActiveStore = TalkID::HealerBuy; - int idx = stextsval + ((stextsel - stextup) / 4); + int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); - if (!PlayerCanAfford(healitem[idx]._iIvalue)) { + if (!PlayerCanAfford(healerItem[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(healitem[idx], false)) { + if (!StoreAutoPlace(healerItem[idx], false)) { StartStore(TalkID::NoRoom); return; } - StoreItem = healitem[idx]; + tempItem = healerItem[idx]; StartStore(TalkID::Confirm); } void StorytellerEnter() { - switch (stextsel) { + switch (currentTextLine) { case 12: - stextlhold = 12; - talker = TOWN_STORY; - stextshold = TalkID::Storyteller; + oldTextLine = 12; + townerId = TOWN_STORY; + oldActiveStore = TalkID::Storyteller; StartStore(TalkID::Gossip); break; case 14: StartStore(TalkID::StorytellerIdentify); break; case 18: - stextflag = TalkID::None; + activeStore = TalkID::None; break; } } void StorytellerIdentifyEnter() { - if (stextsel == BackButtonLine()) { + if (currentTextLine == BackButtonLine()) { StartStore(TalkID::Storyteller); - stextsel = 14; + currentTextLine = 14; return; } - stextshold = TalkID::StorytellerIdentify; - stextlhold = stextsel; - stextvhold = stextsval; + oldActiveStore = TalkID::StorytellerIdentify; + oldTextLine = currentTextLine; + oldScrollPos = scrollPos; - int idx = stextsval + ((stextsel - stextup) / 4); + int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); - if (!PlayerCanAfford(storehold[idx]._iIvalue)) { + if (!PlayerCanAfford(playerItem[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - StoreItem = storehold[idx]; + tempItem = playerItem[idx]; StartStore(TalkID::Confirm); } void TalkEnter() { - if (stextsel == BackButtonLine()) { - StartStore(stextshold); - stextsel = stextlhold; + if (currentTextLine == BackButtonLine()) { + StartStore(oldActiveStore); + currentTextLine = oldTextLine; return; } int sn = 0; for (auto &quest : Quests) { - if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[talker][quest._qidx] != TEXT_NONE && quest._qlog) + if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[townerId][quest._qidx] != TEXT_NONE && quest._qlog) sn++; } int la = 2; @@ -1970,17 +1970,17 @@ void TalkEnter() sn = 15 - sn; } - if (stextsel == sn - 2) { - Towner *target = GetTowner(talker); + if (currentTextLine == sn - 2) { + Towner *target = GetTowner(townerId); assert(target != nullptr); InitQTextMsg(target->gossip); return; } for (auto &quest : Quests) { - if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[talker][quest._qidx] != TEXT_NONE && quest._qlog) { - if (sn == stextsel) { - InitQTextMsg(QuestDialogTable[talker][quest._qidx]); + if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[townerId][quest._qidx] != TEXT_NONE && quest._qlog) { + if (sn == currentTextLine) { + InitQTextMsg(QuestDialogTable[townerId][quest._qidx]); } sn += la; } @@ -1989,30 +1989,30 @@ void TalkEnter() void TavernEnter() { - switch (stextsel) { + switch (currentTextLine) { case 12: - stextlhold = 12; - talker = TOWN_TAVERN; - stextshold = TalkID::Tavern; + oldTextLine = 12; + townerId = TOWN_TAVERN; + oldActiveStore = TalkID::Tavern; StartStore(TalkID::Gossip); break; case 18: - stextflag = TalkID::None; + activeStore = TalkID::None; break; } } void BarmaidEnter() { - switch (stextsel) { + switch (currentTextLine) { case 12: - stextlhold = 12; - talker = TOWN_BMAID; - stextshold = TalkID::Barmaid; + oldTextLine = 12; + townerId = TOWN_BMAID; + oldActiveStore = TalkID::Barmaid; StartStore(TalkID::Gossip); break; case 14: - stextflag = TalkID::None; + activeStore = TalkID::None; IsStashOpen = true; Stash.RefreshItemStatFlags(); invflag = true; @@ -2023,22 +2023,22 @@ void BarmaidEnter() } break; case 18: - stextflag = TalkID::None; + activeStore = TalkID::None; break; } } void DrunkEnter() { - switch (stextsel) { + switch (currentTextLine) { case 12: - stextlhold = 12; - talker = TOWN_DRUNK; - stextshold = TalkID::Drunk; + oldTextLine = 12; + townerId = TOWN_DRUNK; + oldActiveStore = TalkID::Drunk; StartStore(TalkID::Gossip); break; case 18: - stextflag = TalkID::None; + activeStore = TalkID::None; break; } } @@ -2088,8 +2088,8 @@ void AddStoreHoldRepair(Item *itm, int8_t i) Item *item; int v; - item = &storehold[storenumh]; - storehold[storenumh] = *itm; + item = &playerItem[currentItemIndex]; + playerItem[currentItemIndex] = *itm; int due = item->_iMaxDur - item->_iDurability; if (item->_iMagical != ITEM_QUALITY_NORMAL && item->_iIdentified) { @@ -2102,24 +2102,24 @@ void AddStoreHoldRepair(Item *itm, int8_t i) } item->_iIvalue = v; item->_ivalue = v; - storehidx[storenumh] = i; - storenumh++; + playerItemIndexes[currentItemIndex] = i; + currentItemIndex++; } void InitStores() { ClearSText(0, STORE_LINES); - stextflag = TalkID::None; - stextsize = false; - stextscrl = false; - numpremium = 0; - premiumlevel = 1; + activeStore = TalkID::None; + isTextFullSize = false; + hasScrollbar = false; + numPremiumItems = 0; + premiumItemLevel = 1; - for (auto &premiumitem : premiumitems) + for (auto &premiumitem : premiumItem) premiumitem.clear(); - boyitem.clear(); - boylevel = 0; + boyItem.clear(); + boyItemLevel = 0; } void SetupTownStores() @@ -2148,8 +2148,8 @@ void FreeStoreMem() if (*sgOptions.Gameplay.showItemGraphicsInStores) { FreeHalfSizeItemSprites(); } - stextflag = TalkID::None; - for (STextStruct &entry : stext) { + activeStore = TalkID::None; + for (STextStruct &entry : textLine) { entry.text.clear(); entry.text.shrink_to_fit(); } @@ -2159,14 +2159,14 @@ void PrintSString(const Surface &out, int margin, int line, std::string_view tex { const Point uiPosition = GetUIRectangle().position; int sx = uiPosition.x + 32 + margin; - if (!stextsize) { + if (!isTextFullSize) { sx += 320; } - const int sy = uiPosition.y + PaddingTop + stext[line].y + stext[line]._syoff; + const int sy = uiPosition.y + PaddingTop + textLine[line].y + textLine[line]._syoff; - int width = stextsize ? 575 : 255; - if (stextscrl && line >= 4 && line <= 20) { + int width = isTextFullSize ? 575 : 255; + if (hasScrollbar && line >= 4 && line <= 20) { width -= 9; // Space for the selector } width -= margin * 2; @@ -2205,7 +2205,7 @@ void PrintSString(const Surface &out, int margin, int line, std::string_view tex if (price > 0) DrawString(out, FormatInteger(price), rect, { .flags = flags | UiFlags::AlignRight }); - if (stextsel == line) { + if (currentTextLine == line) { DrawSelector(out, rect, text, flags); } } @@ -2216,7 +2216,7 @@ void DrawSLine(const Surface &out, int sy) int sx = 26; int width = 587; - if (!stextsize) { + if (!isTextFullSize) { sx += SidePanelSize.width; width -= SidePanelSize.width; } @@ -2230,20 +2230,20 @@ void DrawSLine(const Surface &out, int sy) void DrawSTextHelp() { - stextsel = -1; - stextsize = true; + currentTextLine = -1; + isTextFullSize = true; } void ClearSText(int s, int e) { for (int i = s; i < e; i++) { - stext[i]._sx = 0; - stext[i]._syoff = 0; - stext[i].text.clear(); - stext[i].text.shrink_to_fit(); - stext[i].flags = UiFlags::None; - stext[i].type = STextStruct::Label; - stext[i]._sval = 0; + textLine[i]._sx = 0; + textLine[i]._syoff = 0; + textLine[i].text.clear(); + textLine[i].text.shrink_to_fit(); + textLine[i].flags = UiFlags::None; + textLine[i].type = STextStruct::Label; + textLine[i]._sval = 0; } } @@ -2255,7 +2255,7 @@ void StartStore(TalkID s) SpellbookFlag = false; CloseInventory(); CloseCharPanel(); - RenderGold = false; + renderGold = false; QuestLogIsOpen = false; CloseGoldDrop(); ClearSText(0, STORE_LINES); @@ -2266,15 +2266,15 @@ void StartStore(TalkID s) break; case TalkID::SmithBuy: { bool hasAnyItems = false; - for (int i = 0; !smithitem[i].isEmpty(); i++) { + for (int i = 0; !smithItem[i].isEmpty(); i++) { hasAnyItems = true; break; } if (hasAnyItems) StartSmithBuy(); else { - stextflag = TalkID::SmithBuy; - stextlhold = 12; + activeStore = TalkID::SmithBuy; + oldTextLine = 12; StoreESC(); return; } @@ -2290,7 +2290,7 @@ void StartStore(TalkID s) StartWitch(); break; case TalkID::WitchBuy: - if (storenumh > 0) + if (currentItemIndex > 0) StartWitchBuy(); break; case TalkID::WitchSell: @@ -2306,7 +2306,7 @@ void StartStore(TalkID s) StoreNoRoom(); break; case TalkID::Confirm: - StoreConfirm(StoreItem); + StoreConfirm(tempItem); break; case TalkID::Boy: StartBoy(); @@ -2321,7 +2321,7 @@ void StartStore(TalkID s) StartStoryteller(); break; case TalkID::HealerBuy: - if (storenumh > 0) + if (currentItemIndex > 0) StartHealerBuy(); break; case TalkID::StorytellerIdentify: @@ -2335,7 +2335,7 @@ void StartStore(TalkID s) StartTalk(); break; case TalkID::StorytellerIdentifyShow: - StartStorytellerIdentifyShow(StoreItem); + StartStorytellerIdentifyShow(tempItem); break; case TalkID::Tavern: StartTavern(); @@ -2350,44 +2350,44 @@ void StartStore(TalkID s) break; } - stextsel = -1; + currentTextLine = -1; for (int i = 0; i < STORE_LINES; i++) { - if (stext[i].isSelectable()) { - stextsel = i; + if (textLine[i].isSelectable()) { + currentTextLine = i; break; } } - stextflag = s; + activeStore = s; } void DrawSText(const Surface &out) { - if (!stextsize) + if (!isTextFullSize) DrawSTextBack(out); else DrawQTextBack(out); - if (stextscrl) { - switch (stextflag) { + if (hasScrollbar) { + switch (activeStore) { case TalkID::SmithBuy: - ScrollSmithBuy(stextsval); + ScrollSmithBuy(scrollPos); break; case TalkID::SmithSell: case TalkID::SmithRepair: case TalkID::WitchSell: case TalkID::WitchRecharge: case TalkID::StorytellerIdentify: - ScrollSmithSell(stextsval); + ScrollSmithSell(scrollPos); break; case TalkID::WitchBuy: - ScrollWitchBuy(stextsval); + ScrollWitchBuy(scrollPos); break; case TalkID::HealerBuy: - ScrollHealerBuy(stextsval); + ScrollHealerBuy(scrollPos); break; case TalkID::SmithPremiumBuy: - ScrollSmithPremiumBuy(stextsval); + ScrollSmithPremiumBuy(scrollPos); break; default: break; @@ -2397,17 +2397,17 @@ void DrawSText(const Surface &out) CalculateLineHeights(); const Point uiPosition = GetUIRectangle().position; for (int i = 0; i < STORE_LINES; i++) { - if (stext[i].isDivider()) - DrawSLine(out, uiPosition.y + PaddingTop + stext[i].y + TextHeight() / 2); - else if (stext[i].hasText()) - PrintSString(out, stext[i]._sx, i, stext[i].text, stext[i].flags, stext[i]._sval, stext[i].cursId, stext[i].cursIndent); + if (textLine[i].isDivider()) + DrawSLine(out, uiPosition.y + PaddingTop + textLine[i].y + TextHeight() / 2); + else if (textLine[i].hasText()) + PrintSString(out, textLine[i]._sx, i, textLine[i].text, textLine[i].flags, textLine[i]._sval, textLine[i].cursId, textLine[i].cursIndent); } - if (RenderGold) { + if (renderGold) { PrintSString(out, 28, 1, fmt::format(fmt::runtime(_("Your gold: {:s}")), FormatInteger(TotalPlayerGold())).c_str(), UiFlags::ColorWhitegold | UiFlags::AlignRight); } - if (stextscrl) + if (hasScrollbar) DrawSSlider(out, 4, 20); } @@ -2420,7 +2420,7 @@ void StoreESC() return; } - switch (stextflag) { + switch (activeStore) { case TalkID::Smith: case TalkID::Witch: case TalkID::Boy: @@ -2430,47 +2430,47 @@ void StoreESC() case TalkID::Tavern: case TalkID::Drunk: case TalkID::Barmaid: - stextflag = TalkID::None; + activeStore = TalkID::None; break; case TalkID::Gossip: - StartStore(stextshold); - stextsel = stextlhold; + StartStore(oldActiveStore); + currentTextLine = oldTextLine; break; case TalkID::SmithBuy: StartStore(TalkID::Smith); - stextsel = 12; + currentTextLine = 12; break; case TalkID::SmithPremiumBuy: StartStore(TalkID::Smith); - stextsel = 14; + currentTextLine = 14; break; case TalkID::SmithSell: StartStore(TalkID::Smith); - stextsel = 16; + currentTextLine = 16; break; case TalkID::SmithRepair: StartStore(TalkID::Smith); - stextsel = 18; + currentTextLine = 18; break; case TalkID::WitchBuy: StartStore(TalkID::Witch); - stextsel = 14; + currentTextLine = 14; break; case TalkID::WitchSell: StartStore(TalkID::Witch); - stextsel = 16; + currentTextLine = 16; break; case TalkID::WitchRecharge: StartStore(TalkID::Witch); - stextsel = 18; + currentTextLine = 18; break; case TalkID::HealerBuy: StartStore(TalkID::Healer); - stextsel = 14; + currentTextLine = 14; break; case TalkID::StorytellerIdentify: StartStore(TalkID::Storyteller); - stextsel = 14; + currentTextLine = 14; break; case TalkID::StorytellerIdentifyShow: StartStore(TalkID::StorytellerIdentify); @@ -2478,9 +2478,9 @@ void StoreESC() case TalkID::NoMoney: case TalkID::NoRoom: case TalkID::Confirm: - StartStore(stextshold); - stextsel = stextlhold; - stextsval = stextvhold; + StartStore(oldActiveStore); + currentTextLine = oldTextLine; + scrollPos = oldScrollPos; break; case TalkID::None: break; @@ -2490,85 +2490,85 @@ void StoreESC() void StoreUp() { PlaySFX(SfxID::MenuMove); - if (stextsel == -1) { + if (currentTextLine == -1) { return; } - if (stextscrl) { - if (stextsel == stextup) { - if (stextsval != 0) - stextsval--; + if (hasScrollbar) { + if (currentTextLine == previousScrollPos) { + if (scrollPos != 0) + scrollPos--; return; } - stextsel--; - while (!stext[stextsel].isSelectable()) { - if (stextsel == 0) - stextsel = STORE_LINES - 1; + currentTextLine--; + while (!textLine[currentTextLine].isSelectable()) { + if (currentTextLine == 0) + currentTextLine = STORE_LINES - 1; else - stextsel--; + currentTextLine--; } return; } - if (stextsel == 0) - stextsel = STORE_LINES - 1; + if (currentTextLine == 0) + currentTextLine = STORE_LINES - 1; else - stextsel--; + currentTextLine--; - while (!stext[stextsel].isSelectable()) { - if (stextsel == 0) - stextsel = STORE_LINES - 1; + while (!textLine[currentTextLine].isSelectable()) { + if (currentTextLine == 0) + currentTextLine = STORE_LINES - 1; else - stextsel--; + currentTextLine--; } } void StoreDown() { PlaySFX(SfxID::MenuMove); - if (stextsel == -1) { + if (currentTextLine == -1) { return; } - if (stextscrl) { - if (stextsel == stextdown) { - if (stextsval < stextsmax) - stextsval++; + if (hasScrollbar) { + if (currentTextLine == nextScrollPos) { + if (scrollPos < numTextLines) + scrollPos++; return; } - stextsel++; - while (!stext[stextsel].isSelectable()) { - if (stextsel == STORE_LINES - 1) - stextsel = 0; + currentTextLine++; + while (!textLine[currentTextLine].isSelectable()) { + if (currentTextLine == STORE_LINES - 1) + currentTextLine = 0; else - stextsel++; + currentTextLine++; } return; } - if (stextsel == STORE_LINES - 1) - stextsel = 0; + if (currentTextLine == STORE_LINES - 1) + currentTextLine = 0; else - stextsel++; + currentTextLine++; - while (!stext[stextsel].isSelectable()) { - if (stextsel == STORE_LINES - 1) - stextsel = 0; + while (!textLine[currentTextLine].isSelectable()) { + if (currentTextLine == STORE_LINES - 1) + currentTextLine = 0; else - stextsel++; + currentTextLine++; } } void StorePrior() { PlaySFX(SfxID::MenuMove); - if (stextsel != -1 && stextscrl) { - if (stextsel == stextup) { - stextsval = std::max(stextsval - 4, 0); + if (currentTextLine != -1 && hasScrollbar) { + if (currentTextLine == previousScrollPos) { + scrollPos = std::max(scrollPos - 4, 0); } else { - stextsel = stextup; + currentTextLine = previousScrollPos; } } } @@ -2576,14 +2576,14 @@ void StorePrior() void StoreNext() { PlaySFX(SfxID::MenuMove); - if (stextsel != -1 && stextscrl) { - if (stextsel == stextdown) { - if (stextsval < stextsmax) - stextsval += 4; - if (stextsval > stextsmax) - stextsval = stextsmax; + if (currentTextLine != -1 && hasScrollbar) { + if (currentTextLine == nextScrollPos) { + if (scrollPos < numTextLines) + scrollPos += 4; + if (scrollPos > numTextLines) + scrollPos = numTextLines; } else { - stextsel = stextdown; + currentTextLine = nextScrollPos; } } } @@ -2614,7 +2614,7 @@ void StoreEnter() } PlaySFX(SfxID::MenuSelect); - switch (stextflag) { + switch (activeStore) { case TalkID::Smith: SmithEnter(); break; @@ -2644,12 +2644,12 @@ void StoreEnter() break; case TalkID::NoMoney: case TalkID::NoRoom: - StartStore(stextshold); - stextsel = stextlhold; - stextsval = stextvhold; + StartStore(oldActiveStore); + currentTextLine = oldTextLine; + scrollPos = oldScrollPos; break; case TalkID::Confirm: - ConfirmEnter(StoreItem); + ConfirmEnter(tempItem); break; case TalkID::Boy: BoyEnter(); @@ -2695,14 +2695,14 @@ void CheckStoreBtn() const Rectangle windowRect { { uiPosition.x + 344, uiPosition.y + PaddingTop - 7 }, { 271, 303 } }; const Rectangle windowRectFull { { uiPosition.x + 24, uiPosition.y + PaddingTop - 7 }, { 591, 303 } }; - if (!stextsize) { + if (!isTextFullSize) { if (!windowRect.contains(MousePosition)) { - while (stextflag != TalkID::None) + while (activeStore != TalkID::None) StoreESC(); } } else { if (!windowRectFull.contains(MousePosition)) { - while (stextflag != TalkID::None) + while (activeStore != TalkID::None) StoreESC(); } } @@ -2711,26 +2711,26 @@ void CheckStoreBtn() qtextflag = false; if (leveltype == DTYPE_TOWN) stream_stop(); - } else if (stextsel != -1) { + } else if (currentTextLine != -1) { const int relativeY = MousePosition.y - (uiPosition.y + PaddingTop); - if (stextscrl && MousePosition.x > 600 + uiPosition.x) { + if (hasScrollbar && MousePosition.x > 600 + uiPosition.x) { // Scroll bar is always measured in terms of the small line height. int y = relativeY / SmallLineHeight; if (y == 4) { - if (stextscrlubtn <= 0) { + if (countdownScrollUp <= 0) { StoreUp(); - stextscrlubtn = 10; + countdownScrollUp = 10; } else { - stextscrlubtn--; + countdownScrollUp--; } } if (y == 20) { - if (stextscrldbtn <= 0) { + if (countdownScrollDown <= 0) { StoreDown(); - stextscrldbtn = 10; + countdownScrollDown = 10; } else { - stextscrldbtn--; + countdownScrollDown--; } } return; @@ -2740,23 +2740,23 @@ void CheckStoreBtn() // Large small fonts draw beyond LineHeight. Check if the click was on the overflow text. if (IsSmallFontTall() && y > 0 && y < STORE_LINES - && stext[y - 1].hasText() && !stext[y].hasText() - && relativeY < stext[y - 1].y + LargeTextHeight) { + && textLine[y - 1].hasText() && !textLine[y].hasText() + && relativeY < textLine[y - 1].y + LargeTextHeight) { --y; } if (y >= 5) { if (y >= BackButtonLine() + 1) y = BackButtonLine(); - if (stextscrl && y <= 20 && !stext[y].isSelectable()) { - if (stext[y - 2].isSelectable()) { + if (hasScrollbar && y <= 20 && !textLine[y].isSelectable()) { + if (textLine[y - 2].isSelectable()) { y -= 2; - } else if (stext[y - 1].isSelectable()) { + } else if (textLine[y - 1].isSelectable()) { y--; } } - if (stext[y].isSelectable() || (stextscrl && y == BackButtonLine())) { - stextsel = y; + if (textLine[y].isSelectable() || (hasScrollbar && y == BackButtonLine())) { + currentTextLine = y; StoreEnter(); } } @@ -2765,8 +2765,8 @@ void CheckStoreBtn() void ReleaseStoreBtn() { - stextscrlubtn = -1; - stextscrldbtn = -1; + countdownScrollUp = -1; + countdownScrollDown = -1; } } // namespace devilution diff --git a/Source/stores.h b/Source/stores.h index 631ca9a285a..4f5ea696035 100644 --- a/Source/stores.h +++ b/Source/stores.h @@ -49,34 +49,34 @@ enum class TalkID : uint8_t { }; /** Currently active store */ -extern TalkID stextflag; +extern TalkID activeStore; -/** Current index into storehidx/storehold */ -extern DVL_API_FOR_TEST int storenumh; +/** Current index into playerItemIndexes/playerItem */ +extern DVL_API_FOR_TEST int currentItemIndex; /** Map of inventory items being presented in the store */ -extern int8_t storehidx[48]; +extern int8_t playerItemIndexes[48]; /** Copies of the players items as presented in the store */ -extern DVL_API_FOR_TEST Item storehold[48]; +extern DVL_API_FOR_TEST Item playerItem[48]; /** Items sold by Griswold */ -extern Item smithitem[SMITH_ITEMS]; +extern Item smithItem[SMITH_ITEMS]; /** Number of premium items for sale by Griswold */ -extern int numpremium; +extern int numPremiumItems; /** Base level of current premium items sold by Griswold */ -extern int premiumlevel; +extern int premiumItemLevel; /** Premium items sold by Griswold */ -extern Item premiumitems[SMITH_PREMIUM_ITEMS]; +extern Item premiumItem[SMITH_PREMIUM_ITEMS]; /** Items sold by Pepin */ -extern Item healitem[20]; +extern Item healerItem[20]; /** Items sold by Adria */ -extern Item witchitem[WITCH_ITEMS]; +extern Item witchItem[WITCH_ITEMS]; /** Current level of the item sold by Wirt */ -extern int boylevel; +extern int boyItemLevel; /** Current item sold by Wirt */ -extern Item boyitem; +extern Item boyItem; void AddStoreHoldRepair(Item *itm, int8_t i); diff --git a/Source/track.cpp b/Source/track.cpp index 3096da77cf4..2dc420a41e2 100644 --- a/Source/track.cpp +++ b/Source/track.cpp @@ -66,7 +66,7 @@ void RepeatMouseAction() if (sgbMouseDown == CLICK_NONE && ControllerActionHeld == GameActionType_NONE) return; - if (stextflag != TalkID::None) + if (activeStore != TalkID::None) return; if (LastMouseButtonAction == MouseActionType::None) diff --git a/test/fixtures/memory_map/game.txt b/test/fixtures/memory_map/game.txt index c6e6402ac3c..f1c98aac768 100644 --- a/test/fixtures/memory_map/game.txt +++ b/test/fixtures/memory_map/game.txt @@ -47,8 +47,8 @@ M_DL 12544 8 dLight M_DL 12544 8 dPreLight M_DL 1600 8 AutomapView M_DL 12544 8 dMissile -R 32 numpremium -R 32 premiumlevel +R 32 numPremiumItems +R 32 premiumItemLevel C_DA 6 item PremiumItems C_HF 15 item PremiumItems R 8 AutomapActive diff --git a/test/stores_test.cpp b/test/stores_test.cpp index b321cf87ecd..825207777c8 100644 --- a/test/stores_test.cpp +++ b/test/stores_test.cpp @@ -10,7 +10,7 @@ TEST(Stores, AddStoreHoldRepair_magic) { Item *item; - item = &storehold[0]; + item = &playerItem[0]; item->_iMaxDur = 60; item->_iDurability = item->_iMaxDur; @@ -23,18 +23,18 @@ TEST(Stores, AddStoreHoldRepair_magic) item->_ivalue = 2000; item->_iIvalue = 19000; item->_iDurability = i; - storenumh = 0; + currentItemIndex = 0; AddStoreHoldRepair(item, 0); - EXPECT_EQ(1, storenumh); + EXPECT_EQ(1, currentItemIndex); EXPECT_EQ(95 * (item->_iMaxDur - i) / 2, item->_ivalue); } item->_iDurability = 59; - storenumh = 0; + currentItemIndex = 0; item->_ivalue = 500; item->_iIvalue = 30; // To cheap to repair AddStoreHoldRepair(item, 0); - EXPECT_EQ(0, storenumh); + EXPECT_EQ(0, currentItemIndex); EXPECT_EQ(30, item->_iIvalue); EXPECT_EQ(500, item->_ivalue); } @@ -43,7 +43,7 @@ TEST(Stores, AddStoreHoldRepair_normal) { Item *item; - item = &storehold[0]; + item = &playerItem[0]; item->_iMaxDur = 20; item->_iDurability = item->_iMaxDur; @@ -56,18 +56,18 @@ TEST(Stores, AddStoreHoldRepair_normal) item->_ivalue = 2000; item->_iIvalue = item->_ivalue; item->_iDurability = i; - storenumh = 0; + currentItemIndex = 0; AddStoreHoldRepair(item, 0); - EXPECT_EQ(1, storenumh); + EXPECT_EQ(1, currentItemIndex); EXPECT_EQ(50 * (item->_iMaxDur - i), item->_ivalue); } item->_iDurability = 19; - storenumh = 0; + currentItemIndex = 0; item->_ivalue = 10; // less than 1 per dur item->_iIvalue = item->_ivalue; AddStoreHoldRepair(item, 0); - EXPECT_EQ(1, storenumh); + EXPECT_EQ(1, currentItemIndex); EXPECT_EQ(1, item->_ivalue); EXPECT_EQ(1, item->_iIvalue); } From 447fc0c79bb91bdccc95cc8818fa8d4a4c308e99 Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Fri, 20 Sep 2024 16:14:55 -0400 Subject: [PATCH 2/6] PascalCase --- Source/DiabloUI/credits.cpp | 8 +- Source/control.cpp | 2 +- Source/controls/game_controls.cpp | 8 +- Source/controls/plrctrls.cpp | 4 +- Source/controls/touch/event_handlers.cpp | 2 +- Source/controls/touch/renderers.cpp | 2 +- Source/diablo.cpp | 40 +- Source/engine/render/scrollrt.cpp | 4 +- Source/inv.cpp | 2 +- Source/items.cpp | 116 +-- Source/loadsave.cpp | 12 +- Source/msg.cpp | 6 +- Source/qol/chatlog.cpp | 2 +- Source/qol/itemlabels.cpp | 6 +- Source/qol/stash.cpp | 2 +- Source/stores.cpp | 1182 +++++++++++----------- Source/stores.h | 26 +- Source/track.cpp | 2 +- test/fixtures/memory_map/game.txt | 4 +- test/pack_test.cpp | 6 +- test/stores_test.cpp | 20 +- 21 files changed, 728 insertions(+), 728 deletions(-) diff --git a/Source/DiabloUI/credits.cpp b/Source/DiabloUI/credits.cpp index 17c343a32e8..a3fffeab368 100644 --- a/Source/DiabloUI/credits.cpp +++ b/Source/DiabloUI/credits.cpp @@ -33,9 +33,9 @@ const int LINE_H = 22; class CreditsRenderer { public: - CreditsRenderer(char const *const *text, std::size_t textLines) + CreditsRenderer(char const *const *text, std::size_t TextLines) { - for (size_t i = 0; i < textLines; i++) { + for (size_t i = 0; i < TextLines; i++) { std::string_view orgText = _(text[i]); uint16_t offset = 0; @@ -132,9 +132,9 @@ void CreditsRenderer::Render() } } -bool TextDialog(char const *const *text, std::size_t textLines) +bool TextDialog(char const *const *text, std::size_t TextLines) { - CreditsRenderer creditsRenderer(text, textLines); + CreditsRenderer creditsRenderer(text, TextLines); bool endMenu = false; if (IsHardwareCursor()) diff --git a/Source/control.cpp b/Source/control.cpp index 7766cb40bad..5af03b80cd5 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -686,7 +686,7 @@ bool IsLevelUpButtonVisible() if (ControlMode == ControlTypes::VirtualGamepad) { return false; } - if (activeStore != TalkID::None || IsStashOpen) { + if (ActiveStore != TalkID::None || IsStashOpen) { return false; } if (QuestLogIsOpen && GetLeftPanel().contains(GetMainPanel().position + Displacement { 0, -74 })) { diff --git a/Source/controls/game_controls.cpp b/Source/controls/game_controls.cpp index ebd08d39bf9..9c6cfd3bb56 100644 --- a/Source/controls/game_controls.cpp +++ b/Source/controls/game_controls.cpp @@ -134,7 +134,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game if (ControllerActionHeld == GameActionType_NONE) { ControllerActionHeld = GameActionType_PRIMARY_ACTION; } - } else if (sgpCurrentMenu != nullptr || activeStore != TalkID::None || QuestLogIsOpen) { + } else if (sgpCurrentMenu != nullptr || ActiveStore != TalkID::None || QuestLogIsOpen) { *action = GameActionSendKey { SDLK_RETURN, false }; } else { *action = GameActionSendKey { SDLK_SPACE, false }; @@ -171,12 +171,12 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game return true; } if (VirtualGamepadState.healthButton.isHeld && VirtualGamepadState.healthButton.didStateChange) { - if (!QuestLogIsOpen && !SpellbookFlag && activeStore == TalkID::None) + if (!QuestLogIsOpen && !SpellbookFlag && ActiveStore == TalkID::None) *action = GameAction(GameActionType_USE_HEALTH_POTION); return true; } if (VirtualGamepadState.manaButton.isHeld && VirtualGamepadState.manaButton.didStateChange) { - if (!QuestLogIsOpen && !SpellbookFlag && activeStore == TalkID::None) + if (!QuestLogIsOpen && !SpellbookFlag && ActiveStore == TalkID::None) *action = GameAction(GameActionType_USE_MANA_POTION); return true; } @@ -196,7 +196,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game SDL_Keycode translation = SDLK_UNKNOWN; - if (gmenu_is_active() || activeStore != TalkID::None) + if (gmenu_is_active() || ActiveStore != TalkID::None) translation = TranslateControllerButtonToGameMenuKey(ctrlEvent.button); else if (inGameMenu) translation = TranslateControllerButtonToMenuKey(ctrlEvent.button); diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index dd37cbd89c0..65982b7d55f 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -65,7 +65,7 @@ quest_id pcursquest = Q_INVALID; */ bool InGameMenu() { - return activeStore != TalkID::None + return ActiveStore != TalkID::None || HelpFlag || ChatLogFlag || ChatFlag @@ -1347,7 +1347,7 @@ HandleLeftStickOrDPadFn GetLeftStickOrDPadGameUIHandler() if (QuestLogIsOpen) { return &QuestLogMove; } - if (activeStore != TalkID::None) { + if (ActiveStore != TalkID::None) { return &StoreMove; } return nullptr; diff --git a/Source/controls/touch/event_handlers.cpp b/Source/controls/touch/event_handlers.cpp index 0f4c9dde0fd..5e2b3906790 100644 --- a/Source/controls/touch/event_handlers.cpp +++ b/Source/controls/touch/event_handlers.cpp @@ -63,7 +63,7 @@ bool HandleGameMenuInteraction(const SDL_Event &event) bool HandleStoreInteraction(const SDL_Event &event) { - if (activeStore == TalkID::None) + if (ActiveStore == TalkID::None) return false; if (event.type == SDL_FINGERDOWN) CheckStoreBtn(); diff --git a/Source/controls/touch/renderers.cpp b/Source/controls/touch/renderers.cpp index 5a1d0fff2f1..6bbe710c4d8 100644 --- a/Source/controls/touch/renderers.cpp +++ b/Source/controls/touch/renderers.cpp @@ -430,7 +430,7 @@ VirtualGamepadButtonType PrimaryActionButtonRenderer::GetButtonType() VirtualGamepadButtonType PrimaryActionButtonRenderer::GetTownButtonType() { - if (activeStore != TalkID::None || pcursmonst != -1) + if (ActiveStore != TalkID::None || pcursmonst != -1) return GetTalkButtonType(virtualPadButton->isHeld); return GetBlankButtonType(virtualPadButton->isHeld); } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 46450c6e9e5..e50b62433bd 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -353,7 +353,7 @@ void LeftMouseDown(uint16_t modState) return; } - if (activeStore != TalkID::None) { + if (ActiveStore != TalkID::None) { CheckStoreBtn(); return; } @@ -417,7 +417,7 @@ void LeftMouseUp(uint16_t modState) } if (LevelButtonDown) CheckLevelButtonUp(); - if (activeStore != TalkID::None) + if (ActiveStore != TalkID::None) ReleaseStoreBtn(); } @@ -439,7 +439,7 @@ void RightMouseDown(bool isShiftHeld) doom_close(); return; } - if (activeStore != TalkID::None) + if (ActiveStore != TalkID::None) return; if (SpellSelectFlag) { SetSpell(); @@ -576,7 +576,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) if ((modState & KMOD_ALT) != 0) { sgOptions.Graphics.fullscreen.SetValue(!IsFullScreen()); SaveOptions(); - } else if (activeStore != TalkID::None) { + } else if (ActiveStore != TalkID::None) { StoreEnter(); } else if (QuestLogIsOpen) { QuestlogEnter(); @@ -585,7 +585,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) } return; case SDLK_UP: - if (activeStore != TalkID::None) { + if (ActiveStore != TalkID::None) { StoreUp(); } else if (QuestLogIsOpen) { QuestlogUp(); @@ -600,7 +600,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) } return; case SDLK_DOWN: - if (activeStore != TalkID::None) { + if (ActiveStore != TalkID::None) { StoreDown(); } else if (QuestLogIsOpen) { QuestlogDown(); @@ -615,14 +615,14 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) } return; case SDLK_PAGEUP: - if (activeStore != TalkID::None) { + if (ActiveStore != TalkID::None) { StorePrior(); } else if (ChatLogFlag) { ChatLogScrollTop(); } return; case SDLK_PAGEDOWN: - if (activeStore != TalkID::None) { + if (ActiveStore != TalkID::None) { StoreNext(); } else if (ChatLogFlag) { ChatLogScrollBottom(); @@ -643,7 +643,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) void HandleMouseButtonDown(Uint8 button, uint16_t modState) { - if (activeStore != TalkID::None && (button == SDL_BUTTON_X1 + if (ActiveStore != TalkID::None && (button == SDL_BUTTON_X1 #if !SDL_VERSION_ATLEAST(2, 0, 0) || button == 8 #endif @@ -752,7 +752,7 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState) #if SDL_VERSION_ATLEAST(2, 0, 0) case SDL_MOUSEWHEEL: if (event.wheel.y > 0) { // Up - if (activeStore != TalkID::None) { + if (ActiveStore != TalkID::None) { StoreUp(); } else if (QuestLogIsOpen) { QuestlogUp(); @@ -766,7 +766,7 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState) sgOptions.Keymapper.KeyPressed(MouseScrollUpButton); } } else if (event.wheel.y < 0) { // down - if (activeStore != TalkID::None) { + if (ActiveStore != TalkID::None) { StoreDown(); } else if (QuestLogIsOpen) { QuestlogDown(); @@ -1492,7 +1492,7 @@ void HelpKeyPressed() { if (HelpFlag) { HelpFlag = false; - } else if (activeStore != TalkID::None) { + } else if (ActiveStore != TalkID::None) { InfoString = StringOrView {}; AddInfoBoxString(_("No help available")); /// BUGFIX: message isn't displayed AddInfoBoxString(_("while in stores")); @@ -1516,7 +1516,7 @@ void HelpKeyPressed() void InventoryKeyPressed() { - if (activeStore != TalkID::None) + if (ActiveStore != TalkID::None) return; invflag = !invflag; if (!IsLeftPanelOpen() && CanPanelsCoverView()) { @@ -1537,7 +1537,7 @@ void InventoryKeyPressed() void CharacterSheetKeyPressed() { - if (activeStore != TalkID::None) + if (ActiveStore != TalkID::None) return; if (!IsRightPanelOpen() && CanPanelsCoverView()) { if (CharFlag) { // We are closing the character sheet @@ -1555,7 +1555,7 @@ void CharacterSheetKeyPressed() void QuestLogKeyPressed() { - if (activeStore != TalkID::None) + if (ActiveStore != TalkID::None) return; if (!QuestLogIsOpen) { StartQuestlog(); @@ -1580,7 +1580,7 @@ void QuestLogKeyPressed() void DisplaySpellsKeyPressed() { - if (activeStore != TalkID::None) + if (ActiveStore != TalkID::None) return; CloseCharPanel(); QuestLogIsOpen = false; @@ -1596,7 +1596,7 @@ void DisplaySpellsKeyPressed() void SpellBookKeyPressed() { - if (activeStore != TalkID::None) + if (ActiveStore != TalkID::None) return; SpellbookFlag = !SpellbookFlag; if (!IsLeftPanelOpen() && CanPanelsCoverView()) { @@ -1761,7 +1761,7 @@ void InitKeymapActions() SDLK_F3, [] { gamemenu_load_game(false); }, nullptr, - [&]() { return !gbIsMultiplayer && gbValidSaveFile && activeStore == TalkID::None && IsGameRunning(); }); + [&]() { return !gbIsMultiplayer && gbValidSaveFile && ActiveStore == TalkID::None && IsGameRunning(); }); #ifndef NOEXIT sgOptions.Keymapper.AddAction( "QuitGame", @@ -2328,7 +2328,7 @@ void InitPadmapActions() ControllerButton_NONE, [] { gamemenu_load_game(false); }, nullptr, - [&]() { return !gbIsMultiplayer && gbValidSaveFile && activeStore == TalkID::None && IsGameRunning(); }); + [&]() { return !gbIsMultiplayer && gbValidSaveFile && ActiveStore == TalkID::None && IsGameRunning(); }); sgOptions.Padmapper.AddAction( "Item Highlighting", N_("Item highlighting"), @@ -2778,7 +2778,7 @@ bool PressEscKey() rv = true; } - if (activeStore != TalkID::None) { + if (ActiveStore != TalkID::None) { StoreESC(); rv = true; } diff --git a/Source/engine/render/scrollrt.cpp b/Source/engine/render/scrollrt.cpp index 19b4e695dce..dcd4fde5bf7 100644 --- a/Source/engine/render/scrollrt.cpp +++ b/Source/engine/render/scrollrt.cpp @@ -613,7 +613,7 @@ void DrawItem(const Surface &out, int8_t itemIndex, Point targetBufferPosition, const Item &item = Items[itemIndex]; const ClxSprite sprite = item.AnimInfo.currentSprite(); const Point position = targetBufferPosition + item.getRenderingOffset(sprite); - if (activeStore == TalkID::None && (itemIndex == pcursitem || AutoMapShowItems)) { + if (ActiveStore == TalkID::None && (itemIndex == pcursitem || AutoMapShowItems)) { ClxDrawOutlineSkipColorZero(out, GetOutlineColor(item, false), position, sprite); } ClxDrawLight(out, position, sprite, lightTableIndex); @@ -1197,7 +1197,7 @@ void DrawView(const Surface &out, Point startPosition) DrawMonsterHealthBar(out); DrawFloatingNumbers(out, startPosition, offset); - if (activeStore != TalkID::None && !qtextflag) + if (ActiveStore != TalkID::None && !qtextflag) DrawSText(out); if (invflag) { DrawInv(out); diff --git a/Source/inv.cpp b/Source/inv.cpp index 87fc1d67495..02384c43bc4 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -2007,7 +2007,7 @@ bool UseInvItem(int cii) return true; if (pcurs != CURSOR_HAND) return true; - if (activeStore != TalkID::None) + if (ActiveStore != TalkID::None) return true; if (cii < INVITEM_INV_FIRST) return false; diff --git a/Source/items.cpp b/Source/items.cpp index 39f4fd3b3e7..f097d00e2ba 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1930,7 +1930,7 @@ _item_indexes RndPremiumItem(const Player &player, int minlvl, int maxlvl) return RndVendorItem(player, minlvl, maxlvl); } -void SpawnOnePremium(Item &premiumItem, int plvl, const Player &player) +void SpawnOnePremium(Item &PremiumItems, int plvl, const Player &player) { int strength = std::max(player.GetMaximumAttributeValue(CharacterAttribute::Strength), player._pStrength); int dexterity = std::max(player.GetMaximumAttributeValue(CharacterAttribute::Dexterity), player._pDexterity); @@ -1944,20 +1944,20 @@ void SpawnOnePremium(Item &premiumItem, int plvl, const Player &player) int maxCount = 150; const bool unlimited = !gbIsHellfire; // TODO: This could lead to an infinite loop if a suitable item can never be generated for (int count = 0; unlimited || count < maxCount; count++) { - premiumItem = {}; - premiumItem._iSeed = AdvanceRndSeed(); - SetRndSeed(premiumItem._iSeed); + PremiumItems = {}; + PremiumItems._iSeed = AdvanceRndSeed(); + SetRndSeed(PremiumItems._iSeed); _item_indexes itemType = RndPremiumItem(player, plvl / 4, plvl); - GetItemAttrs(premiumItem, itemType, plvl); - GetItemBonus(player, premiumItem, plvl / 2, plvl, true, !gbIsHellfire); + GetItemAttrs(PremiumItems, itemType, plvl); + GetItemBonus(player, PremiumItems, plvl / 2, plvl, true, !gbIsHellfire); if (!gbIsHellfire) { - if (premiumItem._iIvalue <= 140000) { + if (PremiumItems._iIvalue <= 140000) { break; } } else { int itemValue = 0; - switch (premiumItem._itype) { + switch (PremiumItems._itype) { case ItemType::LightArmor: case ItemType::MediumArmor: case ItemType::HeavyArmor: { @@ -1979,7 +1979,7 @@ void SpawnOnePremium(Item &premiumItem, int plvl, const Player &player) case ItemType::Ring: case ItemType::Amulet: { const auto *const mostValuablePlayerItem = player.GetMostValuableItem( - [filterType = premiumItem._itype](const Item &item) { return item._itype == filterType; }); + [filterType = PremiumItems._itype](const Item &item) { return item._itype == filterType; }); itemValue = mostValuablePlayerItem == nullptr ? 0 : mostValuablePlayerItem->_iIvalue; break; @@ -1989,18 +1989,18 @@ void SpawnOnePremium(Item &premiumItem, int plvl, const Player &player) break; } itemValue = itemValue * 4 / 5; // avoids forced int > float > int conversion - if (premiumItem._iIvalue <= 200000 - && premiumItem._iMinStr <= strength - && premiumItem._iMinMag <= magic - && premiumItem._iMinDex <= dexterity - && premiumItem._iIvalue >= itemValue) { + if (PremiumItems._iIvalue <= 200000 + && PremiumItems._iMinStr <= strength + && PremiumItems._iMinMag <= magic + && PremiumItems._iMinDex <= dexterity + && PremiumItems._iIvalue >= itemValue) { break; } } } - premiumItem._iCreateInfo = plvl | CF_SMITHPREMIUM; - premiumItem._iIdentified = true; - premiumItem._iStatFlag = player.CanUseItem(premiumItem); + PremiumItems._iCreateInfo = plvl | CF_SMITHPREMIUM; + PremiumItems._iIdentified = true; + PremiumItems._iStatFlag = player.CanUseItem(PremiumItems); } bool WitchItemOk(const Player &player, const ItemData &item) @@ -4374,7 +4374,7 @@ void SpawnSmith(int lvl) int iCnt = RandomIntBetween(10, maxItems); for (int i = 0; i < iCnt; i++) { - Item &newItem = smithItem[i]; + Item &newItem = SmithItems[i]; do { newItem = {}; @@ -4388,40 +4388,40 @@ void SpawnSmith(int lvl) newItem._iIdentified = true; } for (int i = iCnt; i < SMITH_ITEMS; i++) - smithItem[i].clear(); + SmithItems[i].clear(); - SortVendor(smithItem + PinnedItemCount); + SortVendor(SmithItems + PinnedItemCount); } void SpawnPremium(const Player &player) { int lvl = player.getCharacterLevel(); int maxItems = gbIsHellfire ? SMITH_PREMIUM_ITEMS : 6; - if (numPremiumItems < maxItems) { + if (PremiumItemCount < maxItems) { for (int i = 0; i < maxItems; i++) { - if (premiumItem[i].isEmpty()) { - int plvl = premiumItemLevel + (gbIsHellfire ? premiumLvlAddHellfire[i] : premiumlvladd[i]); - SpawnOnePremium(premiumItem[i], plvl, player); + if (PremiumItems[i].isEmpty()) { + int plvl = PremiumItemLevel + (gbIsHellfire ? premiumLvlAddHellfire[i] : premiumlvladd[i]); + SpawnOnePremium(PremiumItems[i], plvl, player); } } - numPremiumItems = maxItems; + PremiumItemCount = maxItems; } - while (premiumItemLevel < lvl) { - premiumItemLevel++; + while (PremiumItemLevel < lvl) { + PremiumItemLevel++; if (gbIsHellfire) { // Discard first 3 items and shift next 10 - std::move(&premiumItem[3], &premiumItem[12] + 1, &premiumItem[0]); - SpawnOnePremium(premiumItem[10], premiumItemLevel + premiumLvlAddHellfire[10], player); - premiumItem[11] = premiumItem[13]; - SpawnOnePremium(premiumItem[12], premiumItemLevel + premiumLvlAddHellfire[12], player); - premiumItem[13] = premiumItem[14]; - SpawnOnePremium(premiumItem[14], premiumItemLevel + premiumLvlAddHellfire[14], player); + std::move(&PremiumItems[3], &PremiumItems[12] + 1, &PremiumItems[0]); + SpawnOnePremium(PremiumItems[10], PremiumItemLevel + premiumLvlAddHellfire[10], player); + PremiumItems[11] = PremiumItems[13]; + SpawnOnePremium(PremiumItems[12], PremiumItemLevel + premiumLvlAddHellfire[12], player); + PremiumItems[13] = PremiumItems[14]; + SpawnOnePremium(PremiumItems[14], PremiumItemLevel + premiumLvlAddHellfire[14], player); } else { // Discard first 2 items and shift next 3 - std::move(&premiumItem[2], &premiumItem[4] + 1, &premiumItem[0]); - SpawnOnePremium(premiumItem[3], premiumItemLevel + premiumlvladd[3], player); - premiumItem[4] = premiumItem[5]; - SpawnOnePremium(premiumItem[5], premiumItemLevel + premiumlvladd[5], player); + std::move(&PremiumItems[2], &PremiumItems[4] + 1, &PremiumItems[0]); + SpawnOnePremium(PremiumItems[3], PremiumItemLevel + premiumlvladd[3], player); + PremiumItems[4] = PremiumItems[5]; + SpawnOnePremium(PremiumItems[5], PremiumItemLevel + premiumlvladd[5], player); } } } @@ -4439,7 +4439,7 @@ void SpawnWitch(int lvl) const int maxValue = gbIsHellfire ? 200000 : 140000; for (int i = 0; i < WITCH_ITEMS; i++) { - Item &item = witchItem[i]; + Item &item = WitchItems[i]; item = {}; if (i < PinnedItemCount) { @@ -4490,7 +4490,7 @@ void SpawnWitch(int lvl) item._iIdentified = true; } - SortVendor(witchItem + PinnedItemCount); + SortVendor(WitchItems + PinnedItemCount); } void SpawnBoy(int lvl) @@ -4509,19 +4509,19 @@ void SpawnBoy(int lvl) dexterity += dexterity / 5; magic += magic / 5; - if (boyItemLevel >= (lvl / 2) && !boyItem.isEmpty()) + if (BoyItemLevel >= (lvl / 2) && !BoyItem.isEmpty()) return; do { keepgoing = false; - boyItem = {}; - boyItem._iSeed = AdvanceRndSeed(); - SetRndSeed(boyItem._iSeed); + BoyItem = {}; + BoyItem._iSeed = AdvanceRndSeed(); + SetRndSeed(BoyItem._iSeed); _item_indexes itype = RndBoyItem(*MyPlayer, lvl); - GetItemAttrs(boyItem, itype, lvl); - GetItemBonus(*MyPlayer, boyItem, lvl, 2 * lvl, true, true); + GetItemAttrs(BoyItem, itype, lvl); + GetItemBonus(*MyPlayer, BoyItem, lvl, 2 * lvl, true, true); if (!gbIsHellfire) { - if (boyItem._iIvalue > 90000) { + if (BoyItem._iIvalue > 90000) { keepgoing = true; // prevent breaking the do/while loop too early by failing hellfire's condition in while continue; } @@ -4530,7 +4530,7 @@ void SpawnBoy(int lvl) ivalue = 0; - ItemType itemType = boyItem._itype; + ItemType itemType = BoyItem._itype; switch (itemType) { case ItemType::LightArmor: @@ -4596,15 +4596,15 @@ void SpawnBoy(int lvl) } } while (keepgoing || (( - boyItem._iIvalue > 200000 - || boyItem._iMinStr > strength - || boyItem._iMinMag > magic - || boyItem._iMinDex > dexterity - || boyItem._iIvalue < ivalue) + BoyItem._iIvalue > 200000 + || BoyItem._iMinStr > strength + || BoyItem._iMinMag > magic + || BoyItem._iMinDex > dexterity + || BoyItem._iIvalue < ivalue) && count < 250)); - boyItem._iCreateInfo = lvl | CF_BOY; - boyItem._iIdentified = true; - boyItemLevel = lvl / 2; + BoyItem._iCreateInfo = lvl | CF_BOY; + BoyItem._iIdentified = true; + BoyItemLevel = lvl / 2; } void SpawnHealer(int lvl) @@ -4613,8 +4613,8 @@ void SpawnHealer(int lvl) constexpr std::array<_item_indexes, PinnedItemCount + 1> PinnedItemTypes = { IDI_HEAL, IDI_FULLHEAL, IDI_RESURRECT }; const auto itemCount = static_cast(RandomIntBetween(10, gbIsHellfire ? 19 : 17)); - for (size_t i = 0; i < sizeof(healerItem) / sizeof(healerItem[0]); ++i) { - Item &item = healerItem[i]; + for (size_t i = 0; i < sizeof(HealerItems) / sizeof(HealerItems[0]); ++i) { + Item &item = HealerItems[i]; item = {}; if (i < PinnedItemCount || (gbIsMultiplayer && i == PinnedItemCount)) { @@ -4638,7 +4638,7 @@ void SpawnHealer(int lvl) item._iIdentified = true; } - SortVendor(healerItem + PinnedItemCount); + SortVendor(HealerItems + PinnedItemCount); } void MakeGoldStack(Item &goldItem, int value) diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 0420dfbc146..9281fc07d49 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -867,7 +867,7 @@ void LoadItem(LoadHelper &file, Item &item) void LoadPremium(LoadHelper &file, int i) { - LoadAndValidateItemData(file, premiumItem[i]); + LoadAndValidateItemData(file, PremiumItems[i]); } void LoadQuest(LoadHelper *file, int i) @@ -2523,8 +2523,8 @@ void LoadGame(bool firstflag) memset(dLight, 0, sizeof(dLight)); } - numPremiumItems = file.NextBE(); - premiumItemLevel = file.NextBE(); + PremiumItemCount = file.NextBE(); + PremiumItemLevel = file.NextBE(); for (int i = 0; i < giNumberOfSmithPremiumItems; i++) LoadPremium(file, i); @@ -2786,11 +2786,11 @@ void SaveGameData(SaveWriter &saveWriter) } } - file.WriteBE(numPremiumItems); - file.WriteBE(premiumItemLevel); + file.WriteBE(PremiumItemCount); + file.WriteBE(PremiumItemLevel); for (int i = 0; i < giNumberOfSmithPremiumItems; i++) - SaveItem(file, premiumItem[i]); + SaveItem(file, PremiumItems[i]); file.WriteLE(AutomapActive ? 1 : 0); file.WriteBE(AutoMapScale); diff --git a/Source/msg.cpp b/Source/msg.cpp index 0a6e2e445bd..8e13ef13639 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1700,12 +1700,12 @@ size_t OnTalkXY(const TCmd *pCmd, Player &player) { const auto &message = *reinterpret_cast(pCmd); const Point position { message.x, message.y }; - const uint16_t townerIdx = SDL_SwapLE16(message.wParam1); + const uint16_t TownerIdx = SDL_SwapLE16(message.wParam1); - if (gbBufferMsgs != 1 && player.isOnActiveLevel() && InDungeonBounds(position) && townerIdx < NUM_TOWNERS) { + if (gbBufferMsgs != 1 && player.isOnActiveLevel() && InDungeonBounds(position) && TownerIdx < NUM_TOWNERS) { MakePlrPath(player, position, false); player.destAction = ACTION_TALK; - player.destParam1 = townerIdx; + player.destParam1 = TownerIdx; } return sizeof(message); diff --git a/Source/qol/chatlog.cpp b/Source/qol/chatlog.cpp index 47e5293482c..4fde2956aac 100644 --- a/Source/qol/chatlog.cpp +++ b/Source/qol/chatlog.cpp @@ -96,7 +96,7 @@ void ToggleChatLog() if (ChatLogFlag) { ChatLogFlag = false; } else { - activeStore = TalkID::None; + ActiveStore = TalkID::None; CloseInventory(); CloseCharPanel(); SpellbookFlag = false; diff --git a/Source/qol/itemlabels.cpp b/Source/qol/itemlabels.cpp index b43346311cd..6d0d78394f0 100644 --- a/Source/qol/itemlabels.cpp +++ b/Source/qol/itemlabels.cpp @@ -98,7 +98,7 @@ void ResetItemlabelHighlighted() bool IsHighlightingLabelsEnabled() { - return activeStore == TalkID::None && highlightKeyPressed != *sgOptions.Gameplay.showItemLabels; + return ActiveStore == TalkID::None && highlightKeyPressed != *sgOptions.Gameplay.showItemLabels; } void AddItemToLabelQueue(int id, Point position) @@ -193,7 +193,7 @@ void DrawItemNameLabels(const Surface &out) if (!gmenu_is_active() && PauseMode == 0 && !MyPlayerIsDead - && activeStore == TalkID::None + && ActiveStore == TalkID::None && IsMouseOverGameArea() && LastMouseButtonAction == MouseActionType::None) { isLabelHighlighted = true; @@ -201,7 +201,7 @@ void DrawItemNameLabels(const Surface &out) pcursitem = label.id; } } - if (pcursitem == label.id && activeStore == TalkID::None) + if (pcursitem == label.id && ActiveStore == TalkID::None) FillRect(clippedOut, label.pos.x, label.pos.y, label.width, labelHeight, PAL8_BLUE + 6); else DrawHalfTransparentRectTo(clippedOut, label.pos.x, label.pos.y, label.width, labelHeight); diff --git a/Source/qol/stash.cpp b/Source/qol/stash.cpp index 9e0299186c2..c4a5320871f 100644 --- a/Source/qol/stash.cpp +++ b/Source/qol/stash.cpp @@ -462,7 +462,7 @@ bool UseStashItem(uint16_t c) return true; if (pcurs != CURSOR_HAND) return true; - if (activeStore != TalkID::None) + if (ActiveStore != TalkID::None) return true; Item *item = &Stash.stashList[c]; diff --git a/Source/stores.cpp b/Source/stores.cpp index 315882334d4..588eec54595 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -32,38 +32,38 @@ namespace devilution { -TalkID activeStore; +TalkID ActiveStore; -int currentItemIndex; -int8_t playerItemIndexes[48]; -Item playerItem[48]; +int CurrentItemIndex; +int8_t PlayerItemIndexes[48]; +Item PlayerItems[48]; -Item smithItem[SMITH_ITEMS]; -int numPremiumItems; -int premiumItemLevel; -Item premiumItem[SMITH_PREMIUM_ITEMS]; +Item SmithItems[SMITH_ITEMS]; +int PremiumItemCount; +int PremiumItemLevel; +Item PremiumItems[SMITH_PREMIUM_ITEMS]; -Item healerItem[20]; +Item HealerItems[20]; -Item witchItem[WITCH_ITEMS]; +Item WitchItems[WITCH_ITEMS]; -int boyItemLevel; -Item boyItem; +int BoyItemLevel; +Item BoyItem; namespace { /** The current towner being interacted with */ -_talker_id townerId; +_talker_id TownerId; /** Is the current dialog full size */ -bool isTextFullSize; +bool IsTextFullSize; /** Number of text lines in the current dialog */ -int numTextLines; -/** Remember currently selected text line from textLine while displaying a dialog */ -int oldTextLine; -/** Currently selected text line from textLine */ -int currentTextLine; +int NumTextLines; +/** Remember currently selected text line from TextLine while displaying a dialog */ +int OldTextLine; +/** Currently selected text line from TextLine */ +int CurrentTextLine; struct STextStruct { enum Type : uint8_t { @@ -98,31 +98,31 @@ struct STextStruct { }; /** Text lines */ -STextStruct textLine[STORE_LINES]; +STextStruct TextLine[STORE_LINES]; /** Whether to render the player's gold amount in the top left */ -bool renderGold; +bool RenderGold; /** Does the current panel have a scrollbar */ -bool hasScrollbar; +bool HasScrollbar; /** Remember last scroll position */ -int oldScrollPos; +int OldScrollPos; /** Scroll position */ -int scrollPos; +int ScrollPos; /** Next scroll position */ -int nextScrollPos; +int NextScrollPos; /** Previous scroll position */ -int previousScrollPos; +int PreviousScrollPos; /** Countdown for the push state of the scroll up button */ -int8_t countdownScrollUp; +int8_t CountdownScrollUp; /** Countdown for the push state of the scroll down button */ -int8_t countdownScrollDown; +int8_t CountdownScrollDown; /** Remember current store while displaying a dialog */ -TalkID oldActiveStore; +TalkID OldActiveStore; /** Temporary item used to hold the item being traded */ -Item tempItem; +Item TempItem; /** Maps from towner IDs to NPC names. */ const char *const TownerNames[] = { @@ -159,7 +159,7 @@ constexpr int LargeTextHeight = 18; int BackButtonLine() { if (IsSmallFontTall()) { - return hasScrollbar ? 21 : 20; + return HasScrollbar ? 21 : 20; } return 22; } @@ -176,19 +176,19 @@ int TextHeight() void CalculateLineHeights() { - textLine[0].y = 0; + TextLine[0].y = 0; if (IsSmallFontTall()) { for (int i = 1; i < STORE_LINES; ++i) { // Space out consecutive text lines, unless they are both selectable (never the case currently). - if (textLine[i].hasText() && textLine[i - 1].hasText() && !(textLine[i].isSelectable() && textLine[i - 1].isSelectable())) { - textLine[i].y = textLine[i - 1].y + LargeTextHeight; + if (TextLine[i].hasText() && TextLine[i - 1].hasText() && !(TextLine[i].isSelectable() && TextLine[i - 1].isSelectable())) { + TextLine[i].y = TextLine[i - 1].y + LargeTextHeight; } else { - textLine[i].y = i * LargeLineHeight; + TextLine[i].y = i * LargeLineHeight; } } } else { for (int i = 1; i < STORE_LINES; ++i) { - textLine[i].y = i * SmallLineHeight; + TextLine[i].y = i * SmallLineHeight; } } } @@ -205,11 +205,11 @@ void DrawSSlider(const Surface &out, int y1, int y2) const Point uiPosition = GetUIRectangle().position; int yd1 = y1 * 12 + 44 + uiPosition.y; int yd2 = y2 * 12 + 44 + uiPosition.y; - if (countdownScrollUp != -1) + if (CountdownScrollUp != -1) ClxDraw(out, { uiPosition.x + 601, yd1 }, (*pSTextSlidCels)[11]); else ClxDraw(out, { uiPosition.x + 601, yd1 }, (*pSTextSlidCels)[9]); - if (countdownScrollDown != -1) + if (CountdownScrollDown != -1) ClxDraw(out, { uiPosition.x + 601, yd2 }, (*pSTextSlidCels)[10]); else ClxDraw(out, { uiPosition.x + 601, yd2 }, (*pSTextSlidCels)[8]); @@ -218,12 +218,12 @@ void DrawSSlider(const Surface &out, int y1, int y2) for (; yd3 < yd2; yd3 += 12) { ClxDraw(out, { uiPosition.x + 601, yd3 }, (*pSTextSlidCels)[13]); } - if (currentTextLine == BackButtonLine()) - yd3 = oldTextLine; + if (CurrentTextLine == BackButtonLine()) + yd3 = OldTextLine; else - yd3 = currentTextLine; - if (currentItemIndex > 1) - yd3 = 1000 * (scrollPos + ((yd3 - previousScrollPos) / 4)) / (currentItemIndex - 1) * (y2 * 12 - y1 * 12 - 24) / 1000; + yd3 = CurrentTextLine; + if (CurrentItemIndex > 1) + yd3 = 1000 * (ScrollPos + ((yd3 - PreviousScrollPos) / 4)) / (CurrentItemIndex - 1) * (y2 * 12 - y1 * 12 - 24) / 1000; else yd3 = 0; ClxDraw(out, { uiPosition.x + 601, (y1 + 1) * 12 + 44 + uiPosition.y + yd3 }, (*pSTextSlidCels)[12]); @@ -231,37 +231,37 @@ void DrawSSlider(const Surface &out, int y1, int y2) void AddSLine(size_t y) { - textLine[y]._sx = 0; - textLine[y]._syoff = 0; - textLine[y].text.clear(); - textLine[y].text.shrink_to_fit(); - textLine[y].type = STextStruct::Divider; - textLine[y].cursId = -1; - textLine[y].cursIndent = false; + TextLine[y]._sx = 0; + TextLine[y]._syoff = 0; + TextLine[y].text.clear(); + TextLine[y].text.shrink_to_fit(); + TextLine[y].type = STextStruct::Divider; + TextLine[y].cursId = -1; + TextLine[y].cursIndent = false; } void AddSTextVal(size_t y, int val) { - textLine[y]._sval = val; + TextLine[y]._sval = val; } void AddSText(uint8_t x, size_t y, std::string_view text, UiFlags flags, bool sel, int cursId = -1, bool cursIndent = false) { - textLine[y]._sx = x; - textLine[y]._syoff = 0; - textLine[y].text.clear(); - textLine[y].text.append(text); - textLine[y].flags = flags; - textLine[y].type = sel ? STextStruct::Selectable : STextStruct::Label; - textLine[y].cursId = cursId; - textLine[y].cursIndent = cursIndent; + TextLine[y]._sx = x; + TextLine[y]._syoff = 0; + TextLine[y].text.clear(); + TextLine[y].text.append(text); + TextLine[y].flags = flags; + TextLine[y].type = sel ? STextStruct::Selectable : STextStruct::Label; + TextLine[y].cursId = cursId; + TextLine[y].cursIndent = cursIndent; } void AddOptionsBackButton() { const int line = BackButtonLine(); AddSText(0, line, _("Back"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); - textLine[line]._syoff = IsSmallFontTall() ? 0 : 6; + TextLine[line]._syoff = IsSmallFontTall() ? 0 : 6; } void AddItemListBackButton(bool selectable = false) @@ -273,7 +273,7 @@ void AddItemListBackButton(bool selectable = false) } else { AddSLine(line - 1); AddSText(0, line, text, UiFlags::ColorWhite | UiFlags::AlignCenter, selectable); - textLine[line]._syoff = 6; + TextLine[line]._syoff = 6; } } @@ -351,7 +351,7 @@ bool StoreAutoPlace(Item &item, bool persistItem) void ScrollVendorStore(Item *itemData, int storeLimit, int idx, int selling = true) { ClearSText(5, 21); - previousScrollPos = 5; + PreviousScrollPos = 5; for (int l = 5; l < 20 && idx < storeLimit; l += 4) { const Item &item = itemData[idx]; @@ -360,24 +360,24 @@ void ScrollVendorStore(Item *itemData, int storeLimit, int idx, int selling = tr AddSText(20, l, item.getName(), itemColor, true, item._iCurs, true); AddSTextVal(l, item._iIdentified ? item._iIvalue : item._ivalue); PrintStoreItem(item, l + 1, itemColor, true); - nextScrollPos = l; + NextScrollPos = l; } else { l -= 4; } idx++; } if (selling) { - if (currentTextLine != -1 && !textLine[currentTextLine].isSelectable() && currentTextLine != BackButtonLine()) - currentTextLine = nextScrollPos; + if (CurrentTextLine != -1 && !TextLine[CurrentTextLine].isSelectable() && CurrentTextLine != BackButtonLine()) + CurrentTextLine = NextScrollPos; } else { - numTextLines = std::max(static_cast(storeLimit) - 4, 0); + NumTextLines = std::max(static_cast(storeLimit) - 4, 0); } } void StartSmith() { - isTextFullSize = false; - hasScrollbar = false; + IsTextFullSize = false; + HasScrollbar = false; AddSText(0, 1, _("Welcome to the"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 3, _("Blacksmith's shop"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 7, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); @@ -388,12 +388,12 @@ void StartSmith() AddSText(0, 18, _("Repair items"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSText(0, 20, _("Leave the shop"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSLine(5); - currentItemIndex = 20; + CurrentItemIndex = 20; } void ScrollSmithBuy(int idx) { - ScrollVendorStore(smithItem, static_cast(std::size(smithItem)), idx); + ScrollVendorStore(SmithItems, static_cast(std::size(SmithItems)), idx); } uint32_t TotalPlayerGold() @@ -409,67 +409,67 @@ bool PlayerCanAfford(int price) void StartSmithBuy() { - isTextFullSize = true; - hasScrollbar = true; - scrollPos = 0; + IsTextFullSize = true; + HasScrollbar = true; + ScrollPos = 0; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("I have these items for sale:"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollSmithBuy(scrollPos); + ScrollSmithBuy(ScrollPos); AddItemListBackButton(); - currentItemIndex = 0; - for (Item &item : smithItem) { + CurrentItemIndex = 0; + for (Item &item : SmithItems) { if (item.isEmpty()) continue; item._iStatFlag = MyPlayer->CanUseItem(item); - currentItemIndex++; + CurrentItemIndex++; } - numTextLines = std::max(currentItemIndex - 4, 0); + NumTextLines = std::max(CurrentItemIndex - 4, 0); } void ScrollSmithPremiumBuy(int boughtitems) { int idx = 0; for (; boughtitems != 0; idx++) { - if (!premiumItem[idx].isEmpty()) + if (!PremiumItems[idx].isEmpty()) boughtitems--; } - ScrollVendorStore(premiumItem, static_cast(std::size(premiumItem)), idx); + ScrollVendorStore(PremiumItems, static_cast(std::size(PremiumItems)), idx); } bool StartSmithPremiumBuy() { - currentItemIndex = 0; - for (Item &item : premiumItem) { + CurrentItemIndex = 0; + for (Item &item : PremiumItems) { if (item.isEmpty()) continue; item._iStatFlag = MyPlayer->CanUseItem(item); - currentItemIndex++; + CurrentItemIndex++; } - if (currentItemIndex == 0) { + if (CurrentItemIndex == 0) { StartStore(TalkID::Smith); - currentTextLine = 14; + CurrentTextLine = 14; return false; } - isTextFullSize = true; - hasScrollbar = true; - scrollPos = 0; + IsTextFullSize = true; + HasScrollbar = true; + ScrollPos = 0; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("I have these premium items for sale:"), UiFlags::ColorWhitegold, false); AddSLine(3); AddItemListBackButton(); - numTextLines = std::max(currentItemIndex - 4, 0); + NumTextLines = std::max(CurrentItemIndex - 4, 0); - ScrollSmithPremiumBuy(scrollPos); + ScrollSmithPremiumBuy(ScrollPos); return true; } @@ -506,73 +506,73 @@ bool SmithSellOk(int i) void ScrollSmithSell(int idx) { - ScrollVendorStore(playerItem, currentItemIndex, idx, false); + ScrollVendorStore(PlayerItems, CurrentItemIndex, idx, false); } void StartSmithSell() { - isTextFullSize = true; + IsTextFullSize = true; bool sellOk = false; - currentItemIndex = 0; + CurrentItemIndex = 0; - for (auto &item : playerItem) { + for (auto &item : PlayerItems) { item.clear(); } const Player &myPlayer = *MyPlayer; for (int8_t i = 0; i < myPlayer._pNumInv; i++) { - if (currentItemIndex >= 48) + if (CurrentItemIndex >= 48) break; if (SmithSellOk(i)) { sellOk = true; - playerItem[currentItemIndex] = myPlayer.InvList[i]; + PlayerItems[CurrentItemIndex] = myPlayer.InvList[i]; - if (playerItem[currentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && playerItem[currentItemIndex]._iIdentified) - playerItem[currentItemIndex]._ivalue = playerItem[currentItemIndex]._iIvalue; + if (PlayerItems[CurrentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && PlayerItems[CurrentItemIndex]._iIdentified) + PlayerItems[CurrentItemIndex]._ivalue = PlayerItems[CurrentItemIndex]._iIvalue; - playerItem[currentItemIndex]._ivalue = std::max(playerItem[currentItemIndex]._ivalue / 4, 1); - playerItem[currentItemIndex]._iIvalue = playerItem[currentItemIndex]._ivalue; - playerItemIndexes[currentItemIndex] = i; - currentItemIndex++; + PlayerItems[CurrentItemIndex]._ivalue = std::max(PlayerItems[CurrentItemIndex]._ivalue / 4, 1); + PlayerItems[CurrentItemIndex]._iIvalue = PlayerItems[CurrentItemIndex]._ivalue; + PlayerItemIndexes[CurrentItemIndex] = i; + CurrentItemIndex++; } } for (int i = 0; i < MaxBeltItems; i++) { - if (currentItemIndex >= 48) + if (CurrentItemIndex >= 48) break; if (SmithSellOk(-(i + 1))) { sellOk = true; - playerItem[currentItemIndex] = myPlayer.SpdList[i]; + PlayerItems[CurrentItemIndex] = myPlayer.SpdList[i]; - if (playerItem[currentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && playerItem[currentItemIndex]._iIdentified) - playerItem[currentItemIndex]._ivalue = playerItem[currentItemIndex]._iIvalue; + if (PlayerItems[CurrentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && PlayerItems[CurrentItemIndex]._iIdentified) + PlayerItems[CurrentItemIndex]._ivalue = PlayerItems[CurrentItemIndex]._iIvalue; - playerItem[currentItemIndex]._ivalue = std::max(playerItem[currentItemIndex]._ivalue / 4, 1); - playerItem[currentItemIndex]._iIvalue = playerItem[currentItemIndex]._ivalue; - playerItemIndexes[currentItemIndex] = -(i + 1); - currentItemIndex++; + PlayerItems[CurrentItemIndex]._ivalue = std::max(PlayerItems[CurrentItemIndex]._ivalue / 4, 1); + PlayerItems[CurrentItemIndex]._iIvalue = PlayerItems[CurrentItemIndex]._ivalue; + PlayerItemIndexes[CurrentItemIndex] = -(i + 1); + CurrentItemIndex++; } } if (!sellOk) { - hasScrollbar = false; + HasScrollbar = false; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("You have nothing I want."), UiFlags::ColorWhitegold, false); AddSLine(3); AddItemListBackButton(/*selectable=*/true); return; } - hasScrollbar = true; - scrollPos = 0; - numTextLines = myPlayer._pNumInv; + HasScrollbar = true; + ScrollPos = 0; + NumTextLines = myPlayer._pNumInv; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("Which item is for sale?"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollSmithSell(scrollPos); + ScrollSmithSell(ScrollPos); AddItemListBackButton(); } @@ -597,10 +597,10 @@ bool SmithRepairOk(int i) void StartSmithRepair() { - isTextFullSize = true; - currentItemIndex = 0; + IsTextFullSize = true; + CurrentItemIndex = 0; - for (auto &item : playerItem) { + for (auto &item : PlayerItems) { item.clear(); } @@ -627,32 +627,32 @@ void StartSmithRepair() } for (int i = 0; i < myPlayer._pNumInv; i++) { - if (currentItemIndex >= 48) + if (CurrentItemIndex >= 48) break; if (SmithRepairOk(i)) { AddStoreHoldRepair(&myPlayer.InvList[i], i); } } - if (currentItemIndex == 0) { - hasScrollbar = false; + if (CurrentItemIndex == 0) { + HasScrollbar = false; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("You have nothing to repair."), UiFlags::ColorWhitegold, false); AddSLine(3); AddItemListBackButton(/*selectable=*/true); return; } - hasScrollbar = true; - scrollPos = 0; - numTextLines = myPlayer._pNumInv; + HasScrollbar = true; + ScrollPos = 0; + NumTextLines = myPlayer._pNumInv; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("Repair which item?"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollSmithSell(scrollPos); + ScrollSmithSell(ScrollPos); AddItemListBackButton(); } @@ -674,8 +674,8 @@ void FillManaPlayer() void StartWitch() { FillManaPlayer(); - isTextFullSize = false; - hasScrollbar = false; + IsTextFullSize = false; + HasScrollbar = false; AddSText(0, 2, _("Witch's shack"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 9, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 12, _("Talk to Adria"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); @@ -684,12 +684,12 @@ void StartWitch() AddSText(0, 18, _("Recharge staves"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSText(0, 20, _("Leave the shack"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSLine(5); - currentItemIndex = 20; + CurrentItemIndex = 20; } void ScrollWitchBuy(int idx) { - ScrollVendorStore(witchItem, static_cast(std::size(witchItem)), idx); + ScrollVendorStore(WitchItems, static_cast(std::size(WitchItems)), idx); } void WitchBookLevel(Item &bookItem) @@ -710,27 +710,27 @@ void WitchBookLevel(Item &bookItem) void StartWitchBuy() { - isTextFullSize = true; - hasScrollbar = true; - scrollPos = 0; - numTextLines = 20; + IsTextFullSize = true; + HasScrollbar = true; + ScrollPos = 0; + NumTextLines = 20; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("I have these items for sale:"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollWitchBuy(scrollPos); + ScrollWitchBuy(ScrollPos); AddItemListBackButton(); - currentItemIndex = 0; - for (Item &item : witchItem) { + CurrentItemIndex = 0; + for (Item &item : WitchItems) { if (item.isEmpty()) continue; WitchBookLevel(item); item._iStatFlag = MyPlayer->CanUseItem(item); - currentItemIndex++; + CurrentItemIndex++; } - numTextLines = std::max(currentItemIndex - 4, 0); + NumTextLines = std::max(CurrentItemIndex - 4, 0); } bool WitchSellOk(int i) @@ -761,54 +761,54 @@ bool WitchSellOk(int i) void StartWitchSell() { - isTextFullSize = true; + IsTextFullSize = true; bool sellok = false; - currentItemIndex = 0; + CurrentItemIndex = 0; - for (auto &item : playerItem) { + for (auto &item : PlayerItems) { item.clear(); } const Player &myPlayer = *MyPlayer; for (int i = 0; i < myPlayer._pNumInv; i++) { - if (currentItemIndex >= 48) + if (CurrentItemIndex >= 48) break; if (WitchSellOk(i)) { sellok = true; - playerItem[currentItemIndex] = myPlayer.InvList[i]; + PlayerItems[CurrentItemIndex] = myPlayer.InvList[i]; - if (playerItem[currentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && playerItem[currentItemIndex]._iIdentified) - playerItem[currentItemIndex]._ivalue = playerItem[currentItemIndex]._iIvalue; + if (PlayerItems[CurrentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && PlayerItems[CurrentItemIndex]._iIdentified) + PlayerItems[CurrentItemIndex]._ivalue = PlayerItems[CurrentItemIndex]._iIvalue; - playerItem[currentItemIndex]._ivalue = std::max(playerItem[currentItemIndex]._ivalue / 4, 1); - playerItem[currentItemIndex]._iIvalue = playerItem[currentItemIndex]._ivalue; - playerItemIndexes[currentItemIndex] = i; - currentItemIndex++; + PlayerItems[CurrentItemIndex]._ivalue = std::max(PlayerItems[CurrentItemIndex]._ivalue / 4, 1); + PlayerItems[CurrentItemIndex]._iIvalue = PlayerItems[CurrentItemIndex]._ivalue; + PlayerItemIndexes[CurrentItemIndex] = i; + CurrentItemIndex++; } } for (int i = 0; i < MaxBeltItems; i++) { - if (currentItemIndex >= 48) + if (CurrentItemIndex >= 48) break; if (!myPlayer.SpdList[i].isEmpty() && WitchSellOk(-(i + 1))) { sellok = true; - playerItem[currentItemIndex] = myPlayer.SpdList[i]; + PlayerItems[CurrentItemIndex] = myPlayer.SpdList[i]; - if (playerItem[currentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && playerItem[currentItemIndex]._iIdentified) - playerItem[currentItemIndex]._ivalue = playerItem[currentItemIndex]._iIvalue; + if (PlayerItems[CurrentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && PlayerItems[CurrentItemIndex]._iIdentified) + PlayerItems[CurrentItemIndex]._ivalue = PlayerItems[CurrentItemIndex]._iIvalue; - playerItem[currentItemIndex]._ivalue = std::max(playerItem[currentItemIndex]._ivalue / 4, 1); - playerItem[currentItemIndex]._iIvalue = playerItem[currentItemIndex]._ivalue; - playerItemIndexes[currentItemIndex] = -(i + 1); - currentItemIndex++; + PlayerItems[CurrentItemIndex]._ivalue = std::max(PlayerItems[CurrentItemIndex]._ivalue / 4, 1); + PlayerItems[CurrentItemIndex]._iIvalue = PlayerItems[CurrentItemIndex]._ivalue; + PlayerItemIndexes[CurrentItemIndex] = -(i + 1); + CurrentItemIndex++; } } if (!sellok) { - hasScrollbar = false; + HasScrollbar = false; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("You have nothing I want."), UiFlags::ColorWhitegold, false); AddSLine(3); @@ -816,14 +816,14 @@ void StartWitchSell() return; } - hasScrollbar = true; - scrollPos = 0; - numTextLines = myPlayer._pNumInv; + HasScrollbar = true; + ScrollPos = 0; + NumTextLines = myPlayer._pNumInv; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("Which item is for sale?"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollSmithSell(scrollPos); + ScrollSmithSell(ScrollPos); AddItemListBackButton(); } @@ -844,21 +844,21 @@ bool WitchRechargeOk(int i) void AddStoreHoldRecharge(Item itm, int8_t i) { - playerItem[currentItemIndex] = itm; - playerItem[currentItemIndex]._ivalue += GetSpellData(itm._iSpell).staffCost(); - playerItem[currentItemIndex]._ivalue = playerItem[currentItemIndex]._ivalue * (playerItem[currentItemIndex]._iMaxCharges - playerItem[currentItemIndex]._iCharges) / (playerItem[currentItemIndex]._iMaxCharges * 2); - playerItem[currentItemIndex]._iIvalue = playerItem[currentItemIndex]._ivalue; - playerItemIndexes[currentItemIndex] = i; - currentItemIndex++; + PlayerItems[CurrentItemIndex] = itm; + PlayerItems[CurrentItemIndex]._ivalue += GetSpellData(itm._iSpell).staffCost(); + PlayerItems[CurrentItemIndex]._ivalue = PlayerItems[CurrentItemIndex]._ivalue * (PlayerItems[CurrentItemIndex]._iMaxCharges - PlayerItems[CurrentItemIndex]._iCharges) / (PlayerItems[CurrentItemIndex]._iMaxCharges * 2); + PlayerItems[CurrentItemIndex]._iIvalue = PlayerItems[CurrentItemIndex]._ivalue; + PlayerItemIndexes[CurrentItemIndex] = i; + CurrentItemIndex++; } void StartWitchRecharge() { - isTextFullSize = true; + IsTextFullSize = true; bool rechargeok = false; - currentItemIndex = 0; + CurrentItemIndex = 0; - for (auto &item : playerItem) { + for (auto &item : PlayerItems) { item.clear(); } @@ -871,7 +871,7 @@ void StartWitchRecharge() } for (int i = 0; i < myPlayer._pNumInv; i++) { - if (currentItemIndex >= 48) + if (CurrentItemIndex >= 48) break; if (WitchRechargeOk(i)) { rechargeok = true; @@ -880,48 +880,48 @@ void StartWitchRecharge() } if (!rechargeok) { - hasScrollbar = false; + HasScrollbar = false; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("You have nothing to recharge."), UiFlags::ColorWhitegold, false); AddSLine(3); AddItemListBackButton(/*selectable=*/true); return; } - hasScrollbar = true; - scrollPos = 0; - numTextLines = myPlayer._pNumInv; + HasScrollbar = true; + ScrollPos = 0; + NumTextLines = myPlayer._pNumInv; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("Recharge which item?"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollSmithSell(scrollPos); + ScrollSmithSell(ScrollPos); AddItemListBackButton(); } void StoreNoMoney() { - StartStore(oldActiveStore); - hasScrollbar = false; - isTextFullSize = true; - renderGold = true; + StartStore(OldActiveStore); + HasScrollbar = false; + IsTextFullSize = true; + RenderGold = true; ClearSText(5, 23); AddSText(0, 14, _("You do not have enough gold"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); } void StoreNoRoom() { - StartStore(oldActiveStore); - hasScrollbar = false; + StartStore(OldActiveStore); + HasScrollbar = false; ClearSText(5, 23); AddSText(0, 14, _("You do not have enough room in inventory"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); } void StoreConfirm(Item &item) { - StartStore(oldActiveStore); - hasScrollbar = false; + StartStore(OldActiveStore); + HasScrollbar = false; ClearSText(5, 23); UiFlags itemColor = item.getTextColorWithStatCheck(); @@ -931,7 +931,7 @@ void StoreConfirm(Item &item) std::string_view prompt; - switch (oldActiveStore) { + switch (OldActiveStore) { case TalkID::BoyBuy: prompt = _("Do we have a deal?"); break; @@ -955,7 +955,7 @@ void StoreConfirm(Item &item) prompt = _("Are you sure you want to repair this item?"); break; default: - app_fatal(StrCat("Unknown store dialog ", static_cast(oldActiveStore))); + app_fatal(StrCat("Unknown store dialog ", static_cast(OldActiveStore))); } AddSText(0, 15, prompt, UiFlags::ColorWhite | UiFlags::AlignCenter, false); AddSText(0, 18, _("Yes"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); @@ -964,11 +964,11 @@ void StoreConfirm(Item &item) void StartBoy() { - isTextFullSize = false; - hasScrollbar = false; + IsTextFullSize = false; + HasScrollbar = false; AddSText(0, 2, _("Wirt the Peg-legged boy"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSLine(5); - if (!boyItem.isEmpty()) { + if (!BoyItem.isEmpty()) { AddSText(0, 8, _("Talk to Wirt"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); AddSText(0, 12, _("I have something for sale,"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 14, _("but it will cost 50 gold"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); @@ -983,21 +983,21 @@ void StartBoy() void SStartBoyBuy() { - isTextFullSize = true; - hasScrollbar = false; + IsTextFullSize = true; + HasScrollbar = false; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("I have this item for sale:"), UiFlags::ColorWhitegold, false); AddSLine(3); - boyItem._iStatFlag = MyPlayer->CanUseItem(boyItem); - UiFlags itemColor = boyItem.getTextColorWithStatCheck(); - AddSText(20, 10, boyItem.getName(), itemColor, true, boyItem._iCurs, true); + BoyItem._iStatFlag = MyPlayer->CanUseItem(BoyItem); + UiFlags itemColor = BoyItem.getTextColorWithStatCheck(); + AddSText(20, 10, BoyItem.getName(), itemColor, true, BoyItem._iCurs, true); if (gbIsHellfire) - AddSTextVal(10, boyItem._iIvalue - (boyItem._iIvalue / 4)); + AddSTextVal(10, BoyItem._iIvalue - (BoyItem._iIvalue / 4)); else - AddSTextVal(10, boyItem._iIvalue + (boyItem._iIvalue / 2)); - PrintStoreItem(boyItem, 11, itemColor, true); + AddSTextVal(10, BoyItem._iIvalue + (BoyItem._iIvalue / 2)); + PrintStoreItem(BoyItem, 11, itemColor, true); { // Add a Leave button. Unlike the other item list back buttons, @@ -1005,7 +1005,7 @@ void SStartBoyBuy() const int line = BackButtonLine(); AddSLine(line - 1); AddSText(0, line, _("Leave"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); - textLine[line]._syoff = 6; + TextLine[line]._syoff = 6; } } @@ -1024,8 +1024,8 @@ void HealPlayer() void StartHealer() { HealPlayer(); - isTextFullSize = false; - hasScrollbar = false; + IsTextFullSize = false; + HasScrollbar = false; AddSText(0, 1, _("Welcome to the"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 3, _("Healer's home"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 9, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); @@ -1033,43 +1033,43 @@ void StartHealer() AddSText(0, 14, _("Buy items"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSText(0, 18, _("Leave Healer's home"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSLine(5); - currentItemIndex = 20; + CurrentItemIndex = 20; } void ScrollHealerBuy(int idx) { - ScrollVendorStore(healerItem, static_cast(std::size(healerItem)), idx); + ScrollVendorStore(HealerItems, static_cast(std::size(HealerItems)), idx); } void StartHealerBuy() { - isTextFullSize = true; - hasScrollbar = true; - scrollPos = 0; + IsTextFullSize = true; + HasScrollbar = true; + ScrollPos = 0; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("I have these items for sale:"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollHealerBuy(scrollPos); + ScrollHealerBuy(ScrollPos); AddItemListBackButton(); - currentItemIndex = 0; - for (Item &item : healerItem) { + CurrentItemIndex = 0; + for (Item &item : HealerItems) { if (item.isEmpty()) continue; item._iStatFlag = MyPlayer->CanUseItem(item); - currentItemIndex++; + CurrentItemIndex++; } - numTextLines = std::max(currentItemIndex - 4, 0); + NumTextLines = std::max(CurrentItemIndex - 4, 0); } void StartStoryteller() { - isTextFullSize = false; - hasScrollbar = false; + IsTextFullSize = false; + HasScrollbar = false; AddSText(0, 2, _("The Town Elder"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 9, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 12, _("Talk to Cain"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); @@ -1091,20 +1091,20 @@ bool IdItemOk(Item *i) void AddStoreHoldId(Item itm, int8_t i) { - playerItem[currentItemIndex] = itm; - playerItem[currentItemIndex]._ivalue = 100; - playerItem[currentItemIndex]._iIvalue = 100; - playerItemIndexes[currentItemIndex] = i; - currentItemIndex++; + PlayerItems[CurrentItemIndex] = itm; + PlayerItems[CurrentItemIndex]._ivalue = 100; + PlayerItems[CurrentItemIndex]._iIvalue = 100; + PlayerItemIndexes[CurrentItemIndex] = i; + CurrentItemIndex++; } void StartStorytellerIdentify() { bool idok = false; - isTextFullSize = true; - currentItemIndex = 0; + IsTextFullSize = true; + CurrentItemIndex = 0; - for (auto &item : playerItem) { + for (auto &item : PlayerItems) { item.clear(); } @@ -1153,7 +1153,7 @@ void StartStorytellerIdentify() } for (int i = 0; i < myPlayer._pNumInv; i++) { - if (currentItemIndex >= 48) + if (CurrentItemIndex >= 48) break; auto &item = myPlayer.InvList[i]; if (IdItemOk(&item)) { @@ -1163,31 +1163,31 @@ void StartStorytellerIdentify() } if (!idok) { - hasScrollbar = false; + HasScrollbar = false; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("You have nothing to identify."), UiFlags::ColorWhitegold, false); AddSLine(3); AddItemListBackButton(/*selectable=*/true); return; } - hasScrollbar = true; - scrollPos = 0; - numTextLines = myPlayer._pNumInv; + HasScrollbar = true; + ScrollPos = 0; + NumTextLines = myPlayer._pNumInv; - renderGold = true; + RenderGold = true; AddSText(20, 1, _("Identify which item?"), UiFlags::ColorWhitegold, false); AddSLine(3); - ScrollSmithSell(scrollPos); + ScrollSmithSell(ScrollPos); AddItemListBackButton(); } void StartStorytellerIdentifyShow(Item &item) { - StartStore(oldActiveStore); - hasScrollbar = false; + StartStore(OldActiveStore); + HasScrollbar = false; ClearSText(5, 23); UiFlags itemColor = item.getTextColorWithStatCheck(); @@ -1202,12 +1202,12 @@ void StartTalk() { int la; - isTextFullSize = false; - hasScrollbar = false; - AddSText(0, 2, fmt::format(fmt::runtime(_("Talk to {:s}")), _(TownerNames[townerId])), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); + IsTextFullSize = false; + HasScrollbar = false; + AddSText(0, 2, fmt::format(fmt::runtime(_("Talk to {:s}")), _(TownerNames[TownerId])), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSLine(5); if (gbIsSpawn) { - AddSText(0, 10, fmt::format(fmt::runtime(_("Talking to {:s}")), _(TownerNames[townerId])), UiFlags::ColorWhite | UiFlags::AlignCenter, false); + AddSText(0, 10, fmt::format(fmt::runtime(_("Talking to {:s}")), _(TownerNames[TownerId])), UiFlags::ColorWhite | UiFlags::AlignCenter, false); AddSText(0, 12, _("is not available"), UiFlags::ColorWhite | UiFlags::AlignCenter, false); AddSText(0, 14, _("in the shareware"), UiFlags::ColorWhite | UiFlags::AlignCenter, false); AddSText(0, 16, _("version"), UiFlags::ColorWhite | UiFlags::AlignCenter, false); @@ -1217,7 +1217,7 @@ void StartTalk() int sn = 0; for (auto &quest : Quests) { - if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[townerId][quest._qidx] != TEXT_NONE && quest._qlog) + if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[TownerId][quest._qidx] != TEXT_NONE && quest._qlog) sn++; } @@ -1232,7 +1232,7 @@ void StartTalk() int sn2 = sn - 2; for (auto &quest : Quests) { - if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[townerId][quest._qidx] != TEXT_NONE && quest._qlog) { + if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[TownerId][quest._qidx] != TEXT_NONE && quest._qlog) { AddSText(0, sn, _(QuestsData[quest._qidx]._qlstr), UiFlags::ColorWhite | UiFlags::AlignCenter, true); sn += la; } @@ -1243,49 +1243,49 @@ void StartTalk() void StartTavern() { - isTextFullSize = false; - hasScrollbar = false; + IsTextFullSize = false; + HasScrollbar = false; AddSText(0, 1, _("Welcome to the"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 3, _("Rising Sun"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 9, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 12, _("Talk to Ogden"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); AddSText(0, 18, _("Leave the tavern"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSLine(5); - currentItemIndex = 20; + CurrentItemIndex = 20; } void StartBarmaid() { - isTextFullSize = false; - hasScrollbar = false; + IsTextFullSize = false; + HasScrollbar = false; AddSText(0, 2, _("Gillian"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 9, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 12, _("Talk to Gillian"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); AddSText(0, 14, _("Access Storage"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSText(0, 18, _("Say goodbye"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSLine(5); - currentItemIndex = 20; + CurrentItemIndex = 20; } void StartDrunk() { - isTextFullSize = false; - hasScrollbar = false; + IsTextFullSize = false; + HasScrollbar = false; AddSText(0, 2, _("Farnham the Drunk"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 9, _("Would you like to:"), UiFlags::ColorWhitegold | UiFlags::AlignCenter, false); AddSText(0, 12, _("Talk to Farnham"), UiFlags::ColorBlue | UiFlags::AlignCenter, true); AddSText(0, 18, _("Say Goodbye"), UiFlags::ColorWhite | UiFlags::AlignCenter, true); AddSLine(5); - currentItemIndex = 20; + CurrentItemIndex = 20; } void SmithEnter() { - switch (currentTextLine) { + switch (CurrentTextLine) { case 10: - townerId = TOWN_SMITH; - oldTextLine = 10; - oldActiveStore = TalkID::Smith; + TownerId = TOWN_SMITH; + OldTextLine = 10; + OldActiveStore = TalkID::Smith; StartStore(TalkID::Gossip); break; case 12: @@ -1301,7 +1301,7 @@ void SmithEnter() StartStore(TalkID::SmithRepair); break; case 20: - activeStore = TalkID::None; + ActiveStore = TalkID::None; break; } } @@ -1315,42 +1315,42 @@ void SmithBuyItem(Item &item) if (item._iMagical == ITEM_QUALITY_NORMAL) item._iIdentified = false; StoreAutoPlace(item, true); - int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); + int idx = OldScrollPos + ((OldTextLine - PreviousScrollPos) / 4); if (idx == SMITH_ITEMS - 1) { - smithItem[SMITH_ITEMS - 1].clear(); + SmithItems[SMITH_ITEMS - 1].clear(); } else { - for (; !smithItem[idx + 1].isEmpty(); idx++) { - smithItem[idx] = std::move(smithItem[idx + 1]); + for (; !SmithItems[idx + 1].isEmpty(); idx++) { + SmithItems[idx] = std::move(SmithItems[idx + 1]); } - smithItem[idx].clear(); + SmithItems[idx].clear(); } CalcPlrInv(*MyPlayer, true); } void SmithBuyEnter() { - if (currentTextLine == BackButtonLine()) { + if (CurrentTextLine == BackButtonLine()) { StartStore(TalkID::Smith); - currentTextLine = 12; + CurrentTextLine = 12; return; } - oldTextLine = currentTextLine; - oldScrollPos = scrollPos; - oldActiveStore = TalkID::SmithBuy; + OldTextLine = CurrentTextLine; + OldScrollPos = ScrollPos; + OldActiveStore = TalkID::SmithBuy; - int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); - if (!PlayerCanAfford(smithItem[idx]._iIvalue)) { + int idx = ScrollPos + ((CurrentTextLine - PreviousScrollPos) / 4); + if (!PlayerCanAfford(SmithItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(smithItem[idx], false)) { + if (!StoreAutoPlace(SmithItems[idx], false)) { StartStore(TalkID::NoRoom); return; } - tempItem = smithItem[idx]; + TempItem = SmithItems[idx]; StartStore(TalkID::Confirm); } @@ -1364,52 +1364,52 @@ void SmithBuyPItem(Item &item) item._iIdentified = false; StoreAutoPlace(item, true); - int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); + int idx = OldScrollPos + ((OldTextLine - PreviousScrollPos) / 4); int xx = 0; for (int i = 0; idx >= 0; i++) { - if (!premiumItem[i].isEmpty()) { + if (!PremiumItems[i].isEmpty()) { idx--; xx = i; } } - premiumItem[xx].clear(); - numPremiumItems--; + PremiumItems[xx].clear(); + PremiumItemCount--; SpawnPremium(*MyPlayer); } void SmithPremiumBuyEnter() { - if (currentTextLine == BackButtonLine()) { + if (CurrentTextLine == BackButtonLine()) { StartStore(TalkID::Smith); - currentTextLine = 14; + CurrentTextLine = 14; return; } - oldActiveStore = TalkID::SmithPremiumBuy; - oldTextLine = currentTextLine; - oldScrollPos = scrollPos; + OldActiveStore = TalkID::SmithPremiumBuy; + OldTextLine = CurrentTextLine; + OldScrollPos = ScrollPos; - int xx = scrollPos + ((currentTextLine - previousScrollPos) / 4); + int xx = ScrollPos + ((CurrentTextLine - PreviousScrollPos) / 4); int idx = 0; for (int i = 0; xx >= 0; i++) { - if (!premiumItem[i].isEmpty()) { + if (!PremiumItems[i].isEmpty()) { xx--; idx = i; } } - if (!PlayerCanAfford(premiumItem[idx]._iIvalue)) { + if (!PlayerCanAfford(PremiumItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(premiumItem[idx], false)) { + if (!StoreAutoPlace(PremiumItems[idx], false)) { StartStore(TalkID::NoRoom); return; } - tempItem = premiumItem[idx]; + TempItem = PremiumItems[idx]; StartStore(TalkID::Confirm); } @@ -1434,18 +1434,18 @@ void StoreSellItem() { Player &myPlayer = *MyPlayer; - int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); - if (playerItemIndexes[idx] >= 0) - myPlayer.RemoveInvItem(playerItemIndexes[idx]); + int idx = OldScrollPos + ((OldTextLine - PreviousScrollPos) / 4); + if (PlayerItemIndexes[idx] >= 0) + myPlayer.RemoveInvItem(PlayerItemIndexes[idx]); else - myPlayer.RemoveSpdBarItem(-(playerItemIndexes[idx] + 1)); - - int cost = playerItem[idx]._iIvalue; - currentItemIndex--; - if (idx != currentItemIndex) { - while (idx < currentItemIndex) { - playerItem[idx] = playerItem[idx + 1]; - playerItemIndexes[idx] = playerItemIndexes[idx + 1]; + myPlayer.RemoveSpdBarItem(-(PlayerItemIndexes[idx] + 1)); + + int cost = PlayerItems[idx]._iIvalue; + CurrentItemIndex--; + if (idx != CurrentItemIndex) { + while (idx < CurrentItemIndex) { + PlayerItems[idx] = PlayerItems[idx + 1]; + PlayerItemIndexes[idx] = PlayerItemIndexes[idx + 1]; idx++; } } @@ -1457,24 +1457,24 @@ void StoreSellItem() void SmithSellEnter() { - if (currentTextLine == BackButtonLine()) { + if (CurrentTextLine == BackButtonLine()) { StartStore(TalkID::Smith); - currentTextLine = 16; + CurrentTextLine = 16; return; } - oldTextLine = currentTextLine; - oldActiveStore = TalkID::SmithSell; - oldScrollPos = scrollPos; + OldTextLine = CurrentTextLine; + OldActiveStore = TalkID::SmithSell; + OldScrollPos = ScrollPos; - int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); + int idx = ScrollPos + ((CurrentTextLine - PreviousScrollPos) / 4); - if (!StoreGoldFit(playerItem[idx])) { + if (!StoreGoldFit(PlayerItems[idx])) { StartStore(TalkID::NoRoom); return; } - tempItem = playerItem[idx]; + TempItem = PlayerItems[idx]; StartStore(TalkID::Confirm); } @@ -1483,10 +1483,10 @@ void SmithSellEnter() */ void SmithRepairItem(int price) { - int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); - playerItem[idx]._iDurability = playerItem[idx]._iMaxDur; + int idx = OldScrollPos + ((OldTextLine - PreviousScrollPos) / 4); + PlayerItems[idx]._iDurability = PlayerItems[idx]._iMaxDur; - int8_t i = playerItemIndexes[idx]; + int8_t i = PlayerItemIndexes[idx]; Player &myPlayer = *MyPlayer; @@ -1509,34 +1509,34 @@ void SmithRepairItem(int price) void SmithRepairEnter() { - if (currentTextLine == BackButtonLine()) { + if (CurrentTextLine == BackButtonLine()) { StartStore(TalkID::Smith); - currentTextLine = 18; + CurrentTextLine = 18; return; } - oldActiveStore = TalkID::SmithRepair; - oldTextLine = currentTextLine; - oldScrollPos = scrollPos; + OldActiveStore = TalkID::SmithRepair; + OldTextLine = CurrentTextLine; + OldScrollPos = ScrollPos; - int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); + int idx = ScrollPos + ((CurrentTextLine - PreviousScrollPos) / 4); - if (!PlayerCanAfford(playerItem[idx]._iIvalue)) { + if (!PlayerCanAfford(PlayerItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - tempItem = playerItem[idx]; + TempItem = PlayerItems[idx]; StartStore(TalkID::Confirm); } void WitchEnter() { - switch (currentTextLine) { + switch (CurrentTextLine) { case 12: - oldTextLine = 12; - townerId = TOWN_WITCH; - oldActiveStore = TalkID::Witch; + OldTextLine = 12; + TownerId = TOWN_WITCH; + OldActiveStore = TalkID::Witch; StartStore(TalkID::Gossip); break; case 14: @@ -1549,7 +1549,7 @@ void WitchEnter() StartStore(TalkID::WitchRecharge); break; case 20: - activeStore = TalkID::None; + ActiveStore = TalkID::None; break; } } @@ -1559,7 +1559,7 @@ void WitchEnter() */ void WitchBuyItem(Item &item) { - int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); + int idx = OldScrollPos + ((OldTextLine - PreviousScrollPos) / 4); if (idx < 3) item._iSeed = AdvanceRndSeed(); @@ -1569,12 +1569,12 @@ void WitchBuyItem(Item &item) if (idx >= 3) { if (idx == WITCH_ITEMS - 1) { - witchItem[WITCH_ITEMS - 1].clear(); + WitchItems[WITCH_ITEMS - 1].clear(); } else { - for (; !witchItem[idx + 1].isEmpty(); idx++) { - witchItem[idx] = std::move(witchItem[idx + 1]); + for (; !WitchItems[idx + 1].isEmpty(); idx++) { + WitchItems[idx] = std::move(WitchItems[idx + 1]); } - witchItem[idx].clear(); + WitchItems[idx].clear(); } } @@ -1583,52 +1583,52 @@ void WitchBuyItem(Item &item) void WitchBuyEnter() { - if (currentTextLine == BackButtonLine()) { + if (CurrentTextLine == BackButtonLine()) { StartStore(TalkID::Witch); - currentTextLine = 14; + CurrentTextLine = 14; return; } - oldTextLine = currentTextLine; - oldScrollPos = scrollPos; - oldActiveStore = TalkID::WitchBuy; + OldTextLine = CurrentTextLine; + OldScrollPos = ScrollPos; + OldActiveStore = TalkID::WitchBuy; - int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); + int idx = ScrollPos + ((CurrentTextLine - PreviousScrollPos) / 4); - if (!PlayerCanAfford(witchItem[idx]._iIvalue)) { + if (!PlayerCanAfford(WitchItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(witchItem[idx], false)) { + if (!StoreAutoPlace(WitchItems[idx], false)) { StartStore(TalkID::NoRoom); return; } - tempItem = witchItem[idx]; + TempItem = WitchItems[idx]; StartStore(TalkID::Confirm); } void WitchSellEnter() { - if (currentTextLine == BackButtonLine()) { + if (CurrentTextLine == BackButtonLine()) { StartStore(TalkID::Witch); - currentTextLine = 16; + CurrentTextLine = 16; return; } - oldTextLine = currentTextLine; - oldActiveStore = TalkID::WitchSell; - oldScrollPos = scrollPos; + OldTextLine = CurrentTextLine; + OldActiveStore = TalkID::WitchSell; + OldScrollPos = ScrollPos; - int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); + int idx = ScrollPos + ((CurrentTextLine - PreviousScrollPos) / 4); - if (!StoreGoldFit(playerItem[idx])) { + if (!StoreGoldFit(PlayerItems[idx])) { StartStore(TalkID::NoRoom); return; } - tempItem = playerItem[idx]; + TempItem = PlayerItems[idx]; StartStore(TalkID::Confirm); } @@ -1637,12 +1637,12 @@ void WitchSellEnter() */ void WitchRechargeItem(int price) { - int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); - playerItem[idx]._iCharges = playerItem[idx]._iMaxCharges; + int idx = OldScrollPos + ((OldTextLine - PreviousScrollPos) / 4); + PlayerItems[idx]._iCharges = PlayerItems[idx]._iMaxCharges; Player &myPlayer = *MyPlayer; - int8_t i = playerItemIndexes[idx]; + int8_t i = PlayerItemIndexes[idx]; if (i < 0) { myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges = myPlayer.InvBody[INVLOC_HAND_LEFT]._iMaxCharges; NetSendCmdChItem(true, INVLOC_HAND_LEFT); @@ -1657,34 +1657,34 @@ void WitchRechargeItem(int price) void WitchRechargeEnter() { - if (currentTextLine == BackButtonLine()) { + if (CurrentTextLine == BackButtonLine()) { StartStore(TalkID::Witch); - currentTextLine = 18; + CurrentTextLine = 18; return; } - oldActiveStore = TalkID::WitchRecharge; - oldTextLine = currentTextLine; - oldScrollPos = scrollPos; + OldActiveStore = TalkID::WitchRecharge; + OldTextLine = CurrentTextLine; + OldScrollPos = ScrollPos; - int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); + int idx = ScrollPos + ((CurrentTextLine - PreviousScrollPos) / 4); - if (!PlayerCanAfford(playerItem[idx]._iIvalue)) { + if (!PlayerCanAfford(PlayerItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - tempItem = playerItem[idx]; + TempItem = PlayerItems[idx]; StartStore(TalkID::Confirm); } void BoyEnter() { - if (!boyItem.isEmpty() && currentTextLine == 18) { + if (!BoyItem.isEmpty() && CurrentTextLine == 18) { if (!PlayerCanAfford(50)) { - oldActiveStore = TalkID::Boy; - oldTextLine = 18; - oldScrollPos = scrollPos; + OldActiveStore = TalkID::Boy; + OldTextLine = 18; + OldScrollPos = ScrollPos; StartStore(TalkID::NoMoney); } else { TakePlrsMoney(50); @@ -1693,14 +1693,14 @@ void BoyEnter() return; } - if ((currentTextLine != 8 && !boyItem.isEmpty()) || (currentTextLine != 12 && boyItem.isEmpty())) { - activeStore = TalkID::None; + if ((CurrentTextLine != 8 && !BoyItem.isEmpty()) || (CurrentTextLine != 12 && BoyItem.isEmpty())) { + ActiveStore = TalkID::None; return; } - townerId = TOWN_PEGBOY; - oldActiveStore = TalkID::Boy; - oldTextLine = currentTextLine; + TownerId = TOWN_PEGBOY; + OldActiveStore = TalkID::Boy; + OldTextLine = CurrentTextLine; StartStore(TalkID::Gossip); } @@ -1708,10 +1708,10 @@ void BoyBuyItem(Item &item) { TakePlrsMoney(item._iIvalue); StoreAutoPlace(item, true); - boyItem.clear(); - oldActiveStore = TalkID::Boy; + BoyItem.clear(); + OldActiveStore = TalkID::Boy; CalcPlrInv(*MyPlayer, true); - oldTextLine = 12; + OldTextLine = 12; } /** @@ -1719,7 +1719,7 @@ void BoyBuyItem(Item &item) */ void HealerBuyItem(Item &item) { - int idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); + int idx = OldScrollPos + ((OldTextLine - PreviousScrollPos) / 4); if (!gbIsMultiplayer) { if (idx < 2) item._iSeed = AdvanceRndSeed(); @@ -1740,46 +1740,46 @@ void HealerBuyItem(Item &item) if (idx < 3) return; } - idx = oldScrollPos + ((oldTextLine - previousScrollPos) / 4); + idx = OldScrollPos + ((OldTextLine - PreviousScrollPos) / 4); if (idx == 19) { - healerItem[19].clear(); + HealerItems[19].clear(); } else { - for (; !healerItem[idx + 1].isEmpty(); idx++) { - healerItem[idx] = std::move(healerItem[idx + 1]); + for (; !HealerItems[idx + 1].isEmpty(); idx++) { + HealerItems[idx] = std::move(HealerItems[idx + 1]); } - healerItem[idx].clear(); + HealerItems[idx].clear(); } CalcPlrInv(*MyPlayer, true); } void BoyBuyEnter() { - if (currentTextLine != 10) { - activeStore = TalkID::None; + if (CurrentTextLine != 10) { + ActiveStore = TalkID::None; return; } - oldActiveStore = TalkID::BoyBuy; - oldScrollPos = scrollPos; - oldTextLine = 10; - int price = boyItem._iIvalue; + OldActiveStore = TalkID::BoyBuy; + OldScrollPos = ScrollPos; + OldTextLine = 10; + int price = BoyItem._iIvalue; if (gbIsHellfire) - price -= boyItem._iIvalue / 4; + price -= BoyItem._iIvalue / 4; else - price += boyItem._iIvalue / 2; + price += BoyItem._iIvalue / 2; if (!PlayerCanAfford(price)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(boyItem, false)) { + if (!StoreAutoPlace(BoyItem, false)) { StartStore(TalkID::NoRoom); return; } - tempItem = boyItem; - tempItem._iIvalue = price; + TempItem = BoyItem; + TempItem._iIvalue = price; StartStore(TalkID::Confirm); } @@ -1787,7 +1787,7 @@ void StorytellerIdentifyItem(Item &item) { Player &myPlayer = *MyPlayer; - int8_t idx = playerItemIndexes[((oldTextLine - previousScrollPos) / 4) + oldScrollPos]; + int8_t idx = PlayerItemIndexes[((OldTextLine - PreviousScrollPos) / 4) + OldScrollPos]; if (idx < 0) { if (idx == -1) myPlayer.InvBody[INVLOC_HEAD]._iIdentified = true; @@ -1813,8 +1813,8 @@ void StorytellerIdentifyItem(Item &item) void ConfirmEnter(Item &item) { - if (currentTextLine == 18) { - switch (oldActiveStore) { + if (CurrentTextLine == 18) { + switch (OldActiveStore) { case TalkID::SmithBuy: SmithBuyItem(item); break; @@ -1849,117 +1849,117 @@ void ConfirmEnter(Item &item) } } - StartStore(oldActiveStore); + StartStore(OldActiveStore); - if (currentTextLine == BackButtonLine()) + if (CurrentTextLine == BackButtonLine()) return; - currentTextLine = oldTextLine; - scrollPos = std::min(oldScrollPos, numTextLines); + CurrentTextLine = OldTextLine; + ScrollPos = std::min(OldScrollPos, NumTextLines); - while (currentTextLine != -1 && !textLine[currentTextLine].isSelectable()) { - currentTextLine--; + while (CurrentTextLine != -1 && !TextLine[CurrentTextLine].isSelectable()) { + CurrentTextLine--; } } void HealerEnter() { - switch (currentTextLine) { + switch (CurrentTextLine) { case 12: - oldTextLine = 12; - townerId = TOWN_HEALER; - oldActiveStore = TalkID::Healer; + OldTextLine = 12; + TownerId = TOWN_HEALER; + OldActiveStore = TalkID::Healer; StartStore(TalkID::Gossip); break; case 14: StartStore(TalkID::HealerBuy); break; case 18: - activeStore = TalkID::None; + ActiveStore = TalkID::None; break; } } void HealerBuyEnter() { - if (currentTextLine == BackButtonLine()) { + if (CurrentTextLine == BackButtonLine()) { StartStore(TalkID::Healer); - currentTextLine = 14; + CurrentTextLine = 14; return; } - oldTextLine = currentTextLine; - oldScrollPos = scrollPos; - oldActiveStore = TalkID::HealerBuy; + OldTextLine = CurrentTextLine; + OldScrollPos = ScrollPos; + OldActiveStore = TalkID::HealerBuy; - int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); + int idx = ScrollPos + ((CurrentTextLine - PreviousScrollPos) / 4); - if (!PlayerCanAfford(healerItem[idx]._iIvalue)) { + if (!PlayerCanAfford(HealerItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(healerItem[idx], false)) { + if (!StoreAutoPlace(HealerItems[idx], false)) { StartStore(TalkID::NoRoom); return; } - tempItem = healerItem[idx]; + TempItem = HealerItems[idx]; StartStore(TalkID::Confirm); } void StorytellerEnter() { - switch (currentTextLine) { + switch (CurrentTextLine) { case 12: - oldTextLine = 12; - townerId = TOWN_STORY; - oldActiveStore = TalkID::Storyteller; + OldTextLine = 12; + TownerId = TOWN_STORY; + OldActiveStore = TalkID::Storyteller; StartStore(TalkID::Gossip); break; case 14: StartStore(TalkID::StorytellerIdentify); break; case 18: - activeStore = TalkID::None; + ActiveStore = TalkID::None; break; } } void StorytellerIdentifyEnter() { - if (currentTextLine == BackButtonLine()) { + if (CurrentTextLine == BackButtonLine()) { StartStore(TalkID::Storyteller); - currentTextLine = 14; + CurrentTextLine = 14; return; } - oldActiveStore = TalkID::StorytellerIdentify; - oldTextLine = currentTextLine; - oldScrollPos = scrollPos; + OldActiveStore = TalkID::StorytellerIdentify; + OldTextLine = CurrentTextLine; + OldScrollPos = ScrollPos; - int idx = scrollPos + ((currentTextLine - previousScrollPos) / 4); + int idx = ScrollPos + ((CurrentTextLine - PreviousScrollPos) / 4); - if (!PlayerCanAfford(playerItem[idx]._iIvalue)) { + if (!PlayerCanAfford(PlayerItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - tempItem = playerItem[idx]; + TempItem = PlayerItems[idx]; StartStore(TalkID::Confirm); } void TalkEnter() { - if (currentTextLine == BackButtonLine()) { - StartStore(oldActiveStore); - currentTextLine = oldTextLine; + if (CurrentTextLine == BackButtonLine()) { + StartStore(OldActiveStore); + CurrentTextLine = OldTextLine; return; } int sn = 0; for (auto &quest : Quests) { - if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[townerId][quest._qidx] != TEXT_NONE && quest._qlog) + if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[TownerId][quest._qidx] != TEXT_NONE && quest._qlog) sn++; } int la = 2; @@ -1970,17 +1970,17 @@ void TalkEnter() sn = 15 - sn; } - if (currentTextLine == sn - 2) { - Towner *target = GetTowner(townerId); + if (CurrentTextLine == sn - 2) { + Towner *target = GetTowner(TownerId); assert(target != nullptr); InitQTextMsg(target->gossip); return; } for (auto &quest : Quests) { - if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[townerId][quest._qidx] != TEXT_NONE && quest._qlog) { - if (sn == currentTextLine) { - InitQTextMsg(QuestDialogTable[townerId][quest._qidx]); + if (quest._qactive == QUEST_ACTIVE && QuestDialogTable[TownerId][quest._qidx] != TEXT_NONE && quest._qlog) { + if (sn == CurrentTextLine) { + InitQTextMsg(QuestDialogTable[TownerId][quest._qidx]); } sn += la; } @@ -1989,30 +1989,30 @@ void TalkEnter() void TavernEnter() { - switch (currentTextLine) { + switch (CurrentTextLine) { case 12: - oldTextLine = 12; - townerId = TOWN_TAVERN; - oldActiveStore = TalkID::Tavern; + OldTextLine = 12; + TownerId = TOWN_TAVERN; + OldActiveStore = TalkID::Tavern; StartStore(TalkID::Gossip); break; case 18: - activeStore = TalkID::None; + ActiveStore = TalkID::None; break; } } void BarmaidEnter() { - switch (currentTextLine) { + switch (CurrentTextLine) { case 12: - oldTextLine = 12; - townerId = TOWN_BMAID; - oldActiveStore = TalkID::Barmaid; + OldTextLine = 12; + TownerId = TOWN_BMAID; + OldActiveStore = TalkID::Barmaid; StartStore(TalkID::Gossip); break; case 14: - activeStore = TalkID::None; + ActiveStore = TalkID::None; IsStashOpen = true; Stash.RefreshItemStatFlags(); invflag = true; @@ -2023,22 +2023,22 @@ void BarmaidEnter() } break; case 18: - activeStore = TalkID::None; + ActiveStore = TalkID::None; break; } } void DrunkEnter() { - switch (currentTextLine) { + switch (CurrentTextLine) { case 12: - oldTextLine = 12; - townerId = TOWN_DRUNK; - oldActiveStore = TalkID::Drunk; + OldTextLine = 12; + TownerId = TOWN_DRUNK; + OldActiveStore = TalkID::Drunk; StartStore(TalkID::Gossip); break; case 18: - activeStore = TalkID::None; + ActiveStore = TalkID::None; break; } } @@ -2088,8 +2088,8 @@ void AddStoreHoldRepair(Item *itm, int8_t i) Item *item; int v; - item = &playerItem[currentItemIndex]; - playerItem[currentItemIndex] = *itm; + item = &PlayerItems[CurrentItemIndex]; + PlayerItems[CurrentItemIndex] = *itm; int due = item->_iMaxDur - item->_iDurability; if (item->_iMagical != ITEM_QUALITY_NORMAL && item->_iIdentified) { @@ -2102,24 +2102,24 @@ void AddStoreHoldRepair(Item *itm, int8_t i) } item->_iIvalue = v; item->_ivalue = v; - playerItemIndexes[currentItemIndex] = i; - currentItemIndex++; + PlayerItemIndexes[CurrentItemIndex] = i; + CurrentItemIndex++; } void InitStores() { ClearSText(0, STORE_LINES); - activeStore = TalkID::None; - isTextFullSize = false; - hasScrollbar = false; - numPremiumItems = 0; - premiumItemLevel = 1; + ActiveStore = TalkID::None; + IsTextFullSize = false; + HasScrollbar = false; + PremiumItemCount = 0; + PremiumItemLevel = 1; - for (auto &premiumitem : premiumItem) + for (auto &premiumitem : PremiumItems) premiumitem.clear(); - boyItem.clear(); - boyItemLevel = 0; + BoyItem.clear(); + BoyItemLevel = 0; } void SetupTownStores() @@ -2148,8 +2148,8 @@ void FreeStoreMem() if (*sgOptions.Gameplay.showItemGraphicsInStores) { FreeHalfSizeItemSprites(); } - activeStore = TalkID::None; - for (STextStruct &entry : textLine) { + ActiveStore = TalkID::None; + for (STextStruct &entry : TextLine) { entry.text.clear(); entry.text.shrink_to_fit(); } @@ -2159,14 +2159,14 @@ void PrintSString(const Surface &out, int margin, int line, std::string_view tex { const Point uiPosition = GetUIRectangle().position; int sx = uiPosition.x + 32 + margin; - if (!isTextFullSize) { + if (!IsTextFullSize) { sx += 320; } - const int sy = uiPosition.y + PaddingTop + textLine[line].y + textLine[line]._syoff; + const int sy = uiPosition.y + PaddingTop + TextLine[line].y + TextLine[line]._syoff; - int width = isTextFullSize ? 575 : 255; - if (hasScrollbar && line >= 4 && line <= 20) { + int width = IsTextFullSize ? 575 : 255; + if (HasScrollbar && line >= 4 && line <= 20) { width -= 9; // Space for the selector } width -= margin * 2; @@ -2205,7 +2205,7 @@ void PrintSString(const Surface &out, int margin, int line, std::string_view tex if (price > 0) DrawString(out, FormatInteger(price), rect, { .flags = flags | UiFlags::AlignRight }); - if (currentTextLine == line) { + if (CurrentTextLine == line) { DrawSelector(out, rect, text, flags); } } @@ -2216,7 +2216,7 @@ void DrawSLine(const Surface &out, int sy) int sx = 26; int width = 587; - if (!isTextFullSize) { + if (!IsTextFullSize) { sx += SidePanelSize.width; width -= SidePanelSize.width; } @@ -2230,20 +2230,20 @@ void DrawSLine(const Surface &out, int sy) void DrawSTextHelp() { - currentTextLine = -1; - isTextFullSize = true; + CurrentTextLine = -1; + IsTextFullSize = true; } void ClearSText(int s, int e) { for (int i = s; i < e; i++) { - textLine[i]._sx = 0; - textLine[i]._syoff = 0; - textLine[i].text.clear(); - textLine[i].text.shrink_to_fit(); - textLine[i].flags = UiFlags::None; - textLine[i].type = STextStruct::Label; - textLine[i]._sval = 0; + TextLine[i]._sx = 0; + TextLine[i]._syoff = 0; + TextLine[i].text.clear(); + TextLine[i].text.shrink_to_fit(); + TextLine[i].flags = UiFlags::None; + TextLine[i].type = STextStruct::Label; + TextLine[i]._sval = 0; } } @@ -2255,7 +2255,7 @@ void StartStore(TalkID s) SpellbookFlag = false; CloseInventory(); CloseCharPanel(); - renderGold = false; + RenderGold = false; QuestLogIsOpen = false; CloseGoldDrop(); ClearSText(0, STORE_LINES); @@ -2266,15 +2266,15 @@ void StartStore(TalkID s) break; case TalkID::SmithBuy: { bool hasAnyItems = false; - for (int i = 0; !smithItem[i].isEmpty(); i++) { + for (int i = 0; !SmithItems[i].isEmpty(); i++) { hasAnyItems = true; break; } if (hasAnyItems) StartSmithBuy(); else { - activeStore = TalkID::SmithBuy; - oldTextLine = 12; + ActiveStore = TalkID::SmithBuy; + OldTextLine = 12; StoreESC(); return; } @@ -2290,7 +2290,7 @@ void StartStore(TalkID s) StartWitch(); break; case TalkID::WitchBuy: - if (currentItemIndex > 0) + if (CurrentItemIndex > 0) StartWitchBuy(); break; case TalkID::WitchSell: @@ -2306,7 +2306,7 @@ void StartStore(TalkID s) StoreNoRoom(); break; case TalkID::Confirm: - StoreConfirm(tempItem); + StoreConfirm(TempItem); break; case TalkID::Boy: StartBoy(); @@ -2321,7 +2321,7 @@ void StartStore(TalkID s) StartStoryteller(); break; case TalkID::HealerBuy: - if (currentItemIndex > 0) + if (CurrentItemIndex > 0) StartHealerBuy(); break; case TalkID::StorytellerIdentify: @@ -2335,7 +2335,7 @@ void StartStore(TalkID s) StartTalk(); break; case TalkID::StorytellerIdentifyShow: - StartStorytellerIdentifyShow(tempItem); + StartStorytellerIdentifyShow(TempItem); break; case TalkID::Tavern: StartTavern(); @@ -2350,44 +2350,44 @@ void StartStore(TalkID s) break; } - currentTextLine = -1; + CurrentTextLine = -1; for (int i = 0; i < STORE_LINES; i++) { - if (textLine[i].isSelectable()) { - currentTextLine = i; + if (TextLine[i].isSelectable()) { + CurrentTextLine = i; break; } } - activeStore = s; + ActiveStore = s; } void DrawSText(const Surface &out) { - if (!isTextFullSize) + if (!IsTextFullSize) DrawSTextBack(out); else DrawQTextBack(out); - if (hasScrollbar) { - switch (activeStore) { + if (HasScrollbar) { + switch (ActiveStore) { case TalkID::SmithBuy: - ScrollSmithBuy(scrollPos); + ScrollSmithBuy(ScrollPos); break; case TalkID::SmithSell: case TalkID::SmithRepair: case TalkID::WitchSell: case TalkID::WitchRecharge: case TalkID::StorytellerIdentify: - ScrollSmithSell(scrollPos); + ScrollSmithSell(ScrollPos); break; case TalkID::WitchBuy: - ScrollWitchBuy(scrollPos); + ScrollWitchBuy(ScrollPos); break; case TalkID::HealerBuy: - ScrollHealerBuy(scrollPos); + ScrollHealerBuy(ScrollPos); break; case TalkID::SmithPremiumBuy: - ScrollSmithPremiumBuy(scrollPos); + ScrollSmithPremiumBuy(ScrollPos); break; default: break; @@ -2397,17 +2397,17 @@ void DrawSText(const Surface &out) CalculateLineHeights(); const Point uiPosition = GetUIRectangle().position; for (int i = 0; i < STORE_LINES; i++) { - if (textLine[i].isDivider()) - DrawSLine(out, uiPosition.y + PaddingTop + textLine[i].y + TextHeight() / 2); - else if (textLine[i].hasText()) - PrintSString(out, textLine[i]._sx, i, textLine[i].text, textLine[i].flags, textLine[i]._sval, textLine[i].cursId, textLine[i].cursIndent); + if (TextLine[i].isDivider()) + DrawSLine(out, uiPosition.y + PaddingTop + TextLine[i].y + TextHeight() / 2); + else if (TextLine[i].hasText()) + PrintSString(out, TextLine[i]._sx, i, TextLine[i].text, TextLine[i].flags, TextLine[i]._sval, TextLine[i].cursId, TextLine[i].cursIndent); } - if (renderGold) { + if (RenderGold) { PrintSString(out, 28, 1, fmt::format(fmt::runtime(_("Your gold: {:s}")), FormatInteger(TotalPlayerGold())).c_str(), UiFlags::ColorWhitegold | UiFlags::AlignRight); } - if (hasScrollbar) + if (HasScrollbar) DrawSSlider(out, 4, 20); } @@ -2420,7 +2420,7 @@ void StoreESC() return; } - switch (activeStore) { + switch (ActiveStore) { case TalkID::Smith: case TalkID::Witch: case TalkID::Boy: @@ -2430,47 +2430,47 @@ void StoreESC() case TalkID::Tavern: case TalkID::Drunk: case TalkID::Barmaid: - activeStore = TalkID::None; + ActiveStore = TalkID::None; break; case TalkID::Gossip: - StartStore(oldActiveStore); - currentTextLine = oldTextLine; + StartStore(OldActiveStore); + CurrentTextLine = OldTextLine; break; case TalkID::SmithBuy: StartStore(TalkID::Smith); - currentTextLine = 12; + CurrentTextLine = 12; break; case TalkID::SmithPremiumBuy: StartStore(TalkID::Smith); - currentTextLine = 14; + CurrentTextLine = 14; break; case TalkID::SmithSell: StartStore(TalkID::Smith); - currentTextLine = 16; + CurrentTextLine = 16; break; case TalkID::SmithRepair: StartStore(TalkID::Smith); - currentTextLine = 18; + CurrentTextLine = 18; break; case TalkID::WitchBuy: StartStore(TalkID::Witch); - currentTextLine = 14; + CurrentTextLine = 14; break; case TalkID::WitchSell: StartStore(TalkID::Witch); - currentTextLine = 16; + CurrentTextLine = 16; break; case TalkID::WitchRecharge: StartStore(TalkID::Witch); - currentTextLine = 18; + CurrentTextLine = 18; break; case TalkID::HealerBuy: StartStore(TalkID::Healer); - currentTextLine = 14; + CurrentTextLine = 14; break; case TalkID::StorytellerIdentify: StartStore(TalkID::Storyteller); - currentTextLine = 14; + CurrentTextLine = 14; break; case TalkID::StorytellerIdentifyShow: StartStore(TalkID::StorytellerIdentify); @@ -2478,9 +2478,9 @@ void StoreESC() case TalkID::NoMoney: case TalkID::NoRoom: case TalkID::Confirm: - StartStore(oldActiveStore); - currentTextLine = oldTextLine; - scrollPos = oldScrollPos; + StartStore(OldActiveStore); + CurrentTextLine = OldTextLine; + ScrollPos = OldScrollPos; break; case TalkID::None: break; @@ -2490,85 +2490,85 @@ void StoreESC() void StoreUp() { PlaySFX(SfxID::MenuMove); - if (currentTextLine == -1) { + if (CurrentTextLine == -1) { return; } - if (hasScrollbar) { - if (currentTextLine == previousScrollPos) { - if (scrollPos != 0) - scrollPos--; + if (HasScrollbar) { + if (CurrentTextLine == PreviousScrollPos) { + if (ScrollPos != 0) + ScrollPos--; return; } - currentTextLine--; - while (!textLine[currentTextLine].isSelectable()) { - if (currentTextLine == 0) - currentTextLine = STORE_LINES - 1; + CurrentTextLine--; + while (!TextLine[CurrentTextLine].isSelectable()) { + if (CurrentTextLine == 0) + CurrentTextLine = STORE_LINES - 1; else - currentTextLine--; + CurrentTextLine--; } return; } - if (currentTextLine == 0) - currentTextLine = STORE_LINES - 1; + if (CurrentTextLine == 0) + CurrentTextLine = STORE_LINES - 1; else - currentTextLine--; + CurrentTextLine--; - while (!textLine[currentTextLine].isSelectable()) { - if (currentTextLine == 0) - currentTextLine = STORE_LINES - 1; + while (!TextLine[CurrentTextLine].isSelectable()) { + if (CurrentTextLine == 0) + CurrentTextLine = STORE_LINES - 1; else - currentTextLine--; + CurrentTextLine--; } } void StoreDown() { PlaySFX(SfxID::MenuMove); - if (currentTextLine == -1) { + if (CurrentTextLine == -1) { return; } - if (hasScrollbar) { - if (currentTextLine == nextScrollPos) { - if (scrollPos < numTextLines) - scrollPos++; + if (HasScrollbar) { + if (CurrentTextLine == NextScrollPos) { + if (ScrollPos < NumTextLines) + ScrollPos++; return; } - currentTextLine++; - while (!textLine[currentTextLine].isSelectable()) { - if (currentTextLine == STORE_LINES - 1) - currentTextLine = 0; + CurrentTextLine++; + while (!TextLine[CurrentTextLine].isSelectable()) { + if (CurrentTextLine == STORE_LINES - 1) + CurrentTextLine = 0; else - currentTextLine++; + CurrentTextLine++; } return; } - if (currentTextLine == STORE_LINES - 1) - currentTextLine = 0; + if (CurrentTextLine == STORE_LINES - 1) + CurrentTextLine = 0; else - currentTextLine++; + CurrentTextLine++; - while (!textLine[currentTextLine].isSelectable()) { - if (currentTextLine == STORE_LINES - 1) - currentTextLine = 0; + while (!TextLine[CurrentTextLine].isSelectable()) { + if (CurrentTextLine == STORE_LINES - 1) + CurrentTextLine = 0; else - currentTextLine++; + CurrentTextLine++; } } void StorePrior() { PlaySFX(SfxID::MenuMove); - if (currentTextLine != -1 && hasScrollbar) { - if (currentTextLine == previousScrollPos) { - scrollPos = std::max(scrollPos - 4, 0); + if (CurrentTextLine != -1 && HasScrollbar) { + if (CurrentTextLine == PreviousScrollPos) { + ScrollPos = std::max(ScrollPos - 4, 0); } else { - currentTextLine = previousScrollPos; + CurrentTextLine = PreviousScrollPos; } } } @@ -2576,14 +2576,14 @@ void StorePrior() void StoreNext() { PlaySFX(SfxID::MenuMove); - if (currentTextLine != -1 && hasScrollbar) { - if (currentTextLine == nextScrollPos) { - if (scrollPos < numTextLines) - scrollPos += 4; - if (scrollPos > numTextLines) - scrollPos = numTextLines; + if (CurrentTextLine != -1 && HasScrollbar) { + if (CurrentTextLine == NextScrollPos) { + if (ScrollPos < NumTextLines) + ScrollPos += 4; + if (ScrollPos > NumTextLines) + ScrollPos = NumTextLines; } else { - currentTextLine = nextScrollPos; + CurrentTextLine = NextScrollPos; } } } @@ -2614,7 +2614,7 @@ void StoreEnter() } PlaySFX(SfxID::MenuSelect); - switch (activeStore) { + switch (ActiveStore) { case TalkID::Smith: SmithEnter(); break; @@ -2644,12 +2644,12 @@ void StoreEnter() break; case TalkID::NoMoney: case TalkID::NoRoom: - StartStore(oldActiveStore); - currentTextLine = oldTextLine; - scrollPos = oldScrollPos; + StartStore(OldActiveStore); + CurrentTextLine = OldTextLine; + ScrollPos = OldScrollPos; break; case TalkID::Confirm: - ConfirmEnter(tempItem); + ConfirmEnter(TempItem); break; case TalkID::Boy: BoyEnter(); @@ -2695,14 +2695,14 @@ void CheckStoreBtn() const Rectangle windowRect { { uiPosition.x + 344, uiPosition.y + PaddingTop - 7 }, { 271, 303 } }; const Rectangle windowRectFull { { uiPosition.x + 24, uiPosition.y + PaddingTop - 7 }, { 591, 303 } }; - if (!isTextFullSize) { + if (!IsTextFullSize) { if (!windowRect.contains(MousePosition)) { - while (activeStore != TalkID::None) + while (ActiveStore != TalkID::None) StoreESC(); } } else { if (!windowRectFull.contains(MousePosition)) { - while (activeStore != TalkID::None) + while (ActiveStore != TalkID::None) StoreESC(); } } @@ -2711,26 +2711,26 @@ void CheckStoreBtn() qtextflag = false; if (leveltype == DTYPE_TOWN) stream_stop(); - } else if (currentTextLine != -1) { + } else if (CurrentTextLine != -1) { const int relativeY = MousePosition.y - (uiPosition.y + PaddingTop); - if (hasScrollbar && MousePosition.x > 600 + uiPosition.x) { + if (HasScrollbar && MousePosition.x > 600 + uiPosition.x) { // Scroll bar is always measured in terms of the small line height. int y = relativeY / SmallLineHeight; if (y == 4) { - if (countdownScrollUp <= 0) { + if (CountdownScrollUp <= 0) { StoreUp(); - countdownScrollUp = 10; + CountdownScrollUp = 10; } else { - countdownScrollUp--; + CountdownScrollUp--; } } if (y == 20) { - if (countdownScrollDown <= 0) { + if (CountdownScrollDown <= 0) { StoreDown(); - countdownScrollDown = 10; + CountdownScrollDown = 10; } else { - countdownScrollDown--; + CountdownScrollDown--; } } return; @@ -2740,23 +2740,23 @@ void CheckStoreBtn() // Large small fonts draw beyond LineHeight. Check if the click was on the overflow text. if (IsSmallFontTall() && y > 0 && y < STORE_LINES - && textLine[y - 1].hasText() && !textLine[y].hasText() - && relativeY < textLine[y - 1].y + LargeTextHeight) { + && TextLine[y - 1].hasText() && !TextLine[y].hasText() + && relativeY < TextLine[y - 1].y + LargeTextHeight) { --y; } if (y >= 5) { if (y >= BackButtonLine() + 1) y = BackButtonLine(); - if (hasScrollbar && y <= 20 && !textLine[y].isSelectable()) { - if (textLine[y - 2].isSelectable()) { + if (HasScrollbar && y <= 20 && !TextLine[y].isSelectable()) { + if (TextLine[y - 2].isSelectable()) { y -= 2; - } else if (textLine[y - 1].isSelectable()) { + } else if (TextLine[y - 1].isSelectable()) { y--; } } - if (textLine[y].isSelectable() || (hasScrollbar && y == BackButtonLine())) { - currentTextLine = y; + if (TextLine[y].isSelectable() || (HasScrollbar && y == BackButtonLine())) { + CurrentTextLine = y; StoreEnter(); } } @@ -2765,8 +2765,8 @@ void CheckStoreBtn() void ReleaseStoreBtn() { - countdownScrollUp = -1; - countdownScrollDown = -1; + CountdownScrollUp = -1; + CountdownScrollDown = -1; } } // namespace devilution diff --git a/Source/stores.h b/Source/stores.h index 4f5ea696035..cea33714bbc 100644 --- a/Source/stores.h +++ b/Source/stores.h @@ -49,34 +49,34 @@ enum class TalkID : uint8_t { }; /** Currently active store */ -extern TalkID activeStore; +extern TalkID ActiveStore; -/** Current index into playerItemIndexes/playerItem */ -extern DVL_API_FOR_TEST int currentItemIndex; +/** Current index into PlayerItemIndexes/PlayerItems */ +extern DVL_API_FOR_TEST int CurrentItemIndex; /** Map of inventory items being presented in the store */ -extern int8_t playerItemIndexes[48]; +extern int8_t PlayerItemIndexes[48]; /** Copies of the players items as presented in the store */ -extern DVL_API_FOR_TEST Item playerItem[48]; +extern DVL_API_FOR_TEST Item PlayerItems[48]; /** Items sold by Griswold */ -extern Item smithItem[SMITH_ITEMS]; +extern Item SmithItems[SMITH_ITEMS]; /** Number of premium items for sale by Griswold */ -extern int numPremiumItems; +extern int PremiumItemCount; /** Base level of current premium items sold by Griswold */ -extern int premiumItemLevel; +extern int PremiumItemLevel; /** Premium items sold by Griswold */ -extern Item premiumItem[SMITH_PREMIUM_ITEMS]; +extern Item PremiumItems[SMITH_PREMIUM_ITEMS]; /** Items sold by Pepin */ -extern Item healerItem[20]; +extern Item HealerItems[20]; /** Items sold by Adria */ -extern Item witchItem[WITCH_ITEMS]; +extern Item WitchItems[WITCH_ITEMS]; /** Current level of the item sold by Wirt */ -extern int boyItemLevel; +extern int BoyItemLevel; /** Current item sold by Wirt */ -extern Item boyItem; +extern Item BoyItem; void AddStoreHoldRepair(Item *itm, int8_t i); diff --git a/Source/track.cpp b/Source/track.cpp index 2dc420a41e2..9ec9fca6c0a 100644 --- a/Source/track.cpp +++ b/Source/track.cpp @@ -66,7 +66,7 @@ void RepeatMouseAction() if (sgbMouseDown == CLICK_NONE && ControllerActionHeld == GameActionType_NONE) return; - if (activeStore != TalkID::None) + if (ActiveStore != TalkID::None) return; if (LastMouseButtonAction == MouseActionType::None) diff --git a/test/fixtures/memory_map/game.txt b/test/fixtures/memory_map/game.txt index f1c98aac768..a725eef9f42 100644 --- a/test/fixtures/memory_map/game.txt +++ b/test/fixtures/memory_map/game.txt @@ -47,8 +47,8 @@ M_DL 12544 8 dLight M_DL 12544 8 dPreLight M_DL 1600 8 AutomapView M_DL 12544 8 dMissile -R 32 numPremiumItems -R 32 premiumItemLevel +R 32 PremiumItemCount +R 32 PremiumItemLevel C_DA 6 item PremiumItems C_HF 15 item PremiumItems R 8 AutomapActive diff --git a/test/pack_test.cpp b/test/pack_test.cpp index 2b5c8537c49..d72d0f5cc6f 100644 --- a/test/pack_test.cpp +++ b/test/pack_test.cpp @@ -1370,13 +1370,13 @@ TEST_F(NetPackTest, UnPackNetPlayer_invalid_townItemLevel) if ((item._iCreateInfo & CF_TOWN) == 0) continue; uint16_t createInfo = item._iCreateInfo; - bool boyItem = (item._iCreateInfo & CF_BOY) != 0; + bool BoyItem = (item._iCreateInfo & CF_BOY) != 0; item._iCreateInfo &= ~CF_LEVEL; - item._iCreateInfo |= boyItem ? MyPlayer->getMaxCharacterLevel() + 1 : 31; + item._iCreateInfo |= BoyItem ? MyPlayer->getMaxCharacterLevel() + 1 : 31; ASSERT_FALSE(TestNetPackValidation()); item._iCreateInfo = createInfo; - size_t &count = boyItem ? boyCount : otherCount; + size_t &count = BoyItem ? boyCount : otherCount; count++; } ASSERT_GT(boyCount, 0); diff --git a/test/stores_test.cpp b/test/stores_test.cpp index 825207777c8..0e4d60e29e9 100644 --- a/test/stores_test.cpp +++ b/test/stores_test.cpp @@ -10,7 +10,7 @@ TEST(Stores, AddStoreHoldRepair_magic) { Item *item; - item = &playerItem[0]; + item = &PlayerItems[0]; item->_iMaxDur = 60; item->_iDurability = item->_iMaxDur; @@ -23,18 +23,18 @@ TEST(Stores, AddStoreHoldRepair_magic) item->_ivalue = 2000; item->_iIvalue = 19000; item->_iDurability = i; - currentItemIndex = 0; + CurrentItemIndex = 0; AddStoreHoldRepair(item, 0); - EXPECT_EQ(1, currentItemIndex); + EXPECT_EQ(1, CurrentItemIndex); EXPECT_EQ(95 * (item->_iMaxDur - i) / 2, item->_ivalue); } item->_iDurability = 59; - currentItemIndex = 0; + CurrentItemIndex = 0; item->_ivalue = 500; item->_iIvalue = 30; // To cheap to repair AddStoreHoldRepair(item, 0); - EXPECT_EQ(0, currentItemIndex); + EXPECT_EQ(0, CurrentItemIndex); EXPECT_EQ(30, item->_iIvalue); EXPECT_EQ(500, item->_ivalue); } @@ -43,7 +43,7 @@ TEST(Stores, AddStoreHoldRepair_normal) { Item *item; - item = &playerItem[0]; + item = &PlayerItems[0]; item->_iMaxDur = 20; item->_iDurability = item->_iMaxDur; @@ -56,18 +56,18 @@ TEST(Stores, AddStoreHoldRepair_normal) item->_ivalue = 2000; item->_iIvalue = item->_ivalue; item->_iDurability = i; - currentItemIndex = 0; + CurrentItemIndex = 0; AddStoreHoldRepair(item, 0); - EXPECT_EQ(1, currentItemIndex); + EXPECT_EQ(1, CurrentItemIndex); EXPECT_EQ(50 * (item->_iMaxDur - i), item->_ivalue); } item->_iDurability = 19; - currentItemIndex = 0; + CurrentItemIndex = 0; item->_ivalue = 10; // less than 1 per dur item->_iIvalue = item->_ivalue; AddStoreHoldRepair(item, 0); - EXPECT_EQ(1, currentItemIndex); + EXPECT_EQ(1, CurrentItemIndex); EXPECT_EQ(1, item->_ivalue); EXPECT_EQ(1, item->_iIvalue); } From 9816f4765f997d263c6647badb1c3f16de33e60f Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Fri, 20 Sep 2024 17:43:15 -0400 Subject: [PATCH 3/6] Fix mistake --- Source/DiabloUI/credits.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/DiabloUI/credits.cpp b/Source/DiabloUI/credits.cpp index a3fffeab368..a6f6b4deeba 100644 --- a/Source/DiabloUI/credits.cpp +++ b/Source/DiabloUI/credits.cpp @@ -33,9 +33,9 @@ const int LINE_H = 22; class CreditsRenderer { public: - CreditsRenderer(char const *const *text, std::size_t TextLines) + CreditsRenderer(char const *const *text, std::size_t textLines) { - for (size_t i = 0; i < TextLines; i++) { + for (size_t i = 0; i < textLines; i++) { std::string_view orgText = _(text[i]); uint16_t offset = 0; From ba39efa1259ebda0600c6a487b7612d29394caa5 Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Fri, 20 Sep 2024 17:43:44 -0400 Subject: [PATCH 4/6] Fix mistake 2 --- Source/DiabloUI/credits.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/DiabloUI/credits.cpp b/Source/DiabloUI/credits.cpp index a6f6b4deeba..17c343a32e8 100644 --- a/Source/DiabloUI/credits.cpp +++ b/Source/DiabloUI/credits.cpp @@ -132,9 +132,9 @@ void CreditsRenderer::Render() } } -bool TextDialog(char const *const *text, std::size_t TextLines) +bool TextDialog(char const *const *text, std::size_t textLines) { - CreditsRenderer creditsRenderer(text, TextLines); + CreditsRenderer creditsRenderer(text, textLines); bool endMenu = false; if (IsHardwareCursor()) From 3cd94bc17346820bb01c7f99074ae9efed2fd048 Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Fri, 20 Sep 2024 17:48:25 -0400 Subject: [PATCH 5/6] Fix error 3 --- Source/items.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index f097d00e2ba..2c7effdee29 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1930,7 +1930,7 @@ _item_indexes RndPremiumItem(const Player &player, int minlvl, int maxlvl) return RndVendorItem(player, minlvl, maxlvl); } -void SpawnOnePremium(Item &PremiumItems, int plvl, const Player &player) +void SpawnOnePremium(Item &premiumItem, int plvl, const Player &player) { int strength = std::max(player.GetMaximumAttributeValue(CharacterAttribute::Strength), player._pStrength); int dexterity = std::max(player.GetMaximumAttributeValue(CharacterAttribute::Dexterity), player._pDexterity); @@ -1944,20 +1944,20 @@ void SpawnOnePremium(Item &PremiumItems, int plvl, const Player &player) int maxCount = 150; const bool unlimited = !gbIsHellfire; // TODO: This could lead to an infinite loop if a suitable item can never be generated for (int count = 0; unlimited || count < maxCount; count++) { - PremiumItems = {}; - PremiumItems._iSeed = AdvanceRndSeed(); - SetRndSeed(PremiumItems._iSeed); + premiumItem = {}; + premiumItem._iSeed = AdvanceRndSeed(); + SetRndSeed(premiumItem._iSeed); _item_indexes itemType = RndPremiumItem(player, plvl / 4, plvl); - GetItemAttrs(PremiumItems, itemType, plvl); - GetItemBonus(player, PremiumItems, plvl / 2, plvl, true, !gbIsHellfire); + GetItemAttrs(premiumItem, itemType, plvl); + GetItemBonus(player, premiumItem, plvl / 2, plvl, true, !gbIsHellfire); if (!gbIsHellfire) { - if (PremiumItems._iIvalue <= 140000) { + if (premiumItem._iIvalue <= 140000) { break; } } else { int itemValue = 0; - switch (PremiumItems._itype) { + switch (premiumItem._itype) { case ItemType::LightArmor: case ItemType::MediumArmor: case ItemType::HeavyArmor: { @@ -1979,7 +1979,7 @@ void SpawnOnePremium(Item &PremiumItems, int plvl, const Player &player) case ItemType::Ring: case ItemType::Amulet: { const auto *const mostValuablePlayerItem = player.GetMostValuableItem( - [filterType = PremiumItems._itype](const Item &item) { return item._itype == filterType; }); + [filterType = premiumItem._itype](const Item &item) { return item._itype == filterType; }); itemValue = mostValuablePlayerItem == nullptr ? 0 : mostValuablePlayerItem->_iIvalue; break; @@ -1989,18 +1989,18 @@ void SpawnOnePremium(Item &PremiumItems, int plvl, const Player &player) break; } itemValue = itemValue * 4 / 5; // avoids forced int > float > int conversion - if (PremiumItems._iIvalue <= 200000 - && PremiumItems._iMinStr <= strength - && PremiumItems._iMinMag <= magic - && PremiumItems._iMinDex <= dexterity - && PremiumItems._iIvalue >= itemValue) { + if (premiumItem._iIvalue <= 200000 + && premiumItem._iMinStr <= strength + && premiumItem._iMinMag <= magic + && premiumItem._iMinDex <= dexterity + && premiumItem._iIvalue >= itemValue) { break; } } } - PremiumItems._iCreateInfo = plvl | CF_SMITHPREMIUM; - PremiumItems._iIdentified = true; - PremiumItems._iStatFlag = player.CanUseItem(PremiumItems); + premiumItem._iCreateInfo = plvl | CF_SMITHPREMIUM; + premiumItem._iIdentified = true; + premiumItem._iStatFlag = player.CanUseItem(premiumItem); } bool WitchItemOk(const Player &player, const ItemData &item) From b96c55a83355ba0667685cca9bb8f4715bb9e84c Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Fri, 20 Sep 2024 17:50:26 -0400 Subject: [PATCH 6/6] Fix error 4 --- Source/msg.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/msg.cpp b/Source/msg.cpp index 8e13ef13639..0a6e2e445bd 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1700,12 +1700,12 @@ size_t OnTalkXY(const TCmd *pCmd, Player &player) { const auto &message = *reinterpret_cast(pCmd); const Point position { message.x, message.y }; - const uint16_t TownerIdx = SDL_SwapLE16(message.wParam1); + const uint16_t townerIdx = SDL_SwapLE16(message.wParam1); - if (gbBufferMsgs != 1 && player.isOnActiveLevel() && InDungeonBounds(position) && TownerIdx < NUM_TOWNERS) { + if (gbBufferMsgs != 1 && player.isOnActiveLevel() && InDungeonBounds(position) && townerIdx < NUM_TOWNERS) { MakePlrPath(player, position, false); player.destAction = ACTION_TALK; - player.destParam1 = TownerIdx; + player.destParam1 = townerIdx; } return sizeof(message);