- Timestamp:
- Jan 11, 2006, 9:58:22 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/coord/p_node.cc
r6424 r6498 1039 1039 SYNCHELP_READ_FKT( BaseObject::writeState ); 1040 1040 1041 PRINTF(0)("name = %s\n", this->getName());1042 1043 1041 char * parentName = NULL; 1044 1042 SYNCHELP_READ_STRINGM( parentName ); … … 1065 1063 SYNCHELP_READ_FLOAT( f3 ); 1066 1064 this->setRelCoor( f1, f2, f3 ); 1067 //this->setRelCoor( 10, 0, 0 );1068 1069 SYNCHELP_READ_FLOAT( f1 );1065 //this->setRelCoor( 5, 0, 0 ); 1066 1067 /*SYNCHELP_READ_FLOAT( f1 ); 1070 1068 SYNCHELP_READ_FLOAT( f2 ); 1071 SYNCHELP_READ_FLOAT( f3 ); 1069 SYNCHELP_READ_FLOAT( f3 );*/ 1072 1070 //this->setAbsCoor( f1, f2, f3 ); 1073 1071 … … 1078 1076 this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) ); 1079 1077 1080 SYNCHELP_READ_FLOAT( f1 );1078 /*SYNCHELP_READ_FLOAT( f1 ); 1081 1079 SYNCHELP_READ_FLOAT( f2 ); 1082 1080 SYNCHELP_READ_FLOAT( f3 ); 1083 SYNCHELP_READ_FLOAT( f4 ); 1081 SYNCHELP_READ_FLOAT( f4 );*/ 1084 1082 //this->setAbsDir( Quaternion( Vector(f2, f3, f4), f1 ) ); 1085 1083 … … 1092 1090 { 1093 1091 SYNCHELP_READ_STRINGM( childName ); 1094 PRINTF(0)("childname = %s\n", childName);1092 //PRINTF(0)("childname = %s\n", childName); 1095 1093 addChild( childName ); 1096 1094 delete childName; … … 1113 1111 SYNCHELP_WRITE_FKT( BaseObject::readState ); 1114 1112 1115 PRINTF(0)("name = %s\n", this->getName());1116 1117 1113 if ( this->parent ) 1118 1114 { … … 1130 1126 SYNCHELP_WRITE_FLOAT( this->relCoordinate.z ); 1131 1127 1132 PRINTF(0)("%s, %f, %f, %f\n", getClassName(), relCoordinate.x, relCoordinate.y, relCoordinate.z);1133 1134 SYNCHELP_WRITE_FLOAT( this->absCoordinate.x );1128 //PRINTF(0)("%s, %f, %f, %f\n", getClassName(), relCoordinate.x, relCoordinate.y, relCoordinate.z); 1129 1130 /*SYNCHELP_WRITE_FLOAT( this->absCoordinate.x ); 1135 1131 SYNCHELP_WRITE_FLOAT( this->absCoordinate.y ); 1136 SYNCHELP_WRITE_FLOAT( this->absCoordinate.z ); 1137 1138 PRINTF(0)("%s, %f, %f, %f\n", getClassName(), absCoordinate.x, absCoordinate.y, absCoordinate.z);1132 SYNCHELP_WRITE_FLOAT( this->absCoordinate.z );*/ 1133 1134 //PRINTF(0)("%s, %f, %f, %f\n", getClassName(), absCoordinate.x, absCoordinate.y, absCoordinate.z); 1139 1135 1140 1136 SYNCHELP_WRITE_FLOAT( this->relDirection.w ); … … 1143 1139 SYNCHELP_WRITE_FLOAT( this->relDirection.v.z ); 1144 1140 1145 SYNCHELP_WRITE_FLOAT( this->absDirection.w );1141 /*SYNCHELP_WRITE_FLOAT( this->absDirection.w ); 1146 1142 SYNCHELP_WRITE_FLOAT( this->absDirection.v.x ); 1147 1143 SYNCHELP_WRITE_FLOAT( this->absDirection.v.y ); 1148 SYNCHELP_WRITE_FLOAT( this->absDirection.v.z ); 1144 SYNCHELP_WRITE_FLOAT( this->absDirection.v.z );*/ 1149 1145 1150 1146 int n = children.size(); … … 1153 1149 for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++) 1154 1150 { 1155 PRINTF(0)("childname = %s\n", (*it)->getName() );1156 1151 SYNCHELP_WRITE_STRING( (*it)->getName() ); 1157 1152 } 1153 1158 1154 return SYNCHELP_WRITE_N; 1159 1155 } -
trunk/src/lib/coord/p_node.h
r6424 r6498 21 21 #include "base_object.h" 22 22 #include "stdincl.h" 23 #include "synchronizeable.h" 23 24 24 25 #include "vector.h" … … 72 73 73 74 //! Patent Node is a Engine to calculate the position of an Object in respect to the position of its parent. 74 class PNode : virtual public BaseObject {75 class PNode : virtual public BaseObject, virtual public Synchronizeable { 75 76 public: 76 77 PNode (PNode* parent = PNode::getNullParent(), long nodeFlags = PNODE_PARENT_MODE_DEFAULT); -
trunk/src/lib/lang/base_object.cc
r6341 r6498 199 199 } 200 200 SYNCHELP_READ_STRINGM( this->objectName ); 201 if ( this->objectName && !strcmp(this->objectName, "") ) 202 { 203 delete[] this->objectName; 204 this->objectName = NULL; 205 } 201 206 202 207 return SYNCHELP_READ_N; -
trunk/src/lib/network/network_game_manager.cc
r6424 r6498 25 25 26 26 #include "p_node.h" 27 #include "state.h" 28 #include "game_world.h" 29 #include "world_entity.h" 30 #include "playable.h" 31 #include "player.h" 32 #include "network_manager.h" 27 33 28 34 … … 81 87 { 82 88 b = data[i++]; 83 84 PRINTF(0)("WriteBytes: b = %d\n", b);85 89 86 90 if ( isServer() ) … … 142 146 if ( b == REQUEST_ENTITY_LIST ) 143 147 { 144 PRINTF(0)("sending THE list\n");145 148 sendEntityList( sender ); 146 149 continue; … … 163 166 SYNCHELP_WRITE_BYTE( b ); 164 167 hasRequestedWorld = true; 165 PRINTF(0)("the world is enough! id=%d\n", this->getUniqueID());166 168 return SYNCHELP_WRITE_N; 167 169 } 170 168 171 for ( int i = 0; i<outBuffer.size(); i++ ) 169 172 { … … 216 219 * @param classID: The ID of the class of which an entity should be created 217 220 */ 218 void NetworkGameManager::createEntity( ClassID classID, int owner ) 219 { 221 int NetworkGameManager::createEntity( ClassID classID, int owner ) 222 { 223 220 224 if ( this->isServer() ) 221 225 { … … 223 227 { 224 228 PRINTF(1)("Cannot create entity! There are no more uniqueIDs left!\n"); 225 return ;226 } 227 228 this->executeCreateEntity( classID, newUniqueID++, owner );229 return -1; 230 } 231 232 return this->executeCreateEntity( classID, newUniqueID++, owner ); 229 233 } 230 234 else 231 235 { 232 236 this->requestCreateEntity( classID ); 237 return -1; 233 238 } 234 239 } … … 273 278 delete b; 274 279 } 280 275 281 } 276 282 else … … 330 336 * @param classID: The ID of the class of which an entity should be created 331 337 */ 332 voidNetworkGameManager::executeCreateEntity(ClassID classID, int uniqueID, int owner)338 int NetworkGameManager::executeCreateEntity(ClassID classID, int uniqueID, int owner) 333 339 { 334 340 if ( !writeToClientBuffer( allOutBuffer, (byte)CREATE_ENTITY ) ) 335 return ;341 return -1; 336 342 if ( !writeToClientBuffer( allOutBuffer, (int)classID ) ) 337 return ;343 return -1; 338 344 if ( !writeToClientBuffer( allOutBuffer, uniqueID ) ) 339 return ;345 return -1; 340 346 if ( !writeToClientBuffer( allOutBuffer, owner ) ) 341 return ;347 return -1; 342 348 343 349 doCreateEntity( classID, uniqueID, owner ); 350 351 return uniqueID; 344 352 } 345 353 … … 401 409 if ( !writeToClientBuffer( outBuffer[userID], (int)((*it)->getLeafClassID()) ) ) 402 410 return; 403 //PRINTF(0)("SendEntityList: ClassID = %x\n", (*it)->getRealClassID());404 411 405 412 if ( !writeToClientBuffer( outBuffer[userID], (int)((*it)->getUniqueID()) ) ) … … 409 416 return; 410 417 411 412 PRINTF(0)("id = %x %s %s\n", (int)((*it)->getLeafClassID()), (*it)->getClassName(), (*it)->getName());413 414 415 /*if ( (*it)->isA(CL_WORLD_ENTITY) )416 {417 n = dynamic_cast<WorldEntity*>((*it))->readState( outBuffer[userID].buffer, outBuffer[userID].maxLength-outBuffer[userID].length );418 if ( n = 0 )419 {420 PRINTF(2)("n = 0\n");421 }422 outBuffer[userID].length += n;423 }*/424 425 418 it++; 426 419 } 427 420 428 429 } 421 signalNewPlayer( userID ); 422 } 423 424 425 426 bool NetworkGameManager::signalNewPlayer(int userId) 427 { 428 429 /* create new playable for Player*/ 430 PRINTF(0)("Request for creation: %i\n", userId); 431 int uniqueId = this->createEntity(CL_SPACE_SHIP, userId); 432 PRINTF(0)("Request for creation: userid: %i, uniqueid: %i\n", userId, uniqueId); 433 this->sendYouAre(uniqueId, userId); 434 435 } 436 430 437 431 438 /** … … 474 481 s->setIsOutOfSync( true ); 475 482 PRINTF(0)("Fabricated %s with id %d\n", s->getClassName(), s->getUniqueID()); 483 484 //HACK: hack to prevent collision 485 if ( b->isA(CL_WORLD_ENTITY) ) 486 { 487 if ( NetworkManager::getInstance()->getHostID()!=0 ) 488 { 489 static Vector pos = Vector(1000.0, 1000.0, 1000.0); 490 PNode *p = dynamic_cast<PNode*>(b); 491 p->setRelCoor(pos); 492 p->updateNode(0); 493 pos += Vector(1000.0, 1000.0, 1000.0); 494 } 495 } 496 476 497 return b; 477 498 } … … 571 592 void NetworkGameManager::doYouAre( int uniqueID ) 572 593 { 573 //TODO: what has to be done 594 595 SynchronizeableList::const_iterator it = this->networkStream->getSyncBegin(); 596 597 Playable *p = NULL; 598 599 for ( ; it !=networkStream->getSyncEnd(); it++ ) 600 { 601 if ( (*it)->getUniqueID()==uniqueID ) 602 { 603 if ( (*it)->isA( CL_PLAYABLE ) ) 604 { 605 p = dynamic_cast<Playable*>(*it); 606 break; 607 } else 608 { 609 PRINTF(1)("UniqueID is not a Playable\n"); 610 } 611 } 612 } 613 614 Player* player = State::getPlayer(); 615 assert(p != NULL); 616 assert(player != NULL); 617 618 player->setControllable(p); 619 620 574 621 } 575 622 … … 716 763 i += Converter::byteArrayToInt( &data[i], &owner ); 717 764 718 PRINTF(0)("before fabricate\n");719 765 if ( classID != CL_NETWORK_GAME_MANAGER && classID != CL_HANDSHAKE ) 720 766 { -
trunk/src/lib/network/network_game_manager.h
r6424 r6498 74 74 virtual void readDebug() const; 75 75 76 voidcreateEntity( ClassID classID, int owner = 0 );76 int createEntity( ClassID classID, int owner = 0 ); 77 77 BaseObject* createEntity(const TiXmlElement* element); 78 78 void removeEntity( int uniqueID ); … … 87 87 88 88 void requestCreateEntity(ClassID classID); 89 voidexecuteCreateEntity(ClassID classID, int uniqueID = 0, int owner = 0);89 int executeCreateEntity(ClassID classID, int uniqueID = 0, int owner = 0); 90 90 91 91 void requestRemoveEntity(int uniqueID); … … 100 100 101 101 bool canCreateEntity(ClassID classID); 102 103 bool signalNewPlayer(int userId); 102 104 103 105 void resizeBufferVector(int n); -
trunk/src/lib/network/network_stream.cc
r6341 r6498 166 166 networkSockets[0]->destroy(); 167 167 networkSockets[0] = NULL; 168 //TODO: delete handshake from synchronizeable list so i can delete it 168 169 169 if ( handshakes[0] ) 170 170 delete handshakes[0]; … … 192 192 else 193 193 { 194 //this->networkGameManager->sendEntityList( i ); 194 195 195 } 196 196 PRINT(0)("handshake finished id=%d\n", handshakes[i]->getNetworkGameManagerId()); … … 252 252 if ( networkSockets[reciever] != NULL ) 253 253 { 254 PRINTF( 0)("write %d bytes to socket %d\n", dataLength, reciever);254 PRINTF(5)("write %d bytes to socket %d\n", dataLength, reciever); 255 255 networkSockets[reciever]->writePacket(downBuffer, dataLength); 256 256 } … … 266 266 if ( networkSockets[i] != NULL ) 267 267 { 268 PRINTF( 0)("write %d bytes to socket %d\n", dataLength, reciever);268 PRINTF(5)("write %d bytes to socket %d\n", dataLength, reciever); 269 269 networkSockets[i]->writePacket(downBuffer, dataLength); 270 270 } … … 291 291 dataLength -= sizeof(header); 292 292 293 PRINTF( 0)("read %d bytes from socket uniqueID = %d\n", dataLength, header.synchronizeableID);293 PRINTF(5)("read %d bytes from socket uniqueID = %d\n", dataLength, header.synchronizeableID); 294 294 295 295 if ( dataLength != header.length ) … … 372 372 networkSockets[i]->destroy(); 373 373 networkSockets[i] = NULL; 374 //TODO: delete handshake from synchronizeable list so i can delete it 374 375 375 if ( handshakes[i] ) 376 376 delete handshakes[i]; -
trunk/src/story_entities/game_world.cc
r6457 r6498 131 131 this->shell = new Shell(); 132 132 133 State::setCurrentStoryEntity(dynamic_cast<StoryEntity*>(this)); 133 134 this->dataTank->init(); 134 135 } -
trunk/src/story_entities/game_world.h
r6424 r6498 9 9 10 10 #include "story_entity.h" 11 11 #include "game_world_data.h" 12 12 13 13 class TiXmlElement; … … 56 56 57 57 58 inline void setSky(WorldEntity* sky) { this->dataTank->sky = sky; } 59 60 58 61 protected: 59 62 /* world - running functions */ -
trunk/src/story_entities/multi_player_world.cc
r6424 r6498 21 21 #include "factory.h" 22 22 #include "load_param.h" 23 #include "shell_command.h" 23 24 24 25 #include "network_manager.h" … … 26 27 27 28 using namespace std; 29 30 31 //! Register a command to print some multiplayer world infos 32 SHELL_COMMAND(debug, MultiPlayerWorld, debug); 28 33 29 34 … … 79 84 } 80 85 86 87 /** 88 * some debug ouptut - shell command 89 */ 90 void MultiPlayerWorld::debug() 91 { 92 ((MultiPlayerWorldData*)this->dataTank)->debug(); 93 } -
trunk/src/story_entities/multi_player_world.h
r6424 r6498 27 27 void loadParams(const TiXmlElement* root); 28 28 29 void debug(); 30 29 31 protected: 30 32 virtual void synchronize(); -
trunk/src/story_entities/multi_player_world_data.cc
r6434 r6498 50 50 51 51 52 52 53 using namespace std; 53 54 … … 58 59 MultiPlayerWorldData::MultiPlayerWorldData() 59 60 : GameWorldData() 60 {} 61 { 62 this->toggle = false; 63 } 61 64 62 65 … … 157 160 } 158 161 } 159 /* clients only spawn the SpaceShip */160 /// FIXME it is not said to be a SpaceShip161 else if( !strcmp( element->Value(), "SpaceShip"))162 {163 BaseObject* created = Factory::fabricate(element);164 if( created != NULL )165 PRINTF(1)("Created a %s: %s (%8.u)\n", created->getClassName(), created->getName(), created->getLeafClassID());166 else167 PRINTF(1)("NetworkWorld: could not create this entity\n");168 }169 162 element = element->NextSiblingElement(); 163 170 164 171 165 glmis->step(); … … 173 167 } 174 168 175 176 /* create a Player */ 177 this->localPlayer = new Player(); 178 Playable* playable; 179 const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE); 180 if (playableList != NULL) 181 { 182 playable = dynamic_cast<Playable*>(playableList->front()); 183 this->localPlayer->setControllable(playable); 169 if( NetworkManager::getInstance()->isGameServer()) 170 { 171 this->localPlayer = new Player(); 172 State::setPlayer(this->localPlayer); 173 174 Playable* playable; 175 const std::list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE); 176 assert( playableList != NULL); 177 178 if (playableList != NULL) 179 { 180 playable = dynamic_cast<Playable*>(playableList->front()); 181 this->localPlayer->setControllable(playable); 182 } 183 } 184 else 185 { 186 /* create a Player */ 187 this->localPlayer = new Player(); 188 State::setPlayer(this->localPlayer); 184 189 } 185 190 … … 221 226 } 222 227 228 229 /** 230 * some debug output 231 */ 232 void MultiPlayerWorldData::debug() 233 { 234 PRINT(0)("==================================================\n"); 235 Playable* playable; 236 const std::list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE); 237 assert(playableList != NULL); 238 std::list<BaseObject*>::const_iterator entity; 239 240 241 242 for (entity = playableList->begin(); entity != playableList->end(); entity++) 243 { 244 Playable* p = dynamic_cast<Playable*>(*entity); 245 PRINTF(0)("Got a playable, class: %s, name: %s, uid: %i\n", (*entity)->getClassName(), (*entity)->getName(), p->getUniqueID()); 246 } 247 248 249 if( this->toggle) 250 { 251 playable = dynamic_cast<Playable*>(playableList->front()); 252 this->localPlayer->disconnectControllable(); 253 this->localPlayer->setControllable(playable); 254 this->toggle = !this->toggle; 255 } 256 else 257 { 258 playable = dynamic_cast<Playable*>(playableList->back()); 259 this->localPlayer->disconnectControllable(); 260 this->localPlayer->setControllable(playable); 261 this->toggle = !this->toggle; 262 } 263 264 265 266 PNode* cam = State::getCameraTarget(); 267 PRINT(0)("Camera has target - class: %s, name: %s, uid: %i\n", cam->getClassName(), cam->getName(), cam->getUniqueID()); 268 269 PRINT(0)("==================================================\n"); 270 271 } 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 -
trunk/src/story_entities/multi_player_world_data.h
r6424 r6498 24 24 virtual ErrorMessage init(); 25 25 26 void debug(); 27 26 28 27 29 protected: … … 33 35 virtual ErrorMessage unloadWorldEntities(); 34 36 virtual ErrorMessage unloadScene(); 37 38 private: 39 bool toggle; 35 40 }; 36 41 -
trunk/src/util/hud.cc
r6446 r6498 143 143 void Hud::updateResolution() 144 144 { 145 this->resX = State:: resX();146 this->resY = State:: resY();145 this->resX = State::getResX(); 146 this->resY = State::getResY(); 147 147 if (this->energyWidget != NULL) 148 148 { … … 174 174 void Hud::tick(float dt) 175 175 { 176 if (this->resY != State:: resY() || this->resX != State::resY())176 if (this->resY != State::getResY() || this->resX != State::getResY()) 177 177 this->updateResolution(); 178 178 } -
trunk/src/util/state.cc
r6468 r6498 29 29 PNode* State::cameraTarget = NULL; 30 30 31 Player* State::_localPlayer = NULL; 32 SkyBox* State::_skyBox = NULL; 31 SkyBox* State::skyBox = NULL; 33 32 34 33 ObjectManager* State::objectManager = NULL; 35 34 36 unsigned int State::_resX = 1; 37 unsigned int State::_resY = 1; 35 36 unsigned int State::resX = 1; 37 unsigned int State::resY = 1; 38 39 StoryEntity* State::storyEntity = NULL; 40 41 Player* State::player = NULL; 42 38 43 39 44 /** -
trunk/src/util/state.h
r6468 r6498 7 7 #define _STATE_H 8 8 9 9 10 // FORWARD DECLARATION 10 11 class PNode; 11 12 class WorldEntity; 13 class Player; 14 class SkyBox; 15 class StoryEntity; 12 16 class ObjectManager; 13 class SkyBox;14 class Player;15 17 16 18 … … 34 36 static inline PNode* getCameraTarget() { return State::cameraTarget; }; 35 37 36 /** @returns the Local Player */ 37 static inline Player* localsPlayer() { return State::_localPlayer; }; 38 /** @param localPlayer the local Player */ 39 static inline void setLocalPlayer(Player* localPlayer) { State::_localPlayer = localPlayer; }; 40 38 //////////////// 39 /// SKYBOX /// 40 //////////////// 41 41 /** @returns the current SkyBox */ 42 static inline SkyBox* skyBox() { return State::_skyBox; };42 static inline SkyBox* getSkyBox() { return State::skyBox; }; 43 43 /** @param skyBox the SkyBox */ 44 static inline SkyBox* setSkyBox(SkyBox* skyBox) { State::_skyBox = skyBox; }; 45 44 static inline SkyBox* setSkyBox(SkyBox* skyBox) { State::skyBox = skyBox; }; 46 45 47 46 ////////////////////// … … 53 52 static inline ObjectManager* getObjectManager() { return State::objectManager; }; 54 53 54 static inline void setResolution(unsigned int resX, unsigned int resY) { State::resX = resX; State::resY = resY; }; 55 static inline unsigned int getResX() { return State::resX; }; 56 static inline unsigned int getResY() { return State::resY; }; 55 57 56 static inline void setResolution(unsigned int resX, unsigned int resY) { State::_resX = resX; State::_resY = resY; }; 57 static inline unsigned int resX() { return State::_resX; }; 58 static inline unsigned int resY() { return State::_resY; }; 58 ////////////////////// 59 /// STORY-ENTITY /// 60 ////////////////////// 61 /** @param storyEntity sets the current StoryEntity that is been played */ 62 static inline void setCurrentStoryEntity(StoryEntity* storyEntity) { State::storyEntity = storyEntity; }; 63 /** @returns the current StoryEntity played */ 64 static inline StoryEntity* getCurrentStoryEntity() { return State::storyEntity; }; 59 65 60 ///////////////////////// 61 /// WORLD_ENTITY_LIST /// 62 ///////////////////////// 66 ////////////// 67 /// PLAYER /// 68 ////////////// 69 /** @param player sets the current local player */ 70 static inline void setPlayer(Player* player) { State::player = player; }; 71 /** @returns the local player*/ 72 static inline Player* getPlayer() { return State::player; }; 73 74 63 75 64 76 private: … … 68 80 static PNode* cameraTarget; //!< A reference to the cameraTarget 69 81 static PNode* nullParent; //!< A reference to the Null-PNode. 70 static ObjectManager* objectManager; //!< A referenct to the current ObjectManager 82 static ObjectManager* objectManager; //!< A reference to the current ObjectManager 83 static StoryEntity* storyEntity; //!< A reference to the current StoryEntity played 84 static Player* player; //!< A reference to the Player 71 85 72 static Player* _localPlayer; //!< The Local Player. 73 static SkyBox* _skyBox; //!< The SkyBox used in the current world. 74 static unsigned int _resX; //!< The X Resolution of the screen. 75 static unsigned int _resY; //!< The Y Resolution of the screen. 86 static SkyBox* skyBox; //!< The SkyBox used in the current world. 87 static unsigned int resX; //!< The X Resolution of the screen. 88 static unsigned int resY; //!< The Y Resolution of the screen. 76 89 }; 77 90 -
trunk/src/world_entities/power_ups/param_power_up.cc
r6424 r6498 138 138 SYNCHELP_READ_INT( this->min_value ); 139 139 SYNCHELP_READ_INT( this->max_value ); 140 respawn(); 140 141 } 141 142 … … 162 163 SYNCHELP_WRITE_FKT( PowerUp::readState ); 163 164 164 int i = this->type;165 int i = (int)this->type; 165 166 SYNCHELP_WRITE_INT( i ); 166 167 SYNCHELP_WRITE_INT( this->value ); -
trunk/src/world_entities/power_ups/power_up.cc
r6424 r6498 96 96 } 97 97 98 99 100 /******************************************************************************************** 101 NETWORK STUFF 102 ********************************************************************************************/ 103 104 98 105 /** 99 106 * data copied in data will bee sent to another host … … 108 115 return SYNCHELP_WRITE_N; 109 116 } 117 110 118 111 119 /** -
trunk/src/world_entities/power_ups/turret_power_up.cc
r6424 r6498 119 119 } 120 120 121 122 123 124 /******************************************************************************************** 125 NETWORK STUFF 126 ********************************************************************************************/ 127 128 121 129 int TurretPowerUp::writeBytes( const byte * data, int length, int sender ) 122 130 { … … 130 138 return SYNCHELP_READ_N; 131 139 } 132 133 140 134 141 -
trunk/src/world_entities/skybox.cc
r6470 r6498 270 270 SYNCHELP_READ_STRINGM( textureName ); 271 271 272 PRINT(0)("GOT DATA: size=%f texture='%s'\n", size, textureName);273 274 272 this->setSize( size ); 275 273 this->setTextureAndType( textureName, "jpg" ); … … 292 290 if ( rec > 0 ) 293 291 { 294 PRINT(0)("SEND DATA: size=%f texture='%s'\n", size, textureName);295 292 *reciever = rec; 296 293 -
trunk/src/world_entities/space_ships/space_ship.cc
r6444 r6498 510 510 } 511 511 512 #define MASK_bUp 1 513 #define MASK_bDown 2 514 #define MASK_bLeft 4 515 #define MASK_bRight 8 516 #define MASK_bAscend 16 517 #define MASK_bDescend 32 518 #define MASK_bFire 64 519 #define MASK_bRollL 128 520 #define MASK_bRollR 256 521 522 #define DATA_state 1 523 #define DATA_flags 2 524 #define DATA_mouse 3 512 525 513 526 int SpaceShip::writeBytes( const byte * data, int length, int sender ) 514 527 { 515 setRequestedSync( false );516 setIsOutOfSync( false );517 518 528 SYNCHELP_READ_BEGIN(); 519 529 520 SYNCHELP_READ_FKT( WorldEntity::writeState ); 530 byte b; 531 SYNCHELP_READ_BYTE( b ); 532 533 if ( b == DATA_state && this->getHostID()!=this->getOwner() ) 534 { 535 setRequestedSync( false ); 536 setIsOutOfSync( false ); 537 SYNCHELP_READ_FKT( WorldEntity::writeState ); 538 SYNCHELP_READ_FLOAT( cycle ); 539 } 540 541 if ( b == DATA_flags && this->getHostID()!=this->getOwner() ) 542 { 543 int flags; 544 SYNCHELP_READ_INT( flags ); 545 546 bUp = flags & MASK_bUp != 0; 547 bDown = flags & MASK_bDown != 0; 548 bLeft = flags & MASK_bLeft != 0; 549 bRight = flags & MASK_bRight != 0; 550 bAscend = flags & MASK_bAscend != 0; 551 bDescend = flags & MASK_bDescend != 0; 552 bFire = flags & MASK_bFire != 0; 553 bRollL = flags & MASK_bRollL != 0; 554 bRollR = flags & MASK_bRollR != 0; 555 } 556 557 if ( b == DATA_mouse && this->getHostID()!=this->getOwner() ) 558 { 559 SYNCHELP_READ_FLOAT( xMouse ); 560 SYNCHELP_READ_FLOAT( yMouse ); 561 SYNCHELP_READ_FLOAT( mouseSensitivity ); 562 SYNCHELP_READ_FLOAT( cycle ); 563 } 521 564 522 565 return SYNCHELP_READ_N; 523 566 } 524 567 568 569 525 570 int SpaceShip::readBytes( byte * data, int maxLength, int * reciever ) 526 571 { 572 SYNCHELP_WRITE_BEGIN(); 573 527 574 if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() ) 528 575 { … … 536 583 *reciever = rec; 537 584 538 SYNCHELP_WRITE_B EGIN();585 SYNCHELP_WRITE_BYTE( (byte)DATA_state ); 539 586 540 587 SYNCHELP_WRITE_FKT( WorldEntity::readState ); 588 SYNCHELP_WRITE_FLOAT( cycle ); 541 589 542 590 return SYNCHELP_WRITE_N; 543 591 } 544 592 593 545 594 *reciever = 0; 546 return 0; 547 } 595 596 if ( this->getHostID()==this->getOwner() ) 597 { 598 int mask = 0; 599 600 if ( bUp ) 601 mask |= MASK_bUp; 602 if ( bDown ) 603 mask |= MASK_bDown; 604 if ( bLeft ) 605 mask |= MASK_bLeft; 606 if ( bRight ) 607 mask |= MASK_bRight; 608 if ( bAscend ) 609 mask |= MASK_bAscend; 610 if ( bFire ) 611 mask |= MASK_bFire; 612 if ( bRollL ) 613 mask |= MASK_bRollL; 614 if ( bRollR ) 615 mask |= MASK_bRollR; 616 617 static int oldMask = mask+1; //so it is different the first time! 618 static float oldxMouse = xMouse + 1.0; 619 static float oldyMouse = yMouse + 1.0; 620 621 if ( mask != oldMask ) 622 { 623 oldMask = mask; 624 SYNCHELP_WRITE_BYTE( DATA_flags ); 625 SYNCHELP_WRITE_INT( mask ); 626 } 627 628 if ( oldxMouse != xMouse || oldyMouse != yMouse ) 629 { 630 oldxMouse = xMouse; 631 oldyMouse = yMouse; 632 SYNCHELP_WRITE_BYTE( DATA_mouse ); 633 SYNCHELP_WRITE_FLOAT( xMouse ); 634 SYNCHELP_WRITE_FLOAT( yMouse ); 635 SYNCHELP_WRITE_FLOAT( mouseSensitivity ); 636 SYNCHELP_WRITE_FLOAT( cycle ); 637 } 638 } 639 640 return SYNCHELP_WRITE_N; 641 } -
trunk/src/world_entities/world_entity.cc
r6440 r6498 491 491 492 492 493 494 495 /******************************************************************************************** 496 NETWORK STUFF 497 ********************************************************************************************/ 498 499 493 500 /** 494 501 * Writes data from network containing information about the state … … 523 530 524 531 SYNCHELP_READ_STRINGM( modelFileName ); 532 525 533 if ( strcmp(modelFileName, "") ) 526 this->md2TextureFileName = modelFileName; 534 if ( strstr(modelFileName, ResourceManager::getInstance()->getDataDir()) ) 535 { 536 this->md2TextureFileName = new char[strlen(modelFileName)-strlen(ResourceManager::getInstance()->getDataDir())+1]; 537 strcpy((char*)this->md2TextureFileName, modelFileName+strlen(ResourceManager::getInstance()->getDataDir())); 538 } 539 else 540 { 541 this->md2TextureFileName = modelFileName; 542 } 527 543 528 544 return SYNCHELP_READ_N; 529 545 } 546 530 547 531 548 /** -
trunk/src/world_entities/world_entity.h
r6440 r6498 28 28 29 29 //! Basis-class all interactive stuff in the world is derived from 30 class WorldEntity : public PNode , public Synchronizeable30 class WorldEntity : public PNode 31 31 { 32 32 public:
Note: See TracChangeset
for help on using the changeset viewer.