summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp82
1 files changed, 42 insertions, 40 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 700e5676..2d6b08a8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -140,16 +140,15 @@ struct Options
printHelp(false),
printVersion(false),
skipUpdate(false),
- chooseDefault(false),
serverPort(0)
{};
bool printHelp;
bool printVersion;
bool skipUpdate;
- bool chooseDefault;
- std::string playername;
+ std::string username;
std::string password;
+ std::string character;
std::string configPath;
std::string updateHost;
std::string dataPath;
@@ -169,7 +168,7 @@ void setUpdatesDir()
// If updatesHost is currently empty, fill it from config file
if (updateHost.empty()) {
updateHost =
- config.getValue("updatehost", "http://updates.thanaworld.org");
+ config.getValue("updatehost", "http://updates.themanaworld.org");
}
// Remove any trailing slash at the end of the update host
@@ -455,10 +454,9 @@ void printHelp()
" -d --data : Directory to load game data from\n"
" -U --username : Login with this username\n"
" -P --password : Login with this password\n"
- " -D --default : Bypass the login process with default settings\n"
" -s --server : Login Server name or IP\n"
" -o --port : Login Server Port\n"
- " -p --playername : Login with this player\n"
+ " -c --character : Login with this character\n"
" -C --configfile : Configuration file to use\n"
" -H --updatehost : Use this update host\n";
}
@@ -475,7 +473,7 @@ void printVersion()
void parseOptions(int argc, char *argv[], Options &options)
{
- const char *optstring = "hvud:U:P:Dp:s:o:C:H:";
+ const char *optstring = "hvud:U:P:Dc:s:o:C:H:";
const struct option long_options[] = {
{ "help", no_argument, 0, 'h' },
@@ -484,17 +482,15 @@ void parseOptions(int argc, char *argv[], Options &options)
{ "data", required_argument, 0, 'd' },
{ "username", required_argument, 0, 'U' },
{ "password", required_argument, 0, 'P' },
- { "default", no_argument, 0, 'D' },
{ "server", required_argument, 0, 's' },
{ "port", required_argument, 0, 'o' },
- { "playername", required_argument, 0, 'p' },
+ { "character", required_argument, 0, 'c' },
{ "configfile", required_argument, 0, 'C' },
{ "updatehost", required_argument, 0, 'H' },
{ 0 }
};
while (optind < argc) {
-
int result = getopt_long(argc, argv, optstring, long_options, NULL);
if (result == -1)
@@ -515,22 +511,19 @@ void parseOptions(int argc, char *argv[], Options &options)
options.dataPath = optarg;
break;
case 'U':
- options.playername = optarg;
+ options.username = optarg;
break;
case 'P':
options.password = optarg;
break;
- case 'D':
- options.chooseDefault = true;
- break;
case 's':
options.serverName = optarg;
break;
case 'o':
options.serverPort = (short)atoi(optarg);
break;
- case 'p':
- options.playername = optarg;
+ case 'c':
+ options.character = optarg;
break;
case 'C':
options.configPath = optarg;
@@ -855,7 +848,7 @@ int main(int argc, char *argv[])
loginData.port = options.serverPort;
}
- loginData.username = options.playername;
+ loginData.username = options.username;
if (loginData.username.empty()) {
if (config.getValue("remember", 0)) {
loginData.username = config.getValue("username", "");
@@ -920,7 +913,16 @@ int main(int argc, char *argv[])
}
}
- graphics->drawImage(login_wallpaper, 0, 0);
+ if (graphics->getWidth() > login_wallpaper->getWidth() ||
+ graphics->getHeight() > login_wallpaper->getHeight())
+ {
+ graphics->setColor(gcn::Color(64, 64, 64));
+ graphics->fillRectangle(gcn::Rectangle(
+ 0, 0, graphics->getWidth(), graphics->getHeight()));
+ }
+ graphics->drawImage(login_wallpaper,
+ (graphics->getWidth() - login_wallpaper->getWidth()) / 2,
+ (graphics->getHeight() - login_wallpaper->getHeight()) / 2);
gui->draw();
graphics->updateScreen();
@@ -980,16 +982,16 @@ int main(int argc, char *argv[])
logger->log("State: CHOOSE_SERVER");
// Allow changing this using a server choice dialog
- // We show the dialog box only if the command-line options
- // weren't set.
+ // We show the dialog box only if the command-line
+ // options weren't set.
if (options.serverName.empty() && options.serverPort == 0) {
currentDialog = new ServerDialog(&loginData);
} else {
state = STATE_CONNECT_ACCOUNT;
- // Reset options so that cancelling or connect timeout
- // will show the server dialog
- options.serverName = "";
+ // Reset options so that cancelling or connect
+ // timeout will show the server dialog.
+ options.serverName.clear();
options.serverPort = 0;
}
break;
@@ -999,7 +1001,8 @@ int main(int argc, char *argv[])
logger->log("Trying to connect to account server...");
accountServerConnection->connect(loginData.hostname,
loginData.port);
- currentDialog = new ConnectionDialog(STATE_SWITCH_ACCOUNTSERVER_ATTEMPT);
+ currentDialog = new ConnectionDialog(
+ STATE_SWITCH_ACCOUNTSERVER_ATTEMPT);
break;
case STATE_UPDATE:
@@ -1017,11 +1020,15 @@ int main(int argc, char *argv[])
case STATE_LOGIN:
logger->log("State: LOGIN");
- currentDialog = new LoginDialog(&loginData);
- // TODO: Restore autologin
- //if (!loginData.password.empty()) {
- // accountLogin(&loginData);
- //}
+ if (options.username.empty()
+ || options.password.empty()) {
+ currentDialog = new LoginDialog(&loginData);
+ } else {
+ state = STATE_LOGIN_ATTEMPT;
+ // Clear the password so that when login fails, the
+ // dialog will show up next time.
+ options.password.clear();
+ }
break;
case STATE_LOADDATA:
@@ -1080,20 +1087,15 @@ int main(int argc, char *argv[])
case STATE_CHAR_SELECT:
logger->log("State: CHAR_SELECT");
currentDialog =
- new CharSelectDialog(&charInfo, &loginData);
+ new CharSelectDialog(&charInfo, &loginData);
if (((CharSelectDialog*) currentDialog)->
- selectByName(options.playername))
- options.chooseDefault = true;
- else
- ((CharSelectDialog*) currentDialog)->selectByName(
- config.getValue("lastCharacter", ""));
-
- if (options.chooseDefault)
- {
+ selectByName(options.character)) {
((CharSelectDialog*) currentDialog)->action(
gcn::ActionEvent(NULL, "ok"));
- options.chooseDefault = false;
+ } else {
+ ((CharSelectDialog*) currentDialog)->selectByName(
+ config.getValue("lastCharacter", ""));
}
break;
@@ -1106,7 +1108,7 @@ int main(int argc, char *argv[])
case STATE_CHANGEEMAIL:
logger->log("State: CHANGE EMAIL");
currentDialog = new OkDialog("Email Address change",
- "Email Address changed successfully!");
+ "Email Address changed successfully!");
currentDialog->addActionListener(&accountListener);
currentDialog = NULL; // OkDialog deletes itself
loginData.email = loginData.newEmail;