DigglesMods / BugFix

Fixes bugs like 'forever pregnancy', Guard-House, 'transport experience calculation error'
GNU General Public License v3.0
1 stars 1 forks source link

Gnome left with food in inventory #18

Closed saibantes closed 1 month ago

saibantes commented 5 months ago

When a gnome's sparetime ends while they are on their way to eat, they will still continue to pick up the food item, but not eat it. This is bad because it blocks one inventory slot during work.

The reason is that in z_spare_procs.tcl, proc sparetime_eat_start, at the very end sparetime_eat_item is set but not used right away. Instead the gnome will eat it at the next call to sparetime_eat_loop - which will not occur if the sparetime ended.

This can be fixed in several ways:

  1. Don't pick up the item yet, just walk to it. Then eat and consume it in one go on the next call to sparetime_eat_loop.
  2. Drop the item if the sparetime is over.
  3. Eat the thing immediately, even if work time has started.

I might think of a solution later.

cech12 commented 5 months ago

The first variant sounds best to me. :) If you found a solution, you could open a PR for that :)

saibantes commented 5 months ago

The first variant seems to be the most complicated. Keep in mind that items that will be picked up are being locked, so that no other gnome will try to pick them up as well. Ending up not picking up the item but keeping it locked would make the fix worse than the bug.

The third options seems to be the easiest. I am currently testing

proc sparetime_eat_end {} {
    global sparetime_disappointment sparetime_eat_item
    if {[lsearch [inv_list this] $sparetime_eat_item]!=-1} {
        log "mealtime ends, so I will drop my leftovers ([get_objname $sparetime_eat_item])"
        beamto_world $sparetime_eat_item
    }
    set sparetime_eat_item 0
    sparetime_check_in 0
    set sparetime_disappointment 0.0
//  log "sparetime_eat_end"
}

in z_spare_procs.tcl.