Author Topic: SCI1.1: Riddle me this  (Read 2867 times)

0 Members and 1 Guest are viewing this topic.

Offline Kawa

SCI1.1: Riddle me this
« on: July 13, 2015, 10:33:22 AM »
I have in my project:
rm100Title screen
rm102Rating selection and question list
rm103Introduction cutscene
rm104Credits and exposition cutscene
rm110The first playable room that helped find that polygon bug
Normal progression is 100-102-103-104-110. I mean to put a skip feature in there but there's another problem.

I can newRoom(110) from any one of these, except for 104. Calling gGame:newRoom(110) from any point in rm104 causes an Oops error in Sierra SCI, yet passes with no issue in ScummVM.

rm104.sc:
Code: [Select]
(version 2)
(include "sci.sh")
(include "Verbs.sh")
(include "0.shm")
(exports
0 rm104
)
(use "Main")
(use "Controls")
(use "Print")
(use "Cycle")
(use "Game")
(use "View")
(use "DebugOut")
(use "Obj")
(script 104)

(local
creditNum
captionNum
timer
textBuffer[200]
)

(define CREDITS 5)
(define CAPTIONS 2) //Should be 11 but we stop early for testing

(instance public rm104 of Rm
(properties
picture 104
)

(method (init)
SetPort(0 0 200 320 0 0)
//(if (gDialog) (send gDialog:dispose()) )
(super:init())

(send gGame:handsOff())
//(send gSq5IconBar:hide() disable())
//(send gUser:
// canControl(TRUE)
// canInput(TRUE)
//)

(aRoad:init() setCycle(Fwd) setPri(4))
(aCar:init())
= creditNum 0
= captionNum 0
= timer 0

(self:setScript(rmScript))
)

(method (dispose param1)
SetPort(0 0 190 320 10 0)
//(send gSq5IconBar:hide() enable())
//= gCursor 999
//(send gGame:setCursor(996 1))
(super:dispose(rest param1))
)
)

(instance rmScript of Script
(properties)

(method (changeState newState)
(switch (= state newState)
(case 0
//(send gSq5Music1: number(1001) loop(1) play())
= seconds 4
)
(case 1
++timer
(if (== timer 2)
++creditNum
= timer 0
(if (< creditNum CREDITS)
Message(msgGET 104 0 0 0 creditNum @textBuffer)
Display(@textBuffer dsCOORD 8 48 dsCOLOR 7 dsBACKGROUND 0 dsWIDTH 168 dsFONT 0 dsALIGN alCENTER)
)
)
++captionNum
(if (< captionNum CAPTIONS)
Message(msgGET 104 1 0 0 captionNum @textBuffer)
DebugPrint("Caption: %s" @textBuffer)
Display(@textBuffer dsCOORD 8 160 dsCOLOR 7 dsBACKGROUND 0 dsWIDTH 304 dsFONT 7 dsALIGN alCENTER)
--state
)
= seconds 6
)
(case 2
(aCar:setMotion(MoveTo 350 102 self))
)
(case 3
//Play crash
//(send gSq5Music1: number(1001) loop(1) play(self))
= seconds 2
)
(case 4
(send gGame:newRoom(110))
)
)
)
)

(instance aCar of Actor
(properties
view 104
x 240
y 102
)
)

(instance aRoad of Prop
(properties
view 104
loop 1
x 184
y 111
)
)

Excerpt from rm110.sc, which works fine if not coming from rm104:
Code: [Select]
(instance public rm110 of Rm
    (properties
        picture 110
        style (| dpANIMATION_BLACKOUT dpOPEN_FADEPALETTE)
        horizon 50
        vanishingX 130
        vanishingY 50
        east 120
        noun N_ROOM
    )

    (method (init)
//AddPolygonsToRoom(@P_Default110) //commented out for ScummVM's sake
(super:init())
SetUpEgo()
(switch (gPreviousRoomNumber)
(case east
(send gEgo: posn(150 180) loop(3))
)
(default
(send gEgo: posn(150 130) loop(1))
)
)
(send gEgo:init())

(aPuddle:init())
(aCar:init())

(send gGame:handsOn())

(if (not (== (send gSq5Music1: number) scriptNumber))
(send gSq5Music1: number(scriptNumber) loop(-1) play())
)
(if (not Btest(fDayOneStart))
Bset(fDayOneStart)
(send gEgo:get(0 1)) //Give keys and manuscript
(self:setScript(IntroScript))
)(else
(self:setScript(RoomScript))
)
DebugPrint("End of Init.")
)
)

