From e7ec90932a52fa1689330054f6e96dfe0d4df51b Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Fri, 12 Mar 2021 09:10:41 +0100 Subject: [PATCH] :green_heart: Expose AddStoreHoldRepair to the tests --- Source/stores.cpp | 57 +++++++++++++++++++---------------------- Source/stores.h | 8 ++++++ SourceT/stores_test.cpp | 5 ---- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Source/stores.cpp b/Source/stores.cpp index 8f600d80b..49ade869a 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -43,13 +43,6 @@ char stextscrldbtn; /** Remember current store while displaying a dialog */ talk_id stextshold; -/** Current index into storehidx/storehold */ -int storenumh; -/** Map of inventory items being presented in the store */ -char storehidx[48]; -/** Copies of the players items as presented in the store */ -ItemStruct storehold[48]; - /** Start of possible gossip dialogs for current store */ _speech_id gossipstart; /** End of possible gossip dialogs for current store */ @@ -578,29 +571,6 @@ BOOL SmithRepairOk(int i) return TRUE; } -void AddStoreHoldRepair(ItemStruct *itm, int i) -{ - ItemStruct *item; - int v; - - item = &storehold[storenumh]; - storehold[storenumh] = *itm; - - int due = item->_iMaxDur - item->_iDurability; - if (item->_iMagical != ITEM_QUALITY_NORMAL && item->_iIdentified) { - v = 30 * item->_iIvalue * due / (item->_iMaxDur * 100 * 2); - if (v == 0) - return; - } else { - v = item->_ivalue * due / (item->_iMaxDur * 2); - v = std::max(v, 1); - } - item->_iIvalue = v; - item->_ivalue = v; - storehidx[storenumh] = i; - storenumh++; -} - void S_StartSRepair() { BOOL repairok; @@ -2208,6 +2178,10 @@ Uint8 *pSTextSlidCels; talk_id stextflag; +int storenumh; +char storehidx[48]; +ItemStruct storehold[48]; + ItemStruct smithitem[SMITH_ITEMS]; int numpremium; int premiumlevel; @@ -2220,6 +2194,29 @@ ItemStruct witchitem[WITCH_ITEMS]; int boylevel; ItemStruct boyitem; +void AddStoreHoldRepair(ItemStruct *itm, int i) +{ + ItemStruct *item; + int v; + + item = &storehold[storenumh]; + storehold[storenumh] = *itm; + + int due = item->_iMaxDur - item->_iDurability; + if (item->_iMagical != ITEM_QUALITY_NORMAL && item->_iIdentified) { + v = 30 * item->_iIvalue * due / (item->_iMaxDur * 100 * 2); + if (v == 0) + return; + } else { + v = item->_ivalue * due / (item->_iMaxDur * 2); + v = std::max(v, 1); + } + item->_iIvalue = v; + item->_ivalue = v; + storehidx[storenumh] = i; + storenumh++; +} + void InitStores() { pSTextBoxCels = LoadFileInMem("Data\\TextBox2.CEL", NULL); diff --git a/Source/stores.h b/Source/stores.h index 213f46689..c78da85f8 100644 --- a/Source/stores.h +++ b/Source/stores.h @@ -62,6 +62,13 @@ extern BYTE *pSTextSlidCels; /** Currently active store */ extern talk_id stextflag; +/** Current index into storehidx/storehold */ +extern int storenumh; +/** Map of inventory items being presented in the store */ +extern char storehidx[48]; +/** Copies of the players items as presented in the store */ +extern ItemStruct storehold[48]; + /** Temporary item used to generate gold piles by various function */ extern ItemStruct golditem; @@ -85,6 +92,7 @@ extern int boylevel; /** Current item sold by Wirt */ extern ItemStruct boyitem; +void AddStoreHoldRepair(ItemStruct *itm, int i); void InitStores(); int PentSpn2Spin(); void SetupTownStores(); diff --git a/SourceT/stores_test.cpp b/SourceT/stores_test.cpp index 66cc66483..27635188c 100644 --- a/SourceT/stores_test.cpp +++ b/SourceT/stores_test.cpp @@ -3,11 +3,6 @@ namespace dvl { -extern ItemStruct storehold[48]; -extern int storenumh; - -void AddStoreHoldRepair(ItemStruct *itm, int i); - namespace { TEST(Stores, AddStoreHoldRepair_magic)