Commit 76e4c59d authored by fallenstardust's avatar fallenstardust

update Gframe

parent 84ed0139
...@@ -209,9 +209,12 @@ void ClientField::AddCard(ClientCard* pcard, int controler, int location, int se ...@@ -209,9 +209,12 @@ void ClientField::AddCard(ClientCard* pcard, int controler, int location, int se
deck[controler].push_back(pcard); deck[controler].push_back(pcard);
pcard->sequence = (unsigned char)(deck[controler].size() - 1); pcard->sequence = (unsigned char)(deck[controler].size() - 1);
} else { } else {
for (auto& pcard : deck[controler]) deck[controler].push_back(0);
pcard->sequence++; for(int i = deck[controler].size() - 1; i > 0; --i) {
deck[controler].insert(deck[controler].begin(), pcard); deck[controler][i] = deck[controler][i - 1];
deck[controler][i]->sequence++;
}
deck[controler][0] = pcard;
pcard->sequence = 0; pcard->sequence = 0;
} }
pcard->is_reversed = false; pcard->is_reversed = false;
...@@ -248,13 +251,15 @@ void ClientField::AddCard(ClientCard* pcard, int controler, int location, int se ...@@ -248,13 +251,15 @@ void ClientField::AddCard(ClientCard* pcard, int controler, int location, int se
extra[controler].push_back(pcard); extra[controler].push_back(pcard);
pcard->sequence = (unsigned char)(extra[controler].size() - 1); pcard->sequence = (unsigned char)(extra[controler].size() - 1);
} else { } else {
extra[controler].push_back(0);
int p = extra[controler].size() - extra_p_count[controler] - 1; int p = extra[controler].size() - extra_p_count[controler] - 1;
for(int i = extra[controler].size() - 1; i > p; --i) { for(int i = extra[controler].size() - 1; i > p; --i) {
extra[controler][i] = extra[controler][i - 1];
extra[controler][i]->sequence++; extra[controler][i]->sequence++;
extra[controler][i]->curPos += irr::core::vector3df(0, 0, 0.01f); extra[controler][i]->curPos += irr::core::vector3df(0, 0, 0.01f);
extra[controler][i]->mTransform.setTranslation(extra[controler][i]->curPos); extra[controler][i]->mTransform.setTranslation(extra[controler][i]->curPos);
} }
extra[controler].insert(extra[controler].begin() + p, pcard); extra[controler][p] = pcard;
pcard->sequence = p; pcard->sequence = p;
} }
if (pcard->position & POS_FACEUP) if (pcard->position & POS_FACEUP)
...@@ -265,54 +270,69 @@ void ClientField::AddCard(ClientCard* pcard, int controler, int location, int se ...@@ -265,54 +270,69 @@ void ClientField::AddCard(ClientCard* pcard, int controler, int location, int se
RefreshCardCountDisplay(); RefreshCardCountDisplay();
} }
ClientCard* ClientField::RemoveCard(int controler, int location, int sequence) { ClientCard* ClientField::RemoveCard(int controler, int location, int sequence) {
ClientCard* pcard = nullptr; ClientCard* pcard = 0;
auto erase_card = [](std::vector<ClientCard*>& lst, int seq) {
for (int i = seq; i < (int)lst.size() - 1; ++i) {
lst[i] = lst[i + 1];
lst[i]->sequence--;
lst[i]->curPos -= irr::core::vector3df(0, 0, 0.01f);
lst[i]->mTransform.setTranslation(lst[i]->curPos);
}
lst.pop_back();
};
switch (location) { switch (location) {
case LOCATION_DECK: { case LOCATION_DECK: {
pcard = deck[controler][sequence]; pcard = deck[controler][sequence];
erase_card(deck[controler], sequence); for (size_t i = sequence; i < deck[controler].size() - 1; ++i) {
deck[controler][i] = deck[controler][i + 1];
deck[controler][i]->sequence--;
deck[controler][i]->curPos -= irr::core::vector3df(0, 0, 0.01f);
deck[controler][i]->mTransform.setTranslation(deck[controler][i]->curPos);
}
deck[controler].erase(deck[controler].end() - 1);
break; break;
} }
case LOCATION_HAND: { case LOCATION_HAND: {
pcard = hand[controler][sequence]; pcard = hand[controler][sequence];
for (int i = sequence; i < (int)hand[controler].size() - 1; ++i) { for (size_t i = sequence; i < hand[controler].size() - 1; ++i) {
hand[controler][i] = hand[controler][i + 1]; hand[controler][i] = hand[controler][i + 1];
hand[controler][i]->sequence--; hand[controler][i]->sequence--;
} }
hand[controler].pop_back(); hand[controler].erase(hand[controler].end() - 1);
break; break;
} }
case LOCATION_MZONE: { case LOCATION_MZONE: {
pcard = mzone[controler][sequence]; pcard = mzone[controler][sequence];
mzone[controler][sequence] = nullptr; mzone[controler][sequence] = 0;
break; break;
} }
case LOCATION_SZONE: { case LOCATION_SZONE: {
pcard = szone[controler][sequence]; pcard = szone[controler][sequence];
szone[controler][sequence] = nullptr; szone[controler][sequence] = 0;
break; break;
} }
case LOCATION_GRAVE: { case LOCATION_GRAVE: {
pcard = grave[controler][sequence]; pcard = grave[controler][sequence];
erase_card(grave[controler], sequence); for (size_t i = sequence; i < grave[controler].size() - 1; ++i) {
grave[controler][i] = grave[controler][i + 1];
grave[controler][i]->sequence--;
grave[controler][i]->curPos -= irr::core::vector3df(0, 0, 0.01f);
grave[controler][i]->mTransform.setTranslation(grave[controler][i]->curPos);
}
grave[controler].erase(grave[controler].end() - 1);
break; break;
} }
case LOCATION_REMOVED: { case LOCATION_REMOVED: {
pcard = remove[controler][sequence]; pcard = remove[controler][sequence];
erase_card(remove[controler], sequence); for (size_t i = sequence; i < remove[controler].size() - 1; ++i) {
remove[controler][i] = remove[controler][i + 1];
remove[controler][i]->sequence--;
remove[controler][i]->curPos -= irr::core::vector3df(0, 0, 0.01f);
remove[controler][i]->mTransform.setTranslation(remove[controler][i]->curPos);
}
remove[controler].erase(remove[controler].end() - 1);
break; break;
} }
case LOCATION_EXTRA: { case LOCATION_EXTRA: {
pcard = extra[controler][sequence]; pcard = extra[controler][sequence];
erase_card(extra[controler], sequence); for (size_t i = sequence; i < extra[controler].size() - 1; ++i) {
extra[controler][i] = extra[controler][i + 1];
extra[controler][i]->sequence--;
extra[controler][i]->curPos -= irr::core::vector3df(0, 0, 0.01f);
extra[controler][i]->mTransform.setTranslation(extra[controler][i]->curPos);
}
extra[controler].erase(extra[controler].end() - 1);
if (pcard->position & POS_FACEUP) if (pcard->position & POS_FACEUP)
extra_p_count[controler]--; extra_p_count[controler]--;
break; break;
......
...@@ -8,28 +8,22 @@ ...@@ -8,28 +8,22 @@
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
#include <android_native_app_glue.h> #include <android_native_app_glue.h>
#include <android/android_tools.h> #include <android/android_tools.h>
#endif #include <android/xstring.h>
#ifdef _WIN32
#define NOMINMAX #define mywcscat wcscat_x
#include <WinSock2.h> #include "os.h"
#include <windows.h> #include <android/bufferio_android.h>
#include <ws2tcpip.h> #include <android/CustomShaderConstantSetCallBack.h>
#endif
#ifdef _MSC_VER #ifndef TEXT
#define myswprintf _swprintf #ifdef UNICODE
#define mywcsncasecmp _wcsnicmp #define TEXT(x) L##x
#define mystrncasecmp _strnicmp
#else #else
#define myswprintf swprintf #define TEXT(x) x
#define mywcsncasecmp wcsncasecmp #endif // UNICODE
#define mystrncasecmp strncasecmp
#endif #endif
#define socklen_t int
#else //_WIN32
#include <errno.h> #include <errno.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/socket.h> #include <sys/socket.h>
...@@ -47,45 +41,22 @@ ...@@ -47,45 +41,22 @@
#define SOCKADDR sockaddr #define SOCKADDR sockaddr
#define SOCKET_ERRNO() (errno) #define SOCKET_ERRNO() (errno)
#ifdef _IRR_ANDROID_PLATFORM_ #define mywcsncasecmp wcsncasecmp
#include <android/xstring.h> #define mystrncasecmp strncasecmp
#define myswprintf(buf, fmt, ...) swprintf_x(buf, 4096, fmt, ##__VA_ARGS__)
#define mywcscat wcscat_x
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <string> #include <string>
#ifdef _IRR_ANDROID_PLATFORM_
#include "os.h"
#include <android/bufferio_android.h>
#endif
#include "myfilesystem.h"
#include "mysignal.h" #include "mysignal.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h"
template<size_t N, typename... TR> template<size_t N, typename... TR>
inline int swprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) { inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
return std::swprintf(buf, N, fmt, args...); return std::swprintf(buf, N, fmt, args...);
} }
#if defined(_IRR_ANDROID_PLATFORM_)
#include <android/CustomShaderConstantSetCallBack.h>
#endif
#ifndef TEXT
#ifdef UNICODE
#define TEXT(x) L##x
#else
#define TEXT(x) x
#endif // UNICODE
#endif
inline FILE* myfopen(const wchar_t* filename, const char* mode) { inline FILE* myfopen(const wchar_t* filename, const char* mode) {
FILE* fp{}; FILE* fp{};
char fname[1024]{}; char fname[1024]{};
...@@ -94,7 +65,6 @@ inline FILE* myfopen(const wchar_t* filename, const char* mode) { ...@@ -94,7 +65,6 @@ inline FILE* myfopen(const wchar_t* filename, const char* mode) {
return fp; return fp;
} }
#include <irrlicht.h> #include <irrlicht.h>
using namespace irr; using namespace irr;
using namespace core; using namespace core;
...@@ -108,5 +78,5 @@ extern const unsigned short PRO_VERSION; ...@@ -108,5 +78,5 @@ extern const unsigned short PRO_VERSION;
extern unsigned int enable_log; extern unsigned int enable_log;
extern bool exit_on_return; extern bool exit_on_return;
extern bool bot_mode; extern bool bot_mode;
#endif
#endif #endif
...@@ -24,7 +24,7 @@ struct CardDataC : card_data { ...@@ -24,7 +24,7 @@ struct CardDataC : card_data {
uint32_t ot{}; uint32_t ot{};
uint32_t category{}; uint32_t category{};
bool is_setcodes(std::vector <uint32_t> values) const { bool is_setcodes(const std::vector<unsigned int>& values) const {
for (auto& value : values) { for (auto& value : values) {
if (is_setcode(value)) if (is_setcode(value))
return true; return true;
......
...@@ -81,7 +81,7 @@ void DeckBuilder::Initialize() { ...@@ -81,7 +81,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;
...@@ -464,7 +464,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -464,7 +464,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
catesel = mainGame->lstCategories->getItemCount() - 1; catesel = mainGame->lstCategories->getItemCount() - 1;
} else { } else {
for(int i = 3; i < (int)mainGame->lstCategories->getItemCount(); i++) { for(int i = 3; i < (int)mainGame->lstCategories->getItemCount(); i++) {
if(!wcsncasecmp(mainGame->lstCategories->getListItem(i), catename, 256)) { if(!mywcsncasecmp(mainGame->lstCategories->getListItem(i), catename, 256)) {
catesel = i; catesel = i;
mainGame->stACMessage->setText(dataManager.GetSysString(1474)); mainGame->stACMessage->setText(dataManager.GetSysString(1474));
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
...@@ -494,7 +494,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -494,7 +494,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
} else { } else {
catesel = 0; catesel = 0;
for(int i = 3; i < (int)mainGame->lstCategories->getItemCount(); i++) { for(int i = 3; i < (int)mainGame->lstCategories->getItemCount(); i++) {
if(!wcsncasecmp(mainGame->lstCategories->getListItem(i), newcatename, 256)) { if(!mywcsncasecmp(mainGame->lstCategories->getListItem(i), newcatename, 256)) {
catesel = i; catesel = i;
mainGame->stACMessage->setText(dataManager.GetSysString(1474)); mainGame->stACMessage->setText(dataManager.GetSysString(1474));
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
...@@ -545,7 +545,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -545,7 +545,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
ChangeCategory(mainGame->lstCategories->getSelected()); ChangeCategory(mainGame->lstCategories->getSelected());
} }
for(int i = 0; i < (int)mainGame->lstDecks->getItemCount(); i++) { for(int i = 0; i < (int)mainGame->lstDecks->getItemCount(); i++) {
if(!wcsncasecmp(mainGame->lstDecks->getListItem(i), deckname, 256)) { if(!mywcsncasecmp(mainGame->lstDecks->getListItem(i), deckname, 256)) {
deckManager.LoadCurrentDeck(filepath); deckManager.LoadCurrentDeck(filepath);
prev_deck = i; prev_deck = i;
mainGame->cbDBDecks->setSelected(prev_deck); mainGame->cbDBDecks->setSelected(prev_deck);
...@@ -579,7 +579,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -579,7 +579,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
RefreshDeckList(true); RefreshDeckList(true);
ChangeCategory(catesel); ChangeCategory(catesel);
for(int i = 0; i < (int)mainGame->lstDecks->getItemCount(); i++) { for(int i = 0; i < (int)mainGame->lstDecks->getItemCount(); i++) {
if(!wcsncasecmp(mainGame->lstDecks->getListItem(i), newdeckname, 256)) { if(!mywcsncasecmp(mainGame->lstDecks->getListItem(i), newdeckname, 256)) {
deckManager.LoadCurrentDeck(newfilepath); deckManager.LoadCurrentDeck(newfilepath);
prev_deck = i; prev_deck = i;
mainGame->cbDBDecks->setSelected(prev_deck); mainGame->cbDBDecks->setSelected(prev_deck);
...@@ -643,7 +643,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -643,7 +643,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->cbDBCategory->setSelected(catesel); mainGame->cbDBCategory->setSelected(catesel);
ChangeCategory(catesel); ChangeCategory(catesel);
for(int i = 0; i < (int)mainGame->lstDecks->getItemCount(); i++) { for(int i = 0; i < (int)mainGame->lstDecks->getItemCount(); i++) {
if(!wcsncasecmp(mainGame->lstDecks->getListItem(i), deckname, 256)) { if(!mywcsncasecmp(mainGame->lstDecks->getListItem(i), deckname, 256)) {
deckManager.LoadCurrentDeck(newfilepath); deckManager.LoadCurrentDeck(newfilepath);
prev_deck = i; prev_deck = i;
mainGame->cbDBDecks->setSelected(prev_deck); mainGame->cbDBDecks->setSelected(prev_deck);
...@@ -681,7 +681,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -681,7 +681,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->cbDBCategory->setSelected(catesel); mainGame->cbDBCategory->setSelected(catesel);
ChangeCategory(catesel); ChangeCategory(catesel);
for(int i = 0; i < (int)mainGame->lstDecks->getItemCount(); i++) { for(int i = 0; i < (int)mainGame->lstDecks->getItemCount(); i++) {
if(!wcsncasecmp(mainGame->lstDecks->getListItem(i), deckname, 256)) { if(!mywcsncasecmp(mainGame->lstDecks->getListItem(i), deckname, 256)) {
deckManager.LoadCurrentDeck(newfilepath); deckManager.LoadCurrentDeck(newfilepath);
prev_deck = i; prev_deck = i;
mainGame->cbDBDecks->setSelected(prev_deck); mainGame->cbDBDecks->setSelected(prev_deck);
......
...@@ -296,7 +296,7 @@ bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) { ...@@ -296,7 +296,7 @@ bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) {
myswprintf(localfile, L"./deck/%ls.ydk", file); myswprintf(localfile, L"./deck/%ls.ydk", file);
reader = OpenDeckReader(localfile); reader = OpenDeckReader(localfile);
} }
if(!reader && !wcsncasecmp(file, L"./pack", 6)) { if(!reader && !mywcsncasecmp(file, L"./pack", 6)) {
wchar_t zipfile[256]; wchar_t zipfile[256];
myswprintf(zipfile, L"%ls", file + 2); myswprintf(zipfile, L"%ls", file + 2);
reader = OpenDeckReader(zipfile); reader = OpenDeckReader(zipfile);
......
...@@ -755,9 +755,8 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) { ...@@ -755,9 +755,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];
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));
...@@ -3656,39 +3655,6 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) { ...@@ -3656,39 +3655,6 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->stANRace->setText(textBuffer); mainGame->stANRace->setText(textBuffer);
mainGame->PopupElement(mainGame->wANRace); mainGame->PopupElement(mainGame->wANRace);
/*#ifdef _IRR_ANDROID_PLATFORM_
char* content;
char** contents;
char* label;
list<IGUIElement*> children = mainGame->wANRace->getChildren();
int count = children.size();
int i = 0;
int filter = 0x1;//属性种族宣言fixme
list<IGUIElement*>::Iterator current = children.begin();
contents = (char **) malloc(count * sizeof(char *));
do {
if ((*current)->getType() == EGUIET_CHECK_BOX) {
content = (char *) malloc(256 * 4);
if (filter & available) {//属性种族宣言fixme
BufferIO::EncodeUTF8(((IGUICheckBox*) (*current))->getText(),
content);
}
else {
BufferIO::EncodeUTF8(dataManager.GetSysString(1080),
content);
}
*(contents + i++) = content;
}
current++;
} while (current != children.end());
android::showAndroidComboBoxCompat(mainGame->appMain, true, contents, i,
1);
count = i;
for (int i = 0; i < count; i++) {
free(*(contents + i));
}
free(contents);
#endif*/
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
...@@ -3709,40 +3675,6 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) { ...@@ -3709,40 +3675,6 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->stANAttribute->setText(textBuffer); mainGame->stANAttribute->setText(textBuffer);
mainGame->PopupElement(mainGame->wANAttribute); mainGame->PopupElement(mainGame->wANAttribute);
/*#ifdef _IRR_ANDROID_PLATFORM_
char* content;
char** contents;
char* label;
list<IGUIElement*> children = mainGame->wANAttribute->getChildren();
int count = children.size();
int i = 0;
int filter = 0x1;
list<IGUIElement*>::Iterator current = children.begin();
contents = (char **) malloc(count * sizeof(char *));
do {
if ((*current)->getType() == EGUIET_CHECK_BOX) {
content = (char *) malloc(256 * 4);
if (filter & available) {
BufferIO::EncodeUTF8(((IGUICheckBox*) (*current))->getText(),
content);
}
else {
BufferIO::EncodeUTF8(dataManager.GetSysString(1080),
content);
}
*(contents + i++) = content;
filter <<= 1;
}
current++;
} while (current != children.end());
android::showAndroidComboBoxCompat(mainGame->appMain, true, contents, i,
1);
count = i;
for (int i = 0; i < count; i++) {
free(*(contents + i));
}
free(contents);
#endif*/
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
......
...@@ -64,7 +64,7 @@ bool IsExtension(const wchar_t* filename, const wchar_t* extension) { ...@@ -64,7 +64,7 @@ bool IsExtension(const wchar_t* filename, const wchar_t* extension) {
auto elen = std::wcslen(extension); auto elen = std::wcslen(extension);
if (!elen || flen < elen) if (!elen || flen < elen)
return false; return false;
return !wcsncasecmp(filename + (flen - elen), extension, elen); return !mywcsncasecmp(filename + (flen - elen), extension, elen);
} }
void Game::process(irr::SEvent &event) { void Game::process(irr::SEvent &event) {
...@@ -150,8 +150,10 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) { ...@@ -150,8 +150,10 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
params.WindowSize = irr::core::dimension2d<u32>(0, 0); params.WindowSize = irr::core::dimension2d<u32>(0, 0);
device = irr::createDeviceEx(params); device = irr::createDeviceEx(params);
if(!device) if(!device) {
ErrorLog("Failed to create Irrlicht Engine device!");
return false; return false;
}
if (!android::perfromTrick(app)) { if (!android::perfromTrick(app)) {
return false; return false;
} }
...@@ -1625,7 +1627,7 @@ void Game::LoadExpansions() { ...@@ -1625,7 +1627,7 @@ void Game::LoadExpansions() {
dataManager.LoadStrings(reader); dataManager.LoadStrings(reader);
continue; continue;
} }
if (!wcsncasecmp(fname, L"pack/", 5) && IsExtension(fname, L".ydk")) { if (!mywcsncasecmp(fname, L"pack/", 5) && IsExtension(fname, L".ydk")) {
deckBuilder.expansionPacks.push_back(fname); deckBuilder.expansionPacks.push_back(fname);
continue; continue;
} }
...@@ -1682,7 +1684,7 @@ void Game::RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBo ...@@ -1682,7 +1684,7 @@ void Game::RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBo
RefreshDeck(catepath, [cbDeck](const wchar_t* item) { cbDeck->addItem(item); }); RefreshDeck(catepath, [cbDeck](const wchar_t* item) { cbDeck->addItem(item); });
} }
void Game::RefreshDeck(const wchar_t* deckpath, const std::function<void(const wchar_t*)>& additem) { void Game::RefreshDeck(const wchar_t* deckpath, const std::function<void(const wchar_t*)>& additem) {
if(!wcsncasecmp(deckpath, L"./pack", 6)) { if(!mywcsncasecmp(deckpath, L"./pack", 6)) {
for(auto& pack : deckBuilder.expansionPacks) { for(auto& pack : deckBuilder.expansionPacks) {
// add pack/xxx.ydk // add pack/xxx.ydk
additem(pack.substr(5, pack.size() - 9).c_str()); additem(pack.substr(5, pack.size() - 9).c_str());
...@@ -2055,10 +2057,9 @@ void Game::ErrorLog(const char* msg) { ...@@ -2055,10 +2057,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);
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,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>
......
...@@ -542,7 +542,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -542,7 +542,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
if(prev_operation == BUTTON_RENAME_REPLAY) { if(prev_operation == BUTTON_RENAME_REPLAY) {
wchar_t newname[256]; wchar_t newname[256];
BufferIO::CopyWideString(mainGame->ebRSName->getText(), newname); BufferIO::CopyWideString(mainGame->ebRSName->getText(), newname);
if(wcsncasecmp(newname + std::wcslen(newname) - 4, L".yrp", 4)) { if(mywcsncasecmp(newname + std::wcslen(newname) - 4, L".yrp", 4)) {
myswprintf(newname, L"%ls.yrp", mainGame->ebRSName->getText()); myswprintf(newname, L"%ls.yrp", mainGame->ebRSName->getText());
} }
if(Replay::RenameReplay(mainGame->lstReplayList->getListItem(prev_sel), newname)) { if(Replay::RenameReplay(mainGame->lstReplayList->getListItem(prev_sel), newname)) {
...@@ -651,8 +651,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -651,8 +651,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]);
...@@ -667,7 +666,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -667,7 +666,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
myswprintf(infobuf, L"%ls\n===VS===\n%ls\n", namebuf[0], namebuf[1]); myswprintf(infobuf, L"%ls\n===VS===\n%ls\n", namebuf[0], namebuf[1]);
repinfo.append(infobuf); repinfo.append(infobuf);
mainGame->ebRepStartTurn->setText(L"1"); mainGame->ebRepStartTurn->setText(L"1");
mainGame->SetStaticText(mainGame->stReplayInfo, 180 * mainGame->xScale, mainGame->guiFont, (wchar_t*)repinfo.c_str()); mainGame->SetStaticText(mainGame->stReplayInfo, 180 * mainGame->xScale, mainGame->guiFont, repinfo.c_str());
break; break;
} }
case LISTBOX_SINGLEPLAY_LIST: { case LISTBOX_SINGLEPLAY_LIST: {
......
...@@ -88,7 +88,7 @@ public: ...@@ -88,7 +88,7 @@ public:
static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) { static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) {
wchar_t findstr[1024]; wchar_t findstr[1024];
std::swprintf(findstr, sizeof findstr / sizeof findstr[0], L"%s/*", wpath); std::swprintf(findstr, sizeof findstr / sizeof findstr[0], L"%ls/*", wpath);
WIN32_FIND_DATAW fdataw; WIN32_FIND_DATAW fdataw;
HANDLE fh = FindFirstFileW(findstr, &fdataw); HANDLE fh = FindFirstFileW(findstr, &fdataw);
if(fh == INVALID_HANDLE_VALUE) if(fh == INVALID_HANDLE_VALUE)
......
...@@ -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);
......
...@@ -72,7 +72,7 @@ int SingleMode::SinglePlayThread() { ...@@ -72,7 +72,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();
...@@ -124,10 +124,9 @@ int SingleMode::SinglePlayThread() { ...@@ -124,10 +124,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));
......
...@@ -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