ItrGameEntity and map2dif
by Stefan Beffy Moises · in Torque Game Engine · 02/01/2004 (2:23 pm) · 4 replies
The current HEAD has a new Interior object called "ItrGameEntity"...
does anybody know what this is and how / for what it's used?
I'm trying to add some additional objects there but this thing is giving me a headache in interiorRes.cc...
and why is there a "0" written after this?
does anybody know what this is and how / for what it's used?
I'm trying to add some additional objects there but this thing is giving me a headache in interiorRes.cc...
// For expansion purposes
stream.read(&dummyInt);
if(dummyInt == 2)
{
U32 numGameEnts;
stream.read(&numGameEnts);
mGameEntities.setSize(numGameEnts);
for (i = 0; i < numGameEnts; i++)
mGameEntities[i] = new ItrGameEntity;
for (i = 0; i < numGameEnts; i++) {
if (mGameEntities[i]->read(stream) == false) {
AssertISV(false, avar("Unable to read SpecNode %d in interior resource", i));
return false;
}
}
stream.read(&dummyInt);
}why is it doing the second "stream.read(&dummyInt);"?and why is there a "0" written after this?
// For expansion purposes
if (mGameEntities.size())
{
stream.write(U32(2));
stream.write(mGameEntities.size());
for(i = 0; i < mGameEntities.size(); i++)
{
if (mGameEntities[i]->write(stream) == false) {
AssertISV(false, avar("Unable to write GameEnt %d in interior resource", i));
return false;
}
}
}
stream.write(U32(0));any ideas / pointers?About the author
#2
but I couldnt find any difference between greathall.dif and e.g. cottage.dif in HEAD...
so the question is: why does this cause greathall.dif to NOT load IF there arent any AINodes in it?
02/01/2004 (10:43 pm)
Hm, here is what I did... for SOME difs, this only works IF there are AINodes in the dif (e.g. greathall.dif), other difs load in any case (e.g. cottage.dif)...but I couldnt find any difference between greathall.dif and e.g. cottage.dif in HEAD...
so the question is: why does this cause greathall.dif to NOT load IF there arent any AINodes in it?
// For expansion purposes
stream.read(&dummyInt);
if(dummyInt == 2)
{
U32 numGameEnts;
stream.read(&numGameEnts);
mGameEntities.setSize(numGameEnts);
for (i = 0; i < numGameEnts; i++)
mGameEntities[i] = new ItrGameEntity;
for (i = 0; i < numGameEnts; i++) {
if (mGameEntities[i]->read(stream) == false) {
AssertISV(false, avar("Unable to read SpecNode %d in interior resource", i));
return false;
}
}
stream.read(&dummyInt);
}
stream.read(&dummyInt);
if(dummyInt == 3)
{
U32 numAINodes;
stream.read(&numAINodes);
mAIPathNodes.setSize(numAINodes);
for (i = 0; i < numAINodes; i++)
mAIPathNodes[i] = new AIPathNode;
for (i = 0; i < numAINodes; i++) {
if (mAIPathNodes[i]->read(stream) == false) {
AssertISV(false, avar("Unable to read AIPathNode %d in interior resource", i));
return false;
}
}
stream.read(&dummyInt);
}
ConnectAINodes();
//end added
return (stream.getStatus() == Stream::Ok);// For expansion purposes
if (mGameEntities.size())
{
stream.write(U32(2));
stream.write(mGameEntities.size());
for(i = 0; i < mGameEntities.size(); i++)
{
if (mGameEntities[i]->write(stream) == false) {
AssertISV(false, avar("Unable to write GameEnt %d in interior resource", i));
return false;
}
}
}
//stream.write(U32(0));
// beffy:added
if (mAIPathNodes.size()!=0)
{
dPrintf("\nWriting (%d) AI Path Nodes\n",mAIPathNodes.size());
stream.write(U32(3)); // my little id number...
stream.write(mAIPathNodes.size());
for (i = 0; i < mAIPathNodes.size(); i++)
{
if (mAIPathNodes[i]->write(stream) == false)
{
AssertISV(false, avar("Unable to write AIPathNode %d in interior resource", i));
return false;
}
}
};
// end added
stream.write(U32(0));
return (stream.getStatus() == Stream::Ok);And where is the link between Map2Dif and this "dummyInt"? I cant see map2dif writing 1, 2 or 3 into the dif file?
#3
why not just do it like all the other entities do ... e.g. the detail levels??
02/02/2004 (6:37 am)
Hm, I'm wondering why this dummyInt stuff is used at all...why not just do it like all the other entities do ... e.g. the detail levels??
U32 numDetailLevels;
stream.read(&numDetailLevels);
mDetailLevels.setSize(numDetailLevels);
for (i = 0; i < mDetailLevels.size(); i++)
mDetailLevels[i] = NULL;
for (i = 0; i < mDetailLevels.size(); i++) {
mDetailLevels[i] = new Interior;
...Where does this dummystuff come from? :P
#4
IMO someone should go ahead a rewrite a whole chunk of it to make it more readable :)
e.g. The segment beffy just posted could easily be simplified down to :
And in the case of certain segments of code like :
Its clear they are not needed at all; Its a waste of 16 bytes!
And of course, theres map2dif itself, but i'm not going into that :)
p.s. beffy, make sure you are reading / writing the same amount of things from your interior. I'm not sure, but it looks like you are reading more dummy integers than you are writing in that last code segment. Or it could be the other way :)
I pretty much prefer the 3Space alloc code (with the nice checkpoint system that can help pinpoint where your read/write operations are going wrong)
02/02/2004 (7:21 am)
After looking at the interior loading code, i'm suprised at how messy the loading code looks.IMO someone should go ahead a rewrite a whole chunk of it to make it more readable :)
e.g. The segment beffy just posted could easily be simplified down to :
U32 numDetailLevels;
stream.read(&numDetailLevels);
mDetailLevels.setSize(numDetailLevels);
for (i = 0; i < mDetailLevels.size(); i++) {
mDetailLevels[i] = new Interior;
...And in the case of certain segments of code like :
// For future expandability U32 dummy; stream.read(&dummy); if (dummy != 0) return false; stream.read(&dummy); if (dummy != 0) return false; stream.read(&dummy); if (dummy != 0) return false; stream.read(&dummy); if (dummy != 0) return false;
Its clear they are not needed at all; Its a waste of 16 bytes!
And of course, theres map2dif itself, but i'm not going into that :)
p.s. beffy, make sure you are reading / writing the same amount of things from your interior. I'm not sure, but it looks like you are reading more dummy integers than you are writing in that last code segment. Or it could be the other way :)
I pretty much prefer the 3Space alloc code (with the nice checkpoint system that can help pinpoint where your read/write operations are going wrong)
Torque Owner Badguy
heh
... :)
anyhow.. looks like the 0 is there to null terminate stuff.
and the other end is to maintain serilization
This ugly little sucker, looks like a foundation class for creating new entity types. and getting some hooks in to have them read.