]> git.lizzy.rs Git - minetest.git/blobdiff - src/rollback.cpp
Use single box for halo mesh
[minetest.git] / src / rollback.cpp
index 7267a50f6e4234ba425948e7817d8bedc560f41b..2367c3a210427a96674346d0425366e57d4a2d06 100644 (file)
@@ -107,6 +107,8 @@ RollbackManager::RollbackManager(const std::string & world_path,
 
 RollbackManager::~RollbackManager()
 {
+       flush();
+
        SQLOK(sqlite3_finalize(stmt_insert));
        SQLOK(sqlite3_finalize(stmt_replace));
        SQLOK(sqlite3_finalize(stmt_select));
@@ -240,8 +242,7 @@ bool RollbackManager::createTables()
                "       FOREIGN KEY (`oldNode`)   REFERENCES `node`(`id`),\n"
                "       FOREIGN KEY (`newNode`)   REFERENCES `node`(`id`)\n"
                ");\n"
-               "CREATE INDEX IF NOT EXISTS `actionActor` ON `action`(`actor`);\n"
-               "CREATE INDEX IF NOT EXISTS `actionTimestamp` ON `action`(`timestamp`);\n",
+               "CREATE INDEX IF NOT EXISTS `actionIndex` ON `action`(`x`,`y`,`z`,`timestamp`,`actor`);\n",
                NULL, NULL, NULL));
        verbosestream << "SQL Rollback: SQLite3 database structure was created" << std::endl;
 
@@ -858,7 +859,7 @@ std::string RollbackManager::getSuspect(v3s16 p, float nearness_shortcut,
        float likely_suspect_nearness = 0;
        for (std::list<RollbackAction>::const_reverse_iterator
             i = action_latest_buffer.rbegin();
-            i != action_latest_buffer.rend(); i++) {
+            i != action_latest_buffer.rend(); ++i) {
                if (i->unix_time < first_time) {
                        break;
                }
@@ -897,7 +898,7 @@ void RollbackManager::flush()
 
        for (iter  = action_todisk_buffer.begin();
                        iter != action_todisk_buffer.end();
-                       iter++) {
+                       ++iter) {
                if (iter->actor == "") {
                        continue;
                }
@@ -930,6 +931,7 @@ std::list<RollbackAction> RollbackManager::getEntriesSince(time_t first_time)
 std::list<RollbackAction> RollbackManager::getNodeActors(v3s16 pos, int range,
                time_t seconds, int limit)
 {
+       flush();
        time_t cur_time = time(0);
        time_t first_time = cur_time - seconds;