diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-01-03 19:31:33 +0100 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-01-03 19:31:33 +0100 |
commit | 352056c23c6258c7acbd9593eacdf1e4bfef3e9e (patch) | |
tree | 95ae2feadaa4fff4ebde977e5fb9f1a1b8fe3b32 /src/utils | |
parent | 6bb8e30f5afc1c77987d8fdef71df880e72db151 (diff) | |
download | manaserv-352056c23c6258c7acbd9593eacdf1e4bfef3e9e.tar.gz manaserv-352056c23c6258c7acbd9593eacdf1e4bfef3e9e.tar.xz manaserv-352056c23c6258c7acbd9593eacdf1e4bfef3e9e.zip |
Cleaned up and document a bit more the speed conversion functions.
Trivial fix.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/speedconv.cpp | 16 | ||||
-rw-r--r-- | src/utils/speedconv.h | 18 |
2 files changed, 24 insertions, 10 deletions
diff --git a/src/utils/speedconv.cpp b/src/utils/speedconv.cpp index f6be2e7..29ab059 100644 --- a/src/utils/speedconv.cpp +++ b/src/utils/speedconv.cpp @@ -20,12 +20,20 @@ #include "utils/speedconv.h" -double utils::tpsToSpeed(double tps) +#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 + +double utils::tpsToRawSpeed(double tps) { - return (32000 / (tps * DEFAULT_TILE_LENGTH)); + return (MAX_MOVE_TIME / (tps * DEFAULT_TILE_LENGTH)); } -double utils::speedToTps(double speed) +double utils::rawSpeedToTps(double speed) { - return (32000 / (speed * DEFAULT_TILE_LENGTH)); + return (MAX_MOVE_TIME / (speed * DEFAULT_TILE_LENGTH)); } diff --git a/src/utils/speedconv.h b/src/utils/speedconv.h index 33e1a94..7dca10e 100644 --- a/src/utils/speedconv.h +++ b/src/utils/speedconv.h @@ -24,21 +24,27 @@ // Simple helper functions for converting between tiles per // second and the internal speed representation -#include "defines.h" - namespace utils { /** - * tpsToSpeed() + * Translate the speed in tiles per second (tps) + * into the raw speed used internally. + * The raw speed is the number of tiles moves per server tick * 100 + * since a server tick is currently 100 ms. + * * @param tps The speed value in tiles per second + * * @returns The speed value in the internal representation */ - double tpsToSpeed(double); + double tpsToRawSpeed(double); + /** - * speedToTps() + * Translate the raw speed used internally into a tile per second one. + * * @param speed The speed value in the internal representation + * * @returns The speed value in tiles per second */ - double speedToTps(double); + double rawSpeedToTps(double); } #endif // SPEEDCONV_H |