Author Topic: Is my game corrupt?  (Read 4824 times)

0 Members and 1 Guest are viewing this topic.

Offline MusicallyInspired

Is my game corrupt?
« on: August 25, 2010, 02:19:02 PM »
This game I'm working on crashes consistently when making a seemingly routine switch to a new title screen room after the initial logo screen. I ran it in debug mode and this is what it gives me:




And it seems to be random every time depending on if I skip the sequence with enter, skip it with escape, or let it play through:





Here are the scripts for the previous room and the room it crashes on when it switches:

Code: [Select]
(include "sci.sh")
(include "game.sh")
(use "main")
(use "game")
(use "menubar")
(use "obj")
(use "cycle")
(use "user")
(use "controls")
(use "feature")
(script TITLESCREEN_SCRIPT)

(instance TitleScreen of Rm
    (properties
        picture scriptNumber
    )
    (method (init)
        ProgramControl()
        = gProgramControl FALSE
        (send gGame:setSpeed(7))
        (SL:disable())
        (TheMenuBar:hide())
        (super:init())
        (self:setScript(RoomScript))
        (Animate((DrawPic(800 dpOPEN_CENTEREDGE))))
        (send gEgo:init() hide())
        (send gTheMusic:prevSignal(0) stop() number(0) loop(0) play())
        (Wolf:init() setLoop(0) hide())
    )


)
(instance RoomScript of Script
    (properties)
    (method (changeState newState)
        = state newState
        (switch ((state))
            (case0
                (= cycles 1)
                ProgramControl()
                = gProgramControl TRUE
            )
            (case1
                = cycles 1
                (send gGame:setCursor(997 0))
            )
            (case2
                = seconds 6
            )
            (case3
                (Wolf:show() setCycle(Fwd) setMotion(MoveTo 215 156 RoomScript))
            )
            (case4
                = cycles 30
                (Wolf:setLoop(1) setCel(0) cycleSpeed(1) setCycle(End))
            )
            (case5
                = cycles 15
                (Wolf:dispose())
                DrawPic(801 dpOPEN_TOP dpCLEAR gDefaultPalette)
                (Moon:init())
            )
            (case6
                = cycles 10
                (Moon:setCycle(End))
            )
            (case7
                = seconds 2
                (Infamous:init())
            )
            (case8
                = seconds 4
                (Adventures:init())
            )
            (case9
                = seconds 1
                (Infamous:dispose())
                (Adventures:dispose())
            )
            (case10
                (Moon:setLoop(0) setCel(4) setCycle(Beg RoomScript))
            )
            (case11
                = cycles 10
                (Moon:dispose())
            )
            (case12
                (send gGame:newRoom(803))
            )
        )
    )


    (method (doit)
        (super:doit())
    )


    (method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if (== (send pEvent:type) evKEYBOARD)
            (switch ((send pEvent:message))
                (caseKEY_ESCAPE
                    (send gTheMusic:fade())
                    (send gGame:newRoom(803))
                )
                (caseKEY_RETURN
                    (send gTheMusic:fade())
                    (send gGame:newRoom(803))
                )
            )
        )
    )


)
(instance Wolf of Act
    (properties
        view 903
        x 310
        y 156
        loop 0
        cycleSpeed 0
    )
)
(instance Moon of Prop
    (properties
        x 160
        y 60
        view 900
        loop 1
        cel 0
        cycleSpeed 0
    )
)
(instance Infamous of Prop
    (properties
        x 160
        y 146
        view 901
    )
)
(instance Adventures of Prop
    (properties
        x 160
        y 178
        view 902
    )
)

The room it crashes on upon loading:

Code: [Select]
(include "sci.sh")
(include "game.sh")
(use "Controls")
(use "Cycle")
(use "Door")
(use "Feature")
(use "Game")
(use "Inv")
(use "Main")
(use "Obj")
(script 803)
(local dGrahamYolk = 0 )
(local dFortuneYolk = 0 )


