Merge plus some work on fixing stacking for merchants.

This commit is contained in:
KimLS
2015-03-15 14:02:13 -07:00
17 changed files with 425 additions and 178 deletions
+13 -7
View File
@@ -126,6 +126,14 @@ struct LDoNTrapTemplate
// All clients translate the character select information to some degree
struct Inventory_Slot_Struct
{
int16 type;
int16 slot;
int16 bag;
int16 aug;
};
struct Color_Struct
{
union {
@@ -1969,13 +1977,11 @@ Unknowns:
struct Merchant_Sell_Struct {
/*000*/ uint32 npcid; // Merchant NPC's entity id
/*004*/ uint32 playerid; // Player's entity id
/*008*/ uint32 itemslot;
uint32 unknown12;
/*016*/ uint8 quantity; // Already sold
/*017*/ uint8 Unknown016[3];
/*020*/ uint32 price;
uint32 npcid;
uint32 playerid;
uint32 itemslot;
int32 quantity;
uint32 price;
};
struct Merchant_Purchase_Struct {
/*000*/ uint32 npcid; // Merchant NPC's entity id
+37
View File
@@ -366,6 +366,43 @@ bool EQEmu::Inventory::Swap(const InventorySlot &src, const InventorySlot &dest,
return true;
}
bool EQEmu::Inventory::TryStacking(std::shared_ptr<EQEmu::ItemInstance> inst, const InventorySlot &slot) {
auto target_inst = Get(slot);
if(!inst || !target_inst ||
!inst->IsStackable() || !target_inst->IsStackable())
{
return false;
}
if(inst->GetBaseItem()->ID != target_inst->GetBaseItem()->ID) {
return false;
}
int stack_avail = target_inst->GetBaseItem()->StackSize - target_inst->GetCharges();
if(stack_avail <= 0) {
return false;
}
impl_->data_model_->Begin();
if(inst->GetCharges() <= stack_avail) {
inst->SetCharges(0);
target_inst->SetCharges(target_inst->GetCharges() + inst->GetCharges());
impl_->data_model_->Delete(slot);
impl_->data_model_->Insert(slot, target_inst);
} else {
inst->SetCharges(inst->GetCharges() - stack_avail);
target_inst->SetCharges(target_inst->GetCharges() + stack_avail);
impl_->data_model_->Delete(slot);
impl_->data_model_->Insert(slot, target_inst);
}
impl_->data_model_->Commit();
return true;
}
bool EQEmu::Inventory::Summon(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst) {
if(!inst)
return false;
+3
View File
@@ -135,9 +135,12 @@ namespace EQEmu
std::shared_ptr<ItemInstance> Get(const InventorySlot &slot);
bool Put(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst);
bool Swap(const InventorySlot &src, const InventorySlot &dest, int charges);
bool TryStacking(std::shared_ptr<EQEmu::ItemInstance> inst, const InventorySlot &slot);
bool Summon(const InventorySlot &slot, std::shared_ptr<ItemInstance> inst);
bool PushToCursorBuffer(std::shared_ptr<ItemInstance> inst);
bool PopFromCursorBuffer();
bool PutStackInInventory(std::shared_ptr<ItemInstance> inst, bool try_worn, bool try_cursor);
InventorySlot PutItemInInventory(std::shared_ptr<ItemInstance> inst, bool try_worn, bool try_cursor);
//utility
static int CalcMaterialFromSlot(const InventorySlot &slot);
+4 -4
View File
@@ -3062,13 +3062,13 @@ namespace RoF
{
ENCODE_LENGTH_EXACT(Merchant_Sell_Struct);
SETUP_DIRECT_ENCODE(Merchant_Sell_Struct, structs::Merchant_Sell_Struct);
OUT(npcid);
OUT(playerid);
OUT(itemslot);
OUT(quantity);
OUT(price);
FINISH_ENCODE();
}
@@ -4821,13 +4821,13 @@ namespace RoF
{
DECODE_LENGTH_EXACT(structs::Merchant_Sell_Struct);
SETUP_DIRECT_DECODE(Merchant_Sell_Struct, structs::Merchant_Sell_Struct);
IN(npcid);
IN(playerid);
IN(itemslot);
IN(quantity);
IN(price);
FINISH_DIRECT_DECODE();
}
+3
View File
@@ -133,6 +133,9 @@ RULE_INT ( Skills, MaxTrainTradeskills, 21 )
RULE_BOOL ( Skills, UseLimitTradeskillSearchSkillDiff, true )
RULE_INT ( Skills, MaxTradeskillSearchSkillDiff, 50 )
RULE_INT ( Skills, MaxTrainSpecializations, 50 ) // Max level a GM trainer will train casting specializations
RULE_INT ( Skills, SwimmingStartValue, 100 )
RULE_BOOL ( Skills, TrainSenseHeading, false )
RULE_INT ( Skills, SenseHeadingStartValue, 200 )
RULE_CATEGORY_END()
RULE_CATEGORY( Pets )
+3 -1
View File
@@ -256,7 +256,9 @@ bool SharedDatabase::UpdateSharedBankSlot(uint32 char_id, const ItemInst* inst,
// Save bag contents, if slot supports bag contents
if (inst->IsType(ItemClassContainer) && InventoryOld::SupportsContainers(slot_id)) {
for (uint8 idx = SUB_BEGIN; idx < EmuConstants::ITEM_CONTAINER_SIZE; idx++) {
// Limiting to bag slot count will get rid of 'hidden' duplicated items and 'Invalid Slot ID'
// messages through attrition (and the modded code in SaveInventory)
for (uint8 idx = SUB_BEGIN; idx < inst->GetItem()->BagSlots && idx < EmuConstants::ITEM_CONTAINER_SIZE; idx++) {
const ItemInst* baginst = inst->GetItem(idx);
SaveInventory(char_id, baginst, InventoryOld::CalcSlotId(slot_id, idx));
}