Files
oboe/src/tools/undo.cpp
Celtic Minstrel 908652d168 Housekeeping
- Rename cItemRec -> cItem and cItemRec::type -> cItem::weap_type
- Clear out a lot of commented code
- Remove the flag_x members in the scenario that used to store the scenario's password hash (or something like that)
2015-01-12 01:01:24 -05:00

41 lines
662 B
C++

/*
* undo.cpp
* BoE
*
* Created by Celtic Minstrel on 29/05/09.
*
*/
#include "undo.hpp"
cUndoList::cUndoList(){
lastSave = cur = theList.begin();
}
size_t cUndoList::maxUndoSize = 0;
// TODO: These functions should have error checking to ensure they do not access an out of bounds action
void cUndoList::undo(){
(*cur)->undo();
cur--;
}
void cUndoList::redo(){
cur++;
(*cur)->redo();
}
void cUndoList::save(){
lastSave = cur;
}
void cUndoList::revert(){
while(cur != lastSave) undo();
}
void cUndoList::add(cAction* what){
theList.push_back(what);
num_actions++;
while(num_actions > maxUndoSize) theList.pop_front(), num_actions--;
}