Skip to content

Commit

Permalink
[c12631] Use uint32 for phaseMasks in core and database
Browse files Browse the repository at this point in the history
Signed-off-by: Dramacydal <PulLumBerMal@gmail.com>
  • Loading branch information
Dramacydal committed May 30, 2013
1 parent 546ffc5 commit 8a0ee64
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 25 deletions.
6 changes: 3 additions & 3 deletions sql/characters.sql
Expand Up @@ -434,7 +434,7 @@ DROP TABLE IF EXISTS `character_db_version`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `character_db_version` (
`required_12447_02_characters_calendar_invites` bit(1) default NULL
`required_c12631_01_characters_corpse` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
/*!40101 SET character_set_client = @saved_cs_client */;

Expand All @@ -444,7 +444,7 @@ CREATE TABLE `character_db_version` (

LOCK TABLES `character_db_version` WRITE;
/*!40000 ALTER TABLE `character_db_version` DISABLE KEYS */;
INSERT INTO `character_db_version` (`required_12447_02_characters_calendar_invites`) VALUES
INSERT INTO `character_db_version` (`required_c12631_01_characters_corpse`) VALUES
(NULL);
/*!40000 ALTER TABLE `character_db_version` ENABLE KEYS */;
UNLOCK TABLES;
Expand Down Expand Up @@ -1220,7 +1220,7 @@ CREATE TABLE `corpse` (
`position_z` float NOT NULL DEFAULT '0',
`orientation` float NOT NULL DEFAULT '0',
`map` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Map Identifier',
`phaseMask` smallint(5) unsigned NOT NULL DEFAULT '1',
`phaseMask` int(11) unsigned NOT NULL DEFAULT '1',
`time` bigint(20) unsigned NOT NULL DEFAULT '0',
`corpse_type` tinyint(3) unsigned NOT NULL DEFAULT '0',
`instance` int(11) unsigned NOT NULL DEFAULT '0',
Expand Down
8 changes: 4 additions & 4 deletions sql/mangos.sql
Expand Up @@ -645,7 +645,7 @@ CREATE TABLE `creature` (
`id` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT 'Creature Identifier',
`map` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Map Identifier',
`spawnMask` tinyint(3) unsigned NOT NULL DEFAULT '1',
`phaseMask` smallint(5) unsigned NOT NULL DEFAULT '1',
`phaseMask` int(11) unsigned NOT NULL DEFAULT '1',
`modelid` mediumint(8) unsigned NOT NULL DEFAULT '0',
`equipment_id` mediumint(9) NOT NULL DEFAULT '0',
`position_x` float NOT NULL DEFAULT '0',
Expand Down Expand Up @@ -1425,7 +1425,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) DEFAULT NULL,
`creature_ai_version` varchar(120) DEFAULT NULL,
`cache_id` int(10) DEFAULT '0',
`required_c12602_01_mangos_npc_spellclick_spells` bit(1) default NULL
`required_c12631_02_mangos_gameobject` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
/*!40101 SET character_set_client = @saved_cs_client */;

Expand All @@ -1435,7 +1435,7 @@ CREATE TABLE `db_version` (

LOCK TABLES `db_version` WRITE;
/*!40000 ALTER TABLE `db_version` DISABLE KEYS */;
INSERT INTO `db_version` (`version`, `creature_ai_version`, `cache_id`, `required_c12602_01_mangos_npc_spellclick_spells`) VALUES
INSERT INTO `db_version` (`version`, `creature_ai_version`, `cache_id`, `required_c12631_02_mangos_gameobject`) VALUES
('Mangos default database.','Creature EventAI not provided.',0,NULL);
/*!40000 ALTER TABLE `db_version` ENABLE KEYS */;
UNLOCK TABLES;
Expand Down Expand Up @@ -1840,7 +1840,7 @@ CREATE TABLE `gameobject` (
`id` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT 'Gameobject Identifier',
`map` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Map Identifier',
`spawnMask` tinyint(3) unsigned NOT NULL DEFAULT '1',
`phaseMask` smallint(5) unsigned NOT NULL DEFAULT '1',
`phaseMask` int(11) unsigned NOT NULL DEFAULT '1',
`position_x` float NOT NULL DEFAULT '0',
`position_y` float NOT NULL DEFAULT '0',
`position_z` float NOT NULL DEFAULT '0',
Expand Down
3 changes: 3 additions & 0 deletions sql/updates/c12631_01_characters_corpse.sql
@@ -0,0 +1,3 @@
ALTER TABLE character_db_version CHANGE COLUMN required_12447_02_characters_calendar_invites required_c12631_01_characters_corpse bit;

ALTER TABLE corpse MODIFY COLUMN `phaseMask` int(11) unsigned NOT NULL DEFAULT '1';
3 changes: 3 additions & 0 deletions sql/updates/c12631_01_mangos_creature.sql
@@ -0,0 +1,3 @@
ALTER TABLE db_version CHANGE COLUMN required_c12602_01_mangos_npc_spellclick_spells required_c12631_01_mangos_creature bit;

ALTER TABLE creature MODIFY COLUMN `phaseMask` int(11) unsigned NOT NULL DEFAULT '1';
3 changes: 3 additions & 0 deletions sql/updates/c12631_02_mangos_gameobject.sql
@@ -0,0 +1,3 @@
ALTER TABLE db_version CHANGE COLUMN required_c12631_01_mangos_creature required_c12631_02_mangos_gameobject bit;

ALTER TABLE gameobject MODIFY COLUMN `phaseMask` int(11) unsigned NOT NULL DEFAULT '1';
2 changes: 1 addition & 1 deletion src/game/Corpse.cpp
Expand Up @@ -119,7 +119,7 @@ void Corpse::SaveToDB()
<< uint64(m_time) << ", "
<< uint32(GetType()) << ", "
<< int(GetInstanceId()) << ", "
<< uint16(GetPhaseMask()) << ")"; // prevent out of range error
<< uint32(GetPhaseMask()) << ")"; // prevent out of range error
CharacterDatabase.Execute(ss.str().c_str());
CharacterDatabase.CommitTransaction();
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/Creature.cpp
Expand Up @@ -1139,7 +1139,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
<< data.id << ","
<< data.mapid << ","
<< uint32(data.spawnMask) << "," // cast to prevent save as symbol
<< uint16(data.phaseMask) << "," // prevent out of range error
<< uint32(data.phaseMask) << "," // prevent out of range error
<< data.modelid_override << ","
<< data.equipmentId << ","
<< data.posX << ","
Expand Down
2 changes: 1 addition & 1 deletion src/game/Creature.h
Expand Up @@ -193,7 +193,7 @@ struct CreatureData
{
uint32 id; // entry in creature_template
uint16 mapid;
uint16 phaseMask;
uint32 phaseMask;
uint32 modelid_override; // overrides any model defined in creature_template
int32 equipmentId;
float posX;
Expand Down
2 changes: 1 addition & 1 deletion src/game/GameObject.cpp
Expand Up @@ -567,7 +567,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
<< GetEntry() << ", "
<< mapid << ", "
<< uint32(spawnMask) << "," // cast to prevent save as symbol
<< uint16(GetPhaseMask()) << "," // prevent out of range error
<< uint32(GetPhaseMask()) << "," // prevent out of range error
<< GetPositionX() << ", "
<< GetPositionY() << ", "
<< GetPositionZ() << ", "
Expand Down
2 changes: 1 addition & 1 deletion src/game/GameObject.h
Expand Up @@ -574,7 +574,7 @@ struct GameObjectData
{
uint32 id; // entry in gamobject_template
uint16 mapid;

This comment has been minimized.

Copy link
@VladimirMangos

VladimirMangos May 30, 2013

Member

Poosible no reason have maipid as uint16 then - for poratbility better have then uint32 as used in most cases.

uint16 phaseMask;
uint32 phaseMask;
float posX;
float posY;
float posZ;
Expand Down
4 changes: 2 additions & 2 deletions src/game/ObjectMgr.cpp
Expand Up @@ -1262,7 +1262,7 @@ void ObjectMgr::LoadCreatures()
data.is_dead = fields[14].GetBool();
data.movementType = fields[15].GetUInt8();
data.spawnMask = fields[16].GetUInt8();
data.phaseMask = fields[17].GetUInt16();
data.phaseMask = fields[17].GetUInt32();
int16 gameEvent = fields[18].GetInt16();
int16 GuidPoolId = fields[19].GetInt16();
int16 EntryPoolId = fields[20].GetInt16();
Expand Down Expand Up @@ -1492,7 +1492,7 @@ void ObjectMgr::LoadGameObjects()
data.animprogress = fields[12].GetUInt32();
uint32 go_state = fields[13].GetUInt32();
data.spawnMask = fields[14].GetUInt8();
data.phaseMask = fields[15].GetUInt16();
data.phaseMask = fields[15].GetUInt32();
int16 gameEvent = fields[16].GetInt16();
int16 GuidPoolId = fields[17].GetInt16();
int16 EntryPoolId = fields[18].GetInt16();
Expand Down
12 changes: 4 additions & 8 deletions src/game/WorldSession.cpp
Expand Up @@ -596,25 +596,21 @@ void WorldSession::SendSetPhaseShift(uint32 phaseMask, uint16 mapId)
data.WriteGuidMask<2, 3, 1, 6, 4, 5, 0, 7>(guid);
data.WriteGuidBytes<7, 4>(guid);

// Seen only 0 bytes
data << uint32(0);
data << uint32(0); // number of WorldMapArea.dbc entries to control world map shift * 2

data.WriteGuidBytes<1>(guid);
data << uint32(phaseMask ? phaseFlags : 8);
data.WriteGuidBytes<2, 6>(guid);

// Seen only 0 bytes
data << uint32(0);
data << uint32(0); // number of inactive terrain swaps * 2

// PhaseShift, uint16 (2 bytes)
data << uint32(phaseMask ? 2 : 0);
data << uint32(phaseMask ? 2 : 0); // WRONG: number of Phase.dbc ids * 2
if (phaseMask)
data << uint16(phaseMask);

data.WriteGuidBytes<3, 0>(guid);

// MapId , uint16 (2 bytes)
data << uint32(mapId ? 2 : 0);
data << uint32(mapId ? 2 : 0); // number of terrains swaps * 2
if (mapId)
data << uint16(mapId);

Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12630"
#define REVISION_NR "12631"
#endif // __REVISION_NR_H__
4 changes: 2 additions & 2 deletions src/shared/revision_sql.h
@@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_12447_02_characters_calendar_invites"
#define REVISION_DB_MANGOS "required_12602_01_mangos_npc_spellclick_spells"
#define REVISION_DB_CHARACTERS "required_c12631_01_characters_corpse"
#define REVISION_DB_MANGOS "required_c12631_02_mangos_gameobject"
#define REVISION_DB_REALMD "required_c12484_02_realmd_account_access"
#endif // __REVISION_SQL_H__

0 comments on commit 8a0ee64

Please sign in to comment.