From 4423d208ad7dc1ed3967d715642595f4fd1e6faf Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Wed, 13 Sep 2006 22:34:17 +0000 Subject: Fix up the player selection command line option. --- src/main.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 17d00949..127b2a84 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -653,23 +653,24 @@ int main(int argc, char *argv[]) logger->log("State: CHAR_SELECT"); currentDialog = new CharSelectDialog(network, &charInfo, 1 - loginData.sex); + if (options.playername != "") { - n_character = 0; - while (((CharSelectDialog*) currentDialog)->getName() - != options.playername && - n_character < MAX_SLOT + 1) - { - ((CharSelectDialog*) currentDialog)->action("next", - NULL); - ((CharSelectDialog*) currentDialog)->updatePlayerInfo(); - n_character++; - } - n_character = MAX_SLOT + 1; - } - if (options.chooseDefault || options.playername != "") { - ((CharSelectDialog*)currentDialog)->action("ok", - NULL); + charInfo.select(0); + do { + LocalPlayer *player = charInfo.getEntry(); + + if (player && player->getName() == + options.playername) { + options.chooseDefault = true; + break; + } + + charInfo.next(); + } while (charInfo.getPos()); } + + if (options.chooseDefault) + ((CharSelectDialog*)currentDialog)->action("ok", NULL); break; case GAME_STATE: -- cgit v1.2.3-70-g09d2