Commit 8893caac authored by wind2009's avatar wind2009

Merge remote-tracking branch 'salix/patch2' into develop

parents 9dad9524 898b4687
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#endif #endif
#include <cstdio> #include <cstdio>
#include <stdlib.h> #include <cstdlib>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <string> #include <string>
......
...@@ -91,10 +91,10 @@ bool DataManager::LoadDB(const wchar_t* wfile) { ...@@ -91,10 +91,10 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
if(reader == nullptr) if(reader == nullptr)
return false; return false;
spmemvfs_db_t db; spmemvfs_db_t db;
spmembuffer_t* mem = (spmembuffer_t*)calloc(sizeof(spmembuffer_t), 1); spmembuffer_t* mem = (spmembuffer_t*)std::calloc(sizeof(spmembuffer_t), 1);
spmemvfs_env_init(); spmemvfs_env_init();
mem->total = mem->used = reader->getSize(); mem->total = mem->used = reader->getSize();
mem->data = (char*)malloc(mem->total + 1); mem->data = (char*)std::malloc(mem->total + 1);
reader->read(mem->data, mem->total); reader->read(mem->data, mem->total);
reader->drop(); reader->drop();
(mem->data)[mem->total] = '\0'; (mem->data)[mem->total] = '\0';
......
...@@ -196,7 +196,7 @@ int DeckManager::LoadDeck(Deck& deck, std::istringstream& deckStream, bool is_pa ...@@ -196,7 +196,7 @@ int DeckManager::LoadDeck(Deck& deck, std::istringstream& deckStream, bool is_pa
if (linebuf[0] < '0' || linebuf[0] > '9') if (linebuf[0] < '0' || linebuf[0] > '9')
continue; continue;
errno = 0; errno = 0;
code = strtol(linebuf.c_str(), nullptr, 10); code = std::strtol(linebuf.c_str(), nullptr, 10);
if (errno == ERANGE) if (errno == ERANGE)
continue; continue;
cardlist[ct++] = code; cardlist[ct++] = code;
......
...@@ -1368,13 +1368,13 @@ void Game::LoadConfig() { ...@@ -1368,13 +1368,13 @@ void Game::LoadConfig() {
if (std::sscanf(linebuf, "%63s = %959s", strbuf, valbuf) != 2) if (std::sscanf(linebuf, "%63s = %959s", strbuf, valbuf) != 2)
continue; continue;
if(!std::strcmp(strbuf, "antialias")) { if(!std::strcmp(strbuf, "antialias")) {
gameConf.antialias = strtol(valbuf, nullptr, 10); gameConf.antialias = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "use_d3d")) { } else if(!std::strcmp(strbuf, "use_d3d")) {
gameConf.use_d3d = strtol(valbuf, nullptr, 10) > 0; gameConf.use_d3d = std::strtol(valbuf, nullptr, 10) > 0;
} else if(!std::strcmp(strbuf, "use_image_scale")) { } else if(!std::strcmp(strbuf, "use_image_scale")) {
gameConf.use_image_scale = strtol(valbuf, nullptr, 10) > 0; gameConf.use_image_scale = std::strtol(valbuf, nullptr, 10) > 0;
} else if(!std::strcmp(strbuf, "errorlog")) { } else if(!std::strcmp(strbuf, "errorlog")) {
unsigned int val = strtol(valbuf, nullptr, 10); unsigned int val = std::strtol(valbuf, nullptr, 10);
enable_log = val & 0xff; enable_log = val & 0xff;
} else if(!std::strcmp(strbuf, "textfont")) { } else if(!std::strcmp(strbuf, "textfont")) {
int textfontsize = 0; int textfontsize = 0;
...@@ -1385,94 +1385,94 @@ void Game::LoadConfig() { ...@@ -1385,94 +1385,94 @@ void Game::LoadConfig() {
} else if(!std::strcmp(strbuf, "numfont")) { } else if(!std::strcmp(strbuf, "numfont")) {
BufferIO::DecodeUTF8(valbuf, gameConf.numfont); BufferIO::DecodeUTF8(valbuf, gameConf.numfont);
} else if(!std::strcmp(strbuf, "serverport")) { } else if(!std::strcmp(strbuf, "serverport")) {
gameConf.serverport = strtol(valbuf, nullptr, 10); gameConf.serverport = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "lasthost")) { } else if(!std::strcmp(strbuf, "lasthost")) {
BufferIO::DecodeUTF8(valbuf, gameConf.lasthost); BufferIO::DecodeUTF8(valbuf, gameConf.lasthost);
} else if(!std::strcmp(strbuf, "lastport")) { } else if(!std::strcmp(strbuf, "lastport")) {
BufferIO::DecodeUTF8(valbuf, gameConf.lastport); BufferIO::DecodeUTF8(valbuf, gameConf.lastport);
} else if(!std::strcmp(strbuf, "automonsterpos")) { } else if(!std::strcmp(strbuf, "automonsterpos")) {
gameConf.chkMAutoPos = strtol(valbuf, nullptr, 10); gameConf.chkMAutoPos = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "autospellpos")) { } else if(!std::strcmp(strbuf, "autospellpos")) {
gameConf.chkSTAutoPos = strtol(valbuf, nullptr, 10); gameConf.chkSTAutoPos = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "randompos")) { } else if(!std::strcmp(strbuf, "randompos")) {
gameConf.chkRandomPos = strtol(valbuf, nullptr, 10); gameConf.chkRandomPos = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "autochain")) { } else if(!std::strcmp(strbuf, "autochain")) {
gameConf.chkAutoChain = strtol(valbuf, nullptr, 10); gameConf.chkAutoChain = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "waitchain")) { } else if(!std::strcmp(strbuf, "waitchain")) {
gameConf.chkWaitChain = strtol(valbuf, nullptr, 10); gameConf.chkWaitChain = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "showchain")) { } else if(!std::strcmp(strbuf, "showchain")) {
gameConf.chkDefaultShowChain = strtol(valbuf, nullptr, 10); gameConf.chkDefaultShowChain = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "mute_opponent")) { } else if(!std::strcmp(strbuf, "mute_opponent")) {
gameConf.chkIgnore1 = strtol(valbuf, nullptr, 10); gameConf.chkIgnore1 = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "mute_spectators")) { } else if(!std::strcmp(strbuf, "mute_spectators")) {
gameConf.chkIgnore2 = strtol(valbuf, nullptr, 10); gameConf.chkIgnore2 = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "use_lflist")) { } else if(!std::strcmp(strbuf, "use_lflist")) {
gameConf.use_lflist = strtol(valbuf, nullptr, 10); gameConf.use_lflist = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "default_lflist")) { } else if(!std::strcmp(strbuf, "default_lflist")) {
gameConf.default_lflist = strtol(valbuf, nullptr, 10); gameConf.default_lflist = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "default_rule")) { } else if(!std::strcmp(strbuf, "default_rule")) {
gameConf.default_rule = strtol(valbuf, nullptr, 10); gameConf.default_rule = std::strtol(valbuf, nullptr, 10);
if(gameConf.default_rule <= 0) if(gameConf.default_rule <= 0)
gameConf.default_rule = DEFAULT_DUEL_RULE; gameConf.default_rule = DEFAULT_DUEL_RULE;
} else if(!std::strcmp(strbuf, "hide_setname")) { } else if(!std::strcmp(strbuf, "hide_setname")) {
gameConf.hide_setname = strtol(valbuf, nullptr, 10); gameConf.hide_setname = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "hide_hint_button")) { } else if(!std::strcmp(strbuf, "hide_hint_button")) {
gameConf.hide_hint_button = strtol(valbuf, nullptr, 10); gameConf.hide_hint_button = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "control_mode")) { } else if(!std::strcmp(strbuf, "control_mode")) {
gameConf.control_mode = strtol(valbuf, nullptr, 10); gameConf.control_mode = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "draw_field_spell")) { } else if(!std::strcmp(strbuf, "draw_field_spell")) {
gameConf.draw_field_spell = strtol(valbuf, nullptr, 10); gameConf.draw_field_spell = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "separate_clear_button")) { } else if(!std::strcmp(strbuf, "separate_clear_button")) {
gameConf.separate_clear_button = strtol(valbuf, nullptr, 10); gameConf.separate_clear_button = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "auto_search_limit")) { } else if(!std::strcmp(strbuf, "auto_search_limit")) {
gameConf.auto_search_limit = strtol(valbuf, nullptr, 10); gameConf.auto_search_limit = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "search_multiple_keywords")) { } else if(!std::strcmp(strbuf, "search_multiple_keywords")) {
gameConf.search_multiple_keywords = strtol(valbuf, nullptr, 10); gameConf.search_multiple_keywords = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "ignore_deck_changes")) { } else if(!std::strcmp(strbuf, "ignore_deck_changes")) {
gameConf.chkIgnoreDeckChanges = strtol(valbuf, nullptr, 10); gameConf.chkIgnoreDeckChanges = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "default_ot")) { } else if(!std::strcmp(strbuf, "default_ot")) {
gameConf.defaultOT = strtol(valbuf, nullptr, 10); gameConf.defaultOT = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "enable_bot_mode")) { } else if(!std::strcmp(strbuf, "enable_bot_mode")) {
gameConf.enable_bot_mode = strtol(valbuf, nullptr, 10); gameConf.enable_bot_mode = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "quick_animation")) { } else if(!std::strcmp(strbuf, "quick_animation")) {
gameConf.quick_animation = strtol(valbuf, nullptr, 10); gameConf.quick_animation = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "auto_save_replay")) { } else if(!std::strcmp(strbuf, "auto_save_replay")) {
gameConf.auto_save_replay = strtol(valbuf, nullptr, 10); gameConf.auto_save_replay = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "draw_single_chain")) { } else if(!std::strcmp(strbuf, "draw_single_chain")) {
gameConf.draw_single_chain = strtol(valbuf, nullptr, 10); gameConf.draw_single_chain = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "hide_player_name")) { } else if(!std::strcmp(strbuf, "hide_player_name")) {
gameConf.hide_player_name = strtol(valbuf, nullptr, 10); gameConf.hide_player_name = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "prefer_expansion_script")) { } else if(!std::strcmp(strbuf, "prefer_expansion_script")) {
gameConf.prefer_expansion_script = strtol(valbuf, nullptr, 10); gameConf.prefer_expansion_script = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "window_maximized")) { } else if(!std::strcmp(strbuf, "window_maximized")) {
gameConf.window_maximized = strtol(valbuf, nullptr, 10) > 0; gameConf.window_maximized = std::strtol(valbuf, nullptr, 10) > 0;
} else if(!std::strcmp(strbuf, "window_width")) { } else if(!std::strcmp(strbuf, "window_width")) {
gameConf.window_width = strtol(valbuf, nullptr, 10); gameConf.window_width = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "window_height")) { } else if(!std::strcmp(strbuf, "window_height")) {
gameConf.window_height = strtol(valbuf, nullptr, 10); gameConf.window_height = std::strtol(valbuf, nullptr, 10);
} else if(!std::strcmp(strbuf, "resize_popup_menu")) { } else if(!std::strcmp(strbuf, "resize_popup_menu")) {
gameConf.resize_popup_menu = strtol(valbuf, nullptr, 10) > 0; gameConf.resize_popup_menu = std::strtol(valbuf, nullptr, 10) > 0;
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
} else if(!std::strcmp(strbuf, "enable_sound")) { } else if(!std::strcmp(strbuf, "enable_sound")) {
gameConf.enable_sound = strtol(valbuf, nullptr, 10) > 0; gameConf.enable_sound = std::strtol(valbuf, nullptr, 10) > 0;
} else if(!std::strcmp(strbuf, "sound_volume")) { } else if(!std::strcmp(strbuf, "sound_volume")) {
int vol = strtol(valbuf, nullptr, 10); int vol = std::strtol(valbuf, nullptr, 10);
if (vol < 0) if (vol < 0)
vol = 0; vol = 0;
else if (vol > 100) else if (vol > 100)
vol = 100; vol = 100;
gameConf.sound_volume = (double)vol / 100; gameConf.sound_volume = (double)vol / 100;
} else if(!std::strcmp(strbuf, "enable_music")) { } else if(!std::strcmp(strbuf, "enable_music")) {
gameConf.enable_music = strtol(valbuf, nullptr, 10) > 0; gameConf.enable_music = std::strtol(valbuf, nullptr, 10) > 0;
} else if(!std::strcmp(strbuf, "music_volume")) { } else if(!std::strcmp(strbuf, "music_volume")) {
int vol = strtol(valbuf, nullptr, 10); int vol = std::strtol(valbuf, nullptr, 10);
if (vol < 0) if (vol < 0)
vol = 0; vol = 0;
else if (vol > 100) else if (vol > 100)
vol = 100; vol = 100;
gameConf.music_volume = (double)vol / 100; gameConf.music_volume = (double)vol / 100;
} else if(!std::strcmp(strbuf, "music_mode")) { } else if(!std::strcmp(strbuf, "music_mode")) {
gameConf.music_mode = strtol(valbuf, nullptr, 10); gameConf.music_mode = std::strtol(valbuf, nullptr, 10);
#endif #endif
} else { } else {
// options allowing multiple words // options allowing multiple words
......
...@@ -400,7 +400,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -400,7 +400,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
char arg3[8]; char arg3[8];
std::snprintf(arg3, sizeof arg3, "%d", mainGame->gameConf.serverport); std::snprintf(arg3, sizeof arg3, "%d", mainGame->gameConf.serverport);
execl("./bot", "bot", arg1, arg2, arg3, nullptr); execl("./bot", "bot", arg1, arg2, arg3, nullptr);
exit(0); std::exit(0);
} else { } else {
if(!NetServer::StartServer(mainGame->gameConf.serverport)) { if(!NetServer::StartServer(mainGame->gameConf.serverport)) {
soundManager.PlaySoundEffect(SOUND_INFO); soundManager.PlaySoundEffect(SOUND_INFO);
......
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