diff --git a/Source/control.cpp b/Source/control.cpp index 5cfdec301be..5af03b80cd5 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..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 || 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..65982b7d55f 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..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 (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..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 (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..e50b62433bd 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..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 (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..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 (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..2c7effdee29 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 = 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 (numpremium < maxItems) { + if (PremiumItemCount < 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 (PremiumItems[i].isEmpty()) { + int plvl = PremiumItemLevel + (gbIsHellfire ? premiumLvlAddHellfire[i] : premiumlvladd[i]); + SpawnOnePremium(PremiumItems[i], plvl, player); } } - numpremium = maxItems; + PremiumItemCount = 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(&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(&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(&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 (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(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(healitem + PinnedItemCount); + SortVendor(HealerItems + PinnedItemCount); } void MakeGoldStack(Item &goldItem, int value) diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 9cb06faae6b..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, premiumitems[i]); + LoadAndValidateItemData(file, PremiumItems[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(); + 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(numpremium); - file.WriteBE(premiumlevel); + file.WriteBE(PremiumItemCount); + file.WriteBE(PremiumItemLevel); for (int i = 0; i < giNumberOfSmithPremiumItems; i++) - SaveItem(file, premiumitems[i]); + SaveItem(file, PremiumItems[i]); file.WriteLE(AutomapActive ? 1 : 0); file.WriteBE(AutoMapScale); diff --git a/Source/qol/chatlog.cpp b/Source/qol/chatlog.cpp index 5e0da7a12b3..4fde2956aac 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..6d0d78394f0 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..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 (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..588eec54595 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 PlayerItems[48]; -Item smithitem[SMITH_ITEMS]; -int numpremium; -int premiumlevel; -Item premiumitems[SMITH_PREMIUM_ITEMS]; +Item SmithItems[SMITH_ITEMS]; +int PremiumItemCount; +int PremiumItemLevel; +Item PremiumItems[SMITH_PREMIUM_ITEMS]; -Item healitem[20]; +Item HealerItems[20]; -Item witchitem[WITCH_ITEMS]; +Item WitchItems[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; /** 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(SmithItems, static_cast(std::size(SmithItems)), 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; 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 : SmithItems) { 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 (!PremiumItems[idx].isEmpty()) boughtitems--; } - ScrollVendorStore(premiumitems, static_cast(std::size(premiumitems)), idx); + ScrollVendorStore(PremiumItems, static_cast(std::size(PremiumItems)), idx); } bool StartSmithPremiumBuy() { - storenumh = 0; - for (Item &item : premiumitems) { + CurrentItemIndex = 0; + for (Item &item : PremiumItems) { 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; 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,57 +506,57 @@ bool SmithSellOk(int i) void ScrollSmithSell(int idx) { - ScrollVendorStore(storehold, storenumh, idx, false); + ScrollVendorStore(PlayerItems, CurrentItemIndex, idx, false); } void StartSmithSell() { - stextsize = true; + IsTextFullSize = true; bool sellOk = false; - storenumh = 0; + CurrentItemIndex = 0; - for (auto &item : storehold) { + for (auto &item : PlayerItems) { 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]; + PlayerItems[CurrentItemIndex] = myPlayer.InvList[i]; - if (storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) - storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; + if (PlayerItems[CurrentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && PlayerItems[CurrentItemIndex]._iIdentified) + PlayerItems[CurrentItemIndex]._ivalue = PlayerItems[CurrentItemIndex]._iIvalue; - storehold[storenumh]._ivalue = std::max(storehold[storenumh]._ivalue / 4, 1); - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh] = i; - storenumh++; + 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 (storenumh >= 48) + if (CurrentItemIndex >= 48) break; if (SmithSellOk(-(i + 1))) { sellOk = true; - storehold[storenumh] = myPlayer.SpdList[i]; + PlayerItems[CurrentItemIndex] = myPlayer.SpdList[i]; - if (storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) - storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; + if (PlayerItems[CurrentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && PlayerItems[CurrentItemIndex]._iIdentified) + PlayerItems[CurrentItemIndex]._ivalue = PlayerItems[CurrentItemIndex]._iIvalue; - storehold[storenumh]._ivalue = std::max(storehold[storenumh]._ivalue / 4, 1); - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh] = -(i + 1); - storenumh++; + PlayerItems[CurrentItemIndex]._ivalue = std::max(PlayerItems[CurrentItemIndex]._ivalue / 4, 1); + PlayerItems[CurrentItemIndex]._iIvalue = PlayerItems[CurrentItemIndex]._ivalue; + PlayerItemIndexes[CurrentItemIndex] = -(i + 1); + CurrentItemIndex++; } } if (!sellOk) { - stextscrl = false; + HasScrollbar = false; RenderGold = true; AddSText(20, 1, _("You have nothing I want."), UiFlags::ColorWhitegold, false); @@ -565,14 +565,14 @@ void StartSmithSell() return; } - stextscrl = true; - stextsval = 0; - stextsmax = myPlayer._pNumInv; + HasScrollbar = true; + ScrollPos = 0; + NumTextLines = myPlayer._pNumInv; 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 : PlayerItems) { item.clear(); } @@ -627,15 +627,15 @@ 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; AddSText(20, 1, _("You have nothing to repair."), UiFlags::ColorWhitegold, false); @@ -644,15 +644,15 @@ void StartSmithRepair() return; } - stextscrl = true; - stextsval = 0; - stextsmax = myPlayer._pNumInv; + HasScrollbar = true; + ScrollPos = 0; + NumTextLines = myPlayer._pNumInv; 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(WitchItems, static_cast(std::size(WitchItems)), 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; 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 : WitchItems) { 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,52 +761,52 @@ bool WitchSellOk(int i) void StartWitchSell() { - stextsize = true; + IsTextFullSize = true; bool sellok = false; - storenumh = 0; + CurrentItemIndex = 0; - for (auto &item : storehold) { + for (auto &item : PlayerItems) { 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]; + PlayerItems[CurrentItemIndex] = myPlayer.InvList[i]; - if (storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) - storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; + if (PlayerItems[CurrentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && PlayerItems[CurrentItemIndex]._iIdentified) + PlayerItems[CurrentItemIndex]._ivalue = PlayerItems[CurrentItemIndex]._iIvalue; - storehold[storenumh]._ivalue = std::max(storehold[storenumh]._ivalue / 4, 1); - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh] = i; - storenumh++; + 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 (storenumh >= 48) + if (CurrentItemIndex >= 48) break; if (!myPlayer.SpdList[i].isEmpty() && WitchSellOk(-(i + 1))) { sellok = true; - storehold[storenumh] = myPlayer.SpdList[i]; + PlayerItems[CurrentItemIndex] = myPlayer.SpdList[i]; - if (storehold[storenumh]._iMagical != ITEM_QUALITY_NORMAL && storehold[storenumh]._iIdentified) - storehold[storenumh]._ivalue = storehold[storenumh]._iIvalue; + if (PlayerItems[CurrentItemIndex]._iMagical != ITEM_QUALITY_NORMAL && PlayerItems[CurrentItemIndex]._iIdentified) + PlayerItems[CurrentItemIndex]._ivalue = PlayerItems[CurrentItemIndex]._iIvalue; - storehold[storenumh]._ivalue = std::max(storehold[storenumh]._ivalue / 4, 1); - storehold[storenumh]._iIvalue = storehold[storenumh]._ivalue; - storehidx[storenumh] = -(i + 1); - storenumh++; + PlayerItems[CurrentItemIndex]._ivalue = std::max(PlayerItems[CurrentItemIndex]._ivalue / 4, 1); + PlayerItems[CurrentItemIndex]._iIvalue = PlayerItems[CurrentItemIndex]._ivalue; + PlayerItemIndexes[CurrentItemIndex] = -(i + 1); + CurrentItemIndex++; } } if (!sellok) { - stextscrl = false; + HasScrollbar = false; RenderGold = true; AddSText(20, 1, _("You have nothing I want."), UiFlags::ColorWhitegold, false); @@ -816,14 +816,14 @@ void StartWitchSell() return; } - stextscrl = true; - stextsval = 0; - stextsmax = myPlayer._pNumInv; + HasScrollbar = true; + ScrollPos = 0; + NumTextLines = myPlayer._pNumInv; 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++; + 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() { - stextsize = true; + IsTextFullSize = true; bool rechargeok = false; - storenumh = 0; + CurrentItemIndex = 0; - for (auto &item : storehold) { + for (auto &item : PlayerItems) { 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,7 +880,7 @@ void StartWitchRecharge() } if (!rechargeok) { - stextscrl = false; + HasScrollbar = false; RenderGold = true; AddSText(20, 1, _("You have nothing to recharge."), UiFlags::ColorWhitegold, false); @@ -889,22 +889,22 @@ void StartWitchRecharge() return; } - stextscrl = true; - stextsval = 0; - stextsmax = myPlayer._pNumInv; + HasScrollbar = true; + ScrollPos = 0; + NumTextLines = myPlayer._pNumInv; 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; + 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); @@ -912,16 +912,16 @@ void StoreNoMoney() 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; 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(HealerItems, static_cast(std::size(HealerItems)), idx); } void StartHealerBuy() { - stextsize = true; - stextscrl = true; - stextsval = 0; + IsTextFullSize = true; + HasScrollbar = true; + ScrollPos = 0; 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 : HealerItems) { 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++; + PlayerItems[CurrentItemIndex] = itm; + PlayerItems[CurrentItemIndex]._ivalue = 100; + PlayerItems[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 : PlayerItems) { 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,7 +1163,7 @@ void StartStorytellerIdentify() } if (!idok) { - stextscrl = false; + HasScrollbar = false; RenderGold = true; AddSText(20, 1, _("You have nothing to identify."), UiFlags::ColorWhitegold, false); @@ -1172,22 +1172,22 @@ void StartStorytellerIdentify() return; } - stextscrl = true; - stextsval = 0; - stextsmax = myPlayer._pNumInv; + HasScrollbar = true; + ScrollPos = 0; + NumTextLines = myPlayer._pNumInv; 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(); + 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 (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(SmithItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(smithitem[idx], false)) { + if (!StoreAutoPlace(SmithItems[idx], false)) { StartStore(TalkID::NoRoom); return; } - StoreItem = smithitem[idx]; + TempItem = SmithItems[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 (!PremiumItems[i].isEmpty()) { idx--; xx = i; } } - premiumitems[xx].clear(); - numpremium--; + PremiumItems[xx].clear(); + PremiumItemCount--; 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 (!PremiumItems[i].isEmpty()) { xx--; idx = i; } } - if (!PlayerCanAfford(premiumitems[idx]._iIvalue)) { + if (!PlayerCanAfford(PremiumItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(premiumitems[idx], false)) { + if (!StoreAutoPlace(PremiumItems[idx], false)) { StartStore(TalkID::NoRoom); return; } - StoreItem = premiumitems[idx]; + TempItem = PremiumItems[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 = 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 (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(PlayerItems[idx])) { StartStore(TalkID::NoRoom); return; } - StoreItem = storehold[idx]; + TempItem = PlayerItems[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); + PlayerItems[idx]._iDurability = PlayerItems[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(PlayerItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - StoreItem = storehold[idx]; + TempItem = PlayerItems[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(); + 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 (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(WitchItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(witchitem[idx], false)) { + if (!StoreAutoPlace(WitchItems[idx], false)) { StartStore(TalkID::NoRoom); return; } - StoreItem = witchitem[idx]; + TempItem = WitchItems[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(PlayerItems[idx])) { StartStore(TalkID::NoRoom); return; } - StoreItem = storehold[idx]; + TempItem = PlayerItems[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); + PlayerItems[idx]._iCharges = PlayerItems[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(PlayerItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - StoreItem = storehold[idx]; + TempItem = PlayerItems[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(); + HealerItems[19].clear(); } else { - for (; !healitem[idx + 1].isEmpty(); idx++) { - healitem[idx] = std::move(healitem[idx + 1]); + for (; !HealerItems[idx + 1].isEmpty(); idx++) { + HealerItems[idx] = std::move(HealerItems[idx + 1]); } - healitem[idx].clear(); + HealerItems[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(HealerItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - if (!StoreAutoPlace(healitem[idx], false)) { + if (!StoreAutoPlace(HealerItems[idx], false)) { StartStore(TalkID::NoRoom); return; } - StoreItem = healitem[idx]; + TempItem = HealerItems[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(PlayerItems[idx]._iIvalue)) { StartStore(TalkID::NoMoney); return; } - StoreItem = storehold[idx]; + TempItem = PlayerItems[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 = &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; - 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; + PremiumItemCount = 0; + PremiumItemLevel = 1; - for (auto &premiumitem : premiumitems) + for (auto &premiumitem : PremiumItems) 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; } } @@ -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 { - 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) { 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..cea33714bbc 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/PlayerItems */ +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 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 numpremium; +extern int PremiumItemCount; /** 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 PremiumItems[SMITH_PREMIUM_ITEMS]; /** Items sold by Pepin */ -extern Item healitem[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 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..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 (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..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 numpremium -R 32 premiumlevel +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 b321cf87ecd..0e4d60e29e9 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 = &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; - 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 = &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; - 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); }