aboutsummaryrefslogtreecommitdiff
path: root/src/rollback.cpp
Commit message (Expand)AuthorAge
* Improve rollback database indexingcheapie2015-10-24
* Flush rollback log more oftenest312015-10-24
* Change i++ to ++iDavid Jones2015-08-25
* Clean up rollbackShadowNinja2014-11-19
* Fix statement not set NULL on deletionsapier2014-06-25
* Fix sqlite3 map shutdown fails due to missing to finalize list statementsapier2014-06-22
* Don't use variable length arraysShadowNinja2013-11-28
* Rollback fixes and get_node_actionsShadowNinja2013-11-27
* SQLite rollbackMario Barrera2013-11-27
* Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenuKahrl2013-08-14
* Update Copyright YearsSfan52013-02-24
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
* Tweak rollback and liquidsPerttu Ahola2012-07-27
* Tweak rollback stuffPerttu Ahola2012-07-27
* Increase automatic suspect guess timeframePerttu Ahola2012-07-27
* Make the rollback system VERY FUCKING GOD DAMN POWERFULPerttu Ahola2012-07-27
* Experimental-ish rollback functionalityPerttu Ahola2012-07-27
ppc">#include <map> #include "debug.h" struct StaticObject { u8 type; v3f pos; std::string data; StaticObject(): type(0), pos(0,0,0) { } StaticObject(u8 type_, v3f pos_, const std::string &data_): type(type_), pos(pos_), data(data_) { } void serialize(std::ostream &os); void deSerialize(std::istream &is, u8 version); }; class StaticObjectList { public: /* Inserts an object to the container. Id must be unique (active) or 0 (stored). */ void insert(u16 id, StaticObject obj) { if(id == 0) { m_stored.push_back(obj); } else { if(m_active.find(id) != m_active.end()) { dstream<<"ERROR: StaticObjectList::insert(): " <<"id already exists"<<std::endl; FATAL_ERROR("StaticObjectList::insert()"); } m_active[id] = obj; } } void remove(u16 id) { assert(id != 0); // Pre-condition if(m_active.find(id) == m_active.end()) { warningstream<<"StaticObjectList::remove(): id="<<id <<" not found"<<std::endl; return; } m_active.erase(id); } void serialize(std::ostream &os); void deSerialize(std::istream &is); /* NOTE: When an object is transformed to active, it is removed from m_stored and inserted to m_active. The caller directly manipulates these containers. */ std::vector<StaticObject> m_stored; std::map<u16, StaticObject> m_active; private: }; #endif