Changeset b07eeac in network-game for server/server.cpp
- Timestamp:
- May 25, 2013, 1:45:54 AM (11 years ago)
- Branches:
- master
- Children:
- 2df63d6
- Parents:
- b81cea1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
rb81cea1 rb07eeac 161 161 } 162 162 163 switch(gameMap->getStructure(it->second.pos.x/25, it->second.pos.y/25)) { 164 case WorldMap::STRUCTURE_BLUE_FLAG: 165 cout << "Got blue flag" << endl; 166 it->second.hasBlueFlag = true; 167 broadcastMove = true; 168 break; 169 case WorldMap::STRUCTURE_RED_FLAG: 170 cout << "Got red flag" << endl; 171 it->second.hasRedFlag = true; 172 broadcastMove = true; 173 break; 163 vector<WorldMap::Object> vctObjects = gameMap->getObjects(); 164 vector<WorldMap::Object>::iterator itObjects; 165 166 for (itObjects = vctObjects.begin(); itObjects != vctObjects.end(); itObjects++) { 167 POSITION pos = itObjects->pos; 168 if (posDistance(it->second.pos, pos.toFloat()) < 10) { 169 switch (itObjects->type) { 170 case WorldMap::OBJECT_BLUE_FLAG: 171 cout << "Got blue flag" << endl; 172 it->second.hasBlueFlag = true; 173 broadcastMove = true; 174 break; 175 case WorldMap::OBJECT_RED_FLAG: 176 cout << "Got red flag" << endl; 177 it->second.hasRedFlag = true; 178 broadcastMove = true; 179 break; 180 } 181 182 // send a MSG_TYPE_REMOVE_OBJECT message 183 serverMsg.type = MSG_TYPE_REMOVE_OBJECT; 184 memcpy(serverMsg.buffer, &itObjects->id, 4); 185 186 map<unsigned int, Player>::iterator it2; 187 for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++) 188 { 189 if ( sendMessage(&serverMsg, sock, &(it2->second.addr)) < 0 ) 190 error("sendMessage"); 191 } 192 } 174 193 } 175 194 … … 179 198 180 199 cout << "about to broadcast move" << endl; 181 map<unsigned int, Player>::iterator it , it2;200 map<unsigned int, Player>::iterator it2; 182 201 for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++) 183 202 { … … 415 434 mapPlayers[id].target.x = x; 416 435 mapPlayers[id].target.y = y; 417 int xDiff = mapPlayers[id].target.x - mapPlayers[id].pos.x;418 int yDiff = mapPlayers[id].target.y - mapPlayers[id].pos.y;419 436 420 437 serverMsg.type = MSG_TYPE_PLAYER_MOVE;
Note:
See TracChangeset
for help on using the changeset viewer.