Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: uptime in protocolstatus #2459

Merged
merged 6 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading