- Timestamp:
- Sep 26, 2013, 2:59:02 AM (11 years ago)
- Branches:
- master
- Children:
- 2ee386d
- Parents:
- 50e6c7a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
r50e6c7a r99afbb8 35 35 #include "../common/Player.h" 36 36 #include "../common/Projectile.h" 37 #include "../common/Game.h" 37 38 38 39 #include "DataAccess.h" … … 44 45 // from used to be const. Removed that so I could take a reference 45 46 // and use it to send messages 46 bool processMessage(const NETWORK_MSG &clientMsg, struct sockaddr_in &from, MessageProcessor &msgProcessor, map<unsigned int, Player>& mapPlayers, WorldMap* gameMap, unsigned int& unusedPlayerId, NETWORK_MSG &serverMsg, int sock, int &scoreBlue, int &scoreRed, ofstream& outputLog);47 bool 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, NETWORK_MSG &serverMsg, int sock, int &scoreBlue, int &scoreRed, ofstream& outputLog); 47 48 48 49 void updateUnusedPlayerId(unsigned int& id, map<unsigned int, Player>& mapPlayers); … … 99 100 map<unsigned int, Player> mapPlayers; 100 101 map<unsigned int, Projectile> mapProjectiles; 102 map<string, Game> mapGames; 101 103 unsigned int unusedPlayerId = 1, unusedProjectileId = 1; 102 104 int scoreBlue, scoreRed; … … 530 532 531 533 if (n >= 0) { 532 broadcastResponse = processMessage(clientMsg, from, msgProcessor, mapPlayers, gameMap, unusedPlayerId, serverMsg, sock, scoreBlue, scoreRed, outputLog);534 broadcastResponse = processMessage(clientMsg, from, msgProcessor, mapPlayers, mapGames, gameMap, unusedPlayerId, serverMsg, sock, scoreBlue, scoreRed, outputLog); 533 535 534 536 if (broadcastResponse) … … 560 562 } 561 563 562 bool processMessage(const NETWORK_MSG &clientMsg, struct sockaddr_in &from, MessageProcessor &msgProcessor, map<unsigned int, Player>& mapPlayers, WorldMap* gameMap, unsigned int& unusedPlayerId, NETWORK_MSG &serverMsg, int sock, int &scoreBlue, int &scoreRed, ofstream& outputLog)564 bool 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, NETWORK_MSG &serverMsg, int sock, int &scoreBlue, int &scoreRed, ofstream& outputLog) 563 565 { 564 566 DataAccess da; … … 933 935 cout << "Game name: " << gameName << endl; 934 936 935 // temp var 936 int numPlayers = 0; 937 mapGames[gameName] = Game(gameName); 938 mapGames[gameName].addPlayer(findPlayerByAddr(mapPlayers, from)); 939 int numPlayers = mapGames[gameName].getNumPlayers(); 937 940 938 941 serverMsg.type = MSG_TYPE_GAME_INFO; … … 950 953 cout << "Game name: " << gameName << endl; 951 954 952 // temp var953 int numPlayers = 0;955 mapGames[gameName].addPlayer(findPlayerByAddr(mapPlayers, from)); 956 int numPlayers = mapGames[gameName].getNumPlayers(); 954 957 955 958 serverMsg.type = MSG_TYPE_GAME_INFO;
Note:
See TracChangeset
for help on using the changeset viewer.