There's a DebugPrint in the first and last case of IntroScript, and one in the first case of RoomScript.
Quote
Start of IntroScript.
End of Init.
Oops!

Strangely, skipping the entire script in rm104 like this
Code: [Select]
(aRoad:init() setCycle(Fwd) setPri(4))
(aCar:init())
= creditNum 0
= captionNum 0
= timer 0

//(self:setScript(rmScript))
(send gGame:newRoom(110))
)
yields no crash at all -- it flashes an empty road for as long as the transitions take, and the game begins just fine:
Quote
Start of IntroScript.
End of Init.
End of IntroScript.
Switched to RoomScript.

And again, the crash does not happen at all in ScummVM -- only in Sierra SCI.



Offline troflip

Re: SCI1.1: Riddle me this
« Reply #1 on: July 13, 2015, 10:39:40 AM »
The obvious suspect is the SetPort stuff in rm104. What happens if you remove it?

[edit:] oh, I see. Removing the setScript makes it not crash, but you're still calling SetPort in that case..

What happens if you make rm104 go to a different room (e.g. not 110)... does it crash then?
« Last Edit: July 13, 2015, 11:12:12 AM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Kawa

Re: SCI1.1: Riddle me this
« Reply #2 on: July 13, 2015, 11:19:49 AM »
What happens if you make rm104 go to a different room (e.g. not 110)... does it crash then?
Going from 104 to 102 (random pick) instead of rm110 gives exactly the same results: changeState case 0 runs, init completes, and it crashes. DebugPrint calls in places matching rm110's confirm it.

Offline Kawa

Re: SCI1.1: Riddle me this
« Reply #3 on: July 13, 2015, 12:43:26 PM »
Now this is interesting! I implemented a skip feature which at first took me from rm103 (opening cartoon) to rm110 (playable bit) when I clicked or pressed Enter (next level: a skip icon). This required the following:
Code: [Select]
(method (init)
SetPort(0 0 200 320 0 0)
(if (gDialog) (send gDialog:dispose()) )
(super:init())

//important lines to make handleEvent work
(send gOldMH:addToFront(self))
(send gOldKH:addToFront(self))

//...
)

(method (dispose param1)
//...
(send gOldKH:delete(self))
(send gOldMH:delete(self))
(super:dispose(rest param1))
)

(method (handleEvent pEvent)
(if ((send pEvent:type))
(send pEvent:claimed(1))
(send gGame:newRoom([wherever]))
)
)
Okay, so that worked. For no good reason at all, I then made rm103 skip to rm104 instead, and added the same stuff to rm104 to make it skip to rm110 in turn.

Which works, even though the script runs.

But letting the script finish and call newRoom(110) still causes the crash as before.

Offline troflip

Re: SCI1.1: Riddle me this
« Reply #4 on: July 13, 2015, 01:02:14 PM »
Ok... you're gonna kick yourself. You should be calling newRoom on gRoom, not gGame.


(that being said, I'm not sure why gGame:newRoom works when called from the init...).
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Kawa

Re: SCI1.1: Riddle me this
« Reply #5 on: July 13, 2015, 01:07:19 PM »
That did it, thanks.

Ow my leg.

Offline troflip

Re: SCI1.1: Riddle me this
« Reply #6 on: July 13, 2015, 01:12:09 PM »
Yeah, I hate that they have the same method name, because I think that I've made that mistake before too. I think Game:newRoom is only safe to call from a very specific place (specifically, the code in Game:doit).

I could probably add some warning in the template game if you accidentally call it.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: SCI1.1: Riddle me this
« Reply #7 on: July 13, 2015, 03:37:33 PM »
Do you really need that many rooms for your introduction sequence or would things get too cluttered (or hard on memory/heap?) by combining a couple into one script?
Brass Lantern Prop Competition

Offline Kawa

Re: SCI1.1: Riddle me this
« Reply #8 on: July 13, 2015, 03:43:13 PM »
Do you really need that many rooms for your introduction sequence or would things get too cluttered (or hard on memory/heap?) by combining a couple into one script?
It's mostly for the sake of keeping track of things, yeah.


SMF 2.0.14 | SMF © 2017, Simple Machines
Simple Audio Video Embedder

Page created in 0.11 seconds with 24 queries.