mirror of
https://github.com/UOX3DevTeam/UOX3
synced 2026-08-13 12:27:04 -04:00
Misc cleanup and standardization of style and naming conventions in code and scripts Added missing code for showing race in paperdoll based on ini setting Players can no longer use Polymorph spell while incognitoed, or while under effect of tribal paint Players can no longer use Incognito spell while polymorphed, or while under the effects of tribal paint Facial hair is now removed from players who are under the effects of Incognito spell that changes their gender for female
83 lines
3 KiB
C++
83 lines
3 KiB
C++
// Created on: 3/28/21
|
|
|
|
#include "TimeUtility.hpp"
|
|
|
|
#include <cstdint>
|
|
#include <iostream>
|
|
#include <stdexcept>
|
|
#include <chrono>
|
|
//#include <ctime>
|
|
#include <time.h>
|
|
#include <sstream>
|
|
#include <iomanip>
|
|
#include "ConfigOS.h"
|
|
|
|
namespace timeutil
|
|
{
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
//
|
|
// Methods for TimeUtilities
|
|
//
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
std::string timeNow()
|
|
{
|
|
std::stringstream msg;
|
|
|
|
auto now_time = std::chrono::system_clock::to_time_t( std::chrono::system_clock::now() );
|
|
struct tm buffer;
|
|
#if PLATFORM == WINDOWS
|
|
localtime_s( &buffer, &now_time );
|
|
auto now_tm = &buffer;
|
|
#else
|
|
auto now_tm = localtime_r( &now_time, &buffer );
|
|
#endif
|
|
msg << std::put_time( now_tm, "%c" );
|
|
return msg.str();
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - Interval_st::Interval_st()
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Constructor
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
Interval_st::Interval_st()
|
|
{
|
|
startTime = std::chrono::steady_clock::now();
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - Interval_st::Start()
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Set a start time point representing current time
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
void Interval_st::Start()
|
|
{
|
|
startTime = std::chrono::steady_clock::now();
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - Interval_st::Elapsed()
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Return elapsed time since start time was set
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
long long Interval_st::Elapsed()
|
|
{
|
|
auto end = std::chrono::steady_clock::now();
|
|
auto diff = end - startTime;
|
|
return std::chrono::duration_cast<std::chrono::milliseconds>( diff ).count();
|
|
}
|
|
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Function - Interval_st::Stop()
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
//| Purpose - Reset start time and return time elapsed since start time was previously set
|
|
//o-----------------------------------------------------------------------------------------------o
|
|
long long Interval_st::Stop()
|
|
{
|
|
auto end = std::chrono::steady_clock::now();
|
|
auto diff = end - startTime;
|
|
startTime = std::chrono::steady_clock::now();
|
|
return std::chrono::duration_cast<std::chrono::milliseconds>( diff ).count();
|
|
}
|
|
}
|