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 / Clone Object problem

Author
Message
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 7th Aug 2009 12:14
I am trying to use CloneObject to speed up the loading of my level, but it doesn't seem to be working.

I load my "to-be-cloned" objects at the beginning of the program and when objects need to be created, I have them cloned from the originals.

The app runs, but no objects show up

This how I try cloning them:


I tried turning on the "iCloneSharedData" flag by changing it to:


But doing that, I get this during compile:
Quote: "1>Main.obj : error LNK2019: unresolved external symbol "void __cdecl dbCloneObject(int,int,int)" (?dbCloneObject@@YAXHHH@Z) referenced in function "void __cdecl makefloor(int,int,int,int)" (?makefloor@@YAXHHHH@Z)"



Any ideas what's going on here?
If I don't clone the object and just load it, it works fine. Also, the clone object is used in a header file, while the parent object is loaded in the Main.cpp file, if that makes a difference.


The one and only,


Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 7th Aug 2009 15:59
Check the scope of the variables you are using to pass the object numbers to clone object, they may not be getting passed as what you think they are if they are declared somewhere else. As an experiment you could temporarily refactor the code to clone objects so that it is right near the code to load(in the same scope), that way you can tell if its your variables or not...

As for the link error, that looks like the command doesnt exist in GDK. It may be in the header, but for whatever reason the command hasnt been included in the static library, so will give you that error. (you can get at those flags you mentioned with the pointer returned from dbGetObject though, at least until tgc get those commands in, it returns a pointer of type sObject*, I dont think that is the problem though, it shouldnt be needed )

If it ain't broke.... DONT FIX IT !!!
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 8th Aug 2009 08:25
Well, the strange thing is, the loaded objects don't show up either when I use the cloneobject command

I have debugged this area of code and the variables are holding the correct numbers (that is OBJ_FLOOR is set tot he value I gave it in the Main.cpp and it is a global constant)... however, it would seem that "dbObjectExist" was returning false for the IDs of the parent objects I loaded. That makes no sense at all, since it normally acted fine when I loaded them in place of the cloneobject command.

"objID" is set by this function:


This function, returned "1" every single time, even though I loaded a parent object (direct load, not cloned) into ID 1... so object 1 should already exist... it seems that the header file code is not seeing objects loaded in the Main.cpp

Would that make any sense?


The one and only,


Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 8th Aug 2009 09:13
Yes, the header file wont have access to variables that are declared in the program scope in main.cpp .... it works the other way around, main.cpp has access to the header file...

Have a look around on the topic of "scope" its exactly what is causing your problem

If it ain't broke.... DONT FIX IT !!!
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 8th Aug 2009 11:15
Then how come the objects I loaded in Main.cpp weren't showing up??


The one and only,


Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 8th Aug 2009 12:26
Ok, simple question first, You have the right path, it hasnt been mucked up somewhere along the line ?(always gotta check the obvious things first)

Next, the easiest thing to try is to maybe do away with the variable system temporarily and use straight numbers to make sure that its actually loading and cloneing properly..

I mean, instead of calling :

dbCloneObject(objID, OBJ_FLOOR);

call :

dbCloneObject(1, 2);

That way you can then add one variable at a time, to see which is the problem.

About your freeobject function, I think the problem might be the lines :



Here, ill retype out the function as I would have it(just simpler, no need for the bounds checking) :



Of course, without seeing your code and knowing where you have defined things and where you are calling them from, I may be way off base, but I hope this helps a little

If it ain't broke.... DONT FIX IT !!!
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 10th Aug 2009 00:58
Thanks for the suggestions, Mista. I replaced the constants with straight numbers and it didn't effect anything... I then replaced the objID with a straight number as well, and that didn't do anything either.

I also replaced my FindFreeObj function with the one you suggested, and thus far it's been behaving in the same manner as my old one (except now I don't have to return -1)

I suppose I can just continue my game with loaded objects for now until I can come up with a workaround for this. Perhaps if I made a function in my header file to load the parent objects, then the parent objects would then be "usable" by the other functions in the header file..


The one and only,


dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 10th Aug 2009 07:12
Show us a short bit of code illustrating only this issue, you must be doing something wrong.

Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 10th Aug 2009 08:48
Quote: "you must be doing something wrong"


Yet again... you are correct.

My object cleanup code was being executed just after I loaded the parent objects (it's at the beginning of a loading sequence.. if the sequence happened to fail, it would loop and delete any previously loaded objects to start fresh and try again) but before the cloning procedures had started... so, yeah, it's fixed.


The one and only,


Login to post a reply

Server time is: 2024-11-20 17:26:52
Your offset time is: 2024-11-20 17:26:52