summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog105
-rw-r--r--src/being.cpp12
-rw-r--r--src/being.h8
-rw-r--r--src/game.cpp5
-rw-r--r--src/gui/chat.cpp3
-rw-r--r--src/gui/chat.h3
-rw-r--r--src/gui/itemshortcutcontainer.cpp1
-rw-r--r--src/gui/itemshortcutcontainer.h4
-rw-r--r--src/gui/itemshortcutwindow.cpp1
-rw-r--r--src/gui/itemshortcutwindow.h1
-rw-r--r--src/itemshortcut.cpp4
-rw-r--r--src/itemshortcut.h23
-rw-r--r--src/log.cpp10
-rw-r--r--src/log.h8
-rw-r--r--src/map.cpp88
-rw-r--r--src/map.h12
-rw-r--r--src/net/beinghandler.cpp28
-rw-r--r--src/net/connection.cpp8
-rw-r--r--src/player.cpp63
-rw-r--r--src/player.h16
20 files changed, 265 insertions, 138 deletions
diff --git a/ChangeLog b/ChangeLog
index 0798b7ea..73e1b2be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -173,6 +173,14 @@
Updated attribute system to the latest design decisions
(removed charisma, kept agility in)
+2007-12-14 Philipp Sehmisch <tmw@crushnet.org>
+
+ * data/graphics/sprites/head-mask.png,
+ data/graphics/sprites/head-mask.xml,
+ data/graphics/sprites/head-mushroom.xml,
+ data/graphics/sprites/head-shroom.xml, data/items.xml,
+ data/equipment.xml: Fixed some problems with the new items.
+
2007-12-12 Philipp Sehmisch <tmw@crushnet.org>
* data/graphics/tiles/cave.png, data/graphics/tiles/cave_x2.png:
@@ -194,10 +202,107 @@
tools/tmxcopy/zlibutils.h: Added my tmxcopy tool for copying
parts of maps to other maps.
+2007-12-10 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/being.cpp: Include cassert header.
+
+2007-12-10 Philipp Sehmisch <tmw@crushnet.org>
+
+ * src/being.cpp, src/being.h, src/net/beinghandler.cpp,
+ src/net/charserverhandler.cpp, src/net/equipmenthandler.cpp,
+ src/player.cpp, src/player.h, data/items.xml: Simplified player
+ subsprite handling by treating equipment, hairstyle and base
+ sprites alike. This also enables gender-specific hairstyles.
+ * src/game.cpp, src/gui/chat.cpp, src/gui/chat.h, src/log.cpp,
+ src/log.h: Added an option to show log messages in the chat console.
+ * data/items.xml,
+ data/graphics/sprites/hairstyle1.png,
+ data/graphics/sprites/hairstyle1.xml,
+ data/graphics/sprites/hairstyle1-male.png,
+ data/graphics/sprites/hairstyle1-male.xml,
+ data/graphics/sprites/hairstyle1-female.png,
+ data/graphics/sprites/hairstyle1-female.xml,
+ data/graphics/sprites/hairstyle2.png,
+ data/graphics/sprites/hairstyle2.xml,
+ data/graphics/sprites/hairstyle2-male.png,
+ data/graphics/sprites/hairstyle2-male.xml,
+ data/graphics/sprites/hairstyle2-female.png,
+ data/graphics/sprites/hairstyle2-female.xml,
+ data/graphics/sprites/hairstyle3.png,
+ data/graphics/sprites/hairstyle3.xml,
+ data/graphics/sprites/hairstyle3-male.png,
+ data/graphics/sprites/hairstyle3-male.xml,
+ data/graphics/sprites/hairstyle3-female.png,
+ data/graphics/sprites/hairstyle3-female.xml,
+ data/graphics/sprites/hairstyle4.png,
+ data/graphics/sprites/hairstyle4.xml,
+ data/graphics/sprites/hairstyle4-male.png,
+ data/graphics/sprites/hairstyle4-male.xml,
+ data/graphics/sprites/hairstyle4-female.png,
+ data/graphics/sprites/hairstyle4-female.xml,
+ data/graphics/sprites/hairstyle5.png,
+ data/graphics/sprites/hairstyle5.xml,
+ data/graphics/sprites/hairstyle5-male.png,
+ data/graphics/sprites/hairstyle5-male.xml,
+ data/graphics/sprites/hairstyle5-female.png,
+ data/graphics/sprites/hairstyle5-female.xml,
+ data/graphics/sprites/hairstyle6.png,
+ data/graphics/sprites/hairstyle6.xml,
+ data/graphics/sprites/hairstyle6-male.png,
+ data/graphics/sprites/hairstyle6-male.xml,
+ data/graphics/sprites/hairstyle6-female.png,
+ data/graphics/sprites/hairstyle6-female.xml,
+ data/graphics/sprites/hairstyle7.png,
+ data/graphics/sprites/hairstyle7.xml,
+ data/graphics/sprites/hairstyle7-male.png,
+ data/graphics/sprites/hairstyle7-male.xml,
+ data/graphics/sprites/hairstyle7-female.png,
+ data/graphics/sprites/hairstyle7-female.xml:
+ Implemented female hairstyles.
+
+2007-12-09 Philipp Sehmisch <tmw@crushnet.org>
+
+ * data/graphics/sprites/head-funkywinter.png,
+ data/graphics/sprites/head-funkywinter.xml,
+ data/graphics/sprites/head-xmaself.png,
+ data/graphics/sprites/head-xmaself.xml: New versions of funky hat
+ and elf hat by QOAL.
+
2007-12-09 Björn Steinbrink <B.Steinbrink@gmx.de>
* src/CMakeLists.txt: Add missing source files.
+2007-12-07 Philipp Sehmisch <tmw@crushnet.org>
+
+ * data/graphics/items/generic-santacookie.png,
+ data/items.xml: Added a new drop item for the christmas event.
+
+2007-12-05 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/map.cpp, src/map.h: Fix drawing of very high fringe tiles by
+ keeping track of the maximum tile height.
+ * src/itemshortcut.h, src/gui/itemshortcutcontainer.h,
+ src/gui/itemshortcutcontainer.cpp, src/gui/itemshortcutwindow.cpp,
+ src/gui/itemshortcutwindow.h, src/itemshortcut.cpp: Random cleanups.
+
+2007-12-04 Philipp Sehmisch <tmw@crushnet.org>
+
+ * data/graphics/sprites/head-funkywinter.png,
+ data/graphics/sprites/head-funkywinter.xml,
+ data/graphics/sprites/head-mask.png,
+ data/graphics/sprites/head-mask.xml,
+ data/graphics/sprites/head-mushroom.png,
+ data/graphics/sprites/head-mushroom.xml,
+ data/graphics/sprites/head-shroom.png,
+ data/graphics/sprites/head-shroom.xml,
+ data/graphics/sprites/head-tophat.png,
+ data/graphics/sprites/head-tophat.xml,
+ data/graphics/sprites/head-xmaself.png,
+ data/graphics/sprites/head-xmaself.xml,
+ data/graphics/items/armor-head-xmaself.png,
+ data/graphics/items/armor-head-mask.png,
+ data/items.xml: Added/renamed some headgears for the christmas event.
+
2007-11-21 Bjørn Lindeijer <bjorn@lindeijer.nl>
* src/properties.h, src/net/charserverhandler.cpp, src/being.h: Small
diff --git a/src/being.cpp b/src/being.cpp
index 22c56a6d..20684d8d 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -61,7 +61,9 @@ Being::Being(int id, int job, Map *map):
mEquippedWeapon(NULL),
mSpeechTime(0),
mPx(0), mPy(0),
- mSprites(VECTOREND_SPRITE, NULL)
+ mSprites(VECTOREND_SPRITE, NULL),
+ mSpriteIDs(VECTOREND_SPRITE, 0),
+ mSpriteColors(VECTOREND_SPRITE, "")
{
setMap(map);
@@ -286,6 +288,14 @@ Being::setPath(const Path &path, int mod)
}
void
+Being::setSprite(int slot, int id, const std::string &color)
+{
+ assert(slot >= BASE_SPRITE && slot < VECTOREND_SPRITE);
+ mSpriteIDs[slot] = id;
+ mSpriteColors[slot] = color;
+}
+
+void
Being::setSpeech(const std::string &text, Uint32 time)
{
mSpeech = text;
diff --git a/src/being.h b/src/being.h
index 7c114cd9..a2d977db 100644
--- a/src/being.h
+++ b/src/being.h
@@ -189,6 +189,12 @@ class Being : public Sprite
setName(const std::string &name) { mName = name; }
/**
+ * Sets visible equipments for this being.
+ */
+ virtual void
+ setSprite(int slot, int id, const std::string &color = "");
+
+ /**
* Makes this being take the next step of his path.
*/
virtual void
@@ -349,6 +355,8 @@ class Being : public Sprite
Sint32 mPx, mPy; /**< Pixel coordinates */
std::vector<AnimatedSprite*> mSprites;
+ std::vector<int> mSpriteIDs;
+ std::vector<std::string> mSpriteColors;
std::list<Particle *> mChildParticleEffects;
private:
diff --git a/src/game.cpp b/src/game.cpp
index 9455e47a..7ae21009 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -197,6 +197,11 @@ void createGuiWindows()
miniStatusWindow->setVisible(true);
menuWindow->setVisible(true);
itemShortcutWindow->setVisible(true);
+
+ if (config.getValue("logToChat", 0))
+ {
+ logger->setChatWindow(chatWindow);
+ }
}
/**
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index f750df99..e9bed822 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -165,6 +165,9 @@ ChatWindow::chatLog(std::string line, int own, std::string channelName)
tmp.nick += "Server: ";
lineColor = "##7"; // Equiv. to BrowserBox::PINK
break;
+ case BY_LOGGER:
+ lineColor = "##8"; // Equiv. to BrowserBox::GREY
+ break;
}
// Get the current system time
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 304d5500..19795dd3 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -45,7 +45,8 @@ enum
BY_GM = 0,
BY_PLAYER = 1,
BY_OTHER = 2,
- BY_SERVER = 3
+ BY_SERVER = 3,
+ BY_LOGGER
};
#if 0
diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp
index 6a5d94fc..d86a99ef 100644
--- a/src/gui/itemshortcutcontainer.cpp
+++ b/src/gui/itemshortcutcontainer.cpp
@@ -18,6 +18,7 @@
* 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 "itemshortcutcontainer.h"
diff --git a/src/gui/itemshortcutcontainer.h b/src/gui/itemshortcutcontainer.h
index 4b154cbb..c69525e0 100644
--- a/src/gui/itemshortcutcontainer.h
+++ b/src/gui/itemshortcutcontainer.h
@@ -18,6 +18,7 @@
* 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 _TMW_ITEMSHORTCUTCONTAINER_H__
@@ -26,8 +27,6 @@
#include <guichan/mouselistener.hpp>
#include <guichan/widget.hpp>
-#include <list>
-
class Image;
class Item;
@@ -109,7 +108,6 @@ class ItemShortcutContainer : public gcn::Widget, public gcn::MouseListener
int mGridWidth, mGridHeight;
bool mItemClicked;
Item *mItemMoved;
-
};
#endif
diff --git a/src/gui/itemshortcutwindow.cpp b/src/gui/itemshortcutwindow.cpp
index dd97a7db..cf266290 100644
--- a/src/gui/itemshortcutwindow.cpp
+++ b/src/gui/itemshortcutwindow.cpp
@@ -18,6 +18,7 @@
* 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 "itemshortcutwindow.h"
diff --git a/src/gui/itemshortcutwindow.h b/src/gui/itemshortcutwindow.h
index 83bc348d..1dde8686 100644
--- a/src/gui/itemshortcutwindow.h
+++ b/src/gui/itemshortcutwindow.h
@@ -18,6 +18,7 @@
* 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 _TMW_ITEMSHORTCUTWINDOW_H
diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp
index 8a514c7e..12ae95f2 100644
--- a/src/itemshortcut.cpp
+++ b/src/itemshortcut.cpp
@@ -18,10 +18,12 @@
* 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 "itemshortcut.h"
+#include "item.h"
#include "localplayer.h"
#include "configuration.h"
@@ -51,7 +53,7 @@ void ItemShortcut::load()
if (itemId != -1)
{
- ItemPtr item = player_node->searchForItem(itemId);
+ Item* item = player_node->searchForItem(itemId);
if (item)
{
mItems[i] = item;
diff --git a/src/itemshortcut.h b/src/itemshortcut.h
index d211c7f3..fecb7d86 100644
--- a/src/itemshortcut.h
+++ b/src/itemshortcut.h
@@ -18,20 +18,19 @@
* 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 _TMW_ITEMSHORTCUT_H__
#define _TMW_ITEMSHORTCUT_H__
-#include "item.h"
-
#define SHORTCUT_ITEMS 10
+class Item;
+
/**
- * The item pointer
+ * The class which keeps track of the item shortcuts.
*/
-typedef Item* ItemPtr;
-
class ItemShortcut
{
public:
@@ -55,7 +54,7 @@ class ItemShortcut
*
* @param index Index of the shortcut item.
*/
- ItemPtr getItem(int index) const
+ Item* getItem(int index) const
{ return mItems[index]; }
/**
@@ -67,7 +66,7 @@ class ItemShortcut
/**
* Returns the item that is currently selected.
*/
- ItemPtr getItemSelected() const
+ Item* getItemSelected() const
{ return mItemSelected; }
/**
@@ -92,20 +91,20 @@ class ItemShortcut
*
* @param item The item that is to be assigned.
*/
- void setItemSelected(ItemPtr item)
+ void setItemSelected(Item* item)
{ mItemSelected = item; }
/**
* A flag to check if the item is selected.
*/
bool isItemSelected()
- { return (mItemSelected) ? true : false; }
+ { return mItemSelected; }
/**
* Remove a item from the shortcut.
*/
void removeItem(int index)
- { mItems[index] = NULL; }
+ { mItems[index] = 0; }
/**
* Try to use the item specified by the index.
@@ -120,8 +119,8 @@ class ItemShortcut
*/
void save();
- ItemPtr mItems[SHORTCUT_ITEMS]; /**< the items stored */
- ItemPtr mItemSelected; /**< the item held by cursor */
+ Item* mItems[SHORTCUT_ITEMS]; /**< The items stored. */
+ Item* mItemSelected; /**< The item held by cursor. */
};
diff --git a/src/log.cpp b/src/log.cpp
index 63a34776..96630a96 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -34,8 +34,11 @@
#include "log.h"
+#include "gui/chat.h"
+
Logger::Logger():
- mLogToStandardOut(false)
+ mLogToStandardOut(false),
+ mChatWindow(NULL)
{
}
@@ -100,6 +103,11 @@ void Logger::log(const char *log_text, ...)
std::cout << timeStr.str() << buf << std::endl;
}
+ if (mChatWindow)
+ {
+ mChatWindow->chatLog(buf, BY_LOGGER);
+ }
+
// Delete temporary buffer
delete[] buf;
}
diff --git a/src/log.h b/src/log.h
index 36328527..dd1c0f91 100644
--- a/src/log.h
+++ b/src/log.h
@@ -25,6 +25,8 @@
#include <iosfwd>
#include <fstream>
+class ChatWindow;
+
/**
* The Log Class : Useful to write debug or info messages
*/
@@ -52,6 +54,11 @@ class Logger
void setLogToStandardOut(bool value) { mLogToStandardOut = value; }
/**
+ * Enables logging to chat window
+ */
+ void setChatWindow(ChatWindow *window) { mChatWindow = window; }
+
+ /**
* Enters a message in the log. The message will be timestamped.
*/
void log(const char *log_text, ...);
@@ -65,6 +72,7 @@ class Logger
private:
std::ofstream mLogFile;
bool mLogToStandardOut;
+ ChatWindow *mChatWindow;
};
extern Logger *logger;
diff --git a/src/map.cpp b/src/map.cpp
index ac570627..c2b0b9a1 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -65,6 +65,7 @@ struct Location
Map::Map(int width, int height, int tileWidth, int tileHeight):
mWidth(width), mHeight(height),
mTileWidth(tileWidth), mTileHeight(tileHeight),
+ mMaxTileHeight(height),
mOnClosedList(1), mOnOpenList(2),
mLastScrollX(0.0f), mLastScrollY(0.0f)
{
@@ -87,8 +88,7 @@ Map::~Map()
for_each(mOverlays.begin(), mOverlays.end(), make_dtor(mOverlays));
}
-void
-Map::initializeOverlays()
+void Map::initializeOverlays()
{
ResourceManager *resman = ResourceManager::getInstance();
@@ -114,10 +114,12 @@ Map::initializeOverlays()
}
}
-void
-Map::addTileset(Tileset *tileset)
+void Map::addTileset(Tileset *tileset)
{
mTilesets.push_back(tileset);
+
+ if (tileset->getHeight() > mMaxTileHeight)
+ mMaxTileHeight = tileset->getHeight();
}
bool spriteCompare(const Sprite *a, const Sprite *b)
@@ -125,13 +127,9 @@ bool spriteCompare(const Sprite *a, const Sprite *b)
return a->getPixelY() < b->getPixelY();
}
-void
-Map::draw(Graphics *graphics, int scrollX, int scrollY, int layer)
+void Map::draw(Graphics *graphics, int scrollX, int scrollY, int layer)
{
- int startX = scrollX / 32;
- int startY = scrollY / 32;
- int endX = (graphics->getWidth() + scrollX + 31) / 32;
- int endY = (graphics->getHeight() + scrollY + 31) / 32;
+ int endPixelY = graphics->getHeight() + scrollY + mTileHeight - 1;
// If drawing the fringe layer, make sure sprites are sorted
SpriteIterator si;
@@ -139,13 +137,14 @@ Map::draw(Graphics *graphics, int scrollX, int scrollY, int layer)
{
mSprites.sort(spriteCompare);
si = mSprites.begin();
-
- // Increase endY to account for high fringe tiles
- // TODO: Improve this hack so that it'll dynamically account for the
- // highest tile.
- endY += 2;
+ endPixelY += mMaxTileHeight - mTileHeight;
}
+ int startX = scrollX / mTileWidth;
+ int startY = scrollY / mTileHeight;
+ int endX = (graphics->getWidth() + scrollX + mTileWidth - 1) / mTileWidth;
+ int endY = endPixelY / mTileHeight;
+
if (startX < 0) startX = 0;
if (startY < 0) startY = 0;
if (endX > mWidth) endX = mWidth;
@@ -169,8 +168,9 @@ Map::draw(Graphics *graphics, int scrollX, int scrollY, int layer)
Image *img = getTile(x, y, layer);
if (img) {
graphics->drawImage(img,
- x * 32 - scrollX,
- y * 32 - scrollY + 32 - img->getHeight());
+ x * mTileWidth - scrollX,
+ y * mTileHeight - scrollY +
+ mTileHeight - img->getHeight());
}
}
}
@@ -186,8 +186,8 @@ Map::draw(Graphics *graphics, int scrollX, int scrollY, int layer)
}
}
-void
-Map::drawOverlay(Graphics *graphics, float scrollX, float scrollY, int detail)
+void Map::drawOverlay(Graphics *graphics,
+ float scrollX, float scrollY, int detail)
{
static int lastTick = tick_time;
@@ -226,8 +226,7 @@ Map::drawOverlay(Graphics *graphics, float scrollX, float scrollY, int detail)
};
}
-void
-Map::setTileWithGid(int x, int y, int layer, int gid)
+void Map::setTileWithGid(int x, int y, int layer, int gid)
{
if (layer == 3)
{
@@ -251,19 +250,17 @@ class ContainsGidFunctor
int gid;
} containsGid;
-Tileset*
-Map::getTilesetWithGid(int gid)
+Tileset* Map::getTilesetWithGid(int gid) const
{
containsGid.gid = gid;
- TilesetIterator i = find_if(mTilesets.begin(), mTilesets.end(),
+ Tilesets::const_iterator i = find_if(mTilesets.begin(), mTilesets.end(),
containsGid);
return (i == mTilesets.end()) ? NULL : *i;
}
-Image*
-Map::getTileWithGid(int gid)
+Image* Map::getTileWithGid(int gid) const
{
Tileset *set = getTilesetWithGid(gid);
@@ -274,20 +271,17 @@ Map::getTileWithGid(int gid)
return NULL;
}
-void
-Map::setWalk(int x, int y, bool walkable)
+void Map::setWalk(int x, int y, bool walkable)
{
mMetaTiles[x + y * mWidth].walkable = walkable;
}
-bool
-Map::getWalk(int x, int y) const
+bool Map::getWalk(int x, int y) const
{
return !tileCollides(x, y) && !occupied(x, y);
}
-bool
-Map::occupied(int x, int y) const
+bool Map::occupied(int x, int y) const
{
Beings &beings = beingManager->getAll();
for (BeingIterator i = beings.begin(); i != beings.end(); i++)
@@ -302,53 +296,45 @@ Map::occupied(int x, int y) const
return false;
}
-bool
-Map::tileCollides(int x, int y) const
+bool Map::tileCollides(int x, int y) const
{
return !(contains(x, y) && mMetaTiles[x + y * mWidth].walkable);
}
-bool
-Map::contains(int x, int y) const
+bool Map::contains(int x, int y) const
{
return x >= 0 && y >= 0 && x < mWidth && y < mHeight;
}
-void
-Map::setTile(int x, int y, int layer, Image *img)
+void Map::setTile(int x, int y, int layer, Image *img)
{
mTiles[x + y * mWidth + layer * (mWidth * mHeight)] = img;
}
-Image*
-Map::getTile(int x, int y, int layer)
+Image* Map::getTile(int x, int y, int layer) const
{
return mTiles[x + y * mWidth + layer * (mWidth * mHeight)];
}
-MetaTile*
-Map::getMetaTile(int x, int y)
+MetaTile* Map::getMetaTile(int x, int y) const
{
return &mMetaTiles[x + y * mWidth];
}
-SpriteIterator
-Map::addSprite(Sprite *sprite)
+SpriteIterator Map::addSprite(Sprite *sprite)
{
mSprites.push_front(sprite);
return mSprites.begin();
}
-void
-Map::removeSprite(SpriteIterator iterator)
+void Map::removeSprite(SpriteIterator iterator)
{
mSprites.erase(iterator);
}
static int const basicCost = 100;
-Path
-Map::findPath(int startX, int startY, int destX, int destY)
+Path Map::findPath(int startX, int startY, int destX, int destY)
{
// Path to be built up (empty by default)
Path path;
@@ -532,8 +518,7 @@ Map::findPath(int startX, int startY, int destX, int destY)
return path;
}
-void
-Map::addParticleEffect (std::string effectFile, int x, int y)
+void Map::addParticleEffect (std::string effectFile, int x, int y)
{
ParticleEffectData newEffect;
newEffect.file = effectFile;
@@ -542,8 +527,7 @@ Map::addParticleEffect (std::string effectFile, int x, int y)
particleEffects.push_back(newEffect);
}
-void
-Map::initializeParticleEffects(Particle* particleEngine)
+void Map::initializeParticleEffects(Particle* particleEngine)
{
for (std::list<ParticleEffectData>::iterator i = particleEffects.begin();
i != particleEffects.end();
diff --git a/src/map.h b/src/map.h
index 17772847..d8cc2189 100644
--- a/src/map.h
+++ b/src/map.h
@@ -39,7 +39,6 @@ class Tileset;
struct PATH_NODE;
typedef std::vector<Tileset*> Tilesets;
-typedef Tilesets::iterator TilesetIterator;
typedef std::list<Sprite*> Sprites;
typedef Sprites::iterator SpriteIterator;
@@ -122,12 +121,12 @@ class Map : public Properties
/**
* Get tile ID.
*/
- Image *getTile(int x, int y, int layer);
+ Image *getTile(int x, int y, int layer) const;
/**
* Get tile reference.
*/
- MetaTile *getMetaTile(int x, int y);
+ MetaTile *getMetaTile(int x, int y) const;
/**
* Set walkability flag for a tile.
@@ -202,14 +201,12 @@ class Map : public Properties
* Converts a global tile id to the Image* pointing to the associated
* tile image.
*/
- Image*
- getTileWithGid(int gid);
+ Image* getTileWithGid(int gid) const;
/**
* Finds the tile set that a tile with the given global id is part of.
*/
- Tileset*
- getTilesetWithGid(int gid);
+ Tileset* getTilesetWithGid(int gid) const;
/**
* Tells whether a tile is occupied by a being.
@@ -223,6 +220,7 @@ class Map : public Properties
int mWidth, mHeight;
int mTileWidth, mTileHeight;
+ int mMaxTileHeight;
MetaTile *mMetaTiles;
Image **mTiles;
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp
index 879c8a46..24db8454 100644
--- a/src/net/beinghandler.cpp
+++ b/src/net/beinghandler.cpp
@@ -140,9 +140,9 @@ void BeingHandler::handleMessage(MessageIn &msg)
dstBeing->setWalkSpeed(speed);
dstBeing->mJob = job;
dstBeing->setHairStyle(msg->readInt16());
- dstBeing->setVisibleEquipment(
+ dstBeing->setSprite(
Being::WEAPON_SPRITE, msg->readInt16());
- dstBeing->setVisibleEquipment(
+ dstBeing->setSprite(
Being::BOTTOMCLOTHES_SPRITE, msg->readInt16());
if (msg.getId() == SMSG_BEING_MOVE)
@@ -153,8 +153,8 @@ void BeingHandler::handleMessage(MessageIn &msg)
msg->readInt16(); // shield
headTop = msg->readInt16();
headMid = msg->readInt16();
- dstBeing->setVisibleEquipment(Being::HAT_SPRITE, headTop);
- dstBeing->setVisibleEquipment(Being::TOPCLOTHES_SPRITE, headMid);
+ dstBeing->setSprite(Being::HAT_SPRITE, headTop);
+ dstBeing->setSprite(Being::TOPCLOTHES_SPRITE, headMid);
dstBeing->setHairColor(msg->readInt16());
msg->readInt16(); // unknown
msg->readInt16(); // head dir
@@ -294,18 +294,18 @@ void BeingHandler::handleMessage(MessageIn &msg)
dstBeing->setHairStyle(id);
break;
case 2:
- dstBeing->setVisibleEquipment(Being::WEAPON_SPRITE, id);
+ dstBeing->setSprite(Being::WEAPON_SPRITE, id);
break;
case 3: // Change lower headgear for eAthena, pants for us
- dstBeing->setVisibleEquipment(
+ dstBeing->setSprite(
Being::BOTTOMCLOTHES_SPRITE, id);
break;
case 4: // Change upper headgear for eAthena, hat for us
- dstBeing->setVisibleEquipment(
+ dstBeing->setSprite(
Being::HAT_SPRITE, id);
break;
case 5: // Change middle headgear for eathena, armor for us
- dstBeing->setVisibleEquipment(
+ dstBeing->setSprite(
Being::TOPCLOTHES_SPRITE, id);
break;
case 6:
@@ -347,7 +347,7 @@ void BeingHandler::handleMessage(MessageIn &msg)
dstBeing->setWalkSpeed(speed);
dstBeing->mJob = job;
dstBeing->setHairStyle(msg->readInt16());
- dstBeing->setVisibleEquipment(
+ dstBeing->setSprite(
Being::WEAPON_SPRITE, msg->readInt16());
msg->readInt16(); // item id 2
headBottom = msg->readInt16();
@@ -367,10 +367,10 @@ void BeingHandler::handleMessage(MessageIn &msg)
msg.readInt16(); // manner
msg.readInt8(); // karma
dstBeing->setSex(1 - msg.readInt8()); // sex
- dstBeing->setVisibleEquipment(
+ dstBeing->setSprite(
Being::BOTTOMCLOTHES_SPRITE, headBottom);
- dstBeing->setVisibleEquipment(Being::HAT_SPRITE, headTop);
- dstBeing->setVisibleEquipment(Being::TOPCLOTHES_SPRITE, headMid);
+ dstBeing->setSprite(Being::HAT_SPRITE, headTop);
+ dstBeing->setSprite(Being::TOPCLOTHES_SPRITE, headMid);
if (msg.getId() == SMSG_PLAYER_MOVE)
{
@@ -434,7 +434,7 @@ static void handleLooks(Player *being, MessageIn &msg)
// The equipment has to be cleared first.
for (int i = 0; i < nb_slots; ++i)
{
- being->setVisibleEquipment(slots[i], 0);
+ being->setSprite(slots[i], 0);
}
}
@@ -443,7 +443,7 @@ static void handleLooks(Player *being, MessageIn &msg)
{
if (!(mask & (1 << i))) continue;
int id = msg.readInt16();
- being->setVisibleEquipment(slots[i], id);
+ being->setSprite(slots[i], id);
}
}
diff --git a/src/net/connection.cpp b/src/net/connection.cpp
index caaa0ce1..a016e07a 100644
--- a/src/net/connection.cpp
+++ b/src/net/connection.cpp
@@ -67,6 +67,14 @@ bool Net::Connection::connect(const std::string &address, short port)
return false;
}
+ ENetEvent event;
+ if (enet_host_service(mClient, &event, 10000) <= 0 ||
+ event.type != ENET_EVENT_TYPE_CONNECT)
+ {
+ logger->log("Well....");
+ return false;
+ }
+
return true;
}
diff --git a/src/player.cpp b/src/player.cpp
index f928aeb1..050790e8 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -37,8 +37,9 @@
Player::Player(int id, int job, Map *map):
Being(id, job, map),
- mEquipmentSpriteIDs(VECTOREND_SPRITE, 0),
- mGender(2), mHairStyle(0), mHairColor(0)
+ mGender(2),
+ mHairStyle(0),
+ mHairColor(0)
{
}
@@ -59,45 +60,31 @@ Player::drawName(Graphics *graphics, int offsetX, int offsetY)
graphics->drawText(mName, px + 15, py + 30, gcn::Graphics::CENTER);
}
-void Player::setGender(int sex)
+void Player::setGender(int gender)
{
// Players can only be male or female
- if (sex > 1)
+ if (gender > 1)
{
- logger->log("Warning: unsupported gender %i, assuming male.", sex);
- sex = 0;
+ logger->log("Warning: unsupported gender %i, assuming male.", gender);
+ gender = 0;
}
- if (sex != mGender)
+ if (gender != mGender)
{
- mGender = sex;
+ mGender = gender;
- // Reload base sprite
- AnimatedSprite *newBaseSprite;
- if (sex == 0)
- {
- newBaseSprite = AnimatedSprite::load(
- "graphics/sprites/player_male_base.xml");
- }
- else
- {
- newBaseSprite = AnimatedSprite::load(
- "graphics/sprites/player_female_base.xml");
- }
+ /* Human base sprite. When implementing different races remove this
+ * line and set the base sprite when setting the race of the player
+ * character.
+ */
+ setSprite(Being::BASE_SPRITE, -100);
- delete mSprites[BASE_SPRITE];
- mSprites[BASE_SPRITE] = newBaseSprite;
-
- // Reload equipment
+ // Reload all subsprites
for (int i = 1; i < VECTOREND_SPRITE; i++)
{
- if (i != HAIR_SPRITE && mEquipmentSpriteIDs.at(i) != 0)
+ if (mSpriteIDs.at(i) != 0)
{
- AnimatedSprite *newEqSprite = AnimatedSprite::load(
- "graphics/sprites/" + ItemDB::get(
- mEquipmentSpriteIDs.at(i)).getSprite(sex));
- delete mSprites[i];
- mSprites[i] = newEqSprite;
+ setSprite(i, mSpriteIDs.at(i), mSpriteColors.at(i));
}
}
}
@@ -126,19 +113,12 @@ void Player::setHairStyle(int style, int color)
"#460850,611967,e7b4ae", // dark purple
};
- AnimatedSprite *newHairSprite = AnimatedSprite::load
- (strprintf("graphics/sprites/hairstyle%d.xml|%s", style, colors[color]));
-
- if (newHairSprite)
- newHairSprite->setDirection(getSpriteDirection());
-
- delete mSprites[HAIR_SPRITE];
- mSprites[HAIR_SPRITE] = newHairSprite;
+ setSprite(HAIR_SPRITE, style * -1, colors[color]);
setAction(mAction);
}
-void Player::setVisibleEquipment(int slot, int id)
+void Player::setSprite(int slot, int id, const std::string &color)
{
// id = 0 means unequip
if (id == 0)
@@ -149,7 +129,8 @@ void Player::setVisibleEquipment(int slot, int id)
else
{
AnimatedSprite *equipmentSprite = AnimatedSprite::load(
- "graphics/sprites/" + ItemDB::get(id).getSprite(mGender));
+ "graphics/sprites/" + ItemDB::get(id).getSprite(mGender) +
+ "|" + color);
if (equipmentSprite)
equipmentSprite->setDirection(getSpriteDirection());
@@ -165,5 +146,5 @@ void Player::setVisibleEquipment(int slot, int id)
setAction(mAction);
}
- mEquipmentSpriteIDs[slot] = id;
+ Being::setSprite(slot, id, color);
}
diff --git a/src/player.h b/src/player.h
index 4d4f53f5..eb642d20 100644
--- a/src/player.h
+++ b/src/player.h
@@ -49,7 +49,7 @@ class Player : public Being
drawName(Graphics *graphics, int offsetX, int offsetY);
/**
- * Sets the sex for this player.
+ * Sets the gender for this player.
*/
void setGender(int);
@@ -67,18 +67,24 @@ class Player : public Being
/**
* Sets the hair style and color for this player.
+ *
+ * NOTE: This method was necessary for convenience in the 0.0 client.
+ * It should be removed here since the server can provide the hair ID
+ * and coloring the same way it does for other equipment pieces. Then
+ * Being::setSprite can be used instead.
*/
void setHairStyle(int style, int color);
/**
* Sets visible equipments for this player.
*/
- void setVisibleEquipment(int slot, int id);
+ virtual void
+ setSprite(int slot, int id, const std::string &color = "");
private:
-
- std::vector<int> mEquipmentSpriteIDs;
- Uint8 mGender, mHairStyle, mHairColor;
+ Uint8 mGender;
+ Uint8 mHairStyle;
+ Uint8 mHairColor;
};
#endif