Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6341 in orxonox.OLD for trunk/src/story_entities/network_world.cc


Ignore:
Timestamp:
Dec 30, 2005, 1:57:12 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the network branche back to the trunk, so we do not get away from each other to fast

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/story_entities/network_world.cc

    r6222 r6341  
    6969#include "playable.h"
    7070#include "network_manager.h"
     71#include "network_game_manager.h"
    7172#include "playable.h"
    7273
     
    167168{
    168169  this->setClassID(CL_WORLD, "NetworkWorld");
     170  PRINTF(0)("START\n");
    169171
    170172  this->setName(name);
     
    337339  // find WorldEntities //
    338340  ////////////////////////
    339   if( NetworkManager::getInstance()->isGameServer())
    340   {}
    341 
    342341  element = root->FirstChildElement("WorldEntities");
    343342  if( element == NULL)
     
    352351    while( element != NULL)
    353352    {
    354       if( NetworkManager::getInstance()->isGameServer() || !strcmp( element->Value(), "SkyBox") || !strcmp( element->Value(), "Terrain")
    355           || !strcmp( element->Value(), "SpaceShip"))
     353      if( NetworkManager::getInstance()->isGameServer())
     354      {
     355
     356        BaseObject* created = NetworkGameManager::getInstance()->createEntity(element);
     357        if( created != NULL )
     358        {
     359          if(created->isA(CL_WORLD_ENTITY))
     360            this->spawn(dynamic_cast<WorldEntity*>(created));
     361          printf("Created a %s: %s\n", created->getClassName(), created->getName());
     362        }
     363        else
     364          PRINTF(1)("NetworkWorld: could not create this entity\n");
     365
     366          // if we load a 'Player' we use it as localPlayer
     367
     368
     369          //todo do this more elegant
     370        if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox"))
     371          sky = dynamic_cast<SkyBox*>(created);
     372        if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
     373        {
     374          terrain = dynamic_cast<Terrain*>(created);
     375          CDEngine::getInstance()->setTerrain(terrain);
     376        }
     377
     378      }
     379      else if( /* !strcmp( element->Value(), "SkyBox") || */ /* !strcmp( element->Value(), "Terrain") || */ !strcmp( element->Value(), "SpaceShip"))
    356380      {
    357381        BaseObject* created = Factory::fabricate(element);
     
    362386          printf("Created a %s: %s\n", created->getClassName(), created->getName());
    363387        }
     388        else
     389          PRINTF(1)("NetworkWorld: could not create this entity\n");
    364390
    365391          // if we load a 'Player' we use it as localPlayer
     
    374400          CDEngine::getInstance()->setTerrain(terrain);
    375401        }
    376 
    377402      }
    378403      element = element->NextSiblingElement();
     
    443468//   this->spawn(testEntity);
    444469
    445   for(int i = 0; i < 100; i++)
    446   {
    447     WorldEntity* tmp = new NPCTest1();
    448     char npcChar[10];
    449     sprintf (npcChar, "NPC_%d", i);
    450         tmp->setName(npcChar);
    451     tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30);
    452     this->spawn(tmp);
    453   }
     470//   for(int i = 0; i < 100; i++)
     471//   {
     472//     WorldEntity* tmp = NetworkGameManager::;
     473//     char npcChar[10];
     474//     sprintf (npcChar, "NPC_%d", i);
     475//         tmp->setName(npcChar);
     476//     tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30);
     477//     this->spawn(tmp);
     478//   }
    454479
    455480  this->music = NULL;
     
    865890//   this->entities->add (entity);
    866891  entity->postSpawn ();
     892
    867893}
    868894
Note: See TracChangeset for help on using the changeset viewer.