Tweak rollback stuff
parent
0de3fb786d
commit
7ef0a13250
|
@ -1828,8 +1828,8 @@ 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
|
// Max. 5 seconds ago, shortcut at 98 points
|
||||||
suspect = m_gamedef->rollback()->getSuspect(p0, 5);
|
suspect = m_gamedef->rollback()->getSuspect(p0, 5, 95);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!suspect.empty()){
|
if(!suspect.empty()){
|
||||||
|
|
|
@ -43,8 +43,8 @@ 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 = -1 point)
|
||||||
f += 1.0 * intToFloat(suspect_p, 1).getDistanceFrom(intToFloat(action_p, 1));
|
f -= 1.0 * intToFloat(suspect_p, 1).getDistanceFrom(intToFloat(action_p, 1));
|
||||||
// Time (1 second = -1 point)
|
// Time (1 second = -1 point)
|
||||||
f -= 1.0 * (action_t - suspect_t);
|
f -= 1.0 * (action_t - suspect_t);
|
||||||
// If is a guess, halve the points
|
// If is a guess, halve the points
|
||||||
|
@ -76,7 +76,8 @@ public:
|
||||||
v3s16 p;
|
v3s16 p;
|
||||||
if(!action.getPosition(&p))
|
if(!action.getPosition(&p))
|
||||||
return;
|
return;
|
||||||
action.actor = getSuspect(p, 30); // 30s timeframe
|
// 60s default timeframe, 95 points shortcut
|
||||||
|
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;
|
||||||
|
@ -102,7 +103,7 @@ 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)
|
std::string getSuspect(v3s16 p, int max_time, float nearness_shortcut)
|
||||||
{
|
{
|
||||||
if(m_current_actor != "")
|
if(m_current_actor != "")
|
||||||
return m_current_actor;
|
return m_current_actor;
|
||||||
|
@ -116,6 +117,8 @@ public:
|
||||||
{
|
{
|
||||||
if(i->unix_time < first_time)
|
if(i->unix_time < first_time)
|
||||||
break;
|
break;
|
||||||
|
if(i->actor == "")
|
||||||
|
continue;
|
||||||
// Find position of suspect or continue
|
// Find position of suspect or continue
|
||||||
v3s16 suspect_p;
|
v3s16 suspect_p;
|
||||||
if(!i->getPosition(&suspect_p))
|
if(!i->getPosition(&suspect_p))
|
||||||
|
@ -125,6 +128,8 @@ public:
|
||||||
if(f > likely_suspect_nearness){
|
if(f > likely_suspect_nearness){
|
||||||
likely_suspect_nearness = f;
|
likely_suspect_nearness = f;
|
||||||
likely_suspect = *i;
|
likely_suspect = *i;
|
||||||
|
if(likely_suspect_nearness >= nearness_shortcut)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// No likely suspect was found
|
// No likely suspect was found
|
||||||
|
|
|
@ -35,7 +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;
|
||||||
virtual std::string getSuspect(v3s16 p, int max_time) = 0;
|
// nearness_shortcut: 100 = same second, same node; 90 = 10s or 10 nodes
|
||||||
|
virtual std::string getSuspect(v3s16 p, int max_time, float nearness_shortcut) = 0;
|
||||||
|
|
||||||
virtual ~IRollbackManager(){}
|
virtual ~IRollbackManager(){}
|
||||||
virtual void flush() = 0;
|
virtual void flush() = 0;
|
||||||
|
|
|
@ -124,7 +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;
|
||||||
virtual std::string getSuspect(v3s16 p, int max_time) = 0;
|
// nearness_shortcut: 100 = same second, same node; 90 = 10s or 10 nodes
|
||||||
|
virtual std::string getSuspect(v3s16 p, int max_time, float nearness_shortcut=98) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RollbackScopeActor
|
class RollbackScopeActor
|
||||||
|
|
Loading…
Reference in New Issue