Commit dc5a3053 authored by Chen Bill's avatar Chen Bill Committed by GitHub

use <ctime> header (#2668)

parent d6c4ad21
...@@ -63,7 +63,7 @@ void DeckBuilder::Initialize() { ...@@ -63,7 +63,7 @@ void DeckBuilder::Initialize() {
mainGame->btnSideReload->setVisible(false); mainGame->btnSideReload->setVisible(false);
filterList = &deckManager._lfList[mainGame->gameConf.use_lflist ? mainGame->gameConf.default_lflist : deckManager._lfList.size() - 1].content; filterList = &deckManager._lfList[mainGame->gameConf.use_lflist ? mainGame->gameConf.default_lflist : deckManager._lfList.size() - 1].content;
ClearSearch(); ClearSearch();
rnd.reset((uint_fast32_t)time(nullptr)); rnd.reset((uint_fast32_t)std::time(nullptr));
mouse_pos.set(0, 0); mouse_pos.set(0, 0);
hovered_code = 0; hovered_code = 0;
hovered_pos = 0; hovered_pos = 0;
......
...@@ -730,9 +730,8 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) { ...@@ -730,9 +730,8 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
else else
starttime = new_replay.pheader.seed; starttime = new_replay.pheader.seed;
tm* localedtime = localtime(&starttime);
wchar_t timetext[40]; wchar_t timetext[40];
std::wcsftime(timetext, 40, L"%Y-%m-%d %H-%M-%S", localedtime); std::wcsftime(timetext, sizeof timetext / sizeof timetext[0], L"%Y-%m-%d %H-%M-%S", std::localtime(&starttime));
mainGame->ebRSName->setText(timetext); mainGame->ebRSName->setText(timetext);
if(!mainGame->chkAutoSaveReplay->isChecked()) { if(!mainGame->chkAutoSaveReplay->isChecked()) {
mainGame->wReplaySave->setText(dataManager.GetSysString(1340)); mainGame->wReplaySave->setText(dataManager.GetSysString(1340));
......
...@@ -1723,10 +1723,9 @@ void Game::ErrorLog(const char* msg) { ...@@ -1723,10 +1723,9 @@ void Game::ErrorLog(const char* msg) {
FILE* fp = fopen("error.log", "at"); FILE* fp = fopen("error.log", "at");
if(!fp) if(!fp)
return; return;
time_t nowtime = time(nullptr); time_t nowtime = std::time(nullptr);
tm* localedtime = localtime(&nowtime);
char timebuf[40]; char timebuf[40];
strftime(timebuf, 40, "%Y-%m-%d %H:%M:%S", localedtime); std::strftime(timebuf, sizeof timebuf, "%Y-%m-%d %H:%M:%S", std::localtime(&nowtime));
fprintf(fp, "[%s]%s\n", timebuf, msg); fprintf(fp, "[%s]%s\n", timebuf, msg);
fclose(fp); fclose(fp);
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "client_field.h" #include "client_field.h"
#include "deck_con.h" #include "deck_con.h"
#include "menu_handler.h" #include "menu_handler.h"
#include <time.h> #include <ctime>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <list> #include <list>
......
...@@ -556,8 +556,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -556,8 +556,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
curtime = ReplayMode::cur_replay.pheader.start_time; curtime = ReplayMode::cur_replay.pheader.start_time;
else else
curtime = ReplayMode::cur_replay.pheader.seed; curtime = ReplayMode::cur_replay.pheader.seed;
tm* st = localtime(&curtime); std::wcsftime(infobuf, sizeof infobuf / sizeof infobuf[0], L"%Y/%m/%d %H:%M:%S\n", std::localtime(&curtime));
std::wcsftime(infobuf, 256, L"%Y/%m/%d %H:%M:%S\n", st);
repinfo.append(infobuf); repinfo.append(infobuf);
wchar_t namebuf[4][20]{}; wchar_t namebuf[4][20]{};
ReplayMode::cur_replay.ReadName(namebuf[0]); ReplayMode::cur_replay.ReadName(namebuf[0]);
......
...@@ -419,7 +419,7 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -419,7 +419,7 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
rh.version = PRO_VERSION; rh.version = PRO_VERSION;
rh.flag = REPLAY_UNIFORM; rh.flag = REPLAY_UNIFORM;
rh.seed = seed; rh.seed = seed;
rh.start_time = (unsigned int)time(nullptr); rh.start_time = (unsigned int)std::time(nullptr);
last_replay.BeginRecord(); last_replay.BeginRecord();
last_replay.WriteHeader(rh); last_replay.WriteHeader(rh);
last_replay.WriteData(players[0]->name, 40, false); last_replay.WriteData(players[0]->name, 40, false);
......
...@@ -84,7 +84,7 @@ int SingleMode::SinglePlayThread() { ...@@ -84,7 +84,7 @@ int SingleMode::SinglePlayThread() {
rh.version = PRO_VERSION; rh.version = PRO_VERSION;
rh.flag = REPLAY_UNIFORM | REPLAY_SINGLE_MODE; rh.flag = REPLAY_UNIFORM | REPLAY_SINGLE_MODE;
rh.seed = seed; rh.seed = seed;
rh.start_time = (unsigned int)time(nullptr); rh.start_time = (unsigned int)std::time(nullptr);
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->HideElement(mainGame->wSinglePlay); mainGame->HideElement(mainGame->wSinglePlay);
mainGame->ClearCardInfo(); mainGame->ClearCardInfo();
...@@ -135,10 +135,9 @@ int SingleMode::SinglePlayThread() { ...@@ -135,10 +135,9 @@ int SingleMode::SinglePlayThread() {
} }
last_replay.EndRecord(); last_replay.EndRecord();
mainGame->gMutex.lock(); mainGame->gMutex.lock();
time_t nowtime = time(nullptr); time_t nowtime = std::time(nullptr);
tm* localedtime = localtime(&nowtime);
wchar_t timetext[40]; wchar_t timetext[40];
std::wcsftime(timetext, 40, L"%Y-%m-%d %H-%M-%S", localedtime); std::wcsftime(timetext, sizeof timetext / sizeof timetext[0], L"%Y-%m-%d %H-%M-%S", std::localtime(&nowtime));
mainGame->ebRSName->setText(timetext); mainGame->ebRSName->setText(timetext);
if(!mainGame->chkAutoSaveReplay->isChecked()) { if(!mainGame->chkAutoSaveReplay->isChecked()) {
mainGame->wReplaySave->setText(dataManager.GetSysString(1340)); mainGame->wReplaySave->setText(dataManager.GetSysString(1340));
......
...@@ -12,7 +12,7 @@ bool SoundManager::Init() { ...@@ -12,7 +12,7 @@ bool SoundManager::Init() {
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
bgm_scene = -1; bgm_scene = -1;
RefreshBGMList(); RefreshBGMList();
rnd.reset((unsigned int)time(nullptr)); rnd.reset((unsigned int)std::time(nullptr));
engineSound = irrklang::createIrrKlangDevice(); engineSound = irrklang::createIrrKlangDevice();
engineMusic = irrklang::createIrrKlangDevice(); engineMusic = irrklang::createIrrKlangDevice();
if(!engineSound || !engineMusic) { if(!engineSound || !engineMusic) {
......
...@@ -392,7 +392,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -392,7 +392,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
rh.version = PRO_VERSION; rh.version = PRO_VERSION;
rh.flag = REPLAY_UNIFORM | REPLAY_TAG; rh.flag = REPLAY_UNIFORM | REPLAY_TAG;
rh.seed = seed; rh.seed = seed;
rh.start_time = (unsigned int)time(nullptr); rh.start_time = (unsigned int)std::time(nullptr);
last_replay.BeginRecord(); last_replay.BeginRecord();
last_replay.WriteHeader(rh); last_replay.WriteHeader(rh);
last_replay.WriteData(players[0]->name, 40, false); last_replay.WriteData(players[0]->name, 40, false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment