Skip to content

Commit

Permalink
Merge remote branch 'mr2/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
DoesntMatter committed Jun 20, 2011
2 parents 33dedba + 8d87ce9 commit e23f283
Show file tree
Hide file tree
Showing 28 changed files with 667 additions and 400 deletions.
24 changes: 22 additions & 2 deletions sql/mangos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`cache_id` int(10) default '0',
`required_11613_01_mangos_spell_bonus_data` bit(1) default NULL
`required_11646_01_mangos_item_expire_convert` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';

--
Expand Down Expand Up @@ -2193,7 +2193,7 @@ CREATE TABLE `item_convert` (
`entry` mediumint(8) unsigned NOT NULL default '0',
`item` mediumint(8) unsigned NOT NULL default '0',
PRIMARY KEY (`entry`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Npc System';
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item Convert System';

--
-- Dumping data for table `item_convert`
Expand Down Expand Up @@ -2225,6 +2225,26 @@ LOCK TABLES `item_enchantment_template` WRITE;
/*!40000 ALTER TABLE `item_enchantment_template` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `item_expire_convert`
--

DROP TABLE IF EXISTS `item_expire_convert`;
CREATE TABLE `item_expire_convert` (
`entry` mediumint(8) unsigned NOT NULL default '0',
`item` mediumint(8) unsigned NOT NULL default '0',
PRIMARY KEY (`entry`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item Convert System';

--
-- Dumping data for table `item_convert`
--

LOCK TABLES `item_convert` WRITE;
/*!40000 ALTER TABLE `item_convert` DISABLE KEYS */;
/*!40000 ALTER TABLE `item_convert` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `item_loot_template`
--
Expand Down
10 changes: 10 additions & 0 deletions sql/updates/11646_01_mangos_item_expire_convert.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ALTER TABLE db_version CHANGE COLUMN required_11613_01_mangos_spell_bonus_data required_11646_01_mangos_item_expire_convert bit;

DROP TABLE IF EXISTS `item_expire_convert`;
CREATE TABLE `item_expire_convert` (
`entry` mediumint(8) unsigned NOT NULL default '0',
`item` mediumint(8) unsigned NOT NULL default '0',
PRIMARY KEY (`entry`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Item Convert System';

INSERT INTO `item_expire_convert` VALUES (44623, 44625), (44625, 44627);
8 changes: 2 additions & 6 deletions src/game/BattleGround.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1354,14 +1354,8 @@ void BattleGround::AddPlayer(Player *plr)
plr->UnsummonPetTemporaryIfAny();

if(GetStatus() == STATUS_WAIT_JOIN) // not started yet
{
plr->CastSpell(plr, SPELL_ARENA_PREPARATION, true);

plr->SetHealth(plr->GetMaxHealth());
plr->SetPower(POWER_MANA, plr->GetMaxPower(POWER_MANA));
plr->SetPower(POWER_RAGE, 0);
}

plr->CastSpell(plr, SPELL_ARENA_DAMPENING, true);
}
else
Expand All @@ -1370,6 +1364,8 @@ void BattleGround::AddPlayer(Player *plr)

if(GetStatus() == STATUS_WAIT_JOIN) // not started yet
plr->CastSpell(plr, SPELL_PREPARATION, true); // reduces all mana cost of spells.

plr->CastSpell(plr, SPELL_BATTLEGROUND_DAMPENING, true);
}

plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, ACHIEVEMENT_CRITERIA_CONDITION_MAP, GetMapId());
Expand Down
4 changes: 2 additions & 2 deletions src/game/BattleGround.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ enum BattleGroundSpells
SPELL_PREPARATION = 44521, // Preparation
SPELL_RECENTLY_DROPPED_FLAG = 42792, // Recently Dropped Flag
SPELL_AURA_PLAYER_INACTIVE = 43681, // Inactive
SPELL_ARENA_DAMPENING = 74410, // 10% healing reduction
SPELL_BATTLEGROUND_DAMPENING = 74411, // 10% healing reduction
SPELL_ARENA_DAMPENING = 74410, // Arena - Dampening
SPELL_BATTLEGROUND_DAMPENING = 74411, // Battleground - Dampening
};

enum BattleGroundTimeIntervals
Expand Down
2 changes: 1 addition & 1 deletion src/game/BattleGroundMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ void BattleGroundMgr::Update(uint32 diff)
if (sWorld.GetGameTime() > m_NextAutoDistributionTime)
{
DistributeArenaPoints();
m_NextAutoDistributionTime = time_t(sWorld.GetGameTime() + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld.getConfig(CONFIG_UINT32_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS));
m_NextAutoDistributionTime = time_t(m_NextAutoDistributionTime + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld.getConfig(CONFIG_UINT32_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS));
CharacterDatabase.PExecute("UPDATE saved_variables SET NextArenaPointDistributionTime = '"UI64FMTD"'", uint64(m_NextAutoDistributionTime));
}
m_AutoDistributionTimeChecker = 600000; // check 10 minutes
Expand Down
19 changes: 4 additions & 15 deletions src/game/Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,21 +280,10 @@ void Item::UpdateDuration(Player* owner, uint32 diff)

if (GetUInt32Value(ITEM_FIELD_DURATION) <= diff)
{
uint32 itemId = this->GetEntry();

owner->DestroyItem(GetBagSlot(), GetSlot(), true);

if (itemId == 39878) //Mysterious Egg
{
if (Item* Item = owner->StoreNewItemInInventorySlot(39883, 1))
owner->SendNewItem(Item, 1, true, false);
}

if (itemId == 44717) //Disgusting Jar
{
if (Item* Item = owner->StoreNewItemInInventorySlot(44718, 1))
owner->SendNewItem(Item, 1, true, false);
}
if (uint32 newItemId = sObjectMgr.GetItemExpireConvert(GetEntry()))
owner->ConvertItem(this, newItemId);
else
owner->DestroyItem(GetBagSlot(), GetSlot(), true);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/game/ItemHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,9 +801,9 @@ void WorldSession::SendListInventory(ObjectGuid vendorguid)
// convert if can use and then buy
if (pProto->RequiredReputationFaction && uint32(_player->GetReputationRank(pProto->RequiredReputationFaction)) >= pProto->RequiredReputationRank)
{
itemId = sObjectMgr.GetItemConvert(itemId, _player->getRaceMask());
// checked at convert data loading as existed
pProto = ObjectMgr::GetItemPrototype(itemId);
if (uint32 newItemId = sObjectMgr.GetItemConvert(itemId, _player->getRaceMask()))
pProto = ObjectMgr::GetItemPrototype(newItemId);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/game/MailHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,8 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data )
Item *it = pl->GetMItem(itemId);

ItemPosCountVec dest;
uint8 msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, it, false );
if( msg == EQUIP_ERR_OK )
InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, it, false );
if (msg == EQUIP_ERR_OK)
{
m->RemoveItem(itemId);
m->removedItems.push_back(itemId);
Expand Down Expand Up @@ -793,8 +793,8 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data )
DETAIL_LOG("HandleMailCreateTextItem mailid=%u", mailId);

ItemPosCountVec dest;
uint8 msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, bodyItem, false );
if( msg == EQUIP_ERR_OK )
InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, dest, bodyItem, false );
if (msg == EQUIP_ERR_OK)
{
m->checked = m->checked | MAIL_CHECK_MASK_COPIED;
m->state = MAIL_STATE_CHANGED;
Expand Down
30 changes: 8 additions & 22 deletions src/game/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,6 @@ void Object::_InitValues()
m_objectUpdated = false;
}

void Object::_Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
{
if(!m_uint32Values)
_InitValues();

ObjectGuid guid = ObjectGuid(guidhigh, entry, guidlow);
_Create(guid);
}

void Object::_Create(ObjectGuid guid)
{
if(!m_uint32Values)
Expand Down Expand Up @@ -255,9 +246,9 @@ void Object::DestroyForPlayer( Player *target, bool anim ) const

void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
{
/* removed by zergtmn. strange...
uint16 moveFlags2 = (isType(TYPEMASK_UNIT) ? ((Unit*)this)->m_movementInfo.GetMovementFlags2() : MOVEFLAG2_NONE);
/* removed by zergtmn. strange...
if(GetTypeId() == TYPEID_UNIT)
if(((Creature*)this)->GetVehicleKit())
moveFlags2 |= MOVEFLAG2_ALLOW_PITCHING; // always allow pitch
Expand Down Expand Up @@ -1141,8 +1132,8 @@ void Object::MarkForClientUpdate()
}

WorldObject::WorldObject()
: m_isActiveObject(false), m_currMap(NULL), m_mapId(0), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL),
m_groupLootTimer(0), m_groupLootId(0), m_lootGroupRecipientId(0), m_name("")
: m_groupLootTimer(0), m_groupLootId(0), m_lootGroupRecipientId(0),
m_isActiveObject(false), m_currMap(NULL), m_mapId(0), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL)
{
}

Expand Down Expand Up @@ -2352,17 +2343,12 @@ void WorldObject::SetLootRecipient(Unit *unit)
}

// Frozen Mod
void Object::ForceValuesUpdateAtIndex(uint32 i)
void Object::ForceValuesUpdateAtIndex(uint16 index)
{
m_uint32Values_mirror[i] = GetUInt32Value(i) + 1; // makes server think the field changed
if(m_inWorld)
{
if(!m_objectUpdated)
{
AddToClientUpdateList();
m_objectUpdated = true;
}
}
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) );

m_uint32Values_mirror[index] = m_uint32Values[index] + 1; // makes server think the field changed
MarkForClientUpdate();
}
// Frozen Mod

Expand Down
4 changes: 2 additions & 2 deletions src/game/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class MANGOS_DLL_SPEC Object
void InitValues() { _InitValues(); }

// Frozen Mod
void ForceValuesUpdateAtIndex(uint32);
void ForceValuesUpdateAtIndex(uint16);
// Frozen Mod

virtual bool HasQuest(uint32 /* quest_id */) const { return false; }
Expand All @@ -371,7 +371,7 @@ class MANGOS_DLL_SPEC Object
Object ( );

void _InitValues();
void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh);
void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh) { _Create(ObjectGuid(guidhigh, entry, guidlow)); }
void _Create(ObjectGuid guid);

