summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Map.cpp25
-rw-r--r--src/Map.h6
2 files changed, 18 insertions, 13 deletions
diff --git a/src/Map.cpp b/src/Map.cpp
index 4f8924af2..a194dbd96 100644
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -9,6 +9,7 @@
#include "World.h"
#include "Chunk.h"
#include "Entities/Player.h"
+#include "FastRandom.h"
@@ -52,14 +53,14 @@ T Clamp(T a_X, T a_Min, T a_Max)
void cMapDecorator::Update(void)
{
- ASSERT(m_Map != NULL);
- unsigned int PixelWidth = m_Map->GetPixelWidth();
-
- int InsideWidth = (m_Map->GetWidth() / 2) - 1;
- int InsideHeight = (m_Map->GetHeight() / 2) - 1;
-
if (m_Player != NULL)
{
+ ASSERT(m_Map != NULL);
+ unsigned int PixelWidth = m_Map->GetPixelWidth();
+
+ int InsideWidth = (m_Map->GetWidth() / 2) - 1;
+ int InsideHeight = (m_Map->GetHeight() / 2) - 1;
+
int PixelX = (m_Player->GetPosX() - m_Map->GetCenterX()) / PixelWidth;
int PixelZ = (m_Player->GetPosZ() - m_Map->GetCenterZ()) / PixelWidth;
@@ -67,18 +68,22 @@ void cMapDecorator::Update(void)
m_PixelX = (2 * PixelX) + 1;
m_PixelZ = (2 * PixelZ) + 1;
- // 1px border
if ((PixelX > -InsideWidth) && (PixelX <= InsideWidth) && (PixelZ > -InsideHeight) && (PixelZ <= InsideHeight))
{
double Yaw = m_Player->GetYaw();
- m_Rot = (Yaw * 16) / 360;
-
if (m_Map->GetDimension() == dimNether)
{
+ cFastRandom Random;
+
Int64 WorldAge = m_Player->GetWorld()->GetWorldAge();
- // TODO 2014-02-18 xdot: Random rotations
+ // TODO 2014-02-19 xdot: Refine
+ m_Rot = Random.NextInt(16, WorldAge);
+ }
+ else
+ {
+ m_Rot = (Yaw * 16) / 360;
}
m_Type = E_TYPE_PLAYER;
diff --git a/src/Map.h b/src/Map.h
index 1a330e1c2..3cf9977ab 100644
--- a/src/Map.h
+++ b/src/Map.h
@@ -51,7 +51,7 @@ public:
/** Constructs a map decorator that tracks a player. */
cMapDecorator(cMap * a_Map, cPlayer * a_Player);
- /** Updates the pixel coordinates of the decorator. */
+ /** Updates the decorator. */
void Update(void);
unsigned int GetPixelX(void) const { return m_PixelX; }
@@ -123,7 +123,7 @@ public:
/** Construct an empty map. */
cMap(unsigned int a_ID, cWorld * a_World);
- /** Constructs an empty map at the specified coordinates. */
+ /** Construct an empty map at the specified coordinates. */
cMap(unsigned int a_ID, int a_CenterX, int a_CenterZ, cWorld * a_World, unsigned int a_Scale = 3);
/** Send this map to the specified client. WARNING: Slow */
@@ -135,7 +135,7 @@ public:
/** Update a circular region around the specified player. */
void UpdateRadius(cPlayer & a_Player, unsigned int a_Radius);
- /** Send next update packet and remove invalid decorators */
+ /** Send next update packet to the specified player and remove invalid decorators/clients. */
void UpdateClient(cPlayer * a_Player);
// tolua_begin