Tweak rollback and liquids

master
Perttu Ahola 2012-07-27 15:46:51 +03:00
parent 7ef0a13250
commit 3e754382af
4 changed files with 16 additions and 16 deletions

View File

@ -1636,7 +1636,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
while(m_transforming_liquid.size() != 0) while(m_transforming_liquid.size() != 0)
{ {
// This should be done here so that it is done when continue is used // This should be done here so that it is done when continue is used
if(loopcount >= initial_size || loopcount >= 1000) if(loopcount >= initial_size || loopcount >= 10000)
break; break;
loopcount++; loopcount++;
@ -1828,8 +1828,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
// Find out whether there is a suspect for this action // Find out whether there is a suspect for this action
std::string suspect; std::string suspect;
if(m_gamedef->rollback()){ if(m_gamedef->rollback()){
// Max. 5 seconds ago, shortcut at 98 points suspect = m_gamedef->rollback()->getSuspect(p0, 83, 1);
suspect = m_gamedef->rollback()->getSuspect(p0, 5, 95);
} }
if(!suspect.empty()){ if(!suspect.empty()){

View File

@ -33,6 +33,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
#define POINTS_PER_NODE (16.0)
// Get nearness factor for subject's action for this action // Get nearness factor for subject's action for this action
// Return value: 0 = impossible, >0 = factor // Return value: 0 = impossible, >0 = factor
static float getSuspectNearness(bool is_guess, v3s16 suspect_p, int suspect_t, static float getSuspectNearness(bool is_guess, v3s16 suspect_p, int suspect_t,
@ -43,10 +45,10 @@ static float getSuspectNearness(bool is_guess, v3s16 suspect_p, int suspect_t,
return 0; // 0 = cannot be return 0; // 0 = cannot be
// Start from 100 // Start from 100
int f = 100; int f = 100;
// Distance (1 node = -1 point) // Distance (1 node = -x points)
f -= 1.0 * intToFloat(suspect_p, 1).getDistanceFrom(intToFloat(action_p, 1)); f -= POINTS_PER_NODE * intToFloat(suspect_p, 1).getDistanceFrom(intToFloat(action_p, 1));
// Time (1 second = -1 point) // Time (1 second = -x points)
f -= 1.0 * (action_t - suspect_t); f -= 1 * (action_t - suspect_t);
// If is a guess, halve the points // If is a guess, halve the points
if(is_guess) if(is_guess)
f *= 0.5; f *= 0.5;
@ -76,8 +78,7 @@ public:
v3s16 p; v3s16 p;
if(!action.getPosition(&p)) if(!action.getPosition(&p))
return; return;
// 60s default timeframe, 95 points shortcut action.actor = getSuspect(p, 83, 1);
action.actor = getSuspect(p, 60, 95);
if(action.actor.empty()) if(action.actor.empty())
return; return;
action.actor_is_guess = true; action.actor_is_guess = true;
@ -103,12 +104,12 @@ public:
m_current_actor = actor; m_current_actor = actor;
m_current_actor_is_guess = is_guess; m_current_actor_is_guess = is_guess;
} }
std::string getSuspect(v3s16 p, int max_time, float nearness_shortcut) std::string getSuspect(v3s16 p, float nearness_shortcut, float min_nearness)
{ {
if(m_current_actor != "") if(m_current_actor != "")
return m_current_actor; return m_current_actor;
int cur_time = time(0); int cur_time = time(0);
int first_time = cur_time - max_time; int first_time = cur_time - (100-min_nearness);
RollbackAction likely_suspect; RollbackAction likely_suspect;
float likely_suspect_nearness = 0; float likely_suspect_nearness = 0;
for(std::list<RollbackAction>::const_reverse_iterator for(std::list<RollbackAction>::const_reverse_iterator
@ -125,7 +126,7 @@ public:
continue; continue;
float f = getSuspectNearness(i->actor_is_guess, suspect_p, float f = getSuspectNearness(i->actor_is_guess, suspect_p,
i->unix_time, p, cur_time); i->unix_time, p, cur_time);
if(f > likely_suspect_nearness){ if(f >= min_nearness && f > likely_suspect_nearness){
likely_suspect_nearness = f; likely_suspect_nearness = f;
likely_suspect = *i; likely_suspect = *i;
if(likely_suspect_nearness >= nearness_shortcut) if(likely_suspect_nearness >= nearness_shortcut)

View File

@ -35,8 +35,8 @@ public:
virtual std::string getActor() = 0; virtual std::string getActor() = 0;
virtual bool isActorGuess() = 0; virtual bool isActorGuess() = 0;
virtual void setActor(const std::string &actor, bool is_guess) = 0; virtual void setActor(const std::string &actor, bool is_guess) = 0;
// nearness_shortcut: 100 = same second, same node; 90 = 10s or 10 nodes virtual std::string getSuspect(v3s16 p, float nearness_shortcut,
virtual std::string getSuspect(v3s16 p, int max_time, float nearness_shortcut) = 0; float min_nearness) = 0;
virtual ~IRollbackManager(){} virtual ~IRollbackManager(){}
virtual void flush() = 0; virtual void flush() = 0;

View File

@ -124,8 +124,8 @@ public:
virtual std::string getActor() = 0; virtual std::string getActor() = 0;
virtual bool isActorGuess() = 0; virtual bool isActorGuess() = 0;
virtual void setActor(const std::string &actor, bool is_guess) = 0; virtual void setActor(const std::string &actor, bool is_guess) = 0;
// nearness_shortcut: 100 = same second, same node; 90 = 10s or 10 nodes virtual std::string getSuspect(v3s16 p, float nearness_shortcut,
virtual std::string getSuspect(v3s16 p, int max_time, float nearness_shortcut=98) = 0; float min_nearness) = 0;
}; };
class RollbackScopeActor class RollbackScopeActor