From f689c19d25b634a1883f402eff6a07d73fa5da21 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 23 Oct 2008 20:31:43 +0000 Subject: Fixed compiler warnings, including a forgotten initialization of an item's script pointer. --- ChangeLog | 27 +++++++++++++++++---------- src/game-server/item.hpp | 30 +++++++++++++++--------------- src/game-server/itemmanager.cpp | 8 ++++---- src/utils/string.cpp | 12 ++++++------ src/utils/string.hpp | 3 ++- 5 files changed, 44 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index bba74ea0..bb6e85f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,14 +1,21 @@ +2008-10-23 Bjørn Lindeijer + + * src/utils/string.cpp, src/utils/string.hpp, + src/game-server/item.hpp, src/game-server/itemmanager.cpp: Fixed + compiler warnings, including a forgotten initialization of an item's + script pointer. + 2008-10-23 David Athay - * src/scripting/lua.cpp: Added functions for getting being name and + * src/scripting/lua.cpp: Added functions for getting being name and attributes in scripts. * data/scripts/test.lua: Added example of using above functions. 2008-10-22 Chuck Miller - * src/game-server/mapreader.cpp, src/utils/sting.cpp - src/utils/string.hpp: Makes the values in tmx files - ignore case for convience + * src/game-server/mapreader.cpp, src/utils/sting.cpp, + src/utils/string.hpp: Makes the values in tmx files ignore case for + convience. 2008-10-22 Chuck Miller @@ -25,16 +32,16 @@ 2008-10-21 Roderic Morris - * data/scripts/libs/libtmw.lua: patch by Kage_Jittai to have - npc ids returned when creating new npcs. + * data/scripts/libs/libtmw.lua: Patch by Kage_Jittai to have NPC ids + returned when creating new NPCs. 2008-10-21 Roderic Morris * src/scripting/lua.cpp, data/test.lua, data/scripts/test.lua, - data/scripts/npclib.lua, data/scripts/libs, data/scripts/libs/npclib.lua, - data/scripts/libs/libtmw.lua, data/scripts/libtmw.lua: - Changed the ordering of lua scripts in preperation for content - conversion. + data/scripts/npclib.lua, data/scripts/libs, + data/scripts/libs/npclib.lua, data/scripts/libs/libtmw.lua, + data/scripts/libtmw.lua: Changed the ordering of lua scripts in + preperation for content conversion. 2008-10-21 Bjørn Lindeijer diff --git a/src/game-server/item.hpp b/src/game-server/item.hpp index 3878755e..603dc2fa 100644 --- a/src/game-server/item.hpp +++ b/src/game-server/item.hpp @@ -27,11 +27,10 @@ #include #include "game-server/object.hpp" -#include "scripting/script.hpp" - class AttackZone; class Being; +class Script; /** * Enumeration of available Item types. @@ -178,7 +177,7 @@ class ItemClass { public: ItemClass(int id, ItemType type, Script *s = NULL) - : mDatabaseID(id), mType(type), mAttackZone(NULL), mScript(NULL) + : mScript(NULL), mDatabaseID(id), mType(type), mAttackZone(NULL) {} ~ItemClass(); @@ -280,21 +279,22 @@ class ItemClass private: - //Script for using items - Script *mScript; - - // Item reference information - unsigned short mDatabaseID; - unsigned short mSpriteID; /**< The sprite that should be shown to the character */ - ItemType mType; /**< Type: usable, equipment etc. */ - unsigned short mWeight; /**< Weight of the item. */ - unsigned short mCost; /**< Unit cost the item. */ - unsigned short mMaxPerSlot; /**< Max item amount per slot in inventory. */ + Script *mScript; /**< Script for using items */ + + unsigned short mDatabaseID; /**< Item reference information */ + /** The sprite that should be shown to the character */ + unsigned short mSpriteID; + ItemType mType; /**< Type: usable, equipment etc. */ + unsigned short mWeight; /**< Weight of the item. */ + unsigned short mCost; /**< Unit cost the item. */ + /** Max item amount per slot in inventory. */ + unsigned short mMaxPerSlot; + ItemModifiers mModifiers; /**< Item modifiers. */ - AttackZone *mAttackZone; /**< attack zone when used as a weapon */ + AttackZone *mAttackZone; /**< Attack zone when used as a weapon */ }; -class Item: public Object +class Item : public Object { public: Item(ItemClass *type, int amount) diff --git a/src/game-server/itemmanager.cpp b/src/game-server/itemmanager.cpp index 65419011..019f4c92 100644 --- a/src/game-server/itemmanager.cpp +++ b/src/game-server/itemmanager.cpp @@ -30,6 +30,7 @@ #include "game-server/attackzone.hpp" #include "game-server/item.hpp" #include "game-server/resourcemanager.hpp" +#include "scripting/script.hpp" #include "utils/logger.h" #include "utils/xml.hpp" @@ -181,19 +182,18 @@ void ItemManager::reload() weight = 1; } - Script *s; - //TODO: Clean this up some + // TODO: Clean this up some + Script *s = 0; std::stringstream filename; filename << "scripts/items/" << id << ".lua"; - if(ResourceManager::exists(filename.str())) //file exists! + if (ResourceManager::exists(filename.str())) // file exists! { LOG_INFO("Loading item script: " + filename.str()); s = Script::create("lua"); s->loadFile(filename.str()); } - item->setWeight(weight); item->setCost(value); item->setMaxPerSlot(maxPerSlot); diff --git a/src/utils/string.cpp b/src/utils/string.cpp index 04d5f031..0785429d 100644 --- a/src/utils/string.cpp +++ b/src/utils/string.cpp @@ -18,14 +18,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -#include -#include + #include "utils/string.hpp" +#include +#include + std::string utils::toupper(std::string s) { - for (int j=0; j