virtual void _SetUpdateBits(UpdateMask *updateMask, Player *target) const;
Expand Down
60 changes: 60 additions & 0 deletions src/game/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,66 @@ void ObjectMgr::LoadItemConverts()
sLog.outString(">> Loaded %u Item converts", count);
}

void ObjectMgr::LoadItemExpireConverts()
{
m_ItemExpireConvert.clear(); // needed for reload case

uint32 count = 0;

QueryResult *result = WorldDatabase.Query("SELECT entry,item FROM item_expire_convert");

if (!result)
{
BarGoLink bar(1);

bar.step();

sLog.outString();
sLog.outErrorDb(">> Loaded 0 Item expire converts . DB table `item_expire_convert` is empty.");
return;
}

BarGoLink bar(result->GetRowCount());

do
{
Field *fields = result->Fetch();
bar.step();

uint32 itemEntry = fields[0].GetUInt32();
uint32 itemTargetId = fields[1].GetUInt32();

ItemPrototype const* pItemEntryProto = sItemStorage.LookupEntry<ItemPrototype>(itemEntry);
if (!pItemEntryProto)
{
sLog.outErrorDb("Table `item_expire_convert`: Item %u not exist in `item_template`.", itemEntry);
continue;
}

ItemPrototype const* pItemTargetProto = sItemStorage.LookupEntry<ItemPrototype>(itemTargetId);
if (!pItemTargetProto)
{
sLog.outErrorDb("Table `item_expire_convert`: Item target %u for original item %u not exist in `item_template`.", itemTargetId, itemEntry);
continue;
}

// Expire convert possible only for items with duration
if (pItemEntryProto->Duration == 0)
{
sLog.outErrorDb("Table `item_expire_convert` not appropriate item %u conversion to %u. Table can be used for items with duration.", itemEntry, itemTargetId);
continue;
}

m_ItemExpireConvert[itemEntry] = itemTargetId;

++count;
} while (result->NextRow());

delete result;

sLog.outString();
sLog.outString(">> Loaded %u Item expire converts", count);
}

