summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/magic.cpp39
-rw-r--r--src/gui/magic.h13
-rw-r--r--src/localplayer.cpp28
-rw-r--r--src/localplayer.h17
-rw-r--r--src/net/tmwserv/inventoryhandler.cpp6
-rw-r--r--src/net/tmwserv/playerhandler.cpp14
-rw-r--r--src/net/tmwserv/protocol.h3
7 files changed, 107 insertions, 13 deletions
diff --git a/src/gui/magic.cpp b/src/gui/magic.cpp
index 48cfc5dc..6e314656 100644
--- a/src/gui/magic.cpp
+++ b/src/gui/magic.cpp
@@ -38,17 +38,19 @@ MagicDialog::MagicDialog():
setDefaultSize(255, 30, 175, 225);
setupWindow->registerWindowForReset(this);
- gcn::Button *spellButton1 = new Button(_("Cast Test Spell 1"), "spell_1", this);
- gcn::Button *spellButton2 = new Button(_("Cast Test Spell 2"), "spell_2", this);
- gcn::Button *spellButton3 = new Button(_("Cast Test Spell 3"), "spell_3", this);
+ mSpellButtons.resize(4);
- spellButton1->setPosition(10, 30);
- spellButton2->setPosition(10, 60);
- spellButton3->setPosition(10, 90);
+ mSpellButtons[1] = new Button(_("Spell 1"), "spell_1", this);
+ mSpellButtons[2] = new Button(_("Spell 2"), "spell_2", this);
+ mSpellButtons[3] = new Button(_("Spell 3"), "spell_3", this);
- add(spellButton1);
- add(spellButton2);
- add(spellButton3);
+ mSpellButtons[1]->setPosition(10, 60);
+ mSpellButtons[2]->setPosition(10, 90);
+ mSpellButtons[3]->setPosition(10, 120);
+
+ add(mSpellButtons[1]);
+ add(mSpellButtons[2]);
+ add(mSpellButtons[3]);
update();
@@ -89,4 +91,23 @@ void MagicDialog::draw(gcn::Graphics *g)
void MagicDialog::update()
{
+ std::map<int, Special> specials = player_node->getSpecialStatus();
+
+ for (size_t i = 1; i < mSpellButtons.size(); i++)
+ {
+ if (specials.find(i) != specials.end())
+ {
+ std::stringstream s;
+ s <<
+ "Spell" <<
+ i <<
+ " (" <<
+ specials[i].currentMana <<
+ "/" <<
+ specials[i].neededMana <<
+ ")";
+ mSpellButtons[i]->setCaption(s.str());
+ mSpellButtons[i]->adjustSize();
+ }
+ }
}
diff --git a/src/gui/magic.h b/src/gui/magic.h
index 734ad799..44a1a6fc 100644
--- a/src/gui/magic.h
+++ b/src/gui/magic.h
@@ -22,6 +22,8 @@
#ifndef MAGIC_H
#define MAGIC_H
+#include <vector>
+
#include "gui/widgets/window.h"
#include "guichanfwd.h"
@@ -29,7 +31,13 @@
#include <guichan/actionlistener.hpp>
/**
- * The skill dialog.
+ * The magic interface.
+ *
+ * This window is hacked together quickly to test the spell
+ * recharge netcode.
+ * It does in no way represent how the interface is going to
+ * look in the final version. Optimization / cleanup is
+ * pointless, as it will be redesigned from scratch.
*
* \ingroup Interface
*/
@@ -54,6 +62,9 @@ class MagicDialog : public Window, public gcn::ActionListener
* Draw this window.
*/
void draw(gcn::Graphics *g);
+
+ private:
+ std::vector<gcn::Button *> mSpellButtons;
};
extern MagicDialog *magicDialog;
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 57dc8981..1cc0ae34 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -28,6 +28,7 @@
#include "graphics.h"
#include "inventory.h"
#include "item.h"
+#include "log.h"
#include "map.h"
#include "monster.h"
#include "particle.h"
@@ -167,6 +168,22 @@ void LocalPlayer::logic()
mMessageTime--;
}
+ if ((mSpecialRechargeUpdateNeeded%11) == 0)
+ {
+ mSpecialRechargeUpdateNeeded = 0;
+ for (std::map<int, Special>::iterator i = mSpecials.begin();
+ i != mSpecials.end();
+ i++)
+ {
+ i->second.currentMana += i->second.recharge;
+ if (i->second.currentMana > i->second.neededMana)
+ {
+ i->second.currentMana = i->second.neededMana;
+ }
+ }
+ }
+ mSpecialRechargeUpdateNeeded++;
+
#ifdef EATHENA_SUPPORT
// Targeting allowed 4 times a second
if (get_elapsed_time(mLastTarget) >= 250)
@@ -633,13 +650,22 @@ void LocalPlayer::attack()
Net::GameServer::Player::attack(getSpriteDirection());
}
*/
-#endif
void LocalPlayer::useSpecial(int special)
{
Net::getSpecialHandler()->use(special);
}
+void LocalPlayer::setSpecialStatus(int id, int current, int max, int recharge)
+{
+ logger->log("SpecialUpdate Skill #%d -- (%d/%d) -> %d", id, current, max, recharge);
+ mSpecials[id].currentMana = current;
+ mSpecials[id].neededMana = max;
+ mSpecials[id].recharge = recharge;
+}
+
+#endif
+
void LocalPlayer::attack(Being *target, bool keep)
{
#ifdef TMWSERV_SUPPORT
diff --git a/src/localplayer.h b/src/localplayer.h
index fa0b8984..0b41ca82 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -35,6 +35,15 @@ class Inventory;
class Item;
class Map;
+
+struct Special
+{
+ int currentMana;
+ int neededMana;
+ int recharge;
+};
+
+
/**
* Attributes used during combat. Available to all the beings.
*/
@@ -174,6 +183,11 @@ class LocalPlayer : public Player
void useSpecial(int id);
+ void setSpecialStatus(int id, int current, int max, int recharge);
+
+ const std::map<int, Special> &getSpecialStatus() const
+ { return mSpecials; }
+
void attack(Being *target = NULL, bool keep = false);
/**
@@ -379,6 +393,9 @@ class LocalPlayer : public Player
std::map<int, std::pair<int, int> > mSkillExp;
int mCharacterPoints;
int mCorrectionPoints;
+ int mLevelProgress;
+ std::map<int, Special> mSpecials;
+ char mSpecialRechargeUpdateNeeded;
int mLevel;
int mExp, mExpNeeded;
int mMp, mMaxMp;
diff --git a/src/net/tmwserv/inventoryhandler.cpp b/src/net/tmwserv/inventoryhandler.cpp
index 8110fdd2..6993167c 100644
--- a/src/net/tmwserv/inventoryhandler.cpp
+++ b/src/net/tmwserv/inventoryhandler.cpp
@@ -40,6 +40,8 @@
#include "resources/iteminfo.h"
+#include "log.h" // <<< REMOVE ME!
+
Net::InventoryHandler *inventoryHandler;
namespace TmwServ {
@@ -102,7 +104,9 @@ void InventoryHandler::unequipItem(const Item *item)
Net::GameServer::connection->send(msg);
// Tidy equipment directly to avoid weapon still shown bug, for instance
- player_node->mEquipment->setEquipment(item->getInvIndex(), 0);
+ int equipSlot = item->getInvIndex();
+ logger->log("Unequipping %d", equipSlot);
+ player_node->mEquipment->setEquipment(equipSlot, 0);
}
void InventoryHandler::useItem(const Item *item)
diff --git a/src/net/tmwserv/playerhandler.cpp b/src/net/tmwserv/playerhandler.cpp
index 656befdf..ce1990ed 100644
--- a/src/net/tmwserv/playerhandler.cpp
+++ b/src/net/tmwserv/playerhandler.cpp
@@ -105,6 +105,7 @@ PlayerHandler::PlayerHandler()
GPMSG_LEVEL_PROGRESS,
GPMSG_RAISE_ATTRIBUTE_RESPONSE,
GPMSG_LOWER_ATTRIBUTE_RESPONSE,
+ GPMSG_SPECIAL_STATUS,
0
};
handledMessages = _messages;
@@ -255,6 +256,19 @@ void PlayerHandler::handleMessage(MessageIn &msg)
}
} break;
+
+ case GPMSG_SPECIAL_STATUS :
+ {
+ while (msg.getUnreadLength())
+ {
+ // { B specialID, L current, L max, L recharge }
+ int id = msg.readInt8();
+ int current = msg.readInt32();
+ int max = msg.readInt32();
+ int recharge = msg.readInt32();
+ player_node->setSpecialStatus(id, current, max, recharge);
+ }
+ } break;
/*
case SMSG_PLAYER_ARROW_MESSAGE:
{
diff --git a/src/net/tmwserv/protocol.h b/src/net/tmwserv/protocol.h
index 90ff2437..60a50d89 100644
--- a/src/net/tmwserv/protocol.h
+++ b/src/net/tmwserv/protocol.h
@@ -107,8 +107,9 @@ enum {
GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, W*2 position, B speed] }*
GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }*
PGMSG_ATTACK = 0x0290, // W being id
- PGMSG_USE_SPECIAL = 0x0292, // B specialID
GPMSG_BEING_ATTACK = 0x0291, // W being id
+ PGMSG_USE_SPECIAL = 0x0292, // B specialID
+ GPMSG_SPECIAL_STATUS = 0x0293, // { B specialID, L current, L max, L recharge }
PGMSG_SAY = 0x02A0, // S text
GPMSG_SAY = 0x02A1, // W being id, S text
GPMSG_NPC_CHOICE = 0x02B0, // W being id, { S text }*