Skip to content

Commit

Permalink
fix: uptime in protocolstatus (#2459)
Browse files Browse the repository at this point in the history
  • Loading branch information
htc16 authored Jul 6, 2024
1 parent 3aeb3e7 commit 9825f4c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lua/functions/core/game/global_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ int GlobalFunctions::luaGetWorldLight(lua_State* L) {

int GlobalFunctions::luaGetWorldUpTime(lua_State* L) {
// getWorldUpTime()
uint64_t uptime = (OTSYS_TIME() - ProtocolStatus::start) / 1000;
uint64_t uptime = (OTSYS_TIME(true) - ProtocolStatus::start) / 1000;
lua_pushnumber(L, uptime);
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/network/protocol/protocolstatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ std::string ProtocolStatus::SERVER_VERSION = "3.0";
std::string ProtocolStatus::SERVER_DEVELOPERS = "OpenTibiaBR Organization";

std::map<uint32_t, int64_t> ProtocolStatus::ipConnectMap;
const uint64_t ProtocolStatus::start = OTSYS_TIME();
const uint64_t ProtocolStatus::start = OTSYS_TIME(true);

void ProtocolStatus::onRecvFirstMessage(NetworkMessage &msg) {
uint32_t ip = getIP();
Expand Down
5 changes: 4 additions & 1 deletion src/utils/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,10 @@ void UPDATE_OTSYS_TIME() {
OTSYSTIME = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}

int64_t OTSYS_TIME() {
int64_t OTSYS_TIME(bool useTime) {
if (useTime) {
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}
return OTSYSTIME;
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/tools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ bool isCaskItem(uint16_t itemId);
std::string getObjectCategoryName(ObjectCategory_t category);
bool isValidObjectCategory(ObjectCategory_t category);

int64_t OTSYS_TIME();
int64_t OTSYS_TIME(bool useTime = false);
void UPDATE_OTSYS_TIME();

SpellGroup_t stringToSpellGroup(const std::string &value);
Expand Down

0 comments on commit 9825f4c

Please sign in to comment.