void ObjectMgr::LoadItemRequiredTarget()
{
Expand Down
17 changes: 13 additions & 4 deletions src/game/ObjectMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ typedef std::pair<QuestRelationsMap::const_iterator, QuestRelationsMap::const_it

struct PetLevelInfo
{
PetLevelInfo() : health(0), mana(0) { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; }
PetLevelInfo(): health(0), mana(0), armor(0), mindmg(0), maxdmg(0), attackpower(0)
{ for (int i = 0; i < MAX_STATS; ++i) stats[i] = 0; }

uint16 stats[MAX_STATS];
uint16 health;
Expand Down Expand Up @@ -760,8 +761,9 @@ class ObjectMgr
void LoadEquipmentTemplates();
void LoadGameObjectLocales();
void LoadGameobjects();
void LoadItemConverts();
void LoadItemPrototypes();
void LoadItemConverts();
void LoadItemExpireConverts();
void LoadItemRequiredTarget();
void LoadItemLocales();
void LoadQuestLocales();
Expand Down Expand Up @@ -1117,10 +1119,16 @@ class ObjectMgr
{
ItemConvertMap::const_iterator iter = m_ItemConvert.find(itemEntry);
if (iter == m_ItemConvert.end())
return itemEntry;
return 0;

ItemPrototype const* proto = GetItemPrototype(iter->second);
return (proto && proto->AllowableRace & raceMask) ? iter->second : itemEntry;
return (proto && proto->AllowableRace & raceMask) ? iter->second : 0;
}

uint32 GetItemExpireConvert(uint32 itemEntry) const
{
ItemConvertMap::const_iterator iter = m_ItemExpireConvert.find(itemEntry);
return iter != m_ItemExpireConvert.end() ? iter->second : 0;
}

ItemRequiredTargetMapBounds GetItemRequiredTargetMapBounds(uint32 uiItemEntry) const
Expand Down Expand Up @@ -1236,6 +1244,7 @@ class ObjectMgr
SpellClickInfoMap mSpellClickInfoMap;

ItemConvertMap m_ItemConvert;
ItemConvertMap m_ItemExpireConvert;
ItemRequiredTargetMap m_ItemRequiredTarget;

VehicleAccessoryMap m_VehicleAccessoryMap;
Expand Down
8 changes: 1 addition & 7 deletions src/game/Pet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1327,13 +1327,7 @@ void Pet::_LoadAuras(uint32 timediff)
}

// prevent wrong values of remaincharges
uint32 procCharges = spellproto->procCharges;
if (procCharges)
{
if (remaincharges <= 0 || remaincharges > procCharges)
remaincharges = procCharges;
}
else
if (spellproto->procCharges == 0)
remaincharges = 0;

if (!spellproto->StackAmount)
Expand Down
Loading

0 comments on commit e23f283

Please sign in to comment.