Пример #1
0
void GamePair::removeClient(S32 index)
{
   // Disconnect before deleting
   ClientGame *clientGame = GameManager::getClientGames()->get(index);

   if(clientGame->getConnectionToServer())
      clientGame->getConnectionToServer()->disconnect(NetConnection::ReasonSelfDisconnect, "");

   this->idle(5, 5);      // Let things settle

   GameManager::deleteClientGame(index);
}
void LevelMenuSelectUserInterface::onActivate()
{
   Parent::onActivate();

   // Replace with a getLevelCount() method on Game?
   ClientGame *game = getGame();
   GameConnection *gc = game->getConnectionToServer();

   if(gc == NULL || gc->mLevelInfos.size() == 0)
      return;

   mMenuTitle = "CHOOSE LEVEL [" + mCategory + "]";
   mMenuDisplayItems.clear();

   char c[2];
   c[1] = 0;   // null termination

   if(mCategory == UPLOAD_LEVELS)
   {
      // Get all the playable levels in levelDir
      mMenuDisplayItems = mGameSettings->getLevelList();

      for(S32 i = 0; i < mMenuDisplayItems.size(); i++)
      {
         c[0] = mMenuDisplayItems[i][0];
         addMenuItem(new MenuItem(i | UPLOAD_LEVELS_BIT, 
                                  mMenuDisplayItems[i], 
                                  processLevelSelectionCallback, 
                                  "", 
                                  InputCodeManager::stringToInputCode(c)));
      }
   }
 
   for(S32 i = 0; i < gc->mLevelInfos.size(); i++)
   {
      if(gc->mLevelInfos[i].mLevelName == "")   // Skip levels with blank names --> but all should have names now!
         continue;

      if(strcmp(gc->mLevelInfos[i].getLevelTypeName(), mCategory.c_str()) == 0 || mCategory == ALL_LEVELS)
      {
         const char *levelName = gc->mLevelInfos[i].mLevelName.getString();
         c[0] = levelName[0];
         addMenuItem(new MenuItem(i, levelName, processLevelSelectionCallback, "", InputCodeManager::stringToInputCode(c)));
      }
   }

   if(!getGame()->isUsingPlaylist())
      sortMenuItems();
}
Пример #3
0
// Checks collisions with a SpeedZone
bool SpeedZone::collide(BfObject *hitObject)
{
    if(ignoreThisCollision)
        return false;

    // This is run on both server and client side to reduce lag
    if(isShipType(hitObject->getObjectTypeNumber()))     // Only ships & robots collide
    {
#ifndef ZAP_DEDICATED
        if(isGhost()) // On client, don't process speedZone on all moveObjects except the controlling one
        {
            ClientGame *client = static_cast<ClientGame *>(getGame());
            GameConnection *gc = client->getConnectionToServer();
            if(gc && gc->getControlObject() != hitObject)
                return false;
        }
#endif
        return true;
    }
    return false;
}