Changeset 8820 in orxonox.OLD for branches/multi_player_map/src/world_entities/spawning_point.cc
- Timestamp:
- Jun 27, 2006, 12:37:58 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/multi_player_map/src/world_entities/spawning_point.cc
r8802 r8820 27 27 #include "game_rules.h" 28 28 29 #include "shared_network_data.h" 30 31 CREATE_FACTORY( SpawningPoint, CL_SPAWNING_POINT ); 29 32 30 33 /** … … 34 37 { 35 38 this->setAbsCoor(position); 36 this->classid = classid;37 this->mode = SPT_ALL_AT_ONCE;38 this->delay = 0;39 39 40 40 this->init(); … … 48 48 { 49 49 this->setAbsCoor(position); 50 this->classid = classid;51 this->mode = mode;52 this->delay = delay;53 50 54 51 this->init(); … … 56 53 57 54 55 SpawningPoint::SpawningPoint( const TiXmlElement * root ) 56 { 57 this->setAbsCoor( 0, 0, 0 ); 58 59 this->init(); 60 61 if (root != NULL) 62 this->loadParams(root); 63 } 58 64 59 65 void SpawningPoint::init() 60 66 { 61 67 this->setClassID(CL_SPAWNING_POINT, "SpawningPoint"); 68 PRINTF(0)("Created SpawningPoint\n"); 62 69 63 70 this->teamId = -1; 71 72 MessageManager::getInstance()->registerMessageHandler( MSGID_RESPAWN, respawnMessageHandler, NULL ); 64 73 } 65 74 … … 81 90 WorldEntity::loadParams(root); 82 91 83 /* now load the frequency */84 LoadParam(root, "delay", this, SpawningPoint, setSpawningDelay)85 .describe("sets the delay of the spawning point");86 87 92 /* load teamId */ 88 93 LoadParam(root, "teamId", this, SpawningPoint, setTeamId) 89 94 .describe("sets teamId"); 90 91 92 /* now load the seed */93 // LoadParam(root, "entity", this, SpawningPoint, setSpawningEntity)94 // .describe("sets the spawning entity");95 96 /* now load the seed */97 /* LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity)98 .describe("sets the class id of the entity to spawn")99 .defaultValues(CL_WORLD_ENTITY);*/100 95 } 101 96 … … 110 105 QueueEntry qe; 111 106 qe.entity = entity; 112 qe.list = entity->getOMListNumber();113 107 qe.respawnTime = this->localTimer + delay; 114 108 … … 129 123 130 124 //TODO set camera (not smooth) 125 126 if ( State::getGameRules() ) 127 { 128 (State::getGameRules())->registerSpawn( entity ); 129 } 131 130 } 132 131 … … 151 150 this->spawn(it->entity); 152 151 153 it->entity->toList( it->list ); 154 155 if ( State::getGameRules() ) 156 { 157 (State::getGameRules())->registerSpawn( it->entity ); 158 } 159 152 if ( SharedNetworkData::getInstance()->isGameServer() ) 153 this->sendRespawnMessage( it->entity->getUniqueID() ); 154 160 155 std::list<QueueEntry>::iterator delit = it; 161 156 it++; … … 179 174 */ 180 175 void SpawningPoint::draw() 181 {} 176 { 177 } 178 179 void SpawningPoint::sendRespawnMessage( int uniqueId ) 180 { 181 byte * buf = new byte[2*INTSIZE]; 182 183 assert( Converter::intToByteArray( this->getUniqueID(), buf, INTSIZE ) == INTSIZE ); 184 assert( Converter::intToByteArray( uniqueId, buf + INTSIZE, INTSIZE ) == INTSIZE ); 185 186 MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_NOT_ME, 0, MP_HIGHBANDWIDTH ); 187 } 188 189 bool SpawningPoint::respawnMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ) 190 { 191 if ( SharedNetworkData::getInstance()->isGameServer() ) 192 { 193 PRINTF(2)("server received spawn message!\n"); 194 return true; 195 } 196 197 int spUniqueId; 198 int uniqueId; 199 200 if ( dataLength != 2*INTSIZE ) 201 { 202 PRINTF(2)("spawn message has wrong size: %d\n", dataLength ); 203 return true; 204 } 205 206 assert( Converter::byteArrayToInt( data, &spUniqueId ) == INTSIZE ); 207 assert( Converter::byteArrayToInt( data+INTSIZE, &uniqueId ) == INTSIZE ); 208 209 //TODO find Playable and SpawningPoint and spawn Playable 210 211 return true; 212 } 213
Note: See TracChangeset
for help on using the changeset viewer.