diff options
author | David Athay <ko2fan@gmail.com> | 2009-03-30 10:56:47 +0100 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2009-03-30 10:56:47 +0100 |
commit | 67cc90165693e445c6b45b4e381148516237c09c (patch) | |
tree | 684264c576e4812e36c6a3a6987d4b1167fc3c1c /src | |
parent | 59cdf04f88eb515fa349404992652ed004e9bb3e (diff) | |
parent | 3a54fb903f9cc2cc47a852dab6569848d19c6dad (diff) | |
download | manaserv-67cc90165693e445c6b45b4e381148516237c09c.tar.gz manaserv-67cc90165693e445c6b45b4e381148516237c09c.tar.bz2 manaserv-67cc90165693e445c6b45b4e381148516237c09c.tar.xz manaserv-67cc90165693e445c6b45b4e381148516237c09c.zip |
Merge branch 'master' of git@gitorious.org:tmwserv/mainline
Diffstat (limited to 'src')
-rw-r--r-- | src/account-server/dalstorage.cpp | 2 | ||||
-rw-r--r-- | src/chat-server/post.cpp | 6 | ||||
-rw-r--r-- | src/common/transaction.hpp | 2 | ||||
-rw-r--r-- | src/game-server/being.cpp | 5 | ||||
-rw-r--r-- | src/game-server/map.cpp | 16 | ||||
-rw-r--r-- | src/game-server/map.hpp | 16 | ||||
-rw-r--r-- | src/game-server/mapcomposite.cpp | 9 | ||||
-rw-r--r-- | src/game-server/mapcomposite.hpp | 13 | ||||
-rw-r--r-- | src/game-server/mapreader.cpp | 19 | ||||
-rw-r--r-- | src/sql/sqlite/createTables.sql | 4 | ||||
-rw-r--r-- | src/sql/sqlite/updates/update_2_to_3.sql | 2 | ||||
-rw-r--r-- | src/utils/stringfilter.cpp | 8 |
12 files changed, 84 insertions, 18 deletions
diff --git a/src/account-server/dalstorage.cpp b/src/account-server/dalstorage.cpp index eac9f409..086487f3 100644 --- a/src/account-server/dalstorage.cpp +++ b/src/account-server/dalstorage.cpp @@ -1688,7 +1688,7 @@ std::vector<Transaction> DALStorage::getTransactions(time_t date) << date; dal::RecordSet const &rec = mDb->execSql(sql.str()); - for (int i = 0; i < rec.rows(); ++i) + for (unsigned int i = 0; i < rec.rows(); ++i) { Transaction trans; trans.mCharacterId = toUint(rec(i, 1)); diff --git a/src/chat-server/post.cpp b/src/chat-server/post.cpp index e3f4c4f0..ba829c02 100644 --- a/src/chat-server/post.cpp +++ b/src/chat-server/post.cpp @@ -62,7 +62,8 @@ std::string Letter::getContents() bool Letter::addAttachment(InventoryItem item) { - if (mAttachments.size() > Configuration::getValue("mail_maxAttachments", 3)) + unsigned int max = Configuration::getValue("mail_maxAttachments", 3); + if (mAttachments.size() > max) { return false; } @@ -102,7 +103,8 @@ Post::~Post() bool Post::addLetter(Letter *letter) { - if (mLetters.size() > Configuration::getValue("mail_maxLetters", 10)) + unsigned int max = Configuration::getValue("mail_maxLetters", 10); + if (mLetters.size() > max) { return false; } diff --git a/src/common/transaction.hpp b/src/common/transaction.hpp index 21a00de8..3cdb4d58 100644 --- a/src/common/transaction.hpp +++ b/src/common/transaction.hpp @@ -61,7 +61,7 @@ enum TRANS_TRADE_MONEY, TRANS_TRADE_ITEM, TRANS_ATTR_INCREASE, - TRANS_ATTR_DECREASE, + TRANS_ATTR_DECREASE }; #endif diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp index cec2c4e6..ace30861 100644 --- a/src/game-server/being.cpp +++ b/src/game-server/being.cpp @@ -190,6 +190,11 @@ void Being::performAttack(Damage const &damage, AttackZone const *attackZone) int type = o->getType(); if (type != OBJECT_CHARACTER && type != OBJECT_MONSTER) continue; + if (getMap()->getPvP() == PVP_NONE && + type == OBJECT_CHARACTER && + getType() == OBJECT_CHARACTER) + continue; + LOG_DEBUG("Attack Zone:"<< attPos.x<<":"<<attPos.y<< " "<< diff --git a/src/game-server/map.cpp b/src/game-server/map.cpp index 0956571e..3821b0a8 100644 --- a/src/game-server/map.cpp +++ b/src/game-server/map.cpp @@ -65,8 +65,7 @@ Map::~Map() } } -void -Map::setSize(int width, int height) +void Map::setSize(int width, int height) { this->mWidth = width; this->mHeight = height; @@ -81,6 +80,16 @@ Map::setSize(int width, int height) } } +const std::string &Map::getProperty(const std::string &key) const +{ + static std::string empty; + std::map<std::string, std::string>::const_iterator i; + i = mProperties.find(key); + if (i == mProperties.end()) + return empty; + return i->second; +} + void Map::blockTile(int x, int y, BlockType type) { if (type == BLOCKTYPE_NONE || x < 0 || y < 0 || x >= mWidth || y >= mHeight) @@ -151,8 +160,7 @@ bool Map::getWalk(int x, int y, char walkmask) const return !(mMetaTiles[x + y * mWidth].blockmask & walkmask); } -MetaTile* -Map::getMetaTile(int x, int y) +MetaTile *Map::getMetaTile(int x, int y) { return &mMetaTiles[x + y * mWidth]; } diff --git a/src/game-server/map.hpp b/src/game-server/map.hpp index 3a9badf9..bbc33fea 100644 --- a/src/game-server/map.hpp +++ b/src/game-server/map.hpp @@ -155,6 +155,17 @@ class Map { return tileHeight; } /** + * Returns a general map property defined in the map file + */ + const std::string &getProperty(const std::string &key) const; + + /** + * Sets a map property + */ + void setProperty(const std::string& key, const std::string& val) + { mProperties[key] = val; } + + /** * Find a path from one location to the next. */ std::list<PATH_NODE> findPath(int startX, int startY, @@ -170,11 +181,14 @@ class Map static const unsigned char BLOCKMASK_CHARACTER = 0x01;// = bin 0000 0001 static const unsigned char BLOCKMASK_MONSTER = 0x02; // = bin 0000 0010 int *mOccupation[NB_BLOCKTYPES]; + + // map properties int mWidth, mHeight; int tileWidth, tileHeight; - MetaTile *mMetaTiles; + std::map<std::string, std::string> mProperties; // Pathfinding members + MetaTile *mMetaTiles; int onClosedList, onOpenList; }; diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp index 137622d5..4994b901 100644 --- a/src/game-server/mapcomposite.cpp +++ b/src/game-server/mapcomposite.cpp @@ -23,6 +23,7 @@ #include <cassert> #include "point.h" +#include "common/configuration.hpp" #include "game-server/map.hpp" #include "game-server/mapcomposite.hpp" #include "game-server/character.hpp" @@ -539,6 +540,14 @@ void MapComposite::setMap(Map *m) assert(!mMap && m); mMap = m; mContent = new MapContent(m); + + std::string sPvP = m->getProperty ("pvp"); + if (sPvP == "") sPvP = Configuration::getValue("defaultPvp", ""); + + if (sPvP == "free") mPvPRules = PVP_FREE; + else if (sPvP == "none") mPvPRules = PVP_NONE; + else mPvPRules = PVP_NONE; + } void MapComposite::update() diff --git a/src/game-server/mapcomposite.hpp b/src/game-server/mapcomposite.hpp index 078842d6..7242fad6 100644 --- a/src/game-server/mapcomposite.hpp +++ b/src/game-server/mapcomposite.hpp @@ -38,6 +38,12 @@ class Thing; struct MapContent; struct MapZone; +enum PvPRules +{ + PVP_NONE, // no PvP on this map + PVP_FREE // unrestricted PvP on this map + // [space for additional PvP modes] +}; /** * Ordered sets of zones of a map. */ @@ -290,6 +296,11 @@ class MapComposite void update(); /** + * Gets the PvP rules on the map + */ + PvPRules getPvP() const { return mPvPRules; } + + /** * Gets an iterator on the objects of the whole map. */ ZoneIterator getWholeMapIterator() const @@ -329,6 +340,8 @@ class MapComposite Script *mScript; /**< Script associated to this map. */ std::string mName; /**< Name of the map. */ unsigned short mID; /**< ID of the map. */ + + PvPRules mPvPRules; }; #endif diff --git a/src/game-server/mapreader.cpp b/src/game-server/mapreader.cpp index 9caddc24..758b37ee 100644 --- a/src/game-server/mapreader.cpp +++ b/src/game-server/mapreader.cpp @@ -114,7 +114,7 @@ void MapReader::readMap(const std::string &filename, MapComposite *composite) } } -Map* MapReader::readMap(xmlNodePtr node, std::string const &path, +Map* MapReader::readMap(xmlNodePtr node, std::string const &path, MapComposite *composite, std::vector<Thing *> &things) { // Take the filename off the path @@ -140,6 +140,19 @@ Map* MapReader::readMap(xmlNodePtr node, std::string const &path, ::tilesetFirstGids.push_back(XML::getProperty(node, "firstgid", 0)); } } + else if (xmlStrEqual(node->name, BAD_CAST "properties")) + { + for_each_xml_child_node(propNode, node) + { + if (xmlStrEqual(propNode->name, BAD_CAST "property")) + { + std::string key = XML::getProperty(propNode, "name", ""); + std::string val = XML::getProperty(propNode, "value", ""); + LOG_DEBUG(" "<<key<<": "<<val); + map->setProperty(key, val); + } + } + } else if (xmlStrEqual(node->name, BAD_CAST "layer")) { // Layer 3 is collision layer. @@ -166,7 +179,7 @@ Map* MapReader::readMap(xmlNodePtr node, std::string const &path, int objW = XML::getProperty(objectNode, "width", 0); int objH = XML::getProperty(objectNode, "height", 0); Rectangle rect = { objX, objY, objW, objH }; - + if (objType == "WARP") { @@ -236,7 +249,7 @@ Map* MapReader::readMap(xmlNodePtr node, std::string const &path, { if (xmlStrEqual(propertyNode->name, BAD_CAST "property")) { - std::string value = XML::getProperty(propertyNode, "name", std::string()); + std::string value = XML::getProperty(propertyNode, "name", std::string()); value = utils::toupper(value); if (value == "MONSTER_ID") { diff --git a/src/sql/sqlite/createTables.sql b/src/sql/sqlite/createTables.sql index 11478d9b..1831c45a 100644 --- a/src/sql/sqlite/createTables.sql +++ b/src/sql/sqlite/createTables.sql @@ -142,7 +142,7 @@ CREATE TABLE tmw_world_states INSERT INTO tmw_world_states VALUES('accountserver_startup',NULL,NULL, strftime('%s','now')); INSERT INTO tmw_world_states VALUES('accountserver_version',NULL,NULL, strftime('%s','now')); -INSERT INTO tmw_world_states VALUES('database_version', NULL,'2', strftime('%s','now')); +INSERT INTO tmw_world_states VALUES('database_version', NULL,'3', strftime('%s','now')); CREATE TABLE tmw_auctions ( @@ -218,7 +218,7 @@ CREATE TABLE tmw_transactions char_id INTEGER NOT NULL, action INTEGER NOT NULL, message TEXT, - time INTEGER NOT NULL, + time INTEGER NOT NULL ); CREATE TABLE tmw_online_list diff --git a/src/sql/sqlite/updates/update_2_to_3.sql b/src/sql/sqlite/updates/update_2_to_3.sql index f8fdfc91..55441eb5 100644 --- a/src/sql/sqlite/updates/update_2_to_3.sql +++ b/src/sql/sqlite/updates/update_2_to_3.sql @@ -6,7 +6,7 @@ CREATE TABLE tmw_transactions char_id INTEGER NOT NULL, action INTEGER NOT NULL, message TEXT, - time INTEGER NOT NULL, + time INTEGER NOT NULL ); -- update the database version, and set date of update diff --git a/src/utils/stringfilter.cpp b/src/utils/stringfilter.cpp index 93be8b3e..1e2eaa54 100644 --- a/src/utils/stringfilter.cpp +++ b/src/utils/stringfilter.cpp @@ -103,9 +103,11 @@ bool StringFilter::filterContent(const std::string& text) bool StringFilter::isEmailValid(const std::string& email) { - // Testing Email validity - if ((email.length() < Configuration::getValue("account_minEmailLength", 7)) || - (email.length() > Configuration::getValue("account_maxEmailLength", 128))) + unsigned int min = Configuration::getValue("account_minEmailLength", 7); + unsigned int max = Configuration::getValue("account_maxEmailLength", 128); + + // Testing email validity + if (email.length() < min || email.length() > max) { return false; } |