This commit is contained in:
vsab
2014-05-10 18:30:52 +00:00
15 changed files with 271 additions and 33 deletions
+30
View File
@@ -24,6 +24,7 @@
#include "races.h"
#include "shareddb.h"
#include "classes.h"
#include "../common/rulesys.h"
#include <limits.h>
@@ -400,6 +401,35 @@ void ItemInst::PutAugment(SharedDatabase *db, uint8 slot, uint32 item_id)
}
}
bool ItemInst::HasOrnamentation() const
{
if(!RuleB(Inventory,UseAugOrnamentations)) return false;
const ItemInst *item;
for (int i = 0; i < MAX_AUGMENT_SLOTS; ++i)
{
uint32 id = 0;
if ((item = GetItem(i)) != nullptr)
{
if (item->GetItem()->AugType == RuleI(Inventory,AugOrnamentationType))return true;
}
}
return false;
}
ItemInst* ItemInst::GetOrnamentation() const
{
if(!RuleB(Inventory,UseAugOrnamentations)) return nullptr;
if (m_item->ItemClass == ItemClassCommon)
{
ItemInst *item;
for (int i = 0; i < MAX_AUGMENT_SLOTS; ++i)
{
if ((item = GetItem(i)) != nullptr && item->GetItem()->AugType == RuleI(Inventory,AugOrnamentationType)) return item;
}
}
return nullptr;
}
// Retrieve item inside container
ItemInst* ItemInst::GetItem(uint8 index) const
{
+2 -1
View File
@@ -304,7 +304,8 @@ public:
bool AvailableWearSlot(uint32 aug_wear_slots) const;
int8 AvailableAugmentSlot(int32 augtype) const;
inline int32 GetAugmentType() const { return m_item->AugType; }
bool HasOrnamentation() const;
ItemInst* GetOrnamentation() const;
inline bool IsExpendable() const { return ((m_item->Click.Type == ET_Expendable ) || (m_item->ItemType == ItemTypePotion)); }
//
+15 -3
View File
@@ -4926,13 +4926,25 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
ss.write((const char*)&null_term, sizeof(uint8));
}
if(strlen(item->IDFile) > 0)
if (RuleB(Inventory,UseAugOrnamentations) && inst && inst->HasOrnamentation())
{
ss.write(item->IDFile, strlen(item->IDFile));
ItemInst* ornamentation = inst->GetOrnamentation();
if (ornamentation) //paranoid!
{
ss.write(ornamentation->GetItem()->IDFile, strlen(ornamentation->GetItem()->IDFile));
}
else if (strlen(item->IDFile) > 0)
{
ss.write(item->IDFile, strlen(item->IDFile));
}
ss.write((const char*)&null_term, sizeof(uint8));
}
else
else //original code although I shortened it
{
if (strlen(item->IDFile) > 0)
{
ss.write(item->IDFile, strlen(item->IDFile));
}
ss.write((const char*)&null_term, sizeof(uint8));
}
+15 -3
View File
@@ -3119,13 +3119,25 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
ss.write((const char*)&null_term, sizeof(uint8));
}
if(strlen(item->IDFile) > 0)
if (RuleB(Inventory,UseAugOrnamentations) && inst && inst->HasOrnamentation())
{
ss.write(item->IDFile, strlen(item->IDFile));
ItemInst* ornamentation = inst->GetOrnamentation();
if (ornamentation) //paranoid!
{
ss.write(ornamentation->GetItem()->IDFile, strlen(ornamentation->GetItem()->IDFile));
}
else if (strlen(item->IDFile) > 0)
{
ss.write(item->IDFile, strlen(item->IDFile));
}
ss.write((const char*)&null_term, sizeof(uint8));
}
else
else //original code although I shortened it
{
if (strlen(item->IDFile) > 0)
{
ss.write(item->IDFile, strlen(item->IDFile));
}
ss.write((const char*)&null_term, sizeof(uint8));
}
+15 -3
View File
@@ -2437,13 +2437,25 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
ss.write((const char*)&null_term, sizeof(uint8));
}
if(strlen(item->IDFile) > 0)
if (RuleB(Inventory,UseAugOrnamentations) && inst && inst->HasOrnamentation())
{
ss.write(item->IDFile, strlen(item->IDFile));
ItemInst* ornamentation = inst->GetOrnamentation();
if (ornamentation) //paranoid!
{
ss.write(ornamentation->GetItem()->IDFile, strlen(ornamentation->GetItem()->IDFile));
}
else if (strlen(item->IDFile) > 0)
{
ss.write(item->IDFile, strlen(item->IDFile));
}
ss.write((const char*)&null_term, sizeof(uint8));
}
else
else //original code although I shortened it
{
if (strlen(item->IDFile) > 0)
{
ss.write(item->IDFile, strlen(item->IDFile));
}
ss.write((const char*)&null_term, sizeof(uint8));
}
+15 -3
View File
@@ -3530,13 +3530,25 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
ss.write((const char*)&null_term, sizeof(uint8));
}
if(strlen(item->IDFile) > 0)
if (RuleB(Inventory,UseAugOrnamentations) && inst && inst->HasOrnamentation())
{
ss.write(item->IDFile, strlen(item->IDFile));
ItemInst* ornamentation = inst->GetOrnamentation();
if (ornamentation) //paranoid!
{
ss.write(ornamentation->GetItem()->IDFile, strlen(ornamentation->GetItem()->IDFile));
}
else if (strlen(item->IDFile) > 0)
{
ss.write(item->IDFile, strlen(item->IDFile));
}
ss.write((const char*)&null_term, sizeof(uint8));
}
else
else //original code although I shortened it
{
if (strlen(item->IDFile) > 0)
{
ss.write(item->IDFile, strlen(item->IDFile));
}
ss.write((const char*)&null_term, sizeof(uint8));
}
+2
View File
@@ -553,6 +553,8 @@ RULE_CATEGORY( Inventory )
RULE_BOOL ( Inventory, EnforceAugmentRestriction, true) // Forces augment slot restrictions
RULE_BOOL ( Inventory, EnforceAugmentUsability, true) // Forces augmented item usability
RULE_BOOL ( Inventory, EnforceAugmentWear, true) // Forces augment wear slot validation
RULE_BOOL ( Inventory, UseAugOrnamentations, true) // Allows use of augment ornamentations
RULE_INT(Inventory,AugOrnamentationType,524288) // Custom servers can override default value (slot 20/524288)
RULE_CATEGORY_END()
#undef RULE_CATEGORY