Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Loading Media Crash

Author
Message
Mang Master
18
Years of Service
User Offline
Joined: 22nd Mar 2008
Location:
Posted: 20th Aug 2010 09:20
Hi, I recently started to implement script reading in my game and I have come across a very annoying problem. Whenever I load an object (or any other media) with a string variable, when the program gets to that part, it crashes. It never did this before until I started to use variables as names.

here is the beginning part of my code which has the object loading in it:


I know the code is a bit messy (and its not done so some of the things will not work...).

If you need anymore code I would happily provide it!
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 21st Aug 2010 17:36
I don't use types so am not 100% sure. But at the start you have declared a simple variable as a string rather than just calling it filename$. I would change that for starters. I would have had all string data in one array and all numerical data in an identical one myself and just use both in your checks.
I have tried types a few times but always find some bug or problem that annoys me. So I stick with old fashioned arrays.

http://s6.bitefight.org/c.php?uid=103081
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Aug 2010 12:22
Quote: "But at the start you have declared a simple variable as a string rather than just calling it filename$. I would change that for starters."


There's nothing wrong (as far as the compiler is concerned) with code such as



The code should work perfectly - even though a programmer might find it hard to read. The problem must be somewhere else in your code. Have you checked the value of filename returned by your opendialog() function?
Mang Master
18
Years of Service
User Offline
Joined: 22nd Mar 2008
Location:
Posted: 22nd Aug 2010 21:24
Thanks for the replies but I forgot to mention, the first part loads fine (the opendialog part), but this part is the one that crashes the game:



I know for sure it is this part because I replaced the variable with just "media/ak47.x" and it worked fine.

I will try getting rid of all the types, I always thought they were too good to be true!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Aug 2010 01:35
As I said before, have you checked the value of the relevant string variable (a different variable this time of course)?
Mang Master
18
Years of Service
User Offline
Joined: 22nd Mar 2008
Location:
Posted: 23rd Aug 2010 05:41 Edited at: 24th Aug 2010 07:46
Hmmmmm, I think you got it. The string is blank when I try to print it to the screen, I think I'll try what DVader said and replace all my types with arrays.

Edit: I have singled out the problem! Changing all the types to arrays didn't work, however it is a lot neater now. There is a problem with the open file to read part.

Here is what I use to load:



As you can see I put some debug stuff in there. The first part prints "File Found!" to the screen, but the print "String is:" + output$ part just prints "String is:" to the screen.

Does anyone know of any bugs with the open to read command?

Is there something wrong with my code?
Mang Master
18
Years of Service
User Offline
Joined: 22nd Mar 2008
Location:
Posted: 28th Aug 2010 21:27
Bump. I still haven't figured it out. I am thinking of completely redoing my code now... Which will take a while...
James H
19
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 28th Aug 2010 22:55 Edited at: 28th Aug 2010 23:01
Looking at your last snippet only you have missed "next m" and "endif". Also I find this neater;

It is easier to see where conditions and nests start and end like this
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 29th Aug 2010 17:57
This line puzzles me:



Is file m open? Or should that line be



?
Mang Master
18
Years of Service
User Offline
Joined: 22nd Mar 2008
Location:
Posted: 30th Aug 2010 22:23
Thank you! That little thing right there made it not read the file...

But that did not fix the crashing problem. Now when I load the file with the variable as the name, It crashes still.
Mang Master
18
Years of Service
User Offline
Joined: 22nd Mar 2008
Location:
Posted: 4th Sep 2010 05:51
Hey guys, I know school is starting up again and you guys are pretty busy, but I still need help. I'll include full code if you want (before I was just giving snippets).
Mang Master
18
Years of Service
User Offline
Joined: 22nd Mar 2008
Location:
Posted: 9th Sep 2010 02:49
Aw man, I guess I have to double bump.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Sep 2010 16:33
Quote: "I'll include full code if you want (before I was just giving snippets)."


That would help - essential media would help too.
Mang Master
18
Years of Service
User Offline
Joined: 22nd Mar 2008
Location:
Posted: 9th Sep 2010 17:32 Edited at: 9th Sep 2010 17:52
Ok, here is all I have. It should work (as in crash).

Edit: Oops, I forgot I had my blue gui password somewhere else in the code...

Edit: Fixed.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Sep 2010 17:44
Thanks. I'll take a look and see if I have any ideas.
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 9th Sep 2010 17:47
Sometimes it helps to isolate the problem. For instance, copy all your code to a new project, and then strip out everything but the code that has the problem. Then you have a program with 4 or 5 lines of code, that crashes, and it's much easier to spot the problem.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Sep 2010 17:57 Edited at: 9th Sep 2010 18:02
Tried it on my ageing laptop. No crash.

What do I have to do to get it to crash? Also, how do I get up the ramp?

Here's a screenshot:



[Edit I see from your edits that I've probably downloaded the version before you edited it. But it works. I've only tried running the exe file so far.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Sep 2010 18:27
I'm puzzled. I've just recompiled your project after removing the bluegui stuff and it compiles and runs until I press F5 for a custom map. Soon after that it crashes. I'm puzzled because your code seems to have Sparky's collision commands so why did it compile?

Er? Just had a look and it seems I've got Sparky's collision after all - an old copy from 2006. Perhaps I'd better get the latest version then try your code again.

In the meantime could you post some instructions so I know what I'm supposed to see and do? You could also follow Rich Dersheimer's advice.
Mang Master
18
Years of Service
User Offline
Joined: 22nd Mar 2008
Location:
Posted: 10th Sep 2010 01:34 Edited at: 10th Sep 2010 03:19
Well I posted this right before I had to go to school. You're right, It doesn't crash anymore.

But now It's acting funky.

The viewmodel is still in the ground (you can see this by going into wireframe mode. To do this, while in-game press ~, then type "wireframe" without the quotes)

And I can't tell since it is so small, but I think it does not load the right model. (I tested this by changing the script file to load a different file)

Quote: "In the meantime could you post some instructions so I know what I'm supposed to see and do? You could also follow Rich Dersheimer's advice."


Well there are no "Instructions" really. The only advice I can give you is that the script file is in the "base" folder. Just open it with notepad.

And yeah, I will try to do what that guy said. I did that to some degree to figure out the problem in the first place, but you're right, it might be something silly... Like loading blue gui or something.

Edit: Sorry about that crashing thing. My bad.
Replace manggame.dba with this:


Edit 2: Oh yeah the ramp! Well, I don't have a very good gravity system right now...

Ignore that, I'll fix it eventually...

Edit 3: Ok I got it to crash again. I was using a funky method that I made AFTER it started crashing.



I took that out and it crashes like normal again. I attached the new version. It also has a "normal" command so after you use wireframe, it can go back to normal.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Sep 2010 12:06 Edited at: 10th Sep 2010 14:01
Quote: "Well there are no "Instructions" really. The only advice I can give you is that the script file is in the "base" folder."


Quote: "It also has a "normal" command so after you use wireframe, it can go back to normal."


I really need instructions of some sort - it will take ages for me to wade through the code to see what inputs are expected from me.

Could you tell us what the various commands are and what we should expect to see at various stages? When I ran your demo I was often presented with a blank black screen (or an almost completely blue screen with a small brown patch) and had no idea whether or not the program was doing something or expecting input from me. I then pressed keys at random till something happened.

Anyway, I'll have a look at the new version.

Edit Well, it certainly crashes every time for me now, which in a strange way is progress I suppose.
Mang Master
18
Years of Service
User Offline
Joined: 22nd Mar 2008
Location:
Posted: 10th Sep 2010 17:29 Edited at: 10th Sep 2010 17:35
Ok, I'll try my best to give you some instructions. Basically, this game is going to be a general fps game until I get all the bugs sorted out.
So controls are:
w-forward
s-back
a-left
d-right
f-flashlight (still kinda buggy)
click-shoot
~-type in console (only commands I made are wireframe (that makes it look wireframe), and normal (it changes it back to normal again)

The console thing is a bit hard to explain but when you press the ~ button, you can type (I basically just put an input)

This is what happens for me:
-I load/compile the game
-I press any key to skip the custom map loading screen (as that doesn't work now since I got rid of the blue gui stuff)
-CRASH (this crash is at the same time I load the weapon that was in the script file)

It is supposed to load the file name from the file "base/ak47.met", but it messes up some how.

Other notes:
Everything code-wise that relates to loading the scripts is modules\scripts.dba

I was experimenting yesterday, and I think the file gets read properly, but for some reason doesn't set the variable right.

Edit: The actual line in the code where I load the object, is line 116 of manggame.dba
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Sep 2010 19:24
Thanks. That's helpful. I guess the WASD bit is only relevant when the map has been loaded correctly.
Mang Master
18
Years of Service
User Offline
Joined: 22nd Mar 2008
Location:
Posted: 18th Sep 2010 04:19
*Bump* Thanks for helping out Green Gandalf. Does anyone else wanna give a try at fixing this?

I have been working on other things, but I did figure out that if I print to the screen what the variable is right after (in the same function) it is declared, it prints fine. But if I print it after I call the function in the main loop, it is blank

O yeah that reminds me, my posts are too bland. I got to add more emotes

Login to post a reply

Server time is: 2026-07-22 12:41:47
Your offset time is: 2026-07-22 12:41:47