Skip to content

Commit

Permalink
Merge pull request #75995 from andrei8l/npc-shop-fix-consumption
Browse files Browse the repository at this point in the history
npc: fix elapsed time for shop consumption
  • Loading branch information
Maleclypse authored Sep 5, 2024
2 parents 734ec4c + b8276a7 commit 2c3ad7b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1940,16 +1940,16 @@ int npc::max_willing_to_owe() const
void npc::shop_restock()
{
// Shops restock once every restock_interval
time_duration const elapsed =
restock != calendar::turn_zero ? calendar::turn - restock : 0_days;
if( ( restock != calendar::turn_zero ) && ( elapsed < 0_days ) ) {
time_duration elapsed = calendar::turn - restock;
if( restock != calendar::turn_zero &&
elapsed < myclass->get_shop_restock_interval() ) {
return;
}

if( is_player_ally() || !is_shopkeeper() ) {
return;
}
restock = calendar::turn + myclass->get_shop_restock_interval();
restock = calendar::turn;

std::vector<item_group_id> rigid_groups;
std::vector<item_group_id> value_groups;
Expand Down Expand Up @@ -2026,7 +2026,7 @@ void npc::shop_restock()
std::string npc::get_restock_interval() const
{
time_duration const restock_remaining =
restock - calendar::turn;
restock + myclass->get_shop_restock_interval() - calendar::turn;
std::string restock_rem = to_string( restock_remaining );
return restock_rem;
}
Expand Down

0 comments on commit 2c3ad7b

Please sign in to comment.