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.

Dark GDK / LoopSDK() dbLoadObject hopefully simple newbie error

Author
Message
John Mark
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location:
Posted: 23rd Nov 2005 19:03
Hi,

I am relatively new to Dark Game SDK, and thus far im pretty impressed with what I have been able to do in a very short development time. I have come up against a problem, whic I can not see a solution to in any documentation.

I was making a simple editor for my game, and wanted to be able to load a "location" file (.x) by selecting from a menu. To cut a long story very short, is there a problem with calling dbLoadObject from within the game loop (LoopSDK).

Outside the game loop my code works fine, but when called from within no object is displayed, anda call to dbObjectExist returns 0.

A subset of my code with hardcoded values is below:


So, am I being daft, is this impossible in Dark Game (if so, any suggestions on how best to load an object at runtime greatfully received).

Many Thanks, Mark
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 23rd Nov 2005 23:33 Edited at: 23rd Nov 2005 23:37
I suspect the SetDir function is failing, thus not being able to load the model.

Try this :



Put the X file in the root of the C drive

If that works, use dbSetDir("c:\\");
and
dbLoadObject("test.x",1);

Attachments

Login to view attachments
John Mark
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location:
Posted: 24th Nov 2005 12:10
Hey SSS that was great, simple debugging I should have tried I guess, my bad.

It is interesting, the files I have are buried a little way into the directory structure, and it would seem that dependent on which directory I put the files in sometimes it works and sometimes it doesnt. However if I use the full path in dbLoadObject I have a much higher success rate. Any reason why setDir may fail?

Once everything is running I will return to the issue and see just what is causing it, but seeing as I have a workaround for now I can get on with the actual coding I wanted to do.

Many Thanks, Mark.
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 26th Nov 2005 12:31
be sure to set the directory back to your root dir when you are done loading a certain type of media.

It wont do it itself, so if for example you have two functions; LoadSounds() and LoadImages() - and the sound one started with dbSetDir(".\\Sound\\"); and the Image one started with dbSetDir(".\\Gfx\\"); and you called the sound one first then by the time it gets to the image one it will actually be trying to set the path to ".\Sound\Gfx\" - easy thing to run into, so double check that in any of your code if you are loading from multiple dirs.

My prefrence is to extern a char global called gRootDir; and on program initialisation set it to the root dir (when program first runs that will dbGetDir()) and then in all media loading routines I start by setting the right dir on the first line and then on the last line of the function I set the dir back to gRootDir.

Login to post a reply

Server time is: 2024-11-19 02:41:49
Your offset time is: 2024-11-19 02:41:49