mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[9636] Move item real-time/in-game duration counting flag to new extraflags field.
Client expected only positive duration values, so stop use duration field as signed.
This commit is contained in:
parent
8e25d43443
commit
d7c1e06d1b
11 changed files with 62 additions and 29 deletions
|
|
@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
|
||||||
`version` varchar(120) default NULL,
|
`version` varchar(120) default NULL,
|
||||||
`creature_ai_version` varchar(120) default NULL,
|
`creature_ai_version` varchar(120) default NULL,
|
||||||
`cache_id` int(10) default '0',
|
`cache_id` int(10) default '0',
|
||||||
`required_9622_01_mangos_gameobject` bit(1) default NULL
|
`required_9636_01_mangos_item_template` bit(1) default NULL
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
@ -2252,7 +2252,7 @@ CREATE TABLE `item_template` (
|
||||||
`GemProperties` mediumint(9) NOT NULL default '0',
|
`GemProperties` mediumint(9) NOT NULL default '0',
|
||||||
`RequiredDisenchantSkill` smallint(6) NOT NULL default '-1',
|
`RequiredDisenchantSkill` smallint(6) NOT NULL default '-1',
|
||||||
`ArmorDamageModifier` float NOT NULL default '0',
|
`ArmorDamageModifier` float NOT NULL default '0',
|
||||||
`Duration` int(11) NOT NULL default '0' COMMENT 'Duration in seconds. Negative value means realtime, postive value ingame time',
|
`Duration` int(11) UNSIGNED DEFAULT '0' NOT NULL COMMENT 'Duration in seconds.',
|
||||||
`ItemLimitCategory` smallint(6) NOT NULL default '0',
|
`ItemLimitCategory` smallint(6) NOT NULL default '0',
|
||||||
`HolidayId` int(11) UNSIGNED DEFAULT '0' NOT NULL,
|
`HolidayId` int(11) UNSIGNED DEFAULT '0' NOT NULL,
|
||||||
`ScriptName` varchar(64) NOT NULL default '',
|
`ScriptName` varchar(64) NOT NULL default '',
|
||||||
|
|
|
||||||
14
sql/updates/9636_01_mangos_item_template.sql
Normal file
14
sql/updates/9636_01_mangos_item_template.sql
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
ALTER TABLE db_version CHANGE COLUMN required_9622_01_mangos_gameobject required_9636_01_mangos_item_template bit;
|
||||||
|
|
||||||
|
ALTER TABLE item_template
|
||||||
|
CHANGE COLUMN NonConsumable ExtraFlags tinyint(1) UNSIGNED DEFAULT '0' NOT NULL;
|
||||||
|
|
||||||
|
UPDATE item_template
|
||||||
|
SET ExtraFlags = ExtraFlags | 0x2 WHERE Duration < 0 ;
|
||||||
|
|
||||||
|
UPDATE item_template
|
||||||
|
SET Duration = abs(Duration);
|
||||||
|
|
||||||
|
ALTER TABLE item_template
|
||||||
|
CHANGE COLUMN Duration Duration int(11) UNSIGNED DEFAULT '0' NOT NULL;
|
||||||
|
|
||||||
|
|
@ -95,6 +95,7 @@ pkgdata_DATA = \
|
||||||
9632_01_characters_characters.sql \
|
9632_01_characters_characters.sql \
|
||||||
9634_01_characters_corpse.sql \
|
9634_01_characters_corpse.sql \
|
||||||
9635_01_characters_characters.sql \
|
9635_01_characters_characters.sql \
|
||||||
|
9636_01_mangos_item_template.sql \
|
||||||
README
|
README
|
||||||
|
|
||||||
## Additional files to include when running 'make dist'
|
## Additional files to include when running 'make dist'
|
||||||
|
|
@ -170,4 +171,5 @@ EXTRA_DIST = \
|
||||||
9632_01_characters_characters.sql \
|
9632_01_characters_characters.sql \
|
||||||
9634_01_characters_corpse.sql \
|
9634_01_characters_corpse.sql \
|
||||||
9635_01_characters_characters.sql \
|
9635_01_characters_characters.sql \
|
||||||
|
9636_01_mangos_item_template.sql \
|
||||||
README
|
README
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,7 @@ bool Item::Create( uint32 guidlow, uint32 itemid, Player const* owner)
|
||||||
SetSpellCharges(i,itemProto->Spells[i].SpellCharges);
|
SetSpellCharges(i,itemProto->Spells[i].SpellCharges);
|
||||||
|
|
||||||
SetUInt32Value(ITEM_FIELD_FLAGS, itemProto->Flags);
|
SetUInt32Value(ITEM_FIELD_FLAGS, itemProto->Flags);
|
||||||
SetUInt32Value(ITEM_FIELD_DURATION, abs(itemProto->Duration));
|
SetUInt32Value(ITEM_FIELD_DURATION, itemProto->Duration);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -403,20 +403,20 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// update duration if need, and remove if not need
|
// update duration if need, and remove if not need
|
||||||
if((proto->Duration==0) != (GetUInt32Value(ITEM_FIELD_DURATION)==0))
|
if ((proto->Duration == 0) != (GetUInt32Value(ITEM_FIELD_DURATION) == 0))
|
||||||
{
|
{
|
||||||
SetUInt32Value(ITEM_FIELD_DURATION,abs(proto->Duration));
|
SetUInt32Value(ITEM_FIELD_DURATION, proto->Duration);
|
||||||
need_save = true;
|
need_save = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set correct owner
|
// set correct owner
|
||||||
if(owner_guid != 0 && GetOwnerGUID() != owner_guid)
|
if (owner_guid != 0 && GetOwnerGUID() != owner_guid)
|
||||||
{
|
{
|
||||||
SetOwnerGUID(owner_guid);
|
SetOwnerGUID(owner_guid);
|
||||||
need_save = true;
|
need_save = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(need_save) // normal item changed state set not work at loading
|
if (need_save) // normal item changed state set not work at loading
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << "UPDATE item_instance SET data = '";
|
ss << "UPDATE item_instance SET data = '";
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,7 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data )
|
||||||
data << pProto->GemProperties;
|
data << pProto->GemProperties;
|
||||||
data << pProto->RequiredDisenchantSkill;
|
data << pProto->RequiredDisenchantSkill;
|
||||||
data << pProto->ArmorDamageModifier;
|
data << pProto->ArmorDamageModifier;
|
||||||
data << abs(pProto->Duration); // added in 2.4.2.8209, duration (seconds)
|
data << pProto->Duration; // added in 2.4.2.8209, duration (seconds)
|
||||||
data << pProto->ItemLimitCategory; // WotLK, ItemLimitCategory
|
data << pProto->ItemLimitCategory; // WotLK, ItemLimitCategory
|
||||||
data << pProto->HolidayId; // Holiday.dbc?
|
data << pProto->HolidayId; // Holiday.dbc?
|
||||||
SendPacket( &data );
|
SendPacket( &data );
|
||||||
|
|
|
||||||
|
|
@ -469,6 +469,14 @@ inline uint8 ItemSubClassToDurabilityMultiplierId(uint32 ItemClass, uint32 ItemS
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ItemExtraFlags
|
||||||
|
{
|
||||||
|
ITEM_EXTRA_NON_CONSUMABLE = 0x01, // use as additional flag to spellcharges_N negative values, item not expire at no chanrges
|
||||||
|
ITEM_EXTRA_REAL_TIME_DURATION = 0x02, // if set and have Duration time, then offline time included in counting, if not set then counted only in game time
|
||||||
|
|
||||||
|
ITEM_EXTRA_ALL // all used flags, used for check DB data
|
||||||
|
};
|
||||||
|
|
||||||
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
|
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
|
||||||
#if defined( __GNUC__ )
|
#if defined( __GNUC__ )
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
@ -578,7 +586,7 @@ struct ItemPrototype
|
||||||
uint32 GemProperties; // id from GemProperties.dbc
|
uint32 GemProperties; // id from GemProperties.dbc
|
||||||
uint32 RequiredDisenchantSkill;
|
uint32 RequiredDisenchantSkill;
|
||||||
float ArmorDamageModifier;
|
float ArmorDamageModifier;
|
||||||
int32 Duration; // negative = realtime, positive = ingame time
|
uint32 Duration; // negative = realtime, positive = ingame time
|
||||||
uint32 ItemLimitCategory; // id from ItemLimitCategory.dbc
|
uint32 ItemLimitCategory; // id from ItemLimitCategory.dbc
|
||||||
uint32 HolidayId; // id from Holidays.dbc
|
uint32 HolidayId; // id from Holidays.dbc
|
||||||
uint32 ScriptId;
|
uint32 ScriptId;
|
||||||
|
|
@ -586,7 +594,7 @@ struct ItemPrototype
|
||||||
uint32 FoodType;
|
uint32 FoodType;
|
||||||
uint32 MinMoneyLoot;
|
uint32 MinMoneyLoot;
|
||||||
uint32 MaxMoneyLoot;
|
uint32 MaxMoneyLoot;
|
||||||
uint32 NonConsumable;
|
uint32 ExtraFlags; // see ItemExtraFlags
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
bool CanChangeEquipStateInCombat() const
|
bool CanChangeEquipStateInCombat() const
|
||||||
|
|
|
||||||
|
|
@ -2072,28 +2072,37 @@ void ObjectMgr::LoadItemPrototypes()
|
||||||
const_cast<ItemPrototype*>(proto)->HolidayId = 0;
|
const_cast<ItemPrototype*>(proto)->HolidayId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(proto->NonConsumable)
|
if(proto->ExtraFlags)
|
||||||
{
|
{
|
||||||
if (proto->NonConsumable > 1)
|
if (proto->ExtraFlags & ~ITEM_EXTRA_ALL)
|
||||||
{
|
sLog.outErrorDb("Item (Entry: %u) has wrong ExtraFlags (%u) with unused bits set",i,proto->ExtraFlags);
|
||||||
sLog.outErrorDb("Item (Entry: %u) has wrong NonConsumable (%u), must be 0..1",i,proto->NonConsumable);
|
|
||||||
const_cast<ItemPrototype*>(proto)->NonConsumable = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool can_be_need = false;
|
if (proto->ExtraFlags & ITEM_EXTRA_NON_CONSUMABLE)
|
||||||
for (int j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
|
|
||||||
{
|
{
|
||||||
if(proto->Spells[j].SpellCharges < 0)
|
bool can_be_need = false;
|
||||||
|
for (int j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
|
||||||
{
|
{
|
||||||
can_be_need = true;
|
if(proto->Spells[j].SpellCharges < 0)
|
||||||
break;
|
{
|
||||||
|
can_be_need = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!can_be_need)
|
||||||
|
{
|
||||||
|
sLog.outErrorDb("Item (Entry: %u) has redundant non-consumable flag in ExtraFlags, item not have negative charges", i);
|
||||||
|
const_cast<ItemPrototype*>(proto)->ExtraFlags &= ~ITEM_EXTRA_NON_CONSUMABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!can_be_need)
|
if (proto->ExtraFlags & ITEM_EXTRA_REAL_TIME_DURATION)
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("Item (Entry: %u) has redundant NonConsumable (%u), item not have negative charges",i,proto->NonConsumable);
|
if (proto->Duration == 0)
|
||||||
const_cast<ItemPrototype*>(proto)->NonConsumable = 0;
|
{
|
||||||
|
sLog.outErrorDb("Item (Entry: %u) has redundant real-time duration flag in ExtraFlags, item not have duration", i);
|
||||||
|
const_cast<ItemPrototype*>(proto)->ExtraFlags &= ~ITEM_EXTRA_REAL_TIME_DURATION;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11863,7 +11863,7 @@ void Player::UpdateItemDuration(uint32 time, bool realtimeonly)
|
||||||
Item* item = *itr;
|
Item* item = *itr;
|
||||||
++itr; // current element can be erased in UpdateDuration
|
++itr; // current element can be erased in UpdateDuration
|
||||||
|
|
||||||
if ((realtimeonly && item->GetProto()->Duration < 0) || !realtimeonly)
|
if ((realtimeonly && (item->GetProto()->ExtraFlags & ITEM_EXTRA_REAL_TIME_DURATION)) || !realtimeonly)
|
||||||
item->UpdateDuration(this,time);
|
item->UpdateDuration(this,time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3650,7 +3650,7 @@ void Spell::TakeCastItem()
|
||||||
// item has limited charges
|
// item has limited charges
|
||||||
if (proto->Spells[i].SpellCharges)
|
if (proto->Spells[i].SpellCharges)
|
||||||
{
|
{
|
||||||
if (proto->Spells[i].SpellCharges < 0 && !proto->NonConsumable)
|
if (proto->Spells[i].SpellCharges < 0 && !(proto->ExtraFlags & ITEM_EXTRA_NON_CONSUMABLE))
|
||||||
expendable = true;
|
expendable = true;
|
||||||
|
|
||||||
int32 charges = m_CastItem->GetSpellCharges(i);
|
int32 charges = m_CastItem->GetSpellCharges(i);
|
||||||
|
|
@ -5557,7 +5557,7 @@ SpellCastResult Spell::CheckItems()
|
||||||
{
|
{
|
||||||
// CastItem will be used up and does not count as reagent
|
// CastItem will be used up and does not count as reagent
|
||||||
int32 charges = m_CastItem->GetSpellCharges(s);
|
int32 charges = m_CastItem->GetSpellCharges(s);
|
||||||
if (proto->Spells[s].SpellCharges < 0 && !proto->NonConsumable && abs(charges) < 2)
|
if (proto->Spells[s].SpellCharges < 0 && !(proto->ExtraFlags & ITEM_EXTRA_NON_CONSUMABLE) && abs(charges) < 2)
|
||||||
{
|
{
|
||||||
++itemcount;
|
++itemcount;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "9635"
|
#define REVISION_NR "9636"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#ifndef __REVISION_SQL_H__
|
#ifndef __REVISION_SQL_H__
|
||||||
#define __REVISION_SQL_H__
|
#define __REVISION_SQL_H__
|
||||||
#define REVISION_DB_CHARACTERS "required_9635_01_characters_characters"
|
#define REVISION_DB_CHARACTERS "required_9635_01_characters_characters"
|
||||||
#define REVISION_DB_MANGOS "required_9622_01_mangos_gameobject"
|
#define REVISION_DB_MANGOS "required_9636_01_mangos_item_template"
|
||||||
#define REVISION_DB_REALMD "required_9010_01_realmd_realmlist"
|
#define REVISION_DB_REALMD "required_9010_01_realmd_realmlist"
|
||||||
#endif // __REVISION_SQL_H__
|
#endif // __REVISION_SQL_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue