Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gnome left with food in inventory #18

Closed
saibantes opened this issue Apr 15, 2024 · 2 comments · Fixed by #23
Closed

Gnome left with food in inventory #18

saibantes opened this issue Apr 15, 2024 · 2 comments · Fixed by #23
Labels

Comments

@saibantes
Copy link

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
Copy link
Member

cech12 commented Apr 16, 2024

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

@saibantes
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
2 participants