More numeric to constant conversions..should be most of them... Please report any inventory abnormalities.

This commit is contained in:
Uleat
2014-07-31 07:52:38 -04:00
parent e902373ce7
commit 8b14c21a24
41 changed files with 1402 additions and 1018 deletions
+4 -2
View File
@@ -912,7 +912,7 @@ void Mob::WakeTheDead(uint16 spell_id, Mob *target, uint32 duration)
//gear stuff, need to make sure there's
//no situation where this stuff can be duped
for(int x = 0; x < 21; x++)
for(int x = EmuConstants::EQUIPMENT_BEGIN; x <= EmuConstants::EQUIPMENT_END; x++) // (< 21) added MainAmmo
{
uint32 sitem = 0;
sitem = CorpseToUse->GetWornItem(x);
@@ -1318,6 +1318,8 @@ void Client::SendAA(uint32 id, int seq) {
//Prevent removal of previous AA from window if next AA belongs to a higher client version.
SendAA_Struct* saa_next = nullptr;
saa_next = zone->FindAA(saa->sof_next_id);
// hard-coding values like this is dangerous and makes adding/updating clients a nightmare...
if (saa_next &&
(((GetClientVersionBit() == 4) && (saa_next->clientver > 4))
|| ((GetClientVersionBit() == 8) && (saa_next->clientver > 5))
@@ -1895,7 +1897,7 @@ SendAA_Struct* ZoneDatabase::GetAASkillVars(uint32 skill_id)
row = mysql_fetch_row(result);
//ATOI IS NOT UNISGNED LONG-SAFE!!!
//ATOI IS NOT UNSIGNED LONG-SAFE!!!
sendaa->cost = atoul(row[0]);
sendaa->cost2 = sendaa->cost;
+1 -1
View File
@@ -544,7 +544,7 @@ bool Object::HandleClick(Client* sender, const ClickObject_Struct* click_object)
EQApplicationPacket* outapp=new EQApplicationPacket(OP_ClientReady,0);
sender->QueuePacket(outapp);
safe_delete(outapp);
for (uint8 i=0; i<10; i++) {
for (uint8 i = SUB_BEGIN; i < EmuConstants::ITEM_CONTAINER_SIZE; i++) {
const ItemInst* inst = m_inst->GetItem(i);
if (inst) {
//sender->GetInv().PutItem(i+4000,inst);
+5 -5
View File
@@ -1248,7 +1248,7 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b
if( Hand == MainPrimary && GetLevel() >= 28 && IsWarriorClass() )
{
// Damage bonuses apply only to hits from the main hand (Hand == 13) by characters level 28 and above
// Damage bonuses apply only to hits from the main hand (Hand == MainPrimary) by characters level 28 and above
// who belong to a melee class. If we're here, then all of these conditions apply.
ucDamageBonus = GetWeaponDamageBonus( weapon ? weapon->GetItem() : (const Item_Struct*) nullptr );
@@ -2629,7 +2629,7 @@ uint8 Mob::GetWeaponDamageBonus( const Item_Struct *Weapon )
// Assert: This function should only be called for hits by the mainhand, as damage bonuses apply only to the
// weapon in the primary slot. Be sure to check that Hand == 13 before calling.
// weapon in the primary slot. Be sure to check that Hand == MainPrimary before calling.
// Assert: The caller should ensure that Weapon is actually a weapon before calling this function.
// The ItemInst::IsWeapon() method can be used to quickly determine this.
@@ -3906,7 +3906,7 @@ void Mob::TryDefensiveProc(const ItemInst* weapon, Mob *on, uint16 hand) {
float ProcChance, ProcBonus;
on->GetDefensiveProcChances(ProcBonus, ProcChance, hand , this);
if(hand != 13)
if(hand != MainPrimary)
ProcChance /= 2;
if (bDefensiveProc){
@@ -3965,7 +3965,7 @@ void Mob::TryWeaponProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on
ProcBonus += static_cast<float>(itembonuses.ProcChance) / 10.0f; // Combat Effects
float ProcChance = GetProcChances(ProcBonus, hand);
if (hand != 13) //Is Archery intened to proc at 50% rate?
if (hand != MainPrimary) //Is Archery intened to proc at 50% rate?
ProcChance /= 2;
// Try innate proc on weapon
@@ -4632,7 +4632,7 @@ float Mob::GetSkillProcChances(uint16 ReuseTime, uint16 hand) {
ProcChance = static_cast<float>(weapon_speed) * (RuleR(Combat, AvgProcsPerMinute) / 60000.0f);
if (hand != 13)
if (hand != MainPrimary)
ProcChance /= 2;
}
+29 -19
View File
@@ -3049,26 +3049,28 @@ void NPC::CalcItemBonuses(StatBonuses *newbon)
}
}
void Client::CalcItemScale()
{
void Client::CalcItemScale() {
bool changed = false;
if(CalcItemScale(0, 21))
// MainAmmo excluded in helper function below
if(CalcItemScale(EmuConstants::EQUIPMENT_BEGIN, EmuConstants::EQUIPMENT_END)) // original coding excluded MainAmmo (< 21)
changed = true;
if(CalcItemScale(22, 30))
if(CalcItemScale(EmuConstants::GENERAL_BEGIN, EmuConstants::GENERAL_END)) // original coding excluded MainCursor (< 30)
changed = true;
if(CalcItemScale(251, 341))
// I excluded cursor bag slots here because cursor was excluded above..if this is incorrect, change 'slot_y' here to CURSOR_BAG_END
// and 'slot_y' above to CURSOR from GENERAL_END above - or however it is supposed to be...
if(CalcItemScale(EmuConstants::GENERAL_BAGS_BEGIN, EmuConstants::GENERAL_BAGS_END)) // (< 341)
changed = true;
if(CalcItemScale(400, 405))
if(CalcItemScale(EmuConstants::TRIBUTE_BEGIN, EmuConstants::TRIBUTE_END)) // (< 405)
changed = true;
//Power Source Slot
if (GetClientVersion() >= EQClientSoF)
{
if(CalcItemScale(9999, 10000))
if(CalcItemScale(MainPowerSource, MainPowerSource))
changed = true;
}
@@ -3078,13 +3080,15 @@ void Client::CalcItemScale()
}
}
bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y)
{
bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y) {
// behavior change: 'slot_y' is now [RANGE]_END and not [RANGE]_END + 1
bool changed = false;
int i;
for (i = slot_x; i < slot_y; i++) {
for (i = slot_x; i <= slot_y; i++) {
if (i == MainAmmo) // moved here from calling procedure to facilitate future range changes where MainAmmo may not be the last slot
continue;
ItemInst* inst = m_inv.GetItem(i);
if(inst == 0)
if(inst == nullptr)
continue;
bool update_slot = false;
@@ -3101,7 +3105,7 @@ bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y)
}
//iterate all augments
for (int x = 0; x < EmuConstants::ITEM_COMMON_SIZE; ++x)
for (int x = AUG_BEGIN; x < EmuConstants::ITEM_COMMON_SIZE; ++x)
{
ItemInst * a_inst = inst->GetAugment(x);
if(!a_inst)
@@ -3132,22 +3136,25 @@ bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y)
void Client::DoItemEnterZone() {
bool changed = false;
if(DoItemEnterZone(0, 21))
// MainAmmo excluded in helper function below
if(DoItemEnterZone(EmuConstants::EQUIPMENT_BEGIN, EmuConstants::EQUIPMENT_END)) // original coding excluded MainAmmo (< 21)
changed = true;
if(DoItemEnterZone(22, 30))
if(DoItemEnterZone(EmuConstants::GENERAL_BEGIN, EmuConstants::GENERAL_END)) // original coding excluded MainCursor (< 30)
changed = true;
if(DoItemEnterZone(251, 341))
// I excluded cursor bag slots here because cursor was excluded above..if this is incorrect, change 'slot_y' here to CURSOR_BAG_END
// and 'slot_y' above to CURSOR from GENERAL_END above - or however it is supposed to be...
if(DoItemEnterZone(EmuConstants::GENERAL_BAGS_BEGIN, EmuConstants::GENERAL_BAGS_END)) // (< 341)
changed = true;
if(DoItemEnterZone(400, 405))
if(DoItemEnterZone(EmuConstants::TRIBUTE_BEGIN, EmuConstants::TRIBUTE_END)) // (< 405)
changed = true;
//Power Source Slot
if (GetClientVersion() >= EQClientSoF)
{
if(DoItemEnterZone(9999, 10000))
if(DoItemEnterZone(MainPowerSource, MainPowerSource))
changed = true;
}
@@ -3158,8 +3165,11 @@ void Client::DoItemEnterZone() {
}
bool Client::DoItemEnterZone(uint32 slot_x, uint32 slot_y) {
// behavior change: 'slot_y' is now [RANGE]_END and not [RANGE]_END + 1
bool changed = false;
for(int i = slot_x; i < slot_y; i++) {
for(int i = slot_x; i <= slot_y; i++) {
if (i == MainAmmo) // moved here from calling procedure to facilitate future range changes where MainAmmo may not be the last slot
continue;
ItemInst* inst = m_inv.GetItem(i);
if(!inst)
continue;
@@ -3188,7 +3198,7 @@ bool Client::DoItemEnterZone(uint32 slot_x, uint32 slot_y) {
}
//iterate all augments
for (int x = 0; x < EmuConstants::ITEM_COMMON_SIZE; ++x)
for (int x = AUG_BEGIN; x < EmuConstants::ITEM_COMMON_SIZE; ++x)
{
ItemInst *a_inst = inst->GetAugment(x);
if(!a_inst)
+46 -46
View File
@@ -475,7 +475,7 @@ void Bot::GenerateBaseStats() {
int16 CorruptionResist = _baseCorrup;
switch(this->GetClass()) {
case 1: // Warrior
case 1: // Warrior (why not just use 'case WARRIOR:'?)
Strength += 10;
Stamina += 20;
Agility += 10;
@@ -3427,7 +3427,7 @@ void Bot::ApplySpecialAttackMod(SkillUseTypes skill, int32 &dmg, int32 &mindmg)
break;
}
if (item_slot >= 0){
if (item_slot >= EmuConstants::EQUIPMENT_BEGIN){
const ItemInst* inst = GetBotItem(item_slot);
const Item_Struct* botweapon = 0;
if(inst)
@@ -4332,7 +4332,7 @@ void Bot::Spawn(Client* botCharacterOwner, std::string* errorMessage) {
/* // fillspawnstruct now properly handles this -U
uint32 itemID = 0;
uint8 materialFromSlot = 0xFF;
for(int i=0; i<22; ++i) {
for(int i=EmuConstants::EQUIPMENT_BEGIN; i<=EmuConstants::EQUIPMENT_END; ++i) {
itemID = GetBotItemBySlot(i);
if(itemID != 0) {
materialFromSlot = Inventory::CalcMaterialFromSlot(i);
@@ -4348,11 +4348,11 @@ void Bot::Spawn(Client* botCharacterOwner, std::string* errorMessage) {
void Bot::SetBotItemInSlot(uint32 slotID, uint32 itemID, const ItemInst* inst, std::string *errorMessage) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
uint32 augslot[5] = { 0, 0, 0, 0, 0 };
uint32 augslot[EmuConstants::ITEM_COMMON_SIZE] = { NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM };
if(this->GetBotID() > 0 && slotID >= 0 && itemID > 0) {
if (this->GetBotID() > 0 && slotID >= EmuConstants::EQUIPMENT_BEGIN && itemID > NO_ITEM) {
if (inst && inst->IsType(ItemClassCommon)) {
for(int i=0; i<5; ++i) {
for(int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; ++i) {
ItemInst* auginst = inst->GetItem(i);
augslot[i] = (auginst && auginst->GetItem()) ? auginst->GetItem()->ID : 0;
}
@@ -4401,7 +4401,7 @@ void Bot::GetBotItems(std::string* errorMessage, Inventory &inv) {
uint32 item_id = atoi(DataRow[1]);
uint16 charges = atoi(DataRow[2]);
uint32 color = atoul(DataRow[3]);
uint32 aug[5];
uint32 aug[EmuConstants::ITEM_COMMON_SIZE];
aug[0] = (uint32)atoul(DataRow[4]);
aug[1] = (uint32)atoul(DataRow[5]);
aug[2] = (uint32)atoul(DataRow[6]);
@@ -4412,7 +4412,7 @@ void Bot::GetBotItems(std::string* errorMessage, Inventory &inv) {
ItemInst* inst = database.CreateItem(item_id, charges, aug[0], aug[1], aug[2], aug[3], aug[4]);
if(inst) {
int16 put_slot_id = INVALID_INDEX;
if(instnodrop || ((slot_id >= 0) && (slot_id <= 21) && inst->GetItem()->Attuneable))
if(instnodrop || ((slot_id >= EmuConstants::EQUIPMENT_BEGIN) && (slot_id <= EmuConstants::EQUIPMENT_END) && inst->GetItem()->Attuneable))
inst->SetInstNoDrop(true);
if(color > 0)
inst->SetColor(color);
@@ -4454,7 +4454,7 @@ void Bot::GetBotItems(std::string* errorMessage, Inventory &inv) {
uint32 Bot::GetBotItemBySlot(uint32 slotID) {
uint32 Result = 0;
if(this->GetBotID() > 0 && slotID >= 0) {
if(this->GetBotID() > 0 && slotID >= EmuConstants::EQUIPMENT_BEGIN) {
char* query = 0;
MYSQL_RES* DatasetResult;
MYSQL_ROW DataRow;
@@ -5298,7 +5298,7 @@ void Bot::LevelBotWithClient(Client* client, uint8 level, bool sendlvlapp) {
Bot* bot = *biter;
if(bot && (bot->GetLevel() != client->GetLevel())) {
bot->SetPetChooser(false); // not sure what this does, but was in bot 'update' code
bot->CalcBotStats(false);
bot->CalcBotStats(false); // TODO: look at this and see if 'true' should be passed...
if(sendlvlapp)
bot->SendLevelAppearance();
// modified from Client::SetLevel()
@@ -5456,7 +5456,7 @@ void Bot::BotAddEquipItem(int slot, uint32 id) {
if(slot > 0 && id > 0) {
uint8 materialFromSlot = Inventory::CalcMaterialFromSlot(slot);
if(materialFromSlot != 0xFF) {
if(materialFromSlot != _MaterialInvalid) {
equipment[slot] = id; // npc has more than just material slots. Valid material should mean valid inventory index
SendWearChange(materialFromSlot);
}
@@ -5468,7 +5468,7 @@ void Bot::BotRemoveEquipItem(int slot) {
if(slot > 0) {
uint8 materialFromSlot = Inventory::CalcMaterialFromSlot(slot);
if(materialFromSlot != 0xFF) {
if(materialFromSlot != _MaterialInvalid) {
equipment[slot] = 0; // npc has more than just material slots. Valid material should mean valid inventory index
SendWearChange(materialFromSlot);
if(materialFromSlot == MaterialChest)
@@ -6006,8 +6006,8 @@ void Bot::FinishTrade(Client* client, BotTradeType tradeType) {
if(client && !client->GetTradeskillObject() && (client->trade->state != Trading)) {
if(tradeType == BotTradeClientNormal) {
// Items being traded are found in the normal trade window used to trade between a Client and a Client or NPC
// Items in this mode are found in slot ids 3000 thru 3003
PerformTradeWithClient(3000, 3007, client);
// Items in this mode are found in slot ids 3000 thru 3003 - thought bots used the full 8-slot window..?
PerformTradeWithClient(EmuConstants::TRADE_BEGIN, EmuConstants::TRADE_END, client); // {3000..3007}
}
else if(tradeType == BotTradeClientNoDropNoTrade) {
// Items being traded are found on the Client's cursor slot, slot id 30. This item can be either a single item or it can be a bag.
@@ -6024,7 +6024,7 @@ void Bot::FinishTrade(Client* client, BotTradeType tradeType) {
void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* client) {
if(client) {
// TODO: Figure out what the actual max slot id is
const int MAX_SLOT_ID = 3179;
const int MAX_SLOT_ID = EmuConstants::TRADE_BAGS_END; // was the old incorrect 3179..
uint32 items[MAX_SLOT_ID] = {0};
uint8 charges[MAX_SLOT_ID] = {0};
bool botCanWear[MAX_SLOT_ID] = {0};
@@ -6049,7 +6049,7 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli
std::string TempErrorMessage;
const Item_Struct* mWeaponItem = inst->GetItem();
bool failedLoreCheck = false;
for (int m = 0; m<EmuConstants::ITEM_COMMON_SIZE; ++m) {
for (int m = AUG_BEGIN; m <EmuConstants::ITEM_COMMON_SIZE; ++m) {
ItemInst *itm = inst->GetAugment(m);
if(itm)
{
@@ -6069,12 +6069,12 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli
botCanWear[i] = BotCanWear;
ItemInst* swap_item = nullptr;
const char* equipped[22] = {"Charm", "Left Ear", "Head", "Face", "Right Ear", "Neck", "Shoulders", "Arms", "Back",
const char* equipped[EmuConstants::EQUIPMENT_SIZE] = {"Charm", "Left Ear", "Head", "Face", "Right Ear", "Neck", "Shoulders", "Arms", "Back",
"Left Wrist", "Right Wrist", "Range", "Hands", "Primary Hand", "Secondary Hand",
"Left Finger", "Right Finger", "Chest", "Legs", "Feet", "Waist", "Ammo" };
bool success = false;
int how_many_slots = 0;
for(int j=0; j<22; ++j) {
for(int j = EmuConstants::EQUIPMENT_BEGIN; j <= EmuConstants::EQUIPMENT_END; ++j) {
if((mWeaponItem->Slots & (1 << j))) {
how_many_slots++;
if(!GetBotItem(j)) {
@@ -6132,11 +6132,11 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli
}
}
if(!success) {
for(int j=0; j<22; ++j) {
for(int j = EmuConstants::EQUIPMENT_BEGIN; j <= EmuConstants::EQUIPMENT_END; ++j) {
if((mWeaponItem->Slots & (1 << j))) {
swap_item = GetBotItem(j);
failedLoreCheck = false;
for (int k = 0; k<EmuConstants::ITEM_COMMON_SIZE; ++k) {
for (int k = AUG_BEGIN; k < EmuConstants::ITEM_COMMON_SIZE; ++k) {
ItemInst *itm = swap_item->GetAugment(k);
if(itm)
{
@@ -6518,7 +6518,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b
if( Hand == MainPrimary && GetLevel() >= 28 && IsWarriorClass() )
{
// Damage bonuses apply only to hits from the main hand (Hand == 13) by characters level 28 and above
// Damage bonuses apply only to hits from the main hand (Hand == MainPrimary) by characters level 28 and above
// who belong to a melee class. If we're here, then all of these conditions apply.
ucDamageBonus = GetWeaponDamageBonus( weapon ? weapon->GetItem() : (const Item_Struct*) nullptr );
@@ -7129,7 +7129,7 @@ int16 Bot::GetBotFocusEffect(BotfocusType bottype, uint16 spell_id) {
int16 focus_max_real = 0;
//item focus
for(int x=0; x<=21; x++)
for(int x = EmuConstants::EQUIPMENT_BEGIN; x <= EmuConstants::EQUIPMENT_END; x++)
{
TempItem = nullptr;
ItemInst* ins = GetBotItem(x);
@@ -7163,7 +7163,7 @@ int16 Bot::GetBotFocusEffect(BotfocusType bottype, uint16 spell_id) {
}
}
for (int y = 0; y < EmuConstants::ITEM_COMMON_SIZE; ++y)
for (int y = AUG_BEGIN; y < EmuConstants::ITEM_COMMON_SIZE; ++y)
{
ItemInst *aug = nullptr;
aug = ins->GetAugment(y);
@@ -8213,7 +8213,7 @@ void Bot::RogueBackstab(Mob* other, bool min_damage, int ReuseTime)
if(botweaponInst) {
primaryweapondamage = GetWeaponDamage(other, botweaponInst);
backstab_dmg = botweaponInst->GetItem()->BackstabDmg;
for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; ++i)
for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; ++i)
{
ItemInst *aug = botweaponInst->GetAugment(i);
if(aug)
@@ -8770,7 +8770,7 @@ void Bot::EquipBot(std::string* errorMessage) {
const ItemInst* inst = 0;
const Item_Struct* item = 0;
for(int i=0; i<=21; ++i) {
for(int i = EmuConstants::EQUIPMENT_BEGIN; i <= EmuConstants::EQUIPMENT_END; ++i) {
inst = GetBotItem(i);
if(inst) {
item = inst->GetItem();
@@ -11260,7 +11260,7 @@ void Bot::ProcessBotInspectionRequest(Bot* inspectedBot, Client* client) {
// Modded to display power source items (will only show up on SoF+ client inspect windows though.)
// I don't think bots are currently coded to use them..but, you'll have to use '#bot inventory list'
// to see them on a Titanium client when/if they are activated. -U
for(int16 L = 0; L <= 20; L++) {
for(int16 L = EmuConstants::EQUIPMENT_BEGIN; L <= MainWaist; L++) {
inst = inspectedBot->GetBotItem(L);
if(inst) {
@@ -11274,28 +11274,28 @@ void Bot::ProcessBotInspectionRequest(Bot* inspectedBot, Client* client) {
}
}
inst = inspectedBot->GetBotItem(9999);
inst = inspectedBot->GetBotItem(MainPowerSource);
if(inst) {
item = inst->GetItem();
if(item) {
strcpy(insr->itemnames[21], item->Name);
insr->itemicons[21] = item->Icon;
strcpy(insr->itemnames[SoF::slots::MainPowerSource], item->Name);
insr->itemicons[SoF::slots::MainPowerSource] = item->Icon;
}
else
insr->itemicons[21] = 0xFFFFFFFF;
insr->itemicons[SoF::slots::MainPowerSource] = 0xFFFFFFFF;
}
inst = inspectedBot->GetBotItem(21);
inst = inspectedBot->GetBotItem(MainAmmo);
if(inst) {
item = inst->GetItem();
if(item) {
strcpy(insr->itemnames[22], item->Name);
insr->itemicons[22] = item->Icon;
strcpy(insr->itemnames[SoF::slots::MainAmmo], item->Name);
insr->itemicons[SoF::slots::MainAmmo] = item->Icon;
}
else
insr->itemicons[22] = 0xFFFFFFFF;
insr->itemicons[SoF::slots::MainAmmo] = 0xFFFFFFFF;
}
strcpy(insr->text, inspectedBot->GetInspectMessage().text);
@@ -11309,10 +11309,10 @@ void Bot::CalcItemBonuses()
memset(&itembonuses, 0, sizeof(StatBonuses));
const Item_Struct* itemtmp = 0;
for(int i=0; i<=21; ++i) {
for (int i = EmuConstants::EQUIPMENT_BEGIN; i <= EmuConstants::EQUIPMENT_END; ++i) {
const ItemInst* item = GetBotItem(i);
if(item) {
for(int j=0; j<=4; ++j) {
for(int j = AUG_BEGIN; j < EmuConstants::ITEM_COMMON_SIZE; ++j) {
const ItemInst* aug = item->GetAugment(j);
if(aug) {
itemtmp = aug->GetItem();
@@ -11739,7 +11739,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) {
if(!strcasecmp(sep->arg[1], "augmentitem")) {
AugmentItem_Struct* in_augment = new AugmentItem_Struct[sizeof(AugmentItem_Struct)];
in_augment->container_slot = 1000;
in_augment->container_slot = 1000; // <watch>
in_augment->unknown02[0] = 0;
in_augment->unknown02[1] = 0;
in_augment->augment_slot = -1;
@@ -12155,13 +12155,13 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) {
return;
}
const char* equipped[22] = {"Charm", "Left Ear", "Head", "Face", "Right Ear", "Neck", "Shoulders", "Arms", "Back",
const char* equipped[EmuConstants::EQUIPMENT_SIZE] = {"Charm", "Left Ear", "Head", "Face", "Right Ear", "Neck", "Shoulders", "Arms", "Back",
"Left Wrist", "Right Wrist", "Range", "Hands", "Primary Hand", "Secondary Hand",
"Left Finger", "Right Finger", "Chest", "Legs", "Feet", "Waist", "Ammo" };
const ItemInst* item1 = nullptr;
const Item_Struct* item2 = nullptr;
bool is2Hweapon = false;
for(int i=0; i<22; ++i)
for(int i = EmuConstants::EQUIPMENT_BEGIN; i <= EmuConstants::EQUIPMENT_END; ++i)
{
if((i == MainSecondary) && is2Hweapon) {
continue;
@@ -12282,11 +12282,11 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) {
return;
int slotId = atoi(sep->arg[3]);
if(slotId > 21 || slotId < 0) {
if(slotId > EmuConstants::EQUIPMENT_END || slotId < EmuConstants::EQUIPMENT_BEGIN) {
c->Message(15, "A bot has 21 slots in its inventory, please choose a slot between 0 and 21.");
return;
}
const char* equipped[22] = {"Charm", "Left Ear", "Head", "Face", "Right Ear", "Neck", "Shoulders", "Arms", "Back",
const char* equipped[EmuConstants::EQUIPMENT_SIZE] = {"Charm", "Left Ear", "Head", "Face", "Right Ear", "Neck", "Shoulders", "Arms", "Back",
"Left Wrist", "Right Wrist", "Range", "Hands", "Primary Hand", "Secondary Hand",
"Left Finger", "Right Finger", "Chest", "Legs", "Feet", "Waist", "Ammo" };
@@ -12303,7 +12303,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) {
// Don't allow the player to remove a lore item they already possess and cause a crash
bool failedLoreCheck = false;
if(itminst) {
for (int m = 0; m<EmuConstants::ITEM_COMMON_SIZE; ++m) {
for (int m = AUG_BEGIN; m < EmuConstants::ITEM_COMMON_SIZE; ++m) {
ItemInst *itma = itminst->GetAugment(m);
if(itma)
{
@@ -14259,10 +14259,10 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) {
Mob *target = c->GetTarget();
if(target && target->IsBot()) {
for(int i=0; i<9; i++) {
for(int i = EmuConstants::MATERIAL_BEGIN; i <= EmuConstants::MATERIAL_END; i++) {
c->Message(15,"Equiped slot: %i , item: %i \n", i, target->CastToBot()->GetEquipment(i));
}
if(target->CastToBot()->GetEquipment(8) > 0)
if(target->CastToBot()->GetEquipment(MaterialSecondary) > 0)
c->Message(15,"This bot has an item in off-hand.");
}
return;
@@ -16512,7 +16512,7 @@ int Bot::GetRawACNoShield(int &shield_ac)
{
ac -= inst->GetItem()->AC;
shield_ac = inst->GetItem()->AC;
for (uint8 i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++)
for (uint8 i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++)
{
if(inst->GetAugment(i))
{
@@ -16531,7 +16531,7 @@ uint32 Bot::CalcCurrentWeight() {
ItemInst* inst;
uint32 Total = 0;
for(int i=0; i<=21; ++i) {
for(int i = EmuConstants::EQUIPMENT_BEGIN; i <= EmuConstants::EQUIPMENT_END; ++i) {
inst = GetBotItem(i);
if(inst) {
TempItem = inst->GetItem();
+4 -4
View File
@@ -5333,7 +5333,7 @@ bool Client::TryReward(uint32 claim_id)
//save
uint32 free_slot = 0xFFFFFFFF;
for(int i = 22; i < 30; ++i)
for(int i = EmuConstants::GENERAL_BEGIN; i <= EmuConstants::GENERAL_END; ++i)
{
ItemInst *item = GetInv().GetItem(i);
if(!item)
@@ -7836,7 +7836,7 @@ void Client::TickItemCheck()
TryItemTick(i);
}
//Scan main inventory + cursor
for(i = EmuConstants::GENERAL_BEGIN; i <= EmuConstants::CURSOR; i++)
for(i = EmuConstants::GENERAL_BEGIN; i <= MainCursor; i++)
{
TryItemTick(i);
}
@@ -7857,7 +7857,7 @@ void Client::TryItemTick(int slot)
if(zone->tick_items.count(iid) > 0)
{
if( GetLevel() >= zone->tick_items[iid].level && MakeRandomInt(0, 100) >= (100 - zone->tick_items[iid].chance) && (zone->tick_items[iid].bagslot || slot < 22) )
if( GetLevel() >= zone->tick_items[iid].level && MakeRandomInt(0, 100) >= (100 - zone->tick_items[iid].chance) && (zone->tick_items[iid].bagslot || slot <= EmuConstants::EQUIPMENT_END) )
{
ItemInst* e_inst = (ItemInst*)inst;
parse->EventItem(EVENT_ITEM_TICK, this, e_inst, nullptr, "", slot);
@@ -7893,7 +7893,7 @@ void Client::ItemTimerCheck()
TryItemTimer(i);
}
for(i = EmuConstants::GENERAL_BAGS_BEGIN; i <= EmuConstants::CURSOR; i++)
for(i = EmuConstants::GENERAL_BAGS_BEGIN; i <= MainCursor; i++)
{
TryItemTimer(i);
}
+2 -2
View File
@@ -1043,9 +1043,9 @@ public:
void MarkSingleCompassLoc(float in_x, float in_y, float in_z, uint8 count=1);
void CalcItemScale();
bool CalcItemScale(uint32 slot_x, uint32 slot_y);
bool CalcItemScale(uint32 slot_x, uint32 slot_y); // behavior change: 'slot_y' is now [RANGE]_END and not [RANGE]_END + 1
void DoItemEnterZone();
bool DoItemEnterZone(uint32 slot_x, uint32 slot_y);
bool DoItemEnterZone(uint32 slot_x, uint32 slot_y); // behavior change: 'slot_y' is now [RANGE]_END and not [RANGE]_END + 1
void SummonAndRezzAllCorpses();
void SummonAllCorpses(float dest_x, float dest_y, float dest_z, float dest_heading);
void DepopAllCorpses();
+6 -5
View File
@@ -449,7 +449,8 @@ uint32 Client::GetClassHPFactor() {
int16 Client::GetRawItemAC() {
int16 Total = 0;
for (int16 slot_id=0; slot_id<21; slot_id++) {
// this skips MainAmmo..add an '=' conditional if that slot is required (original behavior)
for (int16 slot_id = EmuConstants::EQUIPMENT_BEGIN; slot_id < EmuConstants::EQUIPMENT_END; slot_id++) {
const ItemInst* inst = m_inv[slot_id];
if (inst && inst->IsType(ItemClassCommon)) {
Total += inst->GetItem()->AC;
@@ -1127,7 +1128,7 @@ uint32 Client::CalcCurrentWeight() {
ItemInst* ins;
uint32 Total = 0;
int x;
for(x = EmuConstants::EQUIPMENT_BEGIN; x <= EmuConstants::CURSOR; x++) // include cursor or not?
for(x = EmuConstants::EQUIPMENT_BEGIN; x <= MainCursor; x++) // include cursor or not?
{
TempItem = 0;
ins = GetInv().GetItem(x);
@@ -1147,11 +1148,11 @@ uint32 Client::CalcCurrentWeight() {
TmpWeight = TempItem->Weight;
if (TmpWeight > 0)
{
// this code indicates that weight redux bags canonly be in the first general inventory slot to be effective...
// this code indicates that weight redux bags can only be in the first general inventory slot to be effective...
// is this correct? or can we scan for the highest weight redux and use that? (need client verifications)
int bagslot = MainGeneral1;
int reduction = 0;
for (int m = MainGeneral2; m <= EmuConstants::GENERAL_BAGS_END; m += 10) // include cursor bags or not?
for (int m = EmuConstants::GENERAL_BAGS_BEGIN + 10; m <= EmuConstants::GENERAL_BAGS_END; m += 10) // include cursor bags or not?
{
if (x >= m)
bagslot += 1;
@@ -1977,7 +1978,7 @@ int Client::GetRawACNoShield(int &shield_ac) const
{
ac -= inst->GetItem()->AC;
shield_ac = inst->GetItem()->AC;
for (uint8 i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++)
for (uint8 i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++)
{
if(inst->GetAugment(i))
{
+5 -5
View File
@@ -4520,7 +4520,7 @@ void Client::Handle_OP_CastSpell(const EQApplicationPacket *app)
}
return;
}
else if ((castspell->inventoryslot < 30) || (castspell->slot == POTION_BELT_SPELL_SLOT)) // sanity check
else if ((castspell->inventoryslot <= EmuConstants::GENERAL_END) || (castspell->slot == POTION_BELT_SPELL_SLOT)) // sanity check
{
const ItemInst* inst = m_inv[castspell->inventoryslot]; //slot values are int16, need to check packet on this field
//bool cancast = true;
@@ -4585,7 +4585,7 @@ void Client::Handle_OP_CastSpell(const EQApplicationPacket *app)
}
else
{
Message(0, "Error: castspell->inventoryslot >= 30 (0x%04x)", castspell->inventoryslot);
Message(0, "Error: castspell->inventoryslot >= %i (0x%04x)", MainCursor, castspell->inventoryslot);
InterruptSpell(castspell->spell_id);
}
}
@@ -4886,7 +4886,7 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app)
uint16 trade_count = 0;
// Item trade count for packet sizing
for(int16 slot_id=3000; slot_id<=3007; slot_id++) {
for(int16 slot_id = EmuConstants::TRADE_BEGIN; slot_id <= EmuConstants::TRADE_END; slot_id++) {
if(other->GetInv().GetItem(slot_id)) { trade_count += other->GetInv().GetItem(slot_id)->GetTotalItemCount(); }
if(m_inv[slot_id]) { trade_count += m_inv[slot_id]->GetTotalItemCount(); }
}
@@ -4926,7 +4926,7 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app)
if(RuleB(QueryServ, PlayerLogHandins)) {
uint16 handin_count = 0;
for(int16 slot_id=3000; slot_id<=3003; slot_id++) {
for(int16 slot_id = EmuConstants::TRADE_BEGIN; slot_id <= EmuConstants::TRADE_NPC_END; slot_id++) {
if(m_inv[slot_id]) { handin_count += m_inv[slot_id]->GetTotalItemCount(); }
}
@@ -6781,7 +6781,7 @@ void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app) {
Mob* tmp = entity_list.GetMob(insr->TargetID);
const Item_Struct* item = nullptr;
for (int16 L = 0; L <= 20; L++) {
for (int16 L = EmuConstants::EQUIPMENT_BEGIN; L <= MainWaist; L++) {
const ItemInst* inst = GetInv().GetItem(L);
item = inst ? inst->GetItem() : nullptr;
+8 -9
View File
@@ -816,12 +816,11 @@ void Client::OnDisconnect(bool hard_disconnect) {
//#ifdef ITEMCOMBINED
void Client::BulkSendInventoryItems() {
// For future reference: Only the parent item needs to be sent..the ItemInst already contains child ItemInst information
int16 slot_id = 0;
// LINKDEAD TRADE ITEMS
// Move trade slot items back into normal inventory..need them there now for the proceeding validity checks -U
for(slot_id = 3000; slot_id <= 3007; slot_id++) {
for(slot_id = EmuConstants::TRADE_BEGIN; slot_id <= EmuConstants::TRADE_END; slot_id++) {
ItemInst* inst = m_inv.PopItem(slot_id);
if(inst) {
bool is_arrow = (inst->GetItem()->ItemType == ItemTypeArrow) ? true : false;
@@ -867,7 +866,7 @@ void Client::BulkSendInventoryItems() {
std::map<uint16, std::string>::iterator itr;
//Inventory items
for(slot_id = 0; slot_id <= 30; slot_id++) {
for(slot_id = MAP_BEGIN; slot_id < EmuConstants::MAP_POSSESSIONS_SIZE; slot_id++) {
const ItemInst* inst = m_inv[slot_id];
if(inst) {
std::string packet = inst->Serialize(slot_id);
@@ -887,7 +886,7 @@ void Client::BulkSendInventoryItems() {
}
// Bank items
for(slot_id = 2000; slot_id <= 2023; slot_id++) {
for(slot_id = EmuConstants::BANK_BEGIN; slot_id <= EmuConstants::BANK_END; slot_id++) {
const ItemInst* inst = m_inv[slot_id];
if(inst) {
std::string packet = inst->Serialize(slot_id);
@@ -897,7 +896,7 @@ void Client::BulkSendInventoryItems() {
}
// Shared Bank items
for(slot_id = 2500; slot_id <= 2501; slot_id++) {
for(slot_id = EmuConstants::SHARED_BANK_BEGIN; slot_id <= EmuConstants::SHARED_BANK_END; slot_id++) {
const ItemInst* inst = m_inv[slot_id];
if(inst) {
std::string packet = inst->Serialize(slot_id);
@@ -928,14 +927,14 @@ void Client::BulkSendInventoryItems()
if(deletenorent){//client was offline for more than 30 minutes, delete no rent items
RemoveNoRent();
}
for (slot_id=0; slot_id<=30; slot_id++) {
for (slot_id=EmuConstants::POSSESSIONS_BEGIN; slot_id<=EmuConstants::POSSESSIONS_END; slot_id++) {
const ItemInst* inst = m_inv[slot_id];
if (inst){
SendItemPacket(slot_id, inst, ItemPacketCharInventory);
}
}
// Bank items
for (slot_id=2000; slot_id<=2015; slot_id++) {
for (slot_id=EmuConstants::BANK_BEGIN; slot_id<=EmuConstants::BANK_END; slot_id++) { // 2015...
const ItemInst* inst = m_inv[slot_id];
if (inst){
SendItemPacket(slot_id, inst, ItemPacketCharInventory);
@@ -943,7 +942,7 @@ void Client::BulkSendInventoryItems()
}
// Shared Bank items
for (slot_id=2500; slot_id<=2501; slot_id++) {
for (slot_id=EmuConstants::SHARED_BANK_BEGIN; slot_id<=EmuConstants::SHARED_BANK_END; slot_id++) {
const ItemInst* inst = m_inv[slot_id];
if (inst){
SendItemPacket(slot_id, inst, ItemPacketCharInventory);
@@ -953,7 +952,7 @@ void Client::BulkSendInventoryItems()
// LINKDEAD TRADE ITEMS
// If player went LD during a trade, they have items in the trade inventory
// slots. These items are now being put into their inventory (then queue up on cursor)
for (int16 trade_slot_id=3000; trade_slot_id<=3007; trade_slot_id++) {
for (int16 trade_slot_id=EmuConstants::TRADE_BEGIN; trade_slot_id<=EmuConstants::TRADE_END; trade_slot_id++) {
const ItemInst* inst = m_inv[slot_id];
if (inst) {
int16 free_slot_id = m_inv.FindFreeSlot(inst->IsType(ItemClassContainer), true, inst->GetItem()->Size);
+21 -15
View File
@@ -2704,14 +2704,14 @@ void command_texture(Client *c, const Seperator *sep)
// Player Races Wear Armor, so Wearchange is sent instead
int i;
if (!c->GetTarget())
for (i = 0; i < 7; i++)
for (i = EmuConstants::MATERIAL_BEGIN; i <= EmuConstants::MATERIAL_TINT_END; i++)
{
c->SendTextureWC(i, texture);
}
else if ((c->GetTarget()->GetRace() > 0 && c->GetTarget()->GetRace() <= 12) ||
c->GetTarget()->GetRace() == 128 || c->GetTarget()->GetRace() == 130 ||
c->GetTarget()->GetRace() == 330 || c->GetTarget()->GetRace() == 522) {
for (i = 0; i < 7; i++)
for (i = EmuConstants::MATERIAL_BEGIN; i <= EmuConstants::MATERIAL_TINT_END; i++)
{
c->GetTarget()->SendTextureWC(i, texture);
}
@@ -2892,11 +2892,12 @@ void command_peekinv(Client *c, const Seperator *sep)
if (bAll || (strcasecmp(sep->arg[1], "worn")==0)) {
// Worn items
bFound = true;
for (int16 i=0; i<=21; i++) {
for (int16 i = EmuConstants::EQUIPMENT_BEGIN; i <= EmuConstants::EQUIPMENT_END; i++) {
const ItemInst* inst = client->GetInv().GetItem(i);
item = (inst) ? inst->GetItem() : nullptr;
if (c->GetClientVersion() >= EQClientSoF)
{
// this kind of stuff needs to be pushed to the client translators
c->Message((item==0), "WornSlot: %i, Item: %i (%c%06X00000000000000000000000000000000000000000000%s%c), Charges: %i", i,
((item==0)?0:item->ID),0x12, ((item==0)?0:item->ID),
((item==0)?"null":item->Name), 0x12,
@@ -2914,7 +2915,7 @@ void command_peekinv(Client *c, const Seperator *sep)
if (bAll || (strcasecmp(sep->arg[1], "inv")==0)) {
// Personal inventory items
bFound = true;
for (int16 i=22; i<=29; i++) {
for (int16 i = EmuConstants::GENERAL_BEGIN; i <= EmuConstants::GENERAL_END; i++) {
const ItemInst* inst = client->GetInv().GetItem(i);
item = (inst) ? inst->GetItem() : nullptr;
if (c->GetClientVersion() >= EQClientSoF)
@@ -2933,7 +2934,7 @@ void command_peekinv(Client *c, const Seperator *sep)
}
if (inst && inst->IsType(ItemClassContainer)) {
for (uint8 j=0; j<10; j++) {
for (uint8 j = SUB_BEGIN; j < EmuConstants::ITEM_CONTAINER_SIZE; j++) {
const ItemInst* instbag = client->GetInv().GetItem(i, j);
item = (instbag) ? instbag->GetItem() : nullptr;
if (c->GetClientVersion() >= EQClientSoF)
@@ -3006,7 +3007,7 @@ void command_peekinv(Client *c, const Seperator *sep)
}
if (inst && inst->IsType(ItemClassContainer) && i==0) { // 'CSD 1' - only display contents of slot 30[0] container..higher ones don't exist
for (uint8 j=0; j<10; j++) {
for (uint8 j = SUB_BEGIN; j < EmuConstants::ITEM_CONTAINER_SIZE; j++) {
const ItemInst* instbag = client->GetInv().GetItem(MainCursor, j);
item = (instbag) ? instbag->GetItem() : nullptr;
if (c->GetClientVersion() >= EQClientSoF)
@@ -3058,7 +3059,7 @@ void command_peekinv(Client *c, const Seperator *sep)
// Bank and shared bank items
bFound = true;
int16 i = 0;
for (i=2000; i<=2023; i++) {
for (i = EmuConstants::BANK_BEGIN; i <= EmuConstants::BANK_END; i++) {
const ItemInst* inst = client->GetInv().GetItem(i);
item = (inst) ? inst->GetItem() : nullptr;
if (c->GetClientVersion() >= EQClientSoF)
@@ -3077,7 +3078,7 @@ void command_peekinv(Client *c, const Seperator *sep)
}
if (inst && inst->IsType(ItemClassContainer)) {
for (uint8 j=0; j<10; j++) {
for (uint8 j = SUB_BEGIN; j < EmuConstants::ITEM_CONTAINER_SIZE; j++) {
const ItemInst* instbag = client->GetInv().GetItem(i, j);
item = (instbag) ? instbag->GetItem() : nullptr;
if (c->GetClientVersion() >= EQClientSoF)
@@ -3099,7 +3100,7 @@ void command_peekinv(Client *c, const Seperator *sep)
}
}
}
for (i=2500; i<=2501; i++) {
for (i = EmuConstants::SHARED_BANK_BEGIN; i <= EmuConstants::SHARED_BANK_END; i++) {
const ItemInst* inst = client->GetInv().GetItem(i);
item = (inst) ? inst->GetItem() : nullptr;
if (c->GetClientVersion() >= EQClientSoF)
@@ -3118,7 +3119,7 @@ void command_peekinv(Client *c, const Seperator *sep)
}
if (inst && inst->IsType(ItemClassContainer)) {
for (uint8 j=0; j<10; j++) {
for (uint8 j = SUB_BEGIN; j < EmuConstants::ITEM_CONTAINER_SIZE; j++) {
const ItemInst* instbag = client->GetInv().GetItem(i, j);
item = (instbag) ? instbag->GetItem() : nullptr;
if (c->GetClientVersion() >= EQClientSoF)
@@ -3144,7 +3145,7 @@ void command_peekinv(Client *c, const Seperator *sep)
if (bAll || (strcasecmp(sep->arg[1], "trade")==0)) {
// Items in trade window (current trader only, not the other trader)
bFound = true;
for (int16 i=3000; i<=3007; i++) {
for (int16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++) {
const ItemInst* inst = client->GetInv().GetItem(i);
item = (inst) ? inst->GetItem() : nullptr;
if (c->GetClientVersion() >= EQClientSoF)
@@ -3163,7 +3164,7 @@ void command_peekinv(Client *c, const Seperator *sep)
}
if (inst && inst->IsType(ItemClassContainer)) {
for (uint8 j=0; j<10; j++) {
for (uint8 j = SUB_BEGIN; j < EmuConstants::ITEM_CONTAINER_SIZE; j++) {
const ItemInst* instbag = client->GetInv().GetItem(i, j);
item = (instbag) ? instbag->GetItem() : nullptr;
if (c->GetClientVersion() >= EQClientSoF)
@@ -3532,7 +3533,7 @@ void command_listpetition(Client *c, const Seperator *sep)
void command_equipitem(Client *c, const Seperator *sep)
{
uint32 slot_id = atoi(sep->arg[1]);
if (sep->IsNumber(1) && (slot_id>=0) && (slot_id<=21)) {
if (sep->IsNumber(1) && ((slot_id >= EmuConstants::EQUIPMENT_BEGIN) && (slot_id <= EmuConstants::EQUIPMENT_END) || (slot_id == MainPowerSource))) {
const ItemInst* from_inst = c->GetInv().GetItem(MainCursor);
const ItemInst* to_inst = c->GetInv().GetItem(slot_id); // added (desync issue when forcing stack to stack)
bool partialmove = false;
@@ -3568,6 +3569,8 @@ void command_equipitem(Client *c, const Seperator *sep)
else if(c->SwapItem(mi)) {
c->FastQueuePacket(&outapp);
// if the below code is still needed..just send an an item trade packet to each slot..it should overwrite the client instance
// below code has proper logic, but client does not like to have cursor charges changed
// (we could delete the cursor item and resend, but issues would arise if there are queued items)
//if (partialmove) {
@@ -7776,16 +7779,19 @@ void command_path(Client *c, const Seperator *sep)
}
void Client::Undye() {
for (int cur_slot = 0; cur_slot < 9 ; cur_slot++ ){
for (int cur_slot = EmuConstants::MATERIAL_BEGIN; cur_slot <= EmuConstants::MATERIAL_END; cur_slot++ ) {
uint8 slot2=SlotConvert(cur_slot);
ItemInst* inst = m_inv.GetItem(slot2);
if(inst != nullptr) {
inst->SetColor(inst->GetItem()->Color);
database.SaveInventory(CharacterID(), inst, slot2);
}
m_pp.item_tint[cur_slot].color = 0;
SendWearChange(cur_slot);
}
Save(0);
}
@@ -11415,7 +11421,7 @@ void command_augmentitem(Client *c, const Seperator *sep)
return;
AugmentItem_Struct* in_augment = new AugmentItem_Struct[sizeof(AugmentItem_Struct)];
in_augment->container_slot = 1000;
in_augment->container_slot = 1000; // <watch>
in_augment->unknown02[0] = 0;
in_augment->unknown02[1] = 0;
in_augment->augment_slot = -1;
+30 -18
View File
@@ -364,9 +364,9 @@ Corpse::Corpse(Client* client, int32 in_rezexp)
// worn + inventory + cursor
std::list<uint32> removed_list;
bool cursor = false;
for(i = 0; i <= 30; i++)
for(i = MAP_BEGIN; i < EmuConstants::MAP_POSSESSIONS_SIZE; i++)
{
if(i == 21 && client->GetClientVersion() >= EQClientSoF) {
if(i == MainAmmo && client->GetClientVersion() >= EQClientSoF) {
item = client->GetInv().GetItem(MainPowerSource);
if((item && (!client->IsBecomeNPC())) || (item && client->IsBecomeNPC() && !item->GetItem()->NoRent)) {
std::list<uint32> slot_list = MoveItemToCorpse(client, item, MainPowerSource);
@@ -449,9 +449,9 @@ std::list<uint32> Corpse::MoveItemToCorpse(Client *client, ItemInst *item, int16
returnlist.push_back(equipslot);
// Qualified bag slot iterations. processing bag slots that don't exist is probably not a good idea.
if(item->IsType(ItemClassContainer) && ((equipslot >= 22 && equipslot <=30))) // Limit the bag check to inventory and cursor slots.
if(item->IsType(ItemClassContainer) && ((equipslot >= EmuConstants::GENERAL_BEGIN && equipslot <= MainCursor))) // Limit the bag check to inventory and cursor slots.
{
for(bagindex = 0; bagindex <= 9; bagindex++)
for(bagindex = SUB_BEGIN; bagindex <= EmuConstants::ITEM_CONTAINER_SIZE; bagindex++)
{
// For empty bags in cursor queue, slot was previously being resolved as SLOT_INVALID (-1)
interior_slot = Inventory::CalcSlotId(equipslot, bagindex);
@@ -685,7 +685,7 @@ ServerLootItem_Struct* Corpse::GetItem(uint16 lootslot, ServerLootItem_Struct**
if (sitem && bag_item_data && Inventory::SupportsContainers(sitem->equipSlot))
{
int16 bagstart = Inventory::CalcSlotId(sitem->equipSlot, 0);
int16 bagstart = Inventory::CalcSlotId(sitem->equipSlot, SUB_BEGIN);
cur = itemlist.begin();
end = itemlist.end();
@@ -750,7 +750,7 @@ void Corpse::RemoveItem(ServerLootItem_Struct* item_data)
itemlist.erase(cur);
material = Inventory::CalcMaterialFromSlot(sitem->equipSlot);
if(material != 0xFF)
if(material != _MaterialInvalid)
SendWearChange(material);
safe_delete(sitem);
@@ -983,7 +983,7 @@ void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* a
const Item_Struct* item = database.GetItem(pkitem);
ItemInst* inst = database.CreateItem(item, item->MaxCharges);
if(inst) {
client->SendItemPacket(22, inst, ItemPacketLoot);
client->SendItemPacket(EmuConstants::CORPSE_BEGIN, inst, ItemPacketLoot);
safe_delete(inst);
}
else { client->Message(13, "Could not find item number %i to send!!", GetPKItem()); }
@@ -1016,7 +1016,8 @@ void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* a
if(client && item) {
ItemInst* inst = database.CreateItem(item, item_data->charges, item_data->aug1, item_data->aug2, item_data->aug3, item_data->aug4, item_data->aug5);
if(inst) {
client->SendItemPacket(i + 22, inst, ItemPacketLoot); // 22 is the corpse inventory start offset for Ti(EMu)
// MainGeneral1 is the corpse inventory start offset for Ti(EMu) - CORPSE_END = MainGeneral1 + MainCursor
client->SendItemPacket(i + EmuConstants::CORPSE_BEGIN, inst, ItemPacketLoot);
safe_delete(inst);
}
@@ -1110,9 +1111,9 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app)
if(GetPKItem()>1)
item = database.GetItem(GetPKItem());
else if(GetPKItem()==-1 || GetPKItem()==1)
item_data = GetItem(lootitem->slot_id - 22); //dont allow them to loot entire bags of items as pvp reward
item_data = GetItem(lootitem->slot_id - EmuConstants::CORPSE_BEGIN); //dont allow them to loot entire bags of items as pvp reward
else
item_data = GetItem(lootitem->slot_id - 22, bag_item_data);
item_data = GetItem(lootitem->slot_id - EmuConstants::CORPSE_BEGIN, bag_item_data);
if (GetPKItem()<=1 && item_data != 0)
{
@@ -1141,7 +1142,7 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app)
if(inst->IsAugmented())
{
for (int i = 0; i<EmuConstants::ITEM_COMMON_SIZE; i++)
for (int i = AUG_BEGIN; i<EmuConstants::ITEM_COMMON_SIZE; i++)
{
ItemInst *itm = inst->GetAugment(i);
if(itm)
@@ -1238,7 +1239,7 @@ void Corpse::LootItem(Client* client, const EQApplicationPacket* app)
// remove bag contents too
if (item->ItemClass == ItemClassContainer && (GetPKItem()!=-1 || GetPKItem()!=1))
{
for (int i=0; i < 10; i++)
for (int i = SUB_BEGIN; i < EmuConstants::ITEM_CONTAINER_SIZE; i++)
{
if (bag_item_data[i])
{
@@ -1971,14 +1972,14 @@ bool ZoneDatabase::DeletePlayerCorpse(uint32 dbid) {
uint32 Corpse::GetEquipment(uint8 material_slot) const {
int invslot;
if(material_slot > 8)
if(material_slot > EmuConstants::MATERIAL_END)
{
return 0;
return NO_ITEM;
}
invslot = Inventory::CalcSlotFromMaterial(material_slot);
if(invslot == -1)
return 0;
if(invslot == INVALID_INDEX) // GetWornItem() should be returning a NO_ITEM for any invalid index...
return NO_ITEM;
return GetWornItem(invslot);
}
@@ -1986,13 +1987,13 @@ uint32 Corpse::GetEquipment(uint8 material_slot) const {
uint32 Corpse::GetEquipmentColor(uint8 material_slot) const {
const Item_Struct *item;
if(material_slot > 8)
if(material_slot > EmuConstants::MATERIAL_END)
{
return 0;
}
item = database.GetItem(GetEquipment(material_slot));
if(item != 0)
if(item != NO_ITEM)
{
return item_tint[material_slot].rgb.use_tint ?
item_tint[material_slot].color :
@@ -2054,6 +2055,17 @@ void Corpse::LoadPlayerCorpseDecayTime(uint32 dbid){
safe_delete_array(query);
}
/*
uint32 Corpse::ServerToCorpseSlot(int16 server_slot) {
// reserved
}
*/
/*
int16 Corpse::CorpseToServerSlot(uint32 corpse_slot) {
// reserved
}
*/
/*
void Corpse::CastRezz(uint16 spellid, Mob* Caster){
if(Rezzed()){
+4
View File
@@ -111,6 +111,10 @@ public:
uint32 GetEquipmentColor(uint8 material_slot) const;
inline int GetRezzExp() { return rezzexp; }
// these are a temporary work-around until corpse inventory is removed from the database blob
//static uint32 ServerToCorpseSlot(int16 server_slot); // encode
//static int16 CorpseToServerSlot(uint32 corpse_slot); // decode
protected:
std::list<uint32> MoveItemToCorpse(Client *client, ItemInst *item, int16 equipslot);
+77 -73
View File
@@ -253,7 +253,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2,
bool enforcerestr = RuleB(Inventory, EnforceAugmentRestriction);
bool enforceusable = RuleB(Inventory, EnforceAugmentUsability);
for (int iter = 0; iter < EmuConstants::ITEM_COMMON_SIZE; ++iter) {
for (int iter = AUG_BEGIN; iter < EmuConstants::ITEM_COMMON_SIZE; ++iter) {
const Item_Struct* augtest = database.GetItem(augments[iter]);
if(augtest == nullptr) {
@@ -547,7 +547,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2,
}
// add any validated augments
for (int iter = 0; iter < EmuConstants::ITEM_COMMON_SIZE; ++iter) {
for (int iter = AUG_BEGIN; iter < EmuConstants::ITEM_COMMON_SIZE; ++iter) {
if(augments[iter])
inst->PutAugment(&database, iter, augments[iter]);
}
@@ -585,7 +585,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2,
if(!IsDiscovered(item_id))
DiscoverItem(item_id);
for (int iter = 0; iter < EmuConstants::ITEM_COMMON_SIZE; ++iter) {
for (int iter = AUG_BEGIN; iter < EmuConstants::ITEM_COMMON_SIZE; ++iter) {
if(augments[iter] && !IsDiscovered(augments[iter]))
DiscoverItem(augments[iter]);
}
@@ -727,7 +727,7 @@ void Client::DeleteItemInInventory(int16 slot_id, int8 quantity, bool client_upd
qsaudit->items[parent_offset].aug_5 = m_inv[slot_id]->GetAugmentItemID(5);
if(m_inv[slot_id]->IsType(ItemClassContainer)) {
for(uint8 bag_idx = 0; bag_idx < m_inv[slot_id]->GetItem()->BagSlots; bag_idx++) {
for(uint8 bag_idx = SUB_BEGIN; bag_idx < m_inv[slot_id]->GetItem()->BagSlots; bag_idx++) {
ItemInst* bagitem = m_inv[slot_id]->GetItem(bag_idx);
if(bagitem) {
@@ -853,7 +853,7 @@ void Client::PutLootInInventory(int16 slot_id, const ItemInst &inst, ServerLootI
{
int16 interior_slot;
// solar: our bag went into slot_id, now let's pack the contents in
for(int i = 0; i < 10; i++)
for(int i = SUB_BEGIN; i < EmuConstants::ITEM_CONTAINER_SIZE; i++)
{
if(bag_item_data[i] == nullptr)
continue;
@@ -872,7 +872,7 @@ bool Client::TryStacking(ItemInst* item, uint8 type, bool try_worn, bool try_cur
return false;
int16 i;
uint32 item_id = item->GetItem()->ID;
for (i = 22; i <= 29; i++)
for (i = EmuConstants::GENERAL_BEGIN; i <= EmuConstants::GENERAL_END; i++)
{
ItemInst* tmp_inst = m_inv.GetItem(i);
if(tmp_inst && tmp_inst->GetItem()->ID == item_id && tmp_inst->GetCharges() < tmp_inst->GetItem()->StackSize){
@@ -883,9 +883,9 @@ bool Client::TryStacking(ItemInst* item, uint8 type, bool try_worn, bool try_cur
return true;
}
}
for (i = 22; i <= 29; i++)
for (i = EmuConstants::GENERAL_BEGIN; i <= EmuConstants::GENERAL_END; i++)
{
for (uint8 j = 0; j < 10; j++)
for (uint8 j = SUB_BEGIN; j < EmuConstants::ITEM_CONTAINER_SIZE; j++)
{
uint16 slotid = Inventory::CalcSlotId(i, j);
ItemInst* tmp_inst = m_inv.GetItem(slotid);
@@ -909,10 +909,11 @@ bool Client::AutoPutLootInInventory(ItemInst& inst, bool try_worn, bool try_curs
// #1: Try to auto equip
if (try_worn && inst.IsEquipable(GetBaseRace(), GetClass()) && inst.GetItem()->ReqLevel<=level && !inst.GetItem()->Attuneable && inst.GetItem()->ItemType != ItemTypeAugmentation)
{
for (int16 i = 0; i < 9999; i++) // originally (i < 22)
// too messy as-is... <watch>
for (int16 i = EmuConstants::EQUIPMENT_BEGIN; i < MainPowerSource; i++) // originally (i < 22)
{
if (i == 22) {
if(this->GetClientVersion() >= EQClientSoF) { i = 9999; } // added power source check for SoF+ clients
if (i == EmuConstants::GENERAL_BEGIN) {
if(this->GetClientVersion() >= EQClientSoF) { i = MainPowerSource; } // added power source check for SoF+ clients
else { break; }
}
@@ -949,7 +950,7 @@ bool Client::AutoPutLootInInventory(ItemInst& inst, bool try_worn, bool try_curs
//send worn to everyone...
PutLootInInventory(i, inst);
uint8 worn_slot_material = Inventory::CalcMaterialFromSlot(i);
if(worn_slot_material != 0xFF)
if(worn_slot_material != _MaterialInvalid)
{
SendWearChange(worn_slot_material);
}
@@ -1225,7 +1226,7 @@ void Client::SendLootItemInPacket(const ItemInst* inst, int16 slot_id)
bool Client::IsValidSlot(uint32 slot) {
if ((slot == (uint32)INVALID_INDEX) ||
(slot >= EmuConstants::POSSESSIONS_BEGIN && slot <= EmuConstants::POSSESSIONS_END) ||
(slot >= MAP_BEGIN && slot < EmuConstants::MAP_POSSESSIONS_SIZE) ||
(slot >= EmuConstants::GENERAL_BAGS_BEGIN && slot <= EmuConstants::CURSOR_BAG_END) ||
(slot >= EmuConstants::TRIBUTE_BEGIN && slot <= EmuConstants::TRIBUTE_END) ||
(slot >= EmuConstants::BANK_BEGIN && slot <= EmuConstants::BANK_END) ||
@@ -1234,7 +1235,7 @@ bool Client::IsValidSlot(uint32 slot) {
(slot >= EmuConstants::SHARED_BANK_BAGS_BEGIN && slot <= EmuConstants::SHARED_BANK_BAGS_END) ||
(slot >= EmuConstants::TRADE_BEGIN && slot <= EmuConstants::TRADE_END) ||
(slot >= EmuConstants::WORLD_BEGIN && slot <= EmuConstants::WORLD_END) ||
(slot == EmuConstants::POWER_SOURCE))
(slot == MainPowerSource))
return true;
else
return false;
@@ -1242,10 +1243,10 @@ bool Client::IsValidSlot(uint32 slot) {
bool Client::IsBankSlot(uint32 slot)
{
if ((slot >= 2000 && slot <= 2023) || // Bank
(slot >= 2031 && slot <= 2270) || // Bank bags
(slot >= 2500 && slot <= 2501) || // Shared bank
(slot >= 2531 && slot <= 2550)) // Shared bank bags
if ((slot >= EmuConstants::BANK_BEGIN && slot <= EmuConstants::BANK_END) ||
(slot >= EmuConstants::BANK_BAGS_BEGIN && slot <= EmuConstants::BANK_BAGS_END) ||
(slot >= EmuConstants::SHARED_BANK_BEGIN && slot <= EmuConstants::SHARED_BANK_END) ||
(slot >= EmuConstants::SHARED_BANK_BAGS_BEGIN && slot <= EmuConstants::SHARED_BANK_BAGS_END))
{
return true;
}
@@ -1356,15 +1357,18 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
ItemInst* dstbag;
uint32 srcbagid =0;
uint32 dstbagid = 0;
if (src_slot_id>=250 && src_slot_id<330){
srcbag=m_inv.GetItem(((int)(src_slot_id/10))-3);
if(srcbag)
srcbagid=srcbag->GetItem()->ID;
//if (src_slot_id >= 250 && src_slot_id < 330) {
if (src_slot_id >= EmuConstants::GENERAL_BAGS_BEGIN && src_slot_id <= EmuConstants::GENERAL_BAGS_END) {
srcbag = m_inv.GetItem(((int)(src_slot_id / 10)) - 3);
if (srcbag)
srcbagid = srcbag->GetItem()->ID;
}
if (dst_slot_id>=250 && dst_slot_id<330){
dstbag=m_inv.GetItem(((int)(dst_slot_id/10))-3);
if(dstbag)
dstbagid=dstbag->GetItem()->ID;
//if (dst_slot_id >= 250 && dst_slot_id < 330) {
if (dst_slot_id >= EmuConstants::GENERAL_BAGS_BEGIN && dst_slot_id <= EmuConstants::GENERAL_BAGS_END) {
dstbag = m_inv.GetItem(((int)(dst_slot_id / 10)) - 3);
if (dstbag)
dstbagid = dstbag->GetItem()->ID;
}
if (srcitemid==17899 || srcbagid==17899 || dstitemid==17899 || dstbagid==17899){
this->Trader_EndTrader();
@@ -1374,7 +1378,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
// Step 2: Validate item in from_slot
// After this, we can assume src_inst is a valid ptr
if (!src_inst && (src_slot_id<4000 || src_slot_id>4009)) {
if (!src_inst && (src_slot_id < EmuConstants::WORLD_BEGIN || src_slot_id > EmuConstants::WORLD_END)) {
if (dst_inst) {
// If there is no source item, but there is a destination item,
// move the slots around before deleting the invalid source slot item,
@@ -1388,14 +1392,14 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
return false;
}
//verify shared bank transactions in the database
if(src_inst && src_slot_id >= 2500 && src_slot_id <= 2550) {
if(src_inst && src_slot_id >= EmuConstants::SHARED_BANK_BEGIN && src_slot_id <= EmuConstants::SHARED_BANK_BAGS_END) {
if(!database.VerifyInventory(account_id, src_slot_id, src_inst)) {
LogFile->write(EQEMuLog::Error, "Player %s on account %s was found exploiting the shared bank.\n", GetName(), account_name);
DeleteItemInInventory(dst_slot_id,0,true);
return(false);
}
if(src_slot_id >= 2500 && src_slot_id <= 2501 && src_inst->IsType(ItemClassContainer)){
for (uint8 idx=0; idx<10; idx++) {
if(src_slot_id >= EmuConstants::SHARED_BANK_BEGIN && src_slot_id <= EmuConstants::SHARED_BANK_END && src_inst->IsType(ItemClassContainer)){
for (uint8 idx = SUB_BEGIN; idx < EmuConstants::ITEM_CONTAINER_SIZE; idx++) {
const ItemInst* baginst = src_inst->GetItem(idx);
if(baginst && !database.VerifyInventory(account_id, Inventory::CalcSlotId(src_slot_id, idx), baginst)){
DeleteItemInInventory(Inventory::CalcSlotId(src_slot_id, idx),0,false);
@@ -1403,14 +1407,14 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
}
}
}
if(dst_inst && dst_slot_id >= 2500 && dst_slot_id <= 2550) {
if(dst_inst && dst_slot_id >= EmuConstants::SHARED_BANK_BEGIN && dst_slot_id <= EmuConstants::SHARED_BANK_BAGS_END) {
if(!database.VerifyInventory(account_id, dst_slot_id, dst_inst)) {
LogFile->write(EQEMuLog::Error, "Player %s on account %s was found exploting the shared bank.\n", GetName(), account_name);
DeleteItemInInventory(src_slot_id,0,true);
return(false);
}
if(dst_slot_id >= 2500 && dst_slot_id <= 2501 && dst_inst->IsType(ItemClassContainer)){
for (uint8 idx=0; idx<10; idx++) {
if(dst_slot_id >= EmuConstants::SHARED_BANK_BEGIN && dst_slot_id <= EmuConstants::SHARED_BANK_END && dst_inst->IsType(ItemClassContainer)){
for (uint8 idx = SUB_BEGIN; idx < EmuConstants::ITEM_CONTAINER_SIZE; idx++) {
const ItemInst* baginst = dst_inst->GetItem(idx);
if(baginst && !database.VerifyInventory(account_id, Inventory::CalcSlotId(dst_slot_id, idx), baginst)){
DeleteItemInInventory(Inventory::CalcSlotId(dst_slot_id, idx),0,false);
@@ -1422,8 +1426,8 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
// Check for No Drop Hacks
Mob* with = trade->With();
if (((with && with->IsClient() && dst_slot_id>=3000 && dst_slot_id<=3007) || // Trade
(dst_slot_id >= 2500 && dst_slot_id <= 2550)) // Shared Bank
if (((with && with->IsClient() && dst_slot_id >= EmuConstants::TRADE_BEGIN && dst_slot_id <= EmuConstants::TRADE_END) ||
(dst_slot_id >= EmuConstants::SHARED_BANK_BEGIN && dst_slot_id <= EmuConstants::SHARED_BANK_BAGS_END))
&& GetInv().CheckNoDrop(src_slot_id)
&& RuleI(World, FVNoDropFlag) == 0 || RuleI(Character, MinStatusForNoDropExemptions) < Admin() && RuleI(World, FVNoDropFlag) == 2) {
DeleteItemInInventory(src_slot_id);
@@ -1433,7 +1437,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
// Step 3: Check for interaction with World Container (tradeskills)
if(m_tradeskill_object != nullptr) {
if (src_slot_id>=4000 && src_slot_id<=4009) {
if (src_slot_id >= EmuConstants::WORLD_BEGIN && src_slot_id <= EmuConstants::WORLD_END) {
// Picking up item from world container
ItemInst* inst = m_tradeskill_object->PopItem(Inventory::CalcBagIdx(src_slot_id));
if (inst) {
@@ -1445,7 +1449,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
return true;
}
else if (dst_slot_id>=4000 && dst_slot_id<=4009) {
else if (dst_slot_id >= EmuConstants::WORLD_BEGIN && dst_slot_id <= EmuConstants::WORLD_END) {
// Putting item into world container, which may swap (or pile onto) with existing item
uint8 world_idx = Inventory::CalcBagIdx(dst_slot_id);
ItemInst* world_inst = m_tradeskill_object->PopItem(world_idx);
@@ -1509,7 +1513,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
}
// Step 4: Check for entity trade
if (dst_slot_id>=3000 && dst_slot_id<=3007) {
if (dst_slot_id >= EmuConstants::TRADE_BEGIN && dst_slot_id <= EmuConstants::TRADE_END) {
if (src_slot_id != MainCursor) {
Kick();
return false;
@@ -1596,12 +1600,12 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
}
else {
// Not dealing with charges - just do direct swap
if(src_inst && (dst_slot_id <= MainAmmo || dst_slot_id == MainPowerSource) && dst_slot_id >= MainCharm) {
if(src_inst && (dst_slot_id <= EmuConstants::EQUIPMENT_END || dst_slot_id == MainPowerSource) && dst_slot_id >= EmuConstants::EQUIPMENT_BEGIN) {
if (src_inst->GetItem()->Attuneable) {
src_inst->SetInstNoDrop(true);
}
if (src_inst->IsAugmented()) {
for (int i = 0; i < EmuConstants::ITEM_COMMON_SIZE; i++) {
for (int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) {
if (src_inst->GetAugment(i)) {
if (src_inst->GetAugment(i)->GetItem()->Attuneable) {
src_inst->GetAugment(i)->SetInstNoDrop(true);
@@ -1614,7 +1618,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
if(!m_inv.SwapItem(src_slot_id, dst_slot_id)) { return false; }
mlog(INVENTORY__SLOTS, "Moving entire item from slot %d to slot %d", src_slot_id, dst_slot_id);
if(src_slot_id <= MainAmmo || src_slot_id == MainPowerSource) {
if(src_slot_id <= EmuConstants::EQUIPMENT_END || src_slot_id == MainPowerSource) {
if(src_inst) {
parse->EventItem(EVENT_UNEQUIP_ITEM, this, src_inst, nullptr, "", src_slot_id);
}
@@ -1624,7 +1628,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
}
}
if(dst_slot_id <= MainAmmo || dst_slot_id == MainPowerSource) {
if(dst_slot_id <= EmuConstants::EQUIPMENT_END || dst_slot_id == MainPowerSource) {
if(dst_inst) {
parse->EventItem(EVENT_UNEQUIP_ITEM, this, dst_inst, nullptr, "", dst_slot_id);
}
@@ -1636,7 +1640,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
}
int matslot = SlotConvert2(dst_slot_id);
if (dst_slot_id<22 && matslot != 0) {
if (dst_slot_id <= EmuConstants::EQUIPMENT_END && matslot != MaterialHead) { // think this is to allow the client to update with /showhelm
SendWearChange(matslot);
}
@@ -1646,6 +1650,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
database.SaveCursor(character_id, s, e);
} else
database.SaveInventory(character_id, m_inv.GetItem(src_slot_id), src_slot_id);
if (dst_slot_id == MainCursor) {
std::list<ItemInst*>::const_iterator s=m_inv.cursor_begin(),e=m_inv.cursor_end();
database.SaveCursor(character_id, s, e);
@@ -1668,7 +1673,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) {
mlog(INVENTORY__ERROR, "Inventory desyncronization. (charname: %s, source: %i, destination: %i)", GetName(), move_slots->from_slot, move_slots->to_slot);
Message(15, "Inventory Desyncronization detected: Resending slot data...");
if((move_slots->from_slot >= MainCharm && move_slots->from_slot <= 340) || move_slots->from_slot == MainPowerSource) {
if((move_slots->from_slot >= EmuConstants::EQUIPMENT_BEGIN && move_slots->from_slot <= EmuConstants::CURSOR_BAG_END) || move_slots->from_slot == MainPowerSource) {
int16 resync_slot = (Inventory::CalcSlotId(move_slots->from_slot) == INVALID_INDEX) ? move_slots->from_slot : Inventory::CalcSlotId(move_slots->from_slot);
if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) {
// This prevents the client from crashing when closing any 'phantom' bags -U
@@ -1711,7 +1716,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) {
else { Message(13, "Could not resyncronize source slot %i.", move_slots->from_slot); }
}
if((move_slots->to_slot >= MainCharm && move_slots->to_slot <= 340) || move_slots->to_slot == MainPowerSource) {
if((move_slots->to_slot >= EmuConstants::EQUIPMENT_BEGIN && move_slots->to_slot <= EmuConstants::CURSOR_BAG_END) || move_slots->to_slot == MainPowerSource) {
int16 resync_slot = (Inventory::CalcSlotId(move_slots->to_slot) == INVALID_INDEX) ? move_slots->to_slot : Inventory::CalcSlotId(move_slots->to_slot);
if (IsValidSlot(resync_slot) && resync_slot != INVALID_INDEX) {
const Item_Struct* token_struct = database.GetItem(22292); // 'Copper Coin'
@@ -1792,7 +1797,7 @@ void Client::QSSwapItemAuditor(MoveItem_Struct* move_in, bool postaction_call) {
qsaudit->items[move_count++].aug_5 = from_inst->GetAugmentItemID(5);
if(from_inst->IsType(ItemClassContainer)) {
for(uint8 bag_idx = 0; bag_idx < from_inst->GetItem()->BagSlots; bag_idx++) {
for(uint8 bag_idx = SUB_BEGIN; bag_idx < from_inst->GetItem()->BagSlots; bag_idx++) {
const ItemInst* from_baginst = from_inst->GetItem(bag_idx);
if(from_baginst) {
@@ -1825,7 +1830,7 @@ void Client::QSSwapItemAuditor(MoveItem_Struct* move_in, bool postaction_call) {
qsaudit->items[move_count++].aug_5 = to_inst->GetAugmentItemID(5);
if(to_inst->IsType(ItemClassContainer)) {
for(uint8 bag_idx = 0; bag_idx < to_inst->GetItem()->BagSlots; bag_idx++) {
for(uint8 bag_idx = SUB_BEGIN; bag_idx < to_inst->GetItem()->BagSlots; bag_idx++) {
const ItemInst* to_baginst = to_inst->GetItem(bag_idx);
if(to_baginst) {
@@ -1854,7 +1859,7 @@ void Client::QSSwapItemAuditor(MoveItem_Struct* move_in, bool postaction_call) {
void Client::DyeArmor(DyeStruct* dye){
int16 slot=0;
for(int i=0;i<7;i++){
for (int i = EmuConstants::MATERIAL_BEGIN; i <= EmuConstants::MATERIAL_TINT_END; i++) {
if(m_pp.item_tint[i].rgb.blue!=dye->dye[i].rgb.blue ||
m_pp.item_tint[i].rgb.red!=dye->dye[i].rgb.red ||
m_pp.item_tint[i].rgb.green != dye->dye[i].rgb.green){
@@ -1892,7 +1897,7 @@ void Client::DyeArmor(DyeStruct* dye){
const Item_Struct* TempItem = 0;
ItemInst* ins;
int x;
for(x=0; x <= 30; x++)
for(x=EmuConstants::POSSESSIONS_BEGIN; x <= EmuConstants::POSSESSIONS_END; x++)
{
TempItem = 0;
ins = GetInv().GetItem(x);
@@ -1914,7 +1919,7 @@ void Client::DyeArmor(DyeStruct* dye){
return true;
}
}
for(x=251; x < 331; x++)
for(x=EmuConstants::GENERAL_BAGS_BEGIN; x <= EmuConstants::GENERAL_BAGS_END; x++)
{
TempItem = 0;
ins = GetInv().GetItem(x);
@@ -1944,9 +1949,9 @@ bool Client::DecreaseByID(uint32 type, uint8 amt) {
ItemInst* ins;
int x;
int num = 0;
for(x = EmuConstants::POSSESSIONS_BEGIN; x <= EmuConstants::GENERAL_BAGS_END; x++)
for(x = EmuConstants::EQUIPMENT_BEGIN; x <= EmuConstants::GENERAL_BAGS_END; x++)
{
if (x == EmuConstants::CURSOR + 1)
if (x == MainCursor + 1)
x = EmuConstants::GENERAL_BAGS_BEGIN;
TempItem = 0;
ins = GetInv().GetItem(x);
@@ -1961,9 +1966,9 @@ bool Client::DecreaseByID(uint32 type, uint8 amt) {
}
if (num < amt)
return false;
for(x = EmuConstants::POSSESSIONS_BEGIN; x <= EmuConstants::GENERAL_BAGS_END; x++) // should this be CURSOR_BAG_END
for(x = EmuConstants::EQUIPMENT_BEGIN; x <= EmuConstants::GENERAL_BAGS_END; x++) // should this be CURSOR_BAG_END?
{
if (x == EmuConstants::CURSOR + 1)
if (x == MainCursor + 1)
x = EmuConstants::GENERAL_BAGS_BEGIN;
TempItem = 0;
ins = GetInv().GetItem(x);
@@ -1993,7 +1998,7 @@ void Client::RemoveNoRent(bool client_update) {
int16 slot_id;
// personal
for(slot_id = EmuConstants::POSSESSIONS_BEGIN; slot_id <= EmuConstants::POSSESSIONS_END; slot_id++) {
for(slot_id = MAP_BEGIN; slot_id < EmuConstants::MAP_POSSESSIONS_SIZE; slot_id++) {
const ItemInst* inst = m_inv[slot_id];
if(inst && !inst->GetItem()->NoRent) {
mlog(INVENTORY__SLOTS, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id);
@@ -2002,10 +2007,10 @@ void Client::RemoveNoRent(bool client_update) {
}
// power source
const ItemInst* inst = m_inv[EmuConstants::POWER_SOURCE];
const ItemInst* inst = m_inv[MainPowerSource];
if(inst && !inst->GetItem()->NoRent) {
mlog(INVENTORY__SLOTS, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, EmuConstants::POWER_SOURCE);
DeleteItemInInventory(EmuConstants::POWER_SOURCE, 0, (GetClientVersion() >= EQClientSoF) ? client_update : false); // Ti slot non-existent
mlog(INVENTORY__SLOTS, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, MainPowerSource);
DeleteItemInInventory(MainPowerSource, 0, (GetClientVersion() >= EQClientSoF) ? client_update : false); // Ti slot non-existent
}
// containers
@@ -2060,7 +2065,7 @@ void Client::RemoveDuplicateLore(bool client_update) {
int16 slot_id;
// personal
for(slot_id = EmuConstants::POSSESSIONS_BEGIN; slot_id <= EmuConstants::POSSESSIONS_END; slot_id++) {
for(slot_id = MAP_BEGIN; slot_id < EmuConstants::MAP_POSSESSIONS_SIZE; slot_id++) {
ItemInst* inst = m_inv.PopItem(slot_id);
if(inst) {
if(CheckLoreConflict(inst->GetItem())) {
@@ -2075,14 +2080,14 @@ void Client::RemoveDuplicateLore(bool client_update) {
}
// power source
ItemInst* inst = m_inv.PopItem(EmuConstants::POWER_SOURCE);
ItemInst* inst = m_inv.PopItem(MainPowerSource);
if(inst) {
if(CheckLoreConflict(inst->GetItem())) {
mlog(INVENTORY__ERROR, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, slot_id);
database.SaveInventory(character_id, nullptr, EmuConstants::POWER_SOURCE);
database.SaveInventory(character_id, nullptr, MainPowerSource);
}
else {
m_inv.PutItem(EmuConstants::POWER_SOURCE, *inst);
m_inv.PutItem(MainPowerSource, *inst);
}
safe_delete(inst);
}
@@ -2153,7 +2158,7 @@ void Client::MoveSlotNotAllowed(bool client_update) {
}
// power source
slot_id = EmuConstants::POWER_SOURCE;
slot_id = MainPowerSource;
if(m_inv[slot_id] && !m_inv[slot_id]->IsSlotAllowed(slot_id)) {
ItemInst* inst = m_inv.PopItem(slot_id);
bool is_arrow = (inst->GetItem()->ItemType == ItemTypeArrow) ? true : false;
@@ -2174,7 +2179,7 @@ uint32 Client::GetEquipment(uint8 material_slot) const
int invslot;
const ItemInst *item;
if(material_slot > 8)
if(material_slot > EmuConstants::MATERIAL_END)
{
return 0;
}
@@ -2214,7 +2219,7 @@ uint32 Client::GetEquipmentColor(uint8 material_slot) const
{
const Item_Struct *item;
if(material_slot > 8)
if(material_slot > EmuConstants::MATERIAL_END)
{
return 0;
}
@@ -2373,7 +2378,7 @@ void Client::SetBandolier(const EQApplicationPacket *app) {
m_inv.GetItem(MainCursor)->GetCharges() >= 1) // '> 0' the same, but this matches Inventory::_HasItem conditional check
slot = MainCursor;
else if (m_inv.GetItem(MainCursor)->GetItem()->ItemClass == 1) {
for(int16 CursorBagSlot = 331; CursorBagSlot <= 340; CursorBagSlot++) {
for(int16 CursorBagSlot = EmuConstants::CURSOR_BAG_BEGIN; CursorBagSlot <= EmuConstants::CURSOR_BAG_END; CursorBagSlot++) {
if (m_inv.GetItem(CursorBagSlot)) {
if (m_inv.GetItem(CursorBagSlot)->GetItem()->ID == m_pp.bandoliers[bss->number].items[BandolierSlot].item_id &&
m_inv.GetItem(CursorBagSlot)->GetCharges() >= 1) { // ditto
@@ -2513,7 +2518,7 @@ bool Client::MoveItemToInventory(ItemInst *ItemToReturn, bool UpdateClient) {
//
if(ItemToReturn->IsStackable()) {
for (int16 i=22; i<=30; i++) { // changed slot max to 30 from 29. client will stack into slot 30 (bags too) before moving.
for (int16 i = EmuConstants::GENERAL_BEGIN; i <= MainCursor; i++) { // changed slot max to 30 from 29. client will stack into slot 30 (bags too) before moving.
ItemInst* InvItem = m_inv.GetItem(i);
@@ -2540,12 +2545,12 @@ bool Client::MoveItemToInventory(ItemInst *ItemToReturn, bool UpdateClient) {
//
if (InvItem && InvItem->IsType(ItemClassContainer)) {
int16 BaseSlotID = Inventory::CalcSlotId(i, 0);
int16 BaseSlotID = Inventory::CalcSlotId(i, SUB_BEGIN);
uint8 BagSize=InvItem->GetItem()->BagSlots;
uint8 BagSlot;
for (BagSlot=0; BagSlot<BagSize; BagSlot++) {
for (BagSlot = SUB_BEGIN; BagSlot < BagSize; BagSlot++) {
InvItem = m_inv.GetItem(BaseSlotID + BagSlot);
if (InvItem && (InvItem->GetItem()->ID == ItemID) &&
(InvItem->GetCharges() < InvItem->GetItem()->StackSize)) {
@@ -2576,7 +2581,7 @@ bool Client::MoveItemToInventory(ItemInst *ItemToReturn, bool UpdateClient) {
// We have tried stacking items, now just try and find an empty slot.
for (int16 i=22; i<=30; i++) { // changed slot max to 30 from 29. client will move into slot 30 (bags too) before pushing onto cursor.
for (int16 i = EmuConstants::GENERAL_BEGIN; i <= MainCursor; i++) { // changed slot max to 30 from 29. client will move into slot 30 (bags too) before pushing onto cursor.
ItemInst* InvItem = m_inv.GetItem(i);
@@ -2595,11 +2600,11 @@ bool Client::MoveItemToInventory(ItemInst *ItemToReturn, bool UpdateClient) {
}
if(InvItem->IsType(ItemClassContainer) && Inventory::CanItemFitInContainer(ItemToReturn->GetItem(), InvItem->GetItem())) {
int16 BaseSlotID = Inventory::CalcSlotId(i, 0);
int16 BaseSlotID = Inventory::CalcSlotId(i, SUB_BEGIN);
uint8 BagSize=InvItem->GetItem()->BagSlots;
for (uint8 BagSlot=0; BagSlot<BagSize; BagSlot++) {
for (uint8 BagSlot = SUB_BEGIN; BagSlot < BagSize; BagSlot++) {
InvItem = m_inv.GetItem(BaseSlotID + BagSlot);
@@ -2668,4 +2673,3 @@ std::string Inventory::GetCustomItemData(int16 slot_id, std::string identifier)
}
return "";
}
+2 -2
View File
@@ -1461,8 +1461,8 @@ luabind::scope lua_register_slot() {
luabind::value("PersonalEnd", static_cast<int>(EmuConstants::GENERAL_END)), // deprecated
luabind::value("GeneralEnd", static_cast<int>(EmuConstants::GENERAL_END)),
luabind::value("CursorEnd", 0xFFFE), // deprecated
luabind::value("Tradeskill", static_cast<int>(SLOT_TRADESKILL)), // deprecated
luabind::value("Augment", static_cast<int>(SLOT_AUGMENT)), // deprecated
luabind::value("Tradeskill", static_cast<int>(legacy::SLOT_TRADESKILL)), // deprecated
luabind::value("Augment", static_cast<int>(legacy::SLOT_AUGMENT)), // deprecated
luabind::value("Invalid", INVALID_INDEX)
];
}
+5 -5
View File
@@ -5136,13 +5136,13 @@ bool Merc::Spawn(Client *owner) {
//printf("Spawned Merc with ID %i\n", npc->GetID()); fflush(stdout);
/*
uint32 itemID = 0;
uint8 materialFromSlot = 0xFF;
for(int i=0; i<22; ++i) {
uint32 itemID = NO_ITEM;
uint8 materialFromSlot = _MaterialInvalid;
for(int i=EmuConstants::EQUIPMENT_BEGIN; i<=EmuConstants::EQUIPMENT_END; ++i) {
itemID = GetMercItemBySlot(i);
if(itemID != 0) {
if(itemID != NO_ITEM) {
materialFromSlot = Inventory::CalcMaterialFromSlot(i);
if(materialFromSlot != 0xFF) {
if(materialFromSlot != _MaterialInvalid) {
this->SendWearChange(materialFromSlot);
}
}
+1 -1
View File
@@ -872,7 +872,7 @@ XS(XS_Mob_Attack)
Perl_croak(aTHX_ "other is nullptr, avoiding crash.");
if (items < 3)
Hand = MainPrimary;
Hand = 13;
else {
Hand = (int)SvIV(ST(2));
}
+10 -9
View File
@@ -1427,9 +1427,10 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
SendAppearancePacket(AT_Size, 6);
}
}
for(int x = 0; x < 7; x++){
for(int x = EmuConstants::MATERIAL_BEGIN; x <= EmuConstants::MATERIAL_TINT_END; x++)
SendWearChange(x);
}
if(caster && (caster->spellbonuses.IllusionPersistence || caster->aabonuses.IllusionPersistence
|| caster->itembonuses.IllusionPersistence))
buffs[buffslot].persistant_buff = 1;
@@ -1451,9 +1452,9 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
caster->GetTarget()->GetTexture()
);
caster->SendAppearancePacket(AT_Size, caster->GetTarget()->GetSize());
for(int x = 0; x < 7; x++){
for(int x = EmuConstants::MATERIAL_BEGIN; x <= EmuConstants::MATERIAL_TINT_END; x++)
caster->SendWearChange(x);
}
}
}
@@ -3724,7 +3725,7 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
else{
SendAppearancePacket(AT_Size, 6);
}
for(int x = 0; x < 7; x++){
for(int x = EmuConstants::MATERIAL_BEGIN; x <= EmuConstants::MATERIAL_TINT_END; x++){
SendWearChange(x);
}
break;
@@ -5047,7 +5048,7 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
const Item_Struct* TempItem = 0;
for(int x=0; x<=21; x++)
for(int x = EmuConstants::EQUIPMENT_BEGIN; x <= EmuConstants::EQUIPMENT_END; x++)
{
if (SympatheticProcList.size() > MAX_SYMPATHETIC)
continue;
@@ -5070,7 +5071,7 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
}
}
for (int y = 0; y < EmuConstants::ITEM_COMMON_SIZE; ++y)
for (int y = AUG_BEGIN; y < EmuConstants::ITEM_COMMON_SIZE; ++y)
{
if (SympatheticProcList.size() > MAX_SYMPATHETIC)
continue;
@@ -5192,7 +5193,7 @@ int16 Client::GetFocusEffect(focusType type, uint16 spell_id) {
int16 focus_max_real = 0;
//item focus
for(int x=0; x<=21; x++)
for(int x = EmuConstants::EQUIPMENT_BEGIN; x <= EmuConstants::EQUIPMENT_END; x++)
{
TempItem = nullptr;
ItemInst* ins = GetInv().GetItem(x);
@@ -5226,7 +5227,7 @@ int16 Client::GetFocusEffect(focusType type, uint16 spell_id) {
}
}
for (int y = 0; y < EmuConstants::ITEM_COMMON_SIZE; ++y)
for (int y = AUG_BEGIN; y < EmuConstants::ITEM_COMMON_SIZE; ++y)
{
ItemInst *aug = nullptr;
aug = ins->GetAugment(y);
+8 -8
View File
@@ -68,7 +68,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme
// Verify that no more than two items are in container to guarantee no inadvertant wipes.
uint8 itemsFound = 0;
for (uint8 i=0; i<10; i++)
for (uint8 i = MAP_BEGIN; i < EmuConstants::MAP_WORLD_SIZE; i++)
{
const ItemInst* inst = container->GetItem(i);
if (inst)
@@ -212,7 +212,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme
else
{
// Delete items in our inventory container...
for (uint8 i=0; i<10; i++)
for (uint8 i = MAP_BEGIN; i < EmuConstants::MAP_WORLD_SIZE; i++)
{
const ItemInst* inst = container->GetItem(i);
if (inst)
@@ -254,7 +254,7 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob
uint32 some_id = 0;
bool worldcontainer=false;
if (in_combine->container_slot == SLOT_TRADESKILL) {
if (in_combine->container_slot == legacy::SLOT_TRADESKILL) {
if(!worldo) {
user->Message(13, "Error: Server is not aware of the tradeskill container you are attempting to use");
return;
@@ -353,7 +353,7 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob
safe_delete(outapp);
database.DeleteWorldContainer(worldo->m_id, zone->GetZoneID());
} else{
for (uint8 i=0; i<10; i++){
for (uint8 i = MAP_BEGIN; i < EmuConstants::MAP_WORLD_SIZE; i++) {
const ItemInst* inst = container->GetItem(i);
if (inst) {
user->DeleteItemInInventory(Inventory::CalcSlotId(in_combine->container_slot,i),0,true);
@@ -758,7 +758,7 @@ void Client::SendTradeskillDetails(uint32 recipe_id) {
uint32 *ffff_start = (uint32 *) startblock;
//fill in the FFFF's as if there were 0 items
for(r = 0; r < 10; r++) {
for(r = 0; r < 10; r++) { // world:item container size related?
*ffff_start = 0xFFFFFFFF;
ffff_start++;
}
@@ -794,7 +794,7 @@ void Client::SendTradeskillDetails(uint32 recipe_id) {
icon = htonl(icon);
//if we get more than 10 items, just start skipping them...
for(k = 0; k < num && count < 10; k++) {
for(k = 0; k < num && count < 10; k++) { // world:item container size related?
itemptr = (uint32 *) cblock;
cblock += sizeof(uint32);
datalen += sizeof(uint32);
@@ -1199,7 +1199,7 @@ bool ZoneDatabase::GetTradeRecipe(const ItemInst* container, uint8 c_type, uint3
bool first = true;
uint8 i;
char *pos = buf2;
for (i=0; i<10; i++) {
for (i = 0; i < 10; i++) { // <watch> TODO: need to determine if this is bound to world/item container size
const ItemInst* inst = container->GetItem(i);
if (inst) {
const Item_Struct* item = GetItem(inst->GetItem()->ID);
@@ -1334,7 +1334,7 @@ bool ZoneDatabase::GetTradeRecipe(const ItemInst* container, uint8 c_type, uint3
if (RunQuery(TSquery, MakeAnyLenString(&TSquery, "SELECT item_id, componentcount from tradeskill_recipe_entries where recipe_id=%i AND componentcount > 0", recipe_id), TSerrbuf, &TSresult)) {
while((TSrow = mysql_fetch_row(TSresult))!=nullptr) {
int ccnt = 0;
for(int x = 0; x < 10; x++){
for(int x = MAP_BEGIN; x < EmuConstants::MAP_WORLD_SIZE; x++) {
const ItemInst* inst = container->GetItem(x);
if(inst){
const Item_Struct* item = GetItem(inst->GetItem()->ID);
+47 -37
View File
@@ -148,7 +148,7 @@ void Trade::SendItemData(const ItemInst* inst, int16 dest_slot_id)
if (with && with->IsClient()) {
with->SendItemPacket(dest_slot_id - EmuConstants::TRADE_BEGIN, inst, ItemPacketTradeView);
if (inst->GetItem()->ItemClass == 1) {
for (uint16 i=0; i<10; i++) {
for (uint16 i = SUB_BEGIN; i < EmuConstants::ITEM_CONTAINER_SIZE; i++) {
uint16 bagslot_id = Inventory::CalcSlotId(dest_slot_id, i);
const ItemInst* bagitem = trader->GetInv().GetItem(bagslot_id);
if (bagitem) {
@@ -174,7 +174,7 @@ void Trade::LogTrade()
uint8 item_count = 0;
if (zone->tradevar != 0) {
for (uint16 i=3000; i<=3007; i++) {
for (uint16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++) {
if (trader->GetInv().GetItem(i))
item_count++;
}
@@ -226,7 +226,7 @@ void Trade::LogTrade()
if (item_count > 0) {
strcat(logtext, "items {");
for (uint16 i=3000; i<=3007; i++) {
for (uint16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++) {
const ItemInst* inst = trader->GetInv().GetItem(i);
if (!comma)
@@ -242,7 +242,7 @@ void Trade::LogTrade()
strcat(logtext, item_num);
if (inst->IsType(ItemClassContainer)) {
for (uint8 j=0; j<10; j++) {
for (uint8 j = SUB_BEGIN; j < EmuConstants::ITEM_CONTAINER_SIZE; j++) {
inst = trader->GetInv().GetItem(i, j);
if (inst) {
strcat(logtext, ",");
@@ -278,7 +278,7 @@ void Trade::DumpTrade()
return;
Client* trader = owner->CastToClient();
for (uint16 i=3000; i<=3007; i++) {
for (uint16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++) {
const ItemInst* inst = trader->GetInv().GetItem(i);
if (inst) {
@@ -287,7 +287,7 @@ void Trade::DumpTrade()
i, ((inst->IsType(ItemClassContainer)) ? "True" : "False"));
if (inst->IsType(ItemClassContainer)) {
for (uint8 j=0; j<10; j++) {
for (uint8 j = SUB_BEGIN; j < EmuConstants::ITEM_CONTAINER_SIZE; j++) {
inst = trader->GetInv().GetItem(i, j);
if (inst) {
LogFile->write(EQEMuLog::Debug, "\tBagItem %i (Charges=%i, Slot=%i)",
@@ -308,7 +308,7 @@ void Client::ResetTrade() {
ItemInst* ins;
int x;
AddMoneyToPP(trade->cp, trade->sp, trade->gp, trade->pp, true);
for(x=3000; x <= 3007; x++)
for(x = EmuConstants::TRADE_BEGIN; x <= EmuConstants::TRADE_END; x++)
{
TempItem = 0;
ins = GetInv().GetItem(x);
@@ -355,7 +355,7 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer)
}
// Move each trade slot into free inventory slot
for(int16 i = 3000; i <= 3007; i++){
for(int16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++){
const ItemInst* inst = m_inv[i];
uint16 parent_offset = 0;
@@ -385,7 +385,7 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer)
if(inst->IsType(ItemClassContainer)) {
// Pseudo-Slot ID's are generated based on how the db saves bag items...
for(uint8 j = 0; j < inst->GetItem()->BagSlots; j++) {
for(uint8 j = SUB_BEGIN; j < inst->GetItem()->BagSlots; j++) {
const ItemInst* baginst = inst->GetItem(j);
if(baginst == nullptr) { continue; }
@@ -424,7 +424,7 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer)
qsaudit->items[parent_offset].to_slot = slot_id;
if(inst->IsType(ItemClassContainer)) {
for(uint8 bagslot_idx = 0; bagslot_idx < inst->GetItem()->BagSlots; bagslot_idx++) {
for(uint8 bagslot_idx = SUB_BEGIN; bagslot_idx < inst->GetItem()->BagSlots; bagslot_idx++) {
const ItemInst* bag_inst = inst->GetItem(bagslot_idx);
if(bag_inst == nullptr) { continue; }
@@ -444,7 +444,7 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer)
qsaudit->items[parent_offset].to_slot = MainCursor;
if(inst->IsType(ItemClassContainer)) {
for(uint8 bagslot_idx = 0; bagslot_idx < inst->GetItem()->BagSlots; bagslot_idx++) {
for(uint8 bagslot_idx = SUB_BEGIN; bagslot_idx < inst->GetItem()->BagSlots; bagslot_idx++) {
const ItemInst* bag_inst = inst->GetItem(bagslot_idx);
if(bag_inst == nullptr) { continue; }
@@ -468,7 +468,7 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer)
qsaudit->items[parent_offset].to_slot = MainCursor;
if(inst->IsType(ItemClassContainer)) {
for(uint8 bagslot_idx = 0; bagslot_idx < inst->GetItem()->BagSlots; bagslot_idx++) {
for(uint8 bagslot_idx = SUB_BEGIN; bagslot_idx < inst->GetItem()->BagSlots; bagslot_idx++) {
const ItemInst* bag_inst = inst->GetItem(bagslot_idx);
if(bag_inst == nullptr) { continue; }
@@ -531,7 +531,7 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer)
}
if(QSPLH) { // This can be incoporated below when revisions are made -U
for(int16 slot_id = 3000; slot_id <= 3003; slot_id++) {
for(int16 slot_id = EmuConstants::TRADE_BEGIN; slot_id <= EmuConstants::TRADE_NPC_END; slot_id++) {
const ItemInst* trade_inst = m_inv[slot_id];
if(trade_inst) {
@@ -547,7 +547,7 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer)
qsaudit->items[qsaudit->char_count++].aug_5 = trade_inst->GetAugmentItemID(5);
if(trade_inst->IsType(ItemClassContainer)) {
for(uint8 bag_idx = 0; bag_idx < trade_inst->GetItem()->BagSlots; bag_idx++) {
for(uint8 bag_idx = SUB_BEGIN; bag_idx < trade_inst->GetItem()->BagSlots; bag_idx++) {
const ItemInst* trade_baginst = trade_inst->GetItem(bag_idx);
if(trade_baginst) {
@@ -576,10 +576,10 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer)
std::vector<void*> item_list;
uint32 items[4] = { 0 };
for(int i = 3000; i < 3004; ++i) {
for(int i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_NPC_END; ++i) {
ItemInst *inst = m_inv.GetItem(i);
if(inst) {
items[i - 3000] = inst->GetItem()->ID;
items[i - EmuConstants::TRADE_BEGIN] = inst->GetItem()->ID;
item_list.push_back(inst);
} else {
item_list.push_back(nullptr);
@@ -592,7 +592,7 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer)
if(GetGM() || (item->NoDrop != 0 && inst->IsInstNoDrop() == false)) {
// pets need to look inside bags and try to equip items found there
if(item->ItemClass == ItemClassContainer && item->BagSlots > 0) {
for(int16 bslot=0; bslot < item->BagSlots; bslot++) {
for(int16 bslot = SUB_BEGIN; bslot < item->BagSlots; bslot++) {
const ItemInst* baginst = inst->GetItem(bslot);
if (baginst) {
const Item_Struct* bagitem = baginst->GetItem();
@@ -646,8 +646,8 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer)
}
ItemInst *insts[4] = { 0 };
for(int i = 3000; i < 3004; ++i) {
insts[i - 3000] = m_inv.PopItem(i);
for(int i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_NPC_END; ++i) {
insts[i - EmuConstants::TRADE_BEGIN] = m_inv.PopItem(i);
database.SaveInventory(CharacterID(), nullptr, i);
}
@@ -666,8 +666,7 @@ bool Client::CheckTradeLoreConflict(Client* other)
if (!other)
return true;
// Move each trade slot into free inventory slot
for (int16 i=3000; i<=3179; i++){
if(i == 3008) { i = 3100; }
for (int16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++){
const ItemInst* inst = m_inv[i];
if (inst && inst->GetItem()) {
@@ -675,6 +674,16 @@ bool Client::CheckTradeLoreConflict(Client* other)
return true;
}
}
for (int16 i = EmuConstants::TRADE_BAGS_BEGIN; i <= EmuConstants::TRADE_BAGS_END; i++){
const ItemInst* inst = m_inv[i];
if (inst && inst->GetItem()) {
if (other->CheckLoreConflict(inst->GetItem()))
return true;
}
}
return false;
}
@@ -873,7 +882,7 @@ void Client::SendSingleTraderItem(uint32 CharID, int SerialNumber) {
ItemInst* inst= database.LoadSingleTraderItem(CharID, SerialNumber);
if(inst) {
SendItemPacket(30, inst, ItemPacketMerchant);
SendItemPacket(30, inst, ItemPacketMerchant); // MainCursor?
safe_delete(inst);
}
@@ -904,7 +913,7 @@ void Client::BulkSendTraderInventory(uint32 char_id) {
}
inst->SetPrice(TraderItems->ItemCost[i]);
SendItemPacket(30, inst, ItemPacketMerchant);
SendItemPacket(30, inst, ItemPacketMerchant); // MainCursor?
safe_delete(inst);
}
else
@@ -920,11 +929,12 @@ ItemInst* Client::FindTraderItemBySerialNumber(int32 SerialNumber){
ItemInst* item = nullptr;
uint16 SlotID = 0;
for(int i = 0; i < 8;i++){
item = this->GetInv().GetItem(22 + i);
for(int i = EmuConstants::GENERAL_BEGIN; i <= EmuConstants::GENERAL_END; i++){
item = this->GetInv().GetItem(i);
if(item && item->GetItem()->ID == 17899){ //Traders Satchel
for(int x = 0; x < 10; x++){
SlotID = (((22 + i + 3) * 10) + x + 1);
for(int x = SUB_BEGIN; x < EmuConstants::ITEM_CONTAINER_SIZE; x++) {
// we already have the parent bag and a contents iterator..why not just iterate the bag!??
SlotID = Inventory::CalcSlotId(i, x);
item = this->GetInv().GetItem(SlotID);
if(item) {
if(item->GetSerialNumber() == SerialNumber)
@@ -950,11 +960,11 @@ GetItems_Struct* Client::GetTraderItems(){
uint8 ndx = 0;
for(int i = 0; i < 8; i++){
item = this->GetInv().GetItem(22 + i);
for(int i = EmuConstants::GENERAL_BEGIN; i <= EmuConstants::GENERAL_END; i++) {
item = this->GetInv().GetItem(i);
if(item && item->GetItem()->ID == 17899){ //Traders Satchel
for(int x = 0; x < 10; x++){
SlotID = (((22 + i +3 ) *10) + x + 1);
for(int x = SUB_BEGIN; x < EmuConstants::ITEM_CONTAINER_SIZE; x++) {
SlotID = Inventory::CalcSlotId(i, x);
item = this->GetInv().GetItem(SlotID);
@@ -974,11 +984,11 @@ uint16 Client::FindTraderItem(int32 SerialNumber, uint16 Quantity){
const ItemInst* item= nullptr;
uint16 SlotID = 0;
for(int i = 0; i < 8;i++){
item = this->GetInv().GetItem(22+i);
for(int i = EmuConstants::GENERAL_BEGIN; i <= EmuConstants::GENERAL_END; i++) {
item = this->GetInv().GetItem(i);
if(item && item->GetItem()->ID == 17899){ //Traders Satchel
for(int x = 0; x < 10; x++){
SlotID= (((22 + i + 3) * 10) + x + 1);
for(int x = SUB_BEGIN; x < EmuConstants::ITEM_CONTAINER_SIZE; x++){
SlotID = Inventory::CalcSlotId(i, x);
item = this->GetInv().GetItem(SlotID);
@@ -1713,7 +1723,7 @@ static void UpdateTraderCustomerItemsAdded(uint32 CustomerID, TraderCharges_Stru
_log(TRADING__CLIENT, "Sending price update for %s, Serial No. %i with %i charges",
item->Name, gis->SerialNumber[i], gis->Charges[i]);
Customer->SendItemPacket(30, inst, ItemPacketMerchant);
Customer->SendItemPacket(30, inst, ItemPacketMerchant); // MainCursor?
}
}
@@ -1789,7 +1799,7 @@ static void UpdateTraderCustomerPriceChanged(uint32 CustomerID, TraderCharges_St
_log(TRADING__CLIENT, "Sending price update for %s, Serial No. %i with %i charges",
item->Name, gis->SerialNumber[i], gis->Charges[i]);
Customer->SendItemPacket(30, inst, ItemPacketMerchant);
Customer->SendItemPacket(30, inst, ItemPacketMerchant); // MainCursor??
}
safe_delete(inst);
}
+13 -13
View File
@@ -518,7 +518,7 @@ void ZoneDatabase::LoadWorldContainer(uint32 parentid, ItemInst* container)
uint8 index = (uint8)atoi(row[0]);
uint32 item_id = (uint32)atoi(row[1]);
int8 charges = (int8)atoi(row[2]);
uint32 aug[5];
uint32 aug[EmuConstants::ITEM_COMMON_SIZE];
aug[0] = (uint32)atoi(row[3]);
aug[1] = (uint32)atoi(row[4]);
aug[2] = (uint32)atoi(row[5]);
@@ -528,7 +528,7 @@ void ZoneDatabase::LoadWorldContainer(uint32 parentid, ItemInst* container)
ItemInst* inst = database.CreateItem(item_id, charges);
if (inst) {
if (inst->GetItem()->ItemClass == ItemClassCommon) {
for(int i=0;i<5;i++) {
for(int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) {
if (aug[i]) {
inst->PutAugment(&database, i, aug[i]);
}
@@ -564,13 +564,13 @@ void ZoneDatabase::SaveWorldContainer(uint32 zone_id, uint32 parent_id, const It
//Delete all items from container
DeleteWorldContainer(parent_id,zone_id);
// Save all 10 items, if they exist
for (uint8 index=0; index<10; index++) {
for (uint8 index = SUB_BEGIN; index < EmuConstants::ITEM_CONTAINER_SIZE; index++) {
ItemInst* inst = container->GetItem(index);
if (inst) {
uint32 item_id = inst->GetItem()->ID;
uint32 augslot[5] = { 0, 0, 0, 0, 0 };
uint32 augslot[EmuConstants::ITEM_COMMON_SIZE] = { NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM, NO_ITEM };
if (inst->IsType(ItemClassCommon)) {
for(int i=0;i<5;i++) {
for(int i = AUG_BEGIN; i < EmuConstants::ITEM_COMMON_SIZE; i++) {
ItemInst *auginst=inst->GetAugment(i);
augslot[i]=(auginst && auginst->GetItem()) ? auginst->GetItem()->ID : 0;
}
@@ -978,7 +978,7 @@ bool ZoneDatabase::GetCharacterInfoForLogin_result(MYSQL_RES* result,
}
// Fix use_tint, previously it was set to 1 for a dyed slot, client wants it set to 0xFF
for(int i = 0; i<9; i++)
for(int i = EmuConstants::MATERIAL_BEGIN; i <= EmuConstants::MATERIAL_END; i++)
if(pp->item_tint[i].rgb.use_tint == 1)
pp->item_tint[i].rgb.use_tint = 0xFF;
@@ -1238,7 +1238,7 @@ const NPCType* ZoneDatabase::GetNPCType (uint32 id) {
{
if ((at_row = mysql_fetch_row(at_result)))
{
for (i = 0; i < _MaterialCount; i++)
for (i = EmuConstants::MATERIAL_BEGIN; i <= EmuConstants::MATERIAL_END; i++)
{
tmpNPCType->armor_tint[i] = atoi(at_row[i * 3]) << 16;
tmpNPCType->armor_tint[i] |= atoi(at_row[i * 3 + 1]) << 8;
@@ -1271,7 +1271,7 @@ const NPCType* ZoneDatabase::GetNPCType (uint32 id) {
if (armor_tint_id == 0)
{
for (i = 1; i < _MaterialCount; i++)
for (i = MaterialChest; i <= EmuConstants::MATERIAL_END; i++)
{
tmpNPCType->armor_tint[i] = tmpNPCType->armor_tint[0];
}
@@ -1551,7 +1551,7 @@ const NPCType* ZoneDatabase::GetMercType(uint32 id, uint16 raceid, uint32 client
{
if ((at_row = mysql_fetch_row(at_result)))
{
for (i = 0; i < _MaterialCount; i++)
for (i = EmuConstants::MATERIAL_BEGIN; i <= EmuConstants::MATERIAL_END; i++)
{
tmpNPCType->armor_tint[i] = atoi(at_row[i * 3]) << 16;
tmpNPCType->armor_tint[i] |= atoi(at_row[i * 3 + 1]) << 8;
@@ -1584,7 +1584,7 @@ const NPCType* ZoneDatabase::GetMercType(uint32 id, uint16 raceid, uint32 client
if (armor_tint_id == 0)
{
for (i = 1; i < _MaterialCount; i++)
for (i = MaterialChest; i <= EmuConstants::MATERIAL_END; i++)
{
tmpNPCType->armor_tint[i] = tmpNPCType->armor_tint[0];
}
@@ -2774,7 +2774,7 @@ void ZoneDatabase::SavePetInfo(Client *c) {
}
}
for (i = 0; i<EmuConstants::EQUIPMENT_SIZE; i++) {
for (i = EmuConstants::EQUIPMENT_BEGIN; i <= EmuConstants::EQUIPMENT_END; i++) {
if(petinfo->Items[i]) {
database.RunQuery(query, MakeAnyLenString(&query,
"INSERT INTO `character_pet_inventory` (`char_id`, `pet`, `slot`, `item_id`) values (%u, 0, %u, %u)",
@@ -2798,7 +2798,7 @@ void ZoneDatabase::SavePetInfo(Client *c) {
}
safe_delete_array(query);
for (i = 0; i<EmuConstants::EQUIPMENT_SIZE; i++) {
for (i = EmuConstants::EQUIPMENT_BEGIN; i <= EmuConstants::EQUIPMENT_END; i++) {
if(suspended->Items[i]) {
database.RunQuery(query, MakeAnyLenString(&query,
"INSERT INTO `character_pet_inventory` (`char_id`, `pet`, `slot`, `item_id`) values (%u, 1, %u, %u)",
@@ -2931,7 +2931,7 @@ void ZoneDatabase::LoadPetInfo(Client *c) {
continue;
int slot = atoi(row[1]);
if (slot < 0 || slot > EmuConstants::EQUIPMENT_SIZE) // if (slot == 22) { zone.TriggerRandomCrash(); }
if (slot < EmuConstants::EQUIPMENT_BEGIN || slot > EmuConstants::EQUIPMENT_END)
continue;
pi->Items[slot] = atoul(row[2]);