Skip to content

Duke3D: Prevent double allocation of qputs strings inside a switch.

Dino Bollinger requested to merge dibollinger/eduke32:double_redefine into master

Works properly, but can probably be handled better, e.g. by improving the C_CountCaseStatements() function. Will suggest it anyways.

The problem is that the counting phase for the switch statement also already performs all stateful changes inside that switch. Then the parsing is rewinded, and the script compiler will perform all the same actions a second time. This should normally not be a problem, as most declarative statements are placed outside of switch statements, but qputs aka. redefinequote takes effect both when compiling as well as during runtime. Because of this, it can be found in switches.

There may be other commands that need to be considered for this as well.

Fixes #102 (closed)

Merge request reports