Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 31, 2007, 7:40:23 PM (16 years ago)
Author:
rgrieder
Message:
  • added dll support to the network library
  • improved header file dependency in network
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/network/GameStateManager.h

    r774 r777  
    1515#include <map>
    1616
    17 #include "zlib.h"
    18 
    19 #include "ClientInformation.h"
    20 #include "Synchronisable.h"
    21 #include "core/CoreIncludes.h"
    22 #include "core/Iterator.h"
     17#include "NetworkPrereqs.h"
    2318#include "PacketTypes.h"
    2419
    25 namespace network {
     20namespace network
     21{
    2622
    2723#define KEEP_GAMESTATES 20
    2824
    29 /**
    30  * This Class implements a manager for gamestates:
    31  * - creating snapshots of gamestates
    32  * - writing gamestates to universe
    33  * - diffing gamestates ?
    34  *
    35  * EN/DECODATION:
    36  * a: last Gamestate a client has received
    37  * b: new Gamestate
    38  * x: diffed and compressed gamestate
    39  * x=(a^b)
    40  * b=(a^x)
    41  * diff(a,diff(a,x))=x (hope this is correct)
    42  * @author Oliver Scheuss
    43 */
    44 class GameStateManager{
    45 public:
    46   GameStateManager(ClientInformation *head);
    47   ~GameStateManager();
    48   void update();
    49   GameStateCompressed popGameState(int clientID);
    50   void ackGameState(int clientID, int gamestateID);
    51   int id;
    52 private:
    53   GameState *getSnapshot(int id);
    54   GameStateCompressed encode(GameState *a, GameState *b);
    55   GameStateCompressed encode(GameState *a);
    56   GameState diff(GameState *a, GameState *b);
    57   GameStateCompressed compress_(GameState *a);
    58   bool deleteUnusedGameState(int gamestateID);
    59  
    60   std::map<int, GameState*> gameStateMap; //map gsID to gamestate*
    61   std::map<int, int> gameStateUsed; // save the number of clients, that use the specific gamestate
    62   GameState *reference;
    63   ClientInformation *head_;
    64 };
     25  /**
     26  * This Class implements a manager for gamestates:
     27  * - creating snapshots of gamestates
     28  * - writing gamestates to universe
     29  * - diffing gamestates ?
     30  *
     31  * EN/DECODATION:
     32  * a: last Gamestate a client has received
     33  * b: new Gamestate
     34  * x: diffed and compressed gamestate
     35  * x=(a^b)
     36  * b=(a^x)
     37  * diff(a,diff(a,x))=x (hope this is correct)
     38  * @author Oliver Scheuss
     39  */
     40  class GameStateManager{
     41  public:
     42    GameStateManager(ClientInformation *head);
     43    ~GameStateManager();
     44    void update();
     45    GameStateCompressed popGameState(int clientID);
     46    void ackGameState(int clientID, int gamestateID);
     47    int id;
     48  private:
     49    GameState *getSnapshot(int id);
     50    GameStateCompressed encode(GameState *a, GameState *b);
     51    GameStateCompressed encode(GameState *a);
     52    GameState diff(GameState *a, GameState *b);
     53    GameStateCompressed compress_(GameState *a);
     54    bool deleteUnusedGameState(int gamestateID);
     55
     56    std::map<int, GameState*> gameStateMap; //map gsID to gamestate*
     57    std::map<int, int> gameStateUsed; // save the number of clients, that use the specific gamestate
     58    GameState *reference;
     59    ClientInformation *head_;
     60  };
    6561
    6662}
Note: See TracChangeset for help on using the changeset viewer.