summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-04-02 22:25:24 +0200
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-04-02 22:28:24 +0200
commit4a8080dcf73dab2b6e62b8500fec3bb996bcbf17 (patch)
tree67ef51dbb1b360f9a3e7c38cf0dbeb2b5f001bfd
parentad3958701136ff8ae4a4fc749ef616cc8917d2af (diff)
downloadmanaserv-4a8080dcf73dab2b6e62b8500fec3bb996bcbf17.tar.gz
manaserv-4a8080dcf73dab2b6e62b8500fec3bb996bcbf17.tar.xz
manaserv-4a8080dcf73dab2b6e62b8500fec3bb996bcbf17.zip
Fixed multiple warnings and errors that blocked c++0x
This allows the server to compile with c++0x (and enables it). This also includes some coding style / readabillity fixes.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/chat-server/chathandler.cpp2
-rw-r--r--src/common/permissionmanager.cpp2
-rw-r--r--src/game-server/buysell.cpp26
-rw-r--r--src/game-server/buysell.h8
-rw-r--r--src/game-server/character.cpp3
-rw-r--r--src/game-server/commandhandler.cpp8
-rw-r--r--src/game-server/inventory.cpp3
-rw-r--r--src/game-server/itemmanager.cpp3
-rw-r--r--src/game-server/mapcomposite.cpp3
-rw-r--r--src/game-server/skillmanager.cpp3
-rw-r--r--src/game-server/state.cpp38
-rw-r--r--src/game-server/state.h4
-rw-r--r--src/game-server/trade.cpp7
-rw-r--r--src/game-server/trade.h5
-rw-r--r--src/game-server/triggerareacomponent.cpp2
-rw-r--r--src/game-server/triggerareacomponent.h6
-rw-r--r--src/scripting/lua.cpp2
18 files changed, 74 insertions, 53 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8c88d71..85d6b6d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -41,6 +41,8 @@ SET(FLAGS "${FLAGS} -DPACKAGE_VERSION=\\\"${VERSION}\\\"")
SET(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${PKG_DATADIR}/\\\"")
SET(FLAGS "${FLAGS} -DLOCALEDIR=\\\"${LOCALEDIR}/\\\"")
+SET(FLAGS "${FLAGS} -std=c++0x")
+
# If the Sqlite option is enabled...
IF (WITH_SQLITE)
FIND_PACKAGE(Sqlite3 REQUIRED)
diff --git a/src/chat-server/chathandler.cpp b/src/chat-server/chathandler.cpp
index 63aaa43..93b1af4 100644
--- a/src/chat-server/chathandler.cpp
+++ b/src/chat-server/chathandler.cpp
@@ -443,7 +443,7 @@ void ChatHandler::handleModeChangeMessage(ChatClient &client, MessageIn &msg)
trans.mCharacterId = client.characterId;
trans.mAction = TRANS_CHANNEL_MODE;
trans.mMessage = "User mode ";
- trans.mMessage.append(mode + " set on " + user);
+ trans.mMessage.append(utils::toString(mode) + " set on " + user);
storage->addTransaction(trans);
}
diff --git a/src/common/permissionmanager.cpp b/src/common/permissionmanager.cpp
index 573e1d2..5510fd7 100644
--- a/src/common/permissionmanager.cpp
+++ b/src/common/permissionmanager.cpp
@@ -37,7 +37,7 @@ void addPermission(std::string permission, char mask)
std::map<std::string, unsigned char>::iterator i = permissions.find(permission);
if (i == permissions.end())
{
- permissions.insert(std::make_pair<std::string, unsigned char>(permission, mask));
+ permissions.insert(std::make_pair(permission, mask));
} else {
i->second |= mask;
}
diff --git a/src/game-server/buysell.cpp b/src/game-server/buysell.cpp
index ed6d92e..1e63d52 100644
--- a/src/game-server/buysell.cpp
+++ b/src/game-server/buysell.cpp
@@ -46,7 +46,7 @@ void BuySell::cancel()
delete this;
}
-bool BuySell::registerItem(int id, int amount, int cost)
+bool BuySell::registerItem(unsigned id, int amount, int cost)
{
if (mSell)
{
@@ -57,8 +57,11 @@ bool BuySell::registerItem(int id, int amount, int cost)
amount = nb;
}
- TradedItem it = { id, amount, cost };
- mItems.push_back(it);
+ TradedItem item;
+ item.itemId = id;
+ item.amount = amount;
+ item.cost = cost;
+ mItems.push_back(item);
return true;
}
@@ -76,11 +79,11 @@ int BuySell::registerPlayerItems()
for (InventoryData::const_iterator it = inventoryData.begin(),
it_end = inventoryData.end(); it != it_end; ++it)
{
- unsigned nb = it->second.amount;
- if (!nb)
+ unsigned amount = it->second.amount;
+ if (!amount)
continue;
- int id = it->second.itemId;
+ unsigned id = it->second.itemId;
int cost = -1;
if (itemManager->getItem(id))
{
@@ -106,15 +109,18 @@ int BuySell::registerPlayerItems()
if (i->itemId == id)
{
itemAlreadyAdded = true;
- i->amount += nb;
+ i->amount += amount;
break;
}
}
if (!itemAlreadyAdded)
{
- TradedItem itTrade = { id, nb, cost };
- mItems.push_back(itTrade);
+ TradedItem tradeItem;
+ tradeItem.itemId = id;
+ tradeItem.amount = amount;
+ tradeItem.cost = cost;
+ mItems.push_back(tradeItem);
nbItemsToSell++;
}
}
@@ -142,7 +148,7 @@ bool BuySell::start(Actor *actor)
return true;
}
-void BuySell::perform(int id, int amount)
+void BuySell::perform(unsigned id, int amount)
{
Inventory inv(mChar);
for (TradedItems::iterator i = mItems.begin(),
diff --git a/src/game-server/buysell.h b/src/game-server/buysell.h
index 3856600..72da2ce 100644
--- a/src/game-server/buysell.h
+++ b/src/game-server/buysell.h
@@ -45,7 +45,7 @@ class BuySell
* and how much it will cost.
* @return true if at least one item was registered.
*/
- bool registerItem(int id, int amount, int cost);
+ bool registerItem(unsigned id, int amount, int cost);
/**
* Registers every player's item at an average cost given by the ItemDB.
@@ -62,7 +62,7 @@ class BuySell
/**
* Performs the trade.
*/
- void perform(int id, int amount);
+ void perform(unsigned id, int amount);
private:
@@ -70,7 +70,9 @@ class BuySell
struct TradedItem
{
- unsigned short itemId, amount, cost;
+ unsigned itemId;
+ int amount;
+ int cost;
};
typedef std::vector< TradedItem > TradedItems;
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index 994e331..e52747f 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -223,7 +223,8 @@ void Character::respawn()
int spawnX = Configuration::getValue("char_respawnX", 1024);
int spawnY = Configuration::getValue("char_respawnY", 1024);
- GameState::enqueueWarp(this, MapManager::getMap(spawnMap), spawnX, spawnY);
+ GameState::enqueueWarp(this, MapManager::getMap(spawnMap),
+ Point(spawnX, spawnY));
}
bool Character::specialUseCheck(SpecialMap::iterator it)
diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp
index 353c3ef..68899e3 100644
--- a/src/game-server/commandhandler.cpp
+++ b/src/game-server/commandhandler.cpp
@@ -377,7 +377,7 @@ static void handleWarp(Character *player, std::string &args)
y = utils::stringToInt(ystr);
// now warp the player
- GameState::warp(player, map, x, y);
+ GameState::warp(player, map, Point(x, y));
// log transaction
std::stringstream ss;
@@ -479,7 +479,7 @@ static void handleCharWarp(Character *player, std::string &args)
y = utils::stringToInt(ystr);
// now warp the player
- GameState::warp(other, map, x, y);
+ GameState::warp(other, map, Point(x, y));
// log transaction
std::stringstream ss;
@@ -774,7 +774,7 @@ static void handleGoto(Character *player, std::string &args)
// move the player to where the other player is
MapComposite *map = other->getMap();
const Point &pos = other->getPosition();
- GameState::warp(player, map, pos.x, pos.y);
+ GameState::warp(player, map, pos);
// log transaction
std::stringstream msg;
@@ -808,7 +808,7 @@ static void handleRecall(Character *player, std::string &args)
// move the other player to where the player is
MapComposite *map = player->getMap();
const Point &pos = player->getPosition();
- GameState::warp(other, map, pos.x, pos.y);
+ GameState::warp(other, map, pos);
}
static void handleReload(Character *, std::string &)
diff --git a/src/game-server/inventory.cpp b/src/game-server/inventory.cpp
index 1fe0900..e14a36a 100644
--- a/src/game-server/inventory.cpp
+++ b/src/game-server/inventory.cpp
@@ -715,8 +715,7 @@ bool Inventory::equip(int inventorySlot)
{
EquipmentItem equipItem(it->second.itemId, itemInstance);
mPoss->equipSlots.insert(
- std::make_pair<unsigned, EquipmentItem>
- (equipReq.equipSlotId, equipItem));
+ std::make_pair(equipReq.equipSlotId, equipItem));
--capacityLeft;
}
}
diff --git a/src/game-server/itemmanager.cpp b/src/game-server/itemmanager.cpp
index 4837ce9..504ba12 100644
--- a/src/game-server/itemmanager.cpp
+++ b/src/game-server/itemmanager.cpp
@@ -159,8 +159,7 @@ void ItemManager::readEquipSlotsFile()
<< ", capacity: " << capacity << ", visible? " << visible);
EquipSlotInfo *equipSlotInfo =
new EquipSlotInfo(slotId, name, capacity, visible);
- mEquipSlotsInfo.insert(
- std::make_pair<unsigned, EquipSlotInfo*>(slotId, equipSlotInfo));
+ mEquipSlotsInfo.insert(std::make_pair(slotId, equipSlotInfo));
mNamedEquipSlotsInfo.insert(name, equipSlotInfo);
totalCapacity += capacity;
diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp
index f1b545e..bb7093b 100644
--- a/src/game-server/mapcomposite.cpp
+++ b/src/game-server/mapcomposite.cpp
@@ -802,7 +802,8 @@ void MapComposite::initializeContent()
if (destMap && destX && destY)
{
Entity *entity = new Entity(OBJECT_OTHER, this);
- WarpAction *action = new WarpAction(destMap, destX, destY);
+ const Point warpTarget(destX, destY);
+ WarpAction *action = new WarpAction(destMap, warpTarget);
entity->addComponent(
new TriggerAreaComponent(object->getBounds(),
action, false));
diff --git a/src/game-server/skillmanager.cpp b/src/game-server/skillmanager.cpp
index 2e78194..69a875e 100644
--- a/src/game-server/skillmanager.cpp
+++ b/src/game-server/skillmanager.cpp
@@ -130,8 +130,7 @@ void SkillManager::readSkillNode(xmlNodePtr skillNode,
mDefaultSkillId = skillInfo->id;
}
- mSkillsInfo.insert(
- std::make_pair<unsigned, SkillInfo*>(skillInfo->id, skillInfo));
+ mSkillsInfo.insert(std::make_pair(skillInfo->id, skillInfo));
std::string keyName = setName + "_" + skillInfo->skillName;
mNamedSkillsInfo.insert(keyName, skillInfo);
diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp
index eaffe77..d3a2986 100644
--- a/src/game-server/state.cpp
+++ b/src/game-server/state.cpp
@@ -54,7 +54,8 @@ enum
*/
struct DelayedEvent
{
- unsigned short type, x, y;
+ unsigned short type;
+ Point point;
MapComposite *map;
};
@@ -104,9 +105,7 @@ static void serializeLooks(Character *ch, MessageOut &msg)
// When the insertion succeeds, its the first time
// we encounter the item, so we can send the look change.
// We also send empty slots for unequipment handling.
- lookChanges.insert(
- std::make_pair<unsigned, unsigned>(it->first,
- it->second.itemId));
+ lookChanges.insert(std::make_pair(it->first, it->second.itemId));
}
}
@@ -500,7 +499,7 @@ void GameState::update(int tick)
case EVENT_WARP:
assert(o->getType() == OBJECT_CHARACTER);
- warp(static_cast< Character * >(o), e.map, e.x, e.y);
+ warp(static_cast< Character * >(o), e.map, e.point);
break;
}
}
@@ -700,11 +699,11 @@ void GameState::remove(Entity *ptr)
map->remove(ptr);
}
-void GameState::warp(Character *ptr, MapComposite *map, int x, int y)
+void GameState::warp(Character *ptr, MapComposite *map, const Point &point)
{
remove(ptr);
ptr->setMap(map);
- ptr->setPosition(Point(x, y));
+ ptr->setPosition(point);
ptr->clearDestination();
/* Force update of persistent data on map change, so that
characters can respawn at the start of the map after a death or
@@ -750,28 +749,37 @@ static void enqueueEvent(Actor *ptr, const DelayedEvent &e)
void GameState::enqueueInsert(Actor *ptr)
{
- DelayedEvent e = { EVENT_INSERT, 0, 0, 0 };
- enqueueEvent(ptr, e);
+ DelayedEvent event;
+ event.type = EVENT_INSERT;
+ event.map = 0;
+ enqueueEvent(ptr, event);
}
void GameState::enqueueRemove(Actor *ptr)
{
- DelayedEvent e = { EVENT_REMOVE, 0, 0, 0 };
- enqueueEvent(ptr, e);
+ DelayedEvent event;
+ event.type = EVENT_REMOVE;
+ event.map = 0;
+ enqueueEvent(ptr, event);
}
-void GameState::enqueueWarp(Character *ptr, MapComposite *m, int x, int y)
+void GameState::enqueueWarp(Character *ptr,
+ MapComposite *map,
+ const Point &point)
{
// When the player has just disconnected, better not wait for the pointer
// to become invalid.
if (!ptr->isConnected())
{
- warp(ptr, m, x, y);
+ warp(ptr, map, point);
return;
}
- DelayedEvent e = { EVENT_WARP, x, y, m };
- enqueueEvent(ptr, e);
+ DelayedEvent event;
+ event.type = EVENT_WARP;
+ event.point = point;
+ event.map = map;
+ enqueueEvent(ptr, event);
}
void GameState::sayAround(Actor *obj, const std::string &text)
diff --git a/src/game-server/state.h b/src/game-server/state.h
index c518972..e8ed30a 100644
--- a/src/game-server/state.h
+++ b/src/game-server/state.h
@@ -71,7 +71,7 @@ namespace GameState
* @note No update may be in progress.
* @note The character is destroyed, if needed.
*/
- void warp(Character *, MapComposite *, int x, int y);
+ void warp(Character *, MapComposite *, const Point &point);
/**
* Enqueues an insert event.
@@ -90,7 +90,7 @@ namespace GameState
* Enqueues a warp event.
* @note The event will be executed at end of update.
*/
- void enqueueWarp(Character *, MapComposite *, int x, int y);
+ void enqueueWarp(Character *, MapComposite *, const Point &point);
/**
* Says something to an actor.
diff --git a/src/game-server/trade.cpp b/src/game-server/trade.cpp
index 0b906b1..042719b 100644
--- a/src/game-server/trade.cpp
+++ b/src/game-server/trade.cpp
@@ -249,8 +249,11 @@ void Trade::addItem(Character *c, int slot, int amount)
later on. At worst, the transaction will be canceled at the end if
the client lied. */
- TradedItem ti = { id, slot, amount };
- items->push_back(ti);
+ TradedItem tradedItem;
+ tradedItem.id = id;
+ tradedItem.slot = slot;
+ tradedItem.amount = amount;
+ items->push_back(tradedItem);
MessageOut msg(GPMSG_TRADE_ADD_ITEM);
msg.writeInt16(id);
diff --git a/src/game-server/trade.h b/src/game-server/trade.h
index 43b674f..3e5fb3a 100644
--- a/src/game-server/trade.h
+++ b/src/game-server/trade.h
@@ -77,8 +77,9 @@ class Trade
struct TradedItem
{
- unsigned short id;
- unsigned char slot, amount;
+ unsigned id;
+ unsigned slot;
+ int amount;
};
typedef std::vector< TradedItem > TradedItems;
diff --git a/src/game-server/triggerareacomponent.cpp b/src/game-server/triggerareacomponent.cpp
index ebfe858..7c32f09 100644
--- a/src/game-server/triggerareacomponent.cpp
+++ b/src/game-server/triggerareacomponent.cpp
@@ -34,7 +34,7 @@ void WarpAction::process(Actor *obj)
{
if (obj->getType() == OBJECT_CHARACTER)
{
- GameState::enqueueWarp(static_cast< Character * >(obj), mMap, mX, mY);
+ GameState::enqueueWarp(static_cast< Character * >(obj), mMap, mTargetPoint);
}
}
diff --git a/src/game-server/triggerareacomponent.h b/src/game-server/triggerareacomponent.h
index f766c81..6c2df7d 100644
--- a/src/game-server/triggerareacomponent.h
+++ b/src/game-server/triggerareacomponent.h
@@ -40,14 +40,14 @@ class TriggerAction
class WarpAction : public TriggerAction
{
public:
- WarpAction(MapComposite *m, int x, int y)
- : mMap(m), mX(x), mY(y) {}
+ WarpAction(MapComposite *m, const Point &point)
+ : mMap(m), mTargetPoint(point) {}
virtual void process(Actor *obj);
private:
MapComposite *mMap;
- unsigned short mX, mY;
+ Point mTargetPoint;
};
class ScriptAction : public TriggerAction
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index cbdb088..a02f84e 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -1650,7 +1650,7 @@ static int chr_warp(lua_State *s)
x *= map->getTileWidth();
y *= map->getTileHeight();
}
- GameState::enqueueWarp(q, m, x, y);
+ GameState::enqueueWarp(q, m, Point(x, y));
return 0;
}