diff --git a/src/World.hpp b/src/World.hpp index 55f9dcce..57e25c5b 100644 --- a/src/World.hpp +++ b/src/World.hpp @@ -224,9 +224,9 @@ class World : public WorldScriptInterface { * Method for returning the current illarion time * *@param timeType <"year"|"month"|"day"|"hour"|"minute"|"second"> - *@return an int which is the current illarion time from the type + *@return a long which is the current illarion time from the type */ - auto getTime(const std::string &timeType) const -> int override; + auto getTime(const std::string &timeType) const -> long override; void allowLogin(bool allow) { _is_login_allowed = allow; } auto isLoginAllowed() const -> bool { return _is_login_allowed; } diff --git a/src/WorldIMPLTalk.cpp b/src/WorldIMPLTalk.cpp index 0444c70b..e9fc8d85 100644 --- a/src/WorldIMPLTalk.cpp +++ b/src/WorldIMPLTalk.cpp @@ -324,7 +324,7 @@ void World::sendIGTime(Player *cp) const { ServerCommandPointer cmd = std::make_shared( static_cast(getTime("hour")), static_cast(getTime("minute")), static_cast(getTime("day")), static_cast(getTime("month")), - static_cast(getTime("year"))); + static_cast(getTime("year"))); cp->Connection->addCommand(cmd); } diff --git a/src/WorldIMPLTools.cpp b/src/WorldIMPLTools.cpp index 0646988c..97d5e5de 100644 --- a/src/WorldIMPLTools.cpp +++ b/src/WorldIMPLTools.cpp @@ -597,17 +597,17 @@ void World::Load() { void World::import() { maps.importFromEditor(); } -auto World::getTime(const std::string &timeType) const -> int { +auto World::getTime(const std::string &timeType) const -> long { // return unix timestamp if requsted and quit function if (timeType == "unix") { - return (int)time(nullptr); + return (long)time(nullptr); } // get current time and timezone data to get additional informations for time conversation time_t curr_unixtime = time(nullptr); struct tm *timestamp = localtime(&curr_unixtime); - auto illaTime = (int)curr_unixtime; + auto illaTime = (long)curr_unixtime; static constexpr auto secondsInHour = 60 * 60; // in case its currently dst, correct the timestamp so the illarion time changes the timestamp as well @@ -618,17 +618,17 @@ auto World::getTime(const std::string &timeType) const -> int { illaTime = (illaTime - illarionBirthTime) * illarionTimeFactor; if (timeType == "illarion") { - return (int)illaTime; + return (long)illaTime; } // Calculating year static constexpr auto secondsInYear = 60 * 60 * 24 * 365; - auto year = (int)(illaTime / secondsInYear); + auto year = (long)(illaTime / secondsInYear); illaTime -= year * secondsInYear; // Calculating day static constexpr auto secondsInDay = 60 * 60 * 24; - auto day = (int)(illaTime / secondsInDay); + auto day = (long)(illaTime / secondsInDay); illaTime -= day * secondsInDay; ++day; @@ -636,7 +636,7 @@ auto World::getTime(const std::string &timeType) const -> int { static constexpr auto daysInIllarionMonth = 24; static constexpr auto daysInLastIllarionMonth = 5; static constexpr auto monthsInIllarionYear = 16; - auto month = (int)(day / daysInIllarionMonth); + auto month = (long)(day / daysInIllarionMonth); day -= month * daysInIllarionMonth; // checking for range borders and fixing the date @@ -668,12 +668,12 @@ auto World::getTime(const std::string &timeType) const -> int { // Calculate the time of day // Calculating hour - const auto hour = (int)(illaTime / secondsInHour); + const auto hour = (long)(illaTime / secondsInHour); illaTime -= hour * secondsInHour; // Calculating minute static constexpr auto secondsInMinute = 60; - const auto minute = (int)(illaTime / secondsInMinute); + const auto minute = (long)(illaTime / secondsInMinute); // Calculating seconds illaTime -= minute * secondsInMinute; diff --git a/src/WorldScriptInterface.hpp b/src/WorldScriptInterface.hpp index 2358a8b2..3fb7437e 100644 --- a/src/WorldScriptInterface.hpp +++ b/src/WorldScriptInterface.hpp @@ -102,7 +102,7 @@ class WorldScriptInterface { // Other virtual void broadcast(const std::string &german, const std::string &english) const = 0; - [[nodiscard]] virtual auto getTime(const std::string &timeType) const -> int = 0; + [[nodiscard]] virtual auto getTime(const std::string &timeType) const -> long = 0; virtual void gfx(unsigned short int gfxid, const position &pos) const = 0; virtual void makeSound(unsigned short int soundid, const position &pos) const = 0; virtual void sendMonitoringMessage(const std::string &msg, unsigned char id = 0) const = 0; diff --git a/test/test_binding_world.cpp b/test/test_binding_world.cpp index 0b50d79d..c1097646 100644 --- a/test/test_binding_world.cpp +++ b/test/test_binding_world.cpp @@ -51,7 +51,7 @@ class MockWorld : public World { MOCK_METHOD(void, removePersistenceAt, (const position &), (override)); MOCK_METHOD(bool, isPersistentAt, (const position &), (const override)); MOCK_METHOD(void, broadcast, (const std::string &, const std::string &), (const override)); - MOCK_METHOD(int, getTime, (const std::string &), (const override)); + MOCK_METHOD(long, getTime, (const std::string &), (const override)); MOCK_METHOD(void, gfx, (unsigned short int, const position &), (const override)); MOCK_METHOD(void, makeSound, (unsigned short int, const position &), (const override)); MOCK_METHOD(void, sendMonitoringMessage, (const std::string &, unsigned char), (const override));