00001
00026 #ifndef _REPLAY_
00027 #define _REPLAY_
00028
00029 #include <iostream>
00030 #include <fstream>
00031 #include <string>
00032 #include <math.h>
00033
00034 #include <stdio.h>
00035 #include <stdarg.h>
00036 #include <ctype.h>
00037 #include <string>
00038
00039 #include <Player.h>
00040 #include <Level2D.h>
00041
00042 #include <Vector2D.h>
00043
00044 #include <disableWarnings.h>
00045
00046 typedef int ReplayMode;
00047
00048 #define REPLAY_MODE_READ 1
00049 #define REPLAY_MODE_WRITE 2
00050
00051 using namespace std;
00052
00053 namespace sonus
00054 {
00095 class Replay
00096 {
00097 public:
00098
00104 Replay( char* file );
00105
00111 Replay( int timeStepMs );
00112
00116 ~Replay();
00117
00123 static int getLastIndex()
00124 {
00125
00126 ifstream readIndex( "replay/lastReplayIndex.txt" );
00127 if ( ! readIndex.fail() )
00128 {
00129 string indexString;
00130 getline( readIndex, indexString );
00131 return atoi( indexString.c_str() );
00132 }
00133 else
00134 {
00135 return -1;
00136 }
00137 }
00138
00146 void readUpdate( Level2D* l );
00147
00155 void writeUpdate( Level2D* l );
00156
00157 ReplayMode mode;
00158
00159 int timeStepMs;
00160 bool replayReachedPortal;
00161 int lastIndex;
00162 bool replayEnded;
00163
00164 private:
00165
00166 ifstream* input;
00167 ofstream* output;
00168
00169 };
00170 }
00171
00172 #endif