Those help to find out what request the random numbers and if you know that
then you know where the differences are between turn master and non turn master.
---
src/ai/ai_shoot_module.cpp | 2 ++
src/graphic/polygon.cpp | 10 ++++++++--
src/network/randomsync.cpp | 7 +++----
src/object/physical_obj.cpp | 12 ++++++++----
src/team/teams_list.cpp | 1 +
5 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/src/ai/ai_shoot_module.cpp b/src/ai/ai_shoot_module.cpp
index a8778c6..c14fe58 100644
--- a/src/ai/ai_shoot_module.cpp
+++ b/src/ai/ai_shoot_module.cpp
@@ -210,6 +210,7 @@ bool AIShootModule::SelectFiringWeapon(double
/*shoot_angle*/) const
// randomly choose a good one
// TODO: in the future add logic to discriminate between weapons
+ MSG_DEBUG("random.get", "AIShootModule::SelectFiringWeapon(...)");
uint selected = RandomSync().GetUint(0, count-1);
ActiveTeam().SetWeapon(usable_weapons.at(selected));
@@ -502,6 +503,7 @@ void AIShootModule::BeginTurn()
SetStrategy(NO_STRATEGY);
// Choose random direction for the moment
+ MSG_DEBUG("random.get", "AIShootModule::BeginTurn(...)");
ActiveCharacter().SetDirection(
RandomSync().GetBool()?DIRECTION_LEFT:DIRECTION_RIGHT );
}
diff --git a/src/graphic/polygon.cpp b/src/graphic/polygon.cpp
index 196be21..283a218 100644
--- a/src/graphic/polygon.cpp
+++ b/src/graphic/polygon.cpp
@@ -474,6 +474,7 @@ Point2d Polygon::GetRandomUpperPoint()
std::vector<Point2d>::iterator point = transformed_shape.begin();
Point2d tmp, previous;
tmp = *point;
+ MSG_DEBUG("random.get", "Polygon::GetRandomUpperPoint()");
int start = RandomSync().GetInt(0, GetNbOfPoint());
int i;
for(i = 0; i < start; i++)
@@ -526,8 +527,11 @@ void Polygon::AddRandomCurve(const Point2d& start, const
Point2d& end,
if(add_first_point)
AddPoint(start);
for (int i = 1; i < num_steps - 1; i++) {
- AddPoint(start + (step * i) +
Point2d(RandomSync().GetDouble(-x_random_offset, x_random_offset),
-
RandomSync().GetDouble(-y_random_offset, y_random_offset)));
+ MSG_DEBUG("random.get", "Polygon::AddRandomCurve(...)");
+ double x = RandomSync().GetDouble(-x_random_offset, x_random_offset);
+ MSG_DEBUG("random.get", "Polygon::AddRandomCurve(...)");
+ double y = RandomSync().GetDouble(-y_random_offset, y_random_offset);
+ AddPoint(start + (step * i) + Point2d(x,y));
}
if(add_last_point)
AddPoint(end);
@@ -562,8 +566,10 @@ Polygon * Polygon::GetBezierInterpolation(double
smooth_value, int num_steps, do
// Randomization
if(rand != 0.0) {
+ MSG_DEBUG("random.get", "Polygon::GetBezierInterpolation(...)");
trans.SetRotation(RandomSync().GetDouble(-rand, rand));
v1 = trans * v1;
+ MSG_DEBUG("random.get", "Polygon::GetBezierInterpolation(...)");
trans.SetRotation(RandomSync().GetDouble(-rand, rand));
v2 = trans * v2;
}
diff --git a/src/network/randomsync.cpp b/src/network/randomsync.cpp
index 25e0201..e86f8df 100644
--- a/src/network/randomsync.cpp
+++ b/src/network/randomsync.cpp
@@ -30,10 +30,6 @@ void RandomSyncGen::InitRandom()
{
MSG_DEBUG("random", "Initialization...");
-#ifdef DEBUG
- nb_get = 0;
-#endif
-
if (Network::GetInstance()->IsLocal()) {
int seed = time(NULL);
SetRand(seed);
@@ -64,6 +60,9 @@ uint RandomSyncGen::GetRand()
void RandomSyncGen::SetRand(uint seed)
{
+#ifdef DEBUG
+ nb_get = 0;
+#endif
RandomGenerator::SetRand(seed);
}
diff --git a/src/object/physical_obj.cpp b/src/object/physical_obj.cpp
index 5ff1f56..f1885da 100644
--- a/src/object/physical_obj.cpp
+++ b/src/object/physical_obj.cpp
@@ -770,16 +770,20 @@ bool PhysicalObj::PutRandomly(bool on_top_of_world,
double min_dst_with_characte
if (on_top_of_world) {
// Give a random position for x
- if(net_sync)
+ if(net_sync) {
+ MSG_DEBUG("random.get", "PhysicalObj::PutRandomly(...)");
position.x = RandomSync().GetLong(0, GetWorld().GetWidth() -
GetWidth());
- else
+ } else {
position.x = RandomLocal().GetLong(0, GetWorld().GetWidth() -
GetWidth());
+ }
position.y = -GetHeight()+1;
} else {
- if(net_sync)
+ if(net_sync) {
+ MSG_DEBUG("random.get", "PhysicalObj::PutRandomly(...)");
position = RandomSync().GetPoint(GetWorld().GetSize() - GetSize() + 1);
- else
+ } else {
position = RandomLocal().GetPoint(GetWorld().GetSize() - GetSize() +
1);
+ }
}
SetXY(position);
MSG_DEBUG("physic.position", "%s (try %u/%u) - Test in %d, %d",
diff --git a/src/team/teams_list.cpp b/src/team/teams_list.cpp
index 286930c..98b1457 100644
--- a/src/team/teams_list.cpp
+++ b/src/team/teams_list.cpp
@@ -206,6 +206,7 @@ void TeamsList::LoadGamingData()
void TeamsList::RandomizeFirstPlayer()
{
active_team = playing_list.begin();
+ MSG_DEBUG("random.get", "TeamList::RandomizeFirstPlayer()");
int skip = RandomSync().GetLong(0, playing_list.size() - 1);
for(int i = 0; i < skip; i++)
active_team++;
--
1.6.0.4
_______________________________________________
Wormux-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wormux-dev