Changeset 1916 for code/branches/objecthierarchy/src/network/Server.cc
- Timestamp:
- Oct 14, 2008, 12:20:14 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/network/Server.cc
r1907 r1916 49 49 #include "ClientInformation.h" 50 50 #include "util/Sleep.h" 51 #include "objects/SpaceShip.h"52 51 #include "core/ConsoleCommand.h" 53 52 #include "core/CoreIncludes.h" … … 101 100 gamestates_ = new GamestateManager(); 102 101 } 103 102 104 103 /** 105 104 * @brief Destructor … … 304 303 COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl; 305 304 connection->syncClassid(temp->getID()); 306 COUT(5) << "creating spaceship for clientid: " << temp->getID() << std::endl;307 // TODO: this is only a hack, untill we have a possibility to define default player-join actions308 if(!createShip(temp))309 COUT(2) << "Con.Man. could not create ship for clientid: " << clientID << std::endl;310 else311 COUT(3) << "created spaceship" << std::endl;312 305 temp->setSynched(true); 313 306 COUT(3) << "sending welcome" << std::endl; … … 327 320 } 328 321 329 bool Server::createShip(ClientInformation *client){330 if(!client)331 return false;332 orxonox::Identifier* id = ClassByName("SpaceShip");333 if(!id){334 COUT(4) << "We could not create the SpaceShip for client: " << client->getID() << std::endl;335 return false;336 }337 orxonox::SpaceShip *no = dynamic_cast<orxonox::SpaceShip *>(id->fabricate());338 no->classID = id->getNetworkID();339 client->setShipID(no->getObjectID());340 no->setPosition(orxonox::Vector3(0,0,80));341 no->setScale(10);342 //no->setYawPitchRoll(orxonox::Degree(-90),orxonox::Degree(-90),orxonox::Degree(0));343 no->setMesh("assff.mesh");344 no->setMaxSpeed(500);345 no->setMaxSideAndBackSpeed(50);346 no->setMaxRotation(1.0);347 no->setTransAcc(200);348 no->setRotAcc(3.0);349 no->setTransDamp(75);350 no->setRotDamp(1.0);351 no->setCamera(std::string("cam_") + convertToString(client->getID()));352 no->create();353 354 return true;355 }356 357 322 bool Server::disconnectClient(ENetEvent *event){ 358 323 COUT(4) << "removing client from list" << std::endl; … … 360 325 361 326 //boost::recursive_mutex::scoped_lock lock(head_->mutex_); 362 orxonox::ObjectList<orxonox::SpaceShip>::iterator it = orxonox::ObjectList<orxonox::SpaceShip>::begin();363 327 ClientInformation *client = ClientInformation::findClient(&event->peer->address); 364 328 if(!client) 365 329 return false; 366 330 gamestates_->removeClient(client); 367 while(it){ 368 if(it->getObjectID()!=client->getShipID()){ 369 ++it; 370 continue; 371 } 372 orxonox::ObjectList<orxonox::SpaceShip>::iterator temp=it; 373 ++it; 374 delete *temp; 375 return ClientInformation::removeClient(event->peer); 376 } 377 return false; 331 return ClientInformation::removeClient(event->peer); 378 332 } 379 333 … … 387 341 gamestates_->removeClient(client); 388 342 } 389 343 390 344 bool Server::chat(std::string message){ 391 345 ClientInformation *temp = ClientInformation::getBegin();
Note: See TracChangeset
for help on using the changeset viewer.