diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-20 14:29:05 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-20 14:29:05 +0000 |
commit | 292f3e50a59b06bf129893b352466d7d54fa3d71 (patch) | |
tree | 7150b66c08c3dd83e79baef52332922ba3ab324d | |
parent | 0c90838cef0d75e14097dc66c6b5210eef976029 (diff) | |
download | mana-client-292f3e50a59b06bf129893b352466d7d54fa3d71.tar.gz mana-client-292f3e50a59b06bf129893b352466d7d54fa3d71.tar.bz2 mana-client-292f3e50a59b06bf129893b352466d7d54fa3d71.tar.xz mana-client-292f3e50a59b06bf129893b352466d7d54fa3d71.zip |
Fixed selection of player character and implemented sending of game and chat
server tokens. It gets you in the game (or what's left of it), but not on any
map yet.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/engine.cpp | 7 | ||||
-rw-r--r-- | src/game.cpp | 1 | ||||
-rw-r--r-- | src/main.cpp | 23 | ||||
-rw-r--r-- | src/main.h | 1 | ||||
-rw-r--r-- | src/net/charserverhandler.cpp | 16 | ||||
-rw-r--r-- | src/net/network.cpp | 1 |
7 files changed, 36 insertions, 18 deletions
@@ -20,6 +20,11 @@ a bit of cleanup (peer pointers now stored in an array). * src/gui/register.cpp, src/main.h: Made cancel button in register dialog go back to the login dialog and cleaned up two unused states. + * src/game.cpp, src/engine.cpp, src/main.cpp, + src/net/charserverhandler.cpp, src/net/network.cpp, src/main.h: Fixed + selection of player character and implemented sending of game and chat + server tokens. It gets you in the game (or what's left of it), but not + on any map yet. 2006-08-19 Bjørn Lindeijer <bjorn@lindeijer.nl> diff --git a/src/engine.cpp b/src/engine.cpp index 84574b26..77f7f8ac 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -194,6 +194,13 @@ void Engine::draw(Graphics *graphics) mCurrentMap->draw(graphics, map_x, map_y, 1); mCurrentMap->draw(graphics, map_x, map_y, 2); } + else + { + // When no map is loaded, draw a replacement background + graphics->setColor(gcn::Color(128, 128, 128)); + graphics->fillRectangle(gcn::Rectangle(0, 0, + graphics->getWidth(), graphics->getHeight())); + } // Find a path from the player to the mouse, and draw it. This is for debug // purposes. diff --git a/src/game.cpp b/src/game.cpp index 2f62148c..b6428103 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -277,7 +277,6 @@ Game::Game(Network *network): // Initialize beings beingManager->setPlayer(player_node); player_node->setNetwork(network); - engine->changeMap(map_path); Joystick::init(); // TODO: The user should be able to choose which one to use diff --git a/src/main.cpp b/src/main.cpp index d62594c9..ef5557ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -80,6 +80,7 @@ // Account infos char n_character; +std::string token; std::vector<Spriteset *> hairset; Spriteset *playerset[2]; @@ -456,20 +457,16 @@ void accountRegister(LoginData *loginData) void mapLogin(Network *network, LoginData *loginData) { - // TODO: Before the client has been identified using the magic token, the - // map path is not known yet. - logger->log("Map: %s", map_path.c_str()); - network->registerHandler(&mapLoginHandler); - // Send login infos - // TODO: The token would need to be sent to complete client identification - // for the game server - //MessageOut outMsg(0x0072); - //outMsg.writeLong(loginData->account_ID); - //outMsg.writeLong(player_node->mCharId); - //outMsg.writeLong(loginData->session_ID1); - //outMsg.writeLong(loginData->session_ID2); + // Send connect messages with the magic token to game and chat servers + MessageOut gameServerConnect(PGMSG_CONNECT); + gameServerConnect.writeString(token, 32); + network->send(Network::GAME, gameServerConnect); + + MessageOut chatServerConnect(PCMSG_CONNECT); + chatServerConnect.writeString(token, 32); + network->send(Network::CHAT, chatServerConnect); } /** Main */ @@ -689,11 +686,11 @@ int main(int argc, char *argv[]) case STATE_CONNECT_GAME: logger->log("State: CONNECT_GAME"); - mapLogin(network, &loginData); currentDialog = new ConnectionDialog(); break; case STATE_GAME: + mapLogin(network, &loginData); sound.fadeOutMusic(1000); currentDialog = NULL; @@ -65,6 +65,7 @@ enum { }; extern char n_character; +extern std::string token; extern unsigned char state; extern std::string errorMessage; diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index ea9b3196..2bf2c4b4 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -163,10 +163,9 @@ CharServerHandler::handleCharSelectResponse(MessageIn &msg) { int errMsg = msg.readByte(); - if (errMsg == 0) + if (errMsg == ERRMSG_OK) { - // TODO: Somehow be able to send this token once connected - std::string token = msg.readString(32); + token = msg.readString(32); std::string gameServer = msg.readString(); unsigned short gameServerPort = msg.readShort(); std::string chatServer = msg.readString(); @@ -178,6 +177,17 @@ CharServerHandler::handleCharSelectResponse(MessageIn &msg) network->connect(Network::GAME, gameServer, gameServerPort); network->connect(Network::CHAT, chatServer, chatServerPort); + // Keep the selected character and delete the others + player_node = mCharInfo->getEntry(); + mCharInfo->unlock(); + mCharInfo->select(0); + do { + LocalPlayer *tmp = mCharInfo->getEntry(); + if (tmp != player_node) + delete tmp; + mCharInfo->next(); + } while (mCharInfo->getPos()); + state = STATE_CONNECT_GAME; } } diff --git a/src/net/network.cpp b/src/net/network.cpp index 911353b1..2ce6fc2b 100644 --- a/src/net/network.cpp +++ b/src/net/network.cpp @@ -192,7 +192,6 @@ void Network::flush() break; case ENET_EVENT_TYPE_RECEIVE: - logger->log("Incoming data..."); dispatchMessage(event.packet); break; |