Skip to content

Commit

Permalink
reorder stores.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
pionere committed Aug 8, 2024
1 parent c9d8fe0 commit 64f8f16
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions Source/stores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ static const char* const talkname[] = {
// clang-format on
};

static void StoreUpdateSelection();

static void ClearSText(int s, int e)
{
// int i;
Expand Down Expand Up @@ -866,9 +864,9 @@ static void S_StartNoMoney()
{
// StartStore(stextshold);
// ClearSText(STORE_LIST_FIRST, STORE_LINES);
// gbHasScroll = false;
gbWidePanel = true;
// gbRenderGold = true;
// gbHasScroll = false;
AddSText(0, 14, true, "You do not have enough gold", COL_WHITE, true);

// AddSLine(3);
Expand All @@ -879,9 +877,9 @@ static void S_StartNoRoom()
{
// StartStore(stextshold);
// ClearSText(STORE_LIST_FIRST, STORE_LINES);
// gbHasScroll = false;
gbWidePanel = true;
// gbRenderGold = true;
// gbHasScroll = false;
AddSText(0, 14, true, "You do not have enough room in inventory", COL_WHITE, true);

// AddSLine(3);
Expand All @@ -899,9 +897,9 @@ static void S_StartConfirm()
{
// StartStore(stextshold);
// ClearSText(STORE_LIST_FIRST, STORE_LINES);
// gbHasScroll = false;
gbWidePanel = true;
// gbRenderGold = true;
// gbHasScroll = false;
AddSItem(260, STORE_LIST_FIRST, 0, storeitem._iCurs, FALSE);
PrintStoreItem(&storeitem, STORE_LIST_FIRST - 1 + STORE_ITEM_LINES, false);
AddSTextVal(STORE_LIST_FIRST - 1 + STORE_ITEM_LINES, storeitem._iIvalue);
Expand Down Expand Up @@ -1233,8 +1231,9 @@ void StartStore(int s)
stextflag = s;
stextsidx = 0;
stextsmax = 0;
gbHasScroll = false;
gbWidePanel = false; // 11 vs 14
// gbRenderGold = false;
gbHasScroll = false;
switch (s) {
case STORE_SMITH:
S_StartSmith();
Expand Down Expand Up @@ -1329,6 +1328,23 @@ void StartStore(int s)
stextselx = 0;
}

static void StoreUpdateSelection()
{
if (stextsidx > stextsmax) {
stextsidx = stextsmax;
}
DEBUG_ASSERT(stextsel != -1);
while (/*stextsel != -1 && */ !stextlines[stextsel]._ssel) {
stextsel--;
DEBUG_ASSERT(stextsel != -1);
}
if (/*stextsel != -1 && */ stextlines[stextsel]._sitemlist) {
while (stextselx >= 0 && stextlines[stextsel]._siCurs[stextselx] == CURSOR_NONE) {
stextselx--;
}
}
}

/*void DrawStoreLineX(int sx, int sy, int dx, int dy, int length)
{
int sxy, dxy, width;
Expand Down Expand Up @@ -2009,23 +2025,6 @@ void SyncStoreCmd(int pnum, int cmd, int ii, int price)
StoreUpdateSelection();
}

static void StoreUpdateSelection()
{
if (stextsidx > stextsmax) {
stextsidx = stextsmax;
}
DEBUG_ASSERT(stextsel != -1);
while (/*stextsel != -1 && */ !stextlines[stextsel]._ssel) {
stextsel--;
DEBUG_ASSERT(stextsel != -1);
}
if (/*stextsel != -1 && */ stextlines[stextsel]._sitemlist) {
while (stextselx >= 0 && stextlines[stextsel]._siCurs[stextselx] == CURSOR_NONE) {
stextselx--;
}
}
}

/**
* @brief Sells an item from the player's inventory or belt.
*/
Expand Down

0 comments on commit 64f8f16

Please sign in to comment.