summaryrefslogtreecommitdiff
path: root/src/net/manaserv
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-11-03 12:06:48 -0700
committerJared Adams <jaxad0127@gmail.com>2009-11-03 12:06:48 -0700
commite07e2a6db902f2ce0095b65708a98fa4dbf40aa0 (patch)
treeb91b3e3d3f06199dcc34e32834941964a263e0be /src/net/manaserv
parente2897e4a7cb7eb0c4a7e46d72a9a19b909368c26 (diff)
downloadmana-e07e2a6db902f2ce0095b65708a98fa4dbf40aa0.tar.gz
mana-e07e2a6db902f2ce0095b65708a98fa4dbf40aa0.tar.bz2
mana-e07e2a6db902f2ce0095b65708a98fa4dbf40aa0.tar.xz
mana-e07e2a6db902f2ce0095b65708a98fa4dbf40aa0.zip
Simplify ManaServ netcode some more
Diffstat (limited to 'src/net/manaserv')
-rw-r--r--src/net/manaserv/accountserver/account.cpp107
-rw-r--r--src/net/manaserv/accountserver/account.h54
-rw-r--r--src/net/manaserv/accountserver/accountserver.cpp86
-rw-r--r--src/net/manaserv/accountserver/accountserver.h47
-rw-r--r--src/net/manaserv/accountserver/internal.cpp32
-rw-r--r--src/net/manaserv/accountserver/internal.h35
-rw-r--r--src/net/manaserv/adminhandler.cpp10
-rw-r--r--src/net/manaserv/beinghandler.cpp5
-rw-r--r--src/net/manaserv/charhandler.cpp41
-rw-r--r--src/net/manaserv/chathandler.cpp33
-rw-r--r--src/net/manaserv/chatserver/chatserver.cpp57
-rw-r--r--src/net/manaserv/chatserver/chatserver.h44
-rw-r--r--src/net/manaserv/chatserver/guild.cpp16
-rw-r--r--src/net/manaserv/chatserver/internal.cpp32
-rw-r--r--src/net/manaserv/chatserver/internal.h35
-rw-r--r--src/net/manaserv/chatserver/party.cpp83
-rw-r--r--src/net/manaserv/chatserver/party.h61
-rw-r--r--src/net/manaserv/gamehandler.cpp14
-rw-r--r--src/net/manaserv/gameserver/gameserver.cpp53
-rw-r--r--src/net/manaserv/gameserver/gameserver.h39
-rw-r--r--src/net/manaserv/gameserver/internal.cpp32
-rw-r--r--src/net/manaserv/gameserver/internal.h35
-rw-r--r--src/net/manaserv/gameserver/player.cpp61
-rw-r--r--src/net/manaserv/gameserver/player.h51
-rw-r--r--src/net/manaserv/guildhandler.cpp1
-rw-r--r--src/net/manaserv/inventoryhandler.cpp27
-rw-r--r--src/net/manaserv/loginhandler.cpp67
-rw-r--r--src/net/manaserv/loginhandler.h2
-rw-r--r--src/net/manaserv/npchandler.cpp24
-rw-r--r--src/net/manaserv/partyhandler.cpp34
-rw-r--r--src/net/manaserv/playerhandler.cpp27
-rw-r--r--src/net/manaserv/playerhandler.h8
-rw-r--r--src/net/manaserv/specialhandler.cpp6
-rw-r--r--src/net/manaserv/tradehandler.cpp29
34 files changed, 214 insertions, 1074 deletions
diff --git a/src/net/manaserv/accountserver/account.cpp b/src/net/manaserv/accountserver/account.cpp
deleted file mode 100644
index e680d9d5..00000000
--- a/src/net/manaserv/accountserver/account.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "account.h"
-
-#include "internal.h"
-
-#include "net/manaserv/connection.h"
-#include "net/manaserv/messageout.h"
-#include "net/manaserv/protocol.h"
-
-#include "utils/sha256.h"
-
-#include <string>
-
-void ManaServ::AccountServer::Account::createCharacter(
- const std::string &name, char hairStyle, char hairColor, char gender,
- short strength, short agility, short vitality,
- short intelligence, short dexterity, short willpower)
-{
- MessageOut msg(PAMSG_CHAR_CREATE);
-
- msg.writeString(name);
- msg.writeInt8(hairStyle);
- msg.writeInt8(hairColor);
- msg.writeInt8(gender);
- msg.writeInt16(strength);
- msg.writeInt16(agility);
- msg.writeInt16(vitality);
- msg.writeInt16(intelligence);
- msg.writeInt16(dexterity);
- msg.writeInt16(willpower);
-
- ManaServ::AccountServer::connection->send(msg);
-}
-
-void ManaServ::AccountServer::Account::deleteCharacter(char slot)
-{
- MessageOut msg(PAMSG_CHAR_DELETE);
-
- msg.writeInt8(slot);
-
- ManaServ::AccountServer::connection->send(msg);
-}
-
-void ManaServ::AccountServer::Account::selectCharacter(char slot)
-{
- MessageOut msg(PAMSG_CHAR_SELECT);
-
- msg.writeInt8(slot);
-
- ManaServ::AccountServer::connection->send(msg);
-}
-
-void ManaServ::AccountServer::Account::unregister(const std::string &username,
- const std::string &password)
-{
- MessageOut msg(PAMSG_UNREGISTER);
-
- msg.writeString(username);
- msg.writeString(sha256(username + password));
-
- ManaServ::AccountServer::connection->send(msg);
-}
-
-void ManaServ::AccountServer::Account::changeEmail(const std::string &email)
-{
- MessageOut msg(PAMSG_EMAIL_CHANGE);
-
- // Email is sent clearly so the server can validate the data.
- // Encryption is assumed server-side.
- msg.writeString(email);
-
- ManaServ::AccountServer::connection->send(msg);
-}
-
-void ManaServ::AccountServer::Account::changePassword(
- const std::string &username,
- const std::string &oldPassword,
- const std::string &newPassword)
-{
- MessageOut msg(PAMSG_PASSWORD_CHANGE);
-
- // Change password using SHA2 encryption
- msg.writeString(sha256(username + oldPassword));
- msg.writeString(sha256(username + newPassword));
-
- ManaServ::AccountServer::connection->send(msg);
-}
diff --git a/src/net/manaserv/accountserver/account.h b/src/net/manaserv/accountserver/account.h
deleted file mode 100644
index 03453655..00000000
--- a/src/net/manaserv/accountserver/account.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef NET_MANASERV_ACCOUNTSERVER_CHARACTER_H
-#define NET_MANASERV_ACCOUNTSERVER_CHARACTER_H
-
-#include <iosfwd>
-
-namespace ManaServ
-{
- namespace AccountServer
- {
- namespace Account
- {
- void createCharacter(const std::string &name,
- char hairStyle, char hairColor, char gender,
- short strength, short agility, short vitality,
- short intelligence, short dexterity, short willpower);
-
- void deleteCharacter(char slot);
-
- void selectCharacter(char slot);
-
- void unregister(const std::string &username,
- const std::string &password);
-
- void changeEmail(const std::string &email);
-
- void changePassword(const std::string &username,
- const std::string &oldPassword,
- const std::string &newPassword);
- }
- }
-}
-
-#endif // NET_MANASERV_ACCOUNTSERVER_CHARACTER_H
diff --git a/src/net/manaserv/accountserver/accountserver.cpp b/src/net/manaserv/accountserver/accountserver.cpp
deleted file mode 100644
index afbee4ab..00000000
--- a/src/net/manaserv/accountserver/accountserver.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "accountserver.h"
-
-#include "internal.h"
-
-#include "net/manaserv/connection.h"
-#include "net/manaserv/messageout.h"
-#include "net/manaserv/protocol.h"
-
-#include "utils/sha256.h"
-
-#include <string>
-
-namespace ManaServ
-{
-
-void AccountServer::login(Connection *connection,
- int version, const std::string &username, const std::string &password)
-{
- AccountServer::connection = connection;
-
- MessageOut msg(PAMSG_LOGIN);
-
- msg.writeInt32(version);
- msg.writeString(username);
- msg.writeString(sha256(username + password));
-
- AccountServer::connection->send(msg);
-}
-
-void AccountServer::registerAccount(Connection *connection,
- int version, const std::string &username, const std::string &password,
- const std::string &email)
-{
- AccountServer::connection = connection;
-
- MessageOut msg(PAMSG_REGISTER);
-
- msg.writeInt32(version); // client version
- msg.writeString(username);
- // When registering, the password and email hash is assumed by server.
- // Hence, data can be validated safely server-side.
- // This is the only time we send a clear password.
- msg.writeString(password);
- msg.writeString(email);
-
- AccountServer::connection->send(msg);
-}
-
-void AccountServer::logout()
-{
- MessageOut msg(PAMSG_LOGOUT);
- AccountServer::connection->send(msg);
-}
-
-void AccountServer::reconnectAccount(Connection *connection,
- const std::string &passToken)
-{
- AccountServer::connection = connection;
-
- MessageOut msg(PAMSG_RECONNECT);
- msg.writeString(passToken, 32);
- AccountServer::connection->send(msg);
-}
-
-}
diff --git a/src/net/manaserv/accountserver/accountserver.h b/src/net/manaserv/accountserver/accountserver.h
deleted file mode 100644
index a1bbb5f5..00000000
--- a/src/net/manaserv/accountserver/accountserver.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef NET_MANASERV_ACCOUNTSERVER_ACCOUNTSERVER_H
-#define NET_MANASERV_ACCOUNTSERVER_ACCOUNTSERVER_H
-
-#include <iosfwd>
-
-namespace ManaServ
-{
- class Connection;
-
- namespace AccountServer
- {
- void login(ManaServ::Connection *connection, int version,
- const std::string &username, const std::string &password);
-
- void registerAccount(ManaServ::Connection *connection, int version,
- const std::string &username, const std::string &password,
- const std::string &email);
-
- void logout();
-
- void reconnectAccount(ManaServ::Connection *connection,
- const std::string &passToken);
- }
-}
-
-#endif // NET_MANASERV_ACCOUNTSERVER_ACCOUNTSERVER_H
diff --git a/src/net/manaserv/accountserver/internal.cpp b/src/net/manaserv/accountserver/internal.cpp
deleted file mode 100644
index e1d105b7..00000000
--- a/src/net/manaserv/accountserver/internal.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "internal.h"
-
-namespace ManaServ
-{
- class Connection;
-
- namespace AccountServer
- {
- Connection *connection = 0;
- }
-}
diff --git a/src/net/manaserv/accountserver/internal.h b/src/net/manaserv/accountserver/internal.h
deleted file mode 100644
index af91f692..00000000
--- a/src/net/manaserv/accountserver/internal.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef NET_MANASERV_ACCOUNTSERVER_INTERNAL_H
-#define NET_MANASERV_ACCOUNTSERVER_INTERNAL_H
-
-namespace ManaServ
-{
- class Connection;
-
- namespace AccountServer
- {
- extern Connection *connection;
- }
-}
-
-#endif // NET_MANASERV_ACCOUNTSERVER_INTERNAL_H
diff --git a/src/net/manaserv/adminhandler.cpp b/src/net/manaserv/adminhandler.cpp
index abdf86ef..e77d2bec 100644
--- a/src/net/manaserv/adminhandler.cpp
+++ b/src/net/manaserv/adminhandler.cpp
@@ -21,12 +21,16 @@
#include "net/manaserv/adminhandler.h"
-#include "net/manaserv/chatserver/chatserver.h"
+#include "net/manaserv/connection.h"
+#include "net/manaserv/messageout.h"
+#include "net/manaserv/protocol.h"
Net::AdminHandler *adminHandler;
namespace ManaServ {
+extern Connection *chatServerConnection;
+
AdminHandler::AdminHandler()
{
adminHandler = this;
@@ -34,7 +38,9 @@ AdminHandler::AdminHandler()
void AdminHandler::announce(const std::string &text)
{
- ManaServ::ChatServer::announce(text);
+ MessageOut msg(PCMSG_ANNOUNCE);
+ msg.writeString(text);
+ chatServerConnection->send(msg);
}
void AdminHandler::localAnnounce(const std::string &text)
diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp
index 71325fd5..d7cb40c0 100644
--- a/src/net/manaserv/beinghandler.cpp
+++ b/src/net/manaserv/beinghandler.cpp
@@ -21,6 +21,7 @@
#include "net/manaserv/beinghandler.h"
+#include "net/manaserv/playerhandler.h"
#include "net/manaserv/protocol.h"
#include "net/messagein.h"
@@ -41,8 +42,6 @@
#include "utils/gettext.h"
-#include "net/manaserv/gameserver/player.h"
-
namespace ManaServ {
BeingHandler::BeingHandler()
@@ -288,7 +287,7 @@ void BeingHandler::handleBeingActionChangeMessage(Net::MessageIn &msg)
std::string message(deadMsg[rand()%13]);
message.append(std::string(" ") + _("Press OK to respawn."));
OkDialog *dlg = new OkDialog(_("You Died"), message);
- dlg->addActionListener(&(ManaServ::GameServer::Player::respawnListener));
+ dlg->addActionListener(&(ManaServ::respawnListener));
}
}
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index a08799f9..bc7ffaaa 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -22,14 +22,12 @@
#include "net/manaserv/charhandler.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messagein.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/manaserv/accountserver/accountserver.h"
-#include "net/manaserv/accountserver/account.h"
-
#include "net/logindata.h"
#include "net/loginhandler.h"
-#include "net/messagein.h"
#include "net/net.h"
#include "game.h"
@@ -359,26 +357,39 @@ void CharHandler::getCharacters()
void CharHandler::chooseCharacter(int slot, LocalPlayer* character)
{
- AccountServer::Account::selectCharacter(slot);
+ MessageOut msg(PAMSG_CHAR_SELECT);
+
+ msg.writeInt8(slot);
+
+ accountServerConnection->send(msg);
}
void CharHandler::newCharacter(const std::string &name, int slot, bool gender,
int hairstyle, int hairColor, std::vector<int> stats)
{
- AccountServer::Account::createCharacter(name, hairstyle, hairColor,
- gender,
- stats[0], // STR
- stats[1], // AGI
- stats[2], // DEX
- stats[3], // VIT
- stats[4], // INT
- stats[5] // WILL
- );
+ MessageOut msg(PAMSG_CHAR_CREATE);
+
+ msg.writeString(name);
+ msg.writeInt8(hairstyle);
+ msg.writeInt8(hairColor);
+ msg.writeInt8(gender);
+ msg.writeInt16(stats[0]);
+ msg.writeInt16(stats[1]);
+ msg.writeInt16(stats[2]);
+ msg.writeInt16(stats[3]);
+ msg.writeInt16(stats[4]);
+ msg.writeInt16(stats[5]);
+
+ accountServerConnection->send(msg);
}
void CharHandler::deleteCharacter(int slot, LocalPlayer* character)
{
- AccountServer::Account::deleteCharacter(slot);
+ MessageOut msg(PAMSG_CHAR_DELETE);
+
+ msg.writeInt8(slot);
+
+ accountServerConnection->send(msg);
}
void CharHandler::switchCharacter()
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index c4c86d62..a72fc8fd 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -26,12 +26,6 @@
#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/manaserv/chatserver/chatserver.h"
-#include "net/manaserv/chatserver/internal.h"
-
-#include "net/manaserv/gameserver/internal.h"
-#include "net/manaserv/gameserver/player.h"
-
#include "being.h"
#include "beingmanager.h"
#include "channel.h"
@@ -56,6 +50,7 @@ Net::ChatHandler *chatHandler;
namespace ManaServ {
extern Connection *chatServerConnection;
+extern Connection *gameServerConnection;
extern std::string netToken;
extern ServerInfo chatServer;
@@ -352,7 +347,9 @@ void ChatHandler::handleWhoResponse(Net::MessageIn &msg)
void ChatHandler::connect()
{
- ChatServer::connect(chatServerConnection, netToken);
+ MessageOut msg(PCMSG_CONNECT);
+ msg.writeString(netToken, 32);
+ chatServerConnection->send(msg);
}
bool ChatHandler::isConnected()
@@ -369,7 +366,7 @@ void ChatHandler::talk(const std::string &text)
{
MessageOut msg(PGMSG_SAY);
msg.writeString(text);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void ChatHandler::me(const std::string &text)
@@ -383,13 +380,13 @@ void ChatHandler::privateMessage(const std::string &recipient,
MessageOut msg(PCMSG_PRIVMSG);
msg.writeString(recipient);
msg.writeString(text);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatHandler::channelList()
{
MessageOut msg(PCMSG_LIST_CHANNELS);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatHandler::enterChannel(const std::string &channel,
@@ -398,14 +395,14 @@ void ChatHandler::enterChannel(const std::string &channel,
MessageOut msg(PCMSG_ENTER_CHANNEL);
msg.writeString(channel);
msg.writeString(password);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatHandler::quitChannel(int channelId)
{
MessageOut msg(PCMSG_QUIT_CHANNEL);
msg.writeInt16(channelId);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatHandler::sendToChannel(int channelId, const std::string &text)
@@ -413,14 +410,14 @@ void ChatHandler::sendToChannel(int channelId, const std::string &text)
MessageOut msg(PCMSG_CHAT);
msg.writeString(text);
msg.writeInt16(channelId);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatHandler::userList(const std::string &channel)
{
MessageOut msg(PCMSG_LIST_CHANNELUSERS);
msg.writeString(channel);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatHandler::setChannelTopic(int channelId, const std::string &text)
@@ -428,7 +425,7 @@ void ChatHandler::setChannelTopic(int channelId, const std::string &text)
MessageOut msg(PCMSG_TOPIC_CHANGE);
msg.writeInt16(channelId);
msg.writeString(text);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatHandler::setUserMode(int channelId, const std::string &name, int mode)
@@ -437,7 +434,7 @@ void ChatHandler::setUserMode(int channelId, const std::string &name, int mode)
msg.writeInt16(channelId);
msg.writeString(name);
msg.writeInt8(mode);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatHandler::kickUser(int channelId, const std::string &name)
@@ -445,13 +442,13 @@ void ChatHandler::kickUser(int channelId, const std::string &name)
MessageOut msg(PCMSG_KICK_USER);
msg.writeInt16(channelId);
msg.writeString(name);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatHandler::who()
{
MessageOut msg(PCMSG_WHO);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
} // namespace ManaServ
diff --git a/src/net/manaserv/chatserver/chatserver.cpp b/src/net/manaserv/chatserver/chatserver.cpp
deleted file mode 100644
index 23eee3e6..00000000
--- a/src/net/manaserv/chatserver/chatserver.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "chatserver.h"
-
-#include "internal.h"
-
-#include "net/manaserv/connection.h"
-#include "net/manaserv/messageout.h"
-#include "net/manaserv/protocol.h"
-
-namespace ManaServ {
-
-using ChatServer::connection;
-
-void ChatServer::connect(Connection *connection,
- const std::string &token)
-{
- ChatServer::connection = connection;
-
- MessageOut msg(PCMSG_CONNECT);
- msg.writeString(token, 32);
- connection->send(msg);
-}
-
-void ChatServer::logout()
-{
- MessageOut msg(PCMSG_DISCONNECT);
- connection->send(msg);
-}
-
-void ChatServer::announce(const std::string &text)
-{
- MessageOut msg(PCMSG_ANNOUNCE);
- msg.writeString(text);
- connection->send(msg);
-}
-
-}
diff --git a/src/net/manaserv/chatserver/chatserver.h b/src/net/manaserv/chatserver/chatserver.h
deleted file mode 100644
index 18cd5960..00000000
--- a/src/net/manaserv/chatserver/chatserver.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef NET_MANASERV_CHATSERVER_CHATSERVER_H
-#define NET_MANASERV_CHATSERVER_CHATSERVER_H
-
-#include <iosfwd>
-
-namespace ManaServ
-{
- class Connection;
-
- namespace ChatServer
- {
- void connect(Connection *connection, const std::string &token);
-
- void logout();
-
- void announce(const std::string &text);
-
- void kickUser(short channel, const std::string &user);
-
- }
-}
-
-#endif // NET_MANASERV_CHATSERVER_CHATSERVER_H
diff --git a/src/net/manaserv/chatserver/guild.cpp b/src/net/manaserv/chatserver/guild.cpp
index e34b3bc4..1f0990b1 100644
--- a/src/net/manaserv/chatserver/guild.cpp
+++ b/src/net/manaserv/chatserver/guild.cpp
@@ -21,8 +21,6 @@
#include "guild.h"
-#include "internal.h"
-
#include "net/manaserv/connection.h"
#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
@@ -32,6 +30,8 @@
namespace ManaServ
{
+extern Connection *chatServerConnection;
+
void ChatServer::Guild::createGuild(const std::string &name)
{
logger->log("Sending PCMSG_GUILD_CREATE");
@@ -39,7 +39,7 @@ void ChatServer::Guild::createGuild(const std::string &name)
msg.writeString(name);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatServer::Guild::invitePlayer(const std::string &name, short guildId)
@@ -50,7 +50,7 @@ void ChatServer::Guild::invitePlayer(const std::string &name, short guildId)
msg.writeInt16(guildId);
msg.writeString(name);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatServer::Guild::acceptInvite(const std::string &name)
@@ -60,7 +60,7 @@ void ChatServer::Guild::acceptInvite(const std::string &name)
msg.writeString(name);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatServer::Guild::getGuildMembers(short guildId)
@@ -70,7 +70,7 @@ void ChatServer::Guild::getGuildMembers(short guildId)
msg.writeInt16(guildId);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatServer::Guild::promoteMember(const std::string &name,
@@ -83,7 +83,7 @@ void ChatServer::Guild::promoteMember(const std::string &name,
msg.writeString(name);
msg.writeInt8(level);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
void ChatServer::Guild::quitGuild(short guildId)
@@ -93,7 +93,7 @@ void ChatServer::Guild::quitGuild(short guildId)
msg.writeInt16(guildId);
- ChatServer::connection->send(msg);
+ chatServerConnection->send(msg);
}
}
diff --git a/src/net/manaserv/chatserver/internal.cpp b/src/net/manaserv/chatserver/internal.cpp
deleted file mode 100644
index 890cb1f1..00000000
--- a/src/net/manaserv/chatserver/internal.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "internal.h"
-
-namespace ManaServ
-{
- class Connection;
-
- namespace ChatServer
- {
- Connection *connection = 0;
- }
-}
diff --git a/src/net/manaserv/chatserver/internal.h b/src/net/manaserv/chatserver/internal.h
deleted file mode 100644
index 6807f147..00000000
--- a/src/net/manaserv/chatserver/internal.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef NET_MANASERV_CHATSERVER_INTERNAL_H
-#define NET_MANASERV_CHATSERVER_INTERNAL_H
-
-namespace ManaServ
-{
- class Connection;
-
- namespace ChatServer
- {
- extern Connection *connection;
- }
-}
-
-#endif // NET_MANASERV_CHATSERVER_INTERNAL_H
diff --git a/src/net/manaserv/chatserver/party.cpp b/src/net/manaserv/chatserver/party.cpp
deleted file mode 100644
index fdefc59d..00000000
--- a/src/net/manaserv/chatserver/party.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2008 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "party.h"
-
-#include "internal.h"
-
-#include "net/manaserv/connection.h"
-#include "net/manaserv/messageout.h"
-#include "net/manaserv/protocol.h"
-
-#include "log.h"
-
-namespace ManaServ
-{
-
-void ChatServer::Party::invitePlayer(const std::string &name)
-{
- logger->log("Sending PCMSG_PARTY_INVITE");
- MessageOut msg(PCMSG_PARTY_INVITE);
-
- msg.writeString(name);
-
- ChatServer::connection->send(msg);
-}
-
-void ChatServer::Party::acceptInvite(const std::string &name)
-{
- logger->log("Sending PCMSG_PARTY_ACCEPT_INVITE");
- MessageOut msg(PCMSG_PARTY_ACCEPT_INVITE);
-
- msg.writeString(name);
-
- ChatServer::connection->send(msg);
-}
-
-void ChatServer::Party::rejectInvite(const std::string &name)
-{
- logger->log("Sending PCMSG_PARTY_REJECT_INVITE");
- MessageOut msg(PCMSG_PARTY_REJECT_INVITE);
-
- msg.writeString(name);
-
- ChatServer::connection->send(msg);
-}
-
-void ChatServer::Party::getPartyMembers()
-{
- logger->log("Sending PCMSG_PARTY_GET_MEMBERS");
-// MessageOut msg(PCMSG_GUILD_GET_MEMBERS);
-
-// msg.writeInt16(guildId);
-
-// ChatServer::connection->send(msg);
-}
-
-void ChatServer::Party::quitParty()
-{
- logger->log("Sending PCMSG_PARTY_QUIT");
- MessageOut msg(PCMSG_PARTY_QUIT);
-
- ChatServer::connection->send(msg);
-}
-
-}
diff --git a/src/net/manaserv/chatserver/party.h b/src/net/manaserv/chatserver/party.h
deleted file mode 100644
index 34f308f7..00000000
--- a/src/net/manaserv/chatserver/party.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2008 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef NET_MANASERV_CHATSERVER_PARTY_H
-#define NET_MANASERV_CHATSERVER_PARTY_H
-
-#include <iosfwd>
-
-namespace ManaServ
-{
- namespace ChatServer
- {
- namespace Party
- {
- /**
- * Invite a player to the party.
- */
- void invitePlayer(const std::string &name);
-
- /**
- * Accept an invite another player has sent to join their party
- */
- void acceptInvite(const std::string &name);
-
- /**
- * Reject an invite from another player to join their party
- */
- void rejectInvite(const std::string &name);
-
- /**
- * Get a list of party members
- */
- void getPartyMembers();
-
- /**
- * Leave party
- */
- void quitParty();
- }
- }
-}
-
-#endif // NET_MANASERV_CHATSERVER_PARTY_H
diff --git a/src/net/manaserv/gamehandler.cpp b/src/net/manaserv/gamehandler.cpp
index 1916d492..306dc5e6 100644
--- a/src/net/manaserv/gamehandler.cpp
+++ b/src/net/manaserv/gamehandler.cpp
@@ -23,11 +23,9 @@
#include "net/manaserv/chathandler.h"
#include "net/manaserv/connection.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/manaserv/chatserver/chatserver.h"
-#include "net/manaserv/gameserver/gameserver.h"
-
#include "main.h"
Net::GameHandler *gameHandler;
@@ -99,7 +97,11 @@ void GameHandler::disconnect()
void GameHandler::inGame()
{
- GameServer::connect(gameServerConnection, netToken);
+
+ MessageOut msg(PGMSG_CONNECT);
+ msg.writeString(netToken, 32);
+ gameServerConnection->send(msg);
+
chatHandler->connect();
}
@@ -115,7 +117,9 @@ void GameHandler::who()
void GameHandler::quit()
{
- // TODO
+ //MessageOut msg(PGMSG_DISCONNECT);
+ //msg.writeInt8((unsigned char) reconnectAccount);
+ //gameServerConnection->send(msg);
}
void GameHandler::ping(int tick)
diff --git a/src/net/manaserv/gameserver/gameserver.cpp b/src/net/manaserv/gameserver/gameserver.cpp
deleted file mode 100644
index ba3bd983..00000000
--- a/src/net/manaserv/gameserver/gameserver.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "gameserver.h"
-
-#include "internal.h"
-
-#include "net/manaserv/connection.h"
-#include "net/manaserv/messageout.h"
-#include "net/manaserv/protocol.h"
-
-namespace ManaServ
-{
-
-void GameServer::connect(Connection *connection, const std::string &token)
-{
- GameServer::connection = connection;
-
- MessageOut msg(PGMSG_CONNECT);
-
- msg.writeString(token, 32);
-
- GameServer::connection->send(msg);
-}
-
-void GameServer::logout(bool reconnectAccount)
-{
- MessageOut msg(PGMSG_DISCONNECT);
-
- msg.writeInt8((unsigned char) reconnectAccount);
-
- GameServer::connection->send(msg);
-}
-
-}
diff --git a/src/net/manaserv/gameserver/gameserver.h b/src/net/manaserv/gameserver/gameserver.h
deleted file mode 100644
index 1f9e5b78..00000000
--- a/src/net/manaserv/gameserver/gameserver.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef NET_MANASERV_GAMESERVER_GAMESERVER_H
-#define NET_MANASERV_GAMESERVER_GAMESERVER_H
-
-#include <iosfwd>
-
-namespace ManaServ
-{
- class Connection;
-
- namespace GameServer
- {
- void connect(Connection *connection, const std::string &token);
-
- void logout(bool reconnectAccount);
- }
-}
-
-#endif // NET_MANASERV_GAMESERVER_GAMESERVER_H
diff --git a/src/net/manaserv/gameserver/internal.cpp b/src/net/manaserv/gameserver/internal.cpp
deleted file mode 100644
index e998ced9..00000000
--- a/src/net/manaserv/gameserver/internal.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "internal.h"
-
-namespace ManaServ
-{
- class Connection;
-
- namespace GameServer
- {
- Connection *connection = 0;
- }
-}
diff --git a/src/net/manaserv/gameserver/internal.h b/src/net/manaserv/gameserver/internal.h
deleted file mode 100644
index 44cd3be2..00000000
--- a/src/net/manaserv/gameserver/internal.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef NET_MANASERV_GAMESERVER_INTERNAL_H
-#define NET_MANASERV_GAMESERVER_INTERNAL_H
-
-namespace ManaServ
-{
- class Connection;
-
- namespace GameServer
- {
- extern Connection *connection;
- }
-}
-
-#endif // NET_MANASERV_GAMESERVER_INTERNAL_H
diff --git a/src/net/manaserv/gameserver/player.cpp b/src/net/manaserv/gameserver/player.cpp
deleted file mode 100644
index 6fa146d4..00000000
--- a/src/net/manaserv/gameserver/player.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "player.h"
-
-#include "internal.h"
-
-#include "net/manaserv/connection.h"
-#include "net/manaserv/messageout.h"
-#include "net/manaserv/protocol.h"
-
-void RespawnRequestListener::action(const gcn::ActionEvent &event)
-{
- ManaServ::GameServer::Player::respawn();
-}
-
-namespace ManaServ
-{
-
-void GameServer::Player::walk(int x, int y)
-{
- MessageOut msg(PGMSG_WALK);
- msg.writeInt16(x);
- msg.writeInt16(y);
- GameServer::connection->send(msg);
-}
-
-void GameServer::Player::moveItem(int oldSlot, int newSlot, int amount)
-{
- MessageOut msg(PGMSG_MOVE_ITEM);
- msg.writeInt8(oldSlot);
- msg.writeInt8(newSlot);
- msg.writeInt8(amount);
- GameServer::connection->send(msg);
-}
-
-void GameServer::Player::respawn()
-{
- MessageOut msg(PGMSG_RESPAWN);
- GameServer::connection->send(msg);
-}
-
-}
diff --git a/src/net/manaserv/gameserver/player.h b/src/net/manaserv/gameserver/player.h
deleted file mode 100644
index 40ba4b2b..00000000
--- a/src/net/manaserv/gameserver/player.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef NET_MANASERV_GAMESERVER_PLAYER_H
-#define NET_MANASERV_GAMESERVER_PLAYER_H
-
-#include "being.h"
-
-#include <guichan/actionlistener.hpp>
-
-#include <iosfwd>
-
-
-struct RespawnRequestListener : public gcn::ActionListener
-{
- void action(const gcn::ActionEvent &event);
-};
-
-namespace ManaServ
-{
- namespace GameServer
- {
- namespace Player
- {
- void walk(int x, int y);
- void moveItem(int oldSlot, int newSlot, int amount);
- void respawn();
- static RespawnRequestListener respawnListener;
- }
- }
-}
-
-#endif // NET_MANASERV_GAMESERVER_PLAYER_H
diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp
index 9cdc1c72..d4bf2397 100644
--- a/src/net/manaserv/guildhandler.cpp
+++ b/src/net/manaserv/guildhandler.cpp
@@ -23,7 +23,6 @@
#include "net/messagein.h"
-#include "net/manaserv/chatserver/chatserver.h"
#include "net/manaserv/chatserver/guild.h"
#include "net/manaserv/protocol.h"
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index e4fe0ecc..0d0c1b34 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -26,9 +26,6 @@
#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/manaserv/gameserver/internal.h"
-#include "net/manaserv/gameserver/player.h"
-
#include "equipment.h"
#include "inventory.h"
#include "item.h"
@@ -45,6 +42,8 @@ Net::InventoryHandler *inventoryHandler;
namespace ManaServ {
+extern Connection *gameServerConnection;
+
InventoryHandler::InventoryHandler()
{
static const Uint16 _messages[] = {
@@ -93,14 +92,14 @@ void InventoryHandler::equipItem(const Item *item)
{
MessageOut msg(PGMSG_EQUIP);
msg.writeInt8(item->getInvIndex());
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void InventoryHandler::unequipItem(const Item *item)
{
MessageOut msg(PGMSG_UNEQUIP);
msg.writeInt8(item->getInvIndex());
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
// Tidy equipment directly to avoid weapon still shown bug, for instance
int equipSlot = item->getInvIndex();
@@ -112,7 +111,7 @@ void InventoryHandler::useItem(const Item *item)
{
MessageOut msg(PGMSG_USE_ITEM);
msg.writeInt8(item->getInvIndex());
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void InventoryHandler::dropItem(const Item *item, int amount)
@@ -120,7 +119,7 @@ void InventoryHandler::dropItem(const Item *item, int amount)
MessageOut msg(PGMSG_DROP);
msg.writeInt8(item->getInvIndex());
msg.writeInt8(amount);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
bool InventoryHandler::canSplit(const Item *item)
@@ -133,7 +132,11 @@ void InventoryHandler::splitItem(const Item *item, int amount)
int newIndex = player_node->getInventory()->getFreeSlot();
if (newIndex > Inventory::NO_SLOT_INDEX)
{
- GameServer::Player::moveItem(item->getInvIndex(), newIndex, amount);
+ MessageOut msg(PGMSG_MOVE_ITEM);
+ msg.writeInt8(item->getInvIndex());
+ msg.writeInt8(newIndex);
+ msg.writeInt8(amount);
+ gameServerConnection->send(msg);
}
}
@@ -142,8 +145,12 @@ void InventoryHandler::moveItem(int oldIndex, int newIndex)
if (oldIndex == newIndex)
return;
- GameServer::Player::moveItem(oldIndex, newIndex,
- player_node->getInventory()->getItem(oldIndex)->getQuantity());
+ MessageOut msg(PGMSG_MOVE_ITEM);
+ msg.writeInt8(oldIndex);
+ msg.writeInt8(newIndex);
+ msg.writeInt8(player_node->getInventory()->getItem(oldIndex)
+ ->getQuantity());
+ gameServerConnection->send(msg);
}
void InventoryHandler::openStorage()
diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp
index d753d8d1..5e8780d4 100644
--- a/src/net/manaserv/loginhandler.cpp
+++ b/src/net/manaserv/loginhandler.cpp
@@ -23,16 +23,15 @@
#include "net/manaserv/connection.h"
#include "net/manaserv/messagein.h"
+#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/manaserv/accountserver/account.h"
-#include "net/manaserv/accountserver/accountserver.h"
-
#include "net/logindata.h"
#include "main.h"
#include "utils/gettext.h"
+#include "utils/sha256.h"
Net::LoginHandler *loginHandler;
@@ -40,6 +39,7 @@ Net::LoginHandler *loginHandler;
namespace ManaServ {
extern Connection *accountServerConnection;
+extern std::string netToken;
LoginHandler::LoginHandler()
{
@@ -306,27 +306,44 @@ void LoginHandler::disconnect()
void LoginHandler::loginAccount(LoginData *loginData)
{
mLoginData = loginData;
- AccountServer::login(accountServerConnection,
- 0, // client version
- loginData->username,
- loginData->password);
+
+ MessageOut msg(PAMSG_LOGIN);
+
+ msg.writeInt32(0); // client version
+ msg.writeString(loginData->username);
+ msg.writeString(sha256(loginData->username + loginData->password));
+
+ accountServerConnection->send(msg);
}
void LoginHandler::logout()
{
- // TODO
+ MessageOut msg(PAMSG_LOGOUT);
+ accountServerConnection->send(msg);
}
void LoginHandler::changeEmail(const std::string &email)
{
- AccountServer::Account::changeEmail(email);
+ MessageOut msg(PAMSG_EMAIL_CHANGE);
+
+ // Email is sent clearly so the server can validate the data.
+ // Encryption is assumed server-side.
+ msg.writeString(email);
+
+ accountServerConnection->send(msg);
}
void LoginHandler::changePassword(const std::string &username,
const std::string &oldPassword,
const std::string &newPassword)
{
- AccountServer::Account::changePassword(username, oldPassword, newPassword);
+ MessageOut msg(PAMSG_PASSWORD_CHANGE);
+
+ // Change password using SHA2 encryption
+ msg.writeString(sha256(username + oldPassword));
+ msg.writeString(sha256(username + newPassword));
+
+ accountServerConnection->send(msg);
}
void LoginHandler::chooseServer(unsigned int server)
@@ -336,17 +353,28 @@ void LoginHandler::chooseServer(unsigned int server)
void LoginHandler::registerAccount(LoginData *loginData)
{
- AccountServer::registerAccount(accountServerConnection,
- 0, // client version
- loginData->username,
- loginData->password,
- loginData->email);
+ MessageOut msg(PAMSG_REGISTER);
+
+ msg.writeInt32(0); // client version
+ msg.writeString(loginData->username);
+ // When registering, the password and email hash is assumed by server.
+ // Hence, data can be validated safely server-side.
+ // This is the only time we send a clear password.
+ msg.writeString(loginData->password);
+ msg.writeString(loginData->email);
+
+ accountServerConnection->send(msg);
}
void LoginHandler::unregisterAccount(const std::string &username,
const std::string &password)
{
- AccountServer::Account::unregister(username, password);
+ MessageOut msg(PAMSG_UNREGISTER);
+
+ msg.writeString(username);
+ msg.writeString(sha256(username + password));
+
+ accountServerConnection->send(msg);
}
Worlds LoginHandler::getWorlds() const
@@ -354,4 +382,11 @@ Worlds LoginHandler::getWorlds() const
return Worlds();
}
+void reconnect()
+{
+ MessageOut msg(PAMSG_RECONNECT);
+ msg.writeString(netToken, 32);
+ accountServerConnection->send(msg);
+}
+
} // namespace ManaServ
diff --git a/src/net/manaserv/loginhandler.h b/src/net/manaserv/loginhandler.h
index 14c14a53..1a929c96 100644
--- a/src/net/manaserv/loginhandler.h
+++ b/src/net/manaserv/loginhandler.h
@@ -70,6 +70,8 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler
Worlds getWorlds() const;
+ void reconnect();
+
private:
void handleLoginResponse(Net::MessageIn &msg);
void handleRegisterResponse(Net::MessageIn &msg);
diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp
index 7384d18e..4c4aa53f 100644
--- a/src/net/manaserv/npchandler.cpp
+++ b/src/net/manaserv/npchandler.cpp
@@ -26,9 +26,6 @@
#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/manaserv/gameserver/internal.h"
-#include "net/manaserv/gameserver/player.h"
-
#include "beingmanager.h"
#include "npc.h"
@@ -39,6 +36,8 @@ Net::NpcHandler *npcHandler;
namespace ManaServ {
+extern Connection *gameServerConnection;
+
NpcHandler::NpcHandler()
{
static const Uint16 _messages[] = {
@@ -114,21 +113,22 @@ void NpcHandler::talk(int npcId)
{
MessageOut msg(PGMSG_NPC_TALK);
msg.writeInt16(npcId);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void NpcHandler::nextDialog(int npcId)
{
MessageOut msg(PGMSG_NPC_TALK_NEXT);
msg.writeInt16(npcId);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void NpcHandler::closeDialog(int npcId)
{
MessageOut msg(PGMSG_NPC_TALK_NEXT);
msg.writeInt16(npcId);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
+
npcDialog->setVisible(false);
npcDialog->setText("");
}
@@ -138,7 +138,7 @@ void NpcHandler::listInput(int npcId, int value)
MessageOut msg(PGMSG_NPC_SELECT);
msg.writeInt16(npcId);
msg.writeInt8(value);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void NpcHandler::integerInput(int npcId, int value)
@@ -146,7 +146,7 @@ void NpcHandler::integerInput(int npcId, int value)
MessageOut msg(PGMSG_NPC_NUMBER);
msg.writeInt16(npcId);
msg.writeInt32(value);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void NpcHandler::stringInput(int npcId, const std::string &value)
@@ -154,7 +154,7 @@ void NpcHandler::stringInput(int npcId, const std::string &value)
MessageOut msg(PGMSG_NPC_STRING);
msg.writeInt16(npcId);
msg.writeString(value);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void NpcHandler::sendLetter(int npcId, const std::string &recipient,
@@ -163,7 +163,7 @@ void NpcHandler::sendLetter(int npcId, const std::string &recipient,
MessageOut msg(PGMSG_NPC_POST_SEND);
msg.writeString(recipient);
msg.writeString(text);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void NpcHandler::startShopping(int beingId)
@@ -186,7 +186,7 @@ void NpcHandler::buyItem(int beingId, int itemId, int amount)
MessageOut msg(PGMSG_NPC_BUYSELL);
msg.writeInt16(itemId);
msg.writeInt16(amount);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void NpcHandler::sellItem(int beingId, int itemId, int amount)
@@ -194,7 +194,7 @@ void NpcHandler::sellItem(int beingId, int itemId, int amount)
MessageOut msg(PGMSG_NPC_BUYSELL);
msg.writeInt16(itemId);
msg.writeInt16(amount);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void NpcHandler::endShopping(int beingId)
diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp
index ea968649..2426f17e 100644
--- a/src/net/manaserv/partyhandler.cpp
+++ b/src/net/manaserv/partyhandler.cpp
@@ -21,12 +21,10 @@
#include "net/manaserv/partyhandler.h"
-#include "net/manaserv/protocol.h"
+#include "net/manaserv/connection.h"
#include "net/manaserv/messagein.h"
#include "net/manaserv/messageout.h"
-
-#include "net/manaserv/chatserver/chatserver.h"
-#include "net/manaserv/chatserver/party.h"
+#include "net/manaserv/protocol.h"
#include "gui/partywindow.h"
@@ -44,6 +42,8 @@ Net::PartyHandler *partyHandler;
namespace ManaServ {
+extern Connection *chatServerConnection;
+
PartyHandler::PartyHandler()
{
static const Uint16 _messages[] = {
@@ -140,20 +140,28 @@ void PartyHandler::invite(Player *player)
void PartyHandler::invite(const std::string &name)
{
- ChatServer::Party::invitePlayer(name);
+ MessageOut msg(PCMSG_PARTY_INVITE);
+
+ msg.writeString(name);
+
+ chatServerConnection->send(msg);
}
void PartyHandler::inviteResponse(const std::string &inviter, bool accept)
{
- if (accept)
- ChatServer::Party::acceptInvite(inviter);
- else
- ChatServer::Party::rejectInvite(inviter);
+ MessageOut msg = MessageOut(accept ? PCMSG_PARTY_ACCEPT_INVITE :
+ PCMSG_PARTY_REJECT_INVITE);
+
+ msg.writeString(inviter);
+
+ chatServerConnection->send(msg);
}
void PartyHandler::leave()
{
- ChatServer::Party::quitParty();
+ MessageOut msg(PCMSG_PARTY_QUIT);
+
+ chatServerConnection->send(msg);
}
void PartyHandler::kick(Player *player)
@@ -173,7 +181,11 @@ void PartyHandler::chat(const std::string &text)
void PartyHandler::requestPartyMembers()
{
- // TODO
+ //MessageOut msg(PCMSG_GUILD_GET_MEMBERS);
+
+ //msg.writeInt16(guildId);
+
+ //chatServerConnection->send(msg);
}
} // namespace ManaServ
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index fabf7c25..276b2c3a 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -26,9 +26,6 @@
#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-#include "net/manaserv/gameserver/internal.h"
-#include "net/manaserv/gameserver/player.h"
-
#include "net/net.h"
#include "effectmanager.h"
@@ -94,6 +91,13 @@ Net::PlayerHandler *playerHandler;
namespace ManaServ {
+void RespawnRequestListener::action(const gcn::ActionEvent &event)
+{
+ Net::getPlayerHandler()->respawn();
+}
+
+extern Connection *gameServerConnection;
+
PlayerHandler::PlayerHandler()
{
static const Uint16 _messages[] = {
@@ -328,7 +332,7 @@ void PlayerHandler::attack(int id)
{
MessageOut msg(PGMSG_ATTACK);
msg.writeInt16(id);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void PlayerHandler::emote(int emoteId)
@@ -340,14 +344,14 @@ void PlayerHandler::increaseAttribute(size_t attr)
{
MessageOut msg(PGMSG_RAISE_ATTRIBUTE);
msg.writeInt8(attr);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void PlayerHandler::decreaseAttribute(size_t attr)
{
MessageOut msg(PGMSG_LOWER_ATTRIBUTE);
msg.writeInt8(attr);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void PlayerHandler::increaseSkill(int skillId)
@@ -361,14 +365,14 @@ void PlayerHandler::pickUp(FloorItem *floorItem)
MessageOut msg(PGMSG_PICKUP);
msg.writeInt16(id >> 16);
msg.writeInt16(id & 0xFFFF);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void PlayerHandler::setDirection(char direction)
{
MessageOut msg(PGMSG_DIRECTION_CHANGE);
msg.writeInt8(direction);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void PlayerHandler::setDestination(int x, int y, int /* direction */)
@@ -376,7 +380,7 @@ void PlayerHandler::setDestination(int x, int y, int /* direction */)
MessageOut msg(PGMSG_WALK);
msg.writeInt16(x);
msg.writeInt16(y);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void PlayerHandler::changeAction(Being::Action action)
@@ -385,12 +389,13 @@ void PlayerHandler::changeAction(Being::Action action)
MessageOut msg(PGMSG_ACTION_CHANGE);
msg.writeInt8(action);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void PlayerHandler::respawn()
{
- // TODO
+ MessageOut msg(PGMSG_RESPAWN);
+ gameServerConnection->send(msg);
}
void PlayerHandler::ignorePlayer(const std::string &player, bool ignore)
diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h
index 926f05dd..37d485f8 100644
--- a/src/net/manaserv/playerhandler.h
+++ b/src/net/manaserv/playerhandler.h
@@ -26,8 +26,16 @@
#include "net/manaserv/messagehandler.h"
+#include <guichan/actionlistener.hpp>
+
namespace ManaServ {
+struct RespawnRequestListener : public gcn::ActionListener
+{
+ void action(const gcn::ActionEvent &event);
+};
+static RespawnRequestListener respawnListener;
+
class PlayerHandler : public MessageHandler, public Net::PlayerHandler
{
public:
diff --git a/src/net/manaserv/specialhandler.cpp b/src/net/manaserv/specialhandler.cpp
index 2e152d60..17d26d07 100644
--- a/src/net/manaserv/specialhandler.cpp
+++ b/src/net/manaserv/specialhandler.cpp
@@ -21,8 +21,6 @@
#include "net/manaserv/specialhandler.h"
-#include "net/manaserv/gameserver/internal.h"
-
#include "net/manaserv/connection.h"
#include "net/manaserv/messagein.h"
#include "net/manaserv/messageout.h"
@@ -32,6 +30,8 @@ Net::SpecialHandler *specialHandler;
namespace ManaServ {
+extern Connection *gameServerConnection;
+
SpecialHandler::SpecialHandler()
{
specialHandler = this;
@@ -46,7 +46,7 @@ void SpecialHandler::use(int id)
{
MessageOut msg(PGMSG_USE_SPECIAL);
msg.writeInt8(id);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void SpecialHandler::use(int id, int level, int beingId)
diff --git a/src/net/manaserv/tradehandler.cpp b/src/net/manaserv/tradehandler.cpp
index 46664193..bcfe20e9 100644
--- a/src/net/manaserv/tradehandler.cpp
+++ b/src/net/manaserv/tradehandler.cpp
@@ -21,9 +21,6 @@
#include "net/manaserv/tradehandler.h"
-#include "net/manaserv/gameserver/internal.h"
-#include "net/manaserv/gameserver/player.h"
-
#include "net/manaserv/connection.h"
#include "net/manaserv/messagein.h"
#include "net/manaserv/messageout.h"
@@ -46,6 +43,12 @@
std::string tradePartnerName;
int tradePartnerID;
+Net::TradeHandler *tradeHandler;
+
+namespace ManaServ {
+
+extern Connection *gameServerConnection;
+
/**
* Listener for request trade dialogs
*/
@@ -58,7 +61,7 @@ namespace {
{
ManaServ::MessageOut msg(PGMSG_TRADE_REQUEST);
msg.writeInt16(tradePartnerID);
- ManaServ::GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
else
Net::getTradeHandler()->cancel();
@@ -66,10 +69,6 @@ namespace {
} listener;
}
-Net::TradeHandler *tradeHandler;
-
-namespace ManaServ {
-
TradeHandler::TradeHandler():
mAcceptTradeRequests(true)
{
@@ -170,13 +169,13 @@ void TradeHandler::request(Being *being)
MessageOut msg(PGMSG_TRADE_REQUEST);
msg.writeInt16(tradePartnerID);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void TradeHandler::respond(bool accept)
{
MessageOut msg(accept ? PGMSG_TRADE_REQUEST : PGMSG_TRADE_CANCEL);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
if (!accept)
player_node->setTrading(false);
@@ -187,7 +186,7 @@ void TradeHandler::addItem(Item *item, int amount)
MessageOut msg(PGMSG_TRADE_ADD_ITEM);
msg.writeInt8(item->getInvIndex());
msg.writeInt8(amount);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
tradeWindow->addItem(item->getId(), true, amount);
item->increaseQuantity(-amount);
@@ -202,25 +201,25 @@ void TradeHandler::setMoney(int amount)
{
MessageOut msg(PGMSG_TRADE_SET_MONEY);
msg.writeInt32(amount);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void TradeHandler::confirm()
{
MessageOut msg(PGMSG_TRADE_CONFIRM);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void TradeHandler::finish()
{
MessageOut msg(PGMSG_TRADE_AGREED);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
void TradeHandler::cancel()
{
MessageOut msg(PGMSG_TRADE_CANCEL);
- GameServer::connection->send(msg);
+ gameServerConnection->send(msg);
}
} // namespace ManaServ