Opened 20 years ago

Closed 20 years ago

Last modified 5 years ago

#1384 closed defect (fixed)

ALL: Local script variables not always initialized

Reported by: eriktorbjorn Owned by: Kirben
Priority: low Component: Engine: SCUMM
Version: Keywords:
Cc: Game:


While looking for a different bug, I noticed that in SCUMM games we sometimes ensure that all unused local variables for a script are zeroed before calling runScript(), and sometimes we don't.

Specifically, I noticed these cases:

In Actor::startWalkAnim(), when a walk script is invoked.

In ScummEngine::runInventoryScript()

When running the boot script. In this case we don't even bother to give the script as many local variables as we usually do.

Now, in all likelyhood these cases are probably still well-defined. I assume the scripts never look at the uninitialized variables. But maybe we should initialize them anyway, just to be nice?

Ticket imported from: #874631. Ticket imported from: bugs/1384.

Change History (9)

comment:1 by fingolfin, 20 years ago

Priority: normallow
Resolution: invalid

comment:2 by fingolfin, 20 years ago

I am aware of this. Note that the original engines didn't init the local vars at all. In fact, we have severalhacks in our code base which work around scripting bugs - those scripts only worked in the original engine because the engine didn't clean the local vars properly (this is a case of a bug in the scripts being canceled out by a bug in the engine :-).

If you feel like it, you have my blessings of 'fixing' this. However, be aware that it might actually cause regressions, and is unlikely to fix any bugs.

comment:3 by Kirben, 20 years ago

Definately should zero all unused vars, this was cause of start up problem in puttputt: I was tracing down cause of puttputt trying to load non exisant verb images and noticed it was getting insane var values (ie 2292776) shortly before problem. The actual cause was that the inventory script's local vars were not been cleared.

I changed runInventoryScript() and startWalkAnim() to zero local script vars, would be worth enabling walkscripts again to see if they work better now too.

comment:4 by Kirben, 20 years ago

Resolution: invalid

comment:5 by Kirben, 20 years ago

Summary: Local script variables not always initialized?ALL: Local script variables not always initialized

comment:6 by Kirben, 20 years ago

Owner: set to Kirben
Resolution: fixed
Status: newclosed

comment:7 by fingolfin, 20 years ago

"enabling walkscripts again" -> what do you mean, walkscripts were never disabled ?!?

comment:8 by Kirben, 20 years ago

OK I was just cofused by the comment in startWalkAnim().

comment:9 by digitall, 5 years ago

Component: Engine: SCUMM
Note: See TracTickets for help on using tickets.