]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/rollback_interface.h
Cleanup and (mostly) document util/string.h and (very) minor refactoring
[dragonfireclient.git] / src / rollback_interface.h
index 0f0a11885afa64f48f6b1ba587753ada748c3c87..f16f82b4028f910cf76e82eaf0d6ed80ccf961b8 100644 (file)
@@ -1,6 +1,6 @@
 /*
-Minetest-c55
-Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
+Minetest
+Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
@@ -63,8 +63,9 @@ struct RollbackAction
                TYPE_MODIFY_INVENTORY_STACK,
        } type;
 
-       int unix_time;
+       time_t unix_time;
        std::string actor;
+       bool actor_is_guess;
 
        v3s16 p;
        RollbackNode n_old;
@@ -77,7 +78,9 @@ struct RollbackAction
        std::string inventory_stack;
 
        RollbackAction():
-               type(TYPE_NOTHING)
+               type(TYPE_NOTHING),
+               unix_time(0),
+               actor_is_guess(false)
        {}
 
        void setSetNode(v3s16 p_, const RollbackNode &n_old_,
@@ -107,6 +110,8 @@ struct RollbackAction
        
        // Eg. flowing water level changes are not important
        bool isImportant(IGameDef *gamedef) const;
+       
+       bool getPosition(v3s16 *dst) const;
 
        bool applyRevert(Map *map, InventoryManager *imgr, IGameDef *gamedef) const;
 };
@@ -117,29 +122,35 @@ class IRollbackReportSink
        virtual ~IRollbackReportSink(){}
        virtual void reportAction(const RollbackAction &action) = 0;
        virtual std::string getActor() = 0;
-       virtual void setActor(const std::string &actor) = 0;
+       virtual bool isActorGuess() = 0;
+       virtual void setActor(const std::string &actor, bool is_guess) = 0;
+       virtual std::string getSuspect(v3s16 p, float nearness_shortcut,
+                       float min_nearness) = 0;
 };
 
 class RollbackScopeActor
 {
 public:
-       RollbackScopeActor(IRollbackReportSink *sink, const std::string &actor):
+       RollbackScopeActor(IRollbackReportSink *sink, const std::string &actor,
+                       bool is_guess=false):
                m_sink(sink)
        {
                if(m_sink){
                        m_actor_was = m_sink->getActor();
-                       m_sink->setActor(actor);
+                       m_actor_was_guess = m_sink->isActorGuess();
+                       m_sink->setActor(actor, is_guess);
                }
        }
        ~RollbackScopeActor()
        {
                if(m_sink){
-                       m_sink->setActor(m_actor_was);
+                       m_sink->setActor(m_actor_was, m_actor_was_guess);
                }
        }
 private:
        IRollbackReportSink *m_sink;
        std::string m_actor_was;
+       bool m_actor_was_guess;
 };
 
 #endif