summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/defines.h3
-rw-r--r--src/game-server/actor.h3
-rw-r--r--src/game-server/being.cpp8
-rw-r--r--src/game-server/character.cpp4
-rw-r--r--src/game-server/main-game.cpp5
-rw-r--r--src/utils/speedconv.cpp11
6 files changed, 19 insertions, 15 deletions
diff --git a/src/defines.h b/src/defines.h
index 5cce0f7..fc99fb6 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -24,6 +24,9 @@
// Precomputed square-root of 2.
#define SQRT2 1.4142135623730950488
+// World tick time in miliseconds.
+#define WORLD_TICK_MS 100
+
/**
* Exit value codes are thrown back at servers exit to reflect their exit state.
*/
diff --git a/src/game-server/actor.h b/src/game-server/actor.h
index b5c634f..fa44355 100644
--- a/src/game-server/actor.h
+++ b/src/game-server/actor.h
@@ -130,7 +130,8 @@ class Actor : public Thing
virtual Map::BlockType getBlockType() const
{ return Map::BLOCKTYPE_NONE; }
- unsigned short mMoveTime; /**< Delay until next action. */
+ /** Delay until move to next tile in miliseconds. */
+ unsigned short mMoveTime;
private:
char mUpdateFlags; /**< Changes in actor status. */
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp
index 4e78586..c0fc65e 100644
--- a/src/game-server/being.cpp
+++ b/src/game-server/being.cpp
@@ -211,10 +211,10 @@ void Being::move()
mOld = getPosition();
- if (mMoveTime > 100)
+ if (mMoveTime > WORLD_TICK_MS)
{
// Current move has not yet ended
- mMoveTime -= 100;
+ mMoveTime -= WORLD_TICK_MS;
return;
}
@@ -291,10 +291,10 @@ void Being::move()
pos.x = next.x * tileWidth + (tileWidth / 2);
pos.y = next.y * tileHeight + (tileHeight / 2);
}
- while (mMoveTime < 100);
+ while (mMoveTime < WORLD_TICK_MS);
setPosition(pos);
- mMoveTime = mMoveTime > 100 ? mMoveTime - 100 : 0;
+ mMoveTime = mMoveTime > WORLD_TICK_MS ? mMoveTime - WORLD_TICK_MS : 0;
}
int Being::directionToAngle(int direction)
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index 3fadf18..6246402 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -148,9 +148,9 @@ void Character::perform()
// wait before next attack
// Note: The auto-attack system will handle the delay between two attacks.
// TODO: Remove this condition when it's done.
- if (mMoveTime > 100)
+ if (mMoveTime > WORLD_TICK_MS)
{
- mMoveTime -= 100;
+ mMoveTime -= WORLD_TICK_MS;
return;
}
diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp
index d62c92a..182e459 100644
--- a/src/game-server/main-game.cpp
+++ b/src/game-server/main-game.cpp
@@ -77,8 +77,9 @@ using utils::Logger;
static int const WORLD_TICK_SKIP = 2; /** tolerance for lagging behind in world calculation) **/
-utils::Timer worldTimer(100, false); /**< Timer for world tics set to 100 ms */
-int worldTime = 0; /**< Current world time in 100ms ticks */
+/** Timer for world ticks */
+utils::Timer worldTimer(WORLD_TICK_MS, false);
+int worldTime = 0; /**< Current world time in ticks */
bool running = true; /**< Determines if server keeps running */
utils::StringFilter *stringFilter; /**< Slang's Filter */
diff --git a/src/utils/speedconv.cpp b/src/utils/speedconv.cpp
index 29ab059..cbea2c1 100644
--- a/src/utils/speedconv.cpp
+++ b/src/utils/speedconv.cpp
@@ -23,17 +23,16 @@
#include "defines.h"
// Defines the max base scale used to compute the raw speed system.
-// The raw speed is the number of tile moves per server tick * 100
-// since a server tick is currently 100 ms.
-// TODO: Deharcode the magic value by obtaining the server tick time.
-#define MAX_MOVE_TIME 32000
+// The raw speed is the number of tile moves per server tick multiplied the
+// server tick value in miliseconds.
+#define MAX_MOVE_TIME 320
double utils::tpsToRawSpeed(double tps)
{
- return (MAX_MOVE_TIME / (tps * DEFAULT_TILE_LENGTH));
+ return ((MAX_MOVE_TIME * WORLD_TICK_MS) / (tps * DEFAULT_TILE_LENGTH));
}
double utils::rawSpeedToTps(double speed)
{
- return (MAX_MOVE_TIME / (speed * DEFAULT_TILE_LENGTH));
+ return ((MAX_MOVE_TIME * WORLD_TICK_MS) / (speed * DEFAULT_TILE_LENGTH));
}