by ZzZombo » Fri Sep 18, 2015 9:10 pm
https://github.com/rheit/zdoom/pull/392.
I found out the reason today why the hell all of my scripts randomly stop working. They all do not contain any call to SetResultValue(). But their result value is used in the calling routine, if it's false the routine ends. So I was quite surprised when the said routine stops working half the time instead of working all the time. I first blamed BCC, then checked the ACS VM code and found out PCD_DROP, that is used to decrement the stack pointer in Hexen, in ZDoom falls through to the next case label, that is PCD_SETRESULTVALUE... Since it's used to unwind the stack if the return value of a function wasn't used, and most of the time it's void return type functions, it ultimately sets the script result value to 0 that breaks the convention of implicit 1 result value unless changed by SetResultvalue().
Blzut3 pointed out some possible cases where people unintentionally called a script expecting it to return 0 without actually calling SetResultValue(0), but PCD_DROP did that and they thought it works as desired, but I don't think those cases reach enough size to consider backwards compatibility, so I made the pull request. However second opinion on this is welcome. There also were some ways to fix this w/o changing the VM, but they unfortunately require compiler support, and Positron for one refused to add that.
https://github.com/rheit/zdoom/pull/392.
I found out the reason today why the hell all of my scripts randomly stop working. They all do not contain any call to SetResultValue(). But their result value is used in the calling routine, if it's false the routine ends. So I was quite surprised when the said routine stops working half the time instead of working all the time. I first blamed BCC, then checked the ACS VM code and found out PCD_DROP, that is used to decrement the stack pointer in Hexen, in ZDoom falls through to the next case label, that is PCD_SETRESULTVALUE... Since it's used to unwind the stack if the return value of a function wasn't used, and most of the time it's void return type functions, it ultimately sets the script result value to 0 that breaks the convention of implicit 1 result value unless changed by SetResultvalue().
Blzut3 pointed out some possible cases where people unintentionally called a script expecting it to return 0 without actually calling SetResultValue(0), but PCD_DROP did that and they thought it works as desired, but I don't think those cases reach enough size to consider backwards compatibility, so I made the pull request. However second opinion on this is welcome. There also were some ways to fix this w/o changing the VM, but they unfortunately require compiler support, and Positron for one refused to add that.