Opened 15 years ago

Closed 15 years ago

Last modified 6 months ago

#1384 closed defect (fixed)

ALL: Local script variables not always initialized

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


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 Changed 15 years ago by fingolfin

Priority: normallow
Resolution: invalid

comment:2 Changed 15 years ago by fingolfin

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 Changed 15 years ago by Kirben

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

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 Changed 15 years ago by Kirben

Resolution: invalid

comment:5 Changed 15 years ago by Kirben

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

comment:6 Changed 15 years ago by Kirben

Owner: set to Kirben
Resolution: fixed
Status: newclosed

comment:7 Changed 15 years ago by fingolfin

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

comment:8 Changed 15 years ago by Kirben

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

comment:9 Changed 6 months ago by digitall

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