Changeset 10f6fc2 in network-game


Ignore:
Timestamp:
Jul 14, 2013, 9:42:56 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
198cf2d
Parents:
9b5d30b
Message:

The client uses MessageProcessor to send/receive messages

Location:
client/Client
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • client/Client/Client.vcxproj

    r9b5d30b r10f6fc2  
    6868  <ItemGroup>
    6969    <ClCompile Include="..\..\common\Common.cpp" />
     70    <ClCompile Include="..\..\common\MessageProcessor.cpp" />
    7071    <ClCompile Include="..\..\common\Projectile.cpp" />
    7172    <ClCompile Include="..\..\common\WorldMap.cpp" />
     
    8384    <ClInclude Include="..\..\common\Common.h" />
    8485    <ClInclude Include="..\..\common\Compiler.h" />
     86    <ClInclude Include="..\..\common\MessageProcessor.h" />
    8587    <ClInclude Include="..\..\common\Projectile.h" />
    8688    <ClInclude Include="..\..\common\WorldMap.h" />
  • client/Client/Client.vcxproj.filters

    r9b5d30b r10f6fc2  
    6464      <Filter>Source Files\gui</Filter>
    6565    </ClCompile>
     66    <ClCompile Include="..\..\common\MessageProcessor.cpp">
     67      <Filter>Source Files\common</Filter>
     68    </ClCompile>
    6669  </ItemGroup>
    6770  <ItemGroup>
     
    102105      <Filter>Header Files\gui</Filter>
    103106    </ClInclude>
     107    <ClInclude Include="..\..\common\MessageProcessor.h">
     108      <Filter>Header Files\common</Filter>
     109    </ClInclude>
    104110  </ItemGroup>
    105111  <ItemGroup>
  • client/Client/main.cpp

    r9b5d30b r10f6fc2  
    2727#include <allegro5/allegro_primitives.h>
    2828
     29#include "../../common/Common.h"
    2930#include "../../common/Message.h"
    30 #include "../../common/Common.h"
     31#include "../../common/MessageProcessor.h"
    3132#include "../../common/WorldMap.h"
    3233#include "../../common/Player.h"
     
    101102string username;
    102103chat chatConsole;
     104
     105MessageProcessor msgProcessor;
    103106
    104107int main(int argc, char **argv)
     
    279282                  msgTo.type = MSG_TYPE_PICKUP_FLAG;
    280283                  memcpy(msgTo.buffer, &curPlayerId, 4);
    281                   sendMessage(&msgTo, sock, &server);
     284                  msgProcessor.sendMessage(&msgTo, sock, &server);
    282285               }
    283286               break;
     
    304307                        msgTo.type = MSG_TYPE_DROP_FLAG;
    305308                        memcpy(msgTo.buffer, &curPlayerId, 4);
    306                         sendMessage(&msgTo, sock, &server);
     309                        msgProcessor.sendMessage(&msgTo, sock, &server);
    307310                     }
    308311                  }
     
    327330                  memcpy(msgTo.buffer+8, &pos.y, 4);
    328331
    329                   sendMessage(&msgTo, sock, &server);
     332                  msgProcessor.sendMessage(&msgTo, sock, &server);
    330333               }
    331334               else
     
    354357                        memcpy(msgTo.buffer+4, &target->id, 4);
    355358
    356                         sendMessage(&msgTo, sock, &server);
     359                        msgProcessor.sendMessage(&msgTo, sock, &server);
    357360                     }
    358361                  }
     
    361364      }
    362365
    363       if (receiveMessage(&msgFrom, sock, &from) >= 0)
     366      if (msgProcessor.receiveMessage(&msgFrom, sock, &from) >= 0)
    364367         processMessage(msgFrom, state, chatConsole, gameMap, mapPlayers, mapProjectiles, curPlayerId, scoreBlue, scoreRed);
    365368
     
    367370      {
    368371         redraw = false;
     372
     373         msgProcessor.resendUnackedMessages(sock);
    369374
    370375         wndCurrent->draw(display);
     
    927932   memcpy(msgTo.buffer+username.size()+password.size()+2, &playerClass, 4);
    928933
    929    sendMessage(&msgTo, sock, &server);
     934   msgProcessor.sendMessage(&msgTo, sock, &server);
    930935}
    931936
     
    944949   strcpy(msgTo.buffer+username.size()+1, strPassword.c_str());
    945950
    946    sendMessage(&msgTo, sock, &server);
     951   msgProcessor.sendMessage(&msgTo, sock, &server);
    947952}
    948953
     
    955960   strcpy(msgTo.buffer, username.c_str());
    956961
    957    sendMessage(&msgTo, sock, &server);
     962   msgProcessor.sendMessage(&msgTo, sock, &server);
    958963}
    959964
     
    973978   strcpy(msgTo.buffer, msg.c_str());
    974979
    975    sendMessage(&msgTo, sock, &server);
     980   msgProcessor.sendMessage(&msgTo, sock, &server);
    976981}
    977982
Note: See TracChangeset for help on using the changeset viewer.