Sign in to follow this  

Incorrect logic in yotb_stager:DeclareWinner() causes crash.


penguin0616
  • Pending

When the posts do not have a valid hitched beefalo (I managed to cause this by using a pan flute during the selection process), YOTB_STAGER:GetBeefScore(...) is called on the nil beefalo and the game crashes.

This is due to YOTB_STAGER:DeclareWinner() attempting to assign the beef score to member "candidate_values" to the beefalo BEFORE checking that the beefalo actually exists. 

Please let me know if additional information is required.

Picture of the flawed game code:

Spoiler

image.thumb.png.90cee7b151de4ca6d248e0860923ea5f.png

Error: 

Spoiler

[00:06:43]: [string "scripts/components/yotb_stager.lua"]:696: attempt to index local 'beef' (a nil value)
LUA ERROR stack traceback:
scripts/components/yotb_stager.lua:696 in (method) GetBeefScore (Lua) <695-718>
   self =
      choice = far
      temp_trainers = table: 9363E678
      tasks = table: 91ED20F0
      voice = 160486 - yotb_stage_voice (valid:true)
      queue = table: 91ED22A8
      temp_beefalo = table: A70AD010
      inst = 105204 - yotb_stage (valid:true)
      target_values = table: 9617F640
      posts = table: 9617EC90
      current_post = 0
      starter = 107354 - wilson (valid:true)
   beef = nil
scripts/components/yotb_stager.lua:877 in (method) DeclareWinner (Lua) <863-971>
   self =
      choice = far
      temp_trainers = table: 9363E678
      tasks = table: 91ED20F0
      voice = 160486 - yotb_stage_voice (valid:true)
      queue = table: 91ED22A8
      temp_beefalo = table: A70AD010
      inst = 105204 - yotb_stage (valid:true)
      target_values = table: 9617F640
      posts = table: 9617EC90
      current_post = 0
      starter = 107354 - wilson (valid:true)
   time = 0
   scores = table: 126AB740
   lowest_score = 9999
   lowest_index = 0
   index = 1
   v = 104025 - yotb_post (valid:true)
   beefalo = nil
scripts/components/yotb_stager.lua:841 in (field) fn (Lua) <840-842>
scripts/scheduler.lua:177 in (method) OnTick (Lua) <155-207>
   self =
      running = table: 17253E58
      waitingfortick = table: 17253E80
      tasks = table: 17253CA0
      waking = table: 879C3CC8
      attime = table: 17253D18
      hibernating = table: 17253C28
   tick = 2667
   k = PERIODIC 105204: 25.000000
   v = true
   already_dead = false
scripts/scheduler.lua:371 in (global) RunScheduler (Lua) <369-377>
   tick = 2667
scripts/update.lua:185 in () ? (Lua) <164-243>
   dt = 0.033333335071802
   tick = 2667
   i = 2667

 

 


Steps to Reproduce

1) Start a contest

2) During selection phase, use a pan flute

3) Crash, if you timed it properly.

Sign in to follow this  


User Feedback


There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now