From c7e7b62aa94bf295ca1dc556762ad6070221e0cd Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Tue, 25 Jul 2006 18:04:38 +0000 Subject: Switched client to use enet and modified login sequence to work with the new protocol from tmwserv. --- src/gui/buy.cpp | 10 +++++----- src/gui/char_select.cpp | 34 +++++++++++++++++----------------- src/gui/chat.cpp | 16 ++++++++-------- src/gui/sell.cpp | 10 +++++----- src/gui/trade.cpp | 28 ++++++++++++++-------------- 5 files changed, 49 insertions(+), 49 deletions(-) (limited to 'src/gui') diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 86bd5413..e96cc04f 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -216,11 +216,11 @@ void BuyDialog::action(const std::string& eventId) // there a better way to ensure this fails in an _obivous_ way in C++? else if (eventId == "buy" && (mAmountItems > 0 && mAmountItems <= mMaxItems)) { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_BUY_REQUEST); - outMsg.writeInt16(8); - outMsg.writeInt16(mAmountItems); - outMsg.writeInt16(mShopItems->at(selectedItem).id); + MessageOut outMsg; + outMsg.writeShort(CMSG_NPC_BUY_REQUEST); + outMsg.writeShort(8); + outMsg.writeShort(mAmountItems); + outMsg.writeShort(mShopItems->at(selectedItem).id); // update money ! mMoney -= mAmountItems * mShopItems->at(selectedItem).price; diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 801b0ffe..e8aa84e0 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -207,9 +207,9 @@ void CharSelectDialog::updatePlayerInfo() void CharSelectDialog::attemptCharDelete() { // Request character deletion - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0068); - outMsg.writeInt32(mCharInfo->getEntry()->mCharId); + MessageOut outMsg; + outMsg.writeShort(0x0068); + outMsg.writeLong(mCharInfo->getEntry()->mCharId); outMsg.writeString("a@a.com", 40); mCharInfo->lock(); } @@ -217,9 +217,9 @@ void CharSelectDialog::attemptCharDelete() void CharSelectDialog::attemptCharSelect() { // Request character selection - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0066); - outMsg.writeInt8(mCharInfo->getPos()); + MessageOut outMsg; + outMsg.writeShort(0x0066); + outMsg.writeByte(mCharInfo->getPos()); mCharInfo->lock(); } @@ -326,16 +326,16 @@ std::string CharCreateDialog::getName() void CharCreateDialog::attemptCharCreate() { // Send character infos - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0067); + MessageOut outMsg; + outMsg.writeShort(0x0067); outMsg.writeString(getName(), 24); - outMsg.writeInt8(5); - outMsg.writeInt8(5); - outMsg.writeInt8(5); - outMsg.writeInt8(5); - outMsg.writeInt8(5); - outMsg.writeInt8(5); - outMsg.writeInt8(mSlot); - outMsg.writeInt16(mPlayerBox->mHairColor + 1); - outMsg.writeInt16(mPlayerBox->mHairStyle + 1); + outMsg.writeByte(5); + outMsg.writeByte(5); + outMsg.writeByte(5); + outMsg.writeByte(5); + outMsg.writeByte(5); + outMsg.writeByte(5); + outMsg.writeByte(mSlot); + outMsg.writeShort(mPlayerBox->mHairColor + 1); + outMsg.writeShort(mPlayerBox->mHairStyle + 1); } diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 64b56caf..870582df 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -261,9 +261,9 @@ ChatWindow::chatSend(const std::string &nick, std::string msg) if (msg.substr(0, IS_ANNOUNCE_LENGTH) == IS_ANNOUNCE) { msg.erase(0, IS_ANNOUNCE_LENGTH); - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0099); - outMsg.writeInt16(msg.length() + 4); + MessageOut outMsg; + outMsg.writeShort(0x0099); + outMsg.writeShort(msg.length() + 4); outMsg.writeString(msg, msg.length()); } else if (msg.substr(0, IS_HELP_LENGTH) == IS_HELP) @@ -280,8 +280,8 @@ ChatWindow::chatSend(const std::string &nick, std::string msg) } else if (msg.substr(0, IS_WHO_LENGTH) == IS_WHO) { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x00c1); + MessageOut outMsg; + outMsg.writeShort(0x00c1); } else { @@ -292,9 +292,9 @@ ChatWindow::chatSend(const std::string &nick, std::string msg) else { msg = nick + " : " + msg; - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_CHAT_MESSAGE); - outMsg.writeInt16(msg.length() + 4); + MessageOut outMsg; + outMsg.writeShort(CMSG_CHAT_MESSAGE); + outMsg.writeShort(msg.length() + 4); outMsg.writeString(msg, msg.length()); } } diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index ec565ac3..0b7abf6f 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -213,11 +213,11 @@ void SellDialog::action(const std::string& eventId) // Attempt sell assert(mAmountItems > 0 && mAmountItems <= mMaxItems); - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_SELL_REQUEST); - outMsg.writeInt16(8); - outMsg.writeInt16(mShopItems->at(selectedItem).index); - outMsg.writeInt16(mAmountItems); + MessageOut outMsg; + outMsg.writeShort(CMSG_NPC_SELL_REQUEST); + outMsg.writeShort(8); + outMsg.writeShort(mShopItems->at(selectedItem).index); + outMsg.writeShort(mAmountItems); mMaxItems -= mAmountItems; mAmountItems = 0; diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 9b98fa09..4efdb06c 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -215,10 +215,10 @@ void TradeWindow::receivedOk(bool own) void TradeWindow::tradeItem(Item *item, int quantity) { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST); - outMsg.writeInt16(item->getInvIndex()); - outMsg.writeInt32(quantity); + MessageOut outMsg; + outMsg.writeShort(CMSG_TRADE_ITEM_ADD_REQUEST); + outMsg.writeShort(item->getInvIndex()); + outMsg.writeLong(quantity); } void TradeWindow::mouseClick(int x, int y, int button, int count) @@ -287,8 +287,8 @@ void TradeWindow::action(const std::string &eventId) } else if (eventId == "cancel") { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_CANCEL_REQUEST); + MessageOut outMsg; + outMsg.writeShort(CMSG_TRADE_CANCEL_REQUEST); } else if (eventId == "ok") { @@ -298,20 +298,20 @@ void TradeWindow::action(const std::string &eventId) { mMoneyField->setText(toString(tempInt)); - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST); - outMsg.writeInt16(0); - outMsg.writeInt32(tempInt); + MessageOut outMsg; + outMsg.writeShort(CMSG_TRADE_ITEM_ADD_REQUEST); + outMsg.writeShort(0); + outMsg.writeLong(tempInt); } else { mMoneyField->setText(""); } mMoneyField->setEnabled(false); - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_ADD_COMPLETE); + MessageOut outMsg; + outMsg.writeShort(CMSG_TRADE_ADD_COMPLETE); } else if (eventId == "trade") { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_OK); + MessageOut outMsg; + outMsg.writeShort(CMSG_TRADE_OK); } } -- cgit v1.2.3-60-g2f50 From 33e19fb0822308a630ca6e1122b9b97882a120a7 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Tue, 25 Jul 2006 19:21:22 +0000 Subject: Fixed Linux compiling issues and merged update system fix for Windows. --- ChangeLog | 6 ++++++ NEWS | 5 ++++- configure.ac | 6 +++--- src/gui/updatewindow.cpp | 11 +++++++---- src/net/beinghandler.cpp | 2 +- src/net/network.cpp | 8 ++++---- 6 files changed, 25 insertions(+), 13 deletions(-) (limited to 'src/gui') diff --git a/ChangeLog b/ChangeLog index 67b6a585..662d0b5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-07-25 Bjørn Lindeijer + + * src/gui/updatewindow.cpp: Fixed updating on Windows. + * src/net/beinghandler.cpp, src/net/network.cpp, configure.ac: Fixed + Linux compiling issues. + 2006-07-24 Bjørn Lindeijer * src/main.cpp: Fixed the loading of updates and made skipping the diff --git a/NEWS b/NEWS index b1d48891..ad78fc4f 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,7 @@ -0.0.20 (23 July 2006) +0.0.20.1 (25 July 2006) +- Fixed updating system on Windows + +0.0.20 (24 July 2006) - Added new hairstyle, and some fixes to the old ones - Added slider to set FPS limit - Added visible equipments diff --git a/configure.ac b/configure.ac index a4a3eef6..ce30607f 100755 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.59) -AC_INIT([The Mana World], [0.0.20], [elvenprogrammer@gmail.com], [tmw]) +AC_INIT([The Mana World], [0.1.0], [elvenprogrammer@gmail.com], [tmw]) AC_CONFIG_HEADERS([config.h:config.h.in]) AC_LANG_CPLUSPLUS @@ -43,8 +43,8 @@ AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio, , AC_MSG_ERROR([ *** Unable to find SDL_mixer library (http://www.libsdl.org/projects/SDL_mixer/)])) -AC_CHECK_LIB(SDL_net, SDLNet_Init, , -AC_MSG_ERROR([ *** Unable to find SDL_net library])) +AC_CHECK_LIB([enet], [enet_initialize], , +AC_MSG_ERROR([ *** Unable to find enet library (enet.bespin.org)])) AC_CHECK_LIB(png, png_write_info, , AC_MSG_ERROR([ *** Unable to find png library])) diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 8f43903f..3f5fe7bb 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -106,8 +106,7 @@ UpdaterWindow::~UpdaterWindow() free(mMemoryBuffer); } - // Remove downloaded files - remove((mBasePath + "/updates/news.txt").c_str()); + // Remove possibly leftover temporary download remove((mBasePath + "/updates/download.temp").c_str()); delete[] mCurlError; @@ -293,10 +292,14 @@ int UpdaterWindow::downloadThread(void *ptr) if (!uw->mStoreInMemory) { fclose(outfile); - // If the download was successful give the file the proper name - // else it will be deleted later + + // Give the file the proper name std::string newName(uw->mBasePath + "/updates/" + uw->mCurrentFile.c_str()); + + // Any existing file with this name is deleted first, otherwise the + // rename will fail on Windows. + remove(newName.c_str()); rename(outFilename.c_str(), newName.c_str()); } } diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index 68a46650..7730e9be 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -368,7 +368,7 @@ void BeingHandler::handleMessage(MessageIn *msg) case 0x0119: // Change in players look - printf("0x0119 %i %i %i %x %i\n", msg->readLong(), + printf("0x0119 %li %i %i %x %i\n", msg->readLong(), msg->readShort(), msg->readShort(), msg->readShort(), msg->readByte()); break; diff --git a/src/net/network.cpp b/src/net/network.cpp index 8278e266..aa18e888 100644 --- a/src/net/network.cpp +++ b/src/net/network.cpp @@ -40,13 +40,13 @@ Network::~Network() { clearHandlers(); - if (mState != IDLE && mState != ERROR) + if (mState != IDLE && mState != NET_ERROR) disconnect(); } bool Network::connect(const std::string &address, short port) { - if (mState != IDLE && mState != ERROR) + if (mState != IDLE && mState != NET_ERROR) { logger->log("Tried to connect an already connected socket!"); return false; @@ -55,7 +55,7 @@ bool Network::connect(const std::string &address, short port) if (address.empty()) { logger->log("Empty address given to Network::connect()!"); - mState = ERROR; + mState = NET_ERROR; return false; } @@ -84,7 +84,7 @@ bool Network::connect(const std::string &address, short port) if (mServer == 0) { logger->log("Unable to initiate connection to the server."); - mState = ERROR; + mState = NET_ERROR; return false; } -- cgit v1.2.3-60-g2f50 From 4b04c501e2391c9226595679c064510c6ea2e94c Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Wed, 26 Jul 2006 07:30:12 +0000 Subject: Removed char server selection dialog, and added character visualization in character selection dialog. --- ChangeLog | 24 +++++++++ src/gui/char_server.cpp | 125 ----------------------------------------------- src/gui/char_server.h | 68 -------------------------- src/main.cpp | 41 +--------------- src/net/loginhandler.cpp | 18 +++++-- src/net/loginhandler.h | 8 ++- tmw.cbp | 10 ---- 7 files changed, 46 insertions(+), 248 deletions(-) delete mode 100644 src/gui/char_server.cpp delete mode 100644 src/gui/char_server.h (limited to 'src/gui') diff --git a/ChangeLog b/ChangeLog index 8ab60c64..2af8e09a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-07-26 Eugenio Favalli + + * src/gui/char_server.cpp, src/gui/char_sever.h, src/main.cpp, + src/net/loginhandler.cpp, src/net/loginhandler.h, tmw,cbp: Removed char + server selection dialog, and added character visualization in character + selection dialog. + 2006-07-25 Bjørn Lindeijer * src/gui/updatewindow.cpp: Fixed updating on Windows. @@ -9,6 +16,23 @@ * src/main.cpp: Reorganized initialization somewhat. * src/resources/resourcemanager.cpp: Take into account singular form. +2006-07-25 Eugenio Favalli + + * src/beingmanager.cpp, src/engine.cpp, src/gui/buy.cpp, + src/gui/char_select.cpp,src/gui/chat.cpp, src/gui/sell.cpp, + src/gui/trade.cpp, src/localplayer.cpp, src/main.cpp, + src/net/beinghandler.cpp, src/net/buysellhandler.cpp, + src/net/charserverhandler.cpp, src/net/chathandler, + src/net/equipmenthandler.cpp, src/net/inventoryhandler.cpp, + src/net/itemhandler.cpp, src/net/loginhandler.cpp, + src/net/maploginhandler.cpp, src/net/messagein.cpp, + src/net/messagein.h, src/net/messageout.cpp, src/net/messageout.h, + src/net/network.cpp, src/net/network.h, src/net/npchandler.cpp, + src/net/playerhandler.cpp, src/net/protocol.h, + src/net/skillhandler.cpp, src/net/tradehandler.cpp, src/npc.cpp, + tmw.cbp: Switched client to use enet and modified login sequence to + work with the new protocol from tmwserv. + 2006-07-24 Bjørn Lindeijer * src/main.cpp: Fixed the loading of updates and made skipping the diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp deleted file mode 100644 index ad0df223..00000000 --- a/src/gui/char_server.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * The Mana World - * Copyright 2004 The Mana World Development Team - * - * This file is part of The Mana World. - * - * The Mana World is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * The Mana World is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with The Mana World; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -#include "char_server.h" - -#include "button.h" -#include "listbox.h" -#include "scrollarea.h" - -#include "../logindata.h" -#include "../main.h" -#include "../serverinfo.h" - -#include "../net/network.h" // TODO this is just for iptostring, move that? - -#include "../utils/tostring.h" - -extern SERVER_INFO **server_info; - -/** - * The list model for the server list. - */ -class ServerListModel : public gcn::ListModel { - public: - virtual ~ServerListModel() {}; - - int getNumberOfElements(); - std::string getElementAt(int i); -}; - -ServerSelectDialog::ServerSelectDialog(LoginData *loginData): - Window("Select Server"), mLoginData(loginData) -{ - mServerListModel = new ServerListModel(); - mServerList = new ListBox(mServerListModel); - ScrollArea *mScrollArea = new ScrollArea(mServerList); - mOkButton = new Button("OK", "ok", this); - Button *mCancelButton = new Button("Cancel", "cancel", this); - - setContentSize(200, 100); - - mCancelButton->setPosition( - 200 - mCancelButton->getWidth() - 5, - 100 - mCancelButton->getHeight() - 5); - mOkButton->setPosition( - mCancelButton->getX() - mOkButton->getWidth() - 5, - 100 - mOkButton->getHeight() - 5); - mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - mScrollArea->setDimension(gcn::Rectangle( - 5, 5, 200 - 2 * 5, - 100 - 3 * 5 - mCancelButton->getHeight() - - mScrollArea->getBorderSize())); - - mServerList->setEventId("ok"); - - //mServerList->addActionListener(this); - - add(mScrollArea); - add(mOkButton); - add(mCancelButton); - - if (n_server == 0) { - // Disable Ok button - mOkButton->setEnabled(false); - } else { - // Select first server - mServerList->setSelected(1); - } - - mOkButton->requestFocus(); - setLocationRelativeTo(getParent()); -} - -ServerSelectDialog::~ServerSelectDialog() -{ - delete mServerListModel; -} - -void -ServerSelectDialog::action(const std::string& eventId) -{ - if (eventId == "ok") { - mOkButton->setEnabled(false); - const SERVER_INFO *si = server_info[mServerList->getSelected()]; - mLoginData->hostname = iptostring(si->address); - mLoginData->port = si->port; - state = CHAR_CONNECT_STATE; - } - else if (eventId == "cancel") { - state = LOGIN_STATE; - } -} - -int -ServerListModel::getNumberOfElements() -{ - return n_server; -} - -std::string -ServerListModel::getElementAt(int i) -{ - const SERVER_INFO *si = server_info[i]; - return si->name + " (" + toString(si->online_users) + ")"; -} diff --git a/src/gui/char_server.h b/src/gui/char_server.h deleted file mode 100644 index 85ae2408..00000000 --- a/src/gui/char_server.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The Mana World - * Copyright 2004 The Mana World Development Team - * - * This file is part of The Mana World. - * - * The Mana World is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * The Mana World is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with The Mana World; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -#ifndef _CHAR_SEL_SERVER_H -#define _CHAR_SEL_SERVER_H - -#include -#include - -#include "window.h" - -#include "../guichanfwd.h" - -class LoginData; -class ServerListModel; - -/** - * The server select dialog. - * - * \ingroup Interface - */ -class ServerSelectDialog : public Window, public gcn::ActionListener { - public: - /** - * Constructor - * - * @see Window::Window - */ - ServerSelectDialog(LoginData *loginData); - - /** - * Destructor. - */ - ~ServerSelectDialog(); - - /** - * Called when receiving actions from the widgets. - */ - void action(const std::string& eventId); - - private: - LoginData *mLoginData; - ServerListModel *mServerListModel; - gcn::ListBox *mServerList; - gcn::Button *mOkButton; -}; - -#endif diff --git a/src/main.cpp b/src/main.cpp index ca70b0dc..deca661c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,7 +56,6 @@ #endif #include "sound.h" -#include "gui/char_server.h" #include "gui/char_select.h" #include "gui/connection.h" #include "gui/gui.h" @@ -81,16 +80,12 @@ #include "utils/tostring.h" // Account infos -char n_server, n_character; +char n_character; std::vector hairset; Spriteset *playerset[2]; Graphics *graphics; -// TODO Anyone knows a good location for this? Or a way to make it non-global? -class SERVER_INFO; -SERVER_INFO **server_info; - unsigned char state; std::string errorMessage; std::string homeDir; @@ -429,6 +424,7 @@ void accountLogin(Network *network, LoginData *loginData) logger->log("Username is %s", loginData->username.c_str()); network->connect(loginData->hostname, loginData->port); network->registerHandler(&loginHandler); + loginHandler.setCharInfo(&charInfo); loginHandler.setLoginData(loginData); // Send login infos @@ -451,24 +447,6 @@ void accountLogin(Network *network, LoginData *loginData) config.setValue("remember", loginData->remember); } -void charLogin(Network *network, LoginData *loginData) -{ - logger->log("Trying to connect to char server..."); - network->connect(loginData->hostname, loginData->port); - network->registerHandler(&charServerHandler); - charServerHandler.setCharInfo(&charInfo); - charServerHandler.setLoginData(loginData); - - // Send login infos - MessageOut outMsg; - outMsg.writeShort(0x0065); - outMsg.writeLong(loginData->account_ID); - outMsg.writeLong(loginData->session_ID1); - outMsg.writeLong(loginData->session_ID2); - outMsg.writeShort(0); // unknown - outMsg.writeByte(loginData->sex); -} - void mapLogin(Network *network, LoginData *loginData) { MessageOut outMsg; @@ -617,7 +595,6 @@ int main(int argc, char *argv[]) // Those states don't cause a network disconnect case ACCOUNT_STATE: - case CHAR_CONNECT_STATE: case CONNECTING_STATE: break; @@ -649,14 +626,6 @@ int main(int argc, char *argv[]) currentDialog = new RegisterDialog(&loginData); break; - case CHAR_SERVER_STATE: - logger->log("State: CHAR_SERVER"); - currentDialog = new ServerSelectDialog(&loginData); - if (options.chooseDefault) { - ((ServerSelectDialog*)currentDialog)->action("ok"); - } - break; - case CHAR_SELECT_STATE: logger->log("State: CHAR_SELECT"); currentDialog = new CharSelectDialog(network, &charInfo, @@ -700,11 +669,6 @@ int main(int argc, char *argv[]) currentDialog = new ConnectionDialog(); break; - case CHAR_CONNECT_STATE: - printf("Char: %i\n", loginData.sex); - charLogin(network, &loginData); - break; - case ACCOUNT_STATE: printf("Account: %i\n", loginData.sex); accountLogin(network, &loginData); @@ -717,7 +681,6 @@ int main(int argc, char *argv[]) } } - network->disconnect(); delete network; enet_deinitialize(); diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp index d65f7001..5b8fbd1f 100644 --- a/src/net/loginhandler.cpp +++ b/src/net/loginhandler.cpp @@ -27,12 +27,10 @@ #include "network.h" #include "protocol.h" +#include "../localplayer.h" #include "../log.h" #include "../logindata.h" #include "../main.h" -#include "../serverinfo.h" - -extern SERVER_INFO **server_info; LoginHandler::LoginHandler() { @@ -56,9 +54,19 @@ void LoginHandler::handleMessage(MessageIn *msg) charNumber = msg->readByte(); printf("Account has %i characters:\n", charNumber); for (unsigned int i = 0; i < charNumber; i++) { - printf("%i) %s\n", i, msg->readString().c_str()); + // Create a temp empty player to show up in character + // selection dialog + LocalPlayer *temp = new LocalPlayer(0, 0, 0); + temp->setName(msg->readString()); + temp->setSex(msg->readByte()); + temp->setHairStyle(msg->readByte()); + temp->setHairColor(msg->readByte()); + temp->mLevel = msg->readByte(); + temp->mGp = msg->readShort(); + mCharInfo->select(i); + mCharInfo->setEntry(temp); } - state = CHAR_SERVER_STATE; + state = CHAR_SELECT_STATE; } // Login failed else diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index 52014559..7d5d6f75 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -26,7 +26,10 @@ #include "messagehandler.h" -struct LoginData; +#include "../lockedarray.h" + +class LocalPlayer; +class LoginData; class LoginHandler : public MessageHandler { @@ -35,10 +38,13 @@ class LoginHandler : public MessageHandler void handleMessage(MessageIn *msg); + void setCharInfo(LockedArray *charInfo) { mCharInfo = charInfo; }; + void setLoginData(LoginData *loginData) { mLoginData = loginData; }; protected: LoginData *mLoginData; + LockedArray *mCharInfo; }; #endif diff --git a/tmw.cbp b/tmw.cbp index 9f764a5f..ec9438d6 100644 --- a/tmw.cbp +++ b/tmw.cbp @@ -225,17 +225,7 @@