(instance rm803 of Rm
    (properties
        picture scriptNumber
        north 0
        east 0
        south 0
        west 0
    )
    (method (init)
        (super:init())
        (self:setScript(RoomScript))
        (switch ((gPreviousRoomNumber))
            (default
                (Animate((DrawPic(803 dpOPEN_CENTEREDGE))))
            )
        )
        (send gEgo:init() hide())
    )


)
(instance RoomScript of Script
    (properties)
    (method (doit)
        (super:doit())
    )


    (method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if (== (send pEvent:type) evKEYBOARD)
            (switch ((send pEvent:message))
            )
        )
    )


    (method (changeState newState)
        (= state newState)
        (switch ((newState))
            (case0
                (= cycles 1)
                ProgramControl()
                = gProgramControl TRUE
            )
            (case1
                = cycles 1
                (send gGame:setCursor(999 0))
            )
            (case2
                = seconds 2
            )
            (case21
                (send gGame:newRoom(802))
            )
        )
    )


)
« Last Edit: August 25, 2010, 02:26:41 PM by MusicallyInspired »


Brass Lantern Prop Competition

Offline MusicallyInspired

Re: Is my game corrupt?
« Reply #1 on: August 25, 2010, 02:45:19 PM »
Hmm, actually that second room had some Instances at the bottom that weren't being used yet so I just deleted them from the code snippet I posted. When I actually commented them out the room loaded fine. Soon as I put them back in the game crashes again. Even if I do something with them in the script. Any idea why that would happen?

EDIT: I tried compiling the same script in SCI Studio and the game runs flawlessly. It must be an issue with SCI Companion. The first one I've ever run into.
« Last Edit: August 25, 2010, 03:35:09 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline Cloudee1

Re: Is my game corrupt?
« Reply #2 on: August 25, 2010, 04:24:52 PM »
When you say it crashes, do you get the oops error or what?

And if the offending code is in the part of the script that you removed from the post, that makes it harder for us to help.

I'll scroll through what you gave us and give you any thoughts:

1. When you Drawpic, why are you using animate. Isn't DrawPic(800 dpOPEN_CENTEREDGE) sufficient?

2. The second set of parenthesis is unnecesary ((state)) in your changestate.

