Sim::findObject("..") works on Windows HEAD but not Linux HEAD
by Jay Bradley · in Torque Game Engine · 03/04/2004 (10:20 am) · 5 replies
I'm using a HEAD build on both Linux and Windows. The code is identical for both. Windows runs these fine but Linux seg faults at the point indicated. I presume the problem is the same for both pieces of code. I beleive that for some reason Sim::findObject works on Windows but not on Linux.
.
.
.
Con::printf("Agent: %s", name);
GameBaseData* datablock = dynamic_cast (Sim::findObject("PlayerBody"));
MatrixF* initialOrientationAndPosition;
F32 zPos;
TerrainBlock *terrain = dynamic_cast(Sim::findObject("Terrain"));
Point3F terrPt(xPos, yPos, 0);
***********Linux seg faults on the next line. It is the first time terrain is used from above. Presumably it has not been found.
terrain->getWorldTransform().mulP(terrPt);
terrain->getHeight(Point2F(terrPt.x,terrPt.y), &zPos);
initialOrientationAndPosition = new MatrixF(Point3F(rand(), rand(), rand()), Point3F(xPos, yPos, zPos));
.
.
.
Also,
.
.
Item *pItem = new Item;
ItemData *pHealthKit = dynamic_cast(Sim::findObject("HealthKit"));
pItem->onNewDataBlock( pHealthKit );
pItem->setScale(Point3F(1, 1, 50));
pItem->setPosition(Point3F(x, y, z));
if (!pItem->registerObject())
{
Con::printf("Cannot register item");
delete pItem;
pItem = 0;
}
.
.
.
This piece of code prints out the "Cannot register item" message. Again this is presumably because "HealthKit" has not been found.
So this code works on Windows but not Linux. Can anybody see why?
Jay
.
.
.
Con::printf("Agent: %s", name);
GameBaseData* datablock = dynamic_cast
MatrixF* initialOrientationAndPosition;
F32 zPos;
TerrainBlock *terrain = dynamic_cast
Point3F terrPt(xPos, yPos, 0);
***********Linux seg faults on the next line. It is the first time terrain is used from above. Presumably it has not been found.
terrain->getWorldTransform().mulP(terrPt);
terrain->getHeight(Point2F(terrPt.x,terrPt.y), &zPos);
initialOrientationAndPosition = new MatrixF(Point3F(rand(), rand(), rand()), Point3F(xPos, yPos, zPos));
.
.
.
Also,
.
.
Item *pItem = new Item;
ItemData *pHealthKit = dynamic_cast
pItem->onNewDataBlock( pHealthKit );
pItem->setScale(Point3F(1, 1, 50));
pItem->setPosition(Point3F(x, y, z));
if (!pItem->registerObject())
{
Con::printf("Cannot register item");
delete pItem;
pItem = 0;
}
.
.
.
This piece of code prints out the "Cannot register item" message. Again this is presumably because "HealthKit" has not been found.
So this code works on Windows but not Linux. Can anybody see why?
Jay
About the author
#2
The dedicated server is not starting properly on linux whereas it is on Windows. Here is what I get on linux:
Sleep latency: 19ms
%
--------- Initializing MOD: FPS Starter Kit ---------
Loading compiled script starter.fps/client/init.cs.
Loading compiled script starter.fps/server/init.cs.
Loading compiled script starter.fps/data/init.cs.
Loading compiled script starter.fps/data/terrains/grassland/propertyMap.cs.
Missing file: starter.fps/data/terrains/scorched/propertyMap.cs!
%
--------- Initializing MOD: FPS Starter Kit: Server ---------
starter.fps/server/init.cs (54): Unable to find function initBaseServer
Loading compiled script starter.fps/server/scripts/commands.cs.
Loading compiled script starter.fps/server/scripts/centerPrint.cs.
Loading compiled script starter.fps/server/scripts/game.cs.
%
--------- Starting Dedicated Server ---------
starter.fps/server/init.cs (75): Unable to find function createServer
Engine initialized...
%
So it says that it can't find initBaseServer and createServer. I've had a look at these two functions and they do some important stuff like laoding all the other scripts. This may be what's causing my problem above. The files exist on my linux installation and my windows installation and they are identical and in the same directories. The files concerned are:
example/common/main.cs for initBaseServer
example/common/server/server.cs for createServer
both the functions are called from example/starter.fps/server/init.cs
So how come the two functions aren't found under linux but are under windows? Any pointers welcome.
04/07/2004 (8:55 am)
Okay some more information I've found. Hopefully someone is still following this and can see my error.The dedicated server is not starting properly on linux whereas it is on Windows. Here is what I get on linux:
Sleep latency: 19ms
%
--------- Initializing MOD: FPS Starter Kit ---------
Loading compiled script starter.fps/client/init.cs.
Loading compiled script starter.fps/server/init.cs.
Loading compiled script starter.fps/data/init.cs.
Loading compiled script starter.fps/data/terrains/grassland/propertyMap.cs.
Missing file: starter.fps/data/terrains/scorched/propertyMap.cs!
%
--------- Initializing MOD: FPS Starter Kit: Server ---------
starter.fps/server/init.cs (54): Unable to find function initBaseServer
Loading compiled script starter.fps/server/scripts/commands.cs.
Loading compiled script starter.fps/server/scripts/centerPrint.cs.
Loading compiled script starter.fps/server/scripts/game.cs.
%
--------- Starting Dedicated Server ---------
starter.fps/server/init.cs (75): Unable to find function createServer
Engine initialized...
%
So it says that it can't find initBaseServer and createServer. I've had a look at these two functions and they do some important stuff like laoding all the other scripts. This may be what's causing my problem above. The files exist on my linux installation and my windows installation and they are identical and in the same directories. The files concerned are:
example/common/main.cs for initBaseServer
example/common/server/server.cs for createServer
both the functions are called from example/starter.fps/server/init.cs
So how come the two functions aren't found under linux but are under windows? Any pointers welcome.
#3
Have you tried doing a fresh checkout on linux?
04/07/2004 (11:23 am)
Yeah, those missing functions pretty much explain why stuff can't be found.Have you tried doing a fresh checkout on linux?
#4
I can't run a client from the machine I'm on now, so I don't know how the rest of it behaves.
You might try doing rm -r ~/.garagegames/torqueDemo. You may have older scripts or realmwars bits there conflicting with the fps demo.
04/07/2004 (2:20 pm)
My build on linux (latest source) doesn't give the initBaseServer / createServer issues. The only missing file is starter.fps/data/terrains/scorched/propertyMap.csI can't run a client from the machine I'm on now, so I don't know how the rest of it behaves.
You might try doing rm -r ~/.garagegames/torqueDemo. You may have older scripts or realmwars bits there conflicting with the fps demo.
#5
dollars to donuts it is a simple filename case problem.
check the case of the filename in script and in disk.
04/13/2004 (12:35 am)
Was this resolved?dollars to donuts it is a simple filename case problem.
check the case of the filename in script and in disk.
Torque Owner Jay Bradley
I can see that Sim::findObject will find "PlayerBody" but will not find "Terrain" or "HealthKit". Is it possible that I've done something to upset the Terrain and HealthKit definitions? Possibly when moving the files across from Windows? I suspected this but can't find how I could have done it.
I followed the function chain right down to StringTable::lookupn where it fails. There doesn't seem to be any trouble other than the objects aren't found.
Remember this only happens on Linux and I'm pretty sure now that the code is indeed right and that I've screwed up a definition file somewhere in all my work.
Can anybody suggest how this would show up elsewhere or anyway I could go about finding the exact cause of this? I've been going at it full time for a while and I'm now a bit stuck for ideas to continue the search.