Permalink
Browse files

make stores auto-identify their items if lore is good enough

  • Loading branch information...
1 parent 6543dcd commit 9dbe7358934623623588ddfe9fec9d6a116a0799 @fizzet fizzet committed Apr 15, 2013
View
@@ -229,9 +229,6 @@ void Store::RechargeItem(CREItem *item)
if (!itm) {
return;
}
- if (!itm->LoreToID) {
- item->Flags |= IE_INV_ITEM_IDENTIFIED;
- }
//gemrb extension, some shops won't recharge items
//containers' behaviour is inverted
//bag 0 1 0 1
@@ -253,8 +250,25 @@ void Store::RechargeItem(CREItem *item)
gamedata->FreeItem(itm, item->ItemResRef, 0);
}
+void Store::IdentifyItem(CREItem *item) const
+{
+ if (item->Flags & IE_INV_ITEM_IDENTIFIED) {
+ return;
+ }
+
+ Item *itm = gamedata->GetItem(item->ItemResRef);
+ if (!itm) {
+ return;
+ }
+
+ if (itm->LoreToID <= Lore) {
+ item->Flags |= IE_INV_ITEM_IDENTIFIED;
+ }
+}
+
void Store::AddItem(CREItem *item)
{
+ IdentifyItem(item);
RechargeItem(item);
STOItem *temp = FindItem(item, true);
View
@@ -173,6 +173,8 @@ class GEM_EXPORT Store {
ieDword GetOwnerID() const;
void SetOwnerID(ieDword owner);
private:
+ /** Identifies item according to store lore */
+ void IdentifyItem(CREItem *item) const;
/** Finds a mergeable item in the stock, if exact is set, it checks for usage counts too */
STOItem *FindItem(CREItem *item, bool exact);
bool IsItemAvailable(unsigned int slot) const;
@@ -136,7 +136,7 @@ Store* STOImporter::GetStore(Store *s)
str->Seek( s->ItemsOffset, GEM_STREAM_START );
for (i = 0; i < s->ItemsCount; i++) {
STOItem *item = s->items[i];
- GetItem(item);
+ GetItem(item, s);
//it is important to handle this field as signed
if (item->InfiniteSupply>0) {
char *TriggerCode = core->GetString( (ieStrRef) item->InfiniteSupply );
@@ -162,7 +162,7 @@ Store* STOImporter::GetStore(Store *s)
return s;
}
-void STOImporter::GetItem(STOItem *it)
+void STOImporter::GetItem(STOItem *it, Store *s)
{
core->ReadItem(str, (CREItem *) it);
@@ -178,7 +178,7 @@ void STOImporter::GetItem(STOItem *it)
if (item) {
it->MaxStackAmount = item->MaxStackAmount;
//another hack-fix
- if (!item->LoreToID) {
+ if (item->LoreToID <= s->Lore) {
it->Flags |= IE_INV_ITEM_IDENTIFIED;
}
gamedata->FreeItem( item, it->ItemResRef, false );
@@ -47,7 +47,7 @@ class STOImporter : public StoreMgr {
bool PutStore(DataStream *stream, Store *store);
private:
- void GetItem(STOItem *item);
+ void GetItem(STOItem *item, Store* s);
void GetDrink(STODrink *drink);
void GetCure(STOCure *cure);
void GetPurchasedCategories(Store* s);

0 comments on commit 9dbe735

Please sign in to comment.