From 21dc5bb7a3ec09dafb41bc84050a2f5fbe0f9311 Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Thu, 14 Sep 2006 01:29:30 +0000 Subject: src/gui/char_select.cpp, src/main.cpp: Fix the character name matching loop and add support for saving the last used character (based on a patch by Andrew Harrison). --- ChangeLog | 3 +++ src/gui/char_select.cpp | 4 ++++ src/main.cpp | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index ea6d7b32..4938dc7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,9 @@ 2006-09-14 Björn Steinbrink + * src/gui/char_select.cpp, src/main.cpp: Fix the character name + matching loop and add support for saving the last used character + (based on a patch by Andrew Harrison). * src/gui/char_select.cpp, src/gui/char_select.h, src/main.cpp: Clean up the player selection stuff, it's a bit nicer now. * src/main.cpp: Fix up the player selection command line option. diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 6da0f64d..4aacd40e 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -23,6 +23,7 @@ #include "char_select.h" +#include #include #include @@ -238,9 +239,12 @@ bool CharSelectDialog::selectByName(const std::string &name) mCharInfo->select(0); do { LocalPlayer *player = mCharInfo->getEntry(); + std::cout << name << " " << (player ? player->getName() : "") << "\n"; if (player && player->getName() == name) return true; + + mCharInfo->next(); } while (mCharInfo->getPos()); mCharInfo->select(oldPos); diff --git a/src/main.cpp b/src/main.cpp index 0d4b54d7..08fc7a56 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -468,6 +468,10 @@ void charLogin(Network *network, LoginData *loginData) void mapLogin(Network *network, LoginData *loginData) { + logger->log("Memorizing selected character %s", + player_node->getName().c_str()); + config.setValue("lastCharacter", player_node->getName()); + MessageOut outMsg(network); logger->log("Trying to connect to map server..."); @@ -657,6 +661,9 @@ int main(int argc, char *argv[]) if (((CharSelectDialog*)currentDialog)-> selectByName(options.playername)) options.chooseDefault = true; + else + ((CharSelectDialog*)currentDialog)->selectByName( + config.getValue("lastCharacter", "")); if (options.chooseDefault) ((CharSelectDialog*)currentDialog)->action("ok", NULL); -- cgit v1.2.3-60-g2f50