summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog24
-rw-r--r--src/gui/char_server.cpp125
-rw-r--r--src/gui/char_server.h68
-rw-r--r--src/main.cpp41
-rw-r--r--src/net/loginhandler.cpp18
-rw-r--r--src/net/loginhandler.h8
-rw-r--r--tmw.cbp10
7 files changed, 46 insertions, 248 deletions
diff --git a/ChangeLog b/ChangeLog
index 8ab60c64..2af8e09a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-07-26 Eugenio Favalli <elvenprogrammer@gmail.com>
+
+ * 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 <bjorn@lindeijer.nl>
* 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 <elvenprogrammer@gmail.com>
+
+ * 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 <bjorn@lindeijer.nl>
* 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 <guichan/actionlistener.hpp>
-#include <guichan/listmodel.hpp>
-
-#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<Spriteset *> 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<LocalPlayer*> *charInfo) { mCharInfo = charInfo; };
+
void setLoginData(LoginData *loginData) { mLoginData = loginData; };
protected:
LoginData *mLoginData;
+ LockedArray<LocalPlayer*> *mCharInfo;
};
#endif
diff --git a/tmw.cbp b/tmw.cbp
index 9f764a5f..ec9438d6 100644
--- a/tmw.cbp
+++ b/tmw.cbp
@@ -225,17 +225,7 @@
<Option target="default" />
</Unit>
<Unit filename="src\gui\char_select.h">
- <Option compilerVar="" />
- <Option compile="0" />
- <Option link="0" />
- <Option target="default" />
- </Unit>
- <Unit filename="src\gui\char_server.cpp">
<Option compilerVar="CPP" />
- <Option target="default" />
- </Unit>
- <Unit filename="src\gui\char_server.h">
- <Option compilerVar="" />
<Option compile="0" />
<Option link="0" />
<Option target="default" />