summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/effectmanager.cpp1
-rw-r--r--src/game.cpp3
-rw-r--r--src/game.h1
-rw-r--r--src/net/effecthandler.cpp59
-rw-r--r--src/net/effecthandler.h39
-rw-r--r--src/net/protocol.h1
9 files changed, 115 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 4841c9b6..1e97bcc9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-27 Chuck Miller <shadowmil@gmail.com>
+
+ * src/game.h, src/game.cpp, src/net/protocol.h, src/net/effecthandler.h,
+ src/net/effecthandler.cpp: Added a handler for handling effects sent
+ from the server, you'll need the latest server patch for them too work
+ * src/effectmanager.cpp: Removed some debugging code left in by
+ mistake
+
2008-10-26 Chuck Miller <shadowmil@gmail.com>
* src/effectmanager.h,src/effectmanager.cpp,src/game.cpp: Added a
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0c4dec38..9f73a7a4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -252,6 +252,8 @@ SET(SRCS
net/protocol.h
net/tradehandler.cpp
net/tradehandler.h
+ net/effecthandler.cpp
+ net/effecthandler.h
net/accountserver/account.cpp
net/accountserver/account.h
net/accountserver/accountserver.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 02d73b1a..af7ed48d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -204,6 +204,8 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \
net/protocol.h \
net/tradehandler.cpp \
net/tradehandler.h \
+ net/effecthandler.h \
+ net/effecthandler.cpp \
net/accountserver/account.cpp \
net/accountserver/account.h \
net/accountserver/accountserver.cpp \
diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp
index 4b835355..bb8b5733 100644
--- a/src/effectmanager.cpp
+++ b/src/effectmanager.cpp
@@ -71,7 +71,6 @@ bool EffectManager::trigger(int id, int x, int y)
{
if ((*i).id == id)
{
- printf("Found effect, playing it");
rValue = true;
if((*i).GFX != "")
particleEngine->addEffect((*i).GFX, x, y);
diff --git a/src/game.cpp b/src/game.cpp
index b4c9190d..6c370d83 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -86,6 +86,7 @@
#include "net/posthandler.h"
#include "net/playerhandler.h"
#include "net/tradehandler.h"
+#include "net/effecthandler.h"
#include "resources/imagewriter.h"
@@ -277,6 +278,7 @@ Game::Game():
mPlayerHandler(new PlayerHandler()),
mPostHandler(new PostHandler()),
mTradeHandler(new TradeHandler()),
+ mEffectHandler(new EffectHandler()),
mLogicCounterId(0), mSecondsCounterId(0)
{
done = false;
@@ -324,6 +326,7 @@ Game::Game():
Net::registerHandler(mPlayerHandler.get());
Net::registerHandler(mPostHandler.get());
Net::registerHandler(mTradeHandler.get());
+ Net::registerHandler(mEffectHandler.get());
}
Game::~Game()
diff --git a/src/game.h b/src/game.h
index 78c5dc80..56923bd0 100644
--- a/src/game.h
+++ b/src/game.h
@@ -71,6 +71,7 @@ class Game : public ConfigListener
MessageHandlerPtr mPlayerHandler;
MessageHandlerPtr mPostHandler;
MessageHandlerPtr mTradeHandler;
+ MessageHandlerPtr mEffectHandler;
SDL_TimerID mLogicCounterId;
SDL_TimerID mSecondsCounterId;
diff --git a/src/net/effecthandler.cpp b/src/net/effecthandler.cpp
new file mode 100644
index 00000000..04951d46
--- /dev/null
+++ b/src/net/effecthandler.cpp
@@ -0,0 +1,59 @@
+/*
+ * 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
+ *
+ */
+
+#include "effecthandler.h"
+
+#include "messagein.h"
+#include "protocol.h"
+
+#include "../effectmanager.h"
+
+
+EffectHandler::EffectHandler()
+{
+ static const Uint16 _messages[] = {
+ GPMSG_CREATE_EFFECT,
+ 0
+ };
+ handledMessages = _messages;
+}
+
+void EffectHandler::handleMessage(MessageIn &msg)
+{
+ switch (msg.getId())
+ {
+ case GPMSG_CREATE_EFFECT:
+ handleCreateEffects(msg);
+ break;
+ default:
+ break;
+ }
+}
+
+void EffectHandler::handleCreateEffects(MessageIn &msg)
+{
+ int id = msg.readInt16();
+ Uint16 x = msg.readInt16();
+ Uint16 y = msg.readInt16();
+ effectManager->trigger(id, x, y);
+}
+
diff --git a/src/net/effecthandler.h b/src/net/effecthandler.h
new file mode 100644
index 00000000..d836b341
--- /dev/null
+++ b/src/net/effecthandler.h
@@ -0,0 +1,39 @@
+/*
+ * 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
+ *
+ */
+
+#ifndef _TMW_NET_EFFECTSHANDLER_H
+#define _TMW_NET_EFFECTSHANDLER_H
+
+#include "messagehandler.h"
+
+class EffectHandler : public MessageHandler
+{
+ public:
+ EffectHandler();
+
+ void handleMessage(MessageIn &msg);
+
+ private:
+ void handleCreateEffects(MessageIn &msg);
+};
+
+#endif
diff --git a/src/net/protocol.h b/src/net/protocol.h
index ad1eebdb..abbad442 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -131,6 +131,7 @@ enum {
PGMSG_USE_ITEM = 0x0300, // B slot
GPMSG_USE_RESPONSE = 0x0301, // B error
GPMSG_BEINGS_DAMAGE = 0x0310, // { W being id, W amount }*
+ GPMSG_CREATE_EFFECT = 0x0320, // W effect id, W*2 position
// Guild
PCMSG_GUILD_CREATE = 0x0350, // S name