Skip to content

Commit

Permalink
fix: itemcache bullshit errors
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyV99 committed Aug 20, 2023
1 parent e646db3 commit 23d9607
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/gamedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ void gamedata::set_counter(word change, byte c)
if(c>=MAX_COUNTERS) // Sanity check
return;

flushItemCache(true);

if(game!=NULL)
{
int32_t ringID=current_item_id(itype_ring, true);
_counter[c]=zc_max(change, 0);

flushItemCache(true);

// ringcolor is very slow, so make sure the ring has actually changed
if(ringID!=current_item_id(itype_ring, true))
ringcolor(false);
Expand All @@ -168,14 +168,14 @@ void gamedata::change_counter(int16_t change, byte c)

if(c>=MAX_COUNTERS) // Sanity check
return;

flushItemCache(true);

if(game!=NULL)
{
int32_t ringID=current_item_id(itype_ring, true);
_counter[c]=vbound(_counter[c]+change, 0, _maxcounter[c]);

flushItemCache(true);

if(ringID!=current_item_id(itype_ring, true))
ringcolor(false);
}
Expand Down
15 changes: 15 additions & 0 deletions src/new_subscr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ void refresh_subscr_items()
{
subscr_item_clk = 0;
subscr_itemless = false;
if(replay_version_check(0,19))
{
//This needs to be here for the item cache to be correct...
for(int i = 0; i < itype_max; ++i)
{
switch(i)
{
case itype_map:
case itype_compass:
case itype_bosskey:
continue;
}
current_item_id(i,false);
}
}
}

void kill_subscr_items()
Expand Down
5 changes: 2 additions & 3 deletions src/zc/zc_sys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2287,7 +2287,7 @@ int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
jinx_check = false; //not jinxed
}
if(itemtype == itype_ring) checkmagic = true;
if (!jinx_check)
if (!jinx_check && (use_cost_cache || itemtype != itype_ring))
{
auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
auto res = cache.find(itemtype);
Expand All @@ -2305,8 +2305,7 @@ int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
{
if(checkmagic && itemtype != itype_magicring)
if(!checkmagiccost(i))
if ( !get_qr(qr_NEVERDISABLEAMMOONSUBSCREEN) )
continue; //don't make items with a magic cost vanish!! -Z
continue;
if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
continue;
Expand Down

0 comments on commit 23d9607

Please sign in to comment.