Skip to content

Commit

Permalink
[z2824] Creature: Fix naming of modelId in Classic
Browse files Browse the repository at this point in the history
  • Loading branch information
insunaa authored and killerwife committed May 8, 2024
1 parent f928d60 commit 7a2c28a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
5 changes: 2 additions & 3 deletions sql/base/mangos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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_z2823_01_mangos_displayid_probability` bit(1) DEFAULT NULL
`required_z2824_01_mangos_model_unification` bit(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Used DB version notes';

--
Expand Down Expand Up @@ -1074,7 +1074,7 @@ CREATE TABLE `creature_model_info` (
`SpeedRun` FLOAT NOT NULL DEFAULT '1.14286' COMMENT 'Default running speed for any creature with model',
`gender` tinyint(3) unsigned NOT NULL DEFAULT '2',
`modelid_other_gender` mediumint(8) unsigned NOT NULL DEFAULT '0',
`modelid_other_team` mediumint(8) unsigned NOT NULL DEFAULT '0',
`modelid_alternative` mediumint(8) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`modelid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Creature System (Model related info)';

Expand Down Expand Up @@ -1219,7 +1219,6 @@ CREATE TABLE `creature_template` (
`SubName` char(100) DEFAULT NULL,
`MinLevel` tinyint(3) unsigned NOT NULL DEFAULT '1',
`MaxLevel` tinyint(3) unsigned NOT NULL DEFAULT '1',
`HeroicEntry` mediumint(8) unsigned NOT NULL DEFAULT '0',
`DisplayId1` mediumint(8) unsigned NOT NULL DEFAULT '0',
`DisplayId2` mediumint(8) unsigned NOT NULL DEFAULT '0',
`DisplayId3` mediumint(8) unsigned NOT NULL DEFAULT '0',
Expand Down
8 changes: 4 additions & 4 deletions sql/updates/mangos/z2823_01_mangos_displayid_probability.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ ALTER TABLE `creature_template` ADD COLUMN `DisplayIdProbability4` SMALLINT UNSI
SET sql_safe_updates=0;
-- setting probabilities to exactly replicate previous behaviour
UPDATE creature_template SET DisplayIdProbability1=100 WHERE DisplayId1!=0;
UPDATE creature_template SET DisplayIdProbability1=50,DisplayIdProbability2=50 WHERE DisplayId1!=0 AND DisplayId2!=0 AND EXISTS(SELECT modelid FROM creature_model_info WHERE creature_template.DisplayId2=creature_model_info.modelid AND modelid_alternative > 0);
UPDATE creature_template SET DisplayIdProbability1=0,DisplayIdProbability2=100 WHERE DisplayId1!=0 AND DisplayId2!=0 AND NOT EXISTS(SELECT modelid FROM creature_model_info WHERE creature_template.DisplayId2=creature_model_info.modelid AND modelid_alternative > 0);
UPDATE creature_template SET DisplayIdProbability1=33,DisplayIdProbability2=33,DisplayIdProbability3=33 WHERE DisplayId1!=0 AND DisplayId2!=0 AND DisplayId3!=0 AND EXISTS(SELECT modelid FROM creature_model_info WHERE creature_template.DisplayId2=creature_model_info.modelid AND modelid_alternative > 0);
UPDATE creature_template SET DisplayIdProbability1=0,DisplayIdProbability2=0,DisplayIdProbability3=100 WHERE DisplayId1!=0 AND DisplayId2!=0 AND DisplayId3!=0 AND NOT EXISTS(SELECT modelid FROM creature_model_info WHERE creature_template.DisplayId2=creature_model_info.modelid AND modelid_alternative > 0);
UPDATE creature_template SET DisplayIdProbability1=50,DisplayIdProbability2=50 WHERE DisplayId1!=0 AND DisplayId2!=0 AND EXISTS(SELECT modelid FROM creature_model_info WHERE creature_template.DisplayId2=creature_model_info.modelid AND modelid_other_team > 0);
UPDATE creature_template SET DisplayIdProbability1=0,DisplayIdProbability2=100 WHERE DisplayId1!=0 AND DisplayId2!=0 AND NOT EXISTS(SELECT modelid FROM creature_model_info WHERE creature_template.DisplayId2=creature_model_info.modelid AND modelid_other_team > 0);
UPDATE creature_template SET DisplayIdProbability1=33,DisplayIdProbability2=33,DisplayIdProbability3=33 WHERE DisplayId1!=0 AND DisplayId2!=0 AND DisplayId3!=0 AND EXISTS(SELECT modelid FROM creature_model_info WHERE creature_template.DisplayId2=creature_model_info.modelid AND modelid_other_team > 0);
UPDATE creature_template SET DisplayIdProbability1=0,DisplayIdProbability2=0,DisplayIdProbability3=100 WHERE DisplayId1!=0 AND DisplayId2!=0 AND DisplayId3!=0 AND NOT EXISTS(SELECT modelid FROM creature_model_info WHERE creature_template.DisplayId2=creature_model_info.modelid AND modelid_other_team > 0);
UPDATE creature_template SET DisplayIdProbability1=25,DisplayIdProbability2=25,DisplayIdProbability3=25,DisplayIdProbability4=25 WHERE DisplayId1!=0 AND DisplayId2!=0 AND DisplayId3!=0 AND DisplayId4!=0;
SET sql_safe_updates=1;
5 changes: 5 additions & 0 deletions sql/updates/mangos/z2824_01_mangos_model_unification.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE db_version CHANGE COLUMN required_z2823_01_mangos_displayid_probability required_z2824_01_mangos_model_unification bit;

ALTER TABLE `creature_model_info` RENAME COLUMN `modelid_other_team` TO `modelid_alternative`;


2 changes: 1 addition & 1 deletion src/game/Entities/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ struct CreatureModelInfo
float SpeedRun;
uint8 gender;
uint32 modelid_other_gender; // The oposite gender for this modelid (male/female)
uint32 modelid_other_team; // The oposite team. Generally for alliance totem
uint32 modelid_alternative; // The oposite team. Generally for alliance totem
};

struct CreatureConditionalSpawn
Expand Down
16 changes: 8 additions & 8 deletions src/game/Globals/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ void ObjectMgr::LoadEquipmentTemplates()
uint32 ObjectMgr::GetCreatureModelOtherTeamModel(uint32 modelId) const
{
if (const CreatureModelInfo* modelInfo = GetCreatureModelInfo(modelId))
return modelInfo->modelid_other_team;
return modelInfo->modelid_alternative;

return 0;
}
Expand Down Expand Up @@ -1535,17 +1535,17 @@ void ObjectMgr::LoadCreatureModelInfo()
}
}

if (minfo->modelid_other_team)
if (minfo->modelid_alternative)
{
if (minfo->modelid_other_team == minfo->modelid)
if (minfo->modelid_alternative == minfo->modelid)
{
sLog.outErrorDb("Table `creature_model_info` has redundant modelid_other_team model (%u) defined for model id %u.", minfo->modelid_other_team, minfo->modelid);
const_cast<CreatureModelInfo*>(minfo)->modelid_other_team = 0;
sLog.outErrorDb("Table `creature_model_info` has redundant modelid_alternative model (%u) defined for model id %u.", minfo->modelid_alternative, minfo->modelid);
const_cast<CreatureModelInfo*>(minfo)->modelid_alternative = 0;
}
else if (!sCreatureDisplayInfoStore.LookupEntry(minfo->modelid_other_team))
else if (!sCreatureDisplayInfoStore.LookupEntry(minfo->modelid_alternative))
{
sLog.outErrorDb("Table `creature_model_info` has nonexistent modelid_other_team model (%u) defined for model id %u.", minfo->modelid_other_team, minfo->modelid);
const_cast<CreatureModelInfo*>(minfo)->modelid_other_team = 0;
sLog.outErrorDb("Table `creature_model_info` has nonexistent modelid_alternative model (%u) defined for model id %u.", minfo->modelid_alternative, minfo->modelid);
const_cast<CreatureModelInfo*>(minfo)->modelid_alternative = 0;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_sql.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#define REVISION_DB_REALMD "required_z2820_01_realmd_joindate_datetime"
#define REVISION_DB_LOGS "required_z2778_01_logs_anticheat"
#define REVISION_DB_CHARACTERS "required_z2819_01_characters_item_instance_text_id_fix"
#define REVISION_DB_MANGOS "required_z2823_01_mangos_displayid_probability"
#define REVISION_DB_MANGOS "required_z2824_01_mangos_model_unification"
#endif // __REVISION_SQL_H__

0 comments on commit 7a2c28a

Please sign in to comment.