3. during your changestate, you have this: (Wolf:setLoop(1) setCel(0) ... you don't have to use setLoop or setCel in situations like this, loop(1) cel(0) work just as good.

4. (Wolf:dispose()) I have always had mixed results with disposing. It doesn't work exactly like I think it should with the pnc stuff so in a situation like this I just hide() and posn(400 400) not that your way doesn't work perfectly well.

Alright, thats about all I see that raises an eyebrow, besides having two local sections in room 803, instead of just one with both variables declared in it, and the fact that nothing we see ever gets us to case 21. I don't see what I was expecting to see and nothing else jumps out at me as being wrong that I have ever come across. I have had a couple of wierd things happen on occasion while using companion, every once and a while any wondering character heads straight north. Usually if I recompile all, the situation clears itself up.
« Last Edit: August 25, 2010, 04:27:20 PM by Cloudee1 »
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline MusicallyInspired

Re: Is my game corrupt?
« Reply #3 on: August 25, 2010, 05:21:06 PM »
I copied those codes from Companion's "View Syntax Tree" function so it probably added those extra parentheses. Yes, if I don't do debug mode it gives me the "Oops!" message.

As far as the bits of code I removed, I removed them because they give away stuff. I suppose I can just rename them.

Thanks for the DrawPic thing. I don't remember why I used Animate. It was suggested to me years ago for KQ2SCI. Probably on the Mega-Tokyo boards.

The View Syntax Tree function is also responsible for creating two Local sections. They shouldn't even be in that script, actually. So I've removed them. Here is the unadulterated scripts that crash the game when compiled with Companion and run just fine when compiled with Studio.

Code: [Select]
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script TITLESCREEN_SCRIPT)
/******************************************************************************/
(use "main")
(use "game")
(use "menubar")
(use "obj")
(use "cycle")
(use "user")
(use "controls")
(use "feature")
/******************************************************************************/
(instance public TitleScreen of Rm
(properties
picture scriptNumber
)
(method (init)
        // Set up the title screen
ProgramControl()
= gProgramControl FALSE
(send gGame:setSpeed(7))
(SL:disable())
(TheMenuBar:hide())

(super:init())
(self:setScript(RoomScript))

DrawPic(800 dpOPEN_CENTEREDGE)

(send gEgo:
init()
hide()
)
 
        /****************************************
         * Set up the room's music to play here *
         ****************************************/
(send gTheMusic:
prevSignal(0)
stop()
number(0)
loop(0)
play()
)       

        /**************************************************
         * Add the rest of your initialization stuff here *
         **************************************************/
         (Wolf:init()hide()setLoop(0))
)
)
/******************************************************************************/
(instance RoomScript of Script
(properties)     
    (method (changeState newState)
= state newState
(switch(state)
(case 0
(= cycles 1)
ProgramControl()
= gProgramControl TRUE
)
(case 1 = cycles 1
(send gGame:setCursor(997 0))
)
(case 2 = seconds 6

)
(case 3
(Wolf:show()setCycle(Fwd)setMotion(MoveTo 215 156 RoomScript))
)
(case 4 = cycles 30
(Wolf:loop(1)cel(0)cycleSpeed(1)setCycle(End))
)
(case 5 = cycles 15
(Wolf:dispose())
DrawPic(801 dpOPEN_TOP dpCLEAR gDefaultPalette)
(Moon:init())
)
(case 6 = cycles 10
(Moon:setCycle(End))
)
(case 7 = seconds 2
(Infamous:init())
)
(case 8 = seconds 4
(Adventures:init())
)
(case 9 = seconds 1
(Infamous:dispose())
(Adventures:dispose())
)
(case 10
(Moon:setLoop(0)setCel(4)setCycle(Beg RoomScript))
)
(case 11 = cycles 10
(Moon:hide())
)
(case 12
(send gGame:newRoom(803))
)
)
)
(method (doit)
(super:doit())
// code executed each game cycle
)
(method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if (== (send pEvent:type) evKEYBOARD)
            (switch(send pEvent:message)
            (case KEY_ESCAPE
            (send gTheMusic:fade())
(send gGame:newRoom(803))
)
(case KEY_RETURN
(send gTheMusic:fade())
(send gGame:newRoom(803))
)
)
)
)
)
/******************************************************************************/
(instance Wolf of Act
(properties
view 903
x 310
y 156
loop 0
cycleSpeed 0
)
)
(instance Moon of Prop
(properties
x 160
y 60
view 900
loop 1
cel 0
cycleSpeed 0
)
)
(instance Infamous of Prop
(properties
x 160
y 146
view 901
)
)
(instance Adventures of Prop
(properties
x 160
y 178
view 902
)
)

The crash room:

Code: [Select]
/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 803)
/******************************************************************************/
(use "Controls")
(use "Cycle")
(use "Door")
(use "Feature")
(use "Game")
(use "Inv")
(use "Main")
(use "Obj")
/******************************************************************************/
(instance public rm803 of Rm
(properties
picture scriptNumber
north 0
east 0
south 0
west 0
)
(method (init)
(super:init())
(self:setScript(RoomScript))
(titleOne:init()setCel(0))
(titleTwo:init()setCel(1))
(titleThree:init()setCel(2))

(switch(gPreviousRoomNumber)
(default
DrawPic(803 dpOPEN_CENTEREDGE)
)
)
(send gEgo:init()hide())
)
)
/******************************************************************************/
(instance RoomScript of Script
(properties)

(method (doit)
(super:doit())
// code executed each game cycle
)

(method (handleEvent pEvent)
(super:handleEvent(pEvent))
// handle Said's, etc...
(if (== (send pEvent:type) evKEYBOARD)
            (switch(send pEvent:message)
            (case KEY_ESCAPE
            (send gTheMusic:fade())
(send gGame:newRoom(802))
)
(case KEY_RETURN
(send gTheMusic:fade())
(send gGame:newRoom(802))
)
)
)
)

(method (changeState newState)
(= state newState)
(switch (newState)
(case 0
(= cycles 1)
ProgramControl()
= gProgramControl TRUE
)
(case 1 = cycles 1
(send gGame:setCursor(997 0))
)
(case 2 = seconds 5

)
(case 3
(send gGame:newRoom(802))
)
)
)
)
/******************************************************************************/
(instance titleOne of Prop
(properties
x 76
y 139
view 904
)
)
(instance titleTwo of Prop
(properties
x 158
y 139
view 904
)
)
(instance titleThree of Prop
(properties
x 235
y 134
view 904
)
)

Neither program gives a compiling error. It's just bizarre. I don't see anything that could possibly break it either. Unless there's something in another script (like main or game or something) that screws things up. But I haven't made any big changes anywhere else...
« Last Edit: August 25, 2010, 05:29:53 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline gumby

Re: Is my game corrupt?
« Reply #4 on: August 25, 2010, 05:34:26 PM »
Stupid related question:  how to you even run a game in debug?  I could probably utilize such functionality...
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline MusicallyInspired

Re: Is my game corrupt?
« Reply #5 on: August 25, 2010, 05:38:33 PM »
Code: [Select]
sciv.exe -d
When it crashes it brings up the debug mode and shows exactly what object crashes the game. Problem is it doesn't help with my issue as it just seems like a bunch of random characters...leading me to believe that it's being compiled incorrectly somehow.
Brass Lantern Prop Competition

Offline MusicallyInspired

Re: Is my game corrupt?
« Reply #6 on: August 26, 2010, 03:51:34 PM »
I'm getting some really strange debug window characters here. Something is definitely wrong. Maybe I should start over again with a brand new template game.

EDIT: ARGGG. I tried starting from scratch with a new template game and I'm STILL getting these bizarre crashes. It must be a scripting issue but I just don't see anything that could possibly be crashing the game and I don't know how else to script these things.
« Last Edit: August 26, 2010, 05:28:15 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline Cloudee1

Re: Is my game corrupt?
« Reply #7 on: August 26, 2010, 07:13:44 PM »
Well that sucks, I still don't see anything that pops out at me. I wouldn't want to leave you hanging, so first off try getting rid of the music fades in the second script. afterall we already faded the music in the first script and haven't started any more yet. Also, since the second room isn't really doing much more than the first one, how about we just add some more numbers to the first scripts  changestate as well as add another drawpic to get the right screen up.
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline Cloudee1

Re: Is my game corrupt?
« Reply #8 on: August 26, 2010, 07:23:32 PM »
Ah shit, I'll bet I know whats doing it. I'll bet its the music fading in the middle of a room change. I'll bet if you put a couple of seconds between them you'll be fine. 90% of my oops errors were because something was going on while I was changing rooms. Trying telling the first script to go to the third room before  you make any  other changes and see if it crashes there. If it does then my money is definately on the fade
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline MusicallyInspired

Re: Is my game corrupt?
« Reply #9 on: August 26, 2010, 07:43:07 PM »
Ah that could be it! Thanks, I'll try it!
Brass Lantern Prop Competition

Offline MusicallyInspired

Re: Is my game corrupt?
« Reply #10 on: August 26, 2010, 07:55:36 PM »
Well, not exactly. But I think we're closer now. I tried sending it straight to the third room and it doesn't crash. But I remembered that it doesn't crash in the second room either when there are no instances at the bottom of the script.

So I removed ALL music references (cuing, fading, stopping, everything. no music) from both scripts to see what happens. And the result is when it switches to room 2 the output is a stack overflow at titleTwo. Any idea what that could mean?
« Last Edit: August 26, 2010, 08:02:13 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline Cloudee1

Re: Is my game corrupt?
« Reply #11 on: August 26, 2010, 09:02:54 PM »
Yeah I tried to crash my game with a simultaneous music fade and newroom and there were no ill effects. hmmm. Now the only thing I see that I don't do is the cycleSpeed in the views instance, I always set that in the same line  as init().
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.141 seconds with 24 queries.