[Orxonox-commit 3974] r8648 - in code/branches/presentation/src: libraries/network libraries/network/packet orxonox/infos orxonox/items orxonox/worldentities/pawns
scheusso at orxonox.net
scheusso at orxonox.net
Sat May 28 20:53:15 CEST 2011
Author: scheusso
Date: 2011-05-28 20:53:14 +0200 (Sat, 28 May 2011)
New Revision: 8648
Modified:
code/branches/presentation/src/libraries/network/Server.cc
code/branches/presentation/src/libraries/network/packet/Welcome.cc
code/branches/presentation/src/libraries/network/packet/Welcome.h
code/branches/presentation/src/orxonox/infos/GametypeInfo.cc
code/branches/presentation/src/orxonox/items/Engine.cc
code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc
code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h
Log:
some network related fixes
Modified: code/branches/presentation/src/libraries/network/Server.cc
===================================================================
--- code/branches/presentation/src/libraries/network/Server.cc 2011-05-28 18:01:37 UTC (rev 8647)
+++ code/branches/presentation/src/libraries/network/Server.cc 2011-05-28 18:53:14 UTC (rev 8648)
@@ -412,7 +412,7 @@
GamestateManager::setSynched(clientID);
COUT(4) << "sending welcome" << std::endl;
- packet::Welcome *w = new packet::Welcome(clientID, OBJECTID_UNKNOWN);
+ packet::Welcome *w = new packet::Welcome(clientID);
w->setPeerID(clientID);
b = w->send( static_cast<Host*>(this) );
assert(b);
Modified: code/branches/presentation/src/libraries/network/packet/Welcome.cc
===================================================================
--- code/branches/presentation/src/libraries/network/packet/Welcome.cc 2011-05-28 18:01:37 UTC (rev 8647)
+++ code/branches/presentation/src/libraries/network/packet/Welcome.cc 2011-05-28 18:53:14 UTC (rev 8648)
@@ -43,7 +43,7 @@
#define _CLIENTID _PACKETID + sizeof(Type::Value)
#define _ENDIANTEST _CLIENTID + sizeof(uint32_t)
- Welcome::Welcome( uint32_t clientID, uint32_t shipID )
+ Welcome::Welcome( uint32_t clientID )
: Packet()
{
flags_ = flags_ | PACKET_FLAGS_CLASSID;
Modified: code/branches/presentation/src/libraries/network/packet/Welcome.h
===================================================================
--- code/branches/presentation/src/libraries/network/packet/Welcome.h 2011-05-28 18:01:37 UTC (rev 8647)
+++ code/branches/presentation/src/libraries/network/packet/Welcome.h 2011-05-28 18:53:14 UTC (rev 8648)
@@ -40,7 +40,7 @@
class _NetworkExport Welcome : public Packet
{
public:
- Welcome( uint32_t clientID, uint32_t shipID );
+ Welcome( uint32_t clientID );
Welcome( uint8_t* data, uint32_t clientID );
virtual ~Welcome();
Modified: code/branches/presentation/src/orxonox/infos/GametypeInfo.cc
===================================================================
--- code/branches/presentation/src/orxonox/infos/GametypeInfo.cc 2011-05-28 18:01:37 UTC (rev 8647)
+++ code/branches/presentation/src/orxonox/infos/GametypeInfo.cc 2011-05-28 18:53:14 UTC (rev 8648)
@@ -341,12 +341,15 @@
{
if(GameMode::isMaster())
{
- // Display "Press [Fire] to start the match" if the game has not yet ended.
- if(!this->hasEnded())
- NotificationListener::sendNotification("Press [Fire] to start the match", GametypeInfo::NOTIFICATION_SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID());
- // Else display "Game has ended".
- else
- NotificationListener::sendNotification("Game has ended", GametypeInfo::NOTIFICATION_SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID());
+ if( player->isHumanPlayer() )
+ {
+ // Display "Press [Fire] to start the match" if the game has not yet ended.
+ if(!this->hasEnded())
+ NotificationListener::sendNotification("Press [Fire] to start the match", GametypeInfo::NOTIFICATION_SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID());
+ // Else display "Game has ended".
+ else
+ NotificationListener::sendNotification("Game has ended", GametypeInfo::NOTIFICATION_SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID());
+ }
}
}
Modified: code/branches/presentation/src/orxonox/items/Engine.cc
===================================================================
--- code/branches/presentation/src/orxonox/items/Engine.cc 2011-05-28 18:01:37 UTC (rev 8647)
+++ code/branches/presentation/src/orxonox/items/Engine.cc 2011-05-28 18:53:14 UTC (rev 8648)
@@ -71,7 +71,8 @@
Engine::~Engine()
{
-
+ if( this->ship_ && this->ship_->hasEngine(this) )
+ this->ship_->removeEngine(this);
}
void Engine::XMLPort(Element& xmlelement, XMLPort::Mode mode)
Modified: code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-05-28 18:01:37 UTC (rev 8647)
+++ code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-05-28 18:53:14 UTC (rev 8648)
@@ -373,9 +373,21 @@
void SpaceShip::removeAllEngines()
{
- for(unsigned int i=0; i<this->engineList_.size(); i++)
- this->engineList_[i]->destroy();
+ while(this->engineList_.size())
+ this->engineList_.back()->destroy();
}
+
+ void SpaceShip::removeEngine(Engine* engine)
+ {
+ for(std::vector<Engine*>::iterator it=this->engineList_.begin(); it!=this->engineList_.end(); ++it)
+ {
+ if(*it==engine)
+ {
+ this->engineList_.erase(it);
+ return;
+ }
+ }
+ }
void SpaceShip::setSpeedFactor(float factor)
{
Modified: code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h 2011-05-28 18:01:37 UTC (rev 8647)
+++ code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h 2011-05-28 18:53:14 UTC (rev 8648)
@@ -65,6 +65,7 @@
Engine* getEngine(unsigned int i); // This one's for XMLPort
inline const std::vector<Engine*>& getEngineList()
{ return this->engineList_; }
+ void removeEngine(Engine* engine);
void removeAllEngines();
void setSpeedFactor(float factor);
More information about the Orxonox-commit
mailing list