summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/engine.cpp7
-rw-r--r--src/game.cpp1
-rw-r--r--src/main.cpp23
-rw-r--r--src/main.h1
-rw-r--r--src/net/charserverhandler.cpp16
-rw-r--r--src/net/network.cpp1
6 files changed, 31 insertions, 18 deletions
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;
diff --git a/src/main.h b/src/main.h
index 089f3f18..fbd7f4a4 100644
--- a/src/main.h
+++ b/src/main.h
@@ -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;