From: <ave...@us...> - 2007-09-02 16:11:34
|
Revision: 4796 http://gemrb.svn.sourceforge.net/gemrb/?rev=4796&view=rev Author: avenger_teambg Date: 2007-09-02 09:11:28 -0700 (Sun, 02 Sep 2007) Log Message: ----------- improved text messages when item equipping has failed added lots of consts fixed LeaveAreaLua*Entry actions Modified Paths: -------------- gemrb/trunk/gemrb/includes/strrefs.h gemrb/trunk/gemrb/override/bg1/strings.2da gemrb/trunk/gemrb/override/bg2/strings.2da gemrb/trunk/gemrb/override/how/strings.2da gemrb/trunk/gemrb/override/iwd/strings.2da gemrb/trunk/gemrb/override/iwd2/strings.2da gemrb/trunk/gemrb/override/pst/strings.2da gemrb/trunk/gemrb/override/tob/strings.2da gemrb/trunk/gemrb/plugins/Core/Actions.cpp gemrb/trunk/gemrb/plugins/Core/Actor.cpp gemrb/trunk/gemrb/plugins/Core/Actor.h gemrb/trunk/gemrb/plugins/Core/GSUtils.cpp gemrb/trunk/gemrb/plugins/Core/GSUtils.h gemrb/trunk/gemrb/plugins/Core/Interface.cpp gemrb/trunk/gemrb/plugins/Core/Interface.h gemrb/trunk/gemrb/plugins/Core/Inventory.cpp gemrb/trunk/gemrb/plugins/Core/Inventory.h gemrb/trunk/gemrb/plugins/Core/PluginMgr.cpp gemrb/trunk/gemrb/plugins/Core/PluginMgr.h gemrb/trunk/gemrb/plugins/Core/Triggers.cpp gemrb/trunk/gemrb/plugins/Core/Window.cpp gemrb/trunk/gemrb/plugins/Core/Window.h gemrb/trunk/gemrb/plugins/GUIScript/GUIScript.cpp Modified: gemrb/trunk/gemrb/includes/strrefs.h =================================================================== --- gemrb/trunk/gemrb/includes/strrefs.h 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/includes/strrefs.h 2007-09-02 16:11:28 UTC (rev 4796) @@ -120,7 +120,14 @@ #define STR_LOCKPICK_FAILED 86 #define STR_STATIC_DISS 87 #define STR_LIGHTNING_DISS 88 +// +// +#define STR_WRONGITEMTYPE 90 +#define STR_OFFHANDINUSE 91 +#define STR_2HANDEDEQUIP 92 +#define STR_CANNOTUSEITEM 93 +#define STR_2HANDEDOFFHAND 94 -#define STRREF_COUNT 89 +#define STRREF_COUNT 95 #endif //! IE_STRINGS_H Modified: gemrb/trunk/gemrb/override/bg1/strings.2da =================================================================== --- gemrb/trunk/gemrb/override/bg1/strings.2da 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/override/bg1/strings.2da 2007-09-02 16:11:28 UTC (rev 4796) @@ -89,3 +89,10 @@ LOCKPICK_DONE 16517 STATIC_DISSIPATE -1 LIGHTNING_DISSIPATE -1 +X -1 +Y -1 +WRONG_ITEMTYPE 9375 +OFFHAND_IN_USE 9380 +2HANDED_EQUIPPED 9381 +CANNOT_USE_ITEM 9382 +2HANDED_OFFHAND 9375 Modified: gemrb/trunk/gemrb/override/bg2/strings.2da =================================================================== --- gemrb/trunk/gemrb/override/bg2/strings.2da 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/override/bg2/strings.2da 2007-09-02 16:11:28 UTC (rev 4796) @@ -89,3 +89,10 @@ LOCKPICK_DONE 16517 STATIC_DISSIPATE -1 LIGHTNING_DISSIPATE -1 +X -1 +Y -1 +WRONG_ITEMTYPE 9375 +OFFHAND_IN_USE 9380 +2HANDED_EQUIPPED 9381 +CANNOT_USE_ITEM 9382 +2HANDED_OFFHAND 26342 Modified: gemrb/trunk/gemrb/override/how/strings.2da =================================================================== --- gemrb/trunk/gemrb/override/how/strings.2da 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/override/how/strings.2da 2007-09-02 16:11:28 UTC (rev 4796) @@ -89,3 +89,10 @@ LOCKPICK_DONE 16517 STATIC_DISSIPATE 26518 LIGHTNING_DISSIPATE -1 +X -1 +Y -1 +WRONG_ITEMTYPE 9375 +OFFHAND_IN_USE 9380 +2HANDED_EQUIPPED 9381 +CANNOT_USE_ITEM 9382 +2HANDED_OFFHAND 26342 Modified: gemrb/trunk/gemrb/override/iwd/strings.2da =================================================================== --- gemrb/trunk/gemrb/override/iwd/strings.2da 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/override/iwd/strings.2da 2007-09-02 16:11:28 UTC (rev 4796) @@ -89,3 +89,10 @@ LOCKPICK_DONE 16517 STATIC_DISSIPATE -1 LIGHTNING_DISSIPATE -1 +X -1 +Y -1 +WRONG_ITEMTYPE 9375 +OFFHAND_IN_USE 9380 +2HANDED_EQUIPPED 9381 +CANNOT_USE_ITEM 9382 +2HANDED_OFFHAND 26342 Modified: gemrb/trunk/gemrb/override/iwd2/strings.2da =================================================================== --- gemrb/trunk/gemrb/override/iwd2/strings.2da 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/override/iwd2/strings.2da 2007-09-02 16:11:28 UTC (rev 4796) @@ -90,3 +90,10 @@ LOCKPICK_FAILED 16518 STATIC_DISSIPATE 26518 LIGHTNING_DISSIPATE 41008 +X -1 +Y -1 +WRONG_ITEMTYPE 9375 +OFFHAND_IN_USE 9380 +2HANDED_EQUIPPED 9381 +CANNOT_USE_ITEM 9382 +2HANDED_OFFHAND 26342 Modified: gemrb/trunk/gemrb/override/pst/strings.2da =================================================================== --- gemrb/trunk/gemrb/override/pst/strings.2da 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/override/pst/strings.2da 2007-09-02 16:11:28 UTC (rev 4796) @@ -90,3 +90,10 @@ LOCKPICK_FAILED 19282 STATIC_DISSIPATE -1 LIGHTNING_DISSIPATE -1 +X -1 +Y -1 +WRONG_ITEMTYPE 9375 +OFFHAND_IN_USE 9380 +2HANDED_EQUIPPED 9381 +CANNOT_USE_ITEM 9382 +2HANDED_OFFHAND 9375 Modified: gemrb/trunk/gemrb/override/tob/strings.2da =================================================================== --- gemrb/trunk/gemrb/override/tob/strings.2da 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/override/tob/strings.2da 2007-09-02 16:11:28 UTC (rev 4796) @@ -89,3 +89,10 @@ LOCKPICK_DONE 16517 STATIC_DISSIPATE -1 LIGHTNING_DISSIPATE -1 +X -1 +Y -1 +WRONG_ITEMTYPE 9375 +OFFHAND_IN_USE 9380 +2HANDED_EQUIPPED 9381 +CANNOT_USE_ITEM 9382 +2HANDED_OFFHAND 26342 Modified: gemrb/trunk/gemrb/plugins/Core/Actions.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Actions.cpp 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/Actions.cpp 2007-09-02 16:11:28 UTC (rev 4796) @@ -280,7 +280,7 @@ value+= parameters->int2Parameter; break; case 3: - default: //no idea what happens + default: //no idea what happens value = parameters->int2Parameter; break; } @@ -2611,15 +2611,13 @@ Actor *actor = (Actor *) Sender; Game *game = core->GetGame(); strncpy(game->LoadMos, parameters->string1Parameter,8); - //no need to change the pathfinder just for getting the entrance - Map *map = game->GetMap(actor->Area, false); - Entrance *ent = map->GetEntrance(parameters->string1Parameter); - if (PersonalDistance(ent->Pos, Sender) <= MAX_OPERATING_DISTANCE) { - LeaveAreaLUA(Sender, parameters); + Point p = GetEntryPoint(actor->Area, parameters->string1Parameter); + if (p.isempty()) { Sender->ReleaseCurrentAction(); return; } - GoNearAndRetry( Sender, ent->Pos, MAX_OPERATING_DISTANCE); + parameters->pointParameter=p; + LeaveAreaLUA(Sender, parameters); Sender->ReleaseCurrentAction(); } @@ -2643,15 +2641,13 @@ Actor *actor = (Actor *) Sender; Game *game = core->GetGame(); strncpy(game->LoadMos, parameters->string1Parameter,8); - //no need to change the pathfinder just for getting the entrance - Map *map = game->GetMap( actor->Area, false); - Entrance *ent = map->GetEntrance(parameters->string1Parameter); - if (PersonalDistance(ent->Pos, Sender) <= MAX_OPERATING_DISTANCE) { - LeaveAreaLUAPanic(Sender, parameters); + Point p = GetEntryPoint(actor->Area, parameters->string1Parameter); + if (p.isempty()) { Sender->ReleaseCurrentAction(); return; } - GoNearAndRetry( Sender, ent->Pos, MAX_OPERATING_DISTANCE); + parameters->pointParameter=p; + LeaveAreaLUAPanic(Sender, parameters); Sender->ReleaseCurrentAction(); } @@ -3733,7 +3729,7 @@ Actor *snd = (Actor *) Sender; Actor *scr = (Actor *) tar; //for PP one must go REALLY close - + if (PersonalDistance(Sender, tar)>10 ) { GoNearAndRetry(Sender, tar, true, 10+snd->size+scr->size); Sender->ReleaseCurrentAction(); @@ -3767,7 +3763,7 @@ scr->SetBase(IE_GOLD,scr->GetBase(IE_GOLD)-money); snd->SetBase(IE_GOLD,snd->GetBase(IE_GOLD)+money); } - + Sender->ReleaseCurrentAction(); } @@ -5675,7 +5671,7 @@ //invalid effect name didn't resolve to opcode return; } - + //vvc type fx->Parameter2 = parameters->int0Parameter; //height (not sure if this is in the opcode, but seems acceptable) Modified: gemrb/trunk/gemrb/plugins/Core/Actor.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Actor.cpp 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/Actor.cpp 2007-09-02 16:11:28 UTC (rev 4796) @@ -1747,7 +1747,7 @@ fxqueue.dump(); } -const char* Actor::GetActorNameByID(ieDword ID) +const char* Actor::GetActorNameByID(ieDword ID) const { Actor *actor = GetCurrentArea()->GetActorByGlobalID(ID); if (!actor) { @@ -2029,7 +2029,7 @@ idx=(ieWord) which; headerindex=(ieWord) header; } - CREItem *slot = inventory.GetSlotItem(idx); + const CREItem *slot = inventory.GetSlotItem(idx); if (!slot) return; //quick item slot is empty Item *itm = core->GetItem(slot->ItemResRef); if (!itm) return; //quick item slot contains invalid item resref @@ -2140,7 +2140,7 @@ // If current quickweaponslot contains ammo, and bow not found, reset if (core->QuerySlotEffects(slot) == SLOT_EFFECT_MISSILE) { - CREItem *slotitm = inventory.GetSlotItem(slot); + const CREItem *slotitm = inventory.GetSlotItem(slot); assert(slotitm); Item *itm = core->GetItem(slotitm->ItemResRef); assert(itm); @@ -2169,7 +2169,7 @@ PCStats->InitQuickSlot(which, (ieWord) slot, (ieWord) headerindex); } -bool Actor::ValidTarget(int ga_flags) +bool Actor::ValidTarget(int ga_flags) const { if (Immobile()) return false; //scripts can still see this type of actor @@ -2202,7 +2202,7 @@ //returns true if it won't be destroyed with an area //in this case it shouldn't be saved with the area either //it will be saved in the savegame -bool Actor::Persistent() +bool Actor::Persistent() const { if (InParty) return true; if (InternalFlags&IF_FROMGAME) return true; @@ -2236,10 +2236,10 @@ } //slot is the projectile slot -int Actor::GetRangedWeapon(ITMExtHeader *&which) +int Actor::GetRangedWeapon(ITMExtHeader *&which) const { unsigned int slot = inventory.FindRangedWeapon(); - CREItem *wield = inventory.GetSlotItem(slot); + const CREItem *wield = inventory.GetSlotItem(slot); if (!wield) { return 0; } @@ -2254,9 +2254,9 @@ //returns weapon header currently used //if range is nonzero, then the returned header is valid -unsigned int Actor::GetWeapon(ITMExtHeader *&which, bool leftorright) +unsigned int Actor::GetWeapon(ITMExtHeader *&which, bool leftorright) const { - CREItem *wield = inventory.GetUsedWeapon(leftorright); + const CREItem *wield = inventory.GetUsedWeapon(leftorright); if (!wield) { return 0; } @@ -3685,13 +3685,8 @@ return 0; } -//checks usability only -int Actor::Unusable(Item *item) const +int Actor::CheckUsability(Item *item) const { - if (GetStat(IE_CANUSEANYITEM)) { - return 0; - } - ieDword itembits[2]={item->UsabilityBitmask, item->KitUsability}; for (int i=0;i<usecount;i++) { @@ -3714,10 +3709,20 @@ stat = ResolveTableValue(itemuse[i].table, stat, mcol, itemuse[i].vcol); } if (stat&itemvalue) { - return 1; + return STR_CANNOTUSEITEM; } } + return 0; +} + +//checks usability only +int Actor::Unusable(Item *item) const +{ + if (!GetStat(IE_CANUSEANYITEM)) { + return CheckUsability(item); + } + if (!CheckAbilities) { return 0; } Modified: gemrb/trunk/gemrb/plugins/Core/Actor.h =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Actor.h 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/Actor.h 2007-09-02 16:11:28 UTC (rev 4796) @@ -213,11 +213,13 @@ /** fixes the palette */ void SetupColors(); /** debugging function, gets the scripting name of an actor referenced by a global ID */ - const char* GetActorNameByID(ieDword ID); + const char* GetActorNameByID(ieDword ID) const; /* if Lasttarget is gone, call this */ void StopAttack(); /* checks a weapon quick slot and resets it to fist if it is empty */ void CheckWeaponQuickSlot(unsigned int which); + /* helper for usability checks */ + int CheckUsability(Item *item) const; public: Actor(void); ~Actor(void); @@ -246,7 +248,7 @@ /** returns a saving throw */ bool GetSavingThrow(ieDword type, int modifier); /** Returns true if the actor is targetable */ - bool ValidTarget(int ga_flags); + bool ValidTarget(int ga_flags) const; /** Returns a Stat value */ ieDword GetStat(unsigned int StatIndex) const; /** Sets a Stat Value (unsaved) */ @@ -358,11 +360,10 @@ void SetRunFlags(ieDword flags); /* applies the kit abilities, returns false if kit is not applicable */ bool ApplyKit(ieDword Value); -public: /* calls InitQuickSlot in PCStatStruct */ void SetupQuickSlot(unsigned int which, int slot, int headerindex); /* returns true if the actor is PC/joinable*/ - bool Persistent(); + bool Persistent() const; /* assigns actor to party slot, 0 = NPC, areas won't remove it */ void SetPersistent(int partyslot); /* resurrects actor */ @@ -380,10 +381,10 @@ /* learns the given spell, possibly receive XP */ int LearnSpell(const ieResRef resref, ieDword flags); /* returns the ranged weapon header associated with the currently equipped projectile */ - int GetRangedWeapon(ITMExtHeader *&which); + int GetRangedWeapon(ITMExtHeader *&which) const; /* Returns current weapon range and extended header if range is nonzero, then which is valid */ - unsigned int GetWeapon(ITMExtHeader *&which, bool leftorright=false); + unsigned int GetWeapon(ITMExtHeader *&which, bool leftorright=false) const; /* Creates player statistics */ void CreateStats(); /* Heals actor by days */ Modified: gemrb/trunk/gemrb/plugins/Core/GSUtils.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/GSUtils.cpp 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/GSUtils.cpp 2007-09-02 16:11:28 UTC (rev 4796) @@ -2272,3 +2272,21 @@ return XthNearestOf(parameters,count); } +Point GetEntryPoint(const char *areaname, const char *entryname) +{ + Point p; + + int table = core->LoadTable( "entries" ); + if (table<0) { + return p; + } + TableMgr *tab = core->GetTable( table ); + const char *tmpstr = tab->QueryField(areaname, entryname); + int x=-1; + int y=-1; + sscanf(tmpstr, "%d.%d", &x, &y); + core->DelTable(table); + p.x=(short) x; + p.y=(short) y; + return p; +} Modified: gemrb/trunk/gemrb/plugins/Core/GSUtils.h =================================================================== --- gemrb/trunk/gemrb/plugins/Core/GSUtils.h 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/GSUtils.h 2007-09-02 16:11:28 UTC (rev 4796) @@ -100,6 +100,7 @@ int GetObjectCount(Scriptable* Sender, Object* oC); int GetObjectLevelCount(Scriptable* Sender, Object* oC); void SetVariable(Scriptable* Sender, const char* VarName, ieDword value); +Point GetEntryPoint(const char *areaname, const char *entryname); //these are used from other plugins GEM_EXPORT int CanSee(Scriptable* Sender, Scriptable* target, bool range, int nodead); GEM_EXPORT int SeeCore(Scriptable* Sender, Trigger* parameters, int justlos); Modified: gemrb/trunk/gemrb/plugins/Core/Interface.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Interface.cpp 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/Interface.cpp 2007-09-02 16:11:28 UTC (rev 4796) @@ -839,7 +839,7 @@ return flag; } -int Interface::GetItemExcl(const ieResRef itemname) +int Interface::GetItemExcl(const ieResRef itemname) const { ieDword value; @@ -870,7 +870,7 @@ return ret; } -int Interface::GetItemDialStr(const ieResRef itemname) +int Interface::GetItemDialStr(const ieResRef itemname) const { ieDword value; @@ -881,7 +881,7 @@ } //second value is the item dialog resource returned by this method -int Interface::GetItemDialRes(const ieResRef itemname, ieResRef retval) +int Interface::GetItemDialRes(const ieResRef itemname, ieResRef retval) const { if (ItemDial2Table && ItemDial2Table->Lookup(itemname, retval, sizeof(ieResRef))) { return 1; @@ -922,7 +922,7 @@ } //this isn't const -int Interface::GetAreaAlias(const ieResRef areaname) +int Interface::GetAreaAlias(const ieResRef areaname) const { ieDword value; @@ -1630,7 +1630,7 @@ return GEM_OK; } -bool Interface::IsAvailable(SClass_ID filetype) +bool Interface::IsAvailable(SClass_ID filetype) const { return plugin->IsAvailable( filetype ); } @@ -1641,7 +1641,7 @@ return worldmap->GetWorldMap(index); } -void* Interface::GetInterface(SClass_ID filetype) +void* Interface::GetInterface(SClass_ID filetype) const { if (!plugin) { return NULL; @@ -1649,7 +1649,7 @@ return plugin->GetPlugin( filetype ); } -std::vector<InterfaceElement>* Interface::GetInterfaceVector(SClass_ID filetype) +std::vector<InterfaceElement>* Interface::GetInterfaceVector(SClass_ID filetype) const { if (!plugin) { return NULL; @@ -1672,7 +1672,7 @@ return key; } -const char* Interface::TypeExt(SClass_ID type) +const char* Interface::TypeExt(SClass_ID type) const { switch (type) { case IE_2DA_CLASS_ID: @@ -2403,7 +2403,7 @@ } /** No descriptions */ -Color* Interface::GetPalette(int index, int colors, Color *pal) +Color* Interface::GetPalette(int index, int colors, Color *pal) const { //Color* pal = NULL; if (colors == 32) { @@ -2752,7 +2752,7 @@ } /** Get a Control on a Window */ -int Interface::GetControl(unsigned short WindowIndex, unsigned long ControlID) +int Interface::GetControl(unsigned short WindowIndex, unsigned long ControlID) const { if (WindowIndex >= windows.size()) { return -1; @@ -2838,7 +2838,7 @@ tooltip_ctrl = ctrl; } -int Interface::GetVisible(unsigned short WindowIndex) +int Interface::GetVisible(unsigned short WindowIndex) const { if (WindowIndex >= windows.size()) { return -1; @@ -3099,7 +3099,7 @@ //interface for higher level functions, if the window was //marked for deletion it is not returned -Window* Interface::GetWindow(unsigned short WindowIndex) +Window* Interface::GetWindow(unsigned short WindowIndex) const { if (WindowIndex < windows.size()) { Window *win = windows[WindowIndex]; @@ -3112,7 +3112,7 @@ // this function will determine if wnd is a valid window pointer // by checking if its WindowID is the same as the reference -bool Interface::IsValidWindow(unsigned short WindowID, Window *wnd) +bool Interface::IsValidWindow(unsigned short WindowID, Window *wnd) const { size_t WindowIndex = windows.size(); while (WindowIndex--) { @@ -3192,12 +3192,12 @@ } /** Get the Sound Manager */ -SoundMgr* Interface::GetSoundMgr() +SoundMgr* Interface::GetSoundMgr() const { return soundmgr; } /** Get the Sound Manager */ -SaveGameIterator* Interface::GetSaveGameIterator() +SaveGameIterator* Interface::GetSaveGameIterator() const { return sgiterator; } @@ -3207,17 +3207,17 @@ return video->Quit(); } /** Returns the variables dictionary */ -Variables* Interface::GetDictionary() +Variables* Interface::GetDictionary() const { return vars; } /** Returns the token dictionary */ -Variables* Interface::GetTokenDictionary() +Variables* Interface::GetTokenDictionary() const { return tokens; } /** Get the Music Manager */ -MusicMgr* Interface::GetMusicMgr() +MusicMgr* Interface::GetMusicMgr() const { return music; } @@ -3261,7 +3261,7 @@ return ( int ) tables.size() - 1; } /** Gets the index of a loaded table, returns -1 on error */ -int Interface::GetTableIndex(const char* ResRef) +int Interface::GetTableIndex(const char* ResRef) const { for (size_t i = 0; i < tables.size(); i++) { if (tables[i].free) @@ -3272,7 +3272,7 @@ return -1; } /** Gets a Loaded Table by its index, returns NULL on error */ -TableMgr* Interface::GetTable(unsigned int index) +TableMgr* Interface::GetTable(unsigned int index) const { if (index >= tables.size()) { return NULL; @@ -3339,7 +3339,7 @@ return ( int ) symbols.size() - 1; } /** Gets the index of a loaded Symbol Table, returns -1 on error */ -int Interface::GetSymbolIndex(const char* ResRef) +int Interface::GetSymbolIndex(const char* ResRef) const { for (size_t i = 0; i < symbols.size(); i++) { if (symbols[i].free) @@ -3350,7 +3350,7 @@ return -1; } /** Gets a Loaded Symbol Table by its index, returns NULL on error */ -SymbolMgr* Interface::GetSymbol(unsigned int index) +SymbolMgr* Interface::GetSymbol(unsigned int index) const { if (index >= symbols.size()) { return NULL; @@ -3455,7 +3455,7 @@ return 0; } -int Interface::Roll(int dice, int size, int add) +int Interface::Roll(int dice, int size, int add) const { if (dice < 1) { return add; @@ -3653,7 +3653,7 @@ video->moveY = 0; } -bool Interface::InCutSceneMode() +bool Interface::InCutSceneMode() const { return (GetGameControl()->GetScreenFlags()&SF_DISABLEMOUSE)!=0; } @@ -3816,7 +3816,7 @@ if (sav_str) delete sav_str; } -GameControl *Interface::GetGameControl() +GameControl *Interface::GetGameControl() const { Window *window = GetWindow( 0 ); // in the beginning, there's no window at all @@ -3990,7 +3990,7 @@ // checks the itemtype vs. slottype, and also checks the usability flags // vs. Actor's stats (alignment, class, race, kit etc.) -int Interface::CanUseItemType(int slottype, Item *item, Actor *actor) const +int Interface::CanUseItemType(int slottype, Item *item, Actor *actor, bool feedback) const { //inventory is a special case, we allow any items to enter it if ( slottype==SLOT_ALL ) { @@ -4000,28 +4000,36 @@ //with twohandedness if ((slottype&SLOT_SHIELD) && (slottype!=SLOT_ANY) ) { if (item->Flags&IE_INV_ITEM_TWOHANDED) { + //cannot equip twohanded in offhand + if (feedback) core->DisplayConstantString(STR_2HANDEDOFFHAND, 0xf0f0f0); return 0; } } if ( (unsigned int) item->ItemType>=(unsigned int) ItemTypes) { //invalid itemtype + if (feedback) core->DisplayConstantString(STR_WRONGITEMTYPE, 0xf0f0f0); return 0; } //if actor is supplied, check its usability fields if (actor) { - if (actor->Unusable(item)) { + ieStrRef str = actor->Unusable(item); + if (str) { + if (feedback) core->DisplayConstantString(str, 0xf0f0f0); return 0; } } //if any bit is true, the answer counts as true int ret = (slotmatrix[item->ItemType]&slottype); + if (!ret) { + if (feedback) core->DisplayConstantString(STR_WRONGITEMTYPE, 0xf0f0f0); + } return ret; } -Label *Interface::GetMessageLabel() +Label *Interface::GetMessageLabel() const { ieDword WinIndex = (ieDword) -1; ieDword TAIndex = (ieDword) -1; @@ -4039,7 +4047,7 @@ return NULL; } -TextArea *Interface::GetMessageTextArea() +TextArea *Interface::GetMessageTextArea() const { ieDword WinIndex = (ieDword) -1; ieDword TAIndex = (ieDword) -1; @@ -4920,7 +4928,7 @@ } /* we should return -1 if it isn't gold, otherwise return the gold value */ -int Interface::CanMoveItem(CREItem *item) +int Interface::CanMoveItem(const CREItem *item) const { if (item->Flags & IE_INV_ITEM_UNDROPPABLE) return 0; @@ -5152,9 +5160,9 @@ return 0; } -int Interface::GetMaximumAbility() { return MaximumAbility; } +int Interface::GetMaximumAbility() const { return MaximumAbility; } -int Interface::GetStrengthBonus(int column, int value, int ex) +int Interface::GetStrengthBonus(int column, int value, int ex) const { //to hit, damage, open doors, weight allowance if (column<0 || column>3) @@ -5174,7 +5182,7 @@ } //only the first 3 columns are supported -int Interface::GetIntelligenceBonus(int column, int value) +int Interface::GetIntelligenceBonus(int column, int value) const { //learn spell, max spell level, max spell number on level if (column<0 || column>2) @@ -5183,7 +5191,7 @@ return intmod[column*(MaximumAbility+1)+value]; } -int Interface::GetDexterityBonus(int column, int value) +int Interface::GetDexterityBonus(int column, int value) const { //reaction, missile, ac if (column<0 || column>2) @@ -5192,7 +5200,7 @@ return dexmod[column*(MaximumAbility+1)+value]; } -int Interface::GetConstitutionBonus(int column, int value) +int Interface::GetConstitutionBonus(int column, int value) const { //normal, warrior, minimum, regen hp, regen fatigue if (column<0 || column>4) @@ -5201,7 +5209,7 @@ return conmod[column*(MaximumAbility+1)+value]; } -int Interface::GetCharismaBonus(int column, int value) +int Interface::GetCharismaBonus(int column, int value) const { //?reaction if (column<0 || column>0) @@ -5300,7 +5308,7 @@ } //returns a numeric value associated with a stat name (symbol) from stats.ids -ieDword Interface::TranslateStat(const char *stat_name) +ieDword Interface::TranslateStat(const char *stat_name) { int symbol = LoadSymbol( "stats" ); SymbolMgr *sym = GetSymbol( symbol ); Modified: gemrb/trunk/gemrb/plugins/Core/Interface.h =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Interface.h 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/Interface.h 2007-09-02 16:11:28 UTC (rev 4796) @@ -324,10 +324,10 @@ void SetFeature(int value, int position); /* don't rely on the exact return value of this function */ ieDword HasFeature(int position) const; - bool IsAvailable(SClass_ID filetype); - void * GetInterface(SClass_ID filetype); - std::vector<InterfaceElement>* GetInterfaceVector(SClass_ID filetype); - const char * TypeExt(SClass_ID type); + bool IsAvailable(SClass_ID filetype) const; + void * GetInterface(SClass_ID filetype) const; + std::vector<InterfaceElement>* GetInterfaceVector(SClass_ID filetype) const; + const char * TypeExt(SClass_ID type) const; ProjectileServer* GetProjectileServer() const; Video * GetVideoDriver() const; ResourceMgr * GetResourceMgr() const; @@ -340,7 +340,7 @@ /* sets the floattext color */ void SetInfoTextColor(Color &color); /** returns a gradient set */ - Color * GetPalette(int index, int colors, Color *buffer); + Color * GetPalette(int index, int colors, Color *buffer) const; /** Returns a preloaded Font */ Font * GetFont(const char *) const; Font * GetFont(unsigned int index) const; @@ -374,7 +374,7 @@ /** Add a window to the Window List */ void AddWindow(Window * win); /** Get a Control on a Window */ - int GetControl(unsigned short WindowIndex, unsigned long ControlID); + int GetControl(unsigned short WindowIndex, unsigned long ControlID) const; /** Adjust the scrolling of the control (if applicable) */ int AdjustScrolling(unsigned short WindowIndex, unsigned short ControlIndex, short x, short y); /** Set the Text of a Control */ @@ -386,9 +386,9 @@ /** Actually draws tooltip on the screen. Called from SDLVideoDriver */ void DrawTooltip(); /** returns the label which should receive game messages (overrides messagetextarea) */ - Label *GetMessageLabel(); + Label *GetMessageLabel() const; /** returns the textarea of the main game screen */ - TextArea *GetMessageTextArea(); + TextArea *GetMessageTextArea() const; /** returns a string reference from a string reference index constant*/ ieStrRef GetStringReference(int stridx); /** displays any string in the textarea */ @@ -406,7 +406,7 @@ /** displays a string in the textarea, starting with speaker's name */ void DisplayStringName(int stridx, unsigned int color, Scriptable *speaker, ieDword flags); /** returns the Window Visible Flag */ - int GetVisible(unsigned short WindowIndex); + int GetVisible(unsigned short WindowIndex) const; /** Set a Window Visible Flag */ int SetVisible(unsigned short WindowIndex, int visible); /** Show a Window in Modal Mode */ @@ -414,9 +414,9 @@ /** Set the Status of a Control in a Window */ int SetControlStatus(unsigned short WindowIndex, unsigned short ControlIndex, unsigned long Status); /** Get a Window from the Loaded Window List */ - Window * GetWindow(unsigned short WindowIndex); + Window * GetWindow(unsigned short WindowIndex) const; /** Returns true if wnd is a valid window with WindowIndex */ - bool IsValidWindow(unsigned short WindowID, Window *wnd); + bool IsValidWindow(unsigned short WindowID, Window *wnd) const; /** Removes a Loaded Window */ int DelWindow(unsigned short WindowIndex); /** Redraws all window */ @@ -428,41 +428,41 @@ /** Draws the Console */ void DrawConsole(); /** Get the Sound Manager */ - SoundMgr * GetSoundMgr(); + SoundMgr * GetSoundMgr() const; /** Get the SaveGameIterator */ - SaveGameIterator * GetSaveGameIterator(); + SaveGameIterator * GetSaveGameIterator() const; /** Get the Variables Dictionary */ - Variables * GetDictionary(); + Variables * GetDictionary() const; /** Get the Token Dictionary */ - Variables * GetTokenDictionary(); + Variables * GetTokenDictionary() const; /** Get the Music Manager */ - MusicMgr * GetMusicMgr(); + MusicMgr * GetMusicMgr() const; /** Loads a 2DA Table, returns -1 on error or the Table Index on success */ int LoadTable(const char * ResRef); /** Gets the index of a loaded table, returns -1 on error */ - int GetTableIndex(const char * ResRef); + int GetTableIndex(const char * ResRef) const; /** Gets a Loaded Table by its index, returns NULL on error */ - TableMgr * GetTable(unsigned int index); + TableMgr * GetTable(unsigned int index) const; /** Frees a Loaded Table, returns false on error, true on success */ bool DelTable(unsigned int index); /** Loads an IDS Table, returns -1 on error or the Symbol Table Index on success */ int LoadSymbol(const char * ResRef); /** Gets the index of a loaded Symbol Table, returns -1 on error */ - int GetSymbolIndex(const char * ResRef); + int GetSymbolIndex(const char * ResRef) const; /** Gets a Loaded Symbol Table by its index, returns NULL on error */ - SymbolMgr * GetSymbol(unsigned int index); + SymbolMgr * GetSymbol(unsigned int index) const; /** Frees a Loaded Symbol Table, returns false on error, true on success */ bool DelSymbol(unsigned int index); /** Plays a Movie */ int PlayMovie(const char * ResRef); /** Generates traditional random number xdy+z */ - int Roll(int dice, int size, int add); + int Roll(int dice, int size, int add) const; /** Loads a Game Compiled Script */ int LoadScript(const char * ResRef); /** Enables/Disables the CutScene Mode */ void SetCutSceneMode(bool active); /** returns true if in cutscene mode */ - bool InCutSceneMode(); + bool InCutSceneMode() const; /** Updates the Game Script Engine State */ void GSUpdate(bool update_scripts) { @@ -474,27 +474,27 @@ } } /** Get the Party INI Interpreter */ - DataFileMgr * GetPartyINI() + DataFileMgr * GetPartyINI() const { return INIparty; } - DataFileMgr * GetBeastsINI() + DataFileMgr * GetBeastsINI() const { return INIbeasts; } - DataFileMgr * GetQuestsINI() + DataFileMgr * GetQuestsINI() const { return INIquests; } /** Gets the Game class */ - Game * GetGame() + Game * GetGame() const { return game; } /** Gets the WorldMap class, returns the current worldmap or the first worldmap containing the area*/ WorldMap * GetWorldMap(const char *area = NULL); void SetWindowFrame(int i, Sprite2D *Picture); - GameControl *GetGameControl(); + GameControl *GetGameControl() const; /** if backtomain is not null then goes back to main screen */ void QuitGame(int backtomain); void LoadGame(int index); @@ -513,7 +513,7 @@ ieDword QuerySlotEffects(unsigned int idx) const; const char * QuerySlotResRef(unsigned int idx) const; /*returns true if an itemtype is acceptable for a slottype, also checks the usability flags */ - int CanUseItemType(int slottype, Item *item, Actor *actor=NULL) const; + int CanUseItemType(int slottype, Item *item, Actor *actor=NULL, bool feedback=false) const; /*removes single file from cache*/ void RemoveFromCache(const ieResRef resref, SClass_ID SClassID); /*removes all files from directory*/ @@ -532,7 +532,7 @@ void FreePalette(Palette *&pal, const ieResRef name=NULL); void DragItem(CREItem* item, const ieResRef Picture); - CREItem* GetDraggedItem() { return DraggedItem; } + CREItem* GetDraggedItem() const { return DraggedItem; } /* use this only when the dragged item is dropped */ void ReleaseDraggedItem(); CREItem *ReadItem(DataStream *str); @@ -575,13 +575,13 @@ Sprite2D *GetCursorSprite(); /** returns 0 for unmovable, -1 for movable items, otherwise it returns gold value! */ - int CanMoveItem(CREItem *item); - int GetMaximumAbility(); - int GetStrengthBonus(int column, int value, int ex); - int GetIntelligenceBonus(int column, int value); - int GetDexterityBonus(int column, int value); - int GetConstitutionBonus(int column, int value); - int GetCharismaBonus(int column, int value); + int CanMoveItem(const CREItem *item) const; + int GetMaximumAbility() const; + int GetStrengthBonus(int column, int value, int ex) const; + int GetIntelligenceBonus(int column, int value) const; + int GetDexterityBonus(int column, int value) const; + int GetConstitutionBonus(int column, int value) const; + int GetCharismaBonus(int column, int value) const; /** applies the spell on the target */ void ApplySpell(const ieResRef resname, Actor *target, Actor *caster, int level); @@ -611,13 +611,13 @@ /** Returns the item tooltip value for the xth extension header */ int GetItemTooltip(const ieResRef itemname, int idx); /** Returns the item exclusion value */ - int GetItemExcl(const ieResRef itemname); + int GetItemExcl(const ieResRef itemname) const; /** Returns the strref for the item dialog */ - int GetItemDialStr(const ieResRef itemname); + int GetItemDialStr(const ieResRef itemname) const; /** Returns the strref for the item dialog */ - int GetItemDialRes(const ieResRef itemname, ieResRef dialog); + int GetItemDialRes(const ieResRef itemname, ieResRef dialog) const; /** Returns the virtual worldmap entry of a sub-area */ - int GetAreaAlias(const ieResRef areaname); + int GetAreaAlias(const ieResRef areaname) const; /** Returns up to 3 resources from resref, choosing rows randomly unwanted return variables could be omitted */ void GetResRefFrom2DA(const ieResRef resref, ieResRef resource1, ieResRef resource2 = NULL, ieResRef resource3 = NULL); Modified: gemrb/trunk/gemrb/plugins/Core/Inventory.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Inventory.cpp 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/Inventory.cpp 2007-09-02 16:11:28 UTC (rev 4796) @@ -53,7 +53,7 @@ abort(); } -inline const Item *Inventory::GetItemPointer(ieDword slot, CREItem *&item) +inline Item *Inventory::GetItemPointer(ieDword slot, CREItem *&item) const { item = GetSlotItem(slot); if (!item) return NULL; @@ -236,12 +236,12 @@ } /** if you supply a "" string, then it checks if the slot is empty */ -bool Inventory::HasItemInSlot(const char *resref, unsigned int slot) +bool Inventory::HasItemInSlot(const char *resref, unsigned int slot) const { if (slot >= Slots.size()) { return false; } - CREItem *item = Slots[slot]; + const CREItem *item = Slots[slot]; if (!item) { return false; } @@ -256,12 +256,12 @@ /** counts the items in the inventory, if stacks == 1 then stacks are accounted for their heap size */ -int Inventory::CountItems(const char *resref, bool stacks) +int Inventory::CountItems(const char *resref, bool stacks) const { int count = 0; size_t slot = Slots.size(); while(slot--) { - CREItem *item = Slots[slot]; + const CREItem *item = Slots[slot]; if (!item) { continue; } @@ -282,11 +282,11 @@ /** this function can look for stolen, equipped, identified, destructible etc, items. You just have to specify the flags in the bitmask specifying 1 in a bit signifies a requirement */ -bool Inventory::HasItem(const char *resref, ieDword flags) +bool Inventory::HasItem(const char *resref, ieDword flags) const { size_t slot = Slots.size(); while(slot--) { - CREItem *item = Slots[slot]; + const CREItem *item = Slots[slot]; if (!item) { continue; } @@ -563,7 +563,7 @@ } /* could the source item be dropped on the target item to merge them */ -bool Inventory::ItemsAreCompatible(CREItem* target, CREItem* source) +bool Inventory::ItemsAreCompatible(CREItem* target, CREItem* source) const { if (!target) { //this isn't always ok, please check! @@ -612,10 +612,10 @@ return -1; } -int Inventory::FindItem(const char *resref, unsigned int flags) +int Inventory::FindItem(const char *resref, unsigned int flags) const { for (size_t i = 0; i < Slots.size(); i++) { - CREItem *item = Slots[i]; + const CREItem *item = Slots[i]; if (!item) { continue; } @@ -688,7 +688,7 @@ return dropped; } -CREItem *Inventory::GetSlotItem(unsigned int slot) +CREItem *Inventory::GetSlotItem(unsigned int slot) const { if (slot >= Slots.size() ) { InvalidSlot(slot); @@ -696,9 +696,9 @@ return Slots[slot]; } -ieDword Inventory::GetItemFlag(unsigned int slot) +ieDword Inventory::GetItemFlag(unsigned int slot) const { - CREItem *item = GetSlotItem(slot); + const CREItem *item = GetSlotItem(slot); if (!item) { return 0; } @@ -839,7 +839,7 @@ // 2 - xbow // 4 - sling //returns equipped code -int Inventory::FindRangedProjectile(unsigned int type) +int Inventory::FindRangedProjectile(unsigned int type) const { for(int i=SLOT_RANGED;i<=LAST_RANGED;i++) { CREItem *Slot; @@ -861,17 +861,17 @@ // find which bow is attached to the projectile marked by 'Equipped' // returns slotcode -int Inventory::FindRangedWeapon() +int Inventory::FindRangedWeapon() const { if (Equipped>=0) return SLOT_FIST; return FindSlotRangedWeapon(Equipped+SLOT_MELEE); } -int Inventory::FindSlotRangedWeapon(unsigned int slot) +int Inventory::FindSlotRangedWeapon(unsigned int slot) const { if ((int)slot >= SLOT_MELEE) return SLOT_FIST; CREItem *Slot; - const Item *itm = GetItemPointer(slot, Slot); + Item *itm = GetItemPointer(slot, Slot); if (!itm) return SLOT_FIST; ITMExtHeader *ext_header = itm->GetExtHeader(0); @@ -885,7 +885,7 @@ // find bow for a specific projectile type -int Inventory::FindTypedRangedWeapon(unsigned int type) +int Inventory::FindTypedRangedWeapon(unsigned int type) const { if (!type) { return SLOT_FIST; @@ -987,13 +987,13 @@ return SLOT_INV; } -int Inventory::GetEquipped() +int Inventory::GetEquipped() const { return Equipped; } //if shield slot is empty, call again for fist slot! -int Inventory::GetShieldSlot() +int Inventory::GetShieldSlot() const { if (IWD2) { if (Equipped>=0 && Equipped<=3) { @@ -1004,7 +1004,7 @@ return SLOT_LEFT; } -int Inventory::GetEquippedSlot() +int Inventory::GetEquippedSlot() const { if (Equipped == IW_NO_EQUIPPED) { return SLOT_FIST; @@ -1012,7 +1012,9 @@ if (IWD2 && Equipped>=0) { //i've absolutely NO idea what is this 4 (Avenger) //Equipped should be 0-3 in iWD2, no??? - if (Equipped == 4) Equipped = 0; + if (Equipped >= 4) { + return SLOT_MELEE; + } return Equipped*2+SLOT_MELEE; } return Equipped+SLOT_MELEE; @@ -1055,7 +1057,7 @@ } //returns the fist weapon if there is nothing else -CREItem *Inventory::GetUsedWeapon(bool leftorright) +CREItem *Inventory::GetUsedWeapon(bool leftorright) const { CREItem *ret; int slot; @@ -1404,7 +1406,7 @@ } //this function will also check disabled slots (if that feature will be imped) -bool Inventory::IsSlotBlocked(int slot) +bool Inventory::IsSlotBlocked(int slot) const { if (slot<SLOT_MELEE) return false; if (slot>LAST_MELEE) return false; @@ -1417,7 +1419,7 @@ return HasItemInSlot("",otherslot); } -inline bool Inventory::TwoHandedInSlot(int slot) +inline bool Inventory::TwoHandedInSlot(int slot) const { CREItem *item; @@ -1429,10 +1431,11 @@ return false; } -int Inventory::WhyCantEquip(int slot, int twohanded) +int Inventory::WhyCantEquip(int slot, int twohanded) const { //can't equip in shield slot if a weapon slot is twohanded for (int i=SLOT_MELEE; i<=LAST_MELEE;i++) { + //see GetShieldSlot int otherslot; if (IWD2) { otherslot = ++i; Modified: gemrb/trunk/gemrb/plugins/Core/Inventory.h =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Inventory.h 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/Inventory.h 2007-09-02 16:11:28 UTC (rev 4796) @@ -217,12 +217,12 @@ /** adds an item to the inventory */ void AddItem(CREItem *item); /** Returns number of items in the inventory */ - int CountItems(const char *resref, bool charges); + int CountItems(const char *resref, bool charges) const; /** looks for a particular item in a slot */ - bool HasItemInSlot(const char *resref, unsigned int slot); + bool HasItemInSlot(const char *resref, unsigned int slot) const; /** Looks for a particular item in the inventory. */ /* flags: see ieCREItemFlagBits */ - bool HasItem(const char *resref, ieDword flags); + bool HasItem(const char *resref, ieDword flags) const; void CalculateWeight(void); void SetInventoryType(int arg); @@ -258,40 +258,40 @@ /** flags: see ieCREItemFlagBits */ void SetItemFlags(CREItem* item, ieDword flags); void SetSlotItem(CREItem* item, unsigned int slot); - int GetWeight() {return Weight;} + int GetWeight() const {return Weight;} - bool ItemsAreCompatible(CREItem* target, CREItem* source); + bool ItemsAreCompatible(CREItem* target, CREItem* source) const; //depletes charged items int DepleteItem(ieDword flags); /** Finds the first slot of named item, if resref is empty, finds the first filled! slot */ - int FindItem(const char *resref, unsigned int flags); + int FindItem(const char *resref, unsigned int flags) const; bool DropItemAtLocation(unsigned int slot, unsigned int flags, Map *map, Point &loc); bool DropItemAtLocation(const char *resref, unsigned int flags, Map *map, Point &loc); bool SetEquippedSlot(int slotcode); - int GetEquipped(); + int GetEquipped() const; //right hand - int GetEquippedSlot(); + int GetEquippedSlot() const; //left hand - int GetShieldSlot(); + int GetShieldSlot() const; void AddSlotEffects( ieDword slot); //void AddAllEffects(); /** Returns item in specified slot. Does NOT change inventory */ - CREItem* GetSlotItem(ieDword slot); + CREItem* GetSlotItem(ieDword slot) const; /** Returns the item's inventory flags */ - ieDword GetItemFlag(unsigned int slot); + ieDword GetItemFlag(unsigned int slot) const; /** Changes the inventory flags */ bool ChangeItemFlag(ieDword slot, ieDword value, int mode); /** Equips the item, don't use it directly for weapons */ bool EquipItem(ieDword slot); bool UnEquipItem(ieDword slot, bool removecurse); /** Returns equipped weapon */ - CREItem *GetUsedWeapon(bool leftorright); + CREItem *GetUsedWeapon(bool leftorright) const; /** returns slot of launcher weapon currently equipped */ - int FindRangedWeapon(); + int FindRangedWeapon() const; /** returns slot of launcher weapon for specified projectile type */ - int FindTypedRangedWeapon(unsigned int type); + int FindTypedRangedWeapon(unsigned int type) const; /** returns slot of launcher weapon for projectile in specified slot */ - int FindSlotRangedWeapon(ieDword slot); + int FindSlotRangedWeapon(ieDword slot) const; /** Returns a slot which might be empty, or capable of holding item (or part of it) */ int FindCandidateSlot(int slottype, size_t first_slot, const char *resref = NULL); /** Creates an item in the slot*/ @@ -309,11 +309,11 @@ /** returns the exclusion bits */ ieDword GetEquipExclusion() const; /** returns if a slot is temporarily blocked */ - bool IsSlotBlocked(int slot); + bool IsSlotBlocked(int slot) const; /** returns true if a two handed weapon is in slot */ - inline bool TwoHandedInSlot(int slot); + inline bool TwoHandedInSlot(int slot) const; /** returns the strref for the reason why the item cannot be equipped */ - int WhyCantEquip(int slot, int twohanded); + int WhyCantEquip(int slot, int twohanded) const; //setting important constants static void Init(int mb); static void SetHeadSlot(int arg); @@ -332,11 +332,11 @@ static int GetQuickSlot(); static int GetInventorySlot(); private: - int FindRangedProjectile(unsigned int type); + int FindRangedProjectile(unsigned int type) const; // called by KillSlot void RemoveSlotEffects( /*CREItem* slot*/ ieDword slot ); void KillSlot(ieDword index); - inline const Item *GetItemPointer(ieDword slot, CREItem *&Slot); + inline Item *GetItemPointer(ieDword slot, CREItem *&Slot) const; void UpdateWeaponAnimation(); void UpdateShieldAnimation(Item *it); }; Modified: gemrb/trunk/gemrb/plugins/Core/PluginMgr.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/PluginMgr.cpp 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/PluginMgr.cpp 2007-09-02 16:11:28 UTC (rev 4796) @@ -229,7 +229,7 @@ #endif } -bool PluginMgr::IsAvailable(SClass_ID plugintype) +bool PluginMgr::IsAvailable(SClass_ID plugintype) const { for (unsigned int i = 0; i < plugins.size(); i++) { if (plugins[i]->SuperClassID() == plugintype) { @@ -239,7 +239,7 @@ return false; } -void* PluginMgr::GetPlugin(SClass_ID plugintype) +void* PluginMgr::GetPlugin(SClass_ID plugintype) const { if (!&plugins) { return NULL; @@ -253,7 +253,7 @@ return NULL; } -std::vector<InterfaceElement> *PluginMgr::GetAllPlugin(SClass_ID plugintype) +std::vector<InterfaceElement> *PluginMgr::GetAllPlugin(SClass_ID plugintype) const { if (!&plugins) { return NULL; Modified: gemrb/trunk/gemrb/plugins/Core/PluginMgr.h =================================================================== --- gemrb/trunk/gemrb/plugins/Core/PluginMgr.h 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/PluginMgr.h 2007-09-02 16:11:28 UTC (rev 4796) @@ -70,11 +70,11 @@ std::vector< ClassDesc*> plugins; std::vector< LibHandle> libs; public: - bool IsAvailable(SClass_ID plugintype); - void* GetPlugin(SClass_ID plugintype); - std::vector<InterfaceElement> *GetAllPlugin(SClass_ID plugintype); + bool IsAvailable(SClass_ID plugintype) const; + void* GetPlugin(SClass_ID plugintype) const; + std::vector<InterfaceElement> *GetAllPlugin(SClass_ID plugintype) const; void FreePlugin(void* ptr); - size_t GetPluginCount() { return plugins.size(); } + size_t GetPluginCount() const { return plugins.size(); } }; #endif Modified: gemrb/trunk/gemrb/plugins/Core/Triggers.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Triggers.cpp 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/Triggers.cpp 2007-09-02 16:11:28 UTC (rev 4796) @@ -1409,7 +1409,7 @@ if (!target) { return 0; } - if (PersonalDistance(target, Sender) > MAX_OPERATING_DISTANCE ) { + if (PersonalDistance(target, Sender) > 3*MAX_OPERATING_DISTANCE ) { return 0; } //now objects suicide themselves if they are empty objects Modified: gemrb/trunk/gemrb/plugins/Core/Window.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Window.cpp 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/Window.cpp 2007-09-02 16:11:28 UTC (rev 4796) @@ -151,7 +151,7 @@ return lastC; } } - std::vector< Control*>::iterator m; + std::vector< Control*>::const_iterator m; for (m = Controls.begin(); m != Controls.end(); m++) { if (ignore && (*m)->ControlID&IGNORE_CONTROL) { continue; @@ -169,12 +169,12 @@ return ctrl; } -Control* Window::GetOver() +Control* Window::GetOver() const { return lastOver; } -Control* Window::GetFocus() +Control* Window::GetFocus() const { return lastFocus; } @@ -193,7 +193,7 @@ } } -Control* Window::GetControl(unsigned short i) +Control* Window::GetControl(unsigned short i) const { if (i < Controls.size()) { return Controls[i]; @@ -201,7 +201,7 @@ return NULL; } -bool Window::IsValidControl(unsigned short ID, Control *ctrl) +bool Window::IsValidControl(unsigned short ID, Control *ctrl) const { size_t i = Controls.size(); while (i--) { @@ -231,7 +231,7 @@ Invalidate(); } -Control* Window::GetDefaultControl() +Control* Window::GetDefaultControl() const { if (!Controls.size()) { return NULL; Modified: gemrb/trunk/gemrb/plugins/Core/Window.h =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Window.h 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/Core/Window.h 2007-09-02 16:11:28 UTC (rev 4796) @@ -119,21 +119,21 @@ /** Returns the Control at X,Y Coordinates */ Control* GetControl(unsigned short x, unsigned short y, bool ignore=0); /** Returns the Control by Index */ - Control* GetControl(unsigned short i); + Control* GetControl(unsigned short i) const; /** Returns true if ctrl is valid and ctrl->ControlID is ID */ - bool IsValidControl(unsigned short ID, Control *ctrl); + bool IsValidControl(unsigned short ID, Control *ctrl) const; /** Deletes the xth. Control */ void DelControl(unsigned short i); /** Returns the Default Control which may be a button/gamecontrol atm */ - Control* GetDefaultControl(); + Control* GetDefaultControl() const; /** Sets 'ctrl' as currently under mouse */ void SetOver(Control* ctrl); /** Returns last control under mouse */ - Control* GetOver(); + Control* GetOver() const; /** Sets 'ctrl' as Focused */ void SetFocused(Control* ctrl); /** Returns last focused control */ - Control* GetFocus(); + Control* GetFocus() const; /** Redraw all the Window */ void Invalidate(); /** Redraw controls of the same group */ Modified: gemrb/trunk/gemrb/plugins/GUIScript/GUIScript.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/GUIScript/GUIScript.cpp 2007-09-02 15:56:49 UTC (rev 4795) +++ gemrb/trunk/gemrb/plugins/GUIScript/GUIScript.cpp 2007-09-02 16:11:28 UTC (rev 4796) @@ -6082,7 +6082,7 @@ } } - int ret=core->CanUseItemType(SlotType, item, actor); + int ret=core->CanUseItemType(SlotType, item, actor, false); core->FreeItem(item, ItemName, false); return PyInt_FromLong(ret); } @@ -6189,10 +6189,10 @@ PyDict_SetItemString(dict, "LoreToID", PyInt_FromLong(item->LoreToID)); int function=0; - if (core->CanUseItemType(SLOT_POTION, item, actor) ) { + if (core->CanUseItemType(SLOT_POTION, item, actor, false) ) { function|=CAN_DRINK; } - if (core->CanUseItemType(SLOT_SCROLL, item, actor) ) { + if (core->CanUseItemType(SLOT_SCROLL, item, actor, false) ) { ITMExtHeader *eh; Effect *f; //determining if this is a copyable scroll @@ -6215,7 +6215,7 @@ function|=CAN_READ; } not_a_scroll: - if (core->CanUseItemType(SLOT_BAG, item, NULL) ) { + if (core->CanUseItemType(SLOT_BAG, item, NULL, false) ) { //allow the open container flag only if there is //a store file (this fixes pst eye items, which //got the same item type as bags) @@ -6446,7 +6446,7 @@ return PyInt_FromLong( 0 ); } //CanUseItemType will check actor's class bits too - Slottype =core->CanUseItemType (Slottype, item, actor); + Slottype = core->CanUseItemType (Slottype, item, actor, true); //resolve the equipping sound if (core->HasFeature(GF_HAS_PICK_SOUND) && item->ReplacementItem[0]) { memcpy(Sound, item->ReplacementItem, 9); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |