Changeset fbcfc35 in network-game
- Timestamp:
- Jun 9, 2013, 5:59:48 PM (12 years ago)
- Branches:
- master
- Children:
- 8795a38
- Parents:
- b978503
- Location:
- client/Client
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/Client.vcxproj
rb978503 rfbcfc35 65 65 <ItemGroup> 66 66 <ClCompile Include="..\..\common\Common.cpp" /> 67 <ClCompile Include="..\..\common\Projectile.cpp" /> 67 68 <ClCompile Include="..\..\common\WorldMap.cpp" /> 68 69 <ClCompile Include="..\..\common\Message.cpp" /> … … 78 79 <ClInclude Include="..\..\common\Common.h" /> 79 80 <ClInclude Include="..\..\common\Compiler.h" /> 81 <ClInclude Include="..\..\common\Projectile.h" /> 80 82 <ClInclude Include="..\..\common\WorldMap.h" /> 81 83 <ClInclude Include="..\..\common\Message.h" /> -
client/Client/Client.vcxproj.filters
rb978503 rfbcfc35 58 58 <Filter>Source Files\common</Filter> 59 59 </ClCompile> 60 <ClCompile Include="..\..\common\Projectile.cpp"> 61 <Filter>Source Files\common</Filter> 62 </ClCompile> 60 63 </ItemGroup> 61 64 <ItemGroup> … … 90 93 <Filter>Header Files\common</Filter> 91 94 </ClInclude> 95 <ClInclude Include="..\..\common\Projectile.h"> 96 <Filter>Header Files\common</Filter> 97 </ClInclude> 92 98 </ItemGroup> 93 99 <ItemGroup> -
client/Client/main.cpp
rb978503 rfbcfc35 33 33 #include "../../common/WorldMap.h" 34 34 #include "../../common/Player.h" 35 #include "../../common/Projectile.h" 35 36 36 37 #include "Window.h" … … 47 48 void initWinSock(); 48 49 void shutdownWinSock(); 49 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player>& mapPlayers, unsigned int& curPlayerId, int &scoreBlue, int &scoreRed);50 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player>& mapPlayers, map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId, int &scoreBlue, int &scoreRed); 50 51 void drawMap(WorldMap* gameMap); 51 52 void drawPlayers(map<unsigned int, Player>& mapPlayers, ALLEGRO_FONT* font, unsigned int curPlayerId); … … 99 100 doexit = false; 100 101 map<unsigned int, Player> mapPlayers; 102 map<unsigned int, Projectile> mapProjectiles; 101 103 unsigned int curPlayerId = -1; 102 104 int scoreBlue, scoreRed; … … 299 301 map<unsigned int, Player>::iterator it; 300 302 303 cout << "Detected a right-click" << endl; 304 301 305 Player* curPlayer; 302 306 for(it = mapPlayers.begin(); it != mapPlayers.end(); it++) … … 309 313 for(it = mapPlayers.begin(); it != mapPlayers.end(); it++) 310 314 { 315 // need to check if the right-click was actually on this player 311 316 target = &it->second; 312 317 if (target->id != curPlayerId && target->team != curPlayer->team) { … … 323 328 324 329 if (receiveMessage(&msgFrom, sock, &from) >= 0) 325 processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, curPlayerId, scoreBlue, scoreRed);330 processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, mapProjectiles, curPlayerId, scoreBlue, scoreRed); 326 331 327 332 if (redraw) … … 447 452 } 448 453 449 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player>& mapPlayers, unsigned int& curPlayerId, int &scoreBlue, int &scoreRed)454 void processMessage(NETWORK_MSG &msg, int &state, chat &chatConsole, WorldMap *gameMap, map<unsigned int, Player>& mapPlayers, map<unsigned int, Projectile>& mapProjectiles, unsigned int& curPlayerId, int &scoreBlue, int &scoreRed) 450 455 { 451 456 string response = string(msg.buffer); … … 623 628 case MSG_TYPE_PROJECTILE: 624 629 { 630 cout << "Received a prjectile message" << endl; 631 632 int id, x, y, targetId; 633 634 memcpy(&id, msg.buffer, 4); 635 memcpy(&x, msg.buffer+4, 4); 636 memcpy(&y, msg.buffer+8, 4); 637 memcpy(&targetId, msg.buffer+12, 4); 638 639 cout << "id" << id << endl; 640 cout << "x" << x << endl; 641 cout << "y" << y << endl; 642 cout << "Target" << targetId << endl; 643 625 644 break; 626 645 }
Note:
See TracChangeset
for help on using the changeset viewer.