Browse Source

💚 Expose AddStoreHoldRepair to the tests

pull/1166/head
Anders Jenbo 5 years ago
parent
commit
e7ec90932a
  1. 57
      Source/stores.cpp
  2. 8
      Source/stores.h
  3. 5
      SourceT/stores_test.cpp

57
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);

8
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();

5
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)

Loading…
Cancel
Save