Commit bae9acfa authored by wind2009's avatar wind2009

Revert "Merge remote-tracking branch 'salix5/patch-wcscpy' into develop"

This reverts commit 67ca7ea1, reversing
changes made to 0cf2937f.
parent 44e74d89
...@@ -1605,8 +1605,8 @@ void Game::ShowCardInfo(int code, bool resize) { ...@@ -1605,8 +1605,8 @@ void Game::ShowCardInfo(int code, bool resize) {
offset_info = 15; offset_info = 15;
if(!(cd.type & TYPE_LINK)) { if(!(cd.type & TYPE_LINK)) {
const wchar_t* form = L"\u2605"; const wchar_t* form = L"\u2605";
if(cd.type & TYPE_XYZ) if(cd.type & TYPE_XYZ) form = L"\u2606";
form = L"\u2606"; myswprintf(formatBuffer, L"[%ls%d] ", form, cd.level);
wchar_t adBuffer[16]; wchar_t adBuffer[16];
if(cd.attack < 0 && cd.defense < 0) if(cd.attack < 0 && cd.defense < 0)
myswprintf(adBuffer, L"?/?"); myswprintf(adBuffer, L"?/?");
...@@ -1616,14 +1616,16 @@ void Game::ShowCardInfo(int code, bool resize) { ...@@ -1616,14 +1616,16 @@ void Game::ShowCardInfo(int code, bool resize) {
myswprintf(adBuffer, L"%d/?", cd.attack); myswprintf(adBuffer, L"%d/?", cd.attack);
else else
myswprintf(adBuffer, L"%d/%d", cd.attack, cd.defense); myswprintf(adBuffer, L"%d/%d", cd.attack, cd.defense);
myswprintf(formatBuffer, L"[%ls%d] %ls", form, cd.level, adBuffer); wcscat(formatBuffer, adBuffer);
} else { } else {
myswprintf(formatBuffer, L"[LINK-%d] ", cd.level);
wchar_t adBuffer[16]; wchar_t adBuffer[16];
if(cd.attack < 0) if(cd.attack < 0)
myswprintf(adBuffer, L"?/- "); myswprintf(adBuffer, L"?/- ");
else else
myswprintf(adBuffer, L"%d/- ", cd.attack); myswprintf(adBuffer, L"%d/- ", cd.attack);
myswprintf(formatBuffer, L"[LINK-%d] %ls%ls", cd.level, adBuffer, dataManager.FormatLinkMarker(cd.link_marker)); wcscat(formatBuffer, adBuffer);
wcscat(formatBuffer, dataManager.FormatLinkMarker(cd.link_marker).c_str());
} }
if(cd.type & TYPE_PENDULUM) { if(cd.type & TYPE_PENDULUM) {
wchar_t scaleBuffer[16]; wchar_t scaleBuffer[16];
......
...@@ -115,16 +115,14 @@ int main(int argc, char* argv[]) { ...@@ -115,16 +115,14 @@ int main(int argc, char* argv[]) {
++i; ++i;
if(i < wargc) { if(i < wargc) {
deckCategorySpecified = true; deckCategorySpecified = true;
wcsncpy(ygo::mainGame->gameConf.lastcategory, wargv[i], sizeof ygo::mainGame->gameConf.lastcategory / sizeof ygo::mainGame->gameConf.lastcategory[0]); wcscpy(ygo::mainGame->gameConf.lastcategory, wargv[i]);
BufferIO::NullTerminate(ygo::mainGame->gameConf.lastcategory);
} }
} else if(!wcscmp(wargv[i], L"-d")) { // Deck } else if(!wcscmp(wargv[i], L"-d")) { // Deck
++i; ++i;
if(!deckCategorySpecified) if(!deckCategorySpecified)
ygo::mainGame->gameConf.lastcategory[0] = 0; ygo::mainGame->gameConf.lastcategory[0] = 0;
if(i + 1 < wargc) { // select deck if(i + 1 < wargc) { // select deck
wcsncpy(ygo::mainGame->gameConf.lastdeck, wargv[i], sizeof ygo::mainGame->gameConf.lastdeck / sizeof ygo::mainGame->gameConf.lastdeck[0]); wcscpy(ygo::mainGame->gameConf.lastdeck, wargv[i]);
BufferIO::NullTerminate(ygo::mainGame->gameConf.lastdeck);
continue; continue;
} else { // open deck } else { // open deck
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
...@@ -137,8 +135,7 @@ int main(int argc, char* argv[]) { ...@@ -137,8 +135,7 @@ int main(int argc, char* argv[]) {
myswprintf(open_file_name, L"%ls/%ls", ygo::mainGame->gameConf.lastcategory, wargv[i]); myswprintf(open_file_name, L"%ls/%ls", ygo::mainGame->gameConf.lastcategory, wargv[i]);
#endif #endif
} else { } else {
wcsncpy(open_file_name, wargv[i], sizeof open_file_name / sizeof open_file_name[0]); wcscpy(open_file_name, wargv[i]);
BufferIO::NullTerminate(open_file_name);
} }
} }
ClickButton(ygo::mainGame->btnDeckEdit); ClickButton(ygo::mainGame->btnDeckEdit);
...@@ -159,8 +156,7 @@ int main(int argc, char* argv[]) { ...@@ -159,8 +156,7 @@ int main(int argc, char* argv[]) {
++i; ++i;
if(i < wargc) { if(i < wargc) {
open_file = true; open_file = true;
wcsncpy(open_file_name, wargv[i], sizeof open_file_name / sizeof open_file_name[0]); wcscpy(open_file_name, wargv[i]);
BufferIO::NullTerminate(open_file_name);
} }
ClickButton(ygo::mainGame->btnReplayMode); ClickButton(ygo::mainGame->btnReplayMode);
if(open_file) if(open_file)
...@@ -171,8 +167,7 @@ int main(int argc, char* argv[]) { ...@@ -171,8 +167,7 @@ int main(int argc, char* argv[]) {
++i; ++i;
if(i < wargc) { if(i < wargc) {
open_file = true; open_file = true;
wcsncpy(open_file_name, wargv[i], sizeof open_file_name / sizeof open_file_name[0]); wcscpy(open_file_name, wargv[i]);
BufferIO::NullTerminate(open_file_name);
} }
ClickButton(ygo::mainGame->btnSingleMode); ClickButton(ygo::mainGame->btnSingleMode);
if(open_file) if(open_file)
...@@ -182,16 +177,14 @@ int main(int argc, char* argv[]) { ...@@ -182,16 +177,14 @@ int main(int argc, char* argv[]) {
wchar_t* pstrext = wargv[1] + wcslen(wargv[1]) - 4; wchar_t* pstrext = wargv[1] + wcslen(wargv[1]) - 4;
if(!mywcsncasecmp(pstrext, L".ydk", 4)) { if(!mywcsncasecmp(pstrext, L".ydk", 4)) {
open_file = true; open_file = true;
wcsncpy(open_file_name, wargv[i], sizeof open_file_name / sizeof open_file_name[0]); wcscpy(open_file_name, wargv[i]);
BufferIO::NullTerminate(open_file_name);
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
ClickButton(ygo::mainGame->btnDeckEdit); ClickButton(ygo::mainGame->btnDeckEdit);
break; break;
} }
if(!mywcsncasecmp(pstrext, L".yrp", 4)) { if(!mywcsncasecmp(pstrext, L".yrp", 4)) {
open_file = true; open_file = true;
wcsncpy(open_file_name, wargv[i], sizeof open_file_name / sizeof open_file_name[0]); wcscpy(open_file_name, wargv[i]);
BufferIO::NullTerminate(open_file_name);
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
ClickButton(ygo::mainGame->btnReplayMode); ClickButton(ygo::mainGame->btnReplayMode);
ClickButton(ygo::mainGame->btnLoadReplay); ClickButton(ygo::mainGame->btnLoadReplay);
......
...@@ -448,8 +448,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -448,8 +448,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wcsncpy(deck_name, dash + 1, 256); wcsncpy(deck_name, dash + 1, 256);
for(size_t i = 0; i < mainGame->cbDBDecks->getItemCount(); ++i) { for(size_t i = 0; i < mainGame->cbDBDecks->getItemCount(); ++i) {
if(!wcscmp(mainGame->cbDBDecks->getItem(i), deck_name)) { if(!wcscmp(mainGame->cbDBDecks->getItem(i), deck_name)) {
wcsncpy(mainGame->gameConf.lastdeck, deck_name, sizeof mainGame->gameConf.lastdeck / sizeof mainGame->gameConf.lastdeck[0]); wcscpy(mainGame->gameConf.lastdeck, deck_name);
BufferIO::NullTerminate(mainGame->gameConf.lastdeck);
mainGame->cbDBDecks->setSelected(i); mainGame->cbDBDecks->setSelected(i);
break; break;
} }
...@@ -457,8 +456,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -457,8 +456,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} else { // only deck name } else { // only deck name
for(size_t i = 0; i < mainGame->cbDBDecks->getItemCount(); ++i) { for(size_t i = 0; i < mainGame->cbDBDecks->getItemCount(); ++i) {
if(!wcscmp(mainGame->cbDBDecks->getItem(i), open_file_name)) { if(!wcscmp(mainGame->cbDBDecks->getItem(i), open_file_name)) {
wcsncpy(mainGame->gameConf.lastdeck, open_file_name, sizeof mainGame->gameConf.lastdeck / sizeof mainGame->gameConf.lastdeck[0]); wcscpy(mainGame->gameConf.lastdeck, open_file_name);
BufferIO::NullTerminate(mainGame->gameConf.lastdeck);
mainGame->cbDBDecks->setSelected(i); mainGame->cbDBDecks->setSelected(i);
break; break;
} }
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#ifdef _WIN32 #ifdef _WIN32
#include <wchar.h>
#define NOMINMAX #define NOMINMAX
#include <Windows.h> #include <Windows.h>
...@@ -90,7 +89,8 @@ public: ...@@ -90,7 +89,8 @@ 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];
swprintf(findstr, 1024, L"%s/*", wpath); wcscpy(findstr, wpath);
wcscat(findstr, L"/*");
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)
......
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