mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[7908] Extract class data from creature_*_addon bytes0 fields, drop its, amd add unit_class field to creature_template.
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
39637858aa
commit
84464e5f3f
12 changed files with 65 additions and 16 deletions
|
|
@ -23,7 +23,7 @@ DROP TABLE IF EXISTS `db_version`;
|
|||
CREATE TABLE `db_version` (
|
||||
`version` varchar(120) default NULL,
|
||||
`creature_ai_version` varchar(120) default NULL,
|
||||
`required_7904_01_mangos_creature_template` bit(1) default NULL
|
||||
`required_7908_03_mangos_creature_template_addon` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
||||
|
||||
--
|
||||
|
|
@ -564,7 +564,6 @@ DROP TABLE IF EXISTS `creature_addon`;
|
|||
CREATE TABLE `creature_addon` (
|
||||
`guid` int(11) NOT NULL default '0',
|
||||
`mount` mediumint(8) unsigned NOT NULL default '0',
|
||||
`bytes0` int(10) unsigned NOT NULL default '0',
|
||||
`bytes1` int(10) unsigned NOT NULL default '0',
|
||||
`bytes2` int(10) unsigned NOT NULL default '0',
|
||||
`emote` int(10) unsigned NOT NULL default '0',
|
||||
|
|
@ -816,6 +815,7 @@ CREATE TABLE `creature_template` (
|
|||
`dmg_multiplier` float NOT NULL default '1',
|
||||
`baseattacktime` int(10) unsigned NOT NULL default '0',
|
||||
`rangeattacktime` int(10) unsigned NOT NULL default '0',
|
||||
`unit_class` tinyint(3) unsigned NOT NULL default '0',
|
||||
`unit_flags` int(10) unsigned NOT NULL default '0',
|
||||
`dynamicflags` int(10) unsigned NOT NULL default '0',
|
||||
`family` tinyint(4) NOT NULL default '0',
|
||||
|
|
@ -865,7 +865,7 @@ CREATE TABLE `creature_template` (
|
|||
LOCK TABLES `creature_template` WRITE;
|
||||
/*!40000 ALTER TABLE `creature_template` DISABLE KEYS */;
|
||||
INSERT INTO `creature_template` VALUES
|
||||
(1,0,10045,0,10045,0,'Waypoint(Only GM can see it)','Visual',NULL,1,1,64,64,0,0,0,35,35,0,0.91,1,0,14,15,0,100,2000,2200,4096,0,0,0,0,0,0,1.76,2.42,100,8,5242886,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,3,1.0,1.0,0,1,0,0,0x82,'');
|
||||
(1,0,10045,0,10045,0,'Waypoint(Only GM can see it)','Visual',NULL,1,1,64,64,0,0,0,35,35,0,0.91,1,0,14,15,0,100,1,2000,2200,8,4096,0,0,0,0,0,0,1.76,2.42,100,8,5242886,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',0,3,1.0,1.0,0,1,0,0,0x82,'');
|
||||
/*!40000 ALTER TABLE `creature_template` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
|
@ -877,7 +877,6 @@ DROP TABLE IF EXISTS `creature_template_addon`;
|
|||
CREATE TABLE `creature_template_addon` (
|
||||
`entry` mediumint(8) unsigned NOT NULL default '0',
|
||||
`mount` mediumint(8) unsigned NOT NULL default '0',
|
||||
`bytes0` int(10) unsigned NOT NULL default '0',
|
||||
`bytes1` int(10) unsigned NOT NULL default '0',
|
||||
`bytes2` int(10) unsigned NOT NULL default '0',
|
||||
`emote` mediumint(8) unsigned NOT NULL default '0',
|
||||
|
|
|
|||
17
sql/updates/7908_01_mangos_creature_template.sql
Normal file
17
sql/updates/7908_01_mangos_creature_template.sql
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
ALTER TABLE db_version CHANGE COLUMN required_7904_01_mangos_creature_template required_7908_01_mangos_creature_template bit;
|
||||
|
||||
ALTER TABLE creature_template ADD COLUMN unit_class tinyint(3) unsigned NOT NULL default '0' AFTER rangeattacktime;
|
||||
|
||||
UPDATE creature_template ct
|
||||
JOIN creature c ON ct.entry=c.id
|
||||
JOIN creature_addon ad ON c.guid=ad.guid
|
||||
SET ct.unit_class=(ad.bytes0 & 0x0000FF00) >> 8
|
||||
WHERE ct.entry=c.id AND ct.unit_class=0;
|
||||
|
||||
UPDATE creature_template ct
|
||||
JOIN creature_template_addon ad ON ct.entry=ad.entry
|
||||
SET ct.unit_class=(ad.bytes0 & 0x0000FF00) >> 8
|
||||
WHERE ct.entry=ad.entry AND ct.unit_class=0;
|
||||
|
||||
UPDATE creature_template a1, creature_template a2 SET a1.unit_class=a2.unit_class WHERE a1.unit_class=0 AND a2.unit_class!=0 AND a1.entry=a2.heroic_entry;
|
||||
UPDATE creature_template a1, creature_template a2 SET a1.unit_class=a2.unit_class WHERE a1.unit_class=0 AND a2.unit_class!=0 AND a2.entry=a1.heroic_entry;
|
||||
4
sql/updates/7908_02_mangos_creature_addon.sql
Normal file
4
sql/updates/7908_02_mangos_creature_addon.sql
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE db_version CHANGE COLUMN required_7908_01_mangos_creature_template required_7908_02_mangos_creature_addon bit;
|
||||
|
||||
ALTER TABLE creature_addon
|
||||
DROP COLUMN bytes0;
|
||||
4
sql/updates/7908_03_mangos_creature_template_addon.sql
Normal file
4
sql/updates/7908_03_mangos_creature_template_addon.sql
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE db_version CHANGE COLUMN required_7908_02_mangos_creature_addon required_7908_03_mangos_creature_template_addon bit;
|
||||
|
||||
ALTER TABLE creature_template_addon
|
||||
DROP COLUMN bytes0;
|
||||
|
|
@ -205,6 +205,9 @@ pkgdata_DATA = \
|
|||
7902_02_mangos_pool_gameobject.sql \
|
||||
7903_01_characters_character_pet.sql \
|
||||
7904_01_mangos_creature_template.sql \
|
||||
7908_01_mangos_creature_template.sql \
|
||||
7908_02_mangos_creature_addon.sql \
|
||||
7908_03_mangos_creature_template_addon.sql \
|
||||
README
|
||||
|
||||
## Additional files to include when running 'make dist'
|
||||
|
|
@ -390,4 +393,7 @@ EXTRA_DIST = \
|
|||
7902_02_mangos_pool_gameobject.sql \
|
||||
7903_01_characters_character_pet.sql \
|
||||
7904_01_mangos_creature_template.sql \
|
||||
7908_01_mangos_creature_template.sql \
|
||||
7908_02_mangos_creature_addon.sql \
|
||||
7908_03_mangos_creature_template_addon.sql \
|
||||
README
|
||||
|
|
|
|||
|
|
@ -197,6 +197,12 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
|
|||
SetEntry(Entry); // normal entry always
|
||||
m_creatureInfo = cinfo; // map mode related always
|
||||
|
||||
// equal to player Race field, but creature does not have race
|
||||
SetByteValue(UNIT_FIELD_BYTES_0, 0, 0);
|
||||
|
||||
// known valid are: CLASS_WARRIOR,CLASS_PALADIN,CLASS_ROGUE,CLASS_MAGE
|
||||
SetByteValue(UNIT_FIELD_BYTES_0, 1, uint8(cinfo->unit_class));
|
||||
|
||||
if (cinfo->DisplayID_A == 0 || cinfo->DisplayID_H == 0) // Cancel load if no model defined
|
||||
{
|
||||
sLog.outErrorDb("Creature (Entry: %u) has no model defined for Horde or Alliance in table `creature_template`, can't load. ",Entry);
|
||||
|
|
@ -1204,6 +1210,8 @@ void Creature::SelectLevel(const CreatureInfo *cinfo)
|
|||
SetMaxPower(POWER_MANA, mana); //MAX Mana
|
||||
SetPower(POWER_MANA, mana);
|
||||
|
||||
// TODO: set UNIT_FIELD_POWER*, for some creature class case (energy, etc)
|
||||
|
||||
SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, health);
|
||||
SetModifierValue(UNIT_MOD_MANA, BASE_VALUE, mana);
|
||||
|
||||
|
|
@ -1860,9 +1868,6 @@ bool Creature::LoadCreaturesAddon(bool reload)
|
|||
if (cainfo->mount != 0)
|
||||
Mount(cainfo->mount);
|
||||
|
||||
if (cainfo->bytes0 != 0)
|
||||
SetUInt32Value(UNIT_FIELD_BYTES_0, cainfo->bytes0);
|
||||
|
||||
if (cainfo->bytes1 != 0)
|
||||
SetUInt32Value(UNIT_FIELD_BYTES_1, cainfo->bytes1);
|
||||
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ struct CreatureInfo
|
|||
float dmg_multiplier;
|
||||
uint32 baseattacktime;
|
||||
uint32 rangeattacktime;
|
||||
uint32 unit_class; // enum Classes. Note only 4 classes are known for creatures.
|
||||
uint32 unit_flags; // enum UnitFlags mask values
|
||||
uint32 dynamicflags;
|
||||
uint32 family; // enum CreatureFamily values (optional)
|
||||
|
|
@ -296,7 +297,6 @@ struct CreatureDataAddon
|
|||
{
|
||||
uint32 guidOrEntry;
|
||||
uint32 mount;
|
||||
uint32 bytes0;
|
||||
uint32 bytes1;
|
||||
uint32 bytes2;
|
||||
uint32 emote;
|
||||
|
|
|
|||
|
|
@ -490,6 +490,12 @@ void ObjectMgr::LoadCreatureTemplates()
|
|||
continue;
|
||||
}
|
||||
|
||||
if(cInfo->unit_class != heroicInfo->unit_class)
|
||||
{
|
||||
sLog.outErrorDb("Creature (Entry: %u, class %u) has different `unit_class` in heroic mode (Entry: %u, class %u).",i, cInfo->unit_class, cInfo->HeroicEntry, heroicInfo->unit_class);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(cInfo->npcflag != heroicInfo->npcflag)
|
||||
{
|
||||
sLog.outErrorDb("Creature (Entry: %u) has different `npcflag` in heroic mode (Entry: %u).",i,cInfo->HeroicEntry);
|
||||
|
|
@ -551,6 +557,9 @@ void ObjectMgr::LoadCreatureTemplates()
|
|||
if (!minfo)
|
||||
sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_H (%u)", cInfo->Entry, cInfo->DisplayID_H);
|
||||
|
||||
if (cInfo->unit_class && ((1 << (cInfo->unit_class-1)) & CLASSMASK_ALL_CREATURES) == 0)
|
||||
sLog.outErrorDb("Creature (Entry: %u) has invalid unit_class(%u) for creature_template", cInfo->Entry, cInfo->unit_class);
|
||||
|
||||
if(cInfo->dmgschool >= MAX_SPELL_SCHOOL)
|
||||
{
|
||||
sLog.outErrorDb("Creature (Entry: %u) has invalid spell school value (%u) in `dmgschool`",cInfo->Entry,cInfo->dmgschool);
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ enum Classes
|
|||
(1<<(CLASS_MAGE-1)) |(1<<(CLASS_WARLOCK-1))|(1<<(CLASS_DRUID-1)) | \
|
||||
(1<<(CLASS_DEATH_KNIGHT-1)) )
|
||||
|
||||
#define CLASSMASK_ALL_CREATURES ((1<<(CLASS_WARRIOR-1)) | (1<<(CLASS_PALADIN-1)) | (1<<(CLASS_ROGUE-1)) | (1<<(CLASS_MAGE-1)) )
|
||||
|
||||
#define CLASSMASK_WAND_USERS ((1<<(CLASS_PRIEST-1))|(1<<(CLASS_MAGE-1))|(1<<(CLASS_WARLOCK-1)))
|
||||
|
||||
#define PLAYER_MAX_BATTLEGROUND_QUEUES 3
|
||||
|
|
|
|||
|
|
@ -3217,8 +3217,9 @@ void Aura::HandleModCharm(bool apply, bool Real)
|
|||
CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
|
||||
if(cinfo && cinfo->type == CREATURE_TYPE_DEMON)
|
||||
{
|
||||
//does not appear to have relevance. Why code added initially? See note below at !apply
|
||||
//to prevent client crash
|
||||
m_target->SetFlag(UNIT_FIELD_BYTES_0, 2048);
|
||||
//m_target->SetFlag(UNIT_FIELD_BYTES_0, 2048);
|
||||
//just to enable stat window
|
||||
charmInfo->SetPetNumber(objmgr.GeneratePetNumber(), true);
|
||||
//if charmed two demons the same session, the 2nd gets the 1st one's name
|
||||
|
|
@ -3256,11 +3257,13 @@ void Aura::HandleModCharm(bool apply, bool Real)
|
|||
// restore UNIT_FIELD_BYTES_0
|
||||
if(cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON)
|
||||
{
|
||||
CreatureDataAddon const *cainfo = ((Creature*)m_target)->GetCreatureAddon();
|
||||
//does not appear to have relevance. Why code added initially? Class, gender, powertype should be same.
|
||||
//db field removed and replaced with better way to set class, restore using this if problems
|
||||
/*CreatureDataAddon const *cainfo = ((Creature*)m_target)->GetCreatureAddon();
|
||||
if(cainfo && cainfo->bytes0 != 0)
|
||||
m_target->SetUInt32Value(UNIT_FIELD_BYTES_0, cainfo->bytes0);
|
||||
else
|
||||
m_target->RemoveFlag(UNIT_FIELD_BYTES_0, 2048);
|
||||
m_target->RemoveFlag(UNIT_FIELD_BYTES_0, 2048);*/
|
||||
|
||||
if(m_target->GetCharmInfo())
|
||||
m_target->GetCharmInfo()->SetPetNumber(0, true);
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ extern DatabasePostgre WorldDatabase;
|
|||
extern DatabaseMysql WorldDatabase;
|
||||
#endif
|
||||
|
||||
const char CreatureInfosrcfmt[]="iiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiifflliiis";
|
||||
const char CreatureInfodstfmt[]="iiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiifflliiii";
|
||||
const char CreatureDataAddonInfofmt[]="iiiiiiis";
|
||||
const char CreatureInfosrcfmt[]="iiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiifflliiis";
|
||||
const char CreatureInfodstfmt[]="iiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiifflliiii";
|
||||
const char CreatureDataAddonInfofmt[]="iiiiiis";
|
||||
const char CreatureModelfmt[]="iffbi";
|
||||
const char CreatureInfoAddonInfofmt[]="iiiiiiis";
|
||||
const char CreatureInfoAddonInfofmt[]="iiiiiis";
|
||||
const char EquipmentInfofmt[]="iiii";
|
||||
const char GameObjectInfosrcfmt[]="iiisssiifiiiiiiiiiiiiiiiiiiiiiiiis";
|
||||
const char GameObjectInfodstfmt[]="iiisssiifiiiiiiiiiiiiiiiiiiiiiiiii";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7907"
|
||||
#define REVISION_NR "7908"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue