void Item::LoadFromDB(Field* fields, Player* plr, bool light ) { uint32 itemid = fields[2].GetUInt32(); uint32 random_prop, random_suffix; uint32 count; m_itemProto = ItemPrototypeStorage.LookupEntry( itemid ); ASSERT( m_itemProto ); if(m_itemProto->LockId > 1) locked = true; else locked = false; SetUInt32Value( OBJECT_FIELD_ENTRY, itemid ); m_owner = plr; wrapped_item_id=fields[3].GetUInt32(); m_uint32Values[ITEM_FIELD_GIFTCREATOR] = fields[4].GetUInt32(); m_uint32Values[ITEM_FIELD_CREATOR] = fields[5].GetUInt32(); count = fields[6].GetUInt32(); if (count > m_itemProto->MaxCount) count = m_itemProto->MaxCount; SetUInt32Value( ITEM_FIELD_STACK_COUNT, count); // Again another for that did not indent to make it do anything for more than // one iteration x == 0 was the only one executed for( uint32 x = 0; x < 5; x++ ) { if( m_itemProto->Spells[x].Id ) { SetUInt32Value( ITEM_FIELD_SPELL_CHARGES + x , fields[7].GetUInt32() ); break; } } SetUInt32Value( ITEM_FIELD_FLAGS, fields[8].GetUInt32() ); random_prop = fields[9].GetUInt32(); random_suffix = fields[10].GetUInt32(); if( random_prop ) SetRandomProperty( random_prop ); else if( random_suffix ) SetRandomSuffix( random_suffix ); SetUInt32Value( ITEM_FIELD_ITEM_TEXT_ID, fields[11].GetUInt32() ); SetUInt32Value( ITEM_FIELD_MAXDURABILITY, m_itemProto->MaxDurability ); SetUInt32Value( ITEM_FIELD_DURABILITY, fields[12].GetUInt32() ); if( light ) return; string enchant_field = fields[15].GetString(); vector< string > enchants = StrSplit( enchant_field, ";" ); uint32 enchant_id; EnchantEntry* entry; uint32 time_left; uint32 enchslot; for( vector<string>::iterator itr = enchants.begin(); itr != enchants.end(); ++itr ) { if( sscanf( (*itr).c_str(), "%u,%u,%u", (unsigned int*)&enchant_id, (unsigned int*)&time_left, (unsigned int*)&enchslot) == 3 ) { entry = dbcEnchant.LookupEntry( enchant_id ); if( entry && entry->Id == enchant_id && m_itemProto->SubClass != ITEM_SUBCLASS_WEAPON_THROWN) { AddEnchantment( entry, time_left, ( time_left == 0 ), false, false, enchslot ); //(enchslot != 2) ? false : true, false); } else { /* EnchantEntry *pEnchant = new EnchantEntry; memset(pEnchant,0,sizeof(EnchantEntry)); pEnchant->Id = enchant_id; if(enchslot != 2) AddEnchantment(pEnchant,0,true, false); else AddEnchantment(pEnchant,0,false,false); */ } } } ApplyRandomProperties( false ); // Charter stuff if(m_uint32Values[OBJECT_FIELD_ENTRY] == ITEM_ENTRY_GUILD_CHARTER) { SetUInt32Value( ITEM_FIELD_FLAGS, 1 ); SetUInt32Value( ITEM_FIELD_STACK_COUNT, 1 ); SetUInt32Value( ITEM_FIELD_PROPERTY_SEED, 57813883 ); if( plr->m_charters[CHARTER_TYPE_GUILD] ) SetUInt32Value( ITEM_FIELD_ENCHANTMENT, plr->m_charters[CHARTER_TYPE_GUILD]->GetID() ); } if( m_uint32Values[OBJECT_FIELD_ENTRY] == ARENA_TEAM_CHARTER_2v2 ) { SetUInt32Value( ITEM_FIELD_FLAGS, 1 ); SetUInt32Value( ITEM_FIELD_STACK_COUNT, 1 ); SetUInt32Value( ITEM_FIELD_PROPERTY_SEED, 57813883 ); if( plr->m_charters[CHARTER_TYPE_ARENA_2V2] ) SetUInt32Value( ITEM_FIELD_ENCHANTMENT, plr->m_charters[CHARTER_TYPE_ARENA_2V2]->GetID() ); } if( m_uint32Values[OBJECT_FIELD_ENTRY] == ARENA_TEAM_CHARTER_3v3 ) { SetUInt32Value( ITEM_FIELD_FLAGS, 1 ); SetUInt32Value( ITEM_FIELD_STACK_COUNT, 1 ); SetUInt32Value( ITEM_FIELD_PROPERTY_SEED, 57813883 ); if( plr->m_charters[CHARTER_TYPE_ARENA_3V3] ) SetUInt32Value( ITEM_FIELD_ENCHANTMENT, plr->m_charters[CHARTER_TYPE_ARENA_3V3]->GetID() ); } if( m_uint32Values[OBJECT_FIELD_ENTRY] == ARENA_TEAM_CHARTER_5v5 ) { SetUInt32Value( ITEM_FIELD_FLAGS, 1 ); SetUInt32Value( ITEM_FIELD_STACK_COUNT, 1 ); SetUInt32Value( ITEM_FIELD_PROPERTY_SEED, 57813883 ); if( plr->m_charters[CHARTER_TYPE_ARENA_5V5] ) SetUInt32Value( ITEM_FIELD_ENCHANTMENT, plr->m_charters[CHARTER_TYPE_ARENA_5V5]->GetID() ); } }
void Item::LoadFromDB(Field* fields, Player* plr, bool light ) { int32 count; uint32 itemid = fields[2].GetUInt32(), random_prop = fields[9].GetUInt32(), random_suffix = fields[10].GetUInt32(); m_itemProto = ItemPrototypeStorage.LookupEntry( itemid ); ASSERT( m_itemProto ); if(m_itemProto->LockId > 1) locked = true; else locked = false; SetUInt32Value( OBJECT_FIELD_ENTRY, itemid ); m_owner = plr; wrapped_item_id=fields[3].GetUInt32(); m_uint32Values[ITEM_FIELD_GIFTCREATOR] = fields[4].GetUInt32(); m_uint32Values[ITEM_FIELD_CREATOR] = fields[5].GetUInt32(); count = fields[6].GetUInt32(); if(m_itemProto->MaxCount > 0 && count > m_itemProto->MaxCount) count = m_itemProto->MaxCount; SetUInt32Value( ITEM_FIELD_STACK_COUNT, count); // Again another for that did not indent to make it do anything for more than // one iteration x == 0 was the only one executed for( uint32 x = 0; x < 5; x++ ) { if( m_itemProto->Spells[x].Id ) { SetUInt32Value( ITEM_FIELD_SPELL_CHARGES + x , fields[7].GetUInt32() ); break; } } SetUInt32Value( ITEM_FIELD_FLAGS, fields[8].GetUInt32() ); Bind(ITEM_BIND_ON_PICKUP); // Check if we need to bind our shit. if( random_prop ) SetRandomProperty( random_prop ); else if( random_suffix ) SetRandomSuffix( random_suffix ); SetTextID( fields[11].GetUInt32() ); SetUInt32Value( ITEM_FIELD_MAXDURABILITY, m_itemProto->MaxDurability ); SetUInt32Value( ITEM_FIELD_DURABILITY, fields[12].GetUInt32() ); if( light ) return; string enchant_field = fields[15].GetString(); vector< string > enchants = StrSplit( enchant_field, ";" ); uint32 enchant_id; EnchantEntry* entry; uint32 time_left; uint32 enchslot; uint32 dummy = 0; for( vector<string>::iterator itr = enchants.begin(); itr != enchants.end(); itr++ ) { if( sscanf( (*itr).c_str(), "%u,%u,%u,%u", (unsigned int*)&enchant_id, (unsigned int*)&time_left, (unsigned int*)&enchslot, (unsigned int*)&dummy) > 3 ) { entry = dbcEnchant.LookupEntry( enchant_id ); if( entry && entry->Id == enchant_id ) { AddEnchantment( entry, time_left, ( time_left == 0 ), false, false, enchslot, 0, ((dummy > 0) ? true : false) ); //(enchslot != 2) ? false : true, false); } } } string gem_field = fields[16].GetString(); for( uint8 k = 0; k < 3; k++ ) sscanf( gem_field.c_str(), GemReadFormat[k], &Gems[k]); ApplyRandomProperties( false ); Charter* charter = guildmgr.GetCharterByItemGuid(GetLowGUID()); if(charter != NULL) { SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, charter->GetID()); // Charter stuff if(m_uint32Values[OBJECT_FIELD_ENTRY] == ITEM_ENTRY_GUILD_CHARTER) { SetUInt32Value( ITEM_FIELD_STACK_COUNT, 1 ); SetUInt32Value( ITEM_FIELD_PROPERTY_SEED, 57813883 ); if( plr->m_playerInfo->charterId[CHARTER_TYPE_GUILD] ) SetUInt32Value( ITEM_FIELD_ENCHANTMENT_1_1, plr->m_playerInfo->charterId[CHARTER_TYPE_GUILD] ); } if( m_uint32Values[OBJECT_FIELD_ENTRY] == ARENA_TEAM_CHARTER_2v2 ) { SetUInt32Value( ITEM_FIELD_STACK_COUNT, 1 ); SetUInt32Value( ITEM_FIELD_PROPERTY_SEED, 57813883 ); if( plr->m_playerInfo->charterId[CHARTER_TYPE_ARENA_2V2] ) SetUInt32Value( ITEM_FIELD_ENCHANTMENT_1_1, plr->m_playerInfo->charterId[CHARTER_TYPE_ARENA_2V2] ); } if( m_uint32Values[OBJECT_FIELD_ENTRY] == ARENA_TEAM_CHARTER_3v3 ) { SetUInt32Value( ITEM_FIELD_STACK_COUNT, 1 ); SetUInt32Value( ITEM_FIELD_PROPERTY_SEED, 57813883 ); if( plr->m_playerInfo->charterId[CHARTER_TYPE_ARENA_3V3] ) SetUInt32Value( ITEM_FIELD_ENCHANTMENT_1_1, plr->m_playerInfo->charterId[CHARTER_TYPE_ARENA_3V3] ); } if( m_uint32Values[OBJECT_FIELD_ENTRY] == ARENA_TEAM_CHARTER_5v5 ) { SetUInt32Value( ITEM_FIELD_STACK_COUNT, 1 ); SetUInt32Value( ITEM_FIELD_PROPERTY_SEED, 57813883 ); if( plr->m_playerInfo->charterId[CHARTER_TYPE_ARENA_5V5] ) SetUInt32Value( ITEM_FIELD_ENCHANTMENT_1_1, plr->m_playerInfo->charterId[CHARTER_TYPE_ARENA_5V5] ); } } }