git repos / blockattack-game

commit ca486238

sago007 · 2015-08-23 15:12
ca486238cd1d41ceb2e90a1ad2c90100cb9622e6 patch · browse files
parent 6787b808bf64d364c0b63323105f575b59460c64

Removed replay functionality

Changed files

M source/code/BlockGame.cpp before
M source/code/BlockGame.hpp before
M source/code/Makefile before
M source/code/main.cpp before
D source/code/replay.cpp before
D source/code/replay.h before
diff --git a/source/code/BlockGame.cpp b/source/code/BlockGame.cpp index 8c05f60..b3c570d 100644 --- a/source/code/BlockGame.cpp +++ b/source/code/BlockGame.cpp
@@ -78,7 +78,6 @@ BlockGame::BlockGame()
score = 0;
bGameOver = false;
bDraw = false;
- bReplaying=false; //No replay by default
timetrial = false;
stageClear = false;
vsMode = false;
@@ -111,7 +110,6 @@ BlockGame::BlockGame()
chainUsed[i]=false;
chainSize[i] = 0;
}
- theReplay = Replay();
lastCounter = -1; //To prevent the final chunk to be played when stating the program
} //Constructor
@@ -125,7 +123,6 @@ void BlockGame::setGameSpeed(Uint8 globalSpeedLevel)
{
format f("%1%");
f % globalSpeedLevel;
- ActionPerformed(ACTION_GAMESPEED,f.str());
switch (globalSpeedLevel)
{
case 0:
@@ -153,7 +150,6 @@ void BlockGame::setHandicap(Uint8 globalHandicap)
{
format f("%1%");
f % globalHandicap;
- ActionPerformed(ACTION_HANDICAP, f.str());
handicap=1000*((Uint32)globalHandicap);
}
@@ -257,9 +253,6 @@ int BlockGame::GetCursorY() const
void BlockGame::MoveCursorTo(int x, int y)
{
- format f("%1% %2%");
- f % x % y;
- ActionPerformed(ACTION_MOVECURSORTO, f.str());
cursorx = x;
cursory = y;
}
@@ -274,7 +267,6 @@ void BlockGame::NewGame( unsigned int ticks)
{
this->ticks = ticks;
stageButtonStatus = SBdontShow;
- bReplaying = false;
nrFellDown = 0;
nrPushedPixel = 0;
nrStops = 0;
@@ -301,7 +293,6 @@ void BlockGame::NewGame( unsigned int ticks)
pushedPixelAt = gameStartedAt;
nextGarbageNumber = 10;
handicap=0;
- actionIndex = 0;
for (int i=0; i<7; i++)
for (int j=0; j<30; j++)
{
@@ -313,14 +304,11 @@ void BlockGame::NewGame( unsigned int ticks)
chainSize[i] = 0;
}
lastAImove = ticks+3000;
- theReplay = Replay();
- ActionPerformed(ACTION_NEW,"");
} //NewGame
void BlockGame::NewTimeTrialGame( unsigned int ticks)
{
NewGame(ticks);
- ActionPerformed(ACTION_NEWTT,"");
timetrial = true;
putStartBlocks();
}
@@ -409,7 +397,6 @@ void BlockGame::nextLevel(unsigned int ticks)
void BlockGame::NewVsGame(BlockGame *target, unsigned int ticks)
{
NewGame(ticks);
- ActionPerformed(ACTION_NEWVS,"");
vsMode = true;
putStartBlocks();
garbageTarget = target;
@@ -437,44 +424,29 @@ void BlockGame::Demonstration(bool toggle)
speed=0;
baseSpeed = 0;
}
-//We want to play the replay (must have been loaded beforehand)
-void BlockGame::playReplay( unsigned int ticks, const Replay& r)
-{
- if(r.getActions().size()==0)
- {
- cerr << "Empty replay data" << endl;
- return;
- }
- NewGame(ticks);
- gameStartedAt = ticks+3000;
- replayIndex = 0;
- bReplaying = true; //We are playing, no calculations
- theReplay = r;
-}
//Prints "winner" and ends game
void BlockGame::setPlayerWon()
{
- ActionPerformed(ACTION_WIN,"");
if (!bGameOver || !hasWonTheGame)
{
gameEndedAfter = ticks-gameStartedAt; //We game ends now!
- if(!AI_Enabled && !bReplaying)
+ if(!AI_Enabled)
{
TimeHandler::addTime("playTime",TimeHandler::ms2ct(gameEndedAfter));
}
bGameOver = true;
PlayerWonEvent();
- if(!AI_Enabled && !bReplaying)
+ if(!AI_Enabled)
{
Stats::getInstance()->addOne("totalWins");
- if(garbageTarget->AI_Enabled && !(garbageTarget->bReplaying))
+ if(garbageTarget->AI_Enabled)
{
//We have defeated an AI
Stats::getInstance()->addOne("defeatedAI"+itoa(garbageTarget->getAIlevel()));
}
}
- if(AI_Enabled && !(garbageTarget->AI_Enabled) && garbageTarget->bReplaying==false)
+ if(AI_Enabled && !(garbageTarget->AI_Enabled))
{
//The AI have defeated a human player
Stats::getInstance()->addOne("defeatedByAI"+itoa(getAIlevel()));
@@ -486,24 +458,22 @@ void BlockGame::setPlayerWon()
//Prints "draw" and ends the game
void BlockGame::setDraw()
{
- ActionPerformed(ACTION_DRAW, "");
bGameOver = true;
- if(!AI_Enabled && !bReplaying)
+ if(!AI_Enabled)
{
TimeHandler::addTime("playTime",TimeHandler::ms2ct(gameEndedAfter));
}
hasWonTheGame = false;
bDraw = true;
DrawEvent();
- if (!AI_Enabled && !bReplaying) {
+ if (!AI_Enabled) {
Stats::getInstance()->addOne("totalDraws");
}
}
-
//Test if LineNr is an empty line, returns false otherwise.
-bool BlockGame::LineEmpty(int lineNr)
+bool BlockGame::LineEmpty(int lineNr) const
{
bool empty = true;
for (int i = 0; i <7; i++)
@@ -513,7 +483,7 @@ bool BlockGame::LineEmpty(int lineNr)
}
//Test if the entire board is empty (used for Puzzles)
-bool BlockGame::BoardEmpty()
+bool BlockGame::BoardEmpty() const
{
bool empty = true;
for (int i=0; i<6; i++)
@@ -524,7 +494,7 @@ bool BlockGame::BoardEmpty()
}
//Anything that the user can't move? In that case Game Over cannot occur
-bool BlockGame::hasStaticContent()
+bool BlockGame::hasStaticContent() const
{
for (int i=0; i<6; i++)
for (int j=1; j<13; j++)
@@ -545,9 +515,6 @@ void BlockGame::putStartBlocks()
void BlockGame::putStartBlocks(Uint32 n)
{
- format f("%1%");
- f % n;
- ActionPerformed(ACTION_STARTBLOCKS ,f.str());
#if DEBUG
cout << n << ":" << f.str() << endl;
#endif
@@ -713,9 +680,6 @@ void BlockGame::ReduceStuff()
//Creates garbage using a given wide and height
bool BlockGame::CreateGarbage(int wide, int height)
{
- format f("%1% %2%");
- f % wide % height;
- ActionPerformed(ACTION_CREATEGARBAGE,f.str());
{
if (wide>6) wide = 6;
if (height>12) height = 12;
@@ -753,31 +717,27 @@ bool BlockGame::CreateGarbage(int wide, int height)
//Creates garbage using a given wide and height
bool BlockGame::CreateGreyGarbage()
{
- ActionPerformed(ACTION_CREATEGRAYGARBAGE,"");
+ int startPosition = 12;
+ while ((!(LineEmpty(startPosition))) || (startPosition == 29))
+ startPosition++;
+ if (startPosition == 29) return false; //failed to place blocks
+ if (29-startPosition<1) return false; //not enough space
+ int start, end;
{
- int startPosition = 12;
- while ((!(LineEmpty(startPosition))) || (startPosition == 29))
- startPosition++;
- if (startPosition == 29) return false; //failed to place blocks
- if (29-startPosition<1) return false; //not enough space
- int start, end;
- {
- start=0;
- end=6;
- }
- for (int i = startPosition; i <startPosition+1; i++)
+ start=0;
+ end=6;
+ }
+ for (int i = startPosition; i <startPosition+1; i++)
+ {
+ for (int j = start; j < end; j++)
{
- for (int j = start; j < end; j++)
- {
- board[j][i] = 2*1000000+nextGarbageNumber;
- }
+ board[j][i] = 2*1000000+nextGarbageNumber;
}
- nextGarbageNumber++;
- if (nextGarbageNumber>999999)
- nextGarbageNumber = 10;
- return true;
}
- return false;
+ nextGarbageNumber++;
+ if (nextGarbageNumber>999999)
+ nextGarbageNumber = 10;
+ return true;
}
@@ -1167,23 +1127,12 @@ void BlockGame::ClearBlocks()
//prints "Game Over" and ends game
void BlockGame::SetGameOver()
{
- ActionPerformed(ACTION_GAMEOVER ,"");
- if (!bGameOver)
- {
+ if (!bGameOver) {
gameEndedAfter = ticks-gameStartedAt; //We game ends now!
- if(!AI_Enabled && !bReplaying)
- {
+ if (!AI_Enabled) {
TimeHandler::addTime("playTime",TimeHandler::ms2ct(gameEndedAfter));
}
}
- if(bReplaying)
- {
- bReplaying = false;
- }
- else
- {
- theReplay.setName(name);
- }
bGameOver = true;
if(stageClear)
stageButtonStatus = SBstageClear;
@@ -1266,9 +1215,6 @@ void BlockGame::FallDown()
//Moves the cursor, receaves N,S,E or W as a char an moves as desired
void BlockGame::MoveCursor(char way)
{
- format f("%1%");
- f % way;
- ActionPerformed(ACTION_MOVECURSOR,f.str());
if (!bGameOver) //If game over nothing happends
{
if ((way == 'N') && ((cursory<10)||(TowerHeight>12) ||(((pixels==bsize)||(pixels==0)) && (cursory<11))))
@@ -1285,7 +1231,6 @@ void BlockGame::MoveCursor(char way)
//switches the two blocks at the cursor position, unless game over
void BlockGame::SwitchAtCursor()
{
- ActionPerformed(ACTION_SWITCH,"");
if ((board[cursorx][cursory+1]<7) && (board[cursorx+1][cursory+1]<7) && (!bGameOver) && ((!puzzleMode)||(MovesLeft>0)) && (gameStartedAt<ticks))
{
int temp = board[cursorx][cursory+1];
@@ -1297,7 +1242,6 @@ void BlockGame::SwitchAtCursor()
void BlockGame::PushLine()
{
- ActionPerformed(ACTION_PUSH,"");
PushLineInternal();
}
@@ -1328,10 +1272,8 @@ void BlockGame::PushLineInternal()
board[j][0] = rand2() % 6;
}
score+=1;
- if(!bReplaying)
- MoveCursor('N'); //Workaround for this being done registred too
- if (vsMode)
- {
+ MoveCursor('N'); //Workaround for this being done registred too
+ if (vsMode) {
if (rand2()%6==1)
board[rand2()%6][0]=6;
}
@@ -1342,7 +1284,7 @@ void BlockGame::PushLineInternal()
AI_LineOffset++;
nrPushedPixel=(int)((double)(pushedPixelAt-gameStartedAt)/(1000.0*speed));
- if(!AI_Enabled && !bReplaying)
+ if(!AI_Enabled)
{
Stats::getInstance()->addOne("linesPushed");
}
@@ -1854,12 +1796,10 @@ void BlockGame::Update()
{
Uint32 tempUInt32;
Uint32 nowTime = ticks; //We remember the time, so it doesn't change during this call
- ActionPerformed(ACTION_UPDATE, "");
{
FindTowerHeight();
- if ((linesCleared-TowerHeight>stageClearLimit) && (stageClear) && (!bGameOver))
- {
+ if ((linesCleared-TowerHeight>stageClearLimit) && (stageClear) && (!bGameOver)) {
stageCleared[Level] = true;
if(stageScores[Level]<score)
{
@@ -1983,14 +1923,6 @@ void BlockGame::Update()
inFile >> bestResult;
inFile.close();
}
- if(score>bestResult)
- {
- string bestFile = getPathToSaveFiles() + "/bestTT";
- theReplay.saveReplay(bestFile);
- ofstream outFile(checkFilename.c_str(),ios::trunc);
- if(outFile)
- outFile << score;
- }
}
}
}
@@ -2015,45 +1947,7 @@ void BlockGame::UpdateInternal(unsigned int newtick)
void BlockGame::Update(unsigned int newtick)
{
- if(bReplaying)
- {
- /*cout << "Testing " << replayIndex << "<" << theReplay.getActions().size()
- << " && " << theReplay.getActions().at(replayIndex).time << "<=" <<
- newtick-gameStartedAt << endl;*/
- while(replayIndex >= 0 && replayIndex < theReplay.getActions().size() &&
- theReplay.getActions().at(replayIndex).time <= newtick-gameStartedAt)
- {
- Action a = theReplay.getActions().at(replayIndex);
- PerformAction(a.time+gameStartedAt,a.action,a.param);
- ++replayIndex;
- }
-
- }
- else
- {
- UpdateInternal(newtick);
- }
-}
-
-void BlockGame::ActionPerformed(int action, string param)
-{
- if(bGameOver || bReplaying)
- return;
- theReplay.addAction(ticks-gameStartedAt, action, param);
-}
-
-int BlockGame::GotAction(unsigned int &tick,int &action,string &param)
-{
- if(actionIndex < theReplay.getActions().size())
- {
- Action a = theReplay.getActions().at(actionIndex);
- tick = a.time;
- action = a.action;
- param = a.param;
- ++actionIndex;
- return 1;
- }
- return 0;
+ UpdateInternal(newtick);
}
void BlockGame::PerformAction(unsigned int tick, int action, string param)
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp index 1222907..1f1da8e 100644 --- a/source/code/BlockGame.hpp +++ b/source/code/BlockGame.hpp
@@ -26,7 +26,6 @@ http://blockattack.sf.net
#include "stats.h"
#include "common.h"
-#include "replay.h"
#define NUMBEROFCHAINS 100
#define BLOCKWAIT 100000
@@ -81,12 +80,9 @@ protected:
int lastCounter;
string strHolder;
bool bDraw;
- bool bReplaying; //true if we are watching a replay
unsigned int ticks;
unsigned int gameStartedAt;
unsigned int gameEndedAfter; //How long did the game last?
- unsigned int replayIndex; //Used during replay to remeber how many replay actions we have performed.
- unsigned int actionIndex; //Used during network to remeber how many actions we have sent.
int linesCleared;
int TowerHeight;
BlockGame *garbageTarget;
@@ -121,7 +117,6 @@ protected:
public:
std::string name;
- Replay theReplay; //Stores the replay
public:
//Constructor
@@ -181,8 +176,6 @@ public:
void NewVsGame(BlockGame *target,unsigned int ticks);
//Starts new Vs Game (two Player)
void NewVsGame(BlockGame *target, bool AI,unsigned int ticks);
- //We want to play the replay (must have been loaded beforehand)
- void playReplay(unsigned int ticks, const Replay& r);
void putStartBlocks(Uint32 n);
//Creates garbage using a given wide and height
bool CreateGarbage(int wide, int height);
@@ -217,11 +210,11 @@ private:
//Go in Demonstration mode, no movement
void Demonstration(bool toggle);
//Test if LineNr is an empty line, returns false otherwise.
- bool LineEmpty(int lineNr);
+ bool LineEmpty(int lineNr) const;
//Test if the entire board is empty (used for Puzzles)
- bool BoardEmpty();
+ bool BoardEmpty() const;
//Anything that the user can't move? In that case Game Over cannot occur
- bool hasStaticContent();
+ bool hasStaticContent() const;
void putStartBlocks();
//decreases hang for all hanging blocks and wait for waiting blocks
void ReduceStuff();
@@ -278,7 +271,6 @@ private:
///////////////////////////// AI ends here! //////////////////////////////
//////////////////////////////////////////////////////////////////////////
- void ActionPerformed(int action, string param);
void PushLineInternal();
//Updates evrything, if not called nothing happends
void Update();
diff --git a/source/code/Makefile b/source/code/Makefile index 030061c..73d374c 100644 --- a/source/code/Makefile +++ b/source/code/Makefile
@@ -24,7 +24,7 @@ DEBUG=0
endif
ifndef NETWORK
-NETWORK=1
+NETWORK=0
endif
#Compile with debug information or optimized.
@@ -43,7 +43,7 @@ endif
BASE_LIBS += -lphysfs
-OFILES=main.o highscore.o ReadKeyboard.o joypad.o listFiles.o replay.o common.o stats.o CppSdlException.o CppSdlImageHolder.o Libs/NFont.o MenuSystem.o menudef.o puzzlehandler.o
+OFILES=main.o highscore.o ReadKeyboard.o joypad.o listFiles.o common.o stats.o CppSdlException.o CppSdlImageHolder.o Libs/NFont.o MenuSystem.o menudef.o puzzlehandler.o
ifeq ($(CROSS),i686-pc-mingw32-)
OFILES += winicon.res
diff --git a/source/code/main.cpp b/source/code/main.cpp index c4a6328..427c79d 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -85,7 +85,6 @@ http://blockattack.sf.net
#include "ReadKeyboard.h" //Reads text from keyboard
#include "joypad.h" //Used for joypads
#include "listFiles.h" //Used to show files on screen
-#include "replay.h" //Used for replays
#include "stats.h" //Saves general stats
#if LEVELEDITOR
#include "editor/editorMain.hpp" //The level editor
@@ -3020,15 +3019,6 @@ static void StartTwoPlayerVs()
player2->name = player2name;
}
-static void StartReplay(string filename)
-{
- Replay r1,r2;
- r1.loadReplay(filename);
- player1->playReplay(SDL_GetTicks(),r1);
- r2.loadReplay2(filename);
- player2->playReplay(SDL_GetTicks(),r2);
-}
-
//The main function, quite big... too big
int main(int argc, char *argv[])
{
@@ -3743,34 +3733,16 @@ int runGame(int gametype, int level)
}
if ( event.key.keysym.sym == SDLK_F10 )
{
- StartReplay("/home/poul/.gamesaves/blockattack/quicksave");
+ //StartReplay("/home/poul/.gamesaves/blockattack/quicksave");
}
if ( event.key.keysym.sym == SDLK_F9 )
{
writeScreenShot();
}
- if ( event.key.keysym.sym == SDLK_F5 )
- {
- if(theGame.isGameOver() && theGame2.isGameOver())
- {
- string filename = "/home/poul/.gamesaves/blockattack/quicksave";
- if(!twoPlayers)
- theGame.theReplay.saveReplay(filename);
- else
- theGame.theReplay.saveReplay(filename,theGame2.theReplay);
- }
+ if ( event.key.keysym.sym == SDLK_F5 ) {
}
if ( event.key.keysym.sym == SDLK_F11 )
{
- /*This is the test place, place function to test here*/
-
- StartReplay("/home/poul/.gamesaves/blockattack/bestTT");
-
- //theGame.CreateGreyGarbage();
- //char mitNavn[30];
- //SelectThemeDialogbox(300,400,mitNavn);
- //MainMenu();
- //OpenScoresDisplay();
} //F11
}
if ( event.key.keysym.sym == SDLK_F12 )
diff --git a/source/code/replay.cpp b/source/code/replay.cpp deleted file mode 100644 index c7e3d8a..0000000 --- a/source/code/replay.cpp +++ /dev/null
@@ -1,241 +0,0 @@
-/*
-===========================================================================
-blockattack - Block Attack - Rise of the Blocks
-Copyright (C) 2005-2012 Poul Sander
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see http://www.gnu.org/licenses/
-
-Source information and contacts persons can be found at
-http://blockattack.sf.net
-===========================================================================
-*/
-
-/*
-Handles replay
-*/
-
-#include <string.h>
-
-#include "replay.h"
-
-extern int verboseLevel;
-
-Replay::Replay()
-{
- isLoaded = false;
- actions.clear();
-}
-
-Replay::Replay(const Replay& r)
-{
- isLoaded = r.isLoaded;
- name = r.name;
- actions = r.actions;
-}
-
-
-
-
-
-
-
-bool Replay::saveReplay(const string &filename)
-{
- //Saving as fileversion 4
- if(verboseLevel)
- cout << "Saving as version 4 save file" << endl;
- ofstream saveFile;
- saveFile.open(filename.c_str(),ios::binary|ios::trunc);
- if (saveFile)
- {
- saveFile << "0 16 PLAYER 1\n";
- saveFile << "0 16 NAME " << name << "\n";
- for(unsigned int i = 0; i < actions.size(); ++i)
- {
- saveFile << actions.at(i).time << " " << actions.at(i).action << " " << actions.at(i).param << "\n";
- }
- saveFile.close();
- return true;
- }
- else
- {
- return false;
- }
-}
-
-bool Replay::saveReplay(const string &filename,const Replay &p2)
-{
- //Saving as fileversion 4
- if(verboseLevel)
- cout << "Saving as version 4 save file (2 players)" << endl;
- ofstream saveFile;
- saveFile.open(filename.c_str(),ios::binary|ios::trunc);
- if (saveFile)
- {
- saveFile << "0 16 PLAYER 1\n";
- saveFile << "0 16 NAME " << name << "\n";
- for(unsigned int i = 0; i < actions.size(); ++i)
- {
- saveFile << actions.at(i).time << " " << actions.at(i).action << " " << actions.at(i).param << "\n";
- }
- saveFile << "0 16 PLAYER 2\n";
- saveFile << "0 16 NAME " << name << "\n";
- for(unsigned int i = 0; i < p2.getActions().size(); ++i)
- {
- saveFile << p2.getActions().at(i).time << " " << p2.getActions().at(i).action << " " << p2.getActions().at(i).param << "\n";
- }
- saveFile.close();
- return true;
- }
- else
- {
- return false;
- }
-}
-
-bool Replay::loadReplay(const string &filename)
-{
- isLoaded = true;
- actions.clear();
- ifstream loadFile;
- loadFile.open(filename.c_str());
- if (loadFile)
- {
- while(!loadFile.eof())
- {
- Sint32 time;
- Uint32 action;
- string restOfLine;
- loadFile >> time >> action;
- if(action == 16)
- {
- string command;
- loadFile >> command;
- if(command == "NAME")
- getline(loadFile,name,'\n');
- if(command == "PLAYER")
- {
- getline(loadFile,restOfLine,'\n');
- if(restOfLine != " 1")
- break;
- }
- }
- else
- {
- getline(loadFile,restOfLine,'\n');
- Action a;
- a.time = time;
- a.action = action;
- if(restOfLine.length()>1)
- a.param = restOfLine.substr(1);
- else
- a.param = "";
- actions.push_back(a);
- }
-
- }
- loadFile.close();
- if(verboseLevel)
- cout << "Loaded 1 player, actions.size="<< actions.size() << endl;
- }
- else
- {
- cerr << "File not found or couldn't open: " << filename << endl;
- return false;
- }
- return true;
-}
-
-bool Replay::loadReplay2(const string &filename)
-{
- isLoaded = true;
- bool player2started = false; //set to true once the player two part is reached
- actions.clear();
- ifstream loadFile;
- loadFile.open(filename.c_str());
- if (loadFile)
- {
- while(!loadFile.eof())
- {
- Sint32 time;
- Uint32 action;
- string restOfLine;
- loadFile >> time >> action;
- if(action == 16)
- {
- string command;
- loadFile >> command;
- if(command == "NAME")
- getline(loadFile,name,'\n');
- if(command == "PLAYER")
- {
- getline(loadFile,restOfLine,'\n');
- if(restOfLine == " 2")
- player2started = true;
- }
- }
- else
- {
- getline(loadFile,restOfLine,'\n');
- if(!player2started)
- continue;
- Action a;
- a.time = time;
- a.action = action;
- if(restOfLine.length()>1)
- a.param = restOfLine.substr(1);
- else
- a.param = "";
- actions.push_back(a);
- }
-
- }
- loadFile.close();
- if(verboseLevel)
- cout << "Loaded 2 player, actions.size="<< actions.size() << endl;
- }
- else
- {
- cerr << "File not found or couldn't open: " << filename << endl;
- return false;
- }
- return true;
-}
-
-void Replay::setName(const string &name)
-{
- this->name = name;
-}
-
-string Replay::getName() const
-{
- return name;
-}
-
-vector<Action> Replay::getActions() const
-{
- return actions;
-}
-
-void Replay::addAction(int tick, int action, const string &param)
-{
-#if DEBUG
- cout << tick << " " << action << " " << param << endl;
-#endif
- Action a;
- a.time = tick;
- a.action = action;
- a.param = param;
- actions.push_back(a);
-}
diff --git a/source/code/replay.h b/source/code/replay.h deleted file mode 100644 index 2ec7b5f..0000000 --- a/source/code/replay.h +++ /dev/null
@@ -1,78 +0,0 @@
-/*
-===========================================================================
-blockattack - Block Attack - Rise of the Blocks
-Copyright (C) 2005-2012 Poul Sander
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see http://www.gnu.org/licenses/
-
-Source information and contacts persons can be found at
-http://blockattack.sf.net
-===========================================================================
-*/
-
-//headerfile for replay.h
-/*
-replay is used to save a replay, there is saved 10 moves per second, should be
-able to give a realistic replay
-*/
-
-#ifndef REPLAY_H
-#define REPLAY_H 1
-
-
-#include "SDL.h"
-#include <stdlib.h>
-#include <iostream>
-#include <fstream>
-#include <vector>
-
-using namespace std;
-
-struct Action
-{
- Uint32 time;
- Sint32 action;
- string param;
-};
-
-class Replay
-{
-private:
- vector<Action> actions;
-//If we are loaded from a file, then we are read only
- bool isLoaded;
-//Store player name
- string name;
-
-public:
-
-
-
- Replay(); //Constructor
- Replay(const Replay& r); //Copy constructor
-
- //New replay type 2.0.0+:
- void addAction(int tick, int action,const string &param);
-
-//Ok, I'll ignore this for some time, and just save to file, if however, we ever use a dynamic saving structure, we are fucked
- bool saveReplay(const string &filename); //Saves a replay
- bool saveReplay(const string &filename, const Replay &p2); //saves a replay, plus another replay given as a parameter
- bool loadReplay(const string &filename); //laods a replay
- bool loadReplay2(const string &filename);
- void setName(const string &name);
- string getName() const;
- vector<Action> getActions() const; //loads the second part of the replay file, if it exists, returns false otherwise
-};
-
-#endif