Jump to content

game crashes with no stated reason upon map switch


imjustacowlol
 Share

Recommended Posts

Hey guys,

 

So quite a long time ago I had issues with switching maps at the part of clearing a world. Several weeks ago a update game because there was something missing in the engine itself, but when I switch with the same scripts I used before the 'fix' the game crashes without giving a reason. The scripts involved within map switching are App.lua and LoadLevel.lua. I don't see anything weird at the output tab in the debug editor, the general output tab does randomly say Error: Unknown client disconnected.

 

I have no clue why the map switch works for others and not for me. I tried making a new project and the game would still crash. Here is a link to one of my main projects (it is 1.5gb yes, but I'm using most of the files in it so yeah..)

https://www.dropbox.com/s/68ldy91jccykpdb/TestProject2.zip

if you know the solution please let know smile.png

Link to comment
Share on other sites

What LoadLevel.lua file? I think klepto or something had one of these in the asset store that tried to do this inside an entity which will cause a crash. I can't download that big of a project man. You have to do a test app that is smaller.

Link to comment
Share on other sites

You have the same issue as KTy. In your ShouldSwitchLevel() change self.world:Release() to self.world:Clear() and remove the creation of the new world. It should work then. If you get errors still it's probably because of the FPS script you might have in your scene.

Link to comment
Share on other sites

I'll take a look at it

 

Still crashes if my ShouldSwitchLeve() is this:

function App:ShouldSwitchLevel()

if self.mapFile ~= "" then

self.world:Clear()

 

Map:Load(self.mapFile)

 

self.mapFile = ""

end

end

 

Next to that, the fpsplayer script is the default one by leadwerks.

Link to comment
Share on other sites

Next to that, the fpsplayer script is the default one by leadwerks.

 

That doesn't matter. Changes were made to the engine and the FPSplayer script stayed the same causing some issues.

 

Look in your output after the crash. Does it say it's deleting some things at the end of it? If so that means it started to clear and when it hit the fpsplayer it bombed. You can test this by taking out the player in your scene and put in a basic script where when you press a key it calls it switches the map. After I did this it doesn't bomb anymore, meaning the player script is causing the issue.

Link to comment
Share on other sites

[/size][/font][/color]

 

That doesn't matter. Changes were made to the engine and the FPSplayer script stayed the same causing some issues.

 

Look in your output after the crash. Does it say it's deleting some things at the end of it? If so that means it started to clear and when it hit the fpsplayer it bombed. You can test this by taking out the player in your scene and put in a basic script where when you press a key it calls it switches the map. After I did this it doesn't bomb anymore, meaning the player script is causing the issue.

It does say it is deleting things yeah. But when I deleted the release parts in the player script, it still crashes for some reason. Perhaps I missed something, i'll take a look at it.

 

The part where it goes wrong is actually after loading the next map 0_o

 

--edit--

 

okay found another release part in player script, deleted that and still crashes with self.world:Release() but I fixed it by doing this:

function App:ShouldSwitchLevel()

if self.mapFile ~= "" then

self.world:Release()

 

self.world=World:Create()

 

Map:Load(self.mapFile)

 

self.mapFile = ""

end

end

 

First self.world=World:Create() was not in the script, because that got advised earlier on. But by putting it back it did fix the crash.

 

Here comes the new issue:

The music from the previous level (There was music playing in that level) does not get released/deleted. Do I need to put an additional command in the ShouldSwitchLevel part to do so?

Link to comment
Share on other sites

Change self.world:Release() to self.world:Clear() and drop the creation of the new world. Then be sure to comment out the releasing in the player script. That must be a bug.

 

Didn't work to get rid of the music. The music is attatched to an object with the Noise.lua script, and the object reaches throughout the whole map so everywhere you go you hear that song. When I either use Clear() or Release() in App.lua it doesnt delete the music. it's like something in the engine is registering that you are still in the previous map ánd in the new map that you loaded with the map-switch.

Link to comment
Share on other sites

"Maps" don't really exists in the Leadwerks API. All "maps" are is a collection of entities. A world holds a bunch of entities. So when you load a "map" it's just loading a bunch of entities in the current world. When you Clear() a world it's supposed to unload all entities in the world. If a sound continues to play then it's telling us that it's not getting unloaded when the world is clear.

 

Go inside noise.lua and see if there is a function Script:Delete(). If there isn't then you probably have to add one and inside there stop the sound from playing. I don't have my main PC with LE setup so I can't check how noise.lua is setup, but this sounds like what is going on.

Link to comment
Share on other sites

Noise.lua is in the attatchment of this message. When I put Script:Delete() even anywhere in the Noise.lua script, it gives me an error:

Script Error

 

attempt to index global 'Script' (a nil value)

 

Line 24

 

Noise.lua with the Script:Delete() is in the attatchment.

When I replace Script:Delete() with Sound:Delete() or sound:Delete() it gives an error for the Delete part (doesn't matter if I write Delete or delete, gives the error anyway):

Script Error

 

attempt to index global 'Delete' (a nil value)

 

Line 24

Noise.lua

Link to comment
Share on other sites

You want the function Aggror has above. It might blow up on the Release() function because I think there is a bug so if it does just try calling :Stop() on the source instead to see if that at least stops the sound from playing, but try :Release() first.

Link to comment
Share on other sites

. When you Clear() a world it's supposed to unload all entities in the world. If a sound continues to playarrow-10x10.png then it's telling us that it's not getting unloaded when the world is clear.

 

Should not it be automatic ?

I mean clearing the world would stop and destroy all entities or process related to it could it be tables of entities, sound or whatever. As a world is just a list of instancied objects.

Would perhaps be better in the future to have that done automatically for programmers and other people don't have to program more or care about ? Does it works like that on on other 3D egines ?

Stop toying and make games

Link to comment
Share on other sites

Having the choise to continue playing the sound is always better.

 

If i want to have music continue playing while loading the next level would not be possible if the engine automatically removes all sounds when loading.

Link to comment
Share on other sites

I think that might lead to a memory leak though, because the entity the noise script is attached too would get removed automatically, which would mean our variable to the sound/source object isn't available to us anymore to do anything with.

 

@YouGroove, I believe the entities that would get auto deleted would be the ones created in the scene. Because of the whole reference counting thing if you created it in code then you should delete it in code, because you might have passed it around, adding reference counts to it.

Link to comment
Share on other sites

also just a shot out in the dark, it appears (i'm don't know for sure) that anything that has to do with lua objects require the Script:delete() function as the world:clear calls this function (maybe recursively) until all entities are removed. if an entity doesn't have the delete function then it isn't removed from the world. Just an observation and thought I have.

bool Life()
{
 while(death=false)
 {
   if(death==true)
   return death;
 }
}

 

I have found the secret to infinite life

 

Did I help you out? Like my post!

Link to comment
Share on other sites

I've been observing all solutions, and I'm sorry for my lack of reactions, but none of the solutions unfortinately have helped yet. Aggror's solution causes the game to crash upon map switch with self.world:Clear() again. and xtreampb, in what script should I put that piece of code?

Link to comment
Share on other sites

anything that has a script should have the delete function if my gut feelings are right. so in other words...all of them.

bool Life()
{
 while(death=false)
 {
   if(death==true)
   return death;
 }
}

 

I have found the secret to infinite life

 

Did I help you out? Like my post!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...