#include <cctype>
#include <cstdlib>
+#include <ctime>
#include <fstream>
#include <iostream>
#include <SDL.h>
int port;
in.ReadNumber(port);
net.port = port;
+ } else if (name == "net.cmd_port") {
+ int port;
+ in.ReadNumber(port);
+ net.cmd_port = port;
} else if (name == "player.name") {
in.ReadString(player.name);
} else if (name == "video.dblbuf") {
out << "input.yaw_sensitivity = " << input.yaw_sensitivity << ';' << std::endl;
out << "net.host = \"" << net.host << "\";" << std::endl;
out << "net.port = " << net.port << ';' << std::endl;
+ out << "net.cmd_port = " << net.cmd_port << ';' << std::endl;
out << "player.name = \"" << player.name << "\";" << std::endl;
out << "video.dblbuf = " << (video.dblbuf ? "on" : "off") << ';' << std::endl;
out << "video.vsync = " << (video.vsync ? "on" : "off") << ';' << std::endl;
} else {
config.game.net.port = strtoul(argv[i], nullptr, 10);
}
+ } else if (strcmp(param, "cmd-port") == 0) {
+ ++i;
+ if (i >= argc || argv[i] == nullptr || argv[i][0] == '\0') {
+ cerr << "missing argument to --cmd-port" << endl;
+ error = true;
+ } else {
+ config.game.net.cmd_port = strtoul(argv[i], nullptr, 10);
+ }
} else if (strcmp(param, "player-name") == 0) {
++i;
if (i >= argc || argv[i] == nullptr || argv[i][0] == '\0') {
} else {
mode = NORMAL;
}
-}
-void Runtime::ReadPreferences() {
if (config.env.asset_path.empty()) {
config.env.asset_path = default_asset_path();
} else if (
- config.env.asset_path[config.env.asset_path.size() - 1] != '/' &&
- config.env.asset_path[config.env.asset_path.size() - 1] != '\\'
+ config.env.asset_path.back() != '/' &&
+ config.env.asset_path.back() != '\\'
) {
config.env.asset_path += '/';
}
if (config.env.save_path.empty()) {
config.env.save_path = default_save_path();
} else if (
- config.env.save_path[config.env.save_path.size() - 1] != '/' &&
- config.env.save_path[config.env.save_path.size() - 1] != '\\'
+ config.env.save_path.back() != '/' &&
+ config.env.save_path.back() != '\\'
) {
config.env.save_path += '/';
}
+}
+void Runtime::ReadPreferences() {
string prefs_path = config.env.save_path + "prefs.conf";
if (is_file(prefs_path)) {
ifstream file(prefs_path);