- Timestamp:
- Dec 28, 2013, 4:21:05 PM (11 years ago)
- Branches:
- master
- Children:
- eb2ad4f
- Parents:
- bcfd99a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
rbcfd99a r2e63b64 44 44 // from used to be const. Removed that so I could take a reference 45 45 // and use it to send messages 46 void processMessage(const NETWORK_MSG& clientMsg, struct sockaddr_in& from, MessageProcessor& msgProcessor, map<unsigned int, Player*>& mapPlayers, map<string, Game*>& mapGames, WorldMap* gameMap,unsigned int& unusedPlayerId);46 void processMessage(const NETWORK_MSG& clientMsg, struct sockaddr_in& from, MessageProcessor& msgProcessor, map<unsigned int, Player*>& mapPlayers, map<string, Game*>& mapGames, unsigned int& unusedPlayerId); 47 47 48 48 bool handleGameEvents(Game* game, map<unsigned int, Player*>& mapPlayers, MessageProcessor& msgPocessor); … … 90 90 outputLog.open("server.log", ios::app); 91 91 outputLog << "Started server on " << getCurrentDateTimeString() << endl; 92 93 WorldMap* gameMap = WorldMap::loadMapFromFile("../data/map.txt");94 95 // add some items to the map. They will be sent out96 // to players when they login97 for (int y=0; y<gameMap->height; y++)98 {99 for (int x=0; x<gameMap->width; x++)100 {101 switch (gameMap->getStructure(x, y))102 {103 case WorldMap::STRUCTURE_BLUE_FLAG:104 gameMap->addObject(WorldMap::OBJECT_BLUE_FLAG, x*25+12, y*25+12);105 break;106 case WorldMap::STRUCTURE_RED_FLAG:107 gameMap->addObject(WorldMap::OBJECT_RED_FLAG, x*25+12, y*25+12);108 break;109 }110 }111 }112 92 113 93 sock = socket(AF_INET, SOCK_DGRAM, 0); … … 212 192 map<string, Game*>::iterator itGames; 213 193 Game* game = NULL; 214 WorldMap* gameMap = NULL;215 194 216 195 for (itGames = mapGames.begin(); itGames != mapGames.end();) { … … 268 247 if (msgProcessor.receiveMessage(&clientMsg, &from) >= 0) 269 248 { 270 processMessage(clientMsg, from, msgProcessor, mapPlayers, mapGames, gameMap,unusedPlayerId);249 processMessage(clientMsg, from, msgProcessor, mapPlayers, mapGames, unusedPlayerId); 271 250 272 251 cout << "Finished processing the message" << endl; … … 293 272 } 294 273 295 void processMessage(const NETWORK_MSG &clientMsg, struct sockaddr_in &from, MessageProcessor &msgProcessor, map<unsigned int, Player*>& mapPlayers, map<string, Game*>& mapGames, WorldMap* gameMap,unsigned int& unusedPlayerId)274 void processMessage(const NETWORK_MSG &clientMsg, struct sockaddr_in &from, MessageProcessor &msgProcessor, map<unsigned int, Player*>& mapPlayers, map<string, Game*>& mapGames, unsigned int& unusedPlayerId) 296 275 { 297 276 NETWORK_MSG serverMsg;
Note:
See TracChangeset
for help on using the changeset viewer.