diff options
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 f6be2e7b..29ab059c 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 33e1a944..7dca10e7 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 |