Commit 8893caac authored by wind2009's avatar wind2009

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

parents 9dad9524 898b4687
......@@ -46,7 +46,7 @@
#endif
#include <cstdio>
#include <stdlib.h>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
......
......@@ -91,10 +91,10 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
if(reader == nullptr)
return false;
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();
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->drop();
(mem->data)[mem->total] = '\0';
......
......@@ -196,7 +196,7 @@ int DeckManager::LoadDeck(Deck& deck, std::istringstream& deckStream, bool is_pa
if (linebuf[0] < '0' || linebuf[0] > '9')
continue;
errno = 0;
code = strtol(linebuf.c_str(), nullptr, 10);
code = std::strtol(linebuf.c_str(), nullptr, 10);
if (errno == ERANGE)
continue;
cardlist[ct++] = code;
......
......@@ -1368,13 +1368,13 @@ void Game::LoadConfig() {
if (std::sscanf(linebuf, "%63s = %959s", strbuf, valbuf) != 2)
continue;
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")) {
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")) {
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")) {
unsigned int val = strtol(valbuf, nullptr, 10);
unsigned int val = std::strtol(valbuf, nullptr, 10);
enable_log = val & 0xff;
} else if(!std::strcmp(strbuf, "textfont")) {
int textfontsize = 0;
......@@ -1385,94 +1385,94 @@ void Game::LoadConfig() {
} else if(!std::strcmp(strbuf, "numfont")) {
BufferIO::DecodeUTF8(valbuf, gameConf.numfont);
} 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")) {
BufferIO::DecodeUTF8(valbuf, gameConf.lasthost);
} else if(!std::strcmp(strbuf, "lastport")) {
BufferIO::DecodeUTF8(valbuf, gameConf.lastport);
} 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")) {
gameConf.chkSTAutoPos = strtol(valbuf, nullptr, 10);
gameConf.chkSTAutoPos = std::strtol(valbuf, nullptr, 10);
} 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")) {
gameConf.chkAutoChain = strtol(valbuf, nullptr, 10);
gameConf.chkAutoChain = std::strtol(valbuf, nullptr, 10);
} 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")) {
gameConf.chkDefaultShowChain = strtol(valbuf, nullptr, 10);
gameConf.chkDefaultShowChain = std::strtol(valbuf, nullptr, 10);
} 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")) {
gameConf.chkIgnore2 = strtol(valbuf, nullptr, 10);
gameConf.chkIgnore2 = std::strtol(valbuf, nullptr, 10);
} 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")) {
gameConf.default_lflist = strtol(valbuf, nullptr, 10);
gameConf.default_lflist = std::strtol(valbuf, nullptr, 10);
} 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)
gameConf.default_rule = DEFAULT_DUEL_RULE;
} 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")) {
gameConf.hide_hint_button = strtol(valbuf, nullptr, 10);
gameConf.hide_hint_button = std::strtol(valbuf, nullptr, 10);
} 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")) {
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")) {
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")) {
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")) {
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")) {
gameConf.chkIgnoreDeckChanges = strtol(valbuf, nullptr, 10);
gameConf.chkIgnoreDeckChanges = std::strtol(valbuf, nullptr, 10);
} 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")) {
gameConf.enable_bot_mode = strtol(valbuf, nullptr, 10);
gameConf.enable_bot_mode = std::strtol(valbuf, nullptr, 10);
} 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")) {
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")) {
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")) {
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")) {
gameConf.prefer_expansion_script = strtol(valbuf, nullptr, 10);
gameConf.prefer_expansion_script = std::strtol(valbuf, nullptr, 10);
} 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")) {
gameConf.window_width = strtol(valbuf, nullptr, 10);
gameConf.window_width = std::strtol(valbuf, nullptr, 10);
} 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")) {
gameConf.resize_popup_menu = strtol(valbuf, nullptr, 10) > 0;
gameConf.resize_popup_menu = std::strtol(valbuf, nullptr, 10) > 0;
#ifdef YGOPRO_USE_IRRKLANG
} 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")) {
int vol = strtol(valbuf, nullptr, 10);
int vol = std::strtol(valbuf, nullptr, 10);
if (vol < 0)
vol = 0;
else if (vol > 100)
vol = 100;
gameConf.sound_volume = (double)vol / 100;
} 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")) {
int vol = strtol(valbuf, nullptr, 10);
int vol = std::strtol(valbuf, nullptr, 10);
if (vol < 0)
vol = 0;
else if (vol > 100)
vol = 100;
gameConf.music_volume = (double)vol / 100;
} else if(!std::strcmp(strbuf, "music_mode")) {
gameConf.music_mode = strtol(valbuf, nullptr, 10);
gameConf.music_mode = std::strtol(valbuf, nullptr, 10);
#endif
} else {
// options allowing multiple words
......
......@@ -400,7 +400,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
char arg3[8];
std::snprintf(arg3, sizeof arg3, "%d", mainGame->gameConf.serverport);
execl("./bot", "bot", arg1, arg2, arg3, nullptr);
exit(0);
std::exit(0);
} else {
if(!NetServer::StartServer(mainGame->gameConf.serverport)) {
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