## qc

### Hardware & Tech

.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...

Posts
Axe frames bug & variable bounds checks
numbersix quake-c coder++
Dec 26 2015 Anchor

I came across this here: Quakeone.com

How does it happen?

If you dont know exactly how this works, replicating it is darn near impossible. Most players have likely never seen this.

1. Select axe
2. While standing, wait until walkframe is over 6 *. In stand frames it loops at 12.
3. Fire the axe
4. Start to run immediately
5. Keep running

When the fire frames finish, frames will continue to increment as long as you run without stopping:

* The easiest way to determine walkframe is to put a console print in the code for player_stand1.

Why does this happen?

When any axe fire frame set finishes:

``void() player_axe4 = [\$axatt4, player_run ] {self.weap>``
``` Points self.think to "player_run" found as "void() player_run" in players.qc.We find this segment near the top: if (self.weapon == IT_AXE) { if (self.walkframe == 6) self.walkframe = 0; self.frame = \$axrun1 + self.walkframe; } // rest of code Which sees axe selected and tests for walkframe 6. If frames were incrementing normally 6 would follow 5 and this would catch it.But we fired the axe in standframes with walkframe more than 6! This test fails for any value not 6. Fix: if (self.weapon == IT_AXE) { if (self.walkframe >= 6) // rest of code follows Make that change and the axe frame bug will never rear its head.This comes down to proper bounds checking.You should always consider the possibility of every value a variable can assume when performing a logic check. Edited by: numbersix ```
``` ```