Game Development Community

Severe scoping problems

by Dumbledore · in RTS Starter Kit · 06/13/2008 (4:53 pm) · 1 replies

Hello, I admit I have made many changes to the RTS kit and today is the first time I'm testing the scoping vs a remote client. My setup is a hybrid client-server computer and a client.

I started at the top, checking to see that the vismanager was performing it's calculations properly, then I finally went to cameraOnScopeQuery() and checked to see if the enemy units were getting NetConnection::objectInScope(enemyUnit) called on them. And they are.

I then made RTSUnits Ghostable and ScopeAlways. The effects never changed, and they are: on the hybrid I don't see any of the enemies but if I check the console I see "2145 - has arrived" when an enemy RTSUnit reaches its destination. I can also perform a drag select where I know the enemy is and I see the green selection rings rendered against the terrain. On the client, I see absolutely nothing.

Does anyone know what my problem is?

#1
06/14/2008 (11:11 am)
Okay so my best guess for the above is that the objects were scoping but because the rendering function also depends on the RTSConnection's list of visible objects (which wasn't getting the scoped objects added to it) it wasn't rendering the units.

I have confirmed that this was the case. However, the root of my problem stemmed from the fact that the path of execution cannot get passed:

for (U32 k = 0; k < mObjectList.size(); k++)
      {
			SceneObject* target = reinterpret_cast<SceneObject*>(mObjectList[i]);

         RTSConnection* targetClient = target->getControllingConnection();
         if (!targetClient)
            continue;

         if (targetClient == client)  // HERE... Even if its a unit that belongs to another client it evaluates true.
            continue;
}

The solution doesn't appear to be anything obvious, for instance I didn't change the way we setControllingConnection(). Here's the code which does it:

function RTSConnection::createPlayer(%this, %spawnPoint, %index)
{
      
   %player = new RTSUnit() 
   {
      scale = "1 1 1";
      dataBlock = %data;
      shapeFile = "~/data/shapes/player/player.dts";
      path = "";
   };

   MissionCleanup.add(%player);
   
   %player.setControllingConnection(%this);    // HERE IT SETS THE CONNECTION
   %player.setSkinName( getWord($Pref::Server::TeamInfo[%this.getTeam()], 3) );
   %player.setTeam(%this.getTeam());  
   %player.setTransform(%spawnPoint);
   %player.client = %this;
                    
   %player.stats["Kills"] = (getRandom() * 5) % 5;
   %player.stats["Damage Delt"] = (getRandom() * 1000) % 1000;
   
   // Add the unit to the group of units
   %this.units.add(%player);
}

So I am just a little baffled.