Game Development Community

Strange behavior

by Tim Doty · in Torque Game Builder · 04/09/2005 (12:20 am) · 9 replies

I've recently seen some very strange behavior in one of my T2D projects.

It is still very alpha, but I have two sprites (cars) which are displayed on the (testing) map. Each is controllable from the keyboard with its own separately declared keymap, no overlapping keys. This basic framework has been working for a while, but now? Observed weirdness:

1. Arrow up moves car 1 up (good), but also moves car 2 down (what?)

2. TileMap does not load. The code for this has not changed since... a long time. Backups of certain directories (and my source directory is one of these) are done automatically every day. I've checked the backups and the TileMap matches all the way back for at least six days -- and it was working fine at that time.

$scrollerMap = new fxTileMap2D() { scenegraph = t2dSceneGraph; };
  $scrollerMap.loadTileMap(expandFilename("~/client/maps/AutoArenaTileMap3.map"));

generates:

fxTileLayer2D::setStaticTile() - fxImageMapDatablock2D Datablock is invalid! (tileMapImageMap)
fxTileMap2D::loadTileMap() - Could not Read from Stream 'AutoArena/client/maps/AutoArenaTileMap3.map' for TileMap Load.

I know the tilemap file format is set to change, but I don't have a new version! I recursively deleted all .dso files and tried again with the same results. The code above isn't quite the original, I tried using expandFilename() just to see if it would help.

However, all the tiles for the map load just fine, no problems there.

The only other thing I can think of is that I've compiled T2D for Windows with the OO resource and tried running that. (It doesn't work, crashes with a memory read error.) This is one of the reasons I tried removing all the .dso files.

Any ideas?

#1
04/09/2005 (12:32 am)
I'm new to scripting, but why use the "expandFilename" in the loadTileMap line? It's unnecessary when I've used this command.

But then again, I've always worked from the T2D subdirectory.
#2
04/09/2005 (12:34 am)
If you use a ~ or a . in a path you should use "expandFileName()" or many times you will not have the correct path. In my experiance the ~ and . are only expanded when the script is executed, so using it in a Datablock is usually fine.
#3
04/09/2005 (12:41 am)
I've checked and none of the tilemaps load anymore, not even in the tile editor for the T2D that shipped. I've tried multiple maps saved multiple times in different locations (though ultimately they are all on the same raid, except for backups which are burned to DVD).

If I move car 1 forward, car 2 moves backward. If I move car 1 backward car 2 moves forward. If I turn car 1 to the left then car 2 deflects to the right. If I turn car 1 to the right then car 2 deflects to the left. Moving car 2 has no effect on car 1. The code for this is also something that I haven't touched in some time.

function CreatePlayer() {
  $player = vehicleObject::create("player",t2dSceneGraph, "RacerX");
  
  $player.startposition = "-22.5 0";
  $player.startangle = 0;
  $player.startvelocity = "0 0";

  // Setup the action map
  new ActionMap(playerMap);
  playerMap.bindCmd(keyboard, "up", "$player.Accelerate();", "$player.CancelAccel();");
  playerMap.bindCmd(keyboard, "down", "$player.Decelerate();", "$player.CancelAccel();");
  playerMap.bindCmd(keyboard, "left", "$player.TurnLeft();", "$player.LeftStop();");
  playerMap.bindCmd(keyboard, "right", "$player.TurnRight();", "$player.RightStop();");
  playerMap.bindCmd(keyboard, "space", "$player.Fire();", "");
  playerMap.bindCmd(keyboard, "f1", "$player.Reset();", "");
  playerMap.push();
  
  // Setup weapons
  $player.addWeapon("missilelauncher",LightMissileLauncher,"Front","-0.2 -0.6");
  
  $player.mountCamera(sceneWindow2D);
  $player.Reset();
  }

function CreateEnemy() {
  $enemy = vehicleObject::create("enemy",t2dSceneGraph, "Sedan");
  
  $enemy.startposition = "-37.5 0";
  $enemy.startangle = 0;
  $enemy.startvelocity = "0 0";

  // Setup the action map
  new ActionMap(enemyMap);
  enemyMap.bindCmd(keyboard, "w", "$enemy.Accelerate();", "$enemy.CancelAccel();");
  enemyMap.bindCmd(keyboard, "s", "$enemy.Decelerate();", "$enemy.CancelAccel();");
  enemyMap.bindCmd(keyboard, "a", "$enemy.TurnLeft();", "$enemy.LeftStop();");
  enemyMap.bindCmd(keyboard, "d", "$enemy.TurnRight();", "$enemy.RightStop();");
  enemyMap.bindCmd(keyboard, "lshift", "$enemy.Fire();", "");
  enemyMap.bindCmd(keyboard, "f2", "$enemy.Reset();", "");
  enemyMap.push();
    
  // Setup weapons
  $enemy.addWeapon("missilelauncher",HeavyMissileLauncher,"Front","-0.2 -0.6");
 
  $enemy.Reset();
  }
#4
04/09/2005 (12:46 am)
Originally I didn't have the expandFilename() and it worked (well, until recently). I just tried adding the expandFilename() to see if it helped and it didn't.

What I've been working on has nothing to do with either action maps or tile maps. I started programming up some logic for AI drivers and, due to these problems, commented out the relevant exec()'s. Other than that the only change has been to un-hardcode targeting for $enemy (so that I can fire its missiles at $player).

It's acting very kooky and has me worried. And why $player's action map would have anything to do with $enemy is beyond me. And why no tile map is loadable any more...
#5
04/09/2005 (12:59 am)
Is player2 physically moving the opposite direction? I noticed that you've mounted the camera to player1, so it may seem like player2 is moving in the opposite direction.
#6
04/09/2005 (1:04 am)
Physically moving, yes. Note, the camera mount is "lazy", not rigid. I just fixed the problem, though I don't entirely understand it.

I thought I'd covered everything I'd done and, of course, I'd neglected one thing: I commented out the demoDatablocks because I didn't think I needed them. Stupid me, because I still have some tiles from that in the test map I'm using. So I understand why the tilemap quit loading, but why would none of the tilemaps load, even going back to the original T2D distribution? And why would that mess up the action maps?

At least it works again so maybe I can hit the sack (3am here. woohoo!)

oh yeah, and thanks for the input.
#7
04/09/2005 (5:55 am)
I'm not sure what's going on here but I just thought I'd let you know that all of the T2D load functions already expand the file/path themselves so you don't have to do it. This, of course, doesn't necessarily apply to any other non-T2D platform calls.

You can see this in the C++ like this:-

// Expand relative paths.
	char buffer[1024];
	if ( tileMapDataBlockName )
		if ( Con::expandScriptFilename( buffer, sizeof( buffer ), tileMapDataBlockName ) )
			tileMapDataBlockName = buffer;

If there are no other associated errors with the failed-load, then the stream-load functions encounted an error reading a single field so it fallsback as this general error. There are too many fields loaded to provide an error for each one. All other errors, such as datablocks not being available (but read from the stream correctly), show their own specific errors prior to the general one. The only thing I can think of is a corrupt file at this point If you know how, you could easily step through the "loadMap()" function in C++ and see where it decides there's a problem.

That's about all I can suggest at the moment.

- Melv.
#8
04/09/2005 (7:23 am)
The map was failing because two of the tiles used in it were not being loaded. I admit it, I'm an idiot. But what I still don't understand is the movement. I've thought some more about what LoTekk said and maybe he was right. It sure looked like the player car was moving normally, but since the tilemap wasn't loading I didn't have a proper frame of reference to judge the movement. And I was tired.

I really appreciate the attempts to help, sorry it was my own fault -- I sure don't mean to waste other people's time.
#9
04/09/2005 (8:26 am)
Not a problem, glad it's working. :)

- Melv.