Time: Change old `u32` timestamps to 64-bit (#5818)
MacOSX build fix + cleanups
This commit is contained in:
parent
4d5ce8478c
commit
d99b6fed55
|
@ -590,9 +590,9 @@ void RemoteClient::notifyEvent(ClientStateEvent event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 RemoteClient::uptime() const
|
u64 RemoteClient::uptime() const
|
||||||
{
|
{
|
||||||
return porting::getTime(PRECISION_SECONDS) - m_connection_time;
|
return porting::getTimeS() - m_connection_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientInterface::ClientInterface(con::Connection* con)
|
ClientInterface::ClientInterface(con::Connection* con)
|
||||||
|
|
|
@ -266,7 +266,7 @@ public:
|
||||||
m_version_patch(0),
|
m_version_patch(0),
|
||||||
m_full_version("unknown"),
|
m_full_version("unknown"),
|
||||||
m_deployed_compression(0),
|
m_deployed_compression(0),
|
||||||
m_connection_time(porting::getTime(PRECISION_SECONDS))
|
m_connection_time(porting::getTimeS())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
~RemoteClient()
|
~RemoteClient()
|
||||||
|
@ -345,7 +345,7 @@ public:
|
||||||
{ serialization_version = m_pending_serialization_version; }
|
{ serialization_version = m_pending_serialization_version; }
|
||||||
|
|
||||||
/* get uptime */
|
/* get uptime */
|
||||||
u32 uptime() const;
|
u64 uptime() const;
|
||||||
|
|
||||||
/* set version information */
|
/* set version information */
|
||||||
void setVersionInfo(u8 major, u8 minor, u8 patch, const std::string &full)
|
void setVersionInfo(u8 major, u8 minor, u8 patch, const std::string &full)
|
||||||
|
@ -432,7 +432,7 @@ private:
|
||||||
/*
|
/*
|
||||||
time this client was created
|
time this client was created
|
||||||
*/
|
*/
|
||||||
const u32 m_connection_time;
|
const u64 m_connection_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ClientInterface {
|
class ClientInterface {
|
||||||
|
|
|
@ -2658,7 +2658,7 @@ void GUIFormSpecMenu::drawMenu()
|
||||||
if (hovered != NULL) {
|
if (hovered != NULL) {
|
||||||
s32 id = hovered->getID();
|
s32 id = hovered->getID();
|
||||||
|
|
||||||
u32 delta = 0;
|
u64 delta = 0;
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
m_old_tooltip_id = id;
|
m_old_tooltip_id = id;
|
||||||
m_old_tooltip = L"";
|
m_old_tooltip = L"";
|
||||||
|
@ -3247,7 +3247,7 @@ bool GUIFormSpecMenu::DoubleClickDetection(const SEvent event)
|
||||||
m_doubleclickdetect[1].time = porting::getTimeMs();
|
m_doubleclickdetect[1].time = porting::getTimeMs();
|
||||||
}
|
}
|
||||||
else if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) {
|
else if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) {
|
||||||
u32 delta = porting::getDeltaMs(m_doubleclickdetect[0].time, porting::getTimeMs());
|
u64 delta = porting::getDeltaMs(m_doubleclickdetect[0].time, porting::getTimeMs());
|
||||||
if (delta > 400) {
|
if (delta > 400) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,8 +420,8 @@ protected:
|
||||||
v2s32 m_old_pointer; // Mouse position after previous mouse event
|
v2s32 m_old_pointer; // Mouse position after previous mouse event
|
||||||
gui::IGUIStaticText *m_tooltip_element;
|
gui::IGUIStaticText *m_tooltip_element;
|
||||||
|
|
||||||
u32 m_tooltip_show_delay;
|
u64 m_tooltip_show_delay;
|
||||||
s64 m_hovered_time;
|
u64 m_hovered_time;
|
||||||
s32 m_old_tooltip_id;
|
s32 m_old_tooltip_id;
|
||||||
std::wstring m_old_tooltip;
|
std::wstring m_old_tooltip;
|
||||||
|
|
||||||
|
|
|
@ -626,7 +626,7 @@ void Hud::resizeHotbar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MeshTimeInfo {
|
struct MeshTimeInfo {
|
||||||
s64 time;
|
u64 time;
|
||||||
scene::IMesh *mesh;
|
scene::IMesh *mesh;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ namespace gui
|
||||||
gui::IGUIFont *OverrideFont, *LastBreakFont;
|
gui::IGUIFont *OverrideFont, *LastBreakFont;
|
||||||
IOSOperator* Operator;
|
IOSOperator* Operator;
|
||||||
|
|
||||||
u32 BlinkStartTime;
|
u64 BlinkStartTime;
|
||||||
s32 CursorPos;
|
s32 CursorPos;
|
||||||
s32 HScrollPos, VScrollPos; // scroll position in characters
|
s32 HScrollPos, VScrollPos; // scroll position in characters
|
||||||
u32 Max;
|
u32 Max;
|
||||||
|
|
|
@ -981,7 +981,7 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
|
||||||
|
|
||||||
time_until_purge *= 1000; // seconds -> milliseconds
|
time_until_purge *= 1000; // seconds -> milliseconds
|
||||||
|
|
||||||
u32 curr_time = porting::getTime(PRECISION_MILLI);
|
u64 curr_time = porting::getTimeMs();
|
||||||
u32 prev_unprocessed = m_unprocessed_count;
|
u32 prev_unprocessed = m_unprocessed_count;
|
||||||
m_unprocessed_count = m_transforming_liquid.size();
|
m_unprocessed_count = m_transforming_liquid.size();
|
||||||
|
|
||||||
|
|
|
@ -343,7 +343,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
f32 m_transforming_liquid_loop_count_multiplier;
|
f32 m_transforming_liquid_loop_count_multiplier;
|
||||||
u32 m_unprocessed_count;
|
u32 m_unprocessed_count;
|
||||||
u32 m_inc_trending_up_start_time; // milliseconds
|
u64 m_inc_trending_up_start_time; // milliseconds
|
||||||
bool m_queue_size_timer_started;
|
bool m_queue_size_timer_started;
|
||||||
|
|
||||||
DISABLE_CLASS_COPY(Map);
|
DISABLE_CLASS_COPY(Map);
|
||||||
|
|
|
@ -769,7 +769,7 @@ class Peer {
|
||||||
// Seconds from last receive
|
// Seconds from last receive
|
||||||
float m_timeout_counter;
|
float m_timeout_counter;
|
||||||
|
|
||||||
u32 m_last_timeout_check;
|
u64 m_last_timeout_check;
|
||||||
};
|
};
|
||||||
|
|
||||||
class UDPPeer : public Peer
|
class UDPPeer : public Peer
|
||||||
|
|
|
@ -21,3 +21,33 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
static Profiler main_profiler;
|
static Profiler main_profiler;
|
||||||
Profiler *g_profiler = &main_profiler;
|
Profiler *g_profiler = &main_profiler;
|
||||||
|
ScopeProfiler::ScopeProfiler(
|
||||||
|
Profiler *profiler, const std::string &name, ScopeProfilerType type)
|
||||||
|
: m_profiler(profiler), m_name(name), m_timer(NULL), m_type(type)
|
||||||
|
{
|
||||||
|
if (m_profiler)
|
||||||
|
m_timer = new TimeTaker(m_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopeProfiler::~ScopeProfiler()
|
||||||
|
{
|
||||||
|
if (!m_timer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
float duration_ms = m_timer->stop(true);
|
||||||
|
float duration = duration_ms / 1000.0;
|
||||||
|
if (m_profiler) {
|
||||||
|
switch (m_type) {
|
||||||
|
case SPT_ADD:
|
||||||
|
m_profiler->add(m_name, duration);
|
||||||
|
break;
|
||||||
|
case SPT_AVG:
|
||||||
|
m_profiler->avg(m_name, duration);
|
||||||
|
break;
|
||||||
|
case SPT_GRAPH_ADD:
|
||||||
|
m_profiler->graphAdd(m_name, duration);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete m_timer;
|
||||||
|
}
|
||||||
|
|
|
@ -193,48 +193,8 @@ class ScopeProfiler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScopeProfiler(Profiler *profiler, const std::string &name,
|
ScopeProfiler(Profiler *profiler, const std::string &name,
|
||||||
enum ScopeProfilerType type = SPT_ADD):
|
ScopeProfilerType type = SPT_ADD);
|
||||||
m_profiler(profiler),
|
~ScopeProfiler();
|
||||||
m_name(name),
|
|
||||||
m_timer(NULL),
|
|
||||||
m_type(type)
|
|
||||||
{
|
|
||||||
if(m_profiler)
|
|
||||||
m_timer = new TimeTaker(m_name.c_str());
|
|
||||||
}
|
|
||||||
// name is copied
|
|
||||||
ScopeProfiler(Profiler *profiler, const char *name,
|
|
||||||
enum ScopeProfilerType type = SPT_ADD):
|
|
||||||
m_profiler(profiler),
|
|
||||||
m_name(name),
|
|
||||||
m_timer(NULL),
|
|
||||||
m_type(type)
|
|
||||||
{
|
|
||||||
if(m_profiler)
|
|
||||||
m_timer = new TimeTaker(m_name.c_str());
|
|
||||||
}
|
|
||||||
~ScopeProfiler()
|
|
||||||
{
|
|
||||||
if(m_timer)
|
|
||||||
{
|
|
||||||
float duration_ms = m_timer->stop(true);
|
|
||||||
float duration = duration_ms / 1000.0;
|
|
||||||
if(m_profiler){
|
|
||||||
switch(m_type){
|
|
||||||
case SPT_ADD:
|
|
||||||
m_profiler->add(m_name, duration);
|
|
||||||
break;
|
|
||||||
case SPT_AVG:
|
|
||||||
m_profiler->avg(m_name, duration);
|
|
||||||
break;
|
|
||||||
case SPT_GRAPH_ADD:
|
|
||||||
m_profiler->graphAdd(m_name, duration);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete m_timer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
Profiler *m_profiler;
|
Profiler *m_profiler;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
|
|
|
@ -922,7 +922,7 @@ bool TouchScreenGUI::doubleTapDetection()
|
||||||
m_key_events[1].x = m_move_downlocation.X;
|
m_key_events[1].x = m_move_downlocation.X;
|
||||||
m_key_events[1].y = m_move_downlocation.Y;
|
m_key_events[1].y = m_move_downlocation.Y;
|
||||||
|
|
||||||
u32 delta = porting::getDeltaMs(m_key_events[0].down_time, porting::getTimeMs());
|
u64 delta = porting::getDeltaMs(m_key_events[0].down_time, porting::getTimeMs());
|
||||||
if (delta > 400)
|
if (delta > 400)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1006,7 +1006,7 @@ void TouchScreenGUI::step(float dtime)
|
||||||
(!m_move_has_really_moved) &&
|
(!m_move_has_really_moved) &&
|
||||||
(!m_move_sent_as_mouse_event)) {
|
(!m_move_sent_as_mouse_event)) {
|
||||||
|
|
||||||
u32 delta = porting::getDeltaMs(m_move_downtime, porting::getTimeMs());
|
u64 delta = porting::getDeltaMs(m_move_downtime, porting::getTimeMs());
|
||||||
|
|
||||||
if (delta > MIN_DIG_TIME_MS) {
|
if (delta > MIN_DIG_TIME_MS) {
|
||||||
m_shootline = m_device
|
m_shootline = m_device
|
||||||
|
|
|
@ -229,7 +229,7 @@ bool run_tests()
|
||||||
{
|
{
|
||||||
DSTACK(FUNCTION_NAME);
|
DSTACK(FUNCTION_NAME);
|
||||||
|
|
||||||
u32 t1 = porting::getTime(PRECISION_MILLI);
|
u64 t1 = porting::getTimeMs();
|
||||||
TestGameDef gamedef;
|
TestGameDef gamedef;
|
||||||
|
|
||||||
g_logger.setLevelSilenced(LL_ERROR, true);
|
g_logger.setLevelSilenced(LL_ERROR, true);
|
||||||
|
@ -246,7 +246,7 @@ bool run_tests()
|
||||||
num_total_tests_run += testmods[i]->num_tests_run;
|
num_total_tests_run += testmods[i]->num_tests_run;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 tdiff = porting::getTime(PRECISION_MILLI) - t1;
|
u64 tdiff = porting::getTimeMs() - t1;
|
||||||
|
|
||||||
g_logger.setLevelSilenced(LL_ERROR, false);
|
g_logger.setLevelSilenced(LL_ERROR, false);
|
||||||
|
|
||||||
|
@ -273,12 +273,12 @@ bool run_tests()
|
||||||
bool TestBase::testModule(IGameDef *gamedef)
|
bool TestBase::testModule(IGameDef *gamedef)
|
||||||
{
|
{
|
||||||
rawstream << "======== Testing module " << getName() << std::endl;
|
rawstream << "======== Testing module " << getName() << std::endl;
|
||||||
u32 t1 = porting::getTime(PRECISION_MILLI);
|
u64 t1 = porting::getTimeMs();
|
||||||
|
|
||||||
|
|
||||||
runTests(gamedef);
|
runTests(gamedef);
|
||||||
|
|
||||||
u32 tdiff = porting::getTime(PRECISION_MILLI) - t1;
|
u64 tdiff = porting::getTimeMs() - t1;
|
||||||
rawstream << "======== Module " << getName() << " "
|
rawstream << "======== Module " << getName() << " "
|
||||||
<< (num_tests_failed ? "failed" : "passed") << " (" << num_tests_failed
|
<< (num_tests_failed ? "failed" : "passed") << " (" << num_tests_failed
|
||||||
<< " failures / " << num_tests_run << " tests) - " << tdiff
|
<< " failures / " << num_tests_run << " tests) - " << tdiff
|
||||||
|
|
|
@ -33,7 +33,7 @@ class TestFailedException : public std::exception {
|
||||||
|
|
||||||
// Runs a unit test and reports results
|
// Runs a unit test and reports results
|
||||||
#define TEST(fxn, ...) do { \
|
#define TEST(fxn, ...) do { \
|
||||||
u32 t1 = porting::getTime(PRECISION_MILLI); \
|
u64 t1 = porting::getTimeMs(); \
|
||||||
try { \
|
try { \
|
||||||
fxn(__VA_ARGS__); \
|
fxn(__VA_ARGS__); \
|
||||||
rawstream << "[PASS] "; \
|
rawstream << "[PASS] "; \
|
||||||
|
@ -46,7 +46,7 @@ class TestFailedException : public std::exception {
|
||||||
num_tests_failed++; \
|
num_tests_failed++; \
|
||||||
} \
|
} \
|
||||||
num_tests_run++; \
|
num_tests_run++; \
|
||||||
u32 tdiff = porting::getTime(PRECISION_MILLI) - t1; \
|
u64 tdiff = porting::getTimeMs() - t1; \
|
||||||
rawstream << #fxn << " - " << tdiff << "ms" << std::endl; \
|
rawstream << #fxn << " - " << tdiff << "ms" << std::endl; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
TimeTaker::TimeTaker(const char *name, u32 *result, TimePrecision prec)
|
TimeTaker::TimeTaker(const std::string &name, u64 *result, TimePrecision prec)
|
||||||
{
|
{
|
||||||
m_name = name;
|
m_name = name;
|
||||||
m_result = result;
|
m_result = result;
|
||||||
|
@ -32,18 +32,13 @@ TimeTaker::TimeTaker(const char *name, u32 *result, TimePrecision prec)
|
||||||
m_time1 = porting::getTime(prec);
|
m_time1 = porting::getTime(prec);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 TimeTaker::stop(bool quiet)
|
u64 TimeTaker::stop(bool quiet)
|
||||||
{
|
{
|
||||||
if(m_running)
|
if (m_running) {
|
||||||
{
|
u64 dtime = porting::getTime(m_precision) - m_time1;
|
||||||
u32 time2 = porting::getTime(m_precision);
|
if (m_result != NULL) {
|
||||||
u32 dtime = time2 - m_time1;
|
|
||||||
if(m_result != NULL)
|
|
||||||
{
|
|
||||||
(*m_result) += dtime;
|
(*m_result) += dtime;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
static const char* const units[] = {
|
static const char* const units[] = {
|
||||||
"s" /* PRECISION_SECONDS */,
|
"s" /* PRECISION_SECONDS */,
|
||||||
|
@ -62,10 +57,8 @@ u32 TimeTaker::stop(bool quiet)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 TimeTaker::getTimerTime()
|
u64 TimeTaker::getTimerTime()
|
||||||
{
|
{
|
||||||
u32 time2 = porting::getTime(m_precision);
|
return porting::getTime(m_precision) - m_time1;
|
||||||
u32 dtime = time2 - m_time1;
|
|
||||||
return dtime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,24 +30,24 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
class TimeTaker
|
class TimeTaker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TimeTaker(const char *name, u32 *result=NULL,
|
TimeTaker(const std::string &name, u64 *result=NULL,
|
||||||
TimePrecision=PRECISION_MILLI);
|
TimePrecision prec=PRECISION_MILLI);
|
||||||
|
|
||||||
~TimeTaker()
|
~TimeTaker()
|
||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 stop(bool quiet=false);
|
u64 stop(bool quiet=false);
|
||||||
|
|
||||||
u32 getTimerTime();
|
u64 getTimerTime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char *m_name;
|
std::string m_name;
|
||||||
u32 m_time1;
|
u64 m_time1;
|
||||||
bool m_running;
|
bool m_running;
|
||||||
TimePrecision m_precision;
|
TimePrecision m_precision;
|
||||||
u32 *m_result;
|
u64 *m_result;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,14 +27,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
/*
|
/*
|
||||||
Debug stuff
|
Debug stuff
|
||||||
*/
|
*/
|
||||||
u32 addarea_time = 0;
|
u64 addarea_time = 0;
|
||||||
u32 emerge_time = 0;
|
u64 emerge_time = 0;
|
||||||
u32 emerge_load_time = 0;
|
u64 emerge_load_time = 0;
|
||||||
u32 clearflag_time = 0;
|
u64 clearflag_time = 0;
|
||||||
//u32 getwaterpressure_time = 0;
|
|
||||||
//u32 spreadwaterpressure_time = 0;
|
|
||||||
u32 updateareawaterpressure_time = 0;
|
|
||||||
u32 flowwater_pre_time = 0;
|
|
||||||
|
|
||||||
|
|
||||||
VoxelManipulator::VoxelManipulator():
|
VoxelManipulator::VoxelManipulator():
|
||||||
|
|
|
@ -49,8 +49,8 @@ class INodeDefManager;
|
||||||
/*
|
/*
|
||||||
Debug stuff
|
Debug stuff
|
||||||
*/
|
*/
|
||||||
extern u32 emerge_time;
|
extern u64 emerge_time;
|
||||||
extern u32 emerge_load_time;
|
extern u64 emerge_load_time;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This class resembles aabbox3d<s16> a lot, but has inclusive
|
This class resembles aabbox3d<s16> a lot, but has inclusive
|
||||||
|
|
Loading…
Reference in New Issue