diff --git a/sql/migrations/20210607095329_characters.sql b/sql/migrations/20210607095329_characters.sql new file mode 100644 index 000000000..f10ee02c4 --- /dev/null +++ b/sql/migrations/20210607095329_characters.sql @@ -0,0 +1,335 @@ +DROP PROCEDURE IF EXISTS add_migration; +delimiter ?? +CREATE PROCEDURE `add_migration`() +BEGIN +DECLARE v INT DEFAULT 1; +SET v = (SELECT COUNT(*) FROM `migrations` WHERE `id`='20210607095329'); +IF v=0 THEN +INSERT INTO `migrations` VALUES ('20210607095329'); +-- Add your query below. + + +ALTER TABLE `auction` + CHANGE COLUMN `houseid` `house_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `id`, + CHANGE COLUMN `itemguid` `item_guid` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `house_id`, + CHANGE COLUMN `item_template` `item_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `item_guid`, + CHANGE COLUMN `itemowner` `seller_guid` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `item_id`, + CHANGE COLUMN `buyoutprice` `buyout_price` INT(11) NOT NULL DEFAULT '0' AFTER `seller_guid`, + CHANGE COLUMN `time` `expire_time` BIGINT(40) NOT NULL DEFAULT '0' AFTER `buyout_price`, + CHANGE COLUMN `buyguid` `buyer_guid` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `expire_time`, + CHANGE COLUMN `lastbid` `last_bid` INT(11) NOT NULL DEFAULT '0' AFTER `buyer_guid`, + CHANGE COLUMN `startbid` `start_bid` INT(11) NOT NULL DEFAULT '0' AFTER `last_bid`; + +DROP TABLE `bugreport`; + +DROP TABLE `bugreports`; + +DROP TABLE `census`; + +ALTER TABLE `characters` + DROP COLUMN `cinematic`; + +ALTER TABLE `characters` + ADD COLUMN `skin` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `gender`, + ADD COLUMN `face` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `skin`, + ADD COLUMN `hair_style` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `face`, + ADD COLUMN `hair_color` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `hair_style`, + ADD COLUMN `facial_hair` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `hair_color`; + +UPDATE `characters` SET `skin`=(`playerBytes` & 0xFF); +UPDATE `characters` SET `face`=((`playerBytes` >> 8) & 0xFF); +UPDATE `characters` SET `hair_style`=((`playerBytes` >> 16) & 0xFF); +UPDATE `characters` SET `hair_color`=((`playerBytes` >> 24) & 0xFF); +UPDATE `characters` SET `facial_hair`=(`playerBytes2` & 0xFF); + +ALTER TABLE `characters` + CHANGE COLUMN `playerFlags` `player_flags` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `money`, + CHANGE COLUMN `zone` `zone` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `player_flags`, + CHANGE COLUMN `map` `map` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Map Identifier' AFTER `zone`, + CHANGE COLUMN `transguid` `transport_guid` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `orientation`, + CHANGE COLUMN `trans_x` `transport_x` FLOAT NOT NULL DEFAULT '0' AFTER `transport_guid`, + CHANGE COLUMN `trans_y` `transport_y` FLOAT NOT NULL DEFAULT '0' AFTER `transport_x`, + CHANGE COLUMN `trans_z` `transport_z` FLOAT NOT NULL DEFAULT '0' AFTER `transport_y`, + CHANGE COLUMN `trans_o` `transport_o` FLOAT NOT NULL DEFAULT '0' AFTER `transport_z`, + CHANGE COLUMN `taximask` `known_taxi_mask` LONGTEXT NULL COMMENT 'discovered flight points' AFTER `transport_o`, + CHANGE COLUMN `taxi_path` `current_taxi_path` TEXT NULL COMMENT 'flight destination' AFTER `known_taxi_mask`, + CHANGE COLUMN `totaltime` `played_time_total` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `online`, + CHANGE COLUMN `leveltime` `played_time_level` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `played_time_total`, + ADD COLUMN `create_time` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `played_time_level`, + CHANGE COLUMN `resettalents_multiplier` `reset_talents_multiplier` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `rest_bonus`, + CHANGE COLUMN `resettalents_time` `reset_talents_time` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `reset_talents_multiplier`, + CHANGE COLUMN `death_expire_time` `death_expire_time` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `reset_talents_time`, + ADD COLUMN `bank_bag_slots` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `stable_slots`, + CHANGE COLUMN `at_login` `at_login_flags` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `bank_bag_slots`, + CHANGE COLUMN `extra_flags` `extra_flags` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `at_login_flags`, + CHANGE COLUMN `honorRankPoints` `honor_rank_points` FLOAT NOT NULL DEFAULT '0' AFTER `extra_flags`, + CHANGE COLUMN `honorHighestRank` `honor_highest_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `honor_rank_points`, + CHANGE COLUMN `honorStanding` `honor_standing` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `honor_highest_rank`, + CHANGE COLUMN `honorLastWeekHK` `honor_last_week_hk` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `honor_standing`, + CHANGE COLUMN `honorLastWeekCP` `honor_last_week_cp` FLOAT NOT NULL DEFAULT '0' AFTER `honor_last_week_hk`, + CHANGE COLUMN `honorStoredHK` `honor_stored_hk` INT(11) NOT NULL DEFAULT '0' AFTER `honor_last_week_cp`, + CHANGE COLUMN `honorStoredDK` `honor_stored_dk` INT(11) NOT NULL DEFAULT '0' AFTER `honor_stored_hk`, + CHANGE COLUMN `watchedFaction` `watched_faction` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `honor_stored_dk`, + CHANGE COLUMN `exploredZones` `explored_zones` LONGTEXT NULL AFTER `power5`, + CHANGE COLUMN `equipmentCache` `equipment_cache` LONGTEXT NULL AFTER `explored_zones`, + CHANGE COLUMN `ammoId` `ammo_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `equipment_cache`, + CHANGE COLUMN `actionBars` `action_bars` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `ammo_id`, + CHANGE COLUMN `deleteInfos_Account` `deleted_account` INT(11) UNSIGNED NULL DEFAULT NULL AFTER `action_bars`, + CHANGE COLUMN `deleteInfos_Name` `deleted_name` VARCHAR(12) NULL DEFAULT NULL AFTER `deleted_account`, + CHANGE COLUMN `deleteDate` `deleted_time` BIGINT(20) NULL DEFAULT NULL AFTER `deleted_name`; + +UPDATE `characters` SET `bank_bag_slots`=((`playerBytes2` >> 16) & 0xFF); + +ALTER TABLE `characters` + DROP COLUMN `playerBytes`, + DROP COLUMN `playerBytes2`, + DROP COLUMN `area`, + DROP COLUMN `customFlags`; + +ALTER TABLE `characters` + CHANGE COLUMN `watched_faction` `watched_faction` BIGINT NOT NULL DEFAULT '0' AFTER `honor_stored_dk`; + +UPDATE `characters` SET `watched_faction`=-1 WHERE `watched_faction`=4294967295; + +ALTER TABLE `characters` + CHANGE COLUMN `watched_faction` `watched_faction` INT NOT NULL DEFAULT '-1' AFTER `honor_stored_dk`; + +ALTER TABLE `character_aura` + CHANGE COLUMN `stackcount` `stacks` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `spell`, + CHANGE COLUMN `remaincharges` `charges` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `stacks`, + CHANGE COLUMN `basepoints0` `base_points0` FLOAT NOT NULL DEFAULT '0' AFTER `charges`, + CHANGE COLUMN `basepoints1` `base_points1` FLOAT NOT NULL DEFAULT '0' AFTER `base_points0`, + CHANGE COLUMN `basepoints2` `base_points2` FLOAT NOT NULL DEFAULT '0' AFTER `base_points1`, + CHANGE COLUMN `periodictime0` `periodic_time0` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `base_points2`, + CHANGE COLUMN `periodictime1` `periodic_time1` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `periodic_time0`, + CHANGE COLUMN `periodictime2` `periodic_time2` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `periodic_time1`, + CHANGE COLUMN `maxduration` `max_duration` INT(11) NOT NULL DEFAULT '0' AFTER `periodic_time2`, + CHANGE COLUMN `remaintime` `duration` INT(11) NOT NULL DEFAULT '0' AFTER `max_duration`, + CHANGE COLUMN `effIndexMask` `effect_index_mask` TINYINT UNSIGNED NOT NULL DEFAULT '0' AFTER `duration`; + +ALTER TABLE `pet_aura` + CHANGE COLUMN `stackcount` `stacks` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `spell`, + CHANGE COLUMN `remaincharges` `charges` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `stacks`, + CHANGE COLUMN `basepoints0` `base_points0` FLOAT NOT NULL DEFAULT '0' AFTER `charges`, + CHANGE COLUMN `basepoints1` `base_points1` FLOAT NOT NULL DEFAULT '0' AFTER `base_points0`, + CHANGE COLUMN `basepoints2` `base_points2` FLOAT NOT NULL DEFAULT '0' AFTER `base_points1`, + CHANGE COLUMN `periodictime0` `periodic_time0` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `base_points2`, + CHANGE COLUMN `periodictime1` `periodic_time1` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `periodic_time0`, + CHANGE COLUMN `periodictime2` `periodic_time2` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `periodic_time1`, + CHANGE COLUMN `maxduration` `max_duration` INT(11) NOT NULL DEFAULT '0' AFTER `periodic_time2`, + CHANGE COLUMN `remaintime` `duration` INT(11) NOT NULL DEFAULT '0' AFTER `max_duration`, + CHANGE COLUMN `effIndexMask` `effect_index_mask` TINYINT UNSIGNED NOT NULL DEFAULT '0' AFTER `duration`; + +DROP TABLE `character_bgqueue`; + +ALTER TABLE `character_deleted_items` + CHANGE COLUMN `item_entry` `item_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `player_guid`; + +ALTER TABLE `character_gifts` + CHANGE COLUMN `entry` `item_id` INT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `item_guid`; + +ALTER TABLE `character_honor_cp` + CHANGE COLUMN `victimType` `victim_type` TINYINT(3) UNSIGNED NOT NULL DEFAULT '4' COMMENT 'Object Type Id' AFTER `guid`, + CHANGE COLUMN `victim` `victim_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Creature Id / Player Guid' AFTER `victim_type`; + +ALTER TABLE `character_inventory` + CHANGE COLUMN `item` `item_guid` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Item Global Unique Identifier' AFTER `slot`, + CHANGE COLUMN `item_template` `item_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Item Identifier' AFTER `item_guid`; + +ALTER TABLE `character_pet` + CHANGE COLUMN `modelid` `display_id` INT(11) UNSIGNED NULL DEFAULT '0' AFTER `owner`, + CHANGE COLUMN `CreatedBySpell` `created_by_spell` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `display_id`, + CHANGE COLUMN `PetType` `pet_type` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `created_by_spell`, + CHANGE COLUMN `Reactstate` `react_state` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `exp`, + CHANGE COLUMN `loyaltypoints` `loyalty_points` INT(11) NOT NULL DEFAULT '0' AFTER `react_state`, + CHANGE COLUMN `trainpoint` `training_points` INT(11) NOT NULL DEFAULT '0' AFTER `loyalty`, + CHANGE COLUMN `curhealth` `current_health` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `slot`, + CHANGE COLUMN `curmana` `current_mana` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `current_health`, + CHANGE COLUMN `curhappiness` `current_happiness` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `current_mana`, + CHANGE COLUMN `savetime` `save_time` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `current_happiness`, + CHANGE COLUMN `resettalents_cost` `reset_talents_cost` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `save_time`, + CHANGE COLUMN `resettalents_time` `reset_talents_time` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `reset_talents_cost`, + CHANGE COLUMN `abdata` `action_bar_data` LONGTEXT NULL AFTER `reset_talents_time`, + CHANGE COLUMN `teachspelldata` `teach_spell_data` LONGTEXT NULL AFTER `action_bar_data`; + +ALTER TABLE `character_pet` + CHANGE COLUMN `exp` `xp` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `level`; +ALTER TABLE `character_pet` + CHANGE COLUMN `owner` `owner_guid` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `entry`; + +ALTER TABLE `character_queststatus` + CHANGE COLUMN `mobcount1` `mob_count1` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `timer`, + CHANGE COLUMN `mobcount2` `mob_count2` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `mob_count1`, + CHANGE COLUMN `mobcount3` `mob_count3` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `mob_count2`, + CHANGE COLUMN `mobcount4` `mob_count4` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `mob_count3`, + CHANGE COLUMN `itemcount1` `item_count1` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `mob_count4`, + CHANGE COLUMN `itemcount2` `item_count2` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `item_count1`, + CHANGE COLUMN `itemcount3` `item_count3` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `item_count2`, + CHANGE COLUMN `itemcount4` `item_count4` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `item_count3`; + +ALTER TABLE `character_spell_cooldown` + CHANGE COLUMN `SpellId` `spell` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Spell Identifier' AFTER `guid`, + CHANGE COLUMN `SpellExpireTime` `spell_expire_time` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Spell cooldown expire time' AFTER `spell`, + CHANGE COLUMN `Category` `category` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Spell category' AFTER `spell_expire_time`, + CHANGE COLUMN `CategoryExpireTime` `category_expire_time` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Spell category cooldown expire time' AFTER `category`, + CHANGE COLUMN `ItemId` `item_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Item Identifier' AFTER `category_expire_time`; + +ALTER TABLE `character_stats` + CHANGE COLUMN `maxhealth` `max_health` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `guid`, + CHANGE COLUMN `maxpower1` `max_power1` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `max_health`, + CHANGE COLUMN `maxpower2` `max_power2` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `max_power1`, + CHANGE COLUMN `maxpower3` `max_power3` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `max_power2`, + CHANGE COLUMN `maxpower4` `max_power4` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `max_power3`, + CHANGE COLUMN `maxpower5` `max_power5` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `max_power4`, + CHANGE COLUMN `maxpower6` `max_power6` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `max_power5`, + CHANGE COLUMN `maxpower7` `max_power7` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `max_power6`, + CHANGE COLUMN `strength` `strength` FLOAT NOT NULL DEFAULT '0' AFTER `max_power7`, + CHANGE COLUMN `agility` `agility` FLOAT NOT NULL DEFAULT '0' AFTER `strength`, + CHANGE COLUMN `stamina` `stamina` FLOAT NOT NULL DEFAULT '0' AFTER `agility`, + CHANGE COLUMN `intellect` `intellect` FLOAT NOT NULL DEFAULT '0' AFTER `stamina`, + CHANGE COLUMN `spirit` `spirit` FLOAT NOT NULL DEFAULT '0' AFTER `intellect`, + CHANGE COLUMN `armor` `armor` INT(10) NOT NULL DEFAULT '0' AFTER `spirit`, + CHANGE COLUMN `resHoly` `holy_res` INT(10) NOT NULL DEFAULT '0' AFTER `armor`, + CHANGE COLUMN `resFire` `fire_res` INT(10) NOT NULL DEFAULT '0' AFTER `holy_res`, + CHANGE COLUMN `resNature` `nature_res` INT(10) NOT NULL DEFAULT '0' AFTER `fire_res`, + CHANGE COLUMN `resFrost` `frost_res` INT(10) NOT NULL DEFAULT '0' AFTER `nature_res`, + CHANGE COLUMN `resShadow` `shadow_res` INT(10) NOT NULL DEFAULT '0' AFTER `frost_res`, + CHANGE COLUMN `resArcane` `arcane_res` INT(10) NOT NULL DEFAULT '0' AFTER `shadow_res`, + CHANGE COLUMN `blockPct` `block_chance` FLOAT NOT NULL DEFAULT '0' AFTER `arcane_res`, + CHANGE COLUMN `dodgePct` `dodge_chance` FLOAT NOT NULL DEFAULT '0' AFTER `block_chance`, + CHANGE COLUMN `parryPct` `parry_chance` FLOAT NOT NULL DEFAULT '0' AFTER `dodge_chance`, + CHANGE COLUMN `critPct` `crit_chance` FLOAT NOT NULL DEFAULT '0' AFTER `parry_chance`, + CHANGE COLUMN `rangedCritPct` `ranged_crit_chance` FLOAT NOT NULL DEFAULT '0' AFTER `crit_chance`, + CHANGE COLUMN `attackPower` `attack_power` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `ranged_crit_chance`, + CHANGE COLUMN `rangedAttackPower` `ranged_attack_power` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `attack_power`; + +DROP TABLE `character_ticket`; + +ALTER TABLE `creature_respawn` + CHANGE COLUMN `respawntime` `respawn_time` BIGINT(20) NOT NULL DEFAULT '0' AFTER `guid`; + +ALTER TABLE `corpse` + CHANGE COLUMN `player` `player_guid` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Character Global Unique Identifier' AFTER `guid`; + +ALTER TABLE `gameobject_respawn` + CHANGE COLUMN `respawntime` `respawn_time` BIGINT(20) NOT NULL DEFAULT '0' AFTER `guid`; + +ALTER TABLE `gm_subsurveys` + CHANGE COLUMN `surveyId` `survey_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT FIRST, + CHANGE COLUMN `subsurveyId` `subsurvey_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `survey_id`; + +ALTER TABLE `gm_surveys` + CHANGE COLUMN `surveyId` `survey_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT FIRST, + CHANGE COLUMN `mainSurvey` `main_survey` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `guid`, + CHANGE COLUMN `overallComment` `overall_comment` LONGTEXT NOT NULL AFTER `main_survey`, + CHANGE COLUMN `createTime` `create_time` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `overall_comment`; + +ALTER TABLE `gm_tickets` + CHANGE COLUMN `ticketId` `ticket_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT FIRST, + CHANGE COLUMN `createTime` `create_time` BIGINT UNSIGNED NOT NULL DEFAULT '0' AFTER `message`, + CHANGE COLUMN `mapId` `map` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' AFTER `create_time`, + CHANGE COLUMN `posX` `position_x` FLOAT NOT NULL DEFAULT '0' AFTER `map`, + CHANGE COLUMN `posY` `position_y` FLOAT NOT NULL DEFAULT '0' AFTER `position_x`, + CHANGE COLUMN `posZ` `position_z` FLOAT NOT NULL DEFAULT '0' AFTER `position_y`, + CHANGE COLUMN `lastModifiedTime` `last_modified_time` BIGINT UNSIGNED NOT NULL DEFAULT '0' AFTER `position_z`, + CHANGE COLUMN `closedBy` `closed_by` INT(10) NOT NULL DEFAULT '0' AFTER `last_modified_time`, + CHANGE COLUMN `assignedTo` `assigned_to` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'GUID of admin to whom ticket is assigned' AFTER `closed_by`, + CHANGE COLUMN `haveTicket` `have_ticket` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `viewed`, + CHANGE COLUMN `ticketType` `ticket_type` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `have_ticket`, + CHANGE COLUMN `securityNeeded` `security_needed` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `ticket_type`; + +ALTER TABLE `groups` + CHANGE COLUMN `groupId` `group_id` INT(11) UNSIGNED NOT NULL FIRST, + CHANGE COLUMN `leaderGuid` `leader_guid` INT(11) UNSIGNED NOT NULL AFTER `group_id`, + CHANGE COLUMN `mainTank` `main_tank_guid` INT(11) UNSIGNED NOT NULL AFTER `leader_guid`, + CHANGE COLUMN `mainAssistant` `main_assistant_guid` INT(11) UNSIGNED NOT NULL AFTER `main_tank_guid`, + CHANGE COLUMN `lootMethod` `loot_method` TINYINT(4) UNSIGNED NOT NULL AFTER `main_assistant_guid`, + CHANGE COLUMN `lootThreshold` `loot_threshold` TINYINT(4) UNSIGNED NOT NULL AFTER `loot_method`, + CHANGE COLUMN `looterGuid` `looter_guid` INT(11) UNSIGNED NOT NULL AFTER `loot_threshold`, + CHANGE COLUMN `isRaid` `is_raid` TINYINT(1) UNSIGNED NOT NULL AFTER `icon8`; + +ALTER TABLE `group_instance` + CHANGE COLUMN `leaderGuid` `leader_guid` INT(11) UNSIGNED NOT NULL DEFAULT '0' FIRST; + +ALTER TABLE `group_member` + CHANGE COLUMN `groupId` `group_id` INT(11) UNSIGNED NOT NULL FIRST, + CHANGE COLUMN `memberGuid` `member_guid` INT(11) UNSIGNED NOT NULL AFTER `group_id`; + +ALTER TABLE `guild` + CHANGE COLUMN `guildid` `guild_id` INT(6) UNSIGNED NOT NULL DEFAULT '0' FIRST, + CHANGE COLUMN `leaderguid` `leader_guid` INT(6) UNSIGNED NOT NULL DEFAULT '0' AFTER `name`, + CHANGE COLUMN `EmblemStyle` `emblem_style` INT(5) NOT NULL DEFAULT '0' AFTER `leader_guid`, + CHANGE COLUMN `EmblemColor` `emblem_color` INT(5) NOT NULL DEFAULT '0' AFTER `emblem_style`, + CHANGE COLUMN `BorderStyle` `border_style` INT(5) NOT NULL DEFAULT '0' AFTER `emblem_color`, + CHANGE COLUMN `BorderColor` `border_color` INT(5) NOT NULL DEFAULT '0' AFTER `border_style`, + CHANGE COLUMN `BackgroundColor` `background_color` INT(5) NOT NULL DEFAULT '0' AFTER `border_color`, + CHANGE COLUMN `createdate` `create_date` BIGINT(20) NOT NULL DEFAULT '0' AFTER `motd`; + +ALTER TABLE `guild_eventlog` + CHANGE COLUMN `guildid` `guild_id` INT(11) NOT NULL COMMENT 'Guild Identificator' FIRST, + CHANGE COLUMN `LogGuid` `log_guid` INT(11) NOT NULL COMMENT 'Log record identificator - auxiliary column' AFTER `guild_id`, + CHANGE COLUMN `EventType` `event_type` TINYINT(1) NOT NULL COMMENT 'Event type' AFTER `log_guid`, + CHANGE COLUMN `PlayerGuid1` `player_guid1` INT(11) NOT NULL COMMENT 'Player 1' AFTER `event_type`, + CHANGE COLUMN `PlayerGuid2` `player_guid2` INT(11) NOT NULL COMMENT 'Player 2' AFTER `player_guid1`, + CHANGE COLUMN `NewRank` `new_rank` TINYINT(2) NOT NULL COMMENT 'New rank(in case promotion/demotion)' AFTER `player_guid2`, + CHANGE COLUMN `TimeStamp` `timestamp` BIGINT(20) NOT NULL COMMENT 'Event UNIX time' AFTER `new_rank`; + +ALTER TABLE `guild_member` + CHANGE COLUMN `guildid` `guild_id` INT(6) UNSIGNED NOT NULL DEFAULT '0' FIRST, + CHANGE COLUMN `pnote` `player_note` VARCHAR(255) NOT NULL DEFAULT '' AFTER `rank`, + CHANGE COLUMN `offnote` `officer_note` VARCHAR(255) NOT NULL DEFAULT '' AFTER `player_note`; + +ALTER TABLE `guild_rank` + CHANGE COLUMN `guildid` `guild_id` INT(6) UNSIGNED NOT NULL DEFAULT '0' FIRST, + CHANGE COLUMN `rid` `id` INT(11) UNSIGNED NOT NULL AFTER `guild_id`, + CHANGE COLUMN `rname` `name` VARCHAR(255) NOT NULL DEFAULT '' AFTER `id`; + +ALTER TABLE `instance` + CHANGE COLUMN `resettime` `reset_time` BIGINT(40) NOT NULL DEFAULT '0' AFTER `map`; + +ALTER TABLE `instance_reset` + CHANGE COLUMN `mapid` `map` INT(11) UNSIGNED NOT NULL DEFAULT '0' FIRST, + CHANGE COLUMN `resettime` `reset_time` BIGINT(40) NOT NULL DEFAULT '0' AFTER `map`; + +ALTER TABLE `item_instance` + CHANGE COLUMN `itemEntry` `item_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `guid`, + CHANGE COLUMN `creatorGuid` `creator_guid` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `owner_guid`, + CHANGE COLUMN `giftCreatorGuid` `gift_creator_guid` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `creator_guid`, + CHANGE COLUMN `randomPropertyId` `random_property_id` SMALLINT(5) NOT NULL DEFAULT '0' AFTER `enchantments`; + +ALTER TABLE `item_loot` + CHANGE COLUMN `itemid` `item_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `owner_guid`; + +ALTER TABLE `mail` + CHANGE COLUMN `messageType` `message_type` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER `id`, + CHANGE COLUMN `mailTemplateId` `mail_template_id` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `stationery`, + CHANGE COLUMN `sender` `sender_guid` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Character Global Unique Identifier' AFTER `mail_template_id`, + CHANGE COLUMN `receiver` `receiver_guid` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Character Global Unique Identifier' AFTER `sender_guid`, + CHANGE COLUMN `itemTextId` `item_text_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `subject`; + +ALTER TABLE `mail_items` + CHANGE COLUMN `item_template` `item_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `item_guid`, + CHANGE COLUMN `receiver` `receiver_guid` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Character Global Unique Identifier' AFTER `item_id`; + +ALTER TABLE `petition` + CHANGE COLUMN `ownerguid` `owner_guid` INT(10) UNSIGNED NOT NULL FIRST, + CHANGE COLUMN `petitionguid` `petition_guid` INT(10) UNSIGNED NULL DEFAULT '0' AFTER `owner_guid`, + CHANGE COLUMN `charterguid` `charter_guid` INT(10) UNSIGNED NULL DEFAULT NULL COMMENT 'Charter item GUID' AFTER `petition_guid`; + +ALTER TABLE `petition_sign` + CHANGE COLUMN `ownerguid` `owner_guid` INT(10) UNSIGNED NOT NULL FIRST, + CHANGE COLUMN `petitionguid` `petition_guid` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `owner_guid`, + CHANGE COLUMN `playerguid` `player_guid` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `petition_guid`; + +ALTER TABLE `saved_variables` + CHANGE COLUMN `lastHonorMaintenanceDay` `honor_last_maintenance_day` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `cleaning_flags`, + CHANGE COLUMN `nextHonorMaintenanceDay` `honor_next_maintenance_day` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `honor_last_maintenance_day`, + CHANGE COLUMN `honorMaintenanceMarker` `honor_maintenance_marker` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `honor_next_maintenance_day`; + + +-- End of migration. +END IF; +END?? +delimiter ; +CALL add_migration(); +DROP PROCEDURE IF EXISTS add_migration; diff --git a/src/game/AuctionHouse/AuctionHouseMgr.cpp b/src/game/AuctionHouse/AuctionHouseMgr.cpp index c631d09cc..34bc51177 100644 --- a/src/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouse/AuctionHouseMgr.cpp @@ -174,7 +174,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction) // set owner to bidder (to prevent delete item with sender char deleting) // owner in `data` will set at mail receive and item extracting - CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'", auction->bidder, pItem->GetGUIDLow()); + CharacterDatabase.PExecute("UPDATE `item_instance` SET `owner_guid` = '%u' WHERE `guid`='%u'", auction->bidder, pItem->GetGUIDLow()); CharacterDatabase.CommitTransaction(); if (bidder) @@ -190,7 +190,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction) // receiver not exist else { - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", pItem->GetGUIDLow()); + CharacterDatabase.PExecute("DELETE FROM `item_instance` WHERE `guid`='%u'", pItem->GetGUIDLow()); RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! delete pItem; } @@ -273,7 +273,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction) // owner not found else { - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", pItem->GetGUIDLow()); + CharacterDatabase.PExecute("DELETE FROM `item_instance` WHERE `guid`='%u'", pItem->GetGUIDLow()); RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !! delete pItem; } @@ -344,8 +344,8 @@ void AuctionHouseMgr::LoadAuctionHouses() void AuctionHouseMgr::LoadAuctionItems() { - // 0 1 2 3 4 5 6 7 8 9 10 11 - QueryResult* result = CharacterDatabase.Query("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, text, itemguid, itemEntry FROM auction JOIN item_instance ON itemguid = guid"); + // 0 1 2 3 4 5 6 7 8 9 10 11 + QueryResult* result = CharacterDatabase.Query("SELECT `creator_guid`, `gift_creator_guid`, `count`, `duration`, `charges`, `flags`, `enchantments`, `random_property_id`, `durability`, `text`, `item_guid`, `item_instance`.`item_id` FROM `auction` JOIN `item_instance` ON `item_guid` = `guid`"); if (!result) { @@ -366,20 +366,20 @@ void AuctionHouseMgr::LoadAuctionItems() bar.step(); fields = result->Fetch(); - uint32 item_guid = fields[10].GetUInt32(); - uint32 item_template = fields[11].GetUInt32(); + uint32 itemGuid = fields[10].GetUInt32(); + uint32 itemId = fields[11].GetUInt32(); - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_template); + ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemId); if (!proto) { - sLog.outError("AuctionHouseMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid, item_template); + sLog.outError("AuctionHouseMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", itemGuid, itemId); continue; } Item *item = NewItemOrBag(proto); - if (!item->LoadFromDB(item_guid, ObjectGuid(), fields, item_template)) + if (!item->LoadFromDB(itemGuid, ObjectGuid(), fields, itemId)) { delete item; continue; @@ -420,7 +420,7 @@ void AuctionHouseMgr::LoadAuctions() return; } - result = CharacterDatabase.Query("SELECT id,houseid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit FROM auction"); + result = CharacterDatabase.Query("SELECT `id`, `house_id`, `item_guid`, `item_id`, `seller_guid`, `buyout_price`, `expire_time`, `buyer_guid`, `last_bid`, `start_bid`, `deposit` FROM `auction`"); if (!result) { BarGoLink bar(1); @@ -440,7 +440,7 @@ void AuctionHouseMgr::LoadAuctions() AuctionEntry* auction = new AuctionEntry; auction->Id = fields[0].GetUInt32(); - uint32 houseid = fields[1].GetUInt32(); + uint32 houseId = fields[1].GetUInt32(); auction->itemGuidLow = fields[2].GetUInt32(); auction->itemTemplate = fields[3].GetUInt32(); auction->owner = fields[4].GetUInt32(); @@ -466,9 +466,9 @@ void AuctionHouseMgr::LoadAuctions() continue; } - auction->auctionHouseEntry = sAuctionHouseStore.LookupEntry(houseid); + auction->auctionHouseEntry = sAuctionHouseStore.LookupEntry(houseId); - if (!houseid) + if (!houseId) { // need for send mail, use goblin auctionhouse auction->auctionHouseEntry = sAuctionHouseStore.LookupEntry(7); @@ -544,65 +544,65 @@ uint32 AuctionHouseMgr::GetAuctionHouseTeam(AuctionHouseEntry const* house) uint32 AuctionHouseMgr::GetAuctionHouseId(uint32 factionTemplateId) { - uint32 houseid = 1; + uint32 houseId = 1; switch (factionTemplateId) { case 11: case 12: - houseid = 1; // Human + houseId = 1; // Human break; case 29: case 85: - houseid = 6; // Orc + houseId = 6; // Orc break; case 55: case 57: - houseid = 2; // Dwarf + houseId = 2; // Dwarf break; case 68: case 71: - houseid = 4; // Undead + houseId = 4; // Undead break; case 79: case 80: - houseid = 3; // Night Elf + houseId = 3; // Night Elf break; case 104: case 105: - houseid = 5; // Tauren + houseId = 5; // Tauren break; case 120: - houseid = 7; // Booty Bay + houseId = 7; // Booty Bay break; case 474: - houseid = 7; // Gadgetzan + houseId = 7; // Gadgetzan break; case 534: - houseid = 2; // Alliance Generic + houseId = 2; // Alliance Generic break; case 855: - houseid = 7; // Everlook + houseId = 7; // Everlook break; default: // for unknown case { FactionTemplateEntry const* u_entry = sObjectMgr.GetFactionTemplateEntry(factionTemplateId); if (!u_entry) - houseid = 7; // goblin auction house + houseId = 7; // goblin auction house else if (u_entry->ourMask & FACTION_MASK_ALLIANCE) - houseid = 1; // human auction house + houseId = 1; // human auction house else if (u_entry->ourMask & FACTION_MASK_HORDE) - houseid = 6; // orc auction house + houseId = 6; // orc auction house else - houseid = 7; // goblin auction house + houseId = 7; // goblin auction house break; } } - return houseid; + return houseId; } AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(Unit* unit) { - uint32 houseid = 1; // dwarf auction house (used for normal cut/etc percents) + uint32 houseId = 1; // dwarf auction house (used for normal cut/etc percents) if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) { @@ -611,36 +611,36 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(Unit* unit) // FIXME: found way for proper auctionhouse selection by another way // AuctionHouse.dbc have faction field with _player_ factions associated with auction house races. // but no easy way convert creature faction to player race faction for specific city - houseid = GetAuctionHouseId(unit->GetFactionTemplateId()); + houseId = GetAuctionHouseId(unit->GetFactionTemplateId()); } else { Player* player = (Player*)unit; if (player->GetAuctionAccessMode() > 0) - houseid = 7; + houseId = 7; else { switch (((Player*)unit)->GetTeam()) { case ALLIANCE: - houseid = player->GetAuctionAccessMode() == 0 ? 1 : 6; + houseId = player->GetAuctionAccessMode() == 0 ? 1 : 6; break; case HORDE: - houseid = player->GetAuctionAccessMode() == 0 ? 6 : 1; + houseId = player->GetAuctionAccessMode() == 0 ? 6 : 1; break; } } } } - return sAuctionHouseStore.LookupEntry(houseid); + return sAuctionHouseStore.LookupEntry(houseId); } AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTemplateId) { - uint32 houseid = GetAuctionHouseId(factionTemplateId); + uint32 houseId = GetAuctionHouseId(factionTemplateId); - return sAuctionHouseStore.LookupEntry(houseid); + return sAuctionHouseStore.LookupEntry(houseId); } void AuctionHouseObject::Update() @@ -881,13 +881,13 @@ uint32 AuctionEntry::GetAuctionOutBid() const void AuctionEntry::DeleteFromDB() const { //No SQL injection (Id is integer) - CharacterDatabase.PExecute("DELETE FROM auction WHERE id = '%u'", Id); + CharacterDatabase.PExecute("DELETE FROM `auction` WHERE `id` = '%u'", Id); } void AuctionEntry::SaveToDB() const { //No SQL injection (no strings) - CharacterDatabase.PExecute("INSERT INTO auction (id,houseid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit) " + CharacterDatabase.PExecute("INSERT INTO `auction` (`id`, `house_id`, `item_guid`, `item_id`, `seller_guid`, `buyout_price`, `expire_time`, `buyer_guid`, `last_bid`, `start_bid`, `deposit`) " "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '" UI64FMTD "', '%u', '%u', '%u', '%u')", Id, auctionHouseEntry->houseId, itemGuidLow, itemTemplate, owner, buyout, (uint64)expireTime, bidder, bid, startbid, deposit); } diff --git a/src/game/Battlegrounds/BattleGroundMgr.cpp b/src/game/Battlegrounds/BattleGroundMgr.cpp index 11d6a291d..7a8a56c66 100644 --- a/src/game/Battlegrounds/BattleGroundMgr.cpp +++ b/src/game/Battlegrounds/BattleGroundMgr.cpp @@ -292,24 +292,7 @@ uint32 BattleGroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattleG return 0; } -// Ivina : log player inscription to bg queue. -void BattleGroundQueue::LogQueueInscription(Player* plr, BattleGroundTypeId BgTypeId, uint32 uiAction) -{ - std::string sPName = plr->GetName(); - std::string last_ip; - time_t queuing_time = time(nullptr); - if (WorldSession* session = plr->GetSession()) - last_ip = session->GetRemoteAddress(); - - CharacterDatabase.escape_string(sPName); - CharacterDatabase.escape_string(last_ip); - CharacterDatabase.PExecute("INSERT INTO `character_bgqueue` (`playerGUID`, `playerName`, `playerIP`, `BGtype`, `action`, `time`) " - " VALUES ('%u', '%s', '%s', '%u', '%u', '%u')", - plr->GetGUIDLow(), sPName.c_str(), last_ip.c_str(), BgTypeId, uiAction, queuing_time); - // CharacterDatabase.CommitTransaction(); // Pas de commit de transaction sans un BeginTransaction avant. -} - -//remove player from queue and from group info, if group info is empty then remove it too +// remove player from queue and from group info, if group info is empty then remove it too void BattleGroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount) { //Player* plr = sObjectMgr.GetPlayer(guid); diff --git a/src/game/Battlegrounds/BattleGroundMgr.h b/src/game/Battlegrounds/BattleGroundMgr.h index 2d50dd618..9787c3c04 100644 --- a/src/game/Battlegrounds/BattleGroundMgr.h +++ b/src/game/Battlegrounds/BattleGroundMgr.h @@ -93,7 +93,6 @@ class BattleGroundQueue void RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount); void PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BattleGroundBracketId bracket_id); uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattleGroundBracketId bracket_id); - void LogQueueInscription(Player* plr, BattleGroundTypeId BgTypeId, uint32 uiAction); bool IsPlayerInvited(ObjectGuid guid, uint32 const bgInstanceGuid, uint32 const removeTime); bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo); void PlayerLoggedOut(ObjectGuid guid); diff --git a/src/game/Chat/AsyncCommandHandlers.cpp b/src/game/Chat/AsyncCommandHandlers.cpp index 0e4c56e94..6f2b77be6 100644 --- a/src/game/Chat/AsyncCommandHandlers.cpp +++ b/src/game/Chat/AsyncCommandHandlers.cpp @@ -60,8 +60,8 @@ void PInfoHandler::HandlePInfoCommand(WorldSession* session, Player* target, Obj { data->target_guid = target_guid; CharacterDatabase.AsyncPQuery(&PInfoHandler::HandlePlayerLookupResult, data, - // 0 1 2 3 4 5 - "SELECT `totaltime`, `level`, `money`, `account`, `race`, `class` FROM `characters` WHERE `guid` = '%u'", + // 0 1 2 3 4 5 + "SELECT `played_time_total`, `level`, `money`, `account`, `race`, `class` FROM `characters` WHERE `guid` = '%u'", target_guid.GetCounter()); } } @@ -91,8 +91,8 @@ void PInfoHandler::HandleDataAfterPlayerLookup(PInfoData *data) { SqlQueryHolder* charHolder = new SqlQueryHolder; charHolder->SetSize(2); - charHolder->SetPQuery(PINFO_QUERY_GOLD_SENT, "SELECT SUM(money) FROM mail WHERE sender = %u", data->target_guid.GetCounter()); - charHolder->SetPQuery(PINFO_QUERY_GOLD_RECEIVED, "SELECT SUM(money) FROM mail WHERE receiver = %u", data->target_guid.GetCounter()); + charHolder->SetPQuery(PINFO_QUERY_GOLD_SENT, "SELECT SUM(`money`) FROM `mail` WHERE `sender_guid` = %u", data->target_guid.GetCounter()); + charHolder->SetPQuery(PINFO_QUERY_GOLD_RECEIVED, "SELECT SUM(`money`) FROM `mail` WHERE `receiver_guid` = %u", data->target_guid.GetCounter()); CharacterDatabase.DelayQueryHolder(&PInfoHandler::HandleDelayedMoneyQuery, charHolder, data); } diff --git a/src/game/Chat/MasterPlayer.cpp b/src/game/Chat/MasterPlayer.cpp index 070c55fad..b2aef72ba 100644 --- a/src/game/Chat/MasterPlayer.cpp +++ b/src/game/Chat/MasterPlayer.cpp @@ -101,7 +101,7 @@ void MasterPlayer::SaveMails() Mail *m = (*itr); if (m->state == MAIL_STATE_CHANGED) { - SqlStatement stmt = CharacterDatabase.CreateStatement(updateMail, "UPDATE mail SET itemTextId = ?,has_items = ?, expire_time = ?, deliver_time = ?, money = ?, cod = ?, checked = ? WHERE id = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(updateMail, "UPDATE `mail` SET `item_text_id` = ?, `has_items` = ?, `expire_time` = ?, `deliver_time` = ?, `money` = ?, `cod` = ?, `checked` = ? WHERE `id` = ?"); stmt.addUInt32(m->itemTextId); stmt.addUInt32(m->HasItems() ? 1 : 0); stmt.addUInt64(uint64(m->expire_time)); @@ -114,7 +114,7 @@ void MasterPlayer::SaveMails() if (!m->removedItems.empty()) { - stmt = CharacterDatabase.CreateStatement(deleteMailItems, "DELETE FROM mail_items WHERE item_guid = ?"); + stmt = CharacterDatabase.CreateStatement(deleteMailItems, "DELETE FROM `mail_items` WHERE `item_guid` = ?"); for (const auto removedItem : m->removedItems) stmt.PExecute(removedItem); @@ -127,21 +127,21 @@ void MasterPlayer::SaveMails() { if (m->HasItems()) { - SqlStatement stmt = CharacterDatabase.CreateStatement(deleteItem, "DELETE FROM item_instance WHERE guid = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(deleteItem, "DELETE FROM `item_instance` WHERE `guid` = ?"); for (const auto& item : m->items) - stmt.PExecute(item.item_guid); + stmt.PExecute(item.itemGuid); } if (m->itemTextId && m->stationery != MAIL_STATIONERY_DEFAULT) { - SqlStatement stmt = CharacterDatabase.CreateStatement(deleteItemText, "DELETE FROM item_text WHERE id = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(deleteItemText, "DELETE FROM `item_text` WHERE `id` = ?"); stmt.PExecute(m->itemTextId); } - SqlStatement stmt = CharacterDatabase.CreateStatement(deleteMain, "DELETE FROM mail WHERE id = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(deleteMain, "DELETE FROM `mail` WHERE `id` = ?"); stmt.PExecute(m->messageID); - stmt = CharacterDatabase.CreateStatement(deleteItems, "DELETE FROM mail_items WHERE mail_id = ?"); + stmt = CharacterDatabase.CreateStatement(deleteItems, "DELETE FROM `mail_items` WHERE `mail_id` = ?"); stmt.PExecute(m->messageID); } } @@ -214,8 +214,8 @@ void MasterPlayer::AddNewMailDeliverTime(time_t deliver_time) void MasterPlayer::LoadMailedItems(QueryResult* result) { // data needs to be at first place for Item::LoadFromDB - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 - // creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, text, mail_id, item_guid, itemEntry, generated_loot + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 + // creator_guid, gift_creator_guid, count, duration, charges, flags, enchantments, random_property_id, durability, text, mail_id, item_guid, item_id, generated_loot if (!result) return; @@ -223,22 +223,22 @@ void MasterPlayer::LoadMailedItems(QueryResult* result) { Field* fields = result->Fetch(); uint32 mail_id = fields[10].GetUInt32(); - uint32 item_guid_low = fields[11].GetUInt32(); - uint32 item_template = fields[12].GetUInt32(); + uint32 itemGuidLow = fields[11].GetUInt32(); + uint32 itemId = fields[12].GetUInt32(); Mail* mail = GetMail(mail_id); if (!mail) continue; - mail->AddItem(item_guid_low, item_template); + mail->AddItem(itemGuidLow, itemId); - ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_template); + ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemId); if (!proto) { - sLog.outError("Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template, mail->messageID); - CharacterDatabase.PExecute("INSERT INTO character_deleted_items (player_guid, item_entry, stack_count) VALUES ('%u', '%u', '%u')", GetGUIDLow(), item_template, fields[2].GetUInt32()); - CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low); - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guid_low); + sLog.outError("Player %u has unknown item Id (ProtoType) in mailed items (GUID: %u Id: %u) in mail (%u), deleted.", GetGUIDLow(), itemGuidLow, itemId, mail->messageID); + CharacterDatabase.PExecute("INSERT INTO `character_deleted_items` (`player_guid`, `item_id`, `stack_count`) VALUES ('%u', '%u', '%u')", GetGUIDLow(), itemId, fields[2].GetUInt32()); + CharacterDatabase.PExecute("DELETE FROM `mail_items` WHERE `item_guid` = '%u'", itemGuidLow); + CharacterDatabase.PExecute("DELETE FROM `item_instance` WHERE `guid` = '%u'", itemGuidLow); continue; } @@ -250,10 +250,10 @@ void MasterPlayer::LoadMailedItems(QueryResult* result) */ item->SetGeneratedLoot(fields[13].GetBool()); - if (!item->LoadFromDB(item_guid_low, GetObjectGuid(), fields, item_template)) + if (!item->LoadFromDB(itemGuidLow, GetObjectGuid(), fields, itemId)) { - sLog.outError("Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, item_guid_low); - CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low); + sLog.outError("Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, itemGuidLow); + CharacterDatabase.PExecute("DELETE FROM `mail_items` WHERE `item_guid` = '%u'", itemGuidLow); item->FSetState(ITEM_REMOVED); item->SaveToDB(); // it also deletes item object ! continue; @@ -269,8 +269,8 @@ void MasterPlayer::LoadMails(QueryResult* result) m_mail.clear(); Player* player = GetSession()->GetPlayer(); ASSERT(player); - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 - //"SELECT id,messageType,sender,receiver,subject,itemTextId,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId,has_items FROM mail WHERE receiver = '%u' ORDER BY id DESC",GetGUIDLow() + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 + //"SELECT id, message_type, sender_guid, receiver_guid, subject, item_text_id, expire_time, deliver_time, money, cod, checked, stationery, mail_template_id, has_items FROM mail WHERE receiver_guid = '%u' ORDER BY id DESC",GetGUIDLow() if (!result) return; diff --git a/src/game/Commands/CharacterCommands.cpp b/src/game/Commands/CharacterCommands.cpp index c8ff2dde2..529087ef1 100644 --- a/src/game/Commands/CharacterCommands.cpp +++ b/src/game/Commands/CharacterCommands.cpp @@ -1210,7 +1210,7 @@ bool ChatHandler::GetDeletedCharacterInfoList(DeletedInfoList& foundList, bool u { // search by GUID if (isNumeric(searchString)) - resultChar = CharacterDatabase.PQuery("SELECT `guid`, `deleteInfos_Name`, `deleteInfos_Account`, `deleteDate` FROM `characters` WHERE `deleteDate` IS NOT NULL AND `guid` = %u LIMIT 0,50", uint32(atoi(searchString.c_str()))); + resultChar = CharacterDatabase.PQuery("SELECT `guid`, `deleted_name`, `deleted_account`, `deleted_time` FROM `characters` WHERE `deleted_time` IS NOT NULL AND `guid` = %u LIMIT 0,50", uint32(atoi(searchString.c_str()))); // search by name else { @@ -1219,14 +1219,14 @@ bool ChatHandler::GetDeletedCharacterInfoList(DeletedInfoList& foundList, bool u CharacterDatabase.escape_string(searchString); - resultChar = CharacterDatabase.PQuery("SELECT `guid`, `deleteInfos_Name`, `deleteInfos_Account`, `deleteDate` FROM `characters` WHERE `deleteDate` IS NOT NULL AND `deleteInfos_Name` " _LIKE_ " " _CONCAT2_("'%s'", "'%%'") " LIMIT 0,50", searchString.c_str()); + resultChar = CharacterDatabase.PQuery("SELECT `guid`, `deleted_name`, `deleted_account`, `deleted_time` FROM `characters` WHERE `deleted_time` IS NOT NULL AND `deleted_name` " _LIKE_ " " _CONCAT2_("'%s'", "'%%'") " LIMIT 0,50", searchString.c_str()); } } else { // search by account id if (isNumeric(searchString)) - resultChar = CharacterDatabase.PQuery("SELECT `guid`, `deleteInfos_Name`, `deleteInfos_Account`, `deleteDate` FROM `characters` WHERE `deleteDate` IS NOT NULL AND `deleteInfos_Account` = %u LIMIT 0,50", uint32(atoi(searchString.c_str()))); + resultChar = CharacterDatabase.PQuery("SELECT `guid`, `deleted_name`, `deleted_account`, `deleted_time` FROM `characters` WHERE `deleted_time` IS NOT NULL AND `deleted_account` = %u LIMIT 0,50", uint32(atoi(searchString.c_str()))); // search by account name else { @@ -1254,12 +1254,12 @@ bool ChatHandler::GetDeletedCharacterInfoList(DeletedInfoList& foundList, bool u std::copy(list.begin(), list.end(), std::ostream_iterator(accountStream, ",")); std::string accounts = accountStream.str(); accounts.pop_back(); - resultChar = CharacterDatabase.PQuery("SELECT `guid`, `deleteInfos_Name`, `deleteInfos_Account`, `deleteDate` FROM `characters` WHERE `deleteDate` IS NOT NULL AND `deleteInfos_Account` IN (%s) LIMIT 0,50", accounts.c_str()); + resultChar = CharacterDatabase.PQuery("SELECT `guid`, `deleted_name`, `deleted_account`, `deleted_time` FROM `characters` WHERE `deleted_time` IS NOT NULL AND `deleted_account` IN (%s) LIMIT 0,50", accounts.c_str()); } } } else - resultChar = CharacterDatabase.Query("SELECT `guid`, `deleteInfos_Name`, `deleteInfos_Account`, `deleteDate` FROM `characters` WHERE `deleteDate` IS NOT NULL LIMIT 0,50"); + resultChar = CharacterDatabase.Query("SELECT `guid`, `deleted_name`, `deleted_account`, `deleted_time` FROM `characters` WHERE `deleted_time` IS NOT NULL LIMIT 0,50"); if (resultChar) { @@ -1420,7 +1420,7 @@ void ChatHandler::HandleCharacterDeletedRestoreHelper(DeletedInfo const& delInfo return; } - CharacterDatabase.PExecute("UPDATE `characters` SET `name`='%s', `account`='%u', `deleteDate`=NULL, `deleteInfos_Name`=NULL, `deleteInfos_Account`=NULL WHERE `deleteDate` IS NOT NULL AND `guid` = %u", + CharacterDatabase.PExecute("UPDATE `characters` SET `name`='%s', `account`='%u', `deleted_time`=NULL, `deleted_name`=NULL, `deleted_account`=NULL WHERE `deleted_time` IS NOT NULL AND `guid` = %u", delInfo.name.c_str(), delInfo.accountId, delInfo.lowguid); } @@ -1645,7 +1645,7 @@ bool ChatHandler::HandleCleanCharactersItemsCommand(char* args) PSendSysMessage("%u items to delete.", lDeleteEntries.size()); delete listDeleteItems; - QueryResult* allPlayersItems = CharacterDatabase.Query("SELECT `guid`, `itemEntry`, `owner_guid` FROM `item_instance`;"); + QueryResult* allPlayersItems = CharacterDatabase.Query("SELECT `guid`, `item_id`, `owner_guid` FROM `item_instance`;"); if (!allPlayersItems) { SendSysMessage("Unable to retrieve player items list."); @@ -1660,21 +1660,21 @@ bool ChatHandler::HandleCleanCharactersItemsCommand(char* args) { ++totalItems; fields = allPlayersItems->Fetch(); - uint32 item_guid = fields[0].GetUInt32(); - uint32 item_entry = fields[1].GetUInt32(); - uint32 owner_guid = fields[2].GetUInt32(); + uint32 itemGuid = fields[0].GetUInt32(); + uint32 itemId = fields[1].GetUInt32(); + uint32 ownerGuid = fields[2].GetUInt32(); for (itr = lDeleteEntries.begin(); itr != lDeleteEntries.end(); ++itr) { - if ((*itr) == item_entry) + if ((*itr) == itemId) { if (Real) { // InGame ? - if (Player* pPlayer = sObjectMgr.GetPlayer(owner_guid)) - pPlayer->DestroyItemCount(item_entry, 255, true); + if (Player* pPlayer = sObjectMgr.GetPlayer(ownerGuid)) + pPlayer->DestroyItemCount(itemId, 255, true); else - Item::DeleteAllFromDB(item_guid); + Item::DeleteAllFromDB(itemGuid); } ++deleteCount; break; @@ -1783,7 +1783,7 @@ bool ChatHandler::HandleCharacterRenameCommand(char* args) PSendSysMessage(LANG_RENAME_PLAYER, GetNameLink(target).c_str()); target->SetAtLoginFlag(AT_LOGIN_RENAME); - CharacterDatabase.PExecute("UPDATE `characters` SET `at_login` = `at_login` | '1' WHERE `guid` = '%u'", target->GetGUIDLow()); + CharacterDatabase.PExecute("UPDATE `characters` SET `at_login_flags` = `at_login_flags` | '1' WHERE `guid` = '%u'", target->GetGUIDLow()); } else { @@ -1794,7 +1794,7 @@ bool ChatHandler::HandleCharacterRenameCommand(char* args) std::string oldNameLink = playerLink(target_name); PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), target_guid.GetCounter()); - CharacterDatabase.PExecute("UPDATE `characters` SET `at_login` = `at_login` | '1' WHERE `guid` = '%u'", target_guid.GetCounter()); + CharacterDatabase.PExecute("UPDATE `characters` SET `at_login_flags` = `at_login_flags` | '1' WHERE `guid` = '%u'", target_guid.GetCounter()); } return true; @@ -1852,7 +1852,7 @@ bool ChatHandler::HandleCharacterHasItemCommand(char* args) else { std::unique_ptr result(CharacterDatabase.PQuery( - "SELECT SUM(`count`) AS item_count FROM `item_instance` ii WHERE `itemEntry` = %u and `owner_guid` = %u", + "SELECT SUM(`count`) AS item_count FROM `item_instance` ii WHERE `item_id` = %u and `owner_guid` = %u", itemId, target_guid.GetCounter() )); @@ -2101,7 +2101,8 @@ bool ChatHandler::HandleCharacterCopySkinCommand(char* args) std::string plName(args); CharacterDatabase.escape_string(plName); // No SQL injection - QueryResult* result = CharacterDatabase.PQuery("SELECT `playerBytes`, `playerBytes2` & 0xFF, `gender` FROM `characters` WHERE `name`='%s'", plName.c_str()); + // 0 1 2 3 4 5 + QueryResult* result = CharacterDatabase.PQuery("SELECT `skin`, `face`, `hair_style`, `hair_color`, `facial_hair`, `gender` FROM `characters` WHERE `name`='%s'", plName.c_str()); if (!result) { PSendSysMessage("Player %s not found.", args); @@ -2109,12 +2110,17 @@ bool ChatHandler::HandleCharacterCopySkinCommand(char* args) return false; } Field* fields = result->Fetch(); - uint32 bytes = fields[0].GetUInt32(); - uint32 bytes2 = fields[1].GetUInt32(); - uint8 gender = fields[2].GetUInt8(); - bytes2 |= (target->GetUInt32Value(PLAYER_BYTES_2) & 0xFFFFFF00); - target->SetUInt32Value(PLAYER_BYTES, bytes); - target->SetUInt32Value(PLAYER_BYTES_2, bytes2); + uint8 skin = fields[0].GetUInt32(); + uint8 face = fields[1].GetUInt32(); + uint8 hairStyle = fields[2].GetUInt32(); + uint8 hairColor = fields[3].GetUInt32(); + uint8 facialHair = fields[4].GetUInt32(); + uint8 gender = fields[5].GetUInt8(); + target->SetByteValue(PLAYER_BYTES, 0, skin); + target->SetByteValue(PLAYER_BYTES, 1, face); + target->SetByteValue(PLAYER_BYTES, 2, hairStyle); + target->SetByteValue(PLAYER_BYTES, 3, hairColor); + target->SetByteValue(PLAYER_BYTES_2, 0, facialHair); target->SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, gender); SendSysMessage("Modification du skin/genre OK."); return true; @@ -3091,7 +3097,7 @@ bool ChatHandler::HandleDeleteItemCommand(char* args) else { std::unique_ptr result(CharacterDatabase.PQuery( - "SELECT SUM(`count`) AS item_count FROM `item_instance` ii WHERE `itemEntry` = %u and `owner_guid` = %u", + "SELECT SUM(`count`) AS item_count FROM `item_instance` ii WHERE `item_id` = %u and `owner_guid` = %u", itemId, target_guid.GetCounter() )); @@ -3115,7 +3121,7 @@ bool ChatHandler::HandleDeleteItemCommand(char* args) while (stacksToRemove) { result.reset(CharacterDatabase.PQuery( - "SELECT `guid`, `count` FROM `item_instance` ii WHERE `itemEntry` = %u and `owner_guid` = %u ORDER BY `count` DESC", + "SELECT `guid`, `count` FROM `item_instance` ii WHERE `item_id` = %u and `owner_guid` = %u ORDER BY `count` DESC", itemId, target_guid.GetCounter() )); @@ -3151,7 +3157,7 @@ bool ChatHandler::HandleDeleteItemCommand(char* args) return false; } - if (!CharacterDatabase.DirectPExecute("DELETE FROM `character_inventory` WHERE `item` = %u", guid)) + if (!CharacterDatabase.DirectPExecute("DELETE FROM `character_inventory` WHERE `item_guid` = %u", guid)) { SendSysMessage("Encountered an error while attempting to remove item from inventory"); SetSentErrorMessage(true); @@ -3274,7 +3280,7 @@ bool ChatHandler::HandleListItemCommand(char* args) // inventory case uint32 inv_count = 0; - result = CharacterDatabase.PQuery("SELECT COUNT(`item_template`) FROM `character_inventory` WHERE `item_template`='%u'", item_id); + result = CharacterDatabase.PQuery("SELECT COUNT(`item_id`) FROM `character_inventory` WHERE `item_id`='%u'", item_id); if (result) { inv_count = (*result)[0].GetUInt32(); @@ -3282,10 +3288,10 @@ bool ChatHandler::HandleListItemCommand(char* args) } result = CharacterDatabase.PQuery( - // 0 1 2 3 4 5 - "SELECT ci.`item`, cibag.`slot` AS bag, ci.`slot`, ci.`guid`, `characters`.`account`, `characters`.`name` " - "FROM `character_inventory` AS ci LEFT JOIN `character_inventory` AS cibag ON (cibag.`item`=ci.`bag`), `characters` " - "WHERE ci.`item_template`='%u' AND ci.`guid` = `characters`.`guid` LIMIT %u ", + // 0 1 2 3 4 5 + "SELECT ci.`item_guid`, cibag.`slot` AS bag, ci.`slot`, ci.`guid`, `characters`.`account`, `characters`.`name` " + "FROM `character_inventory` AS ci LEFT JOIN `character_inventory` AS cibag ON (cibag.`item_guid`=ci.`bag`), `characters` " + "WHERE ci.`item_id`='%u' AND ci.`guid` = `characters`.`guid` LIMIT %u ", item_id, uint32(count)); if (result) @@ -3327,7 +3333,7 @@ bool ChatHandler::HandleListItemCommand(char* args) // mail case uint32 mail_count = 0; - result = CharacterDatabase.PQuery("SELECT COUNT(`item_template`) FROM `mail_items` WHERE `item_template`='%u'", item_id); + result = CharacterDatabase.PQuery("SELECT COUNT(`item_id`) FROM `mail_items` WHERE `item_id`='%u'", item_id); if (result) { mail_count = (*result)[0].GetUInt32(); @@ -3337,10 +3343,10 @@ bool ChatHandler::HandleListItemCommand(char* args) if (count > 0) { result = CharacterDatabase.PQuery( - // 0 1 2 3 4 5 6 - "SELECT `mail_items`.`item_guid`, `mail`.`sender`, `mail`.`receiver`, char_s.`account`, char_s.`name`, char_r.`account`, char_r.`name` " + // 0 1 2 3 4 5 6 + "SELECT `mail_items`.`item_guid`, `mail`.`sender_guid`, `mail`.`receiver_guid`, char_s.`account`, char_s.`name`, char_r.`account`, char_r.`name` " "FROM `mail`, `mail_items`, `characters` as char_s, `characters` as char_r " - "WHERE `mail_items`.`item_template`='%u' AND char_s.`guid` = `mail`.`sender` AND char_r.`guid` = `mail`.`receiver` AND `mail`.`id`=`mail_items`.`mail_id` LIMIT %u", + "WHERE `mail_items`.`item_id`='%u' AND char_s.`guid` = `mail`.`sender_guid` AND char_r.`guid` = `mail`.`receiver_guid` AND `mail`.`id`=`mail_items`.`mail_id` LIMIT %u", item_id, uint32(count)); } else @@ -3378,7 +3384,7 @@ bool ChatHandler::HandleListItemCommand(char* args) // auction case uint32 auc_count = 0; - result = CharacterDatabase.PQuery("SELECT COUNT(`item_template`) FROM `auction` WHERE `item_template`='%u'", item_id); + result = CharacterDatabase.PQuery("SELECT COUNT(`item_id`) FROM `auction` WHERE `item_id`='%u'", item_id); if (result) { auc_count = (*result)[0].GetUInt32(); @@ -3388,9 +3394,9 @@ bool ChatHandler::HandleListItemCommand(char* args) if (count > 0) { result = CharacterDatabase.PQuery( - // 0 1 2 3 - "SELECT `auction`.`itemguid`, `auction`.`itemowner`, `characters`.`account`, `characters`.`name` " - "FROM `auction`, `characters` WHERE `auction`.`item_template`='%u' AND `characters`.`guid` = `auction`.`itemowner` LIMIT %u", + // 0 1 2 3 + "SELECT `auction`.`item_guid`, `auction`.`seller_guid`, `characters`.`account`, `characters`.`name` " + "FROM `auction`, `characters` WHERE `auction`.`item_id`='%u' AND `characters`.`guid` = `auction`.`seller_guid` LIMIT %u", item_id, uint32(count)); } else @@ -3576,7 +3582,7 @@ bool ChatHandler::HandleResetSpellsCommand(char* args) } else { - CharacterDatabase.PExecute("UPDATE `characters` SET `at_login` = `at_login` | '%u' WHERE `guid` = '%u'", uint32(AT_LOGIN_RESET_SPELLS), target_guid.GetCounter()); + CharacterDatabase.PExecute("UPDATE `characters` SET `at_login_flags` = `at_login_flags` | '%u' WHERE `guid` = '%u'", uint32(AT_LOGIN_RESET_SPELLS), target_guid.GetCounter()); PSendSysMessage(LANG_RESET_SPELLS_OFFLINE, target_name.c_str()); } @@ -3602,7 +3608,7 @@ bool ChatHandler::HandleResetTalentsCommand(char* args) else if (target_guid) { uint32 at_flags = AT_LOGIN_RESET_TALENTS; - CharacterDatabase.PExecute("UPDATE `characters` SET `at_login` = `at_login` | '%u' WHERE `guid` = '%u'", at_flags, target_guid.GetCounter()); + CharacterDatabase.PExecute("UPDATE `characters` SET `at_login_flags` = `at_login_flags` | '%u' WHERE `guid` = '%u'", at_flags, target_guid.GetCounter()); std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_RESET_TALENTS_OFFLINE, nameLink.c_str()); } @@ -3692,7 +3698,7 @@ bool ChatHandler::HandleResetAllCommand(char* args) return false; } - CharacterDatabase.PExecute("UPDATE `characters` SET `at_login` = `at_login` | '%u' WHERE (`at_login` & '%u') = '0'", atLogin, atLogin); + CharacterDatabase.PExecute("UPDATE `characters` SET `at_login_flags` = `at_login_flags` | '%u' WHERE (`at_login_flags` & '%u') = '0'", atLogin, atLogin); HashMapHolder::MapType const& plist = sObjectAccessor.GetPlayers(); for (const auto& itr : plist) itr.second->SetAtLoginFlag(atLogin); @@ -5033,7 +5039,7 @@ bool ChatHandler::HandlePetRenameCommand(char* args) return false; } - std::unique_ptr result(CharacterDatabase.PQuery("SELECT `owner`, `name` FROM `character_pet` WHERE `id` = %u", petId)); + std::unique_ptr result(CharacterDatabase.PQuery("SELECT `owner_guid`, `name` FROM `character_pet` WHERE `id` = %u", petId)); if (!result) { @@ -5072,7 +5078,7 @@ bool ChatHandler::HandlePetDeleteCommand(char* args) SetSentErrorMessage(true); return false; } - PSendSysMessage("Pet #%u (\"%s\", owner #%u) deleted.", petData->id, petData->name.c_str(), petData->owner); + PSendSysMessage("Pet #%u (\"%s\", owner #%u) deleted.", petData->id, petData->name.c_str(), petData->ownerGuid); CharacterDatabase.PExecute("DELETE FROM `character_pet` WHERE `id` = %u", petId); sCharacterDatabaseCache.DeleteCharacterPetById(petId); return true; @@ -5190,7 +5196,7 @@ bool ChatHandler::HandleServiceDeleteCharacters(char* args) " `characters`.`account`," " `characters`.`level` AS `level`," " `characters`.`money` AS `money`," - " `characters`.`totaltime` AS `totaltime`," + " `characters`.`played_time_total` AS `played_time_total`," " COUNT(`characters`.`guid`) AS `items`," " `characters`.`logout_time` AS `logout_time` " "FROM `characters` " @@ -5234,7 +5240,7 @@ bool ChatHandler::HandleServiceDeleteCharacters(char* args) if (!ExtractUInt32(&args, maxPlayedTime)) return false; - s << (_and ? "AND " : "") << "`totaltime` <= " << maxPlayedTime << " "; + s << (_and ? "AND " : "") << "`played_time_total` <= " << maxPlayedTime << " "; _and = true; } diff --git a/src/game/Commands/UnitCommands.cpp b/src/game/Commands/UnitCommands.cpp index 4f712be95..134acd825 100644 --- a/src/game/Commands/UnitCommands.cpp +++ b/src/game/Commands/UnitCommands.cpp @@ -581,7 +581,7 @@ bool ChatHandler::HandleAuraHelper(uint32 spellId, int32 duration, Unit* unit) if (duration > 0) holder->SetAuraDuration(duration * IN_MILLISECONDS); - for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { uint8 eff = spellInfo->Effect[i]; if (eff >= TOTAL_SPELL_EFFECTS) @@ -667,7 +667,7 @@ bool ChatHandler::HandleListAurasCommand(char* /*args*/) SpellAuraHolder* holder = aura.second; char const* name = holder->GetSpellProto()->SpellName[GetSessionDbcLocale()].c_str(); - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { Aura* aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i)); if (!aur) diff --git a/src/game/Database/CharacterDatabaseCache.cpp b/src/game/Database/CharacterDatabaseCache.cpp index 4fbc453e4..07d559253 100644 --- a/src/game/Database/CharacterDatabaseCache.cpp +++ b/src/game/Database/CharacterDatabaseCache.cpp @@ -29,9 +29,9 @@ void CharacterDatabaseCache::LoadCharacterPet(uint32 singlePetId) if (singlePetId) { result.reset(CharacterDatabase.PQuery( - "SELECT `id`, `entry`, `owner`, `modelid`, `level`, `exp`, `Reactstate`, `loyaltypoints`, `loyalty`, `trainpoint`, " - "`slot`, `name`, `renamed`, `curhealth`, `curmana`, `curhappiness`, `abdata`, `TeachSpelldata`, `savetime`, `resettalents_cost`, " - "`resettalents_time`, `CreatedBySpell`, `PetType` FROM `character_pet` WHERE `id`=%u", singlePetId + "SELECT `id`, `entry`, `owner_guid`, `display_id`, `level`, `xp`, `react_state`, `loyalty_points`, `loyalty`, `training_points`, " + "`slot`, `name`, `renamed`, `current_health`, `current_mana`, `current_happiness`, `action_bar_data`, `teach_spell_data`, `save_time`, `reset_talents_cost`, " + "`reset_talents_time`, `created_by_spell`, `pet_type` FROM `character_pet` WHERE `id`=%u", singlePetId )); } else if (!singlePetId) @@ -39,9 +39,9 @@ void CharacterDatabaseCache::LoadCharacterPet(uint32 singlePetId) m_petsByCharacter.clear(); sLog.outString("* Loading table `character_pet`"); result.reset(CharacterDatabase.Query( - "SELECT `id`, `entry`, `owner`, `modelid`, `level`, `exp`, `Reactstate`, `loyaltypoints`, `loyalty`, `trainpoint`, " - "`slot`, `name`, `renamed`, `curhealth`, `curmana`, `curhappiness`, `abdata`, `TeachSpelldata`, `savetime`, `resettalents_cost`, " - "`resettalents_time`, `CreatedBySpell`, `PetType` FROM `character_pet`" + "SELECT `id`, `entry`, `owner_guid`, `display_id`, `level`, `xp`, `react_state`, `loyalty_points`, `loyalty`, `training_points`, " + "`slot`, `name`, `renamed`, `current_health`, `current_mana`, `current_happiness`, `action_bar_data`, `teach_spell_data`, `save_time`, `reset_talents_cost`, " + "`reset_talents_time`, `created_by_spell`, `pet_type` FROM `character_pet`" )); } @@ -55,27 +55,27 @@ void CharacterDatabaseCache::LoadCharacterPet(uint32 singlePetId) CharacterPetCache* pCache = new CharacterPetCache; pCache->id = fields[0].GetUInt32(); pCache->entry = fields[1].GetUInt32(); - pCache->owner = fields[2].GetUInt32(); - pCache->modelid = fields[3].GetUInt32(); + pCache->ownerGuid = fields[2].GetUInt32(); + pCache->displayId = fields[3].GetUInt32(); pCache->level = fields[4].GetUInt32(); - pCache->exp = fields[5].GetUInt32(); - pCache->Reactstate = fields[6].GetUInt8(); - pCache->loyaltypoints = fields[7].GetInt32(); + pCache->xp = fields[5].GetUInt32(); + pCache->reactState = fields[6].GetUInt8(); + pCache->loyaltyPoints = fields[7].GetInt32(); pCache->loyalty = fields[8].GetUInt32(); - pCache->trainpoint = fields[9].GetInt32(); + pCache->trainingPoints = fields[9].GetInt32(); pCache->slot = fields[10].GetUInt32(); pCache->name = fields[11].GetCppString(); pCache->renamed = fields[12].GetBool(); - pCache->curhealth = fields[13].GetUInt32(); - pCache->curmana = fields[14].GetUInt32(); - pCache->curhappiness = fields[15].GetUInt32(); - pCache->abdata = fields[16].GetCppString(); - pCache->TeachSpelldata = fields[17].GetCppString(); - pCache->savetime = fields[18].GetUInt64(); - pCache->resettalents_cost = fields[19].GetUInt32(); - pCache->resettalents_time = fields[20].GetUInt32(); - pCache->CreatedBySpell = fields[21].GetUInt32(); - pCache->PetType = fields[22].GetUInt32(); + pCache->currentHealth = fields[13].GetUInt32(); + pCache->currentMana = fields[14].GetUInt32(); + pCache->currentHappiness = fields[15].GetUInt32(); + pCache->actionBarData = fields[16].GetCppString(); + pCache->teachSpellData = fields[17].GetCppString(); + pCache->saveTime = fields[18].GetUInt64(); + pCache->resetTalentsCost = fields[19].GetUInt32(); + pCache->resetTalentsTime = fields[20].GetUInt32(); + pCache->createdBySpell = fields[21].GetUInt32(); + pCache->petType = fields[22].GetUInt32(); ++count; InsertCharacterPet(pCache); } @@ -149,7 +149,7 @@ void CharacterDatabaseCache::LoadPetSpellCooldown(uint32 singlePetId) { // Clear previously stored cooldowns for (const auto& it : m_petsByGuid) - it.second->spellCooldown.clear(); + it.second->spellCooldowns.clear(); sLog.outString("* Loading `pet_spell_cooldown`"); result.reset(CharacterDatabase.Query( @@ -177,7 +177,7 @@ void CharacterDatabaseCache::LoadPetSpellCooldown(uint32 singlePetId) PetSpellCoodown _spellStruct; _spellStruct.spell = spellId; _spellStruct.time = time; - lastPetCache->spellCooldown.push_back(_spellStruct); + lastPetCache->spellCooldowns.push_back(_spellStruct); ++count; } while (result->NextRow()); @@ -192,8 +192,8 @@ void CharacterDatabaseCache::LoadPetAura(uint32 singlePetId) if (singlePetId) { result.reset(CharacterDatabase.PQuery( - "SELECT `guid`, `caster_guid`, `item_guid`, `spell`, `stackcount`, `remaincharges`, `maxduration`, `remaintime`, `effIndexMask`, " - "`basepoints0`, `basepoints1`, `basepoints2`, `periodictime0`, `periodictime1`, `periodictime2` " + "SELECT `guid`, `caster_guid`, `item_guid`, `spell`, `stacks`, `charges`, `max_duration`, `duration`, `effect_index_mask`, " + "`base_points0`, `base_points1`, `base_points2`, `periodic_time0`, `periodic_time1`, `periodic_time2` " "FROM `pet_aura` WHERE `guid`=%u", singlePetId )); } @@ -205,10 +205,10 @@ void CharacterDatabaseCache::LoadPetAura(uint32 singlePetId) sLog.outString("* Loading table `pet_aura`"); result.reset(CharacterDatabase.Query( - // 0 1 2 3 4 5 6 7 8 - "SELECT `guid`, `caster_guid`, `item_guid`, `spell`, `stackcount`, `remaincharges`, `maxduration`, `remaintime`, `effIndexMask`, " - // 9 -> 11 12 -> 14 - "`basepoints0`, `basepoints1`, `basepoints2`, `periodictime0`, `periodictime1`, `periodictime2` " + // 0 1 2 3 4 5 6 7 8 + "SELECT `guid`, `caster_guid`, `item_guid`, `spell`, `stacks`, `charges`, `max_duration`, `duration`, `effect_index_mask`, " + // 9 -> 11 12 -> 14 + "`base_points0`, `base_points1`, `base_points2`, `periodic_time0`, `periodic_time1`, `periodic_time2` " "FROM `pet_aura` ORDER BY `guid` ASC" )); } @@ -230,22 +230,22 @@ void CharacterDatabaseCache::LoadPetAura(uint32 singlePetId) continue; PetAuraCache _auraStruct; - _auraStruct.caster_guid = fields[1].GetUInt64(); - _auraStruct.item_guid = fields[2].GetUInt32(); - _auraStruct.spell = fields[3].GetUInt32(); - _auraStruct.stackcount = fields[4].GetUInt32(); - _auraStruct.remaincharges = fields[5].GetUInt32(); - _auraStruct.maxduration = fields[6].GetInt32(); - _auraStruct.remaintime = fields[7].GetInt32(); - _auraStruct.effIndexMask = fields[8].GetUInt32(); + _auraStruct.casterGuid = fields[1].GetUInt64(); + _auraStruct.itemLowGuid = fields[2].GetUInt32(); + _auraStruct.spellId = fields[3].GetUInt32(); + _auraStruct.stacks = fields[4].GetUInt32(); + _auraStruct.charges = fields[5].GetUInt32(); + _auraStruct.maxDuration = fields[6].GetInt32(); + _auraStruct.duration = fields[7].GetInt32(); + _auraStruct.effIndexMask = fields[8].GetUInt8(); - for (int i = 0; i < 3; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { - _auraStruct.basepoints[i] = fields[9 + i].GetInt32(); - _auraStruct.periodictime[i] = fields[12 + i].GetUInt32(); + _auraStruct.damage[i] = fields[9 + i].GetFloat(); + _auraStruct.periodicTime[i] = fields[12 + i].GetUInt32(); } - if (!_auraStruct.spell) + if (!_auraStruct.spellId) continue; lastPetCache->auras.push_back(_auraStruct); @@ -265,10 +265,10 @@ CharacterPetCache* CharacterDatabaseCache::GetCharacterPetById(uint32 id) return petStruct->second; } -CharacterPetCache* CharacterDatabaseCache::GetCharacterPetCacheByOwnerAndId(uint64 owner, uint32 id) +CharacterPetCache* CharacterDatabaseCache::GetCharacterPetCacheByOwnerAndId(uint32 ownerGuidLow, uint32 id) { - // FROM character_pet WHERE owner = '%u' AND id = '%u' - CharPetMap::iterator ownerPets = m_petsByCharacter.find(owner); + // FROM character_pet WHERE owner_guid = '%u' AND id = '%u' + CharPetMap::iterator ownerPets = m_petsByCharacter.find(ownerGuidLow); if (ownerPets == m_petsByCharacter.end()) return nullptr; for (const auto& it : ownerPets->second) @@ -278,10 +278,10 @@ CharacterPetCache* CharacterDatabaseCache::GetCharacterPetCacheByOwnerAndId(uint return nullptr; } -CharacterPetCache* CharacterDatabaseCache::GetCharacterCurrentPet(uint64 owner) +CharacterPetCache* CharacterDatabaseCache::GetCharacterCurrentPet(uint32 ownerGuidLow) { - // FROM character_pet WHERE owner = '%u' AND slot = 'PET_SAVE_AS_CURRENT' - CharPetMap::iterator ownerPets = m_petsByCharacter.find(owner); + // FROM character_pet WHERE owner_guid = '%u' AND slot = 'PET_SAVE_AS_CURRENT' + CharPetMap::iterator ownerPets = m_petsByCharacter.find(ownerGuidLow); if (ownerPets == m_petsByCharacter.end()) return nullptr; for (const auto& it : ownerPets->second) @@ -291,10 +291,10 @@ CharacterPetCache* CharacterDatabaseCache::GetCharacterCurrentPet(uint64 owner) return nullptr; } -CharacterPetCache* CharacterDatabaseCache::GetCharacterPetByOwnerAndEntry(uint64 owner, uint32 entry) +CharacterPetCache* CharacterDatabaseCache::GetCharacterPetByOwnerAndEntry(uint32 ownerGuidLow, uint32 entry) { - // FROM character_pet WHERE owner = '%u' AND entry = '%u' AND (slot = 'PET_SAVE_AS_CURRENT' OR slot > 'PET_SAVE_LAST_STABLE_SLOT') - CharPetMap::iterator ownerPets = m_petsByCharacter.find(owner); + // FROM character_pet WHERE owner_guid = '%u' AND entry = '%u' AND (slot = 'PET_SAVE_AS_CURRENT' OR slot > 'PET_SAVE_LAST_STABLE_SLOT') + CharPetMap::iterator ownerPets = m_petsByCharacter.find(ownerGuidLow); if (ownerPets == m_petsByCharacter.end()) return nullptr; for (const auto& it : ownerPets->second) @@ -304,10 +304,10 @@ CharacterPetCache* CharacterDatabaseCache::GetCharacterPetByOwnerAndEntry(uint64 return nullptr; } -CharacterPetCache* CharacterDatabaseCache::GetCharacterPetByOwner(uint64 owner) +CharacterPetCache* CharacterDatabaseCache::GetCharacterPetByOwner(uint32 ownerGuidLow) { - // FROM character_pet WHERE owner = '%u' AND (slot = 'PET_SAVE_AS_CURRENT' OR slot > 'PET_SAVE_LAST_STABLE_SLOT') - CharPetMap::iterator ownerPets = m_petsByCharacter.find(owner); + // FROM character_pet WHERE owner_guid = '%u' AND (slot = 'PET_SAVE_AS_CURRENT' OR slot > 'PET_SAVE_LAST_STABLE_SLOT') + CharPetMap::iterator ownerPets = m_petsByCharacter.find(ownerGuidLow); if (ownerPets == m_petsByCharacter.end()) return nullptr; for (const auto& it : ownerPets->second) @@ -319,7 +319,7 @@ CharacterPetCache* CharacterDatabaseCache::GetCharacterPetByOwner(uint64 owner) void CharacterDatabaseCache::CharacterPetSetOthersNotInSlot(CharacterPetCache* pCache) { - CharPetMap::iterator ownerPets = m_petsByCharacter.find(pCache->owner); + CharPetMap::iterator ownerPets = m_petsByCharacter.find(pCache->ownerGuid); if (ownerPets == m_petsByCharacter.end()) return; for (const auto& it : ownerPets->second) @@ -329,7 +329,7 @@ void CharacterDatabaseCache::CharacterPetSetOthersNotInSlot(CharacterPetCache* p void CharacterDatabaseCache::InsertCharacterPet(CharacterPetCache* cache) { - m_petsByCharacter[cache->owner].push_back(cache); + m_petsByCharacter[cache->ownerGuid].push_back(cache); m_petsByGuid[cache->id] = cache; } @@ -338,7 +338,7 @@ void CharacterDatabaseCache::DeleteCharacterPetById(uint32 id) PetGuidToPetMap::iterator petStruct = m_petsByGuid.find(id); if (petStruct == m_petsByGuid.end()) return; - CharPetMap::iterator ownerPets = m_petsByCharacter.find(petStruct->second->owner); + CharPetMap::iterator ownerPets = m_petsByCharacter.find(petStruct->second->ownerGuid); for (CharPetVector::iterator it = ownerPets->second.begin(); it != ownerPets->second.end(); ++it) if ((*it)->id == id) { diff --git a/src/game/Database/CharacterDatabaseCache.h b/src/game/Database/CharacterDatabaseCache.h index b76fe15b4..5a3a95a37 100644 --- a/src/game/Database/CharacterDatabaseCache.h +++ b/src/game/Database/CharacterDatabaseCache.h @@ -6,8 +6,8 @@ // pet_spell_cooldown struct PetSpellCoodown { - uint32 spell; - uint64 time; + uint32 spell = 0; + uint64 time = 0; }; typedef std::vector PetSpellCDs; @@ -15,41 +15,43 @@ typedef std::vector PetSpellCDs; // pet_spell struct PetSpellCache { - uint32 spell; - uint8 active; + uint32 spell = 0; + uint8 active = 0; }; typedef std::vector PetSpells; // pet_aura -struct PetAuraCache -{ - uint64 caster_guid; - uint32 item_guid, spell; - uint32 stackcount, remaincharges; - int32 maxduration, remaintime; - uint32 effIndexMask; - - int32 basepoints[3]; - uint32 periodictime[3]; -}; +typedef AuraSaveStruct PetAuraCache; typedef std::vector PetAuras; - struct CharacterPetCache { // character_pet - uint32 id, entry, modelid, level, exp, loyalty; - uint32 slot, curhealth, curmana, curhappiness, resettalents_cost; - uint32 resettalents_time, CreatedBySpell, PetType; - int32 trainpoint, loyaltypoints; - uint64 owner, savetime; - uint8 Reactstate; - std::string name, abdata, TeachSpelldata; - bool renamed; + uint32 id = 0; + uint32 entry = 0; + uint32 displayId = 0; + uint32 level = 0; + uint32 xp = 0; + uint32 loyalty = 0; + uint32 slot = 0; + uint32 currentHealth = 0; + uint32 currentMana = 0; + uint32 currentHappiness = 0; + uint32 resetTalentsCost = 0; + uint32 resetTalentsTime = 0; + uint32 createdBySpell = 0; + uint32 petType = 0; + int32 trainingPoints = 0; + int32 loyaltyPoints = 0;; + uint32 ownerGuid = 0; + uint64 saveTime = 0; + uint8 reactState = 0; + std::string name, actionBarData, teachSpellData; + bool renamed = false; // pet_spell PetSpells spells; // pet_spell_cooldown - PetSpellCDs spellCooldown; + PetSpellCDs spellCooldowns; // pet_aura PetAuras auras; }; @@ -76,10 +78,10 @@ class CharacterDatabaseCache void LoadPetSpellCooldown(uint32 singlePetId); void LoadPetAura(uint32 singlePetId); - CharacterPetCache* GetCharacterPetCacheByOwnerAndId(uint64 owner, uint32 id); - CharacterPetCache* GetCharacterCurrentPet(uint64 owner); - CharacterPetCache* GetCharacterPetByOwnerAndEntry(uint64 owner, uint32 entry); - CharacterPetCache* GetCharacterPetByOwner(uint64 owner); + CharacterPetCache* GetCharacterPetCacheByOwnerAndId(uint32 ownerGuidLow, uint32 id); + CharacterPetCache* GetCharacterCurrentPet(uint32 owner); + CharacterPetCache* GetCharacterPetByOwnerAndEntry(uint32 owner, uint32 entry); + CharacterPetCache* GetCharacterPetByOwner(uint32 owner); CharacterPetCache* GetCharacterPetById(uint32 id); // Very slow method (iterates over all the stored pets) void CharacterPetSetOthersNotInSlot(CharacterPetCache* pCache); void InsertCharacterPet(CharacterPetCache* cache); diff --git a/src/game/Database/DBCStores.cpp b/src/game/Database/DBCStores.cpp index 4a5baff13..3b85f890b 100644 --- a/src/game/Database/DBCStores.cpp +++ b/src/game/Database/DBCStores.cpp @@ -365,7 +365,7 @@ void LoadDBCStores(std::string const& dataPath) std::set spellPaths; for (uint32 i = 1; i < sSpellMgr.GetMaxSpellId(); ++i) if (SpellEntry const* sInfo = sSpellMgr.GetSpellEntry(i)) - for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) if (sInfo->Effect[j] == 123 /*SPELL_EFFECT_SEND_TAXI*/) spellPaths.insert(sInfo->EffectMiscValue[j]); diff --git a/src/game/GMTicketMgr.cpp b/src/game/GMTicketMgr.cpp index bde636ba6..af5c648cb 100644 --- a/src/game/GMTicketMgr.cpp +++ b/src/game/GMTicketMgr.cpp @@ -34,84 +34,86 @@ inline float GetAge(uint64 t) { return float(time(nullptr) - t) / DAY; } /////////////////////////////////////////////////////////////////////////////////////////////////// // GM ticket -GmTicket::GmTicket() : _id(0), _posX(0), _posY(0), _posZ(0), _mapId(0), _createTime(0), _lastModifiedTime(0), - _completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false), - _needResponse(false), _needMoreHelp(false), _securityNeeded(SEC_MODERATOR) +GmTicket::GmTicket() : m_id(0), m_posX(0), m_posY(0), m_posZ(0), m_mapId(0), m_createTime(0), m_lastModifiedTime(0), + m_completed(false), m_escalatedStatus(TICKET_UNASSIGNED), m_viewed(false), + m_needResponse(false), m_needMoreHelp(false), m_securityNeeded(SEC_MODERATOR) { } -GmTicket::GmTicket(Player* player) : _posX(0), _posY(0), _posZ(0), _mapId(0), _createTime(time(nullptr)), _lastModifiedTime(time(nullptr)), - _completed(false), _escalatedStatus(TICKET_UNASSIGNED), _viewed(false), - _needResponse(false), _needMoreHelp(false), _securityNeeded(SEC_MODERATOR) +GmTicket::GmTicket(Player* player) : m_posX(0), m_posY(0), m_posZ(0), m_mapId(0), m_createTime(time(nullptr)), m_lastModifiedTime(time(nullptr)), + m_completed(false), m_escalatedStatus(TICKET_UNASSIGNED), m_viewed(false), + m_needResponse(false), m_needMoreHelp(false), m_securityNeeded(SEC_MODERATOR) { - _id = sTicketMgr->GenerateTicketId(); - _playerName = player->GetName(); - _playerGuid = player->GetGUID(); + m_id = sTicketMgr->GenerateTicketId(); + m_playerName = player->GetName(); + m_playerGuid = player->GetGUID(); } GmTicket::~GmTicket() { } bool GmTicket::LoadFromDB(Field* fields) { - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 - // ticketId, guid, name, message, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, haveTicket, ticketType, securityNeeded + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 + // ticket_id, guid, name, message, create_time, map, position_x, position_y, position_z, last_modified_time, closed_by, assigned_to, comment, response, completed, escalated, viewed, have_ticket, ticket_type, security_needed uint8 index = 0; - _id = fields[ index].GetUInt32(); - _playerGuid = ObjectGuid(HIGHGUID_PLAYER, fields[++index].GetUInt32()); - _playerName = fields[++index].GetString(); - _message = fields[++index].GetString(); - _createTime = fields[++index].GetUInt32(); - _mapId = fields[++index].GetUInt16(); - _posX = fields[++index].GetFloat(); - _posY = fields[++index].GetFloat(); - _posZ = fields[++index].GetFloat(); - _lastModifiedTime = fields[++index].GetUInt32(); - _closedBy = ObjectGuid(uint64(fields[++index].GetInt32())); - _assignedTo = ObjectGuid(HIGHGUID_PLAYER, fields[++index].GetUInt32()); - _comment = fields[++index].GetString(); - _response = fields[++index].GetString(); - _completed = fields[++index].GetBool(); - _escalatedStatus = GMTicketEscalationStatus(fields[++index].GetUInt8()); - _viewed = fields[++index].GetBool(); - _needMoreHelp = fields[++index].GetBool(); - _ticketType = TicketType(fields[++index].GetUInt8()); - _securityNeeded = fields[++index].GetUInt8(); + m_id = fields[ index].GetUInt32(); + m_playerGuid = ObjectGuid(HIGHGUID_PLAYER, fields[++index].GetUInt32()); + m_playerName = fields[++index].GetString(); + m_message = fields[++index].GetString(); + m_createTime = fields[++index].GetUInt32(); + m_mapId = fields[++index].GetUInt16(); + m_posX = fields[++index].GetFloat(); + m_posY = fields[++index].GetFloat(); + m_posZ = fields[++index].GetFloat(); + m_lastModifiedTime = fields[++index].GetUInt32(); + m_closedBy = ObjectGuid(uint64(fields[++index].GetInt32())); + m_assignedTo = ObjectGuid(HIGHGUID_PLAYER, fields[++index].GetUInt32()); + m_comment = fields[++index].GetString(); + m_response = fields[++index].GetString(); + m_completed = fields[++index].GetBool(); + m_escalatedStatus = GMTicketEscalationStatus(fields[++index].GetUInt8()); + m_viewed = fields[++index].GetBool(); + m_needMoreHelp = fields[++index].GetBool(); + m_ticketType = TicketType(fields[++index].GetUInt8()); + m_securityNeeded = fields[++index].GetUInt8(); return true; } +#define TICKET_TABLE_FIELDS "`ticket_id`, `guid`, `name`, `message`, `create_time`, `map`, `position_x`, `position_y`, `position_z`, `last_modified_time`, `closed_by`, `assigned_to`, `comment`, `response`, `completed`, `escalated`, `viewed`, `have_ticket`, `ticket_type`, `security_needed`" + void GmTicket::SaveToDB() const { static SqlStatementID gmTicketSave; - SqlStatement stmt = CharacterDatabase.CreateStatement(gmTicketSave, "REPLACE INTO gm_tickets (ticketId, guid, name, message, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, haveTicket, ticketType, securityNeeded) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); - stmt.addUInt32(_id); - stmt.addUInt32(_playerGuid.GetCounter()); - stmt.addString(_playerName); - stmt.addString(_message); - stmt.addUInt32(uint32(_createTime)); - stmt.addUInt16(_mapId); - stmt.addFloat (_posX); - stmt.addFloat (_posY); - stmt.addFloat (_posZ); - stmt.addUInt32(uint32(_lastModifiedTime)); - stmt.addInt32 (int32(_closedBy.GetCounter())); - stmt.addUInt32(_assignedTo.GetCounter()); - stmt.addString(_comment); - stmt.addString(_response); - stmt.addUInt8 (_completed); - stmt.addUInt8 (uint8(_escalatedStatus)); - stmt.addUInt8 (_viewed); - stmt.addUInt8 (_needMoreHelp); - stmt.addUInt8 (uint8(_ticketType)); - stmt.addUInt8 (_securityNeeded); + SqlStatement stmt = CharacterDatabase.CreateStatement(gmTicketSave, "REPLACE INTO `gm_tickets` (" TICKET_TABLE_FIELDS ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + stmt.addUInt32(m_id); + stmt.addUInt32(m_playerGuid.GetCounter()); + stmt.addString(m_playerName); + stmt.addString(m_message); + stmt.addUInt64(m_createTime); + stmt.addUInt16(m_mapId); + stmt.addFloat (m_posX); + stmt.addFloat (m_posY); + stmt.addFloat (m_posZ); + stmt.addUInt64(m_lastModifiedTime); + stmt.addInt32 (int32(m_closedBy.GetCounter())); + stmt.addUInt32(m_assignedTo.GetCounter()); + stmt.addString(m_comment); + stmt.addString(m_response); + stmt.addUInt8 (m_completed); + stmt.addUInt8 (uint8(m_escalatedStatus)); + stmt.addUInt8 (m_viewed); + stmt.addUInt8 (m_needMoreHelp); + stmt.addUInt8 (uint8(m_ticketType)); + stmt.addUInt8 (m_securityNeeded); stmt.Execute(); } void GmTicket::DeleteFromDB() { static SqlStatementID delTicket; - SqlStatement stmt = CharacterDatabase.CreateStatement(delTicket, "DELETE FROM gm_tickets WHERE ticketId = ?"); - stmt.addUInt32(_id); + SqlStatement stmt = CharacterDatabase.CreateStatement(delTicket, "DELETE FROM `gm_tickets` WHERE `ticket_id` = ?"); + stmt.addUInt32(m_id); stmt.Execute(); } @@ -119,20 +121,20 @@ void GmTicket::WritePacket(WorldPacket& data) const { data << uint32(GMTICKET_STATUS_HASTEXT); std::stringstream displayedMessage; - displayedMessage << _message; + displayedMessage << m_message; if (IsCompleted()) { displayedMessage << "\n\n-----------------------------------------------------------------------\n"; - displayedMessage << "Elysium customer ticket #" << GetId() << " completed.\n"; - if (!_response.empty()) + displayedMessage << "Customer ticket #" << GetId() << " completed.\n"; + if (!m_response.empty()) { displayedMessage << "\n GM answer:\n"; - displayedMessage << _response; + displayedMessage << m_response; } } data << displayedMessage.str(); - data << uint8(_ticketType); - data << GetAge(_lastModifiedTime); + data << uint8(m_ticketType); + data << GetAge(m_lastModifiedTime); if (GmTicket* ticket = sTicketMgr->GetOldestOpenTicket()) data << GetAge(ticket->GetLastModifiedTime()); else @@ -141,8 +143,8 @@ void GmTicket::WritePacket(WorldPacket& data) const // I am not sure how blizzlike this is, and we don't really have a way to find out data << GetAge(sTicketMgr->GetLastChange()); // Estimated wait time ? - GMTicketEscalationStatus escStatus = std::min(_escalatedStatus, TICKET_IN_ESCALATION_QUEUE); - GMTicketOpenedByGMStatus openedStatus = _viewed ? GMTICKET_OPENEDBYGM_STATUS_OPENED : GMTICKET_OPENEDBYGM_STATUS_NOT_OPENED; + GMTicketEscalationStatus escStatus = std::min(m_escalatedStatus, TICKET_IN_ESCALATION_QUEUE); + GMTicketOpenedByGMStatus openedStatus = m_viewed ? GMTICKET_OPENEDBYGM_STATUS_OPENED : GMTICKET_OPENEDBYGM_STATUS_NOT_OPENED; data << uint8(escStatus); // escalated data data << uint8(openedStatus); // whether or not it has been viewed } @@ -160,23 +162,23 @@ std::string GmTicket::FormatMessageString(ChatHandler& handler, bool detailed) c time_t curTime = time(nullptr); std::stringstream ss; - ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTGUID, _id); - ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTNAME, handler.playerLink(_playerName).c_str()); - ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTAGECREATE, (secsToTimeString(curTime - _createTime, true, false)).c_str()); - if (_lastModifiedTime != _createTime) - ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTAGE, (secsToTimeString(curTime - _lastModifiedTime, true, false)).c_str()); + ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTGUID, m_id); + ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTNAME, handler.playerLink(m_playerName).c_str()); + ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTAGECREATE, (secsToTimeString(curTime - m_createTime, true, false)).c_str()); + if (m_lastModifiedTime != m_createTime) + ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTAGE, (secsToTimeString(curTime - m_lastModifiedTime, true, false)).c_str()); std::string name; - if (sObjectMgr.GetPlayerNameByGUID(_assignedTo, name)) + if (sObjectMgr.GetPlayerNameByGUID(m_assignedTo, name)) ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTASSIGNEDTO, handler.playerLink(name).c_str()); if (detailed) { - ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTMESSAGE, _message.c_str()); - if (!_comment.empty()) - ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTCOMMENT, _comment.c_str()); - if (!_response.empty()) - ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTRESPONSE, _response.c_str()); + ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTMESSAGE, m_message.c_str()); + if (!m_comment.empty()) + ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTCOMMENT, m_comment.c_str()); + if (!m_response.empty()) + ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTRESPONSE, m_response.c_str()); } return ss.str(); } @@ -184,8 +186,8 @@ std::string GmTicket::FormatMessageString(ChatHandler& handler, bool detailed) c std::string GmTicket::FormatMessageString(ChatHandler& handler, char const* szClosedName, char const* szAssignedToName, char const* szUnassignedName, char const* szDeletedName, char const* szCompletedName) const { std::stringstream ss; - ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTGUID, _id); - ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTNAME, _playerName.c_str()); + ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTGUID, m_id); + ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTNAME, m_playerName.c_str()); if (szClosedName) ss << handler.PGetParseString(LANG_COMMAND_TICKETCLOSED, szClosedName); if (szAssignedToName) @@ -230,31 +232,31 @@ char const* GmTicket::GetTicketCategoryName(TicketType category) const Player* GmTicket::GetPlayer() const { - return ObjectAccessor::FindPlayer(_playerGuid); + return ObjectAccessor::FindPlayer(m_playerGuid); } Player* GmTicket::GetAssignedPlayer() const { - return ObjectAccessor::FindPlayer(_assignedTo); + return ObjectAccessor::FindPlayer(m_assignedTo); } std::string GmTicket::GetAssignedToName() const { std::string name; // save queries if ticket is not assigned - if (_assignedTo) - sObjectMgr.GetPlayerNameByGUID(_assignedTo, name); + if (m_assignedTo) + sObjectMgr.GetPlayerNameByGUID(m_assignedTo, name); return name; } void GmTicket::SetUnassigned() { - _assignedTo.Clear(); - switch (_escalatedStatus) + m_assignedTo.Clear(); + switch (m_escalatedStatus) { - case TICKET_ASSIGNED: _escalatedStatus = TICKET_UNASSIGNED; break; - case TICKET_ESCALATED_ASSIGNED: _escalatedStatus = TICKET_IN_ESCALATION_QUEUE; break; + case TICKET_ASSIGNED: m_escalatedStatus = TICKET_UNASSIGNED; break; + case TICKET_ESCALATED_ASSIGNED: m_escalatedStatus = TICKET_IN_ESCALATION_QUEUE; break; case TICKET_UNASSIGNED: case TICKET_IN_ESCALATION_QUEUE: default: @@ -264,21 +266,21 @@ void GmTicket::SetUnassigned() void GmTicket::SetPosition(uint32 mapId, float x, float y, float z) { - _mapId = mapId; - _posX = x; - _posY = y; - _posZ = z; + m_mapId = mapId; + m_posX = x; + m_posY = y; + m_posZ = z; } void GmTicket::SetGmAction(uint32 needResponse, bool needMoreHelp) { - _needResponse = (needResponse == 17); // Requires GM response. 17 = true, 1 = false (17 is default) - _needMoreHelp = needMoreHelp; // Requests further GM interaction on a ticket to which a GM has already responded. Basically means "has a new ticket" + m_needResponse = (needResponse == 17); // Requires GM response. 17 = true, 1 = false (17 is default) + m_needMoreHelp = needMoreHelp; // Requests further GM interaction on a ticket to which a GM has already responded. Basically means "has a new ticket" } void GmTicket::TeleportTo(Player* player) const { - player->TeleportTo(_mapId, _posX, _posY, _posZ, 0.0f, 0); + player->TeleportTo(m_mapId, m_posX, m_posY, m_posZ, 0.0f, 0); } void GmTicket::SetChatLog(std::list time, std::string const& log) @@ -292,7 +294,7 @@ void GmTicket::SetChatLog(std::list time, std::string const& log) time.pop_front(); } - _chatLog = newss.str(); + m_chatLog = newss.str(); } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -327,11 +329,9 @@ void TicketMgr::ResetTickets() _lastTicketId = 0; - CharacterDatabase.Execute("TRUNCATE TABLE gm_tickets"); + CharacterDatabase.Execute("TRUNCATE TABLE `gm_tickets`"); } -#define TICKET_TABLE_FIELDS "ticketId, guid, name, message, createTime, mapId, posX, posY, posZ, lastModifiedTime, closedBy, assignedTo, comment, response, completed, escalated, viewed, haveTicket, ticketType, securityNeeded" - void TicketMgr::LoadTickets() { uint32 oldMSTime = WorldTimer::getMSTime(); @@ -343,7 +343,7 @@ void TicketMgr::LoadTickets() _lastTicketId = 0; _openTicketCount = 0; - QueryResult* result = CharacterDatabase.Query("SELECT " TICKET_TABLE_FIELDS " FROM gm_tickets"); + QueryResult* result = CharacterDatabase.Query("SELECT " TICKET_TABLE_FIELDS " FROM `gm_tickets`"); if (!result) { sLog.outString(">> Loaded 0 GM tickets. DB table `gm_ticket` is empty!"); @@ -382,7 +382,7 @@ void TicketMgr::LoadSurveys() _lastSurveyId = 0; uint32 oldMSTime = WorldTimer::getMSTime(); - if (QueryResult* result = CharacterDatabase.Query("SELECT MAX(surveyId) FROM gm_surveys")) + if (QueryResult* result = CharacterDatabase.Query("SELECT MAX(`survey_id`) FROM `gm_surveys`")) { _lastSurveyId = (*result)[0].GetUInt32(); delete result; @@ -497,5 +497,5 @@ void TicketMgr::ReloadTicket(uint32 ticketId) if (_reloadTicketsSet.find(ticketId) != _reloadTicketsSet.end()) return; _reloadTicketsSet.insert(ticketId); - CharacterDatabase.AsyncPQueryUnsafe(this, &TicketMgr::ReloadTicketCallback, "SELECT " TICKET_TABLE_FIELDS " FROM gm_tickets WHERE ticketId = '%u'", ticketId); + CharacterDatabase.AsyncPQueryUnsafe(this, &TicketMgr::ReloadTicketCallback, "SELECT " TICKET_TABLE_FIELDS " FROM `gm_tickets` WHERE `ticket_id` = '%u'", ticketId); } diff --git a/src/game/GMTicketMgr.h b/src/game/GMTicketMgr.h index 66cb50130..ef82ae9b4 100644 --- a/src/game/GMTicketMgr.h +++ b/src/game/GMTicketMgr.h @@ -89,47 +89,47 @@ public: GmTicket(Player* player); ~GmTicket(); - bool IsClosed() const { return !_closedBy.IsEmpty(); } - bool IsCompleted() const { return _completed; } - bool IsFromPlayer(ObjectGuid guid) const { return guid == _playerGuid; } - bool IsAssigned() const { return !_assignedTo.IsEmpty(); } - bool IsAssignedTo(ObjectGuid guid) const { return guid == _assignedTo; } + bool IsClosed() const { return !m_closedBy.IsEmpty(); } + bool IsCompleted() const { return m_completed; } + bool IsFromPlayer(ObjectGuid guid) const { return guid == m_playerGuid; } + bool IsAssigned() const { return !m_assignedTo.IsEmpty(); } + bool IsAssignedTo(ObjectGuid guid) const { return guid == m_assignedTo; } bool IsAssignedNotTo(ObjectGuid guid) const { return IsAssigned() && !IsAssignedTo(guid); } - uint32 GetId() const { return _id; } + uint32 GetId() const { return m_id; } Player* GetPlayer() const; - std::string const& GetPlayerName() const { return _playerName; } - std::string const& GetMessage() const { return _message; } + std::string const& GetPlayerName() const { return m_playerName; } + std::string const& GetMessage() const { return m_message; } Player* GetAssignedPlayer() const; - ObjectGuid GetAssignedToGUID() const { return _assignedTo; } + ObjectGuid GetAssignedToGUID() const { return m_assignedTo; } std::string GetAssignedToName() const; - uint64 GetLastModifiedTime() const { return _lastModifiedTime; } - GMTicketEscalationStatus GetEscalatedStatus() const { return _escalatedStatus; } + uint64 GetLastModifiedTime() const { return m_lastModifiedTime; } + GMTicketEscalationStatus GetEscalatedStatus() const { return m_escalatedStatus; } - void SetEscalatedStatus(GMTicketEscalationStatus escalatedStatus) { _escalatedStatus = escalatedStatus; } + void SetEscalatedStatus(GMTicketEscalationStatus escalatedStatus) { m_escalatedStatus = escalatedStatus; } void SetAssignedTo(ObjectGuid guid, bool isAdmin) { - _assignedTo = guid; - if (isAdmin && _escalatedStatus == TICKET_IN_ESCALATION_QUEUE) - _escalatedStatus = TICKET_ESCALATED_ASSIGNED; - else if (_escalatedStatus == TICKET_UNASSIGNED) - _escalatedStatus = TICKET_ASSIGNED; + m_assignedTo = guid; + if (isAdmin && m_escalatedStatus == TICKET_IN_ESCALATION_QUEUE) + m_escalatedStatus = TICKET_ESCALATED_ASSIGNED; + else if (m_escalatedStatus == TICKET_UNASSIGNED) + m_escalatedStatus = TICKET_ASSIGNED; } - void SetClosedBy(ObjectGuid value) { _closedBy = value; } - void SetCompleted() { _completed = true; } + void SetClosedBy(ObjectGuid value) { m_closedBy = value; } + void SetCompleted() { m_completed = true; } void SetMessage(std::string const& message) { - _message = message; - _lastModifiedTime = uint64(time(nullptr)); + m_message = message; + m_lastModifiedTime = uint64(time(nullptr)); } - void SetComment(std::string const& comment) { _comment = comment; } - void SetViewed() { _viewed = true; } + void SetComment(std::string const& comment) { m_comment = comment; } + void SetViewed() { m_viewed = true; } void SetUnassigned(); void SetPosition(uint32 mapId, float x, float y, float z); void SetGmAction(uint32 needResponse, bool needMoreHelp); - void AppendResponse(std::string const& response) { _response += response; } - void ResetResponse() { _response.clear(); } + void AppendResponse(std::string const& response) { m_response += response; } + void ResetResponse() { m_response.clear(); } bool LoadFromDB(Field* fields); void SaveToDB() const; @@ -144,36 +144,36 @@ public: char const* GetTicketCategoryName(TicketType category) const; void SetChatLog(std::list time, std::string const& log); - std::string const& GetChatLog() const { return _chatLog; } + std::string const& GetChatLog() const { return m_chatLog; } - TicketType GetTicketType() const { return _ticketType; } - void SetTicketType(TicketType type) { _ticketType = type; } + TicketType GetTicketType() const { return m_ticketType; } + void SetTicketType(TicketType type) { m_ticketType = type; } - void SetNeededSecurityLevel(uint8 sec) { _securityNeeded = sec; } - uint8 GetNeededSecurityLevel() const { return _securityNeeded; } + void SetNeededSecurityLevel(uint8 sec) { m_securityNeeded = sec; } + uint8 GetNeededSecurityLevel() const { return m_securityNeeded; } private: - uint32 _id; - ObjectGuid _playerGuid; - std::string _playerName; - float _posX; - float _posY; - float _posZ; - uint16 _mapId; - std::string _message; - uint64 _createTime; - uint64 _lastModifiedTime; - ObjectGuid _closedBy; // 0 = Open, -1 = Console, playerGuid = player abandoned ticket, other = GM who closed it. - ObjectGuid _assignedTo; - std::string _comment; - bool _completed; - GMTicketEscalationStatus _escalatedStatus; - bool _viewed; - bool _needResponse; /// @todo find out the use of this, and then store it in DB - bool _needMoreHelp; - uint8 _securityNeeded; - TicketType _ticketType; - std::string _response; - std::string _chatLog; // No need to store in db, will be refreshed every session client side + uint32 m_id = 0; + ObjectGuid m_playerGuid; + std::string m_playerName; + float m_posX = 0.0f; + float m_posY = 0.0f; + float m_posZ = 0.0f; + uint16 m_mapId = 0; + std::string m_message; + uint64 m_createTime = 0; + uint64 m_lastModifiedTime = 0; + ObjectGuid m_closedBy; // 0 = Open, -1 = Console, playerGuid = player abandoned ticket, other = GM who closed it. + ObjectGuid m_assignedTo; + std::string m_comment; + bool m_completed = false; + GMTicketEscalationStatus m_escalatedStatus; + bool m_viewed = false; + bool m_needResponse = false; /// @todo find out the use of this, and then store it in DB + bool m_needMoreHelp = false; + uint8 m_securityNeeded = 0; + TicketType m_ticketType; + std::string m_response; + std::string m_chatLog; // No need to store in db, will be refreshed every session client side }; typedef std::map GmTicketList; diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp index 6aead2d08..e1e1127ee 100644 --- a/src/game/GameEventMgr.cpp +++ b/src/game/GameEventMgr.cpp @@ -1062,7 +1062,7 @@ void GameEventMgr::SendEventMails(int16 event_id) ss << "SELECT characters.guid FROM characters, character_queststatus " "WHERE (1 << (characters.race - 1)) & " << mail.raceMask - << " AND characters.deleteDate IS NULL AND character_queststatus.guid = characters.guid AND character_queststatus.quest = " + << " AND characters.deleted_time IS NULL AND character_queststatus.guid = characters.guid AND character_queststatus.quest = " << mail.questId << " AND character_queststatus.rewarded <> 0"; sMassMailMgr.AddMassMailTask(new MailDraft(mail.mailTemplateId), MailSender(MAIL_CREATURE, mail.senderEntry), ss.str().c_str()); diff --git a/src/game/Group/Group.cpp b/src/game/Group/Group.cpp index ed94afa22..1aafed5d8 100644 --- a/src/game/Group/Group.cpp +++ b/src/game/Group/Group.cpp @@ -142,10 +142,10 @@ bool Group::Create(ObjectGuid guid, char const* name) // store group in database CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM `groups` WHERE `groupId` ='%u'", m_Id); - CharacterDatabase.PExecute("DELETE FROM `group_member` WHERE `groupId` ='%u'", m_Id); + CharacterDatabase.PExecute("DELETE FROM `groups` WHERE `group_id` ='%u'", m_Id); + CharacterDatabase.PExecute("DELETE FROM `group_member` WHERE `group_id` ='%u'", m_Id); - CharacterDatabase.PExecute("INSERT INTO `groups` (`groupId`, `leaderGuid`, `mainTank`, `mainAssistant`, `lootMethod`, `looterGuid`, `lootThreshold`, `icon1`, `icon2`, `icon3`, `icon4`, `icon5`, `icon6`, `icon7`, `icon8`, `isRaid`) " + CharacterDatabase.PExecute("INSERT INTO `groups` (`group_id`, `leader_guid`, `main_tank_guid`, `main_assistant_guid`, `loot_method`, `looter_guid`, `loot_threshold`, `icon1`, `icon2`, `icon3`, `icon4`, `icon5`, `icon6`, `icon7`, `icon8`, `is_raid`) " "VALUES('%u','%u','%u','%u','%u','%u','%u','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','%u')", m_Id, m_leaderGuid.GetCounter(), m_mainTankGuid.GetCounter(), m_mainAssistantGuid.GetCounter(), uint32(m_lootMethod), m_looterGuid.GetCounter(), uint32(m_lootThreshold), @@ -169,8 +169,8 @@ bool Group::Create(ObjectGuid guid, char const* name) bool Group::LoadGroupFromDB(Field* fields) { - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - // result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, leaderGuid, groupId FROM groups"); + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + // result = CharacterDatabase.Query("SELECT main_tank_guid, main_assistant_guid, loot_method, looter_guid, loot_threshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, is_raid, leader_guid, group_id FROM groups"); m_Id = fields[15].GetUInt32(); m_leaderGuid = ObjectGuid(HIGHGUID_PLAYER, fields[14].GetUInt32()); @@ -230,7 +230,7 @@ void Group::ConvertToRaid() _initRaidSubGroupsCounter(); if (!isBGGroup()) - CharacterDatabase.PExecute("UPDATE `groups` SET `isRaid` = 1 WHERE `groupId`='%u'", m_Id); + CharacterDatabase.PExecute("UPDATE `groups` SET `is_raid` = 1 WHERE `group_id`='%u'", m_Id); SendUpdate(); // update quest related GO states (quest activity dependent from raid membership) @@ -573,8 +573,8 @@ void Group::Disband(bool hideDestroy) if (!isBGGroup()) { CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM `groups` WHERE `groupId`='%u'", m_Id); - CharacterDatabase.PExecute("DELETE FROM `group_member` WHERE `groupId`='%u'", m_Id); + CharacterDatabase.PExecute("DELETE FROM `groups` WHERE `group_id`='%u'", m_Id); + CharacterDatabase.PExecute("DELETE FROM `group_member` WHERE `group_id`='%u'", m_Id); CharacterDatabase.CommitTransaction(); ResetInstances(INSTANCE_RESET_GROUP_DISBAND, nullptr); } @@ -1476,7 +1476,7 @@ bool Group::_addMember(ObjectGuid guid, char const* name, bool isAssistant, uint if (!isBGGroup() && !(player && player->IsBot())) { // insert into group table - CharacterDatabase.PExecute("INSERT INTO `group_member` (`groupId`, `memberGuid`, `assistant`, `subgroup`) VALUES('%u','%u','%u','%u')", + CharacterDatabase.PExecute("INSERT INTO `group_member` (`group_id`, `member_guid`, `assistant`, `subgroup`) VALUES('%u','%u','%u','%u')", m_Id, member.guid.GetCounter(), ((member.assistant == 1) ? 1 : 0), member.group); } @@ -1512,7 +1512,7 @@ bool Group::_removeMember(ObjectGuid guid) } if (!isBGGroup()) - CharacterDatabase.PExecute("DELETE FROM `group_member` WHERE `memberGuid`='%u'", guid.GetCounter()); + CharacterDatabase.PExecute("DELETE FROM `group_member` WHERE `member_guid`='%u'", guid.GetCounter()); if (m_leaderGuid == guid) // leader was removed { @@ -1590,7 +1590,7 @@ void Group::_setLeader(ObjectGuid guid) // in the DB also remove solo binds that will be replaced with permbinds // from the new leader CharacterDatabase.PExecute( - "DELETE FROM `group_instance` WHERE `leaderguid`='%u' AND (`permanent` = 1 OR " + "DELETE FROM `group_instance` WHERE `leader_guid`='%u' AND (`permanent` = 1 OR " "`instance` IN (SELECT `instance` FROM `character_instance` WHERE `guid` = '%u')" ")", leader_lowguid, slot_lowguid); @@ -1611,7 +1611,7 @@ void Group::_setLeader(ObjectGuid guid) } // update the group's solo binds to the new leader - CharacterDatabase.PExecute("UPDATE `group_instance` SET `leaderGuid`='%u' WHERE `leaderGuid` = '%u'", + CharacterDatabase.PExecute("UPDATE `group_instance` SET `leader_guid`='%u' WHERE `leader_guid` = '%u'", slot_lowguid, leader_lowguid); // copy the permanent binds from the new leader to the group @@ -1620,7 +1620,7 @@ void Group::_setLeader(ObjectGuid guid) Player::ConvertInstancesToGroup(player, this, slot->guid); // update the group leader - CharacterDatabase.PExecute("UPDATE `groups` SET `leaderGuid`='%u' WHERE `groupId`='%u'", slot_lowguid, m_Id); + CharacterDatabase.PExecute("UPDATE `groups` SET `leader_guid`='%u' WHERE `group_id`='%u'", slot_lowguid, m_Id); CharacterDatabase.CommitTransaction(); } @@ -1683,8 +1683,8 @@ bool Group::_swapMembersGroup(ObjectGuid guid, ObjectGuid swapGuid) // Don't need to change group counters since we are swapping if (!isBGGroup()) { - CharacterDatabase.PExecute("UPDATE `group_member` SET `subgroup`='%u' WHERE `memberGuid`='%u'", slot->group, guid.GetCounter()); - CharacterDatabase.PExecute("UPDATE `group_member` SET `subgroup`='%u' WHERE `memberGuid`='%u'", swapSlot->group, swapGuid.GetCounter()); + CharacterDatabase.PExecute("UPDATE `group_member` SET `subgroup`='%u' WHERE `member_guid`='%u'", slot->group, guid.GetCounter()); + CharacterDatabase.PExecute("UPDATE `group_member` SET `subgroup`='%u' WHERE `member_guid`='%u'", swapSlot->group, swapGuid.GetCounter()); } return true; @@ -1701,7 +1701,7 @@ bool Group::_setMembersGroup(ObjectGuid guid, uint8 group) SubGroupCounterIncrease(group); if (!isBGGroup()) - CharacterDatabase.PExecute("UPDATE `group_member` SET `subgroup`='%u' WHERE `memberGuid`='%u'", group, guid.GetCounter()); + CharacterDatabase.PExecute("UPDATE `group_member` SET `subgroup`='%u' WHERE `member_guid`='%u'", group, guid.GetCounter()); return true; } @@ -1714,7 +1714,7 @@ bool Group::_setAssistantFlag(ObjectGuid guid, bool const& state) slot->assistant = state; if (!isBGGroup()) - CharacterDatabase.PExecute("UPDATE `group_member` SET `assistant`='%u' WHERE `memberGuid`='%u'", (state) ? 1 : 0, guid.GetCounter()); + CharacterDatabase.PExecute("UPDATE `group_member` SET `assistant`='%u' WHERE `member_guid`='%u'", (state) ? 1 : 0, guid.GetCounter()); return true; } @@ -1736,7 +1736,7 @@ bool Group::_setMainTank(ObjectGuid guid) m_mainTankGuid = guid; if (!isBGGroup()) - CharacterDatabase.PExecute("UPDATE `groups` SET `mainTank`='%u' WHERE `groupId`='%u'", m_mainTankGuid.GetCounter(), m_Id); + CharacterDatabase.PExecute("UPDATE `groups` SET `main_tank_guid`='%u' WHERE `group_id`='%u'", m_mainTankGuid.GetCounter(), m_Id); return true; } @@ -1759,7 +1759,7 @@ bool Group::_setMainAssistant(ObjectGuid guid) m_mainAssistantGuid = guid; if (!isBGGroup()) - CharacterDatabase.PExecute("UPDATE `groups` SET `mainAssistant`='%u' WHERE `groupId`='%u'", + CharacterDatabase.PExecute("UPDATE `groups` SET `main_assistant_guid`='%u' WHERE `group_id`='%u'", m_mainAssistantGuid.GetCounter(), m_Id); return true; @@ -2080,11 +2080,11 @@ InstanceGroupBind* Group::BindToInstance(DungeonPersistentState* state, bool per // when a boss is killed or when copying the players's binds to the group if (permanent != bind.perm || state != bind.state) if (!load) - CharacterDatabase.PExecute("UPDATE `group_instance` SET `instance` = '%u', `permanent` = '%u' WHERE `leaderGuid` = '%u' AND `instance` = '%u'", + CharacterDatabase.PExecute("UPDATE `group_instance` SET `instance` = '%u', `permanent` = '%u' WHERE `leader_guid` = '%u' AND `instance` = '%u'", state->GetInstanceId(), permanent, GetLeaderGuid().GetCounter(), bind.state->GetInstanceId()); } else if (!load) - CharacterDatabase.PExecute("INSERT INTO `group_instance` (`leaderGuid`, `instance`, `permanent`) VALUES ('%u', '%u', '%u')", + CharacterDatabase.PExecute("INSERT INTO `group_instance` (`leader_guid`, `instance`, `permanent`) VALUES ('%u', '%u', '%u')", GetLeaderGuid().GetCounter(), state->GetInstanceId(), permanent); if (bind.state != state) @@ -2111,7 +2111,7 @@ void Group::UnbindInstance(uint32 mapid, bool unload) if (itr != m_boundInstances.end()) { if (!unload) - CharacterDatabase.PExecute("DELETE FROM `group_instance` WHERE `leaderGuid` = '%u' AND `instance` = '%u'", + CharacterDatabase.PExecute("DELETE FROM `group_instance` WHERE `leader_guid` = '%u' AND `instance` = '%u'", GetLeaderGuid().GetCounter(), itr->second.state->GetInstanceId()); itr->second.state->RemoveGroup(this); // save can become invalid m_boundInstances.erase(itr); diff --git a/src/game/Guild/Guild.cpp b/src/game/Guild/Guild.cpp index e885ddbdc..cb87909c5 100644 --- a/src/game/Guild/Guild.cpp +++ b/src/game/Guild/Guild.cpp @@ -54,7 +54,7 @@ void MemberSlot::SetPNOTE(std::string pnote) // pnote now can be used for encoding to DB CharacterDatabase.escape_string(pnote); - CharacterDatabase.PExecute("UPDATE `guild_member` SET `pnote` = '%s' WHERE `guid` = '%u'", pnote.c_str(), guid.GetCounter()); + CharacterDatabase.PExecute("UPDATE `guild_member` SET `player_note` = '%s' WHERE `guid` = '%u'", pnote.c_str(), guid.GetCounter()); } void MemberSlot::SetOFFNOTE(std::string offnote) @@ -63,7 +63,7 @@ void MemberSlot::SetOFFNOTE(std::string offnote) // offnote now can be used for encoding to DB CharacterDatabase.escape_string(offnote); - CharacterDatabase.PExecute("UPDATE `guild_member` SET `offnote` = '%s' WHERE `guid` = '%u'", offnote.c_str(), guid.GetCounter()); + CharacterDatabase.PExecute("UPDATE `guild_member` SET `officer_note` = '%s' WHERE `guid` = '%u'", offnote.c_str(), guid.GetCounter()); } void MemberSlot::ChangeRank(uint32 newRank) @@ -161,9 +161,9 @@ bool Guild::Create(Player* leader, std::string gname) CharacterDatabase.escape_string(dbMOTD); CharacterDatabase.BeginTransaction(); - // CharacterDatabase.PExecute("DELETE FROM guild WHERE guildid='%u'", Id); - MAX(guildid)+1 not exist - CharacterDatabase.PExecute("DELETE FROM `guild_member` WHERE `guildid`='%u'", m_Id); - CharacterDatabase.PExecute("INSERT INTO `guild` (`guildid`, `name`, `leaderguid`, `info`, `motd`, `createdate`, `EmblemStyle`, `EmblemColor`, `BorderStyle`, `BorderColor`, `BackgroundColor`) " + // CharacterDatabase.PExecute("DELETE FROM guild WHERE guild_id='%u'", Id); - MAX(guild_id)+1 not exist + CharacterDatabase.PExecute("DELETE FROM `guild_member` WHERE `guild_id`='%u'", m_Id); + CharacterDatabase.PExecute("INSERT INTO `guild` (`guild_id`, `name`, `leader_guid`, `info`, `motd`, `create_date`, `emblem_style`, `emblem_color`, `border_style`, `border_color`, `background_color`) " "VALUES('%u','%s','%u', '%s', '%s','" UI64FMTD "','%i','%i','%i','%i','%i')", m_Id, gname.c_str(), m_LeaderGuid.GetCounter(), dbGINFO.c_str(), dbMOTD.c_str(), uint64(now), m_EmblemStyle, m_EmblemColor, m_BorderStyle, m_BorderColor, m_BackgroundColor); CharacterDatabase.CommitTransaction(); @@ -175,7 +175,7 @@ bool Guild::Create(Player* leader, std::string gname) void Guild::CreateDefaultGuildRanks(int locale_idx) { - CharacterDatabase.PExecute("DELETE FROM `guild_rank` WHERE `guildid`='%u'", m_Id); + CharacterDatabase.PExecute("DELETE FROM `guild_rank` WHERE `guild_id`='%u'", m_Id); CreateRank(sObjectMgr.GetMangosString(LANG_GUILD_MASTER, locale_idx), GR_RIGHT_ALL); CreateRank(sObjectMgr.GetMangosString(LANG_GUILD_OFFICER, locale_idx), GR_RIGHT_ALL); @@ -191,7 +191,7 @@ void Guild::Rename(std::string& newName) std::string escaped = m_Name; CharacterDatabase.escape_string(escaped); - CharacterDatabase.PExecute("UPDATE `guild` SET `name` = '%s' WHERE `guildid` = '%u'", escaped.c_str(), m_Id); + CharacterDatabase.PExecute("UPDATE `guild` SET `name` = '%s' WHERE `guild_id` = '%u'", escaped.c_str(), m_Id); } GuildAddStatus Guild::AddMember(ObjectGuid plGuid, uint32 plRank) @@ -258,7 +258,7 @@ GuildAddStatus Guild::AddMember(ObjectGuid plGuid, uint32 plRank) CharacterDatabase.escape_string(dbPnote); CharacterDatabase.escape_string(dbOFFnote); - CharacterDatabase.PExecute("INSERT INTO `guild_member` (`guildid`, `guid`, `rank`, `pnote`, `offnote`) VALUES ('%u', '%u', '%u','%s','%s')", + CharacterDatabase.PExecute("INSERT INTO `guild_member` (`guild_id`, `guid`, `rank`, `player_note`, `officer_note`) VALUES ('%u', '%u', '%u','%s','%s')", m_Id, lowguid, newmember.RankId, dbPnote.c_str(), dbOFFnote.c_str()); // If player not in game data in data field will be loaded from guild tables, no need to update it!! @@ -280,7 +280,7 @@ void Guild::SetMOTD(std::string motd) // motd now can be used for encoding to DB CharacterDatabase.escape_string(motd); - CharacterDatabase.PExecute("UPDATE `guild` SET `motd`='%s' WHERE `guildid`='%u'", motd.c_str(), m_Id); + CharacterDatabase.PExecute("UPDATE `guild` SET `motd`='%s' WHERE `guild_id`='%u'", motd.c_str(), m_Id); } void Guild::SetGINFO(std::string ginfo) @@ -289,7 +289,7 @@ void Guild::SetGINFO(std::string ginfo) // ginfo now can be used for encoding to DB CharacterDatabase.escape_string(ginfo); - CharacterDatabase.PExecute("UPDATE `guild` SET `info`='%s' WHERE `guildid`='%u'", ginfo.c_str(), m_Id); + CharacterDatabase.PExecute("UPDATE `guild` SET `info`='%s' WHERE `guild_id`='%u'", ginfo.c_str(), m_Id); } bool Guild::LoadGuildFromDB(QueryResult* guildDataResult) @@ -374,9 +374,9 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult) uint32 guildId = fields[0].GetUInt32(); if (guildId < m_Id) { - //there is in table guild_rank record which doesn't have guildid in guild table, report error + //there is in table guild_rank record which doesn't have guild_id in guild table, report error sLog.outErrorDb("Guild %u does not exist but it has a record in guild_rank table, deleting it!", guildId); - CharacterDatabase.PExecute("DELETE FROM `guild_rank` WHERE `guildid` = '%u'", guildId); + CharacterDatabase.PExecute("DELETE FROM `guild_rank` WHERE `guild_id` = '%u'", guildId); continue; } @@ -410,13 +410,13 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult) { sLog.outError("Guild %u has broken `guild_rank` data, repairing...", m_Id); CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM `guild_rank` WHERE `guildid`='%u'", m_Id); + CharacterDatabase.PExecute("DELETE FROM `guild_rank` WHERE `guild_id`='%u'", m_Id); for (size_t i = 0; i < m_Ranks.size(); ++i) { std::string name = m_Ranks[i].Name; uint32 rights = m_Ranks[i].Rights; CharacterDatabase.escape_string(name); - CharacterDatabase.PExecute("INSERT INTO `guild_rank` (`guildid`, `rid`, `rname`, `rights`) VALUES ('%u', '%u', '%s', '%u')", m_Id, uint32(i), name.c_str(), rights); + CharacterDatabase.PExecute("INSERT INTO `guild_rank` (`guild_id`, `id`, `name`, `rights`) VALUES ('%u', '%u', '%s', '%u')", m_Id, uint32(i), name.c_str(), rights); } CharacterDatabase.CommitTransaction(); } @@ -438,9 +438,9 @@ bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult) uint32 guildId = fields[0].GetUInt32(); if (guildId < m_Id) { - // there is in table guild_member record which doesn't have guildid in guild table, report error + // there is in table guild_member record which doesn't have guild_id in guild table, report error sLog.outErrorDb("Guild %u does not exist but it has a record in guild_member table, deleting it!", guildId); - CharacterDatabase.PExecute("DELETE FROM `guild_member` WHERE `guildid` = '%u'", guildId); + CharacterDatabase.PExecute("DELETE FROM `guild_member` WHERE `guild_id` = '%u'", guildId); continue; } @@ -510,7 +510,7 @@ void Guild::SetLeader(ObjectGuid guid) m_LeaderGuid = guid; slot->ChangeRank(GR_GUILDMASTER); - CharacterDatabase.PExecute("UPDATE `guild` SET `leaderguid`='%u' WHERE `guildid`='%u'", guid.GetCounter(), m_Id); + CharacterDatabase.PExecute("UPDATE `guild` SET `leader_guid`='%u' WHERE `guild_id`='%u'", guid.GetCounter(), m_Id); } /** @@ -666,7 +666,7 @@ void Guild::CreateRank(std::string name_, uint32 rights) // name now can be used for encoding to DB CharacterDatabase.escape_string(name_); - CharacterDatabase.PExecute("INSERT INTO `guild_rank` (`guildid`, `rid`, `rname`, `rights`) VALUES ('%u', '%u', '%s', '%u')", m_Id, new_rank_id, name_.c_str(), rights); + CharacterDatabase.PExecute("INSERT INTO `guild_rank` (`guild_id`, `id`, `name`, `rights`) VALUES ('%u', '%u', '%s', '%u')", m_Id, new_rank_id, name_.c_str(), rights); } void Guild::AddRank(std::string const& name_, uint32 rights) @@ -682,7 +682,7 @@ void Guild::DelRank() // delete lowest guild_rank uint32 rank = GetLowestRank(); - CharacterDatabase.PExecute("DELETE FROM `guild_rank` WHERE `rid`>='%u' AND `guildid`='%u'", rank, m_Id); + CharacterDatabase.PExecute("DELETE FROM `guild_rank` WHERE `id`>='%u' AND `guild_id`='%u'", rank, m_Id); m_Ranks.pop_back(); } @@ -712,7 +712,7 @@ void Guild::SetRankName(uint32 rankId, std::string name_) // name now can be used for encoding to DB CharacterDatabase.escape_string(name_); - CharacterDatabase.PExecute("UPDATE `guild_rank` SET `rname`='%s' WHERE `rid`='%u' AND `guildid`='%u'", name_.c_str(), rankId, m_Id); + CharacterDatabase.PExecute("UPDATE `guild_rank` SET `name`='%s' WHERE `id`='%u' AND `guild_id`='%u'", name_.c_str(), rankId, m_Id); } void Guild::SetRankRights(uint32 rankId, uint32 rights) @@ -722,7 +722,7 @@ void Guild::SetRankRights(uint32 rankId, uint32 rights) m_Ranks[rankId].Rights = rights; - CharacterDatabase.PExecute("UPDATE `guild_rank` SET `rights`='%u' WHERE `rid`='%u' AND `guildid`='%u'", rights, rankId, m_Id); + CharacterDatabase.PExecute("UPDATE `guild_rank` SET `rights`='%u' WHERE `id`='%u' AND `guild_id`='%u'", rights, rankId, m_Id); } /** @@ -741,9 +741,9 @@ void Guild::Disband() } CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM `guild` WHERE `guildid` = '%u'", m_Id); - CharacterDatabase.PExecute("DELETE FROM `guild_rank` WHERE `guildid` = '%u'", m_Id); - CharacterDatabase.PExecute("DELETE FROM `guild_eventlog` WHERE `guildid` = '%u'", m_Id); + CharacterDatabase.PExecute("DELETE FROM `guild` WHERE `guild_id` = '%u'", m_Id); + CharacterDatabase.PExecute("DELETE FROM `guild_rank` WHERE `guild_id` = '%u'", m_Id); + CharacterDatabase.PExecute("DELETE FROM `guild_eventlog` WHERE `guild_id` = '%u'", m_Id); CharacterDatabase.CommitTransaction(); sGuildMgr.RemoveGuild(m_Id); } @@ -865,7 +865,7 @@ void Guild::SetEmblem(int32 emblemStyle, int32 emblemColor, int32 borderStyle, i m_BorderColor = borderColor; m_BackgroundColor = backgroundColor; - CharacterDatabase.PExecute("UPDATE `guild` SET `EmblemStyle`=%i, `EmblemColor`=%i, `BorderStyle`=%i, `BorderColor`=%i, `BackgroundColor`=%i WHERE `guildid` = %u", m_EmblemStyle, m_EmblemColor, m_BorderStyle, m_BorderColor, m_BackgroundColor, m_Id); + CharacterDatabase.PExecute("UPDATE `guild` SET `emblem_style`=%i, `emblem_color`=%i, `border_style`=%i, `border_color`=%i, `background_color`=%i WHERE `guild_id` = %u", m_EmblemStyle, m_EmblemColor, m_BorderStyle, m_BorderColor, m_BackgroundColor, m_Id); } /** @@ -900,8 +900,8 @@ void Guild::DisplayGuildEventLog(WorldSession* session) // Load guild eventlog from DB void Guild::LoadGuildEventLogFromDB() { - // 0 1 2 3 4 5 - QueryResult* result = CharacterDatabase.PQuery("SELECT `LogGuid`, `EventType`, `PlayerGuid1`, `PlayerGuid2`, `NewRank`, `TimeStamp` FROM `guild_eventlog` WHERE `guildid`=%u ORDER BY `TimeStamp` DESC,`LogGuid` DESC LIMIT %u", m_Id, GUILD_EVENTLOG_MAX_RECORDS); + // 0 1 2 3 4 5 + QueryResult* result = CharacterDatabase.PQuery("SELECT `log_guid`, `event_type`, `player_guid1`, `player_guid2`, `new_rank`, `timestamp` FROM `guild_eventlog` WHERE `guild_id`=%u ORDER BY `timestamp` DESC,`log_guid` DESC LIMIT %u", m_Id, GUILD_EVENTLOG_MAX_RECORDS); if (!result) return; bool isNextLogGuidSet = false; @@ -917,11 +917,11 @@ void Guild::LoadGuildEventLogFromDB() } // Fill entry GuildEventLogEntry NewEvent; - NewEvent.EventType = fields[1].GetUInt8(); - NewEvent.PlayerGuid1 = fields[2].GetUInt32(); - NewEvent.PlayerGuid2 = fields[3].GetUInt32(); - NewEvent.NewRank = fields[4].GetUInt8(); - NewEvent.TimeStamp = fields[5].GetUInt64(); + NewEvent.eventType = fields[1].GetUInt8(); + NewEvent.playerGuid1 = fields[2].GetUInt32(); + NewEvent.playerGuid2 = fields[3].GetUInt32(); + NewEvent.newRank = fields[4].GetUInt8(); + NewEvent.timestamp = fields[5].GetUInt64(); // There can be a problem if more events have same TimeStamp the ORDER can be broken when fields[0].GetUInt32() == configCount, but // events with same timestamp can appear when there is lag, and we naively suppose that mangos isn't laggy @@ -936,26 +936,26 @@ void Guild::LoadGuildEventLogFromDB() } // Add entry to guild eventlog -void Guild::LogGuildEvent(uint8 EventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2, uint8 newRank) +void Guild::LogGuildEvent(uint8 eventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2, uint8 newRank) { - GuildEventLogEntry NewEvent; + GuildEventLogEntry newEvent; // Create event - NewEvent.EventType = EventType; - NewEvent.PlayerGuid1 = playerGuid1.GetCounter(); - NewEvent.PlayerGuid2 = playerGuid2.GetCounter(); - NewEvent.NewRank = newRank; - NewEvent.TimeStamp = uint32(time(nullptr)); + newEvent.eventType = eventType; + newEvent.playerGuid1 = playerGuid1.GetCounter(); + newEvent.playerGuid2 = playerGuid2.GetCounter(); + newEvent.newRank = newRank; + newEvent.timestamp = time(nullptr); // Count new LogGuid m_GuildEventLogNextGuid = (m_GuildEventLogNextGuid + 1) % sWorld.getConfig(CONFIG_UINT32_GUILD_EVENT_LOG_COUNT); // Check max records limit if (m_GuildEventLog.size() >= GUILD_EVENTLOG_MAX_RECORDS) m_GuildEventLog.pop_front(); // Add event to list - m_GuildEventLog.push_back(NewEvent); + m_GuildEventLog.push_back(newEvent); // Save event to DB - CharacterDatabase.PExecute("DELETE FROM `guild_eventlog` WHERE `guildid`='%u' AND `LogGuid`='%u'", m_Id, m_GuildEventLogNextGuid); - CharacterDatabase.PExecute("INSERT INTO `guild_eventlog` (`guildid`, `LogGuid`, `EventType`, `PlayerGuid1`, `PlayerGuid2`, `NewRank`, `TimeStamp`) VALUES ('%u','%u','%u','%u','%u','%u','" UI64FMTD "')", - m_Id, m_GuildEventLogNextGuid, uint32(NewEvent.EventType), NewEvent.PlayerGuid1, NewEvent.PlayerGuid2, uint32(NewEvent.NewRank), NewEvent.TimeStamp); + CharacterDatabase.PExecute("DELETE FROM `guild_eventlog` WHERE `guild_id`='%u' AND `log_guid`='%u'", m_Id, m_GuildEventLogNextGuid); + CharacterDatabase.PExecute("INSERT INTO `guild_eventlog` (`guild_id`, `log_guid`, `event_type`, `player_guid1`, `player_guid2`, `new_rank`, `timestamp`) VALUES ('%u','%u','%u','%u','%u','%u','" UI64FMTD "')", + m_Id, m_GuildEventLogNextGuid, uint32(newEvent.eventType), newEvent.playerGuid1, newEvent.playerGuid2, uint32(newEvent.newRank), newEvent.timestamp); } void Guild::BroadcastEvent(GuildEvents event, ObjectGuid guid, char const* str1 /*=nullptr*/, char const* str2 /*=nullptr*/, char const* str3 /*=nullptr*/) diff --git a/src/game/Guild/Guild.h b/src/game/Guild/Guild.h index ef3df8248..921ac59fd 100644 --- a/src/game/Guild/Guild.h +++ b/src/game/Guild/Guild.h @@ -165,11 +165,11 @@ enum GuildEmblem struct GuildEventLogEntry { - uint8 EventType; - uint32 PlayerGuid1; - uint32 PlayerGuid2; - uint8 NewRank; - uint64 TimeStamp; + uint8 eventType = 0; + uint32 playerGuid1 = 0; + uint32 playerGuid2 = 0; + uint8 newRank = 0; + uint64 timestamp = 0; }; struct MemberSlot @@ -312,7 +312,7 @@ class Guild // Guild EventLog void LoadGuildEventLogFromDB(); void DisplayGuildEventLog(WorldSession* session); - void LogGuildEvent(uint8 EventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2 = ObjectGuid(), uint8 newRank = 0); + void LogGuildEvent(uint8 eventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2 = ObjectGuid(), uint8 newRank = 0); protected: void AddRank(std::string const& name,uint32 rights); diff --git a/src/game/Guild/GuildMgr.cpp b/src/game/Guild/GuildMgr.cpp index 776352452..89922a99a 100644 --- a/src/game/Guild/GuildMgr.cpp +++ b/src/game/Guild/GuildMgr.cpp @@ -105,10 +105,10 @@ void GuildMgr::LoadGuilds() { uint32 count = 0; - // 0 1 2 3 4 5 6 - QueryResult* result = CharacterDatabase.Query("SELECT `guild`.`guildid`, `guild`.`name`, `leaderguid`, `EmblemStyle`, `EmblemColor`, `BorderStyle`, `BorderColor`," - // 7 8 9 10 - "`BackgroundColor`, `info`, `motd`, `createdate` FROM `guild` ORDER BY `guildid` ASC"); + // 0 1 2 3 4 5 6 + QueryResult* result = CharacterDatabase.Query("SELECT `guild_id`, `name`, `leader_guid`, `emblem_style`, `emblem_color`, `border_style`, `border_color`," + // 7 8 9 10 + "`background_Color`, `info`, `motd`, `create_date` FROM `guild` ORDER BY `guild_id` ASC"); if (!result) { @@ -122,15 +122,15 @@ void GuildMgr::LoadGuilds() } // load guild ranks - // 0 1 2 3 - QueryResult* guildRanksResult = CharacterDatabase.Query("SELECT `guildid`, `rid`, `rname`, `rights` FROM `guild_rank` ORDER BY `guildid` ASC, `rid` ASC"); + // 0 1 2 3 + QueryResult* guildRanksResult = CharacterDatabase.Query("SELECT `guild_id`, `id`, `name`, `rights` FROM `guild_rank` ORDER BY `guild_id` ASC, `id` ASC"); // load guild members - // 0 1 2 3 4 - QueryResult* guildMembersResult = CharacterDatabase.Query("SELECT `guildid`, `guild_member`.`guid`, `rank`, `pnote`, `offnote`," + // 0 1 2 3 4 + QueryResult* guildMembersResult = CharacterDatabase.Query("SELECT `guild_id`, `guild_member`.`guid`, `rank`, `player_note`, `officer_note`," // 5 6 7 8 9 10 "`characters`.`name`, `characters`.`level`, `characters`.`class`, `characters`.`zone`, `characters`.`logout_time`, `characters`.`account` " - "FROM `guild_member` LEFT JOIN `characters` ON `characters`.`guid` = `guild_member`.`guid` ORDER BY `guildid` ASC"); + "FROM `guild_member` LEFT JOIN `characters` ON `characters`.`guid` = `guild_member`.`guid` ORDER BY `guild_id` ASC"); BarGoLink bar(result->GetRowCount()); @@ -161,9 +161,9 @@ void GuildMgr::LoadGuilds() delete guildRanksResult; delete guildMembersResult; - //delete unused LogGuid records in guild_eventlog table + //delete unused log_guid records in guild_eventlog table //you can comment these lines if you don't plan to change CONFIG_UINT32_GUILD_EVENT_LOG_COUNT - CharacterDatabase.PExecute("DELETE FROM `guild_eventlog` WHERE `LogGuid` > '%u'", sWorld.getConfig(CONFIG_UINT32_GUILD_EVENT_LOG_COUNT)); + CharacterDatabase.PExecute("DELETE FROM `guild_eventlog` WHERE `log_guid` > '%u'", sWorld.getConfig(CONFIG_UINT32_GUILD_EVENT_LOG_COUNT)); sLog.outString(); sLog.outString(">> Loaded %u guild definitions", count); @@ -174,8 +174,8 @@ void GuildMgr::LoadPetitions() CleanUpPetitions(); // for reload uint32 count = 0; - // 0 1 2 3 - QueryResult* result = CharacterDatabase.Query("SELECT `ownerguid`, `petitionguid`, `charterguid`, `name` FROM `petition`"); + // 0 1 2 3 + QueryResult* result = CharacterDatabase.Query("SELECT `owner_guid`, `petition_guid`, `charter_guid`, `name` FROM `petition`"); if (!result) { @@ -189,8 +189,8 @@ void GuildMgr::LoadPetitions() } // load signatures - // 0 1 2 3 - QueryResult* petitionSignatures = CharacterDatabase.Query("SELECT `ownerguid`, `petitionguid`, `playerguid`, `player_account` FROM `petition_sign`"); + // 0 1 2 3 + QueryResult* petitionSignatures = CharacterDatabase.Query("SELECT `owner_guid`, `petition_guid`, `player_guid`, `player_account` FROM `petition_sign`"); BarGoLink bar(result->GetRowCount()); @@ -228,14 +228,14 @@ void GuildMgr::LoadPetitions() { // Signatures for a petition that does not exist. Delete it sLog.outErrorDb("Signatures exist for petition %u that does not exist", petitionId); - CharacterDatabase.PExecute("DELETE FROM `petition_sign` WHERE `petitionguid` = '%u'", petitionId); + CharacterDatabase.PExecute("DELETE FROM `petition_sign` WHERE `petition_guid` = '%u'", petitionId); continue; } if (ownerGuid != petition->GetOwnerGuid()) { sLog.outErrorDb("Signatures exist for petition %u with a different owner, updating", petitionId); - CharacterDatabase.PExecute("UPDATE `petition_sign` SET `ownerguid` = '%u' WHERE `petitionguid` = '%u'", + CharacterDatabase.PExecute("UPDATE `petition_sign` SET `owner_guid` = '%u' WHERE `petition_guid` = '%u'", petition->GetOwnerGuid().GetCounter(), petition->GetId()); ownerGuid = petition->GetOwnerGuid(); @@ -323,7 +323,7 @@ bool Petition::LoadFromDB(QueryResult* result) return false; } - // SELECT ownerguid, petitionguid, name FROM petition + // SELECT owner_guid, petition_guid, name FROM petition Field* fields = result->Fetch(); m_ownerGuid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()); @@ -342,8 +342,8 @@ void Petition::Delete() if (m_id) { CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM `petition` WHERE `petitionguid` = '%u'", m_id); - CharacterDatabase.PExecute("DELETE FROM `petition_sign` WHERE `petitionguid` = '%u'", m_id); + CharacterDatabase.PExecute("DELETE FROM `petition` WHERE `petition_guid` = '%u'", m_id); + CharacterDatabase.PExecute("DELETE FROM `petition_sign` WHERE `petition_guid` = '%u'", m_id); CharacterDatabase.CommitTransaction(); } } @@ -361,7 +361,7 @@ bool Petition::Rename(std::string& newname) { std::string db_newname = newname; CharacterDatabase.escape_string(db_newname); - CharacterDatabase.PExecute("UPDATE `petition` SET `name` = '%s' WHERE `petitionguid` = '%u'", + CharacterDatabase.PExecute("UPDATE `petition` SET `name` = '%s' WHERE `petition_guid` = '%u'", db_newname.c_str(), m_id); DEBUG_LOG("Petition %u renamed to '%s'", m_id, newname.c_str()); @@ -375,7 +375,7 @@ void Petition::SaveToDB() { std::string escaped_name = m_name; CharacterDatabase.escape_string(escaped_name); - CharacterDatabase.PExecute("INSERT INTO `petition` (`ownerguid`, `petitionguid`, `charterguid`, `name`) VALUES ('%u', '%u', '%u', '%s')", + CharacterDatabase.PExecute("INSERT INTO `petition` (`owner_guid`, `petition_guid`, `charter_guid`, `name`) VALUES ('%u', '%u', '%u', '%s')", m_ownerGuid.GetCounter(), m_id, m_charterGuid.GetCounter(), escaped_name.c_str()); } @@ -442,6 +442,6 @@ PetitionSignature::PetitionSignature(Petition* petition, Player* player) void PetitionSignature::SaveToDB() { - CharacterDatabase.PExecute("INSERT INTO `petition_sign` (`ownerguid`, `petitionguid`, `playerguid`, `player_account`) VALUES ('%u', '%u', '%u','%u')", + CharacterDatabase.PExecute("INSERT INTO `petition_sign` (`owner_guid`, `petition_guid`, `player_guid`, `player_account`) VALUES ('%u', '%u', '%u','%u')", m_petition->GetOwnerGuid().GetCounter(), m_petition->GetId(), m_playerGuid.GetCounter(), m_playerAccount); } diff --git a/src/game/Handlers/AuctionHouseHandler.cpp b/src/game/Handlers/AuctionHouseHandler.cpp index 155a71095..ebd9b7df3 100644 --- a/src/game/Handlers/AuctionHouseHandler.cpp +++ b/src/game/Handlers/AuctionHouseHandler.cpp @@ -516,7 +516,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recv_data) auction_owner->GetSession()->SendAuctionOwnerNotification(auction, false); // after this update we should save player's money ... - CharacterDatabase.PExecute("UPDATE auction SET buyguid = '%u', lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id); + CharacterDatabase.PExecute("UPDATE `auction` SET `buyer_guid` = '%u', `last_bid` = '%u' WHERE `id` = '%u'", auction->bidder, auction->bid, auction->Id); SendAuctionCommandResult(auction, AUCTION_BID_PLACED, AUCTION_OK); } diff --git a/src/game/Handlers/CharacterHandler.cpp b/src/game/Handlers/CharacterHandler.cpp index 549f009af..357892210 100644 --- a/src/game/Handlers/CharacterHandler.cpp +++ b/src/game/Handlers/CharacterHandler.cpp @@ -44,14 +44,6 @@ #include "MasterPlayer.h" #include "PlayerBroadcaster.h" -// config option SkipCinematics supported values -enum CinematicsSkipMode -{ - CINEMATICS_SKIP_NONE = 0, - CINEMATICS_SKIP_SAME_RACE = 1, - CINEMATICS_SKIP_ALL = 2, -}; - class LoginQueryHolder : public SqlQueryHolder { @@ -85,31 +77,31 @@ bool LoginQueryHolder::Initialize() // NOTE: all fields in `characters` must be read to prevent lost character data at next save in case wrong DB structure. // !!! NOTE: including unused `zone`,`online` - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, `account`, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, " - "position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_multiplier, " - "resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, " - "honorRankPoints, honorHighestRank, honorStanding, honorLastWeekHK, honorLastWeekCP, honorStoredHK, honorStoredDK, " - "watchedFaction, drunk, health, power1, power2, power3, power4, power5, exploredZones, equipmentCache, ammoId, actionBars, " - "world_phase_mask FROM characters WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT groupId FROM group_member WHERE memberGuid ='%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,item_guid,spell,stackcount,remaincharges,basepoints0,basepoints1,basepoints2,periodictime0,periodictime1,periodictime2,maxduration,remaintime,effIndexMask FROM character_aura WHERE guid = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT `guid`, `account`, `name`, `race`, `class`, `gender`, `level`, `xp`, `money`, `skin`, `face`, `hair_style`, `hair_color`, `facial_hair`, `bank_bag_slots`, `player_flags`, " + "`position_x`, `position_y`, `position_z`, `map`, `orientation`, `known_taxi_mask`, `played_time_total`, `played_time_level`, `rest_bonus`, `logout_time`, `is_logout_resting`, `reset_talents_multiplier`, " + "`reset_talents_time`, `transport_guid`, `transport_x`, `transport_y`, `transport_z`, `transport_o`, `extra_flags`, `stable_slots`, `at_login_flags`, `zone`, `online`, `death_expire_time`, `current_taxi_path`, " + "`honor_rank_points`, `honor_highest_rank`, `honor_standing`, `honor_last_week_hk`, `honor_last_week_cp`, `honor_stored_hk`, `honor_stored_dk`, " + "`watched_faction`, `drunk`, `health`, `power1`, `power2`, `power3`, `power4`, `power5`, `explored_zones`, `equipment_cache`, `ammo_id`, `action_bars`, " + "`world_phase_mask`, `create_time` FROM `characters` WHERE `guid` = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT `group_id` FROM `group_member` WHERE `member_guid` ='%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT `id`, `permanent`, `map`, `reset_time` FROM `character_instance` LEFT JOIN `instance` ON `instance` = `id` WHERE `guid` = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT `caster_guid`, `item_guid`, `spell`, `stacks`, `charges`, `base_points0`, `base_points1`, `base_points2`, `periodic_time0`, `periodic_time1`, `periodic_time2`, `max_duration`, `duration`, `effect_index_mask` FROM `character_aura` WHERE `guid` = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLS, "SELECT `spell`, `active`, `disabled` FROM `character_spell` WHERE `guid` = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS, "SELECT quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4,reward_choice FROM character_queststatus WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADHONORCP, "SELECT victimType,victim,cp,date,type FROM character_honor_cp WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADREPUTATION, "SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADINVENTORY, "SELECT * FROM (SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, text, bag, slot, item, itemEntry, generated_loot FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u') as t ORDER BY bag,slot", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADITEMLOOT, "SELECT guid,itemid,amount,property FROM item_loot WHERE owner_guid = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS, "SELECT `quest`, `status`, `rewarded`, `explored`, `timer`, `mob_count1`, `mob_count2`, `mob_count3`, `mob_count4`, `item_count1`, `item_count2`, `item_count3`, `item_count4`, `reward_choice` FROM `character_queststatus` WHERE `guid` = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADHONORCP, "SELECT `victim_type`, `victim_id`, `cp`, `date`, `type` FROM `character_honor_cp` WHERE `guid` = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADREPUTATION, "SELECT `faction`, `standing`, `flags` FROM `character_reputation` WHERE `guid` = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADINVENTORY, "SELECT * FROM (SELECT `creator_guid`, `gift_creator_guid`, `count`, `duration`, `charges`, `flags`, `enchantments`, `random_property_id`, `durability`, `text`, `bag`, `slot`, `item_guid`, `item_instance`.`item_id`, `generated_loot` FROM `character_inventory` JOIN `item_instance` ON `character_inventory`.`item_guid` = `item_instance`.`guid` WHERE `character_inventory`.`guid` = '%u') as t ORDER BY `bag`, `slot`", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADITEMLOOT, "SELECT `guid`, `item_id`, `amount`, `property` FROM `item_loot` WHERE `owner_guid` = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACTIONS, "SELECT `button`, `action`, `type` FROM `character_action` WHERE `guid` = '%u' ORDER BY `button`", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSOCIALLIST, "SELECT friend,flags FROM character_social WHERE guid = '%u' LIMIT 255", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADHOMEBIND, "SELECT map,zone,position_x,position_y,position_z FROM character_homebind WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS, "SELECT SpellId, SpellExpireTime, Category, CategoryExpireTime, ItemId FROM character_spell_cooldown WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGUILD, "SELECT guildid,`rank` FROM guild_member WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBGDATA, "SELECT instance_id, team, join_x, join_y, join_z, join_o, join_map FROM character_battleground_data WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILS, "SELECT id,messageType,sender,receiver,subject,itemTextId,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId,has_items FROM mail WHERE receiver = '%u' ORDER BY id DESC", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILEDITEMS, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, text, mail_id, item_guid, itemEntry, generated_loot FROM mail_items JOIN item_instance ON item_guid = guid WHERE receiver = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_FORGOTTEN_SKILLS, "SELECT skill, value FROM character_forgotten_skills WHERE guid = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSOCIALLIST, "SELECT `friend`, `flags` FROM `character_social` WHERE `guid` = '%u' LIMIT 255", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADHOMEBIND, "SELECT `map`, `zone`, `position_x`, `position_y`, `position_z` FROM `character_homebind` WHERE `guid` = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS, "SELECT `spell`, `spell_expire_time`, `category`, `category_expire_time`, `item_id` FROM `character_spell_cooldown` WHERE `guid` = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGUILD, "SELECT `guild_id`, `rank` FROM `guild_member` WHERE `guid` = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBGDATA, "SELECT `instance_id`, `team`, `join_x`, `join_y`, `join_z`, `join_o`, `join_map` FROM `character_battleground_data` WHERE `guid` = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, "SELECT `skill`, `value`, `max` FROM `character_skills` WHERE `guid` = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILS, "SELECT `id`, `message_type`, `sender_guid`, `receiver_guid`, `subject`, `item_text_id`, `expire_time`, `deliver_time`, `money`, `cod`, `checked`, `stationery`, `mail_template_id`, `has_items` FROM `mail` WHERE `receiver_guid` = '%u' ORDER BY `id` DESC", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILEDITEMS, "SELECT `creator_guid`, `gift_creator_guid`, `count`, `duration`, `charges`, `flags`, `enchantments`, `random_property_id`, `durability`, `text`, `mail_id`, `item_guid`, `item_instance`.`item_id`, `generated_loot` FROM `mail_items` JOIN `item_instance` ON `item_guid` = `guid` WHERE `receiver_guid` = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_FORGOTTEN_SKILLS, "SELECT `skill`, `value` FROM `character_forgotten_skills` WHERE `guid` = '%u'", m_guid.GetCounter()); return res; } @@ -179,15 +171,15 @@ void WorldSession::HandleCharEnumOpcode(WorldPacket& /*recv_data*/) { /// get all the data necessary for loading all characters (along with their pets) on the account CharacterDatabase.AsyncPQuery(&chrHandler, &CharacterHandler::HandleCharEnumCallback, GetAccountId(), - // 0 1 2 3 4 5 6 7 - "SELECT characters.guid, characters.name, characters.race, characters.class, characters.gender, characters.playerBytes, characters.playerBytes2, characters.level, " - // 8 9 10 11 12 13 14 - "characters.zone, characters.map, characters.position_x, characters.position_y, characters.position_z, guild_member.guildid, characters.playerFlags, " - // 15 16 17 18 19 - "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.equipmentCache " - "FROM characters LEFT JOIN character_pet ON characters.guid=character_pet.owner AND character_pet.slot='%u' " - "LEFT JOIN guild_member ON characters.guid = guild_member.guid " - "WHERE `characters`.`account` = '%u' ORDER BY characters.guid " + // 0 1 2 3 4 5 6 7 8 9 10 + "SELECT `characters`.`guid`, `characters`.`name`, `characters`.`race`, `characters`.`class`, `characters`.`gender`, `characters`.`skin`, `characters`.`face`, `characters`.`hair_style`, `characters`.`hair_color`, `characters`.`facial_hair`, `characters`.`level`, " + // 11 12 13 14 15 16 17 + "`characters`.`zone`, `characters`.`map`, `characters`.`position_x`, `characters`.`position_y`, `characters`.`position_z`, `guild_member`.`guild_id`, `characters`.`player_flags`, " + // 18 19 20 21 22 + "`characters`.`at_login_flags`, `character_pet`.`entry`, `character_pet`.`display_id`, `character_pet`.`level`, `characters`.`equipment_cache` " + "FROM `characters` LEFT JOIN `character_pet` ON `characters`.`guid`=`character_pet`.`owner_guid` AND `character_pet`.`slot`='%u' " + "LEFT JOIN `guild_member` ON `characters`.`guid` = `guild_member`.`guid` " + "WHERE `characters`.`account` = '%u' ORDER BY `characters`.`guid` " "LIMIT 0,10", PET_SAVE_AS_CURRENT, GetAccountId()); } @@ -306,10 +298,8 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recv_data) } bool AllowTwoSideAccounts = !sWorld.IsPvPRealm() || sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_ACCOUNTS) || GetSecurity() > SEC_PLAYER; - CinematicsSkipMode skipCinematics = CinematicsSkipMode(sWorld.getConfig(CONFIG_UINT32_SKIP_CINEMATICS)); - bool have_same_race = false; - if (!AllowTwoSideAccounts || skipCinematics == CINEMATICS_SKIP_SAME_RACE) + if (!AllowTwoSideAccounts) { std::list characters; sObjectMgr.GetPlayerDataForAccount(GetAccountId(), characters); @@ -332,26 +322,11 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recv_data) return; } } - - // search same race for cinematic or same class if need - // TODO: check if cinematic already shown? (already logged in?; cinematic field) - std::list::iterator iter = characters.begin(); - while (iter != characters.end() && skipCinematics == CINEMATICS_SKIP_SAME_RACE && !have_same_race) - { - acc_race = (*iter)->uiRace; - - have_same_race = race_ == acc_race; - ++iter; - } } } - uint32 cinematic = 0; - if ((have_same_race && skipCinematics == CINEMATICS_SKIP_SAME_RACE) || skipCinematics == CINEMATICS_SKIP_ALL) - cinematic = 1; // don't show intro - uint32 const guidLow = sObjectMgr.GeneratePlayerLowGuid(); - if (Player::SaveNewPlayer(this, guidLow, name, race_, class_, gender, skin, face, hairStyle, hairColor, facialHair, cinematic)) + if (Player::SaveNewPlayer(this, guidLow, name, race_, class_, gender, skin, face, hairStyle, hairColor, facialHair)) { _charactersCount += 1; @@ -622,10 +597,8 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder) GetMasterPlayer()->SendInitialActionButtons(); //Show cinematic at the first time that player login - if (!pCurrChar->GetCinematic()) + if (pCurrChar->HasAtLoginFlag(AT_LOGIN_FIRST) && !sWorld.getConfig(CONFIG_BOOL_SKIP_CINEMATICS)) { - pCurrChar->SetCinematic(1); - if (ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(pCurrChar->GetRace())) pCurrChar->SendCinematicStart(rEntry->CinematicSequence); } @@ -660,7 +633,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder) static SqlStatementID updChars; static SqlStatementID updAccount; - SqlStatement stmt = CharacterDatabase.CreateStatement(updChars, "UPDATE characters SET online = 1 WHERE guid = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(updChars, "UPDATE `characters` SET `online` = 1 WHERE `guid` = ?"); stmt.PExecute(pCurrChar->GetGUIDLow()); stmt = LoginDatabase.CreateStatement(updAccount, "UPDATE `account` SET current_realm = ?, online = 1 WHERE id = ?"); @@ -717,7 +690,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder) if (pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) pCurrChar->UpdatePvPContested(true); - // Apply at_login requests + // Apply at_login_flags requests if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS)) { pCurrChar->ResetSpells(); @@ -904,7 +877,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data) // and that there is no character with the desired new name CharacterDatabase.AsyncPQuery(&WorldSession::HandleChangePlayerNameOpcodeCallBack, GetAccountId(), newname, - "SELECT `guid`, `name` FROM `characters` WHERE `guid` = %u AND `account` = %u AND (`at_login` & %u) = %u AND NOT EXISTS (SELECT NULL FROM `characters` WHERE `name` = '%s')", + "SELECT `guid`, `name` FROM `characters` WHERE `guid` = %u AND `account` = %u AND (`at_login_flags` & %u) = %u AND NOT EXISTS (SELECT NULL FROM `characters` WHERE `name` = '%s')", guid.GetCounter(), GetAccountId(), AT_LOGIN_RENAME, AT_LOGIN_RENAME, escaped_newname.c_str() ); } @@ -933,7 +906,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult* result, uin delete result; CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("UPDATE characters set name = '%s', at_login = at_login & ~ %u WHERE guid ='%u'", newname.c_str(), uint32(AT_LOGIN_RENAME), guidLow); + CharacterDatabase.PExecute("UPDATE `characters` SET `name` = '%s', `at_login_flags` = `at_login_flags` & ~ %u WHERE `guid` ='%u'", newname.c_str(), uint32(AT_LOGIN_RENAME), guidLow); CharacterDatabase.CommitTransaction(); sLog.out(LOG_CHAR, "Account: %d (IP: %s) Character:[%s] (guid:%u) Changed name to: %s", session->GetAccountId(), session->GetRemoteAddress().c_str(), oldname.c_str(), guidLow, newname.c_str()); diff --git a/src/game/Handlers/GMTicketHandler.cpp b/src/game/Handlers/GMTicketHandler.cpp index 68ff540a1..d8acc5e0d 100644 --- a/src/game/Handlers/GMTicketHandler.cpp +++ b/src/game/Handlers/GMTicketHandler.cpp @@ -180,7 +180,7 @@ void WorldSession::HandleGMSurveySubmitOpcode(WorldPacket& recvData) continue; static SqlStatementID insSubSurvey; - SqlStatement stmt = CharacterDatabase.CreateStatement(insSubSurvey, "INSERT INTO `gm_subsurveys` (`surveyId`, `subsurveyId`, `rank`, `comment`) VALUES (?, ?, ?, ?)"); + SqlStatement stmt = CharacterDatabase.CreateStatement(insSubSurvey, "INSERT INTO `gm_subsurveys` (`survey_id`, `subsurvey_id`, `rank`, `comment`) VALUES (?, ?, ?, ?)"); stmt.addUInt32(nextSurveyID); stmt.addUInt32(subSurveyId); stmt.addUInt32(rank); @@ -192,7 +192,7 @@ void WorldSession::HandleGMSurveySubmitOpcode(WorldPacket& recvData) recvData >> comment; static SqlStatementID insSurvey; - SqlStatement stmt = CharacterDatabase.CreateStatement(insSurvey, "INSERT INTO `gm_surveys` (`guid`, `surveyId`, `mainSurvey`, `overallComment`, `createTime`) VALUES (?, ?, ?, ?, UNIX_TIMESTAMP(NOW()))"); + SqlStatement stmt = CharacterDatabase.CreateStatement(insSurvey, "INSERT INTO `gm_surveys` (`guid`, `survey_id`, `main_survey`, `overall_comment`, `create_time`) VALUES (?, ?, ?, ?, UNIX_TIMESTAMP(NOW()))"); stmt.addUInt32(GetPlayer()->GetGUIDLow()); stmt.addUInt32(nextSurveyID); stmt.addUInt32(mainSurvey); diff --git a/src/game/Handlers/GuildHandler.cpp b/src/game/Handlers/GuildHandler.cpp index b778228f6..623734309 100644 --- a/src/game/Handlers/GuildHandler.cpp +++ b/src/game/Handlers/GuildHandler.cpp @@ -722,10 +722,10 @@ void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket) DEBUG_LOG("WORLD: Received MSG_SAVE_GUILD_EMBLEM"); ObjectGuid vendorGuid; - int32 EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor; + int32 emblemStyle, emblemColor, borderStyle, borderColor, backgroundColor; recvPacket >> vendorGuid; - recvPacket >> EmblemStyle >> EmblemColor >> BorderStyle >> BorderColor >> BackgroundColor; + recvPacket >> emblemStyle >> emblemColor >> borderStyle >> borderColor >> backgroundColor; Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_TABARDDESIGNER); if (!pCreature) @@ -763,7 +763,7 @@ void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket) } GetPlayer()->ModifyMoney(-10 * GOLD); - guild->SetEmblem(EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor); + guild->SetEmblem(emblemStyle, emblemColor, borderStyle, borderColor, backgroundColor); //"Guild Emblem saved." SendSaveGuildEmblem(ERR_GUILDEMBLEM_SUCCESS); diff --git a/src/game/Handlers/MailHandler.cpp b/src/game/Handlers/MailHandler.cpp index e1330cd85..ef23ec762 100644 --- a/src/game/Handlers/MailHandler.cpp +++ b/src/game/Handlers/MailHandler.cpp @@ -241,7 +241,7 @@ void WorldSession::HandleSendMail(WorldPacket& recv_data) { req->rcTeam = sObjectMgr.GetPlayerTeamByGUID(req->receiver); // Unsafe query: can modify items, accesses online players ... - CharacterDatabase.AsyncPQueryUnsafe(req, &WorldSession::AsyncMailSendRequest::Callback, "SELECT COUNT(*) FROM mail WHERE receiver = '%u'", req->receiver.GetCounter()); + CharacterDatabase.AsyncPQueryUnsafe(req, &WorldSession::AsyncMailSendRequest::Callback, "SELECT COUNT(*) FROM `mail` WHERE `receiver_guid` = '%u'", req->receiver.GetCounter()); } } @@ -383,7 +383,7 @@ void WorldSession::HandleSendMailCallback(WorldSession::AsyncMailSendRequest* re item->DeleteFromInventoryDB(); // deletes item from character's inventory item->SaveToDB(); // recursive and not have transaction guard into self, item not in inventory and can be save standalone // owner in data will set at mail receive and item extracting - CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'", req->receiver.GetCounter(), item->GetGUIDLow()); + CharacterDatabase.PExecute("UPDATE `item_instance` SET `owner_guid` = '%u' WHERE `guid`='%u'", req->receiver.GetCounter(), item->GetGUIDLow()); CharacterDatabase.CommitTransaction(); draft.AddItem(item); @@ -524,9 +524,9 @@ void WorldSession::HandleMailReturnToSender(WorldPacket& recv_data) //we can return mail now //so firstly delete the old one CharacterDatabase.BeginTransaction(pl->GetGUIDLow()); - CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", mailId); + CharacterDatabase.PExecute("DELETE FROM `mail` WHERE `id` = '%u'", mailId); // needed? - CharacterDatabase.PExecute("DELETE FROM mail_items WHERE mail_id = '%u'", mailId); + CharacterDatabase.PExecute("DELETE FROM `mail_items` WHERE `mail_id` = '%u'", mailId); CharacterDatabase.CommitTransaction(); pl->RemoveMail(mailId); @@ -543,10 +543,10 @@ void WorldSession::HandleMailReturnToSender(WorldPacket& recv_data) { for (const auto& itr2 : m->items) { - if (Item *item = pl->GetMItem(itr2.item_guid)) + if (Item *item = pl->GetMItem(itr2.itemGuid)) draft.AddItem(item); - pl->RemoveMItem(itr2.item_guid); + pl->RemoveMItem(itr2.itemGuid); } } @@ -602,8 +602,8 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recv_data) return; } - uint32 itemId = m->items[0].item_template; - uint32 itemGuid = m->items[0].item_guid; + uint32 itemId = m->items[0].itemId; + uint32 itemGuid = m->items[0].itemGuid; Item *it = pl->GetMItem(itemGuid); @@ -788,7 +788,7 @@ void WorldSession::HandleGetMailList(WorldPacket& recv_data) data << uint32((*itr)->stationery); // stationery (Stationery.dbc) // 1.12.1 can have only single item - Item *item = !(*itr)->items.empty() ? pl->GetMItem((*itr)->items[0].item_guid) : nullptr; + Item *item = !(*itr)->items.empty() ? pl->GetMItem((*itr)->items[0].itemGuid) : nullptr; if (item) { diff --git a/src/game/Handlers/NPCHandler.cpp b/src/game/Handlers/NPCHandler.cpp index 9a4ac616a..9734d798e 100644 --- a/src/game/Handlers/NPCHandler.cpp +++ b/src/game/Handlers/NPCHandler.cpp @@ -600,7 +600,7 @@ void WorldSession::SendStablePet(ObjectGuid guid) for (const auto it : myPets->second) if (it->slot >= PET_SAVE_FIRST_STABLE_SLOT && it->slot <= PET_SAVE_LAST_STABLE_SLOT) { - data << uint32(it->id); // petnumber + data << uint32(it->id); // pet number data << uint32(it->entry); // creature entry data << uint32(it->level); // level data << it->name; // name @@ -702,9 +702,9 @@ void WorldSession::HandleUnstablePet(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Recv CMSG_UNSTABLE_PET."); ObjectGuid npcGUID; - uint32 petnumber; + uint32 petNumber; - recv_data >> npcGUID >> petnumber; + recv_data >> npcGUID >> petNumber; if (!CheckStableMaster(npcGUID)) { @@ -714,18 +714,16 @@ void WorldSession::HandleUnstablePet(WorldPacket& recv_data) GetPlayer()->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TALK); // Removes stealth, feign death ... - uint32 creature_id = 0; - - CharacterPetCache const* petData = sCharacterDatabaseCache.GetCharacterPetCacheByOwnerAndId(_player->GetGUIDLow(), petnumber); + CharacterPetCache const* petData = sCharacterDatabaseCache.GetCharacterPetCacheByOwnerAndId(_player->GetGUIDLow(), petNumber); if (!petData || petData->slot < PET_SAVE_FIRST_STABLE_SLOT || petData->slot > PET_SAVE_LAST_STABLE_SLOT) { SendStableResult(STABLE_ERR_STABLE); return; } - creature_id = petData->entry; - CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(creature_id); + uint32 creatureId = petData->entry; + CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(creatureId); if (!creatureInfo || !creatureInfo->isTameable()) { SendStableResult(STABLE_ERR_STABLE); @@ -741,7 +739,7 @@ void WorldSession::HandleUnstablePet(WorldPacket& recv_data) } Pet* newpet = new Pet(HUNTER_PET); - if (!newpet->LoadPetFromDB(_player, creature_id, petnumber)) + if (!newpet->LoadPetFromDB(_player, creatureId, petNumber)) { delete newpet; newpet = nullptr; diff --git a/src/game/Handlers/PetHandler.cpp b/src/game/Handlers/PetHandler.cpp index b9eb24c43..9feb335ee 100644 --- a/src/game/Handlers/PetHandler.cpp +++ b/src/game/Handlers/PetHandler.cpp @@ -348,25 +348,25 @@ void WorldSession::HandlePetNameQueryOpcode(WorldPacket& recv_data) { DETAIL_LOG("HandlePetNameQuery. CMSG_PET_NAME_QUERY"); - uint32 petnumber; - ObjectGuid petguid; + uint32 petNumber; + ObjectGuid petGuid; - recv_data >> petnumber; - recv_data >> petguid; + recv_data >> petNumber; + recv_data >> petGuid; - SendPetNameQuery(petguid, petnumber); + SendPetNameQuery(petGuid, petNumber); } -void WorldSession::SendPetNameQuery(ObjectGuid petguid, uint32 petnumber) +void WorldSession::SendPetNameQuery(ObjectGuid petGuid, uint32 petNumber) { - Creature* pet = _player->GetMap()->GetAnyTypeCreature(petguid); - if (!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber) + Creature* pet = _player->GetMap()->GetAnyTypeCreature(petGuid); + if (!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petNumber) return; std::string name = pet->GetName(); WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4 + 4 + name.size() + 1)); - data << uint32(petnumber); + data << uint32(petNumber); data << name.c_str(); data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP)); @@ -456,32 +456,32 @@ void WorldSession::HandlePetSetAction(WorldPacket& recv_data) for (uint8 i = 0; i < count; ++i) { - uint32 spell_id = UNIT_ACTION_BUTTON_ACTION(data[i]); + uint32 spellId = UNIT_ACTION_BUTTON_ACTION(data[i]); uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]); - DETAIL_LOG("Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", _player->GetName(), position[i], spell_id, uint32(act_state)); + DETAIL_LOG("Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", _player->GetName(), position[i], spellId, uint32(act_state)); // if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add - if (!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id))) + if (!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spellId && !pet->HasSpell(spellId))) { // sign for autocast - if (act_state == ACT_ENABLED && spell_id) + if (act_state == ACT_ENABLED && spellId) { if (pet->IsCharmed()) - charmInfo->ToggleCreatureAutocast(spell_id, true); + charmInfo->ToggleCreatureAutocast(spellId, true); else - ((Pet*)pet)->ToggleAutocast(spell_id, true); + ((Pet*)pet)->ToggleAutocast(spellId, true); } // sign for no/turn off autocast - else if (act_state == ACT_DISABLED && spell_id) + else if (act_state == ACT_DISABLED && spellId) { if (pet->IsCharmed()) - charmInfo->ToggleCreatureAutocast(spell_id, false); + charmInfo->ToggleCreatureAutocast(spellId, false); else - ((Pet*)pet)->ToggleAutocast(spell_id, false); + ((Pet*)pet)->ToggleAutocast(spellId, false); } - charmInfo->SetActionBar(position[i], spell_id, ActiveStates(act_state)); + charmInfo->SetActionBar(position[i], spellId, ActiveStates(act_state)); } } } @@ -525,7 +525,7 @@ void WorldSession::HandlePetRename(WorldPacket& recv_data) CharacterDatabase.BeginTransaction(); CharacterDatabase.escape_string(name); - CharacterDatabase.PExecute("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber()); + CharacterDatabase.PExecute("UPDATE `character_pet` SET `name` = '%s', `renamed` = '1' WHERE `owner_guid` = '%u' AND `id` = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber()); CharacterDatabase.CommitTransaction(); pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(nullptr))); @@ -601,9 +601,9 @@ void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket) for (PetSpellMap::iterator itr = pet->m_petSpells.begin(); itr != pet->m_petSpells.end();) { - uint32 spell_id = itr->first; // Pet::RemoveSpell can invalidate iterator at erase NEW spell + uint32 spellId = itr->first; // Pet::RemoveSpell can invalidate iterator at erase NEW spell ++itr; - pet->unlearnSpell(spell_id, false); + pet->unlearnSpell(spellId, false); } pet->SetTP(pet->GetLevel() * (pet->GetLoyaltyLevel() - 1)); diff --git a/src/game/Handlers/PetitionsHandler.cpp b/src/game/Handlers/PetitionsHandler.cpp index de19b22c1..a20438009 100644 --- a/src/game/Handlers/PetitionsHandler.cpp +++ b/src/game/Handlers/PetitionsHandler.cpp @@ -173,25 +173,25 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recv_data) if (!charter) return; - uint32 petitionguid = charter->GetEnchantmentId(EnchantmentSlot(0)); - Petition *petition = sGuildMgr.GetPetitionById(petitionguid); + uint32 petitionGuid = charter->GetEnchantmentId(EnchantmentSlot(0)); + Petition *petition = sGuildMgr.GetPetitionById(petitionGuid); if (!petition) { sLog.outError("[PetitionHandler] No petition exists for petition ID %u, yet charter exists with guid %u for owner %s", - petitionguid, itemguid.GetCounter(), _player->GetGuidStr().c_str()); + petitionGuid, itemguid.GetCounter(), _player->GetGuidStr().c_str()); return; } uint8 signs = petition->GetSignatureCount(); - DEBUG_LOG("CMSG_PETITION_SHOW_SIGNATURES petition: %u", petitionguid); + DEBUG_LOG("CMSG_PETITION_SHOW_SIGNATURES petition: %u", petitionGuid); WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8 + 8 + 4 + 1 + signs * 12)); data << itemguid; // item guid data << _player->GetObjectGuid(); // owner guid - data << petitionguid; // petition guid + data << petitionGuid; // petition guid data << signs; // sign's count petition->BuildSignatureData(data); @@ -204,18 +204,18 @@ void WorldSession::HandlePetitionQueryOpcode(WorldPacket& recv_data) DEBUG_LOG("Received opcode CMSG_PETITION_QUERY"); //recv_data.hexlike(); - uint32 petitionguid; - ObjectGuid itemguid; - recv_data >> petitionguid; // petition guid - recv_data >> itemguid; // item guid - DEBUG_LOG("CMSG_PETITION_QUERY Item %s Petition GUID %u", itemguid.GetString().c_str(), petitionguid); + uint32 petitionGuid; + ObjectGuid itemGuid; + recv_data >> petitionGuid; // petition guid + recv_data >> itemGuid; // item guid + DEBUG_LOG("CMSG_PETITION_QUERY Item %s Petition GUID %u", itemGuid.GetString().c_str(), petitionGuid); - Petition* petition = sGuildMgr.GetPetitionById(petitionguid); + Petition* petition = sGuildMgr.GetPetitionById(petitionGuid); if (!petition) return; WorldPacket data(SMSG_PETITION_QUERY_RESPONSE, (4 + 8 + petition->GetName().size() + 1 + 2 + 4 * 11)); - data << uint32(petitionguid); // int m_petitionID; + data << uint32(petitionGuid); // int m_petitionID; data << ObjectGuid(petition->GetOwnerGuid()); // unsigned __int64 m_petitioner; data << petition->GetName(); // char m_title[256]; data << uint8(0); // char m_bodyText[4096]; @@ -262,10 +262,9 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket& recv_data) return; } - std::string db_newname = newname; - uint32 petitionguid = charter->GetEnchantmentId(EnchantmentSlot(0)); + uint32 petitionGuid = charter->GetEnchantmentId(EnchantmentSlot(0)); - Petition* petition = sGuildMgr.GetPetitionById(petitionguid); + Petition* petition = sGuildMgr.GetPetitionById(petitionGuid); if (!petition) return; @@ -438,9 +437,9 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recv_data) if (!charter) return; - uint32 petitionguid = charter->GetEnchantmentId(EnchantmentSlot(0)); + uint32 petitionGuid = charter->GetEnchantmentId(EnchantmentSlot(0)); - Petition* petition = sGuildMgr.GetPetitionById(petitionguid); + Petition* petition = sGuildMgr.GetPetitionById(petitionGuid); if (!petition) { sLog.outError("[PetitionHandler] No petition exists for charter with guid %u for signer %s", @@ -448,7 +447,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recv_data) return; } - DEBUG_LOG("OFFER PETITION: petition %u to %s", petitionguid, playerGuid.GetString().c_str()); + DEBUG_LOG("OFFER PETITION: petition %u to %s", petitionGuid, playerGuid.GetString().c_str()); /// Get petition signs count uint8 signs = petition->GetSignatureCount(); @@ -457,7 +456,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recv_data) WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8 + 8 + 4 + 1 + signs * 12)); data << ObjectGuid(itemGuid); // item guid data << ObjectGuid(_player->GetObjectGuid()); // owner guid - data << uint32(petitionguid); // petition guid + data << uint32(petitionGuid); // petition guid data << uint8(signs); // sign's count petition->BuildSignatureData(data); @@ -476,10 +475,10 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recv_data) if (!charter) return; - uint32 petitionguid = charter->GetEnchantmentId(EnchantmentSlot(0)); - DEBUG_LOG("Petition %u turned in by %s", petitionguid, _player->GetGuidStr().c_str()); + uint32 petitionGuid = charter->GetEnchantmentId(EnchantmentSlot(0)); + DEBUG_LOG("Petition %u turned in by %s", petitionGuid, _player->GetGuidStr().c_str()); - Petition* petition = sGuildMgr.GetPetitionById(petitionguid); + Petition* petition = sGuildMgr.GetPetitionById(petitionGuid); if (!petition) { sLog.outError("[PetitionHandler] No petition exists for charter with guid %u for guild master %s", @@ -534,7 +533,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recv_data) _player->DestroyItem(charter->GetBagSlot(), charter->GetSlot(), true); // created - DEBUG_LOG("TURN IN PETITION %u", petitionguid); + DEBUG_LOG("TURN IN PETITION %u", petitionGuid); WorldPacket data(SMSG_TURN_IN_PETITION_RESULTS, 4); data << uint32(PETITION_SIGN_OK); diff --git a/src/game/Handlers/SpellHandler.cpp b/src/game/Handlers/SpellHandler.cpp index 38343807f..9e17e9cca 100644 --- a/src/game/Handlers/SpellHandler.cpp +++ b/src/game/Handlers/SpellHandler.cpp @@ -233,7 +233,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) if (pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))// wrapped? { - QueryResult* result = CharacterDatabase.PQuery("SELECT entry, flags FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow()); + QueryResult* result = CharacterDatabase.PQuery("SELECT `item_id`, `flags` FROM `character_gifts` WHERE `item_guid` = '%u'", pItem->GetGUIDLow()); if (result) { Field* fields = result->Fetch(); @@ -255,7 +255,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) static SqlStatementID delGifts ; - SqlStatement stmt = CharacterDatabase.CreateStatement(delGifts, "DELETE FROM character_gifts WHERE item_guid = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(delGifts, "DELETE FROM `character_gifts` WHERE `item_guid` = ?"); stmt.PExecute(pItem->GetGUIDLow()); } else diff --git a/src/game/HonorMgr.cpp b/src/game/HonorMgr.cpp index ecc3f9e90..2cf29c053 100644 --- a/src/game/HonorMgr.cpp +++ b/src/game/HonorMgr.cpp @@ -65,7 +65,7 @@ void HonorMaintenancer::LoadWeeklyScores() std::ostringstream query; - query << "SELECT `scores`.`guid`, `c`.`level`, `c`.`account`, `c`.`honorRankPoints`, `c`.`honorHighestRank`, SUM(`hk`), SUM(`dk`), SUM(`cp`) FROM" + query << "SELECT `scores`.`guid`, `c`.`level`, `c`.`account`, `c`.`honor_rank_points`, `c`.`honor_highest_rank`, SUM(`hk`), SUM(`dk`), SUM(`cp`) FROM" "(" " SELECT `guid` AS `guid`, COUNT(*) AS `hk`, 0 AS `dk`, SUM(`cp`) AS `cp` FROM `character_honor_cp` WHERE `type` = " << HONORABLE << " AND (`date` BETWEEN " << weekBeginDay << " AND " << weekEndDay << ") GROUP BY `guid`" @@ -76,7 +76,7 @@ void HonorMaintenancer::LoadWeeklyScores() " SELECT `guid` AS `guid`, 0 AS `hk`, 0 AS `dk`, SUM(`cp`) AS `cp` FROM `character_honor_cp` WHERE `type` NOT IN (" << HONORABLE << ", " << DISHONORABLE << ")" " AND (`date` BETWEEN " << weekBeginDay << " AND " << weekEndDay << ") GROUP BY `guid`" " UNION" - " SELECT `guid` AS `guid`, 0 AS `hk`, 0 AS `dk`, 0 AS `cp` FROM `characters` WHERE `honorRankPoints` > 0" + " SELECT `guid` AS `guid`, 0 AS `hk`, 0 AS `dk`, 0 AS `cp` FROM `characters` WHERE `honor_rank_points` > 0" ") AS `scores` INNER JOIN `characters` AS `c` ON `scores`.`guid` = `c`.`guid` GROUP BY `guid` ORDER BY `guid` "; QueryResult* result = CharacterDatabase.Query(query.str().c_str()); @@ -200,7 +200,7 @@ void HonorMaintenancer::SetCityRanks() for (uint8 i = 1; i < MAX_RACES; ++i) { - QueryResult* result = CharacterDatabase.PQuery("SELECT `guid`, `honorStanding` FROM `characters` WHERE `honorStanding` > 0 and `race` = %u ORDER BY `honorStanding` ASC LIMIT 1", i); + QueryResult* result = CharacterDatabase.PQuery("SELECT `guid`, `honor_standing` FROM `characters` WHERE `honor_standing` > 0 and `race` = %u ORDER BY `honor_standing` ASC LIMIT 1", i); if (result) { @@ -229,7 +229,7 @@ void HonorMaintenancer::SetCityRanks() void HonorMaintenancer::FlushRankPoints() { // Imediatly reset honor standing before flushing - CharacterDatabase.Execute("UPDATE `characters` SET `honorStanding` = 0 WHERE `honorStanding` > 0"); + CharacterDatabase.Execute("UPDATE `characters` SET `honor_standing` = 0 WHERE `honor_standing` > 0"); for (auto& pair : m_weeklyScores) { @@ -244,8 +244,8 @@ void HonorMaintenancer::FlushRankPoints() if (currentRank.visualRank > 0 && (currentRank.visualRank > highestRank.visualRank)) highestRank = currentRank; - CharacterDatabase.PExecute("UPDATE `characters` SET `honorHighestRank` = %u, `honorRankPoints` = %.1f, `honorStanding` = %u, " - "`honorLastWeekHK` = %u, `honorStoredHK` = (`honorStoredHK` + %u), `honorStoredDK` = (`honorStoredDK` + %u), `honorLastWeekCP` = %.1f WHERE `guid` = %u", + CharacterDatabase.PExecute("UPDATE `characters` SET `honor_highest_rank` = %u, `honor_rank_points` = %.1f, `honor_standing` = %u, " + "`honor_last_week_hk` = %u, `honor_stored_hk` = (`honor_stored_hk` + %u), `honor_stored_dk` = (`honor_stored_dk` + %u), `honor_last_week_cp` = %.1f WHERE `guid` = %u", highestRank.rank, finiteAlways(weeklyScore.newRp), weeklyScore.standing, weeklyScore.hk, weeklyScore.hk, weeklyScore.dk, @@ -593,8 +593,8 @@ void HonorMaintenancer::CheckMaintenanceDay() void HonorMaintenancer::ToggleMaintenanceMarker() { m_markerToStart = !m_markerToStart; - CharacterDatabase.PExecute("INSERT INTO `saved_variables` (`key`, `honorMaintenanceMarker`) VALUES (0, %u) " - "ON DUPLICATE KEY UPDATE `honorMaintenanceMarker` = %u", m_markerToStart, m_markerToStart); + CharacterDatabase.PExecute("INSERT INTO `saved_variables` (`key`, `honor_maintenance_marker`) VALUES (0, %u) " + "ON DUPLICATE KEY UPDATE `honor_maintenance_marker` = %u", m_markerToStart, m_markerToStart); } void HonorMaintenancer::SetMaintenanceDays(uint32 last, uint32 next) @@ -604,8 +604,8 @@ void HonorMaintenancer::SetMaintenanceDays(uint32 last, uint32 next) if (!next) m_nextMaintenanceDay = m_lastMaintenanceDay + 7; - CharacterDatabase.PExecute("INSERT INTO `saved_variables` (`key`, `lastHonorMaintenanceDay`, `nextHonorMaintenanceDay`) VALUES (0, %u, %u) " - "ON DUPLICATE KEY UPDATE `lastHonorMaintenanceDay` = %u, `nextHonorMaintenanceDay` = %u", + CharacterDatabase.PExecute("INSERT INTO `saved_variables` (`key`, `honor_last_maintenance_day`, `honor_next_maintenance_day`) VALUES (0, %u, %u) " + "ON DUPLICATE KEY UPDATE `honor_last_maintenance_day` = %u, `honor_next_maintenance_day` = %u", m_lastMaintenanceDay, m_nextMaintenanceDay, m_lastMaintenanceDay, m_nextMaintenanceDay); } @@ -613,7 +613,7 @@ void HonorMaintenancer::Initialize() { sLog.outString("Initialize Honor Maintenance system..."); - QueryResult* result = CharacterDatabase.Query("SELECT `lastHonorMaintenanceDay`, `nextHonorMaintenanceDay`, `honorMaintenanceMarker` FROM `saved_variables`"); + QueryResult* result = CharacterDatabase.Query("SELECT `honor_last_maintenance_day`, `honor_next_maintenance_day`, `honor_maintenance_marker` FROM `saved_variables`"); if (result) { Field* fields = result->Fetch(); @@ -674,7 +674,7 @@ void HonorMgr::Save() switch (honorCP.state) { case STATE_NEW: - CharacterDatabase.PExecute("INSERT INTO `character_honor_cp` (`guid`, `victimType`, `victim`, `cp`, `date`, `type`) " + CharacterDatabase.PExecute("INSERT INTO `character_honor_cp` (`guid`, `victim_type`, `victim_id`, `cp`, `date`, `type`) " " VALUES (%u, %u, %u, %.1f, %u, %u)", m_owner->GetGUIDLow(), honorCP.victimType, honorCP.victimId, finiteAlways(honorCP.cp), honorCP.date, honorCP.type); honorCP.state = STATE_UNCHANGED; @@ -716,8 +716,8 @@ void HonorMgr::SaveStoredData() if (!m_owner) return; - CharacterDatabase.PExecute("UPDATE `characters` SET `honorRankPoints` = %.1f, `honorStanding` = %u, `honorHighestRank` = %u, " - "`honorLastWeekHK` = %u, `honorLastWeekCP` = %.1f, `honorStoredHK` = %u, `honorStoredDK` = %u WHERE `guid` = %u", + CharacterDatabase.PExecute("UPDATE `characters` SET `honor_rank_points` = %.1f, `honor_standing` = %u, `honor_highest_rank` = %u, " + "`honor_last_week_hk` = %u, `honor_last_week_cp` = %.1f, `honor_stored_hk` = %u, `honor_stored_dk` = %u WHERE `guid` = %u", finiteAlways(m_rankPoints), m_standing, m_highestRank.rank, m_lastWeekHK, finiteAlways(m_lastWeekCP), m_storedHK, m_storedDK, m_owner->GetGUIDLow()); } diff --git a/src/game/Mail/Mail.cpp b/src/game/Mail/Mail.cpp index 2da1931ec..fd3aab63a 100644 --- a/src/game/Mail/Mail.cpp +++ b/src/game/Mail/Mail.cpp @@ -192,7 +192,7 @@ void MailDraft::deleteIncludedItems(bool inDB /**= false*/) Item* item = itr.second; if (inDB) - CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid='%u'", item->GetGUIDLow()); + CharacterDatabase.PExecute("DELETE FROM `item_instance` WHERE `guid`='%u'", item->GetGUIDLow()); delete item; } @@ -268,7 +268,7 @@ void MailDraft::SendReturnToSender(uint32 sender_acc, ObjectGuid sender_guid, Ob Item* item = itr.second; item->SaveToDB(); // item not in inventory and can be save standalone // owner in data will set at mail receive and item extracting - CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'", receiver_guid.GetCounter(), item->GetGUIDLow()); + CharacterDatabase.PExecute("UPDATE `item_instance` SET `owner_guid` = '%u' WHERE `guid`='%u'", receiver_guid.GetCounter(), item->GetGUIDLow()); } CharacterDatabase.CommitTransaction(); } @@ -323,14 +323,14 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende CharacterDatabase.BeginTransaction(); CharacterDatabase.escape_string(safe_subject); - CharacterDatabase.PExecute("INSERT INTO mail (id,messageType,stationery,mailTemplateId,sender,receiver,subject,itemTextId,has_items,expire_time,deliver_time,money,cod,checked) " + CharacterDatabase.PExecute("INSERT INTO `mail` (`id`, `message_type`, `stationery`, `mail_template_id`, `sender_guid`, `receiver_guid`, `subject`, `item_text_id`, `has_items`, `expire_time`, `deliver_time`, `money`, `cod`, `checked`) " "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%s', '%u', '%u', '" UI64FMTD "','" UI64FMTD "', '%u', '%u', '%u')", mailId, sender.GetMailMessageType(), sender.GetStationery(), GetMailTemplateId(), sender.GetSenderId(), receiver.GetPlayerGuid().GetCounter(), safe_subject.c_str(), GetBodyId(), (has_items ? 1 : 0), (uint64)expire_time, (uint64)deliver_time, m_money, m_COD, checked); for (const auto& itr : m_items) { Item* item = itr.second; - CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES ('%u', '%u', '%u','%u')", + CharacterDatabase.PExecute("INSERT INTO `mail_items` (`mail_id`, `item_guid`, `item_id`, `receiver_guid`) VALUES ('%u', '%u', '%u','%u')", mailId, item->GetGUIDLow(), item->GetEntry(), receiver.GetPlayerGuid().GetCounter()); } CharacterDatabase.CommitTransaction(); @@ -395,7 +395,7 @@ void Mail::prepareTemplateItems(Player* receiver) mailLoot.FillLoot(mailTemplateId, LootTemplates_Mail, receiver, true, true); CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("UPDATE mail SET has_items = 1 WHERE id = %u", messageID); + CharacterDatabase.PExecute("UPDATE `mail` SET `has_items` = 1 WHERE `id` = %u", messageID); uint32 max_slot = mailLoot.GetMaxSlotInLootFor(receiver->GetGUIDLow()); for (uint32 i = 0; items.empty() && i < max_slot; ++i) @@ -410,7 +410,7 @@ void Mail::prepareTemplateItems(Player* receiver) masterReceiver->AddMItem(item); - CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES ('%u', '%u', '%u','%u')", + CharacterDatabase.PExecute("INSERT INTO `mail_items` (`mail_id`, `item_guid`, `item_id`, `receiver_guid`) VALUES ('%u', '%u', '%u','%u')", messageID, item->GetGUIDLow(), item->GetEntry(), masterReceiver->GetGUIDLow()); } } diff --git a/src/game/Mail/Mail.h b/src/game/Mail/Mail.h index 07de7c60e..836aaf4c6 100644 --- a/src/game/Mail/Mail.h +++ b/src/game/Mail/Mail.h @@ -280,8 +280,8 @@ class MailDraft */ struct MailItemInfo { - uint32 item_guid; ///< the GUID of the item. - uint32 item_template; ///< the ID of the template of the item. + uint32 itemGuid; ///< the item instance GUID + uint32 itemId; ///< the item template ID }; typedef std::vector MailItemInfoVec; @@ -335,11 +335,11 @@ struct Mail * @param item_template the ID of the template of the item. * */ - void AddItem(uint32 itemGuidLow, uint32 item_template) + void AddItem(uint32 itemGuidLow, uint32 itemId) { MailItemInfo mii; - mii.item_guid = itemGuidLow; - mii.item_template = item_template; + mii.itemGuid = itemGuidLow; + mii.itemId = itemId; items.push_back(mii); has_items = true; } @@ -354,11 +354,11 @@ struct Mail * @returns true if the item was removed, or false if no item with that GUID was found. * */ - bool RemoveItem(uint32 item_guid) + bool RemoveItem(uint32 itemGuid) { for(MailItemInfoVec::iterator itr = items.begin(); itr != items.end(); ++itr) { - if (itr->item_guid == item_guid) + if (itr->itemGuid == itemGuid) { items.erase(itr); return true; diff --git a/src/game/Mail/MassMailMgr.cpp b/src/game/Mail/MassMailMgr.cpp index 0ccdcd34d..1d319c6a5 100644 --- a/src/game/Mail/MassMailMgr.cpp +++ b/src/game/Mail/MassMailMgr.cpp @@ -43,11 +43,11 @@ void MassMailMgr::AddMassMailTask(MailDraft* mailProto, MailSender const& sender if (RACEMASK_ALL_PLAYABLE & ~raceMask) // have races not included in mask { std::ostringstream ss; - ss << "SELECT `guid` FROM `characters` WHERE (1 << (`race` - 1)) & " << raceMask << " AND `deleteDate` IS NULL"; + ss << "SELECT `guid` FROM `characters` WHERE (1 << (`race` - 1)) & " << raceMask << " AND `deleted_time` IS NULL"; AddMassMailTask(mailProto, sender, ss.str().c_str()); } else - AddMassMailTask(mailProto, sender, "SELECT `guid` FROM `characters` WHERE `deleteDate` IS NULL"); + AddMassMailTask(mailProto, sender, "SELECT `guid` FROM `characters` WHERE `deleted_time` IS NULL"); } struct MassMailerQueryHandler diff --git a/src/game/Maps/Map.cpp b/src/game/Maps/Map.cpp index f6c5e3942..6d6a658f9 100644 --- a/src/game/Maps/Map.cpp +++ b/src/game/Maps/Map.cpp @@ -3315,9 +3315,9 @@ void Map::BindToInstanceOrRaid(Player* player, time_t objectResetTime, bool perm DungeonPersistentState* save = ((DungeonMap*)this)->GetPersistanceState(); // the reset time is set but not added to the scheduler // until the players leave the instance - time_t resettime = objectResetTime + 2 * HOUR; - if (save->GetResetTime() < resettime) - save->SetResetTime(resettime); + time_t resetTime = objectResetTime + 2 * HOUR; + if (save->GetResetTime() < resetTime) + save->SetResetTime(resetTime); } } } diff --git a/src/game/Maps/MapPersistentStateMgr.cpp b/src/game/Maps/MapPersistentStateMgr.cpp index 2a75bea5b..d6152261b 100644 --- a/src/game/Maps/MapPersistentStateMgr.cpp +++ b/src/game/Maps/MapPersistentStateMgr.cpp @@ -88,7 +88,7 @@ void MapPersistentState::SaveCreatureRespawnTime(uint32 loguid, time_t t) if (t > sWorld.GetGameTime()) { - SqlStatement stmt = CharacterDatabase.CreateStatement(replSpawnTime, "REPLACE INTO `creature_respawn` (`guid`, `respawntime`, `instance`, `map`) VALUES ( ?, ?, ?, ?)"); + SqlStatement stmt = CharacterDatabase.CreateStatement(replSpawnTime, "REPLACE INTO `creature_respawn` (`guid`, `respawn_time`, `instance`, `map`) VALUES ( ?, ?, ?, ?)"); stmt.PExecute(loguid, uint64(t), m_instanceid, GetMapId()); } else @@ -110,7 +110,7 @@ void MapPersistentState::SaveGORespawnTime(uint32 loguid, time_t t) if (t > sWorld.GetGameTime()) { - SqlStatement stmt = CharacterDatabase.CreateStatement(replSpawnTime, "REPLACE INTO `gameobject_respawn` (`guid`, `respawntime`, `instance`, `map`) VALUES ( ?, ?, ?, ?)"); + SqlStatement stmt = CharacterDatabase.CreateStatement(replSpawnTime, "REPLACE INTO `gameobject_respawn` (`guid`, `respawn_time`, `instance`, `map`) VALUES ( ?, ?, ?, ?)"); stmt.PExecute(loguid, uint64(t), m_instanceid, GetMapId()); } else @@ -318,32 +318,32 @@ void DungeonResetScheduler::LoadResetTimes() // get the current reset times for normal instances (these may need to be updated) // these are only kept in memory for InstanceSaves that are loaded later - // resettime = 0 in the DB for raid instances so those are skipped + // reset_time = 0 in the DB for raid instances so those are skipped // NOTE: We _CANNOT_ schedule normal dungeon resets here, since the instance IDs // are remapped in PackInstances(). Scheduling normal dungeon resets here leads // to raid dungeons being reset if the raid ID is remapped to that of a normal // dungeon. This leads to further issues with players being allocated lockouts // for random dungeons as we allocate the cleared IDs for future instances, since - // the player bindings will remain due to the wrong mapid being reset. + // the player bindings will remain due to the wrong mapId being reset. // _____BAD_____ ResetTimeMapType InstResetTime; - QueryResult* result = CharacterDatabase.Query("SELECT `id`, `map`, `resettime` FROM `instance`"); + QueryResult* result = CharacterDatabase.Query("SELECT `id`, `map`, `reset_time` FROM `instance`"); if (result) { do { Field* fields = result->Fetch(); uint32 id = fields[0].GetUInt32(); - uint32 mapid = fields[1].GetUInt32(); - time_t resettime = time_t(fields[2].GetUInt64()); + uint32 mapId = fields[1].GetUInt32(); + time_t resetTime = time_t(fields[2].GetUInt64()); - MapEntry const* mapEntry = sMapStorage.LookupEntry(mapid); + MapEntry const* mapEntry = sMapStorage.LookupEntry(mapId); if (!mapEntry || !mapEntry->IsDungeon()) { - sMapPersistentStateMgr.DeleteInstanceFromDB(mapid, id); + sMapPersistentStateMgr.DeleteInstanceFromDB(mapId, id); continue; } @@ -351,26 +351,26 @@ void DungeonResetScheduler::LoadResetTimes() if (mapEntry->IsRaid()) continue; - InstResetTime[id] = std::pair(mapid, - resettime ? resettime : now + 2 * HOUR); + InstResetTime[id] = std::pair(mapId, + resetTime ? resetTime : now + 2 * HOUR); } while (result->NextRow()); delete result; // update reset time for normal instances with the max creature respawn time + X hours - result = CharacterDatabase.Query("SELECT MAX(`respawntime`), `instance` FROM `creature_respawn` WHERE `instance` > 0 GROUP BY `instance`"); + result = CharacterDatabase.Query("SELECT MAX(`respawn_time`), `instance` FROM `creature_respawn` WHERE `instance` > 0 GROUP BY `instance`"); if (result) { do { Field* fields = result->Fetch(); uint32 instance = fields[1].GetUInt32(); - time_t resettime = time_t(fields[0].GetUInt64() + 2 * HOUR); + time_t resetTime = time_t(fields[0].GetUInt64() + 2 * HOUR); ResetTimeMapType::iterator itr = InstResetTime.find(instance); - if (itr != InstResetTime.end() && itr->second.second != resettime) + if (itr != InstResetTime.end() && itr->second.second != resetTime) { - CharacterDatabase.DirectPExecute("UPDATE `instance` SET `resettime` = '" UI64FMTD "' WHERE `id` = '%u'", uint64(resettime), instance); - itr->second.second = resettime; + CharacterDatabase.DirectPExecute("UPDATE `instance` SET `reset_time` = '" UI64FMTD "' WHERE `id` = '%u'", uint64(resetTime), instance); + itr->second.second = resetTime; } } while (result->NextRow()); @@ -381,20 +381,20 @@ void DungeonResetScheduler::LoadResetTimes() // load the global respawn times for raid instances uint32 diff = sWorld.getConfig(CONFIG_UINT32_INSTANCE_RESET_TIME_HOUR) * HOUR; m_resetTimeByMapId.resize(sMapStorage.GetMaxEntry() + 1); - result = CharacterDatabase.Query("SELECT `mapid`, `resettime` FROM `instance_reset`"); + result = CharacterDatabase.Query("SELECT `map`, `reset_time` FROM `instance_reset`"); if (result) { do { Field* fields = result->Fetch(); - uint32 mapid = fields[0].GetUInt32(); + uint32 mapId = fields[0].GetUInt32(); - MapEntry const* mapEntry = sMapStorage.LookupEntry(mapid); + MapEntry const* mapEntry = sMapStorage.LookupEntry(mapId); if (!mapEntry || !mapEntry->IsDungeon()) { - sLog.outError("MapPersistentStateManager::LoadResetTimes: invalid mapid %u in instance_reset!", mapid); - CharacterDatabase.DirectPExecute("DELETE FROM `instance_reset` WHERE `mapid` = '%u'", mapid); + sLog.outError("MapPersistentStateManager::LoadResetTimes: invalid map Id %u in instance_reset!", mapId); + CharacterDatabase.DirectPExecute("DELETE FROM `instance_reset` WHERE `map` = '%u'", mapId); continue; } @@ -402,9 +402,9 @@ void DungeonResetScheduler::LoadResetTimes() uint64 oldresettime = fields[1].GetUInt64(); uint64 newresettime = (oldresettime / DAY) * DAY + diff; if (oldresettime != newresettime) - CharacterDatabase.DirectPExecute("UPDATE `instance_reset` SET `resettime` = '" UI64FMTD "' WHERE `mapid` = '%u'", newresettime, mapid); + CharacterDatabase.DirectPExecute("UPDATE `instance_reset` SET `reset_time` = '" UI64FMTD "' WHERE `map` = '%u'", newresettime, mapId); - SetResetTimeFor(mapid, newresettime); + SetResetTimeFor(mapId, newresettime); } while (result->NextRow()); delete result; @@ -425,21 +425,21 @@ void DungeonResetScheduler::ScheduleAllDungeonResets() // Reset times have already been updated and set in LoadResetTimes(). We just need to start // the initial reset events based on them. Since LoadResetTimes() is called before // PackInstances(), it cannot be done there. - QueryResult* result = CharacterDatabase.Query("SELECT `id`, `map`, `resettime` FROM `instance`"); + QueryResult* result = CharacterDatabase.Query("SELECT `id`, `map`, `reset_time` FROM `instance`"); if (result) { do { Field* fields = result->Fetch(); uint32 id = fields[0].GetUInt32(); - uint32 mapid = fields[1].GetUInt32(); - time_t resettime = time_t(fields[2].GetUInt64()); + uint32 mapId = fields[1].GetUInt32(); + time_t resetTime = time_t(fields[2].GetUInt64()); // Raids or other maps with a global reset timer - if (!resettime) + if (!resetTime) continue; - InstResetTime[id] = std::pair(mapid, resettime); + InstResetTime[id] = std::pair(mapId, resetTime); } while (result->NextRow()); delete result; } @@ -477,7 +477,7 @@ void DungeonResetScheduler::ScheduleAllDungeonResets() // calculate the next reset time t = (t / DAY) * DAY; t += ((today - t) / period + 1) * period + diff; - CharacterDatabase.DirectPExecute("UPDATE `instance_reset` SET `resettime` = '" UI64FMTD "' WHERE `mapid` = '%u'", (uint64)t, itr->id); + CharacterDatabase.DirectPExecute("UPDATE `instance_reset` SET `reset_time` = '" UI64FMTD "' WHERE `map` = '%u'", (uint64)t, itr->id); } SetResetTimeFor(itr->id, t); @@ -496,9 +496,9 @@ void DungeonResetScheduler::ScheduleReset(bool add, time_t time, DungeonResetEve { MapPersistentStateManager::PersistentStateMap::iterator itr = m_InstanceSaves.m_instanceSaveByInstanceId.find(event.instanceId); if (itr == m_InstanceSaves.m_instanceSaveByInstanceId.end()) - sLog.outInfo("[DungeonReset] Instance %u [map %u]: ScheduleReset %u for unknown instance.", event.instanceId, event.mapid, event.type); - else if (itr->second->GetMapId() != event.mapid) - sLog.outInfo("[DungeonReset] Instance %u [map %u]: ScheduleReset %u for wrong instance [map %u]", event.instanceId, event.mapid, event.type, itr->second->GetMapId()); + sLog.outInfo("[DungeonReset] Instance %u [map %u]: ScheduleReset %u for unknown instance.", event.instanceId, event.mapId, event.type); + else if (itr->second->GetMapId() != event.mapId) + sLog.outInfo("[DungeonReset] Instance %u [map %u]: ScheduleReset %u for wrong instance [map %u]", event.instanceId, event.mapId, event.type, itr->second->GetMapId()); if (add) m_resetTimeQueue.insert(std::pair(time, event)); @@ -529,7 +529,7 @@ void DungeonResetScheduler::ScheduleReset(bool add, time_t time, DungeonResetEve } if (itr == m_resetTimeQueue.end()) - sLog.outError("DungeonResetScheduler::ScheduleReset: cannot cancel the reset, the event(%d,%d,%d) was not found!", event.type, event.mapid, event.instanceId); + sLog.outError("DungeonResetScheduler::ScheduleReset: cannot cancel the reset, the event(%d,%d,%d) was not found!", event.type, event.mapId, event.instanceId); } } } @@ -543,15 +543,15 @@ void DungeonResetScheduler::Update() if (event.type == RESET_EVENT_NORMAL_DUNGEON) { // for individual normal instances, max creature respawn + X hours - m_InstanceSaves._ResetInstance(event.mapid, event.instanceId); + m_InstanceSaves._ResetInstance(event.mapId, event.instanceId); } else { // global reset/warning for a certain map - time_t resetTime = GetResetTimeFor(event.mapid); + time_t resetTime = GetResetTimeFor(event.mapId); uint32 timeLeft = uint32(std::max(int32(resetTime - now), 0)); bool warn = event.type != RESET_EVENT_INFORM_LAST && event.type != RESET_EVENT_FORCED_INFORM_LAST; - m_InstanceSaves._ResetOrWarnAll(event.mapid, warn, timeLeft); + m_InstanceSaves._ResetOrWarnAll(event.mapId, warn, timeLeft); if (event.type != RESET_EVENT_INFORM_LAST && event.type != RESET_EVENT_FORCED_INFORM_LAST) { // schedule the next warning/reset @@ -562,14 +562,14 @@ void DungeonResetScheduler::Update() { // re-schedule the next/new global reset/warning // calculate the next reset time - MapEntry const* instanceTemplate = sMapStorage.LookupEntry(event.mapid); + MapEntry const* instanceTemplate = sMapStorage.LookupEntry(event.mapId); MANGOS_ASSERT(instanceTemplate); time_t next_reset = DungeonResetScheduler::CalculateNextResetTime(instanceTemplate, resetTime); - CharacterDatabase.DirectPExecute("UPDATE `instance_reset` SET `resettime` = '" UI64FMTD "' WHERE `mapid` = '%u'", uint64(next_reset), uint32(event.mapid)); + CharacterDatabase.DirectPExecute("UPDATE `instance_reset` SET `reset_time` = '" UI64FMTD "' WHERE `map` = '%u'", uint64(next_reset), uint32(event.mapId)); - SetResetTimeFor(event.mapid, next_reset); + SetResetTimeFor(event.mapId, next_reset); ResetEventType type = RESET_EVENT_INFORM_1; for (; type < RESET_EVENT_INFORM_LAST; type = ResetEventType(type + 1)) @@ -605,7 +605,7 @@ void DungeonResetScheduler::ResetAllRaid() } event.type = RESET_EVENT_FORCED_INFORM_1; time_t next_reset = now + timeleft; - SetResetTimeFor(event.mapid, next_reset); + SetResetTimeFor(event.mapId, next_reset); rTQ.insert(std::pair(now, event)); } m_resetTimeQueue = rTQ; @@ -643,7 +643,7 @@ MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const return old_save; } - DEBUG_LOG("MapPersistentStateManager::AddPersistentState: mapid = %d, instanceid = %d, reset time = %u, canRset = %u", mapEntry->id, instanceId, resetTime, canReset ? 1 : 0); + DEBUG_LOG("MapPersistentStateManager::AddPersistentState: mapId = %d, instanceId = %d, reset time = %u, canRset = %u", mapEntry->id, instanceId, resetTime, canReset ? 1 : 0); MapPersistentState *state; if (mapEntry->IsDungeon()) @@ -695,19 +695,19 @@ MapPersistentState *MapPersistentStateManager::GetPersistentState(uint32 mapId, } } -void MapPersistentStateManager::DeleteInstanceFromDB(uint32 mapid, uint32 instanceid) +void MapPersistentStateManager::DeleteInstanceFromDB(uint32 mapId, uint32 instanceId) { // TODO: An efficient query which ensures that we are only deleting instance data - // if the mapid is correct (otherwise, we just assume the map is correct - which it _should_ be) + // if the mapId is correct (otherwise, we just assume the map is correct - which it _should_ be) // eg. DELETE FROM character_instance WHERE instance = '101' AND EXISTS (SELECT id FROM instance WHERE id = '101' AND map = '429'); - if (instanceid) + if (instanceId) { CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM `instance` WHERE `id` = '%u'", instanceid); - CharacterDatabase.PExecute("DELETE FROM `character_instance` WHERE `instance` = '%u'", instanceid); - CharacterDatabase.PExecute("DELETE FROM `group_instance` WHERE `instance` = '%u'", instanceid); - CharacterDatabase.PExecute("DELETE FROM `creature_respawn` WHERE `instance` = '%u'", instanceid); - CharacterDatabase.PExecute("DELETE FROM `gameobject_respawn` WHERE `instance` = '%u'", instanceid); + CharacterDatabase.PExecute("DELETE FROM `instance` WHERE `id` = '%u'", instanceId); + CharacterDatabase.PExecute("DELETE FROM `character_instance` WHERE `instance` = '%u'", instanceId); + CharacterDatabase.PExecute("DELETE FROM `group_instance` WHERE `instance` = '%u'", instanceId); + CharacterDatabase.PExecute("DELETE FROM `creature_respawn` WHERE `instance` = '%u'", instanceId); + CharacterDatabase.PExecute("DELETE FROM `gameobject_respawn` WHERE `instance` = '%u'", instanceId); CharacterDatabase.CommitTransaction(); } } @@ -773,14 +773,14 @@ void MapPersistentStateManager::CleanupInstances() CharacterDatabase.BeginTransaction(); // clean character/group - instance binds with invalid group/characters _DelHelper(CharacterDatabase, "character_instance.guid, instance", "character_instance", "LEFT JOIN characters ON character_instance.guid = characters.guid WHERE characters.guid IS NULL"); - _DelHelper(CharacterDatabase, "group_instance.leaderGuid, instance", "group_instance", "LEFT JOIN characters ON group_instance.leaderGuid = characters.guid LEFT JOIN `groups` ON group_instance.leaderGuid = `groups`.leaderGuid WHERE characters.guid IS NULL OR `groups`.leaderGuid IS NULL"); + _DelHelper(CharacterDatabase, "group_instance.leader_guid, instance", "group_instance", "LEFT JOIN characters ON group_instance.leader_guid = characters.guid LEFT JOIN `groups` ON group_instance.leader_guid = `groups`.leader_guid WHERE characters.guid IS NULL OR `groups`.leader_guid IS NULL"); // clean instances that do not have any players or groups bound to them _DelHelper(CharacterDatabase, "id, map", "instance", "LEFT JOIN character_instance ON character_instance.instance = id LEFT JOIN group_instance ON group_instance.instance = id WHERE character_instance.instance IS NULL AND group_instance.instance IS NULL"); // clean invalid instance references in other tables _DelHelper(CharacterDatabase, "character_instance.guid, instance", "character_instance", "LEFT JOIN instance ON character_instance.instance = instance.id WHERE instance.id IS NULL"); - _DelHelper(CharacterDatabase, "group_instance.leaderGuid, instance", "group_instance", "LEFT JOIN instance ON group_instance.instance = instance.id WHERE instance.id IS NULL"); + _DelHelper(CharacterDatabase, "group_instance.leader_guid, instance", "group_instance", "LEFT JOIN instance ON group_instance.instance = instance.id WHERE instance.id IS NULL"); // clean unused respawn data CharacterDatabase.PExecute("DELETE FROM `creature_respawn` WHERE `instance` >= %u AND `instance` NOT IN (SELECT `id` FROM `instance`)", RESERVED_INSTANCES_LAST); @@ -874,18 +874,18 @@ void MapPersistentStateManager::_ResetSave(PersistentStateMap& holder, Persisten lock_instLists = false; } -void MapPersistentStateManager::_ResetInstance(uint32 mapid, uint32 instanceId) +void MapPersistentStateManager::_ResetInstance(uint32 mapId, uint32 instanceId) { - DEBUG_LOG("MapPersistentStateManager::_ResetInstance %u, %u", mapid, instanceId); + DEBUG_LOG("MapPersistentStateManager::_ResetInstance %u, %u", mapId, instanceId); PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.find(instanceId); if (itr != m_instanceSaveByInstanceId.end()) { // delay reset until map unload for loaded map - if (mapid != itr->second->GetMapId()) + if (mapId != itr->second->GetMapId()) { sLog.outError("[CRASH] Instance %u is linked to two different maps, '%u' (scheduler) and '%u' (instance bind)", - instanceId, mapid, itr->second->GetMapId()); + instanceId, mapId, itr->second->GetMapId()); return; } @@ -904,7 +904,7 @@ void MapPersistentStateManager::_ResetInstance(uint32 mapid, uint32 instanceId) _ResetSave(m_instanceSaveByInstanceId, itr); } - DeleteInstanceFromDB(mapid, instanceId); // even if state not loaded + DeleteInstanceFromDB(mapId, instanceId); // even if state not loaded } struct MapPersistantStateResetWorker @@ -932,10 +932,10 @@ struct MapPersistantStateWarnWorker time_t timeLeft; }; -void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeLeft) +void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapId, bool warn, uint32 timeLeft) { // global reset for all instances of the given map - MapEntry const* mapEntry = sMapStorage.LookupEntry(mapid); + MapEntry const* mapEntry = sMapStorage.LookupEntry(mapId); if (!mapEntry->IsDungeon()) return; @@ -946,7 +946,7 @@ void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 // this is called one minute before the reset time if (!mapEntry->resetDelay) { - sLog.outError("MapPersistentStateManager::ResetOrWarnAll: no instance template or reset delay for map %d", mapid); + sLog.outError("MapPersistentStateManager::ResetOrWarnAll: no instance template or reset delay for map %d", mapId); return; } @@ -958,31 +958,31 @@ void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 PersistentStateMap::iterator curr = itr; ++itr; - if (curr->second->GetMapId() == mapid) + if (curr->second->GetMapId() == mapId) ((DungeonPersistentState*)(curr->second))->UnbindThisState(); } // reset maps, teleport player automaticaly to their homebinds and unload maps MapPersistantStateResetWorker worker; - sMapMgr.DoForAllMapsWithMapId(mapid, worker); + sMapMgr.DoForAllMapsWithMapId(mapId, worker); // delete them from the DB, even if not loaded CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM `character_instance` USING `character_instance` LEFT JOIN `instance` ON `character_instance`.`instance` = `id` WHERE `map` = '%u'", mapid); - CharacterDatabase.PExecute("DELETE FROM `group_instance` USING `group_instance` LEFT JOIN `instance` ON `group_instance`.`instance` = `id` WHERE `map` = '%u'", mapid); - CharacterDatabase.PExecute("DELETE FROM `instance` WHERE `map` = '%u'", mapid); + CharacterDatabase.PExecute("DELETE FROM `character_instance` USING `character_instance` LEFT JOIN `instance` ON `character_instance`.`instance` = `id` WHERE `map` = '%u'", mapId); + CharacterDatabase.PExecute("DELETE FROM `group_instance` USING `group_instance` LEFT JOIN `instance` ON `group_instance`.`instance` = `id` WHERE `map` = '%u'", mapId); + CharacterDatabase.PExecute("DELETE FROM `instance` WHERE `map` = '%u'", mapId); CharacterDatabase.CommitTransaction(); // calculate the next reset time time_t next_reset = DungeonResetScheduler::CalculateNextResetTime(mapEntry, now + timeLeft); // update it in the DB - CharacterDatabase.PExecute("UPDATE `instance_reset` SET `resettime` = '" UI64FMTD "' WHERE `mapid` = '%u'", (uint64)next_reset, mapid); + CharacterDatabase.PExecute("UPDATE `instance_reset` SET `reset_time` = '" UI64FMTD "' WHERE `map` = '%u'", (uint64)next_reset, mapId); return; } // note: this isn't fast but it's meant to be executed very rarely MapPersistantStateWarnWorker worker(timeLeft); - sMapMgr.DoForAllMapsWithMapId(mapid, worker); + sMapMgr.DoForAllMapsWithMapId(mapId, worker); } void MapPersistentStateManager::GetStatistics(uint32& numStates, uint32& numBoundPlayers, uint32& numBoundGroups) @@ -1005,17 +1005,17 @@ void MapPersistentStateManager::GetStatistics(uint32& numStates, uint32& numBoun void MapPersistentStateManager::_CleanupExpiredInstancesAtTime(time_t t) { - _DelHelper(CharacterDatabase, "id, map", "instance", "LEFT JOIN instance_reset ON mapid = map WHERE (instance.resettime < '" UI64FMTD "' AND instance.resettime > '0') OR (NOT instance_reset.resettime IS NULL AND instance_reset.resettime < '" UI64FMTD "')", (uint64)t, (uint64)t); + _DelHelper(CharacterDatabase, "id, instance.map", "instance", "LEFT JOIN instance_reset ON instance_reset.map = instance.map WHERE (instance.reset_time < '" UI64FMTD "' AND instance.reset_time > '0') OR (NOT instance_reset.reset_time IS NULL AND instance_reset.reset_time < '" UI64FMTD "')", (uint64)t, (uint64)t); } void MapPersistentStateManager::LoadCreatureRespawnTimes() { // remove outdated data - CharacterDatabase.DirectExecute("DELETE FROM `creature_respawn` WHERE `respawntime` <= UNIX_TIMESTAMP(NOW())"); + CharacterDatabase.DirectExecute("DELETE FROM `creature_respawn` WHERE `respawn_time` <= UNIX_TIMESTAMP(NOW())"); uint32 count = 0; - QueryResult* result = CharacterDatabase.Query("SELECT `guid`, `respawntime`, `creature_respawn`.`map`, `instance`, `resettime` FROM `creature_respawn` LEFT JOIN `instance` ON `instance` = `id`"); + QueryResult* result = CharacterDatabase.Query("SELECT `guid`, `respawn_time`, `creature_respawn`.`map`, `instance`, `reset_time` FROM `creature_respawn` LEFT JOIN `instance` ON `instance` = `id`"); if (!result) { BarGoLink bar(1); @@ -1092,11 +1092,11 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes() void MapPersistentStateManager::LoadGameobjectRespawnTimes() { // remove outdated data - CharacterDatabase.DirectExecute("DELETE FROM `gameobject_respawn` WHERE `respawntime` <= UNIX_TIMESTAMP(NOW())"); + CharacterDatabase.DirectExecute("DELETE FROM `gameobject_respawn` WHERE `respawn_time` <= UNIX_TIMESTAMP(NOW())"); uint32 count = 0; - QueryResult* result = CharacterDatabase.Query("SELECT `guid`, `respawntime`, `gameobject_respawn`.`map`, `instance`, `resettime` FROM `gameobject_respawn` LEFT JOIN `instance` ON `instance` = id"); + QueryResult* result = CharacterDatabase.Query("SELECT `guid`, `respawn_time`, `gameobject_respawn`.`map`, `instance`, `reset_time` FROM `gameobject_respawn` LEFT JOIN `instance` ON `instance` = id"); if (!result) { diff --git a/src/game/Maps/MapPersistentStateMgr.h b/src/game/Maps/MapPersistentStateMgr.h index eeb023ebe..fa89fc980 100644 --- a/src/game/Maps/MapPersistentStateMgr.h +++ b/src/game/Maps/MapPersistentStateMgr.h @@ -269,14 +269,14 @@ enum InstanceResetFailReason struct DungeonResetEvent { ResetEventType type :8; // if RESET_EVENT_DUNGEON then InstanceID == 0 and applied to all instances for map) - uint16 mapid; // used with mapid used as for select reset for global cooldown instances (instanceid==0 for event) + uint16 mapId; // used with mapId used as for select reset for global cooldown instances (instanceid==0 for event) uint32 instanceId; // used for select reset for normal dungeons - DungeonResetEvent() : type(RESET_EVENT_NORMAL_DUNGEON), mapid(0), instanceId(0) {} + DungeonResetEvent() : type(RESET_EVENT_NORMAL_DUNGEON), mapId(0), instanceId(0) {} DungeonResetEvent(ResetEventType t, uint32 _mapid, uint32 _instanceid) - : type(t), mapid(_mapid), instanceId(_instanceid) {} + : type(t), mapId(_mapid), instanceId(_instanceid) {} - bool operator == (DungeonResetEvent const& e) { return e.mapid == mapid && e.instanceId == instanceId; } + bool operator == (DungeonResetEvent const& e) { return e.mapId == mapId && e.instanceId == instanceId; } }; typedef std::map > ResetTimeMapType; @@ -290,14 +290,14 @@ class DungeonResetScheduler void ScheduleAllDungeonResets(); public: // accessors - time_t GetResetTimeFor(uint32 mapid) { return m_resetTimeByMapId[mapid]; } + time_t GetResetTimeFor(uint32 mapId) { return m_resetTimeByMapId[mapId]; } static uint32 GetMaxResetTimeFor(MapEntry const* temp); static time_t CalculateNextResetTime(MapEntry const* temp, time_t prevResetTime); public: // modifiers - void SetResetTimeFor(uint32 mapid, time_t t) + void SetResetTimeFor(uint32 mapId, time_t t) { - m_resetTimeByMapId[mapid] = t; + m_resetTimeByMapId[mapId] = t; } void ScheduleReset(bool add, time_t time, DungeonResetEvent event); @@ -347,7 +347,7 @@ class MapPersistentStateManager : public MaNGOS::Singleton PersistentStateMap; // called by scheduler for DungeonPersistentStates - void _ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeleft); - void _ResetInstance(uint32 mapid, uint32 instanceId); + void _ResetOrWarnAll(uint32 mapId, bool warn, uint32 timeleft); + void _ResetInstance(uint32 mapId, uint32 instanceId); void _CleanupExpiredInstancesAtTime(time_t t); void _ResetSave(PersistentStateMap& holder, PersistentStateMap::iterator &itr); diff --git a/src/game/Maps/ScriptCommands.cpp b/src/game/Maps/ScriptCommands.cpp index 295a21d7b..09262949c 100644 --- a/src/game/Maps/ScriptCommands.cpp +++ b/src/game/Maps/ScriptCommands.cpp @@ -625,7 +625,7 @@ bool Map::ScriptCommand_CreateItem(ScriptInfo const& script, WorldObject* source return ShouldAbortScript(script); } - if (Item* pItem = pReceiver->StoreNewItemInInventorySlot(script.createItem.itemEntry, script.createItem.amount)) + if (Item* pItem = pReceiver->StoreNewItemInInventorySlot(script.createItem.itemId, script.createItem.amount)) pReceiver->SendNewItem(pItem, script.createItem.amount, true, false); return false; @@ -1264,7 +1264,7 @@ bool Map::ScriptCommand_RemoveItem(ScriptInfo const& script, WorldObject* source return ShouldAbortScript(script); } - pPlayer->DestroyItemCount(script.createItem.itemEntry, script.createItem.amount, true); + pPlayer->DestroyItemCount(script.createItem.itemId, script.createItem.amount, true); return false; } diff --git a/src/game/Maps/ScriptCommands.h b/src/game/Maps/ScriptCommands.h index 22c91153f..777523e00 100644 --- a/src/game/Maps/ScriptCommands.h +++ b/src/game/Maps/ScriptCommands.h @@ -105,7 +105,7 @@ enum eScriptCommand // datalong = sound_id // datalong2 = ePlaySoundFlags SCRIPT_COMMAND_CREATE_ITEM = 17, // source = Player (from provided source or target) - // datalong = item_entry + // datalong = item_id // datalong2 = amount SCRIPT_COMMAND_DESPAWN_CREATURE = 18, // source = Creature // datalong = despawn_delay @@ -177,7 +177,7 @@ enum eScriptCommand // datalong1-4 = event_script id // dataint1-4 = chance (total cant be above 100) SCRIPT_COMMAND_REMOVE_ITEM = 40, // source = Player (from provided source or target) - // datalong = item_entry + // datalong = item_id // datalong2 = amount SCRIPT_COMMAND_REMOVE_OBJECT = 41, // source = GameObject // target = Unit @@ -629,7 +629,7 @@ struct ScriptInfo struct // SCRIPT_COMMAND_CREATE_ITEM (17) { - uint32 itemEntry; // datalong + uint32 itemId; // datalong uint32 amount; // datalong2 } createItem; @@ -762,7 +762,7 @@ struct ScriptInfo struct // SCRIPT_COMMAND_REMOVE_ITEM (40) { - uint32 itemEntry; // datalong + uint32 itemId; // datalong uint32 amount; // datalong2 } removeItem; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index ec5cd2b7b..375ca48d1 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -654,8 +654,8 @@ void ObjectMgr::LoadPlayerCacheData() m_playerNameToGuid.clear(); std::unique_ptr result(CharacterDatabase.Query( - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 - "SELECT `guid`, `race`, `class`, `gender`, `account`, `name`, `level`, `zone`, `map`, `position_x`, `position_y`, `position_z`, `orientation`, `taxi_path` FROM `characters`;")); + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 + "SELECT `guid`, `race`, `class`, `gender`, `account`, `name`, `level`, `zone`, `map`, `position_x`, `position_y`, `position_z`, `orientation`, `current_taxi_path` FROM `characters`;")); uint32 total_count = 0; @@ -3291,7 +3291,7 @@ void ObjectMgr::FillObtainedItemsList(std::set& obtainedItems) { // These are all the items that have been obtained by players. { - std::unique_ptr result(CharacterDatabase.Query("SELECT DISTINCT `itemEntry` FROM `item_instance`")); + std::unique_ptr result(CharacterDatabase.Query("SELECT DISTINCT `item_id` FROM `item_instance`")); if (result) { do @@ -3746,7 +3746,7 @@ void ObjectMgr::LoadItemRequiredTarget() if (bounds.first != bounds.second) break; - for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { if (pSpellInfo->EffectImplicitTargetA[j] == TARGET_UNIT_ENEMY || pSpellInfo->EffectImplicitTargetB[j] == TARGET_UNIT_ENEMY || @@ -4568,8 +4568,8 @@ void ObjectMgr::LoadGroups() { // -- loading groups -- uint32 count = 0; - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - std::unique_ptr result(CharacterDatabase.Query("SELECT `mainTank`, `mainAssistant`, `lootMethod`, `looterGuid`, `lootThreshold`, `icon1`, `icon2`, `icon3`, `icon4`, `icon5`, `icon6`, `icon7`, `icon8`, `isRaid`, `leaderGuid`, `groupId` FROM `groups`")); + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + std::unique_ptr result(CharacterDatabase.Query("SELECT `main_tank_guid`, `main_assistant_guid`, `loot_method`, `looter_guid`, `loot_threshold`, `icon1`, `icon2`, `icon3`, `icon4`, `icon5`, `icon6`, `icon7`, `icon8`, `is_raid`, `leader_guid`, `group_id` FROM `groups`")); if (!result) { @@ -4605,8 +4605,8 @@ void ObjectMgr::LoadGroups() // -- loading members -- count = 0; - // 0 1 2 3 - result.reset(CharacterDatabase.Query("SELECT `memberGuid`, `assistant`, `subgroup`, `groupId` FROM `group_member` ORDER BY `groupId`")); + // 0 1 2 3 + result.reset(CharacterDatabase.Query("SELECT `member_guid`, `assistant`, `subgroup`, `group_id` FROM `group_member` ORDER BY `group_id`")); if (!result) { BarGoLink bar2(1); @@ -4635,7 +4635,7 @@ void ObjectMgr::LoadGroups() { sLog.outErrorDb("Incorrect entry in group_member table : no group with Id %d for member %s!", groupId, memberGuid.GetString().c_str()); - CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid = '%u'", memberGuidlow); + CharacterDatabase.PExecute("DELETE FROM `group_member` WHERE `member_guid` = '%u'", memberGuidlow); continue; } } @@ -4644,7 +4644,7 @@ void ObjectMgr::LoadGroups() { sLog.outErrorDb("Incorrect entry in group_member table : member %s cannot be added to group (Id: %u)!", memberGuid.GetString().c_str(), groupId); - CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid = '%u'", memberGuidlow); + CharacterDatabase.PExecute("DELETE FROM `group_member` WHERE `member_guid` = '%u'", memberGuidlow); } } while (result->NextRow()); @@ -4670,13 +4670,13 @@ void ObjectMgr::LoadGroups() // -- loading instances -- count = 0; result.reset(CharacterDatabase.Query( - // 0 1 2 3 4 - "SELECT `group_instance`.`leaderGuid`, `map`, `instance`, `permanent`, `resettime`, " + // 0 1 2 3 4 + "SELECT `group_instance`.`leader_guid`, `map`, `instance`, `permanent`, `reset_time`, " // 5 - "(SELECT COUNT(*) FROM `character_instance` WHERE `guid` = `group_instance`.`leaderGuid` AND `instance` = `group_instance`.`instance` AND `permanent` = 1 LIMIT 1), " + "(SELECT COUNT(*) FROM `character_instance` WHERE `guid` = `group_instance`.`leader_guid` AND `instance` = `group_instance`.`instance` AND `permanent` = 1 LIMIT 1), " // 6 - " `groups`.`groupId` " - "FROM `group_instance` LEFT JOIN `instance` ON `instance` = `id` LEFT JOIN `groups` ON `groups`.`leaderGUID` = `group_instance`.`leaderGUID` ORDER BY `leaderGuid`" + " `groups`.`group_id` " + "FROM `group_instance` LEFT JOIN `instance` ON `instance` = `id` LEFT JOIN `groups` ON `groups`.`leader_guid` = `group_instance`.`leader_guid` ORDER BY `leader_guid`" )); if (!result) @@ -5067,10 +5067,10 @@ void ObjectMgr::LoadQuests() if (!qinfo->ReqCreatureOrGOId[j]) { bool found = false; - for (int k = 0; k < MAX_EFFECT_INDEX; ++k) + for (uint8 k = 0; k < MAX_EFFECT_INDEX; ++k) { if ((spellInfo->Effect[k] == SPELL_EFFECT_QUEST_COMPLETE && uint32(spellInfo->EffectMiscValue[k]) == qinfo->QuestId) || - spellInfo->Effect[k] == SPELL_EFFECT_SEND_EVENT) + spellInfo->Effect[k] == SPELL_EFFECT_SEND_EVENT) { found = true; break; @@ -5347,7 +5347,7 @@ void ObjectMgr::LoadQuests() if (!spellInfo) continue; - for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { if (spellInfo->Effect[j] != SPELL_EFFECT_QUEST_COMPLETE) continue; @@ -5982,12 +5982,12 @@ public: else // Return to sender { // mail will be returned: - CharacterDatabase.PExecute("UPDATE `mail` SET `sender` = '%u', `receiver` = '%u', `expire_time` = '" UI64FMTD "', `deliver_time` = '" UI64FMTD "', `cod` = '0', `checked` = '%u' WHERE `id` = '%u'", + CharacterDatabase.PExecute("UPDATE `mail` SET `sender_guid` = '%u', `receiver_guid` = '%u', `expire_time` = '" UI64FMTD "', `deliver_time` = '" UI64FMTD "', `cod` = '0', `checked` = '%u' WHERE `id` = '%u'", receiverGuid.GetCounter(), returnToLowGuid, (uint64)(basetime + 30 * DAY), (uint64)basetime, MAIL_CHECK_MASK_RETURNED, messageID); if (item_guid) { // update receiver in mail items for its proper delivery, and in instance_item for avoid lost item at sender delete - CharacterDatabase.PExecute("UPDATE `mail_items` SET `receiver` = %u WHERE `item_guid` = '%u'", returnToLowGuid, item_guid); + CharacterDatabase.PExecute("UPDATE `mail_items` SET `receiver_guid` = %u WHERE `item_guid` = '%u'", returnToLowGuid, item_guid); CharacterDatabase.PExecute("UPDATE `item_instance` SET `owner_guid` = %u WHERE `guid` = '%u'", returnToLowGuid, item_guid); } } @@ -6084,12 +6084,12 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) DEBUG_LOG("Returning mails current time: hour: %d, minute: %d, second: %d ", localtime(&basetime)->tm_hour, localtime(&basetime)->tm_min, localtime(&basetime)->tm_sec); //delete all old mails without item and without body immediately, if starting server if (!serverUp) - CharacterDatabase.PExecute("DELETE FROM `mail` WHERE `expire_time` < '" UI64FMTD "' AND `has_items` = '0' AND `itemTextId` = 0", (uint64)basetime); + CharacterDatabase.PExecute("DELETE FROM `mail` WHERE `expire_time` < '" UI64FMTD "' AND `has_items` = '0' AND `item_text_id` = 0", (uint64)basetime); OldMailsReturner* cb = new OldMailsReturner(); cb->serverUp = serverUp; cb->basetime = basetime; uint32 limit = serverUp ? 5 : 1000; - CharacterDatabase.AsyncPQueryUnsafe(cb, &OldMailsReturner::Callback, "SELECT `id`, `messageType`, `sender`, `receiver`, `itemTextId`, `has_items`, `expire_time`, `cod`, `checked`, `mailTemplateId` FROM `mail` WHERE `expire_time` < '" UI64FMTD "' ORDER BY `expire_time` LIMIT %u,%u", (uint64)basetime, m_OldMailCounter, limit); + CharacterDatabase.AsyncPQueryUnsafe(cb, &OldMailsReturner::Callback, "SELECT `id`, `message_type`, `sender_guid`, `receiver_guid`, `item_text_id`, `has_items`, `expire_time`, `cod`, `checked`, `mail_template_id` FROM `mail` WHERE `expire_time` < '" UI64FMTD "' ORDER BY `expire_time` LIMIT %u,%u", (uint64)basetime, m_OldMailCounter, limit); } void ObjectMgr::LoadAreaTriggers() @@ -6803,7 +6803,7 @@ void ObjectMgr::PackGroupIds() // all valid ids are in the instance table // any associations to ids not in this table are assumed to be // cleaned already in CleanupInstances - std::unique_ptr result(CharacterDatabase.Query("SELECT `groupId` FROM `groups` ORDER BY `groupId` ASC")); + std::unique_ptr result(CharacterDatabase.Query("SELECT `group_id` FROM `groups` ORDER BY `group_id` ASC")); if (result) { do @@ -6815,8 +6815,8 @@ void ObjectMgr::PackGroupIds() if (id == 0) { CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM `groups` WHERE `groupId` = '%u'", id); - CharacterDatabase.PExecute("DELETE FROM `group_member` WHERE `groupId` = '%u'", id); + CharacterDatabase.PExecute("DELETE FROM `groups` WHERE `group_id` = '%u'", id); + CharacterDatabase.PExecute("DELETE FROM `group_member` WHERE `group_id` = '%u'", id); CharacterDatabase.CommitTransaction(); continue; } @@ -6837,8 +6837,8 @@ void ObjectMgr::PackGroupIds() { // remap group id CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("UPDATE `groups` SET `groupId` = '%u' WHERE `groupId` = '%u'", groupId, i); - CharacterDatabase.PExecute("UPDATE `group_member` SET `groupId` = '%u' WHERE `groupId` = '%u'", groupId, i); + CharacterDatabase.PExecute("UPDATE `groups` SET `group_id` = '%u' WHERE `group_id` = '%u'", groupId, i); + CharacterDatabase.PExecute("UPDATE `group_member` SET `group_id` = '%u' WHERE `group_id` = '%u'", groupId, i); CharacterDatabase.CommitTransaction(); } @@ -6868,9 +6868,9 @@ void ObjectMgr::SetHighestGuids() // Cleanup other tables from nonexistent guids (>=m_hiItemGuid) CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item` >= '%u'", m_ItemGuids.GetNextAfterMaxUsed()); + CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item_guid` >= '%u'", m_ItemGuids.GetNextAfterMaxUsed()); CharacterDatabase.PExecute("DELETE FROM `mail_items` WHERE `item_guid` >= '%u'", m_ItemGuids.GetNextAfterMaxUsed()); - CharacterDatabase.PExecute("DELETE FROM `auction` WHERE `itemguid` >= '%u'", m_ItemGuids.GetNextAfterMaxUsed()); + CharacterDatabase.PExecute("DELETE FROM `auction` WHERE `item_guid` >= '%u'", m_ItemGuids.GetNextAfterMaxUsed()); CharacterDatabase.CommitTransaction(); result.reset(WorldDatabase.Query("SELECT MAX(`guid`) FROM `gameobject`")); @@ -6900,15 +6900,15 @@ void ObjectMgr::SetHighestGuids() if (result) m_CorpseGuids.Set((*result)[0].GetUInt32() + 1); - result.reset(CharacterDatabase.Query("SELECT MAX(`guildid`) FROM `guild`")); + result.reset(CharacterDatabase.Query("SELECT MAX(`guild_id`) FROM `guild`")); if (result) m_GuildIds.Set((*result)[0].GetUInt32() + 1); - result.reset(CharacterDatabase.Query("SELECT MAX(`groupId`) FROM `groups`")); + result.reset(CharacterDatabase.Query("SELECT MAX(`group_id`) FROM `groups`")); if (result) m_GroupIds.Set((*result)[0].GetUInt32() + 1); - result.reset(CharacterDatabase.Query("SELECT MAX(`petitionguid`) FROM `petition`")); + result.reset(CharacterDatabase.Query("SELECT MAX(`petition_guid`) FROM `petition`")); if (result) m_PetitionIds.Set((*result)[0].GetUInt32() + 1); @@ -7449,12 +7449,12 @@ std::string ObjectMgr::GeneratePetName(uint32 entry) void ObjectMgr::LoadCorpses() { uint32 count = 0; - // 0 1 2 3 4 5 6 - std::unique_ptr result(CharacterDatabase.Query("SELECT `corpse`.`guid`, `player`, `corpse`.`position_x`, `corpse`.`position_y`, `corpse`.`position_z`, `corpse`.`orientation`, `corpse`.`map`, " - // 7 8 9 10 11 12 13 14 15 16 17 - "`time`, `corpse_type`, `instance`, `gender`, `race`, `class`, `playerBytes`, `playerBytes2`, `equipmentCache`, `guildId`, `playerFlags` FROM `corpse` " - "JOIN `characters` ON `player` = `characters`.`guid` " - "LEFT JOIN `guild_member` ON `player`=`guild_member`.`guid` WHERE `corpse_type` <> 0")); + // 0 1 2 3 4 5 6 + std::unique_ptr result(CharacterDatabase.Query("SELECT `corpse`.`guid`, `player_guid`, `corpse`.`position_x`, `corpse`.`position_y`, `corpse`.`position_z`, `corpse`.`orientation`, `corpse`.`map`, " + // 7 8 9 10 11 12 13 14 15 16 17 18 19 20 + "`time`, `corpse_type`, `instance`, `gender`, `race`, `class`, `skin`, `face`, `hair_style`, `hair_color`, `facial_hair`, `equipment_cache`, `guild_id`, `player_flags` FROM `corpse` " + "JOIN `characters` ON `player_guid` = `characters`.`guid` " + "LEFT JOIN `guild_member` ON `player_guid`=`guild_member`.`guid` WHERE `corpse_type` <> 0")); if (!result) { @@ -10648,7 +10648,7 @@ void ObjectMgr::LoadFactionChangeMounts() void ObjectMgr::RestoreDeletedItems() { - std::unique_ptr result(CharacterDatabase.Query("SELECT `id`, `player_guid`, `item_entry`, `stack_count` FROM `character_deleted_items`")); + std::unique_ptr result(CharacterDatabase.Query("SELECT `id`, `player_guid`, `item_id`, `stack_count` FROM `character_deleted_items`")); if (!result) { @@ -10670,15 +10670,15 @@ void ObjectMgr::RestoreDeletedItems() uint32 id = fields[0].GetUInt32(); uint32 playerGuidLow = fields[1].GetUInt32(); - uint32 itemEntry = fields[2].GetUInt32(); + uint32 itemId = fields[2].GetUInt32(); uint32 stackCount = fields[3].GetUInt32(); - if (ItemPrototype const* itemProto = GetItemPrototype(itemEntry)) + if (ItemPrototype const* itemProto = GetItemPrototype(itemId)) { ObjectGuid playerGuid = ObjectGuid(HIGHGUID_PLAYER, playerGuidLow); Player* pPlayer = ObjectAccessor::FindPlayerNotInWorld(playerGuid); - if (Item* restoredItem = Item::CreateItem(itemEntry, stackCount ? stackCount : 1, playerGuid)) + if (Item* restoredItem = Item::CreateItem(itemId, stackCount ? stackCount : 1, playerGuid)) { // save new item before send restoredItem->SaveToDB(); diff --git a/src/game/Objects/Corpse.cpp b/src/game/Objects/Corpse.cpp index 5c7634bc5..94bfd76d5 100644 --- a/src/game/Objects/Corpse.cpp +++ b/src/game/Objects/Corpse.cpp @@ -113,7 +113,7 @@ void Corpse::SaveToDB() MANGOS_ASSERT(GetType() != CORPSE_BONES); std::ostringstream ss; - ss << "REPLACE INTO corpse (guid,player,position_x,position_y,position_z,orientation,map,time,corpse_type,instance) VALUES (" + ss << "REPLACE INTO `corpse` (`guid`, `player_guid`, `position_x`, `position_y`, `position_z`, `orientation`, `map`, `time`, `corpse_type`, `instance`) VALUES (" << GetGUIDLow() << ", " << GetOwnerGuid().GetCounter() << ", " << GetPositionX() << ", " @@ -149,16 +149,16 @@ void Corpse::DeleteFromDB() // all corpses (not bones) static SqlStatementID id; - SqlStatement stmt = CharacterDatabase.CreateStatement(id, "DELETE FROM corpse WHERE player = ? AND corpse_type <> '0'"); + SqlStatement stmt = CharacterDatabase.CreateStatement(id, "DELETE FROM `corpse` WHERE `player_guid` = ? AND `corpse_type` <> '0'"); stmt.PExecute(GetOwnerGuid().GetCounter()); } bool Corpse::LoadFromDB(uint32 lowguid, Field* fields) { - //// 0 1 2 3 4 5 6 - //QueryResult* result = CharacterDatabase.Query("SELECT corpse.guid, player, corpse.position_x, corpse.position_y, corpse.position_z, corpse.orientation, corpse.map," - //// 7 8 9 10 11 12 13 14 15 16 17 - // "time, corpse_type, instance, gender, race, class, playerBytes, playerBytes2, equipmentCache, guildId, playerFlags FROM corpse" + //// 0 1 2 3 4 5 6 + //QueryResult* result = CharacterDatabase.Query("SELECT corpse.guid, player_guid, corpse.position_x, corpse.position_y, corpse.position_z, corpse.orientation, corpse.map," + //// 7 8 9 10 11 12 13 14 15 16 17 18 19 20 + // "time, corpse_type, instance, gender, race, class, skin, face, hair_style, hair_color, facial_hair, equipment_cache, guild_id, player_flags FROM corpse" uint32 playerLowGuid = fields[1].GetUInt32(); float positionX = fields[2].GetFloat(); float positionY = fields[3].GetFloat(); @@ -181,10 +181,15 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field* fields) uint8 gender = fields[10].GetUInt8(); uint8 race = fields[11].GetUInt8(); uint8 _class = fields[12].GetUInt8(); - uint32 playerBytes = fields[13].GetUInt32(); - uint32 playerBytes2 = fields[14].GetUInt32(); - uint32 guildId = fields[16].GetUInt32(); - uint32 playerFlags = fields[17].GetUInt32(); + + uint8 skin = fields[13].GetUInt8(); + uint8 face = fields[14].GetUInt8(); + uint8 hairstyle = fields[15].GetUInt8(); + uint8 haircolor = fields[16].GetUInt8(); + uint8 facialhair = fields[17].GetUInt8(); + + uint32 guildId = fields[19].GetUInt32(); + uint32 playerFlags = fields[20].GetUInt32(); ObjectGuid guid = ObjectGuid(HIGHGUID_CORPSE, lowguid); ObjectGuid playerGuid = ObjectGuid(HIGHGUID_PLAYER, playerLowGuid); @@ -204,7 +209,7 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field* fields) SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, gender == GENDER_FEMALE ? info->displayId_f : info->displayId_m); // Load equipment - Tokens data = StrSplit(fields[15].GetCppString(), " "); + Tokens data = StrSplit(fields[18].GetCppString(), " "); for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; slot++) { uint32 visualbase = slot * 2; @@ -219,11 +224,6 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field* fields) SetUInt32Value(CORPSE_FIELD_ITEM + slot, proto->DisplayInfoID | (proto->InventoryType << 24)); } - uint8 skin = (uint8)(playerBytes); - uint8 face = (uint8)(playerBytes >> 8); - uint8 hairstyle = (uint8)(playerBytes >> 16); - uint8 haircolor = (uint8)(playerBytes >> 24); - uint8 facialhair = (uint8)(playerBytes2); SetUInt32Value(CORPSE_FIELD_BYTES_1, ((0x00) | (race << 8) | (gender << 16) | (skin << 24))); SetUInt32Value(CORPSE_FIELD_BYTES_2, ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24))); diff --git a/src/game/Objects/GameObject.cpp b/src/game/Objects/GameObject.cpp index a794edc69..fe768b707 100644 --- a/src/game/Objects/GameObject.cpp +++ b/src/game/Objects/GameObject.cpp @@ -2537,7 +2537,7 @@ SpellEntry const* GameObject::GetSpellForLock(Player const* player) const for (auto&& playerSpell : player->GetSpellMap()) if (SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(playerSpell.first)) - for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) if (spellInfo->Effect[i] == SPELL_EFFECT_OPEN_LOCK && ((uint32)spellInfo->EffectMiscValue[i]) == lock->Index[i]) if (player->CalculateSpellEffectValue(nullptr, spellInfo, SpellEffectIndex(i), nullptr) >= int32(lock->Skill[i])) return spellInfo; diff --git a/src/game/Objects/Item.cpp b/src/game/Objects/Item.cpp index 11b13ccdb..18f6d8b39 100644 --- a/src/game/Objects/Item.cpp +++ b/src/game/Objects/Item.cpp @@ -307,9 +307,9 @@ void Item::SaveToDB() static SqlStatementID updItem; SqlStatement stmt = (uState == ITEM_NEW) ? - CharacterDatabase.CreateStatement(insItem, "REPLACE INTO `item_instance` (`itemEntry`, `owner_guid`, `creatorGuid`, `giftCreatorGuid`, `count`, `duration`, `charges`, `flags`, `enchantments`, `randomPropertyId`, `durability`, `text`, `generated_loot`, `guid`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") + CharacterDatabase.CreateStatement(insItem, "REPLACE INTO `item_instance` (`item_id`, `owner_guid`, `creator_guid`, `gift_creator_guid`, `count`, `duration`, `charges`, `flags`, `enchantments`, `random_property_id`, `durability`, `text`, `generated_loot`, `guid`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") : - CharacterDatabase.CreateStatement(updItem, "UPDATE `item_instance` SET `itemEntry` = ?, `owner_guid` = ?, `creatorGuid` = ?, `giftCreatorGuid` = ?, `count` = ?, `duration` = ?, `charges` = ?, `flags` = ?, `enchantments` = ?, `randomPropertyId` = ?, `durability` = ?, `text` = ?, `generated_loot` = ? WHERE `guid` = ?"); + CharacterDatabase.CreateStatement(updItem, "UPDATE `item_instance` SET `item_id` = ?, `owner_guid` = ?, `creator_guid` = ?, `gift_creator_guid` = ?, `count` = ?, `duration` = ?, `charges` = ?, `flags` = ?, `enchantments` = ?, `random_property_id` = ?, `durability` = ?, `text` = ?, `generated_loot` = ? WHERE `guid` = ?"); stmt.addUInt32(GetEntry()); stmt.addUInt32(GetOwnerGuid().GetCounter()); stmt.addUInt32(GetGuidValue(ITEM_FIELD_CREATOR).GetCounter()); @@ -396,11 +396,11 @@ void Item::SaveToDB() // save money as 0 itemid data if (loot.gold) { - SqlStatement stmt = CharacterDatabase.CreateStatement(saveGold, "INSERT INTO `item_loot` (`guid`, `owner_guid`, `itemid`, `amount`, `property`) VALUES (?, ?, 0, ?, 0)"); + SqlStatement stmt = CharacterDatabase.CreateStatement(saveGold, "INSERT INTO `item_loot` (`guid`, `owner_guid`, `item_id`, `amount`, `property`) VALUES (?, ?, 0, ?, 0)"); stmt.PExecute(GetGUIDLow(), ownerGuid.GetCounter(), loot.gold); } - SqlStatement stmt = CharacterDatabase.CreateStatement(saveLoot, "INSERT INTO `item_loot` (`guid`, `owner_guid`, `itemid`, `amount`, `property`) VALUES (?, ?, ?, ?, ?)"); + SqlStatement stmt = CharacterDatabase.CreateStatement(saveLoot, "INSERT INTO `item_loot` (`guid`, `owner_guid`, `item_id`, `amount`, `property`) VALUES (?, ?, ?, ?, ?)"); // save items and quest items (at load its all will added as normal, but this not important for item loot case) for (size_t i = 0; i < loot.GetMaxSlotInLootFor(ownerGuid); ++i) @@ -435,8 +435,8 @@ void Item::SaveToDB() bool Item::LoadFromDB(uint32 guidLow, ObjectGuid ownerGuid, Field* fields, uint32 entry) { - // 0 1 2 3 4 5 6 7 8 9 10 11 - // SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, text, item_guid, itemEntry + // 0 1 2 3 4 5 6 7 8 9 10 11 + // SELECT creator_guid, gift_creator_guid, count, duration, charges, flags, enchantments, random_property_id, durability, text, item_guid, item_id // create item before any checks for store correct guid // and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB Object::_Create(guidLow, 0, HIGHGUID_ITEM); @@ -532,8 +532,8 @@ bool Item::LoadFromDB(uint32 guidLow, ObjectGuid ownerGuid, Field* fields, uint3 void Item::DeleteAllFromDB(uint32 guidLow) { CharacterDatabase.PExecute("DELETE FROM `item_instance` WHERE `guid` = '%u'", guidLow); - CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item` = '%u'", guidLow); - CharacterDatabase.PExecute("DELETE FROM `auction` WHERE `itemguid` = '%u'", guidLow); + CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item_guid` = '%u'", guidLow); + CharacterDatabase.PExecute("DELETE FROM `auction` WHERE `item_guid` = '%u'", guidLow); CharacterDatabase.PExecute("DELETE FROM `mail_items` WHERE `item_guid` = '%u'", guidLow); // Petitions if (Petition* petition = sGuildMgr.GetPetitionByCharterGuid(ObjectGuid(guidLow))) @@ -561,7 +561,7 @@ void Item::LoadLootFromDB(Field* fields) if (!proto) { - CharacterDatabase.PExecute("DELETE FROM `item_loot` WHERE `guid` = '%u' AND `itemid` = '%u'", GetGUIDLow(), item_id); + CharacterDatabase.PExecute("DELETE FROM `item_loot` WHERE `guid` = '%u' AND `item_id` = '%u'", GetGUIDLow(), item_id); sLog.outError("Item::LoadLootFromDB: %s has an unknown item (id: #%u) in item_loot, deleted.", GetOwnerGuid().GetString().c_str(), item_id); return; } @@ -584,7 +584,7 @@ void Item::DeleteFromInventoryDB() { static SqlStatementID delInv ; - SqlStatement stmt = CharacterDatabase.CreateStatement(delInv, "DELETE FROM `character_inventory` WHERE `item` = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(delInv, "DELETE FROM `character_inventory` WHERE `item_guid` = ?"); stmt.PExecute(GetGUIDLow()); } diff --git a/src/game/Objects/Object.h b/src/game/Objects/Object.h index a74cb4c29..81d57f5ce 100644 --- a/src/game/Objects/Object.h +++ b/src/game/Objects/Object.h @@ -894,7 +894,7 @@ class WorldObject : public Object //these functions are used mostly for Relocate() and Corpse/Player specific stuff... //use them ONLY in LoadFromDB()/Create() funcs and nowhere else! //mapId/instanceId should be set in SetMap() function! - void SetLocationMapId(uint32 _mapId) { m_mapId = _mapId; } + void SetLocationMapId(uint32 mapId) { m_mapId = mapId; } void SetLocationInstanceId(uint32 _instanceId) { m_InstanceId = _instanceId; } bool IsWithinLootXPDist(WorldObject const* objToLoot) const; diff --git a/src/game/Objects/Pet.cpp b/src/game/Objects/Pet.cpp index e8aa0c358..98a7ec481 100644 --- a/src/game/Objects/Pet.cpp +++ b/src/game/Objects/Pet.cpp @@ -112,48 +112,48 @@ void Pet::RemoveFromWorld() Unit::RemoveFromWorld(); } -bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool current) +bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petNumber, bool current) { m_loading = true; m_isActiveObject = true; - uint32 ownerid = owner->GetGUIDLow(); + uint32 ownerGuidLow = owner->GetGUIDLow(); //QueryResult* result; - if (petnumber) + if (petNumber) { - // known petnumber entry 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 - /*result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, loyaltypoints, loyalty, trainpoint, slot, name, renamed, curhealth, curmana, curhappiness, abdata, TeachSpelldata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " - "FROM character_pet WHERE owner = '%u' AND id = '%u'", - ownerid, petnumber); */ - m_pTmpCache = sCharacterDatabaseCache.GetCharacterPetCacheByOwnerAndId(ownerid, petnumber); + // known petNumber entry 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 + /*result = CharacterDatabase.PQuery("SELECT id, entry, owner_guid, display_d, level, xp, react_state, loyalty_points, loyalty, training_points, slot, name, renamed, current_health, current_mana, current_happiness, action_bar_data, teach_spell_data, save_time, reset_talents_cost, reset_talents_time, created_by_spell, pet_type " + "FROM character_pet WHERE owner_guid = '%u' AND id = '%u'", + ownerGuidLow, petNumber); */ + m_pTmpCache = sCharacterDatabaseCache.GetCharacterPetCacheByOwnerAndId(ownerGuidLow, petNumber); } else if (current) { - // current pet (slot 0) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 - /*result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, loyaltypoints, loyalty, trainpoint, slot, name, renamed, curhealth, curmana, curhappiness, abdata, TeachSpelldata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " - "FROM character_pet WHERE owner = '%u' AND slot = '%u'", - ownerid, PET_SAVE_AS_CURRENT);*/ - m_pTmpCache = sCharacterDatabaseCache.GetCharacterCurrentPet(ownerid); + // current pet (slot 0) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 + /*result = CharacterDatabase.PQuery("SELECT id, entry, owner_guid, display_d, level, xp, react_state, loyalty_points, loyalty, training_points, slot, name, renamed, current_health, current_mana, current_happiness, action_bar_data, teach_spell_data, save_time, reset_talents_cost, reset_talents_time, created_by_spell, pet_type " + "FROM character_pet WHERE owner_guid = '%u' AND slot = '%u'", + ownerGuidLow, PET_SAVE_AS_CURRENT);*/ + m_pTmpCache = sCharacterDatabaseCache.GetCharacterCurrentPet(ownerGuidLow); } - else if (petentry) + else if (petEntry) { - // known petentry entry (unique for summoned pet, but non unique for hunter pet (only from current or not stabled pets) - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 - /*result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, loyaltypoints, loyalty, trainpoint, slot, name, renamed, curhealth, curmana, curhappiness, abdata, TeachSpelldata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " - "FROM character_pet WHERE owner = '%u' AND entry = '%u' AND (slot = '%u' OR slot > '%u') ", - ownerid, petentry,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT);*/ - m_pTmpCache = sCharacterDatabaseCache.GetCharacterPetByOwnerAndEntry(ownerid, petentry); + // known pet entry (unique for summoned pet, but non unique for hunter pet (only from current or not stabled pets) + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 + /*result = CharacterDatabase.PQuery("SELECT id, entry, owner_guid, display_d, level, xp, react_state, loyalty_points, loyalty, training_points, slot, name, renamed, current_health, current_mana, current_happiness, action_bar_data, teach_spell_data, save_time, reset_talents_cost, reset_talents_time, created_by_spell, pet_type " + "FROM character_pet WHERE owner_guid = '%u' AND entry = '%u' AND (slot = '%u' OR slot > '%u') ", + ownerGuidLow, petEntry,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT);*/ + m_pTmpCache = sCharacterDatabaseCache.GetCharacterPetByOwnerAndEntry(ownerGuidLow, petEntry); } else { // any current or other non-stabled pet (for hunter "call pet") - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 - /*result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, loyaltypoints, loyalty, trainpoint, slot, name, renamed, curhealth, curmana, curhappiness, abdata, TeachSpelldata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " - "FROM character_pet WHERE owner = '%u' AND (slot = '%u' OR slot > '%u') ", - ownerid,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT);*/ - m_pTmpCache = sCharacterDatabaseCache.GetCharacterPetByOwner(ownerid); + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 + /*result = CharacterDatabase.PQuery("SELECT id, entry, owner_guid, display_d, level, xp, react_state, loyalty_points, loyalty, training_points, slot, name, renamed, current_health, current_mana, current_happiness, action_bar_data, teach_spell_data, save_time, reset_talents_cost, reset_talents_time, created_by_spell, pet_type " + "FROM character_pet WHERE owner_guid = '%u' AND (slot = '%u' OR slot > '%u') ", + ownerGuidLow,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT);*/ + m_pTmpCache = sCharacterDatabaseCache.GetCharacterPetByOwner(ownerGuidLow); } if (!m_pTmpCache) @@ -165,25 +165,25 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c //Field* fields = result->Fetch(); // update for case of current pet "slot = 0" - petentry = m_pTmpCache->entry; - if (!petentry) + petEntry = m_pTmpCache->entry; + if (!petEntry) { m_pTmpCache = nullptr; m_loading = false; return false; } - CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(petentry); + CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(petEntry); if (!creatureInfo) { - sLog.outError("Pet entry %u does not exist but used at pet load (owner: %s).", petentry, owner->GetGuidStr().c_str()); + sLog.outError("Pet entry %u does not exist but used at pet load (owner: %s).", petEntry, owner->GetGuidStr().c_str()); m_pTmpCache = nullptr; m_loading = false; return false; } - uint32 summon_spell_id = m_pTmpCache->CreatedBySpell; + uint32 summon_spell_id = m_pTmpCache->createdBySpell; SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(summon_spell_id); bool is_temporary_summoned = spellInfo && spellInfo->GetDuration() > 0; @@ -196,7 +196,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c return false; } - PetType pet_type = PetType(m_pTmpCache->PetType); + PetType pet_type = PetType(m_pTmpCache->petType); if (pet_type == HUNTER_PET) { if (!creatureInfo->isTameable()) @@ -263,15 +263,15 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c m_charmInfo->SetPetNumber(pet_number, IsPermanentPetFor(owner)); SetOwnerGuid(owner->GetObjectGuid()); - SetDisplayId(m_pTmpCache->modelid); - SetNativeDisplayId(m_pTmpCache->modelid); + SetDisplayId(m_pTmpCache->displayId); + SetNativeDisplayId(m_pTmpCache->displayId); uint32 petlevel = m_pTmpCache->level; SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); if (pet_type == SUMMON_PET && !m_pTmpCache->renamed) { // generate new name for summon pet - std::string new_name = sObjectMgr.GeneratePetName(petentry); + std::string new_name = sObjectMgr.GeneratePetName(petEntry); if (!new_name.empty()) m_pTmpCache->name = new_name; } @@ -287,14 +287,14 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c SetCanModifyStats(true); InitStatsForLevel(petlevel); SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(nullptr))); - SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, m_pTmpCache->exp); + SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, m_pTmpCache->xp); SetCreatorGuid(owner->GetObjectGuid()); - SetReactState(ReactStates(m_pTmpCache->Reactstate)); - m_loyaltyPoints = m_pTmpCache->loyaltypoints; + SetReactState(ReactStates(m_pTmpCache->reactState)); + m_loyaltyPoints = m_pTmpCache->loyaltyPoints; - uint32 savedhealth = m_pTmpCache->curhealth; - uint32 savedmana = m_pTmpCache->curmana; + uint32 savedhealth = m_pTmpCache->currentHealth; + uint32 savedmana = m_pTmpCache->currentMana; // set current pet as current // 0=current @@ -307,11 +307,11 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c static SqlStatementID id_1; static SqlStatementID id_2; - SqlStatement stmt = CharacterDatabase.CreateStatement(id_1, "UPDATE character_pet SET slot = ? WHERE owner = ? AND slot = ? AND id <> ?"); - stmt.PExecute(uint32(PET_SAVE_NOT_IN_SLOT), ownerid, uint32(PET_SAVE_AS_CURRENT), m_charmInfo->GetPetNumber()); + SqlStatement stmt = CharacterDatabase.CreateStatement(id_1, "UPDATE `character_pet` SET `slot` = ? WHERE `owner_guid` = ? AND `slot` = ? AND `id` <> ?"); + stmt.PExecute(uint32(PET_SAVE_NOT_IN_SLOT), ownerGuidLow, uint32(PET_SAVE_AS_CURRENT), m_charmInfo->GetPetNumber()); - stmt = CharacterDatabase.CreateStatement(id_2, "UPDATE character_pet SET slot = ? WHERE owner = ? AND id = ?"); - stmt.PExecute(uint32(PET_SAVE_AS_CURRENT), ownerid, m_charmInfo->GetPetNumber()); + stmt = CharacterDatabase.CreateStatement(id_2, "UPDATE `character_pet` SET `slot` = ? WHERE `owner_guid` = ? AND `id` = ?"); + stmt.PExecute(uint32(PET_SAVE_AS_CURRENT), ownerGuidLow, m_charmInfo->GetPetNumber()); CharacterDatabase.CommitTransaction(); @@ -322,10 +322,10 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c // load action bar, if data broken will fill later by default spells. if (!is_temporary_summoned) { - m_charmInfo->LoadPetActionBar(m_pTmpCache->abdata); + m_charmInfo->LoadPetActionBar(m_pTmpCache->actionBarData); //init teach spells - Tokens tokens = StrSplit(m_pTmpCache->TeachSpelldata, " "); + Tokens tokens = StrSplit(m_pTmpCache->teachSpellData, " "); Tokens::const_iterator iter; int index; // Spells are in pairs. First is the ability, second is what teaches it to the hunter @@ -344,7 +344,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c } // since last save (in seconds) - uint32 timediff = uint32(time(nullptr) - m_pTmpCache->savetime); + uint32 timediff = uint32(time(nullptr) - m_pTmpCache->saveTime); //load spells/cooldowns/auras _LoadAuras(timediff); @@ -404,10 +404,10 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c SetUInt32Value(UNIT_FIELD_FLAGS, m_pTmpCache->renamed ? UNIT_FLAG_PET_ABANDON : UNIT_FLAG_PET_RENAME | UNIT_FLAG_PET_ABANDON); - SetTP(m_pTmpCache->trainpoint); + SetTP(m_pTmpCache->trainingPoints); SetMaxPower(POWER_HAPPINESS, GetCreatePowers(POWER_HAPPINESS)); - SetPower(POWER_HAPPINESS, m_pTmpCache->curhappiness); + SetPower(POWER_HAPPINESS, m_pTmpCache->currentHappiness); SetPowerType(POWER_FOCUS); } @@ -502,7 +502,7 @@ void Pet::SavePetToDB(PetSaveMode mode) static SqlStatementID delPet ; static SqlStatementID insPet ; - SqlStatement stmt = CharacterDatabase.CreateStatement(delPet, "DELETE FROM character_pet WHERE owner = ? AND id = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(delPet, "DELETE FROM `character_pet` WHERE `owner_guid` = ? AND `id` = ?"); stmt.PExecute(ownerLow, m_charmInfo->GetPetNumber()); // prevent duplicate using slot (except PET_SAVE_NOT_IN_SLOT) @@ -510,7 +510,7 @@ void Pet::SavePetToDB(PetSaveMode mode) { static SqlStatementID updPet ; - stmt = CharacterDatabase.CreateStatement(updPet, "UPDATE character_pet SET slot = ? WHERE owner = ? AND slot = ?"); + stmt = CharacterDatabase.CreateStatement(updPet, "UPDATE `character_pet` SET `slot` = ? WHERE `owner_guid` = ? AND `slot` = ?"); stmt.PExecute(uint32(PET_SAVE_NOT_IN_SLOT), ownerLow, uint32(mode)); } @@ -519,36 +519,36 @@ void Pet::SavePetToDB(PetSaveMode mode) { static SqlStatementID del ; - stmt = CharacterDatabase.CreateStatement(del, "DELETE FROM character_pet WHERE owner = ? AND (slot = ? OR slot > ?)"); + stmt = CharacterDatabase.CreateStatement(del, "DELETE FROM `character_pet` WHERE `owner_guid` = ? AND (`slot` = ? OR `slot` > ?)"); stmt.PExecute(ownerLow, uint32(PET_SAVE_AS_CURRENT), uint32(PET_SAVE_LAST_STABLE_SLOT)); } // save pet // On sauvegarde dans le cache m_pTmpCache->id = m_charmInfo->GetPetNumber(); - m_pTmpCache->owner = ownerLow; + m_pTmpCache->ownerGuid = ownerLow; m_pTmpCache->entry = GetEntry(); - m_pTmpCache->modelid = GetNativeDisplayId(); + m_pTmpCache->displayId = GetNativeDisplayId(); m_pTmpCache->level = GetLevel(); - m_pTmpCache->exp = GetUInt32Value(UNIT_FIELD_PETEXPERIENCE); - m_pTmpCache->Reactstate = GetReactState(); - m_pTmpCache->loyaltypoints = m_loyaltyPoints; + m_pTmpCache->xp = GetUInt32Value(UNIT_FIELD_PETEXPERIENCE); + m_pTmpCache->reactState = GetReactState(); + m_pTmpCache->loyaltyPoints = m_loyaltyPoints; m_pTmpCache->loyalty = GetLoyaltyLevel(); - m_pTmpCache->trainpoint = m_TrainingPoints; + m_pTmpCache->trainingPoints = m_TrainingPoints; m_pTmpCache->slot = mode; m_pTmpCache->name = m_name; m_pTmpCache->renamed = uint32(HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_RENAME) ? 0 : 1); - m_pTmpCache->curhealth = curhealth; - m_pTmpCache->curmana = curmana; - m_pTmpCache->curhappiness = GetPower(POWER_HAPPINESS); - m_pTmpCache->savetime = time(nullptr); - m_pTmpCache->resettalents_cost = m_resetTalentsCost; - m_pTmpCache->resettalents_time = m_resetTalentsTime; - m_pTmpCache->CreatedBySpell = GetUInt32Value(UNIT_CREATED_BY_SPELL); - m_pTmpCache->PetType = getPetType(); + m_pTmpCache->currentHealth = curhealth; + m_pTmpCache->currentMana = curmana; + m_pTmpCache->currentHappiness = GetPower(POWER_HAPPINESS); + m_pTmpCache->saveTime = time(nullptr); + m_pTmpCache->resetTalentsCost = m_resetTalentsCost; + m_pTmpCache->resetTalentsTime = m_resetTalentsTime; + m_pTmpCache->createdBySpell = GetUInt32Value(UNIT_CREATED_BY_SPELL); + m_pTmpCache->petType = getPetType(); - SqlStatement savePet = CharacterDatabase.CreateStatement(insPet, "INSERT INTO character_pet " - "( id, entry, owner, modelid, level, exp, Reactstate, loyaltypoints, loyalty, trainpoint, slot, name, renamed, curhealth, curmana, curhappiness, abdata, TeachSpelldata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType) " + SqlStatement savePet = CharacterDatabase.CreateStatement(insPet, "INSERT INTO `character_pet` " + "( `id`, `entry`, `owner_guid`, `display_id`, `level`, `xp`, `react_state`, `loyalty_points`, `loyalty`, `training_points`, `slot`, `name`, `renamed`, `current_health`, `current_mana`, `current_happiness`, `action_bar_data`, `teach_spell_data`, `save_time`, `reset_talents_cost`, `reset_talents_time`, `created_by_spell`, `pet_type`) " "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); savePet.addUInt32(m_charmInfo->GetPetNumber()); @@ -574,7 +574,7 @@ void Pet::SavePetToDB(PetSaveMode mode) ss << uint32(m_charmInfo->GetActionBarEntry(i)->GetType()) << " " << uint32(m_charmInfo->GetActionBarEntry(i)->GetAction()) << " "; }; - m_pTmpCache->abdata = ss.str(); + m_pTmpCache->actionBarData = ss.str(); savePet.addString(ss); ss.str(""); @@ -586,7 +586,7 @@ void Pet::SavePetToDB(PetSaveMode mode) for (; i < 4; ++i) ss << uint32(0) << " " << uint32(0) << " "; } - m_pTmpCache->TeachSpelldata = ss.str(); + m_pTmpCache->teachSpellData = ss.str(); savePet.addString(ss); savePet.addUInt64(uint64(time(nullptr))); @@ -623,16 +623,16 @@ void Pet::DeleteFromDB(uint32 guidlow, bool separate_transaction) static SqlStatementID delSpells ; static SqlStatementID delSpellCD ; - SqlStatement stmt = CharacterDatabase.CreateStatement(delPet, "DELETE FROM character_pet WHERE id = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(delPet, "DELETE FROM `character_pet` WHERE `id` = ?"); stmt.PExecute(guidlow); - stmt = CharacterDatabase.CreateStatement(delAuras, "DELETE FROM pet_aura WHERE guid = ?"); + stmt = CharacterDatabase.CreateStatement(delAuras, "DELETE FROM `pet_aura` WHERE `guid` = ?"); stmt.PExecute(guidlow); - stmt = CharacterDatabase.CreateStatement(delSpells, "DELETE FROM pet_spell WHERE guid = ?"); + stmt = CharacterDatabase.CreateStatement(delSpells, "DELETE FROM `pet_spell` WHERE `guid` = ?"); stmt.PExecute(guidlow); - stmt = CharacterDatabase.CreateStatement(delSpellCD, "DELETE FROM pet_spell_cooldown WHERE guid = ?"); + stmt = CharacterDatabase.CreateStatement(delSpellCD, "DELETE FROM `pet_spell_cooldown` WHERE `guid` = ?"); stmt.PExecute(guidlow); sCharacterDatabaseCache.DeleteCharacterPetById(guidlow); @@ -1545,16 +1545,16 @@ bool Pet::HaveInDiet(ItemPrototype const* item) const return diet & FoodMask; } -uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel) const +uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemLevel) const { // -5 or greater food level - if (GetLevel() <= itemlevel + 5) //possible to feed level 60 pet with level 55 level food for full effect + if (GetLevel() <= itemLevel + 5) //possible to feed level 60 pet with level 55 level food for full effect return 35000; // -10..-6 - if (GetLevel() <= itemlevel + 10) //pure guess, but sounds good + if (GetLevel() <= itemLevel + 10) //pure guess, but sounds good return 17000; // -14..-11 - if (GetLevel() <= itemlevel + 14) //level 55 food gets green on 70, makes sense to me + if (GetLevel() <= itemLevel + 14) //level 55 food gets green on 70, makes sense to me return 8000; // -15 or less return 0; @@ -1571,21 +1571,21 @@ void Pet::_LoadSpellCooldowns() uint32 cdCount = 0; auto curTime = sWorld.GetCurrentClockTime(); - for (const auto& it : m_pTmpCache->spellCooldown) + for (const auto& it : m_pTmpCache->spellCooldowns) { //Field* fields = result->Fetch(); - uint32 spell_id = it.spell; //fields[0].GetUInt32(); - uint64 spell_time = it.time; //fields[1].GetUInt64(); + uint32 spellId = it.spell; //fields[0].GetUInt32(); + uint64 spellTime = it.time; //fields[1].GetUInt64(); - SpellEntry const* spellEntry = sSpellMgr.GetSpellEntry(spell_id); + SpellEntry const* spellEntry = sSpellMgr.GetSpellEntry(spellId); if (!spellEntry) { - sLog.outError("%s has unknown spell %u in `character_spell_cooldown`, skipping.", GetGuidStr().c_str(), spell_id); + sLog.outError("%s has unknown spell %u in `character_spell_cooldown`, skipping.", GetGuidStr().c_str(), spellId); continue; } - TimePoint spellExpireTime = std::chrono::time_point_cast(Clock::from_time_t(spell_time)); + TimePoint spellExpireTime = std::chrono::time_point_cast(Clock::from_time_t(spellTime)); std::chrono::milliseconds spellRecTime = std::chrono::milliseconds::zero(); if (spellExpireTime > curTime) spellRecTime = std::chrono::duration_cast(spellExpireTime - curTime); @@ -1594,14 +1594,14 @@ void Pet::_LoadSpellCooldowns() if (spellRecTime == std::chrono::milliseconds::zero()) continue; - cdData << uint32(spell_id); + cdData << uint32(spellId); cdData << uint32(uint32(spellRecTime.count())); ++cdCount; - m_cooldownMap.AddCooldown(sWorld.GetCurrentClockTime(), spell_id, uint32(spellRecTime.count())); + m_cooldownMap.AddCooldown(sWorld.GetCurrentClockTime(), spellId, uint32(spellRecTime.count())); #ifdef _DEBUG uint32 spellCDDuration = std::chrono::duration_cast(spellRecTime).count(); - sLog.outDebug("Adding spell cooldown to %s, SpellID(%u), recDuration(%us).", GetGuidStr().c_str(), spell_id, spellCDDuration); + sLog.outDebug("Adding spell cooldown to %s, SpellID(%u), recDuration(%us).", GetGuidStr().c_str(), spellId, spellCDDuration); #endif } //while (result->NextRow()); @@ -1622,12 +1622,12 @@ void Pet::_LoadSpellCooldowns() void Pet::_SaveSpellCooldowns() { if (m_pTmpCache) - m_pTmpCache->spellCooldown.clear(); + m_pTmpCache->spellCooldowns.clear(); static SqlStatementID delSpellCD; static SqlStatementID insSpellCD; - SqlStatement stmt = CharacterDatabase.CreateStatement(delSpellCD, "DELETE FROM pet_spell_cooldown WHERE guid = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(delSpellCD, "DELETE FROM `pet_spell_cooldown` WHERE `guid` = ?"); stmt.PExecute(m_charmInfo->GetPetNumber()); TimePoint currTime = sWorld.GetCurrentClockTime(); @@ -1646,10 +1646,10 @@ void Pet::_SaveSpellCooldowns() PetSpellCoodown cd; cd.spell = cdItr.first; cd.time = spellExpireTime; - m_pTmpCache->spellCooldown.push_back(cd); + m_pTmpCache->spellCooldowns.push_back(cd); } - stmt = CharacterDatabase.CreateStatement(insSpellCD, "INSERT INTO pet_spell_cooldown (guid,spell,time) VALUES (?, ?, ?)"); + stmt = CharacterDatabase.CreateStatement(insSpellCD, "INSERT INTO `pet_spell_cooldown` (`guid`, `spell`, `time`) VALUES (?, ?, ?)"); stmt.PExecute(m_charmInfo->GetPetNumber(), cdItr.first, spellExpireTime); } } @@ -1698,14 +1698,14 @@ void Pet::_SaveSpells() { case PETSPELL_REMOVED: { - SqlStatement stmt = CharacterDatabase.CreateStatement(delSpell, "DELETE FROM pet_spell WHERE guid = ? and spell = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(delSpell, "DELETE FROM `pet_spell` WHERE `guid` = ? and `spell` = ?"); stmt.PExecute(m_charmInfo->GetPetNumber(), itr->first); m_petSpells.erase(itr); } continue; case PETSPELL_CHANGED: { - SqlStatement stmt = CharacterDatabase.CreateStatement(delSpell, "DELETE FROM pet_spell WHERE guid = ? and spell = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(delSpell, "DELETE FROM `pet_spell` WHERE `guid` = ? and `spell` = ?"); stmt.PExecute(m_charmInfo->GetPetNumber(), itr->first); stmt = CharacterDatabase.CreateStatement(insSpell, "INSERT INTO `pet_spell` (`guid`, `spell`, `active`) VALUES (?, ?, ?)"); @@ -1734,28 +1734,28 @@ void Pet::_LoadAuras(uint32 timediff) for (int i = UNIT_FIELD_AURA; i <= UNIT_FIELD_AURASTATE; ++i) SetUInt32Value(i, 0); - //QueryResult* result = CharacterDatabase.PQuery("SELECT caster_guid,item_guid,spell,stackcount,remaincharges,basepoints0,basepoints1,basepoints2,periodictime0,periodictime1,periodictime2,maxduration,remaintime,effIndexMask FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber()); + //QueryResult* result = CharacterDatabase.PQuery("SELECT caster_guid, item_guid, spell, stacks, charges, base_points0, base_points1, base_points2, periodic_time0, periodic_time1, periodic_time2, max_duration, duration, effect_index_mask FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber()); if (m_pTmpCache) { for (const auto& it : m_pTmpCache->auras) { - ObjectGuid casterGuid = ObjectGuid(it.caster_guid); - uint32 item_lowguid = it.item_guid; - uint32 spellid = it.spell; + ObjectGuid casterGuid = it.casterGuid; + uint32 item_lowguid = it.itemLowGuid; + uint32 spellid = it.spellId; + uint32 stackcount = it.stacks; + int32 remaincharges = (int32)it.charges; - uint32 stackcount = it.stackcount; - int32 remaincharges = (int32)it.remaincharges; float damage[MAX_EFFECT_INDEX]; int32 periodicTime[MAX_EFFECT_INDEX]; - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { - damage[i] = it.basepoints[i]; - periodicTime[i] = it.periodictime[i]; + damage[i] = it.damage[i]; + periodicTime[i] = it.periodicTime[i]; } - int32 maxduration = it.maxduration; - int32 remaintime = it.remaintime; - uint32 effIndexMask = it.effIndexMask; + int32 maxduration = it.maxDuration; + int32 remaintime = it.duration; + uint8 effIndexMask = it.effIndexMask; SpellEntry const* spellproto = sSpellMgr.GetSpellEntry(spellid); if (!spellproto) @@ -1790,7 +1790,7 @@ void Pet::_LoadAuras(uint32 timediff) SpellAuraHolder* holder = CreateSpellAuraHolder(spellproto, this, nullptr, nullptr); holder->SetLoadedState(casterGuid, ObjectGuid(HIGHGUID_ITEM, item_lowguid), stackcount, remaincharges, maxduration, remaintime); - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if ((effIndexMask & (1 << i)) == 0) continue; @@ -1825,7 +1825,7 @@ void Pet::_SaveAuras() static SqlStatementID delAuras ; static SqlStatementID insAuras ; - SqlStatement stmt = CharacterDatabase.CreateStatement(delAuras, "DELETE FROM pet_aura WHERE guid = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(delAuras, "DELETE FROM `pet_aura` WHERE `guid` = ?"); stmt.PExecute(m_charmInfo->GetPetNumber()); SpellAuraHolderMap const& auraHolders = GetSpellAuraHolderMap(); @@ -1833,8 +1833,8 @@ void Pet::_SaveAuras() if (auraHolders.empty()) return; - stmt = CharacterDatabase.CreateStatement(insAuras, "INSERT INTO pet_aura (guid, caster_guid, item_guid, spell, stackcount, remaincharges, " - "basepoints0, basepoints1, basepoints2, periodictime0, periodictime1, periodictime2, maxduration, remaintime, effIndexMask) " + stmt = CharacterDatabase.CreateStatement(insAuras, "INSERT INTO `pet_aura` (`guid`, `caster_guid`, `item_guid`, `spell`, `stacks`, `charges`, " + "`base_points0`, `base_points1`, `base_points2`, `periodic_time0`, `periodic_time1`, `periodic_time2`, `max_duration`, `duration`, `effect_index_mask`) " "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); for (const auto& auraHolder : auraHolders) @@ -1842,7 +1842,7 @@ void Pet::_SaveAuras() SpellAuraHolder* holder = auraHolder.second; bool save = true; - for (int32 j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { SpellEntry const* spellInfo = holder->GetSpellProto(); if (spellInfo->EffectApplyAuraName[j] == SPELL_AURA_MOD_STEALTH || @@ -1858,11 +1858,11 @@ void Pet::_SaveAuras() //do not save single target holders (unless they were cast by the player) if (save && !holder->IsPassive() && !holder->GetSpellProto()->IsChanneledSpell() && (holder->GetCasterGuid() == GetObjectGuid() || !holder->IsSingleTarget())) { - int32 damage[MAX_EFFECT_INDEX]; + float damage[MAX_EFFECT_INDEX]; uint32 periodicTime[MAX_EFFECT_INDEX]; - uint32 effIndexMask = 0; + uint8 effIndexMask = 0; - for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { damage[i] = 0; periodicTime[i] = 0; @@ -1885,18 +1885,18 @@ void Pet::_SaveAuras() if (m_pTmpCache) { PetAuraCache c; - c.caster_guid = holder->GetCasterGuid().GetRawValue(); - c.item_guid = holder->GetCastItemGuid().GetCounter(); - c.spell = holder->GetId(); - c.stackcount = holder->GetStackAmount(); - c.remaincharges = holder->GetAuraCharges(); + c.casterGuid = holder->GetCasterGuid(); + c.itemLowGuid = holder->GetCastItemGuid().GetCounter(); + c.spellId = holder->GetId(); + c.stacks = holder->GetStackAmount(); + c.charges = holder->GetAuraCharges(); c.effIndexMask = effIndexMask; - c.maxduration = holder->GetAuraMaxDuration(); - c.remaintime = holder->GetAuraDuration(); - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + c.maxDuration = holder->GetAuraMaxDuration(); + c.duration = holder->GetAuraDuration(); + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { - c.basepoints[i] = damage[i]; - c.periodictime[i] = periodicTime[i]; + c.damage[i] = damage[i]; + c.periodicTime[i] = periodicTime[i]; } m_pTmpCache->auras.push_back(c); } @@ -1909,37 +1909,37 @@ void Pet::_SaveAuras() stmt.addUInt8(holder->GetAuraCharges()); for (int32 i : damage) - stmt.addInt32(i); + stmt.addFloat(i); for (uint32 i : periodicTime) stmt.addUInt32(i); stmt.addInt32(holder->GetAuraMaxDuration()); stmt.addInt32(holder->GetAuraDuration()); - stmt.addUInt32(effIndexMask); + stmt.addUInt8(effIndexMask); stmt.Execute(); } } } -bool Pet::AddSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpellState state /*= PETSPELL_NEW*/, PetSpellType type /*= PETSPELL_NORMAL*/) +bool Pet::AddSpell(uint32 spellId, ActiveStates active /*= ACT_DECIDE*/, PetSpellState state /*= PETSPELL_NEW*/, PetSpellType type /*= PETSPELL_NORMAL*/) { - SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(spell_id); + SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(spellId); if (!spellInfo) { // do pet spell book cleanup if (state == PETSPELL_UNCHANGED) // spell load case { - sLog.outError("Pet::AddSpell: nonexistent in SpellStore spell #%u request, deleting for all pets in `pet_spell`.", spell_id); - CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE spell = '%u'", spell_id); + sLog.outError("Pet::AddSpell: nonexistent in SpellStore spell #%u request, deleting for all pets in `pet_spell`.", spellId); + CharacterDatabase.PExecute("DELETE FROM `pet_spell` WHERE `spell` = '%u'", spellId); } else - sLog.outError("Pet::AddSpell: nonexistent in SpellStore spell #%u request.", spell_id); + sLog.outError("Pet::AddSpell: nonexistent in SpellStore spell #%u request.", spellId); return false; } - PetSpellMap::iterator itr = m_petSpells.find(spell_id); + PetSpellMap::iterator itr = m_petSpells.find(spellId); if (itr != m_petSpells.end()) { if (itr->second.state == PETSPELL_REMOVED) @@ -1953,9 +1953,9 @@ bool Pet::AddSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe itr->second.state = PETSPELL_UNCHANGED; if (active == ACT_ENABLED) - ToggleAutocast(spell_id, true); + ToggleAutocast(spellId, true); else if (active == ACT_DISABLED) - ToggleAutocast(spell_id, false); + ToggleAutocast(spellId, false); return false; } @@ -1979,7 +1979,7 @@ bool Pet::AddSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe else newspell.active = active; - if (sSpellMgr.GetSpellRank(spell_id) != 0) + if (sSpellMgr.GetSpellRank(spellId) != 0) { for (const auto& itr : m_petSpells) { @@ -1989,7 +1989,7 @@ bool Pet::AddSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe if (sSpellMgr.IsRankSpellDueToSpell(spellInfo, itr.first)) { // replace by new high rank - if (sSpellMgr.IsHighRankOfSpell(spell_id, itr.first)) + if (sSpellMgr.IsHighRankOfSpell(spellId, itr.first)) { newspell.active = itr.second.active; @@ -2001,29 +2001,29 @@ bool Pet::AddSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe break; } // ignore new lesser rank - else if (sSpellMgr.IsHighRankOfSpell(itr.first, spell_id)) + else if (sSpellMgr.IsHighRankOfSpell(itr.first, spellId)) return false; } } } - m_petSpells[spell_id] = newspell; + m_petSpells[spellId] = newspell; if (spellInfo->IsPassiveSpell()) - CastSpell(this, spell_id, true); + CastSpell(this, spellId, true); else - m_charmInfo->AddSpellToActionBar(spell_id, ActiveStates(newspell.active)); + m_charmInfo->AddSpellToActionBar(spellId, ActiveStates(newspell.active)); if (newspell.active == ACT_ENABLED) - ToggleAutocast(spell_id, true); + ToggleAutocast(spellId, true); return true; } -bool Pet::LearnSpell(uint32 spell_id) +bool Pet::LearnSpell(uint32 spellId) { // prevent duplicated entires in spell book - if (!AddSpell(spell_id)) + if (!AddSpell(spellId)) return false; if (!m_loading) @@ -2035,14 +2035,14 @@ bool Pet::LearnSpell(uint32 spell_id) return true; } -bool Pet::unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab) +bool Pet::unlearnSpell(uint32 spellId, bool learn_prev, bool clear_ab) { - return RemoveSpell(spell_id, learn_prev, clear_ab); + return RemoveSpell(spellId, learn_prev, clear_ab); } -bool Pet::RemoveSpell(uint32 spell_id, bool learn_prev, bool clear_ab) +bool Pet::RemoveSpell(uint32 spellId, bool learn_prev, bool clear_ab) { - auto itr = m_petSpells.find(spell_id); + auto itr = m_petSpells.find(spellId); if (itr == m_petSpells.end()) return false; @@ -2054,18 +2054,18 @@ bool Pet::RemoveSpell(uint32 spell_id, bool learn_prev, bool clear_ab) else itr->second.state = PETSPELL_REMOVED; - RemoveAurasDueToSpell(spell_id); + RemoveAurasDueToSpell(spellId); if (learn_prev) { - if (uint32 prev_id = sSpellMgr.GetPrevSpellInChain(spell_id)) + if (uint32 prev_id = sSpellMgr.GetPrevSpellInChain(spellId)) LearnSpell(prev_id); else learn_prev = false; } // if remove last rank or non-ranked then update action bar at server and client if need - if (clear_ab && !learn_prev && m_charmInfo->RemoveSpellFromActionBar(spell_id)) + if (clear_ab && !learn_prev && m_charmInfo->RemoveSpellFromActionBar(spellId)) { if (!m_loading) { diff --git a/src/game/Objects/Pet.h b/src/game/Objects/Pet.h index 391f115f8..852ff0e1a 100644 --- a/src/game/Objects/Pet.h +++ b/src/game/Objects/Pet.h @@ -159,7 +159,7 @@ class Pet : public Creature bool Create (uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, uint32 pet_number); bool CreateBaseAtCreature(Creature* creature); - bool LoadPetFromDB(Player* owner,uint32 petentry = 0,uint32 petnumber = 0, bool current = false); + bool LoadPetFromDB(Player* owner, uint32 petEntry = 0, uint32 petNumber = 0, bool current = false); void SavePetToDB(PetSaveMode mode); void Unsummon(PetSaveMode mode, Unit* owner = nullptr); void DelayedUnsummon(uint32 timeMSToDespawn, PetSaveMode mode); @@ -192,7 +192,7 @@ class Pet : public Creature void SynchronizeLevelWithOwner(); bool InitStatsForLevel(uint32 level, Unit* owner = nullptr); bool HaveInDiet(ItemPrototype const* item) const; - uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel) const; + uint32 GetCurrentFoodBenefitLevel(uint32 itemLevel) const; void SetDuration(int32 dur) { m_duration = dur; } int32 GetBonusDamage() const { return m_bonusdamage; } @@ -229,10 +229,10 @@ class Pet : public Creature void _LoadSpells(); void _SaveSpells(); - bool AddSpell(uint32 spell_id,ActiveStates active = ACT_DECIDE, PetSpellState state = PETSPELL_NEW, PetSpellType type = PETSPELL_NORMAL); - bool LearnSpell(uint32 spell_id); - bool unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true); - bool RemoveSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true); + bool AddSpell(uint32 spellId, ActiveStates active = ACT_DECIDE, PetSpellState state = PETSPELL_NEW, PetSpellType type = PETSPELL_NORMAL); + bool LearnSpell(uint32 spellId); + bool unlearnSpell(uint32 spellId, bool learn_prev, bool clear_ab = true); + bool RemoveSpell(uint32 spellId, bool learn_prev, bool clear_ab = true); void CleanupActionBar(); PetSpellMap m_petSpells; diff --git a/src/game/Objects/Player.cpp b/src/game/Objects/Player.cpp index ef6f522eb..e5b015b90 100644 --- a/src/game/Objects/Player.cpp +++ b/src/game/Objects/Player.cpp @@ -491,14 +491,14 @@ void TradeData::SetItem(TradeSlots slot, Item* item) SetSpell(0); } -void TradeData::SetSpell(uint32 spell_id, Item* castItem /*= nullptr*/) +void TradeData::SetSpell(uint32 spellId, Item* castItem /*= nullptr*/) { ObjectGuid itemGuid = castItem ? castItem->GetObjectGuid() : ObjectGuid(); - if (m_spell == spell_id && m_spellCastItem == itemGuid) + if (m_spell == spellId && m_spellCastItem == itemGuid) return; - m_spell = spell_id; + m_spell = spellId; m_spellCastItem = itemGuid; SetAccepted(false); @@ -621,8 +621,6 @@ Player::Player(WorldSession* session) : Unit(), m_trade = nullptr; - m_cinematic = 0; - PlayerTalkClass = new PlayerMenu(GetSession()); m_currentBuybackSlot = BUYBACK_SLOT_START; @@ -642,8 +640,9 @@ Player::Player(WorldSession* session) : Unit(), j.invitedToInstance = 0; } - m_logintime = time(nullptr); - m_Last_tick = m_logintime; + m_loginTime = time(nullptr); + m_createTime = m_loginTime; + m_lastTick = m_loginTime; m_WeaponProficiency = 0; m_ArmorProficiency = 0; m_canParry = false; @@ -895,9 +894,9 @@ bool Player::Create(uint32 guidlow, std::string const& name, uint8 race, uint8 c SetUInt32Value(PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_UINT32_START_PLAYER_MONEY)); // Played time - m_Last_tick = time(nullptr); - m_Played_time[PLAYED_TIME_TOTAL] = 0; - m_Played_time[PLAYED_TIME_LEVEL] = 0; + m_lastTick = time(nullptr); + m_playedTime[PLAYED_TIME_TOTAL] = 0; + m_playedTime[PLAYED_TIME_LEVEL] = 0; // base stats and related field values InitStatsForLevel(); @@ -977,19 +976,19 @@ void Player::AddStartingItems() // all item positions resolved } -bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount, uint32 enchantId) +bool Player::StoreNewItemInBestSlots(uint32 itemId, uint32 amount, uint32 enchantId) { - DEBUG_LOG("STORAGE: Creating initial item, itemId = %u, count = %u", titem_id, titem_amount); + DEBUG_LOG("STORAGE: Creating initial item, itemId = %u, count = %u", itemId, amount); // attempt equip by one - while (titem_amount > 0) + while (amount > 0) { uint16 eDest; - uint8 msg = CanEquipNewItem(NULL_SLOT, eDest, titem_id, false); + uint8 msg = CanEquipNewItem(NULL_SLOT, eDest, itemId, false); if (msg != EQUIP_ERR_OK) break; - if (Item* pItem = EquipNewItem(eDest, titem_id, true)) + if (Item* pItem = EquipNewItem(eDest, itemId, true)) { bool needReApplyItemMods = false; if (enchantId) @@ -998,7 +997,7 @@ bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount, uint3 pItem->SetEnchantment(PERM_ENCHANTMENT_SLOT, enchantId, 0, 0); needReApplyItemMods = true; } - if (uint32 randomPropertyId = Item::GenerateItemRandomPropertyId(titem_id)) + if (uint32 randomPropertyId = Item::GenerateItemRandomPropertyId(itemId)) { pItem->SetItemRandomProperties(randomPropertyId); needReApplyItemMods = true; @@ -1013,27 +1012,27 @@ bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount, uint3 AutoUnequipOffhandIfNeed(); - if ((titem_amount > 1) && (titem_amount <= pItem->GetProto()->GetMaxStackSize())) + if ((amount > 1) && (amount <= pItem->GetProto()->GetMaxStackSize())) { - pItem->SetCount(titem_amount); - titem_amount = 0; + pItem->SetCount(amount); + amount = 0; break; } } - --titem_amount; + --amount; } - if (titem_amount == 0) + if (amount == 0) return true; // equipped // attempt store ItemPosCountVec sDest; // store in main bag to simplify second pass (special bags can be not equipped yet at this moment) - uint8 msg = CanStoreNewItem(INVENTORY_SLOT_BAG_0, NULL_SLOT, sDest, titem_id, titem_amount); + uint8 msg = CanStoreNewItem(INVENTORY_SLOT_BAG_0, NULL_SLOT, sDest, itemId, amount); if (msg == EQUIP_ERR_OK) { - if (Item* pItem = StoreNewItem(sDest, titem_id, true, Item::GenerateItemRandomPropertyId(titem_id))) + if (Item* pItem = StoreNewItem(sDest, itemId, true, Item::GenerateItemRandomPropertyId(itemId))) { if (enchantId) { @@ -1045,20 +1044,20 @@ bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount, uint3 } // item can't be added - sLog.outError("STORAGE: Can't equip or store initial item %u for race %u class %u , error msg = %u", titem_id, GetRace(), GetClass(), msg); + sLog.outError("STORAGE: Can't equip or store initial item %u for race %u class %u , error msg = %u", itemId, GetRace(), GetClass(), msg); return false; } // helper function, mainly for script side, but can be used for simple task in mangos also. -Item* Player::StoreNewItemInInventorySlot(uint32 itemEntry, uint32 amount) +Item* Player::StoreNewItemInInventorySlot(uint32 itemId, uint32 amount) { ItemPosCountVec vDest; - uint8 msg = CanStoreNewItem(INVENTORY_SLOT_BAG_0, NULL_SLOT, vDest, itemEntry, amount); + uint8 msg = CanStoreNewItem(INVENTORY_SLOT_BAG_0, NULL_SLOT, vDest, itemId, amount); if (msg == EQUIP_ERR_OK) { - if (Item* pItem = StoreNewItem(vDest, itemEntry, true, Item::GenerateItemRandomPropertyId(itemEntry))) + if (Item* pItem = StoreNewItem(vDest, itemId, true, Item::GenerateItemRandomPropertyId(itemId))) return pItem; } @@ -1520,8 +1519,8 @@ void Player::Update(uint32 update_diff, uint32 p_time) } // Update items that have just a limited lifetime - if (now > m_Last_tick) - UpdateItemDuration(uint32(now - m_Last_tick)); + if (now > m_lastTick) + UpdateItemDuration(uint32(now - m_lastTick)); if (!m_timedquests.empty()) { @@ -1626,12 +1625,12 @@ void Player::Update(uint32 update_diff, uint32 p_time) } // Played time - if (now > m_Last_tick) + if (now > m_lastTick) { - uint32 elapsed = uint32(now - m_Last_tick); - m_Played_time[PLAYED_TIME_TOTAL] += elapsed; // Total played time - m_Played_time[PLAYED_TIME_LEVEL] += elapsed; // Level played time - m_Last_tick = now; + uint32 elapsed = uint32(now - m_lastTick); + m_playedTime[PLAYED_TIME_TOTAL] += elapsed; // Total played time + m_playedTime[PLAYED_TIME_LEVEL] += elapsed; // Level played time + m_lastTick = now; } if (m_drunk) @@ -1949,12 +1948,12 @@ void Player::AutoReSummonPet() bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data) { - // 0 1 2 3 4 5 6 7 - // "SELECT characters.guid, characters.name, characters.race, characters.class, characters.gender, characters.playerBytes, characters.playerBytes2, characters.level, " - // 8 9 10 11 12 13 14 - // "characters.zone, characters.map, characters.position_x, characters.position_y, characters.position_z, guild_member.guildid, characters.playerFlags, " - // 15 16 17 18 19 - // "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.equipmentCache " + // 0 1 2 3 4 5 6 7 8 9 10 + // "SELECT characters.guid, characters.name, characters.race, characters.class, characters.gender, characters.skin, characters.face, characters.hair_style, characters.hair_color, characters.facial_hair, characters.level, " + // 11 12 13 14 15 16 17 + // "characters.zone, characters.map, characters.position_x, characters.position_y, characters.position_z, guild_member.guild_id, characters.player_flags, " + // 18 19 20 21 22 + // "characters.at_login_flags, character_pet.entry, character_pet.display_id, character_pet.level, characters.equipment_cache " Field* fields = result->Fetch(); @@ -1975,28 +1974,31 @@ bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data) *p_data << uint8(pClass); // class *p_data << uint8(fields[4].GetUInt8()); // gender - uint32 playerBytes = fields[5].GetUInt32(); - *p_data << uint8(playerBytes); // skin - *p_data << uint8(playerBytes >> 8); // face - *p_data << uint8(playerBytes >> 16); // hair style - *p_data << uint8(playerBytes >> 24); // hair color + uint8 skin = fields[5].GetUInt8(); + uint8 face = fields[6].GetUInt8(); + uint8 hairStyle = fields[7].GetUInt8(); + uint8 hairColor = fields[8].GetUInt8(); + *p_data << uint8(skin); // skin + *p_data << uint8(face); // face + *p_data << uint8(hairStyle); // hair style + *p_data << uint8(hairColor); // hair color - uint32 playerBytes2 = fields[6].GetUInt32(); - *p_data << uint8(playerBytes2 & 0xFF); // facial hair + uint8 facialHair = fields[9].GetUInt8(); + *p_data << uint8(facialHair); // facial hair - *p_data << uint8(fields[7].GetUInt8()); // level - *p_data << uint32(fields[8].GetUInt32()); // zone - *p_data << uint32(fields[9].GetUInt32()); // map + *p_data << uint8(fields[10].GetUInt8()); // level + *p_data << uint32(fields[11].GetUInt32()); // zone + *p_data << uint32(fields[12].GetUInt32()); // map - *p_data << fields[10].GetFloat(); // x - *p_data << fields[11].GetFloat(); // y - *p_data << fields[12].GetFloat(); // z + *p_data << fields[13].GetFloat(); // x + *p_data << fields[14].GetFloat(); // y + *p_data << fields[15].GetFloat(); // z - *p_data << uint32(fields[13].GetUInt32()); // guild id + *p_data << uint32(fields[16].GetUInt32()); // guild id uint32 char_flags = 0; - uint32 playerFlags = fields[14].GetUInt32(); - uint32 atLoginFlags = fields[15].GetUInt32(); + uint32 playerFlags = fields[17].GetUInt32(); + uint32 atLoginFlags = fields[18].GetUInt32(); if (playerFlags & PLAYER_FLAGS_HIDE_HELM) char_flags |= CHARACTER_FLAG_HIDE_HELM; if (playerFlags & PLAYER_FLAGS_HIDE_CLOAK) @@ -2020,12 +2022,12 @@ bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data) // show pet at selection character in character list only for non-ghost character if (result && !(playerFlags & PLAYER_FLAGS_GHOST) && (pClass == CLASS_WARLOCK || pClass == CLASS_HUNTER)) { - uint32 entry = fields[16].GetUInt32(); + uint32 entry = fields[19].GetUInt32(); CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(entry); if (cInfo) { - petDisplayId = fields[17].GetUInt32(); - petLevel = fields[18].GetUInt32(); + petDisplayId = fields[20].GetUInt32(); + petLevel = fields[21].GetUInt32(); petFamily = cInfo->pet_family; } } @@ -2036,7 +2038,7 @@ bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data) } - Tokens data = StrSplit(fields[19].GetCppString(), " "); + Tokens data = StrSplit(fields[22].GetCppString(), " "); for (uint8 slot = 0; slot < INVENTORY_SLOT_BAG_START + 1; slot++) { uint32 visualbase = slot * 2; // entry, perm ench., temp ench. @@ -3413,7 +3415,7 @@ void Player::GiveLevel(uint32 level) //update level, max level of skills if (GetLevel() != level) - m_Played_time[PLAYED_TIME_LEVEL] = 0; // Level Played Time reset + m_playedTime[PLAYED_TIME_LEVEL] = 0; // Level Played Time reset SetLevel(level); UpdateSkillsForLevel(); @@ -3709,19 +3711,19 @@ void Player::SendInitialSpells() const DETAIL_LOG("CHARACTER: Sent Initial Spells"); } -bool Player::AddSpell(uint32 spell_id, bool active, bool learning, bool dependent, bool disabled) +bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled) { - SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(spell_id); + SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(spellId); if (!spellInfo) { // do character spell book cleanup (all characters) if (!IsInWorld() && !learning) // spell load case { - sLog.outError("Player::AddSpell: nonexistent in SpellStore spell #%u request, deleting for all characters in `character_spell`.", spell_id); - CharacterDatabase.PExecute("DELETE FROM `character_spell` WHERE `spell` = '%u'", spell_id); + sLog.outError("Player::AddSpell: nonexistent in SpellStore spell #%u request, deleting for all characters in `character_spell`.", spellId); + CharacterDatabase.PExecute("DELETE FROM `character_spell` WHERE `spell` = '%u'", spellId); } else - sLog.outError("Player::AddSpell: nonexistent in SpellStore spell #%u request.", spell_id); + sLog.outError("Player::AddSpell: nonexistent in SpellStore spell #%u request.", spellId); return false; } @@ -3731,11 +3733,11 @@ bool Player::AddSpell(uint32 spell_id, bool active, bool learning, bool dependen // do character spell book cleanup (all characters) if (!IsInWorld() && !learning) // spell load case { - sLog.outError("Player::AddSpell: Broken spell #%u learning not allowed, deleting for all characters in `character_spell`.", spell_id); - CharacterDatabase.PExecute("DELETE FROM `character_spell` WHERE `spell` = '%u'", spell_id); + sLog.outError("Player::AddSpell: Broken spell #%u learning not allowed, deleting for all characters in `character_spell`.", spellId); + CharacterDatabase.PExecute("DELETE FROM `character_spell` WHERE `spell` = '%u'", spellId); } else - sLog.outError("Player::AddSpell: Broken spell #%u learning not allowed.", spell_id); + sLog.outError("Player::AddSpell: Broken spell #%u learning not allowed.", spellId); return false; } @@ -3745,7 +3747,7 @@ bool Player::AddSpell(uint32 spell_id, bool active, bool learning, bool dependen bool disabled_case = false; bool superceded_old = false; - PlayerSpellMap::iterator itr = m_spells.find(spell_id); + PlayerSpellMap::iterator itr = m_spells.find(spellId); if (itr != m_spells.end()) { uint32 next_active_spell_id = 0; @@ -3794,7 +3796,7 @@ bool Player::AddSpell(uint32 spell_id, bool active, bool learning, bool dependen if (active) { if (IsNeedCastPassiveLikeSpellAtLearn(spellInfo)) - CastSpell(this, spell_id, true); + CastSpell(this, spellId, true); } else if (IsInWorld()) { @@ -3802,12 +3804,12 @@ bool Player::AddSpell(uint32 spell_id, bool active, bool learning, bool dependen { // update spell ranks in spellbook and action bar WorldPacket data(SMSG_SUPERCEDED_SPELL, (4)); - data << uint16(spell_id); + data << uint16(spellId); data << uint16(next_active_spell_id); GetSession()->SendPacket(&data); } else - SendSpellRemoved(spell_id); + SendSpellRemoved(spellId); } return active; // learn (show in spell book if active now) @@ -3845,7 +3847,7 @@ bool Player::AddSpell(uint32 spell_id, bool active, bool learning, bool dependen } } - TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id); + TalentSpellPos const* talentPos = GetTalentSpellPos(spellId); if (!disabled_case) // skip new spell adding if spell already known (disabled spells case) { @@ -3857,7 +3859,7 @@ bool Player::AddSpell(uint32 spell_id, bool active, bool learning, bool dependen for (uint32 rankSpellId : talentInfo->RankID) { // skip learning spell and no rank spell case - if (!rankSpellId || rankSpellId == spell_id) + if (!rankSpellId || rankSpellId == spellId) continue; RemoveSpell(rankSpellId, false, false); @@ -3865,7 +3867,7 @@ bool Player::AddSpell(uint32 spell_id, bool active, bool learning, bool dependen } } // non talent spell: learn low ranks (recursive call) - else if (uint32 prev_spell = sSpellMgr.GetPrevSpellInChain(spell_id)) + else if (uint32 prev_spell = sSpellMgr.GetPrevSpellInChain(spellId)) { if (!IsInWorld() || disabled) // at spells loading, no output, but allow save AddSpell(prev_spell, active, true, true, disabled); @@ -3893,13 +3895,13 @@ bool Player::AddSpell(uint32 spell_id, bool active, bool learning, bool dependen { if (playerSpell2.active) { - if (nextId == spell_id) + if (nextId == spellId) { if (IsInWorld()) // not send spell (re-/over-)learn packets at loading { WorldPacket data(SMSG_SUPERCEDED_SPELL, (4)); data << uint16(m_spell.first); - data << uint16(spell_id); + data << uint16(spellId); GetSession()->SendPacket(&data); } @@ -3909,12 +3911,12 @@ bool Player::AddSpell(uint32 spell_id, bool active, bool learning, bool dependen playerSpell2.state = PLAYERSPELL_CHANGED; superceded_old = true; // new spell replace old in action bars and spell book. } - else if (m_spell.first == spell_id) + else if (m_spell.first == spellId) { if (IsInWorld()) // not send spell (re-/over-)learn packets at loading { WorldPacket data(SMSG_SUPERCEDED_SPELL, (4)); - data << uint16(spell_id); + data << uint16(spellId); data << uint16(m_spell.first); GetSession()->SendPacket(&data); } @@ -3931,7 +3933,7 @@ bool Player::AddSpell(uint32 spell_id, bool active, bool learning, bool dependen } } - m_spells[spell_id] = newspell; + m_spells[spellId] = newspell; // return false if spell disabled if (newspell.disabled) @@ -3948,7 +3950,7 @@ bool Player::AddSpell(uint32 spell_id, bool active, bool learning, bool dependen // update free primary prof.points (if any, can be none in case GM .learn prof. learning) if (uint32 freeProfs = GetFreePrimaryProfessionPoints()) { - if (sSpellMgr.IsPrimaryProfessionFirstRankSpell(spell_id)) + if (sSpellMgr.IsPrimaryProfessionFirstRankSpell(spellId)) SetFreePrimaryProfessions(freeProfs - 1); } @@ -3957,22 +3959,22 @@ bool Player::AddSpell(uint32 spell_id, bool active, bool learning, bool dependen if (talentPos && spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL)) { // ignore stance requirement for talent learn spell (stance set for spell only for client spell description show) - CastSpell(this, spell_id, true); + CastSpell(this, spellId, true); } // also cast passive (and passive like) spells (including all talents without SPELL_EFFECT_LEARN_SPELL) with additional checks else if (IsNeedCastPassiveLikeSpellAtLearn(spellInfo)) - CastSpell(this, spell_id, true); + CastSpell(this, spellId, true); else if (spellInfo->HasEffect(SPELL_EFFECT_SKILL_STEP)) { - CastSpell(this, spell_id, true); + CastSpell(this, spellId, true); return false; } // add dependent skills - UpdateSpellTrainedSkills(spell_id, true); + UpdateSpellTrainedSkills(spellId, true); // learn dependent spells - SpellLearnSpellMapBounds spell_bounds = sSpellMgr.GetSpellLearnSpellMapBounds(spell_id); + SpellLearnSpellMapBounds spell_bounds = sSpellMgr.GetSpellLearnSpellMapBounds(spellId); for (SpellLearnSpellMap::const_iterator itr2 = spell_bounds.first; itr2 != spell_bounds.second; ++itr2) { @@ -4007,20 +4009,20 @@ bool Player::IsNeedCastPassiveLikeSpellAtLearn(SpellEntry const* spellInfo) cons return need_cast && (!spellInfo->CasterAuraState || HasAuraState(AuraState(spellInfo->CasterAuraState))); } -void Player::LearnSpell(uint32 spell_id, bool dependent, bool talent) +void Player::LearnSpell(uint32 spellId, bool dependent, bool talent) { - PlayerSpellMap::iterator itr = m_spells.find(spell_id); + PlayerSpellMap::iterator itr = m_spells.find(spellId); bool disabled = (itr != m_spells.end()) ? itr->second.disabled : false; bool active = disabled ? itr->second.active : true; - bool learning = AddSpell(spell_id, active, true, dependent, false); + bool learning = AddSpell(spellId, active, true, dependent, false); // prevent duplicated entires in spell book, also not send if not in world (loading) if (learning && IsInWorld()) { WorldPacket data(SMSG_LEARNED_SPELL, 4); - data << uint32(spell_id); + data << uint32(spellId); GetSession()->SendPacket(&data); } @@ -4028,7 +4030,7 @@ void Player::LearnSpell(uint32 spell_id, bool dependent, bool talent) if (disabled || talent) { SpellChainMapNext const& nextMap = sSpellMgr.GetSpellChainNext(); - for (SpellChainMapNext::const_iterator i = nextMap.lower_bound(spell_id); i != nextMap.upper_bound(spell_id); ++i) + for (SpellChainMapNext::const_iterator i = nextMap.lower_bound(spellId); i != nextMap.upper_bound(spellId); ++i) { PlayerSpellMap::iterator iter = m_spells.find(i->second); if (iter != m_spells.end() && iter->second.disabled) @@ -4037,19 +4039,19 @@ void Player::LearnSpell(uint32 spell_id, bool dependent, bool talent) } } -void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) +void Player::RemoveSpell(uint32 spellId, bool disabled, bool learn_low_rank) { - PlayerSpellMap::iterator itr = m_spells.find(spell_id); + PlayerSpellMap::iterator itr = m_spells.find(spellId); if (itr == m_spells.end()) return; // Always try to remove all dependent spells if present (needed to reset some talents properly) - SpellLearnSpellMapBounds spell_bounds = sSpellMgr.GetSpellLearnSpellMapBounds(spell_id); + SpellLearnSpellMapBounds spell_bounds = sSpellMgr.GetSpellLearnSpellMapBounds(spellId); for (SpellLearnSpellMap::const_iterator child_itr = spell_bounds.first; child_itr != spell_bounds.second; ++child_itr) RemoveSpell(child_itr->second.spell, !Spells::IsPassiveSpell(child_itr->second.spell), !Spells::IsPassiveSpell(child_itr->second.spell)); // search again just in case - itr = m_spells.find(spell_id); + itr = m_spells.find(spellId); if (itr == m_spells.end()) return; @@ -4057,17 +4059,17 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) if (playerSpell.state == PLAYERSPELL_REMOVED || (disabled && playerSpell.disabled)) return; - if (disabled && GetTalentSpellPos(spell_id)) + if (disabled && GetTalentSpellPos(spellId)) disabled = false; // talents should never be marked as disabled // unlearn non talent higher ranks (recursive) SpellChainMapNext const& nextMap = sSpellMgr.GetSpellChainNext(); - for (SpellChainMapNext::const_iterator itr2 = nextMap.lower_bound(spell_id); itr2 != nextMap.upper_bound(spell_id); ++itr2) + for (SpellChainMapNext::const_iterator itr2 = nextMap.lower_bound(spellId); itr2 != nextMap.upper_bound(spellId); ++itr2) if (HasSpell(itr2->second) && !GetTalentSpellPos(itr2->second)) RemoveSpell(itr2->second, !Spells::IsPassiveSpell(itr2->second), false); // re-search, it can be corrupted in prev loop - itr = m_spells.find(spell_id); + itr = m_spells.find(spellId); if (itr == m_spells.end() || playerSpell.state == PLAYERSPELL_REMOVED) return; @@ -4088,13 +4090,13 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) itr->second.state = PLAYERSPELL_REMOVED; } - RemoveAurasDueToSpell(spell_id); + RemoveAurasDueToSpell(spellId); // remove pet auras - if (PetAura const* petSpell = sSpellMgr.GetPetAura(spell_id)) + if (PetAura const* petSpell = sSpellMgr.GetPetAura(spellId)) RemovePetAura(petSpell); - TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id); + TalentSpellPos const* talentPos = GetTalentSpellPos(spellId); if (talentPos) { // free talent points @@ -4109,7 +4111,7 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) } // update free primary prof.points (if not overflow setting, can be in case GM use before .learn prof. learning) - if (sSpellMgr.IsPrimaryProfessionFirstRankSpell(spell_id)) + if (sSpellMgr.IsPrimaryProfessionFirstRankSpell(spellId)) { uint32 freeProfs = GetFreePrimaryProfessionPoints() + 1; if (freeProfs <= sWorld.getConfig(CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL)) @@ -4117,12 +4119,12 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) } // remove dependent skills - UpdateSpellTrainedSkills(spell_id, false); + UpdateSpellTrainedSkills(spellId, false); // activate lesser rank in spellbook/action bar, and cast it if need bool prev_activate = false; - if (uint32 prev_id = sSpellMgr.GetPrevSpellInChain(spell_id)) + if (uint32 prev_id = sSpellMgr.GetPrevSpellInChain(spellId)) { uint32 nextId = sSpellMgr.GetSpellBookSuccessorSpellId(prev_id); @@ -4133,7 +4135,7 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) LearnSpell(prev_id, false); } // if ranked non-stackable spell: need activate lesser rank and update dependence state - else if (cur_active && nextId == spell_id) + else if (cur_active && nextId == spellId) { // need manually update dependence state (learn spell ignore like attempts) PlayerSpellMap::iterator prev_itr = m_spells.find(prev_id); @@ -4154,7 +4156,7 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) { // downgrade spell ranks in spellbook and action bar WorldPacket data(SMSG_SUPERCEDED_SPELL, 4); - data << uint16(spell_id); + data << uint16(spellId); data << uint16(prev_id); GetSession()->SendPacket(&data); prev_activate = true; @@ -4166,13 +4168,13 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) // remove from spell book if not replaced by lesser rank if (!prev_activate) - SendSpellRemoved(spell_id); + SendSpellRemoved(spellId); } void Player::_LoadSpellCooldowns(QueryResult* result) { // some cooldowns can be already set at aura loading... - // QueryResult *result = CharacterDatabase.PQuery("SELECT SpellId, SpellExpireTime, Category, CategoryExpireTime, ItemId FROM character_spell_cooldown WHERE guid = '%u'",GetGUIDLow()); + // QueryResult *result = CharacterDatabase.PQuery("SELECT `spell`, `spell_expire_time`, `category`, `category_expire_time`, `item_id` FROM `character_spell_cooldown` WHERE `guid` = '%u'",GetGUIDLow()); if (result) { @@ -4182,32 +4184,32 @@ void Player::_LoadSpellCooldowns(QueryResult* result) { Field* fields = result->Fetch(); - uint32 spell_id = fields[0].GetUInt32(); - uint64 spell_time = fields[1].GetUInt64(); + uint32 spellId = fields[0].GetUInt32(); + uint64 spellTime = fields[1].GetUInt64(); uint32 category = fields[2].GetUInt32(); - uint64 cat_time = fields[3].GetUInt64(); - uint32 item_id = fields[4].GetUInt32(); + uint64 categoryTime = fields[3].GetUInt64(); + uint32 itemId = fields[4].GetUInt32(); - SpellEntry const* spellEntry = sSpellMgr.GetSpellEntry(spell_id); + SpellEntry const* spellEntry = sSpellMgr.GetSpellEntry(spellId); if (!spellEntry) { - sLog.outError("%s has unknown spell %u in `character_spell_cooldown`, skipping.", GetGuidStr().c_str(), spell_id); + sLog.outError("%s has unknown spell %u in `character_spell_cooldown`, skipping.", GetGuidStr().c_str(), spellId); continue; } ItemPrototype const* itemProto = nullptr; - if (item_id) + if (itemId) { - itemProto = ObjectMgr::GetItemPrototype(item_id); + itemProto = ObjectMgr::GetItemPrototype(itemId); if (!itemProto) { - sLog.outError("%s has unknown item ID %u in `character_spell_cooldown`, skipping.", GetGuidStr().c_str(), item_id); + sLog.outError("%s has unknown item ID %u in `character_spell_cooldown`, skipping.", GetGuidStr().c_str(), itemId); continue; } } - TimePoint spellExpireTime = std::chrono::time_point_cast(Clock::from_time_t(spell_time)); - TimePoint catExpireTime = std::chrono::time_point_cast(Clock::from_time_t(cat_time)); + TimePoint spellExpireTime = std::chrono::time_point_cast(Clock::from_time_t(spellTime)); + TimePoint catExpireTime = std::chrono::time_point_cast(Clock::from_time_t(categoryTime)); std::chrono::milliseconds spellRecTime = std::chrono::milliseconds::zero(); std::chrono::milliseconds catRecTime = std::chrono::milliseconds::zero(); if (spellExpireTime > curTime) @@ -4219,15 +4221,15 @@ void Player::_LoadSpellCooldowns(QueryResult* result) if (spellRecTime == std::chrono::milliseconds::zero() && catRecTime == std::chrono::milliseconds::zero()) continue; - m_cooldownMap.AddCooldown(curTime, spell_id, uint32(spellRecTime.count()), category, uint32(catRecTime.count()), item_id); + m_cooldownMap.AddCooldown(curTime, spellId, uint32(spellRecTime.count()), category, uint32(catRecTime.count()), itemId); #ifdef _DEBUG uint32 spellCDDuration = std::chrono::duration_cast(spellRecTime).count(); uint32 catCDDuration = std::chrono::duration_cast(catRecTime).count(); std::string itemStr = ""; - if (item_id) - itemStr = " caused by item id(" + std::to_string(item_id) + ") "; + if (itemId) + itemStr = " caused by item id(" + std::to_string(itemId) + ") "; sLog.outDebug("Adding spell cooldown to %s, SpellID(%u), recDuration(%us), category(%u), catRecDuration(%us)%s.", GetGuidStr().c_str(), - spell_id, spellCDDuration, category, catCDDuration, itemStr.c_str()); + spellId, spellCDDuration, category, catCDDuration, itemStr.c_str()); #endif } while (result->NextRow()); @@ -4239,7 +4241,7 @@ void Player::_SaveSpellCooldowns() static SqlStatementID deleteSpellCooldown; // delete all old cooldown - SqlStatement stmt = CharacterDatabase.CreateStatement(deleteSpellCooldown, "DELETE FROM character_spell_cooldown WHERE guid = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(deleteSpellCooldown, "DELETE FROM `character_spell_cooldown` WHERE `guid` = ?"); stmt.PExecute(GetGUIDLow()); static SqlStatementID insertSpellCooldown; @@ -4256,7 +4258,7 @@ void Player::_SaveSpellCooldowns() uint64 spellExpireTime = uint64(Clock::to_time_t(sTime)); uint64 catExpireTime = uint64(Clock::to_time_t(cTime)); - stmt = CharacterDatabase.CreateStatement(insertSpellCooldown, "INSERT INTO `character_spell_cooldown` (`guid`, `SpellId`, `SpellExpireTime`, `Category`, `CategoryExpireTime`, `ItemId`) VALUES( ?, ?, ?, ?, ?, ?)"); + stmt = CharacterDatabase.CreateStatement(insertSpellCooldown, "INSERT INTO `character_spell_cooldown` (`guid`, `spell`, `spell_expire_time`, `category`, `category_expire_time`, `item_id`) VALUES( ?, ?, ?, ?, ?, ?)"); stmt.addUInt32(GetGUIDLow()); stmt.addUInt32(cdData->GetSpellId()); stmt.addUInt64(spellExpireTime); @@ -4553,12 +4555,12 @@ TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell * * @see Player::DeleteOldCharacters * - * @param playerguid the low-GUID from the player which should be deleted + * @param playerGuid the low-GUID from the player which should be deleted * @param accountId the account id from the player * @param updateRealmChars when this flag is set, the amount of characters on that realm will be updated in the realmlist * @param deleteFinally if this flag is set, the config option will be ignored and the character will be permanently removed from the database */ -void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars, bool deleteFinally) +void Player::DeleteFromDB(ObjectGuid playerGuid, uint32 accountId, bool updateRealmChars, bool deleteFinally) { // for nonexistent account avoid update realm if (accountId == 0) @@ -4572,21 +4574,21 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe charDelete_method = 0; else { - PlayerCacheData const* data = sObjectMgr.GetPlayerDataByGUID(playerguid); + PlayerCacheData const* data = sObjectMgr.GetPlayerDataByGUID(playerGuid); if (data && data->uiLevel < charDelete_minLvl) charDelete_method = 0; } - uint32 lowguid = playerguid.GetCounter(); + uint32 lowguid = playerGuid.GetCounter(); // convert corpse to bones if exist (to prevent exiting Corpse in World without DB entry) // bones will be deleted by corpse/bones deleting thread shortly - sObjectAccessor.ConvertCorpseForPlayer(playerguid); + sObjectAccessor.ConvertCorpseForPlayer(playerGuid); // remove from guild - if (Guild* guild = sGuildMgr.GetPlayerGuild(playerguid)) + if (Guild* guild = sGuildMgr.GetPlayerGuild(playerGuid)) { - if (guild->DelMember(playerguid)) + if (guild->DelMember(playerGuid)) { guild->Disband(); delete guild; @@ -4594,11 +4596,11 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe } // the player was uninvited already on logout so just remove from group - if (Group* group = sObjectMgr.GetGroupByMember(playerguid)) - RemoveFromGroup(group, playerguid); + if (Group* group = sObjectMgr.GetGroupByMember(playerGuid)) + RemoveFromGroup(group, playerGuid); // remove signs from petitions (also remove petitions if owner); - RemovePetitionsAndSigns(playerguid); + RemovePetitionsAndSigns(playerGuid); sObjectMgr.DeletePlayerFromCache(lowguid); switch (charDelete_method) @@ -4606,8 +4608,8 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe // completely remove from the database case 0: { - // return back all mails with COD and Item 0 1 2 3 4 5 6 7 - QueryResult* resultMail = CharacterDatabase.PQuery("SELECT `id`, `messageType`, `mailTemplateId`, `sender`, `subject`, `itemTextId`, `money`, `has_items` FROM `mail` WHERE `receiver`='%u' AND `has_items`<>0 AND `cod`<>0", lowguid); + // return back all mails with COD and Item 0 1 2 3 4 5 6 7 + QueryResult* resultMail = CharacterDatabase.PQuery("SELECT `id`, `message_type`, `mail_template_id`, `sender_guid`, `subject`, `item_text_id`, `money`, `has_items` FROM `mail` WHERE `receiver_guid`='%u' AND `has_items`<>0 AND `cod`<>0", lowguid); if (resultMail) { do @@ -4643,26 +4645,26 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe if (has_items) { - // data needs to be at first place for Item::LoadFromDB - QueryResult* resultItems = CharacterDatabase.PQuery("SELECT `creatorGuid`, `giftCreatorGuid`, `count`, `duration`, `charges`, `flags`, `enchantments`, `randomPropertyId`, `durability`, `text`, `item_guid`, `itemEntry`, `generated_loot` FROM `mail_items` JOIN `item_instance` ON `item_guid` = `guid` WHERE `mail_id`='%u'", mail_id); + // data needs to be at first place for Item::LoadFromDB 0 1 2 3 5 6 7 8 9 10 11 12 + QueryResult* resultItems = CharacterDatabase.PQuery("SELECT `creator_guid`, `gift_creator_guid`, `count`, `duration`, `charges`, `flags`, `enchantments`, `random_property_id`, `durability`, `text`, `item_guid`, `item_instance`.`item_id`, `generated_loot` FROM `mail_items` JOIN `item_instance` ON `item_guid` = `guid` WHERE `mail_id`='%u'", mail_id); if (resultItems) { do { Field* fields2 = resultItems->Fetch(); - uint32 item_guidlow = fields2[10].GetUInt32(); - uint32 item_template = fields2[11].GetUInt32(); + uint32 itemGuidLow = fields2[10].GetUInt32(); + uint32 itemId = fields2[11].GetUInt32(); - ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(item_template); + ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemId); if (!itemProto) { - CharacterDatabase.PExecute("DELETE FROM `item_instance` WHERE `guid` = '%u'", item_guidlow); + CharacterDatabase.PExecute("DELETE FROM `item_instance` WHERE `guid` = '%u'", itemGuidLow); continue; } Item* pItem = NewItemOrBag(itemProto); - if (!pItem->LoadFromDB(item_guidlow, playerguid, fields2, item_template)) + if (!pItem->LoadFromDB(itemGuidLow, playerGuid, fields2, itemId)) { pItem->FSetState(ITEM_REMOVED); pItem->SaveToDB(); // it also deletes item object ! @@ -4679,9 +4681,9 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe CharacterDatabase.PExecute("DELETE FROM `mail_items` WHERE `mail_id` = '%u'", mail_id); - uint32 pl_account = sObjectMgr.GetPlayerAccountIdByGUID(playerguid); + uint32 pl_account = sObjectMgr.GetPlayerAccountIdByGUID(playerGuid); - draft.SetMoney(money).SendReturnToSender(pl_account, playerguid, ObjectGuid(HIGHGUID_PLAYER, sender)); + draft.SetMoney(money).SendReturnToSender(pl_account, playerGuid, ObjectGuid(HIGHGUID_PLAYER, sender)); } while (resultMail->NextRow()); @@ -4690,7 +4692,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe // unsummon and delete for pets in world is not required: player deleted from CLI or character list with not loaded pet. // Get guids of character's pets, will deleted in transaction - QueryResult* resultPets = CharacterDatabase.PQuery("SELECT `id` FROM `character_pet` WHERE `owner` = '%u'", lowguid); + QueryResult* resultPets = CharacterDatabase.PQuery("SELECT `id` FROM `character_pet` WHERE `owner_guid` = '%u'", lowguid); // NOW we can finally clear other DB data related to character CharacterDatabase.BeginTransaction(); @@ -4715,7 +4717,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe CharacterDatabase.PExecute("DELETE FROM `character_gifts` WHERE `guid` = '%u'", lowguid); CharacterDatabase.PExecute("DELETE FROM `character_homebind` WHERE `guid` = '%u'", lowguid); CharacterDatabase.PExecute("DELETE FROM `character_instance` WHERE `guid` = '%u'", lowguid); - CharacterDatabase.PExecute("DELETE FROM `group_instance` WHERE `leaderGuid` = '%u'", lowguid); + CharacterDatabase.PExecute("DELETE FROM `group_instance` WHERE `leader_guid` = '%u'", lowguid); CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `guid` = '%u'", lowguid); CharacterDatabase.PExecute("DELETE FROM `character_queststatus` WHERE `guid` = '%u'", lowguid); CharacterDatabase.PExecute("DELETE FROM `character_reputation` WHERE `guid` = '%u'", lowguid); @@ -4723,19 +4725,18 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe CharacterDatabase.PExecute("DELETE FROM `character_forgotten_skills` WHERE `guid` = '%u'", lowguid); CharacterDatabase.PExecute("DELETE FROM `character_spell` WHERE `guid` = '%u'", lowguid); CharacterDatabase.PExecute("DELETE FROM `character_spell_cooldown` WHERE `guid` = '%u'", lowguid); - CharacterDatabase.PExecute("DELETE FROM `character_ticket` WHERE `guid` = '%u'", lowguid); CharacterDatabase.PExecute("DELETE FROM `item_instance` WHERE `owner_guid` = '%u'", lowguid); CharacterDatabase.PExecute("DELETE FROM `character_social` WHERE `guid` = '%u' OR `friend`='%u'", lowguid, lowguid); - CharacterDatabase.PExecute("DELETE FROM `mail` WHERE `receiver` = '%u'", lowguid); - CharacterDatabase.PExecute("DELETE FROM `mail_items` WHERE `receiver` = '%u'", lowguid); - CharacterDatabase.PExecute("DELETE FROM `character_pet` WHERE `owner` = '%u'", lowguid); - CharacterDatabase.PExecute("DELETE FROM `guild_eventlog` WHERE `PlayerGuid1` = '%u' OR `PlayerGuid2` = '%u'", lowguid, lowguid); + CharacterDatabase.PExecute("DELETE FROM `mail` WHERE `receiver_guid` = '%u'", lowguid); + CharacterDatabase.PExecute("DELETE FROM `mail_items` WHERE `receiver_guid` = '%u'", lowguid); + CharacterDatabase.PExecute("DELETE FROM `character_pet` WHERE `owner_guid` = '%u'", lowguid); + CharacterDatabase.PExecute("DELETE FROM `guild_eventlog` WHERE `player_guid1` = '%u' OR `player_guid2` = '%u'", lowguid, lowguid); CharacterDatabase.CommitTransaction(); break; } // The character gets unlinked from the account, the name gets freed up and appears as deleted ingame case 1: - CharacterDatabase.PExecute("UPDATE `characters` SET `deleteInfos_Name`=`name`, `deleteInfos_Account`=`account`, `deleteDate`='" UI64FMTD "', `name`='', `account`=0 WHERE `guid`=%u", uint64(time(nullptr)), lowguid); + CharacterDatabase.PExecute("UPDATE `characters` SET `deleted_name`=`name`, `deleted_account`=`account`, `deleted_time`='" UI64FMTD "', `name`='', `account`=0 WHERE `guid`=%u", uint64(time(nullptr)), lowguid); break; default: sLog.outError("Player::DeleteFromDB: Unsupported delete method: %u.", charDelete_method); @@ -4768,7 +4769,7 @@ void Player::DeleteOldCharacters() */ void Player::DeleteOldCharacters(uint32 keepDays) { - QueryResult* resultChars = CharacterDatabase.PQuery("SELECT `guid`, `deleteInfos_Account` FROM `characters` WHERE `deleteDate` IS NOT NULL AND `deleteDate` < '" UI64FMTD "' LIMIT 0,2", uint64(time(nullptr) - time_t(keepDays * DAY))); + QueryResult* resultChars = CharacterDatabase.PQuery("SELECT `guid`, `deleted_account` FROM `characters` WHERE `deleted_time` IS NOT NULL AND `deleted_time` < '" UI64FMTD "' LIMIT 0,2", uint64(time(nullptr) - time_t(keepDays * DAY))); if (resultChars) { do @@ -6728,7 +6729,7 @@ uint32 Player::GetGuildIdFromDB(ObjectGuid guid) { uint32 lowguid = guid.GetCounter(); - QueryResult* result = CharacterDatabase.PQuery("SELECT `guildid` FROM `guild_member` WHERE `guid`='%u'", lowguid); + QueryResult* result = CharacterDatabase.PQuery("SELECT `guild_id` FROM `guild_member` WHERE `guid`='%u'", lowguid); if (!result) return 0; @@ -7405,7 +7406,7 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply if (form_change) // check aura active state from other form { bool found = false; - for (int k = 0; k < MAX_EFFECT_INDEX; ++k) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellInfo->Id); for (SpellAuraHolderMap::const_iterator iter = spair.first; iter != spair.second; ++iter) @@ -11642,7 +11643,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem, uint32 money, ObjectGuid vendorGu m_items[slot] = pItem; time_t base = time(nullptr); - uint32 etime = uint32(base - m_logintime + (30 * 3600)); + uint32 etime = uint32(base - m_loginTime + (30 * 3600)); uint32 eslot = slot - BUYBACK_SLOT_START; SetGuidValue(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), pItem->GetObjectGuid()); @@ -13100,10 +13101,10 @@ void Player::FullQuestComplete(uint32 questId) int32 creature = pQuest->ReqCreatureOrGOId[i]; uint32 creaturecount = pQuest->ReqCreatureOrGOCount[i]; - if (uint32 spell_id = pQuest->ReqSpell[i]) + if (uint32 spellId = pQuest->ReqSpell[i]) { for (uint16 z = 0; z < creaturecount; ++z) - CastedCreatureOrGO(creature, ObjectGuid(), spell_id); + CastedCreatureOrGO(creature, ObjectGuid(), spellId); } else if (creature > 0) { @@ -14153,7 +14154,7 @@ void Player::KilledMonsterCredit(uint32 entry, ObjectGuid guid) } } -void Player::CastedCreatureOrGO(uint32 entry, ObjectGuid guid, uint32 spell_id, bool original_caster) +void Player::CastedCreatureOrGO(uint32 entry, ObjectGuid guid, uint32 spellId, bool originalCaster) { bool isCreature = guid.IsCreature(); @@ -14168,7 +14169,7 @@ void Player::CastedCreatureOrGO(uint32 entry, ObjectGuid guid, uint32 spell_id, if (!qInfo) continue; - if (!original_caster && !qInfo->HasQuestFlag(QUEST_FLAGS_SHARABLE)) + if (!originalCaster && !qInfo->HasQuestFlag(QUEST_FLAGS_SHARABLE)) continue; if (!qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAG_KILL_OR_CAST)) @@ -14182,7 +14183,7 @@ void Player::CastedCreatureOrGO(uint32 entry, ObjectGuid guid, uint32 spell_id, for (int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) { // skip kill creature objective (0) or wrong spell casts - if (qInfo->ReqSpell[j] != spell_id) + if (qInfo->ReqSpell[j] != spellId) continue; uint32 reqTarget = 0; @@ -14625,7 +14626,7 @@ bool Player::LoadPositionFromDB(ObjectGuid guid, uint32& mapid, float& x, float& } else { - QueryResult* result = CharacterDatabase.PQuery("SELECT `position_x`, `position_y`, `position_z`, `orientation`, `map`, `taxi_path` FROM `characters` WHERE `guid` = '%u'", guid.GetCounter()); + QueryResult* result = CharacterDatabase.PQuery("SELECT `position_x`, `position_y`, `position_z`, `orientation`, `map`, `current_taxi_path` FROM `characters` WHERE `guid` = '%u'", guid.GetCounter()); if (!result) return false; @@ -14661,18 +14662,18 @@ void Player::_LoadIntoDataField(char const* data, uint32 startOffset, uint32 cou bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) { - // 0 1 2 3 4 5 6 7 8 9 10 11 - //SELECT guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, - // 12 13 14 15 16 17 18 19 20 21 22 23 24 - //"position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_multiplier," - // 25 26 27 28 29 30 31 32 33 34 35 36 37 - //"resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, - // 38 39 40 41 42 43 44 - //"honorRankPoints, honorRighestRank, honorStanding, honorLastWeekHK, honorLastWeekCP, honorStoredHK, honorStoredDK," - // 45 46 47 48 49 50 51 52 53 54 55 56 - //"watchedFaction, drunk, health, power1, power2, power3, power4, power5, exploredZones, equipmentCache, ammoId, actionBars," - // 57 - //"world_phase_mask FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid)); + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + //SELECT guid, account, name, race, class, gender, level, xp, money, skin, face, hair_style, hair_color, facial_hair, bank_bag_slots, player_flags, + // 16 17 18 19 20 21 22 23 24 25 26 27 + //"position_x, position_y, position_z, map, orientation, known_taxi_mask, played_time_total, played_time_level, rest_bonus, logout_time, is_logout_resting, reset_talents_multiplier," + // 28 29 30 31 32 33 34 35 36 37 38 39 40 + //"reset_talents_time, transport_guid, transport_x, transport_y, transport_z, transport_o, extra_flags, stable_slots, at_login_flags, zone, online, death_expire_time, current_taxi_path, + // 41 42 43 44 45 46 47 + //"honor_rank_points, honor_highest_rank, honor_standing, honor_last_week_hk, honor_last_week_cp, honor_stored_hk, honor_stored_dk," + // 48 49 50 51 52 53 54 55 56 57 58 59 + //"watched_faction, drunk, health, power1, power2, power3, power4, power5, explored_zones, equipment_cache, ammo_id, action_bars," + // 60 61 + //"world_phase_mask, create_time FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid)); QueryResult* result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM); @@ -14703,7 +14704,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) if (ObjectMgr::CheckPlayerName(m_name) != CHAR_NAME_SUCCESS || (GetSession()->GetSecurity() == SEC_PLAYER && sObjectMgr.IsReservedName(m_name))) { - CharacterDatabase.PExecute("UPDATE `characters` SET `at_login` = `at_login` | '%u' WHERE `guid` ='%u'", + CharacterDatabase.PExecute("UPDATE `characters` SET `at_login_flags` = `at_login_flags` | '%u' WHERE `guid` ='%u'", uint32(AT_LOGIN_RENAME), guid.GetCounter()); return false; } @@ -14712,7 +14713,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) SetGuidValue(OBJECT_FIELD_GUID, guid); // Phasing - SetWorldMask(fields[57].GetUInt32()); + SetWorldMask(fields[60].GetUInt32()); // overwrite some data fields SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE, fields[3].GetUInt8()); // race @@ -14726,7 +14727,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) SetUInt32Value(UNIT_FIELD_LEVEL, fields[6].GetUInt8()); SetUInt32Value(PLAYER_XP, fields[7].GetUInt32()); - _LoadIntoDataField(fields[53].GetString(), PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE); + _LoadIntoDataField(fields[56].GetString(), PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE); InitPlayerDisplayIds(); // model, scale and model data @@ -14735,14 +14736,18 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) money = MAX_MONEY_AMOUNT; SetMoney(money); - SetUInt32Value(PLAYER_BYTES, fields[9].GetUInt32()); - SetUInt32Value(PLAYER_BYTES_2, fields[10].GetUInt32()); + SetByteValue(PLAYER_BYTES, 0, fields[9].GetUInt8()); // skin + SetByteValue(PLAYER_BYTES, 1, fields[10].GetUInt8()); // face + SetByteValue(PLAYER_BYTES, 2, fields[11].GetUInt8()); // hair style + SetByteValue(PLAYER_BYTES, 3, fields[12].GetUInt8()); // hair color + SetByteValue(PLAYER_BYTES_2, 0, fields[13].GetUInt8()); // facial hair + SetBankBagSlotCount(fields[14].GetUInt8()); - m_drunk = fields[46].GetUInt16(); + m_drunk = fields[49].GetUInt16(); SetUInt16Value(PLAYER_BYTES_3, 0, (m_drunk & 0xFFFE) | gender); - SetUInt32Value(PLAYER_FLAGS, fields[11].GetUInt32()); + SetUInt32Value(PLAYER_FLAGS, fields[15].GetUInt32()); if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_DESIRED)) { @@ -14751,13 +14756,13 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) } #if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 - SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, fields[45].GetInt32()); + SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, fields[48].GetInt32()); #endif - SetUInt32Value(PLAYER_AMMO_ID, fields[55].GetUInt32()); + SetUInt32Value(PLAYER_AMMO_ID, fields[58].GetUInt32()); // Action bars state - SetByteValue(PLAYER_FIELD_BYTES, 2, fields[56].GetUInt8()); + SetByteValue(PLAYER_FIELD_BYTES, 2, fields[59].GetUInt8()); // cleanup inventory related item value fields (its will be filled correctly in _LoadInventory) for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) @@ -14787,9 +14792,9 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) InitPrimaryProfessions(); // to max set before any spell loaded // init saved position, and fix it later if problematic - uint32 transGUID = fields[30].GetUInt32(); + uint32 transGUID = fields[29].GetUInt32(); - if (!MaNGOS::IsValidMapCoord(fields[12].GetFloat(), fields[13].GetFloat(), fields[14].GetFloat(), fields[16].GetFloat())) + if (!MaNGOS::IsValidMapCoord(fields[16].GetFloat(), fields[17].GetFloat(), fields[18].GetFloat(), fields[20].GetFloat())) { sLog.outError("%s have invalid coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", guid.GetString().c_str(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); @@ -14801,19 +14806,19 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) } else { - Relocate(fields[12].GetFloat(), fields[13].GetFloat(), fields[14].GetFloat(), fields[16].GetFloat()); - SetLocationMapId(fields[15].GetUInt32()); + Relocate(fields[16].GetFloat(), fields[17].GetFloat(), fields[18].GetFloat(), fields[20].GetFloat()); + SetLocationMapId(fields[19].GetUInt32()); } _LoadGroup(holder->GetResult(PLAYER_LOGIN_QUERY_LOADGROUP)); - m_honorMgr.SetRankPoints(fields[38].GetFloat()); - m_honorMgr.SetHighestRank(fields[39].GetUInt32()); - m_honorMgr.SetStanding(fields[40].GetUInt32()); - m_honorMgr.SetLastWeekHK(fields[41].GetUInt32()); - m_honorMgr.SetLastWeekCP(fields[42].GetFloat()); - m_honorMgr.SetStoredHK(fields[43].GetUInt32()); - m_honorMgr.SetStoredDK(fields[44].GetUInt32()); + m_honorMgr.SetRankPoints(fields[41].GetFloat()); + m_honorMgr.SetHighestRank(fields[42].GetUInt32()); + m_honorMgr.SetStanding(fields[43].GetUInt32()); + m_honorMgr.SetLastWeekHK(fields[44].GetUInt32()); + m_honorMgr.SetLastWeekCP(fields[45].GetFloat()); + m_honorMgr.SetStoredHK(fields[46].GetUInt32()); + m_honorMgr.SetStoredDK(fields[47].GetUInt32()); m_honorMgr.Load(holder->GetResult(PLAYER_LOGIN_QUERY_LOADHONORCP)); _LoadBoundInstances(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES)); @@ -14854,7 +14859,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) if (GenericTransport* transport = GetMap()->GetTransport(guid)) { - float x = fields[26].GetFloat(), y = fields[27].GetFloat(), z = fields[28].GetFloat(), o = fields[29].GetFloat(); + float x = fields[30].GetFloat(), y = fields[31].GetFloat(), z = fields[32].GetFloat(), o = fields[33].GetFloat(); m_movementInfo.SetTransportData(guid, x, y, z, o, 0); transport->CalculatePassengerPosition(x, y, z, &o); @@ -14919,7 +14924,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) SaveRecallPosition(); time_t now = time(nullptr); - time_t logoutTime = time_t(fields[22].GetUInt64()); + time_t logoutTime = time_t(fields[25].GetUInt64()); // since last logout (in seconds) uint32 time_diff = uint32(now - logoutTime); @@ -14934,12 +14939,12 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) uint16 newDrunkenValue = uint16(soberFactor * m_drunk); SetDrunkValue(newDrunkenValue); - m_cinematic = fields[18].GetUInt32(); - m_Played_time[PLAYED_TIME_TOTAL] = fields[19].GetUInt32(); - m_Played_time[PLAYED_TIME_LEVEL] = fields[20].GetUInt32(); + m_playedTime[PLAYED_TIME_TOTAL] = fields[22].GetUInt32(); + m_playedTime[PLAYED_TIME_LEVEL] = fields[23].GetUInt32(); + m_createTime = fields[61].GetUInt64(); - m_resetTalentsMultiplier = fields[24].GetUInt32(); - m_resetTalentsTime = time_t(fields[25].GetUInt64()); + m_resetTalentsMultiplier = fields[27].GetUInt32(); + m_resetTalentsTime = time_t(fields[28].GetUInt64()); // reserve some flags uint32 old_safe_flags = GetUInt32Value(PLAYER_FLAGS) & (PLAYER_FLAGS_HIDE_CLOAK | PLAYER_FLAGS_HIDE_HELM); @@ -14947,24 +14952,24 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM)) SetUInt32Value(PLAYER_FLAGS, 0 | old_safe_flags); - m_taxi.LoadTaxiMask(fields[17].GetString()); + m_taxi.LoadTaxiMask(fields[21].GetString()); - uint32 extraflags = fields[31].GetUInt32(); + uint32 extraflags = fields[34].GetUInt32(); - m_stableSlots = fields[32].GetUInt32(); + m_stableSlots = fields[35].GetUInt32(); if (m_stableSlots > MAX_PET_STABLES) { sLog.outError("Player can have not more %u stable slots, but have in DB %u", MAX_PET_STABLES, uint32(m_stableSlots)); m_stableSlots = MAX_PET_STABLES; } - m_atLoginFlags = fields[33].GetUInt32(); + m_atLoginFlags = fields[36].GetUInt32(); - m_deathExpireTime = (time_t)fields[36].GetUInt64(); + m_deathExpireTime = (time_t)fields[39].GetUInt64(); if (m_deathExpireTime > now + MAX_DEATH_COUNT * DEATH_EXPIRE_STEP) m_deathExpireTime = now + MAX_DEATH_COUNT * DEATH_EXPIRE_STEP - 1; - std::string taxi_nodes = fields[37].GetCppString(); + std::string taxi_nodes = fields[40].GetCppString(); // clear channel spell data (if saved at channel spell casting) SetChannelObjectGuid(ObjectGuid()); @@ -15002,10 +15007,10 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_PET_LOYALTY, 0xEE); // rest bonus can only be calculated after InitStatsForLevel() - m_restBonus = fields[21].GetFloat(); + m_restBonus = fields[24].GetFloat(); if (time_diff > 0) - SetRestBonus(GetRestBonus() + ComputeRest(time_diff, true, (fields[23].GetInt32() > 0))); + SetRestBonus(GetRestBonus() + ComputeRest(time_diff, true, (fields[26].GetInt32() > 0))); // load skills after InitStatsForLevel because it triggering aura apply also _LoadSkills(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSKILLS)); @@ -15102,11 +15107,11 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) UpdateAllStats(); // restore remembered power/health values (but not more max values) - uint32 savedhealth = fields[47].GetUInt32(); + uint32 savedhealth = fields[50].GetUInt32(); SetHealth(savedhealth > GetMaxHealth() ? GetMaxHealth() : savedhealth); for (uint32 i = 0; i < MAX_POWERS; ++i) { - uint32 savedpower = fields[48 + i].GetUInt32(); + uint32 savedpower = fields[51 + i].GetUInt32(); SetPower(Powers(i), savedpower > GetMaxPower(Powers(i)) ? GetMaxPower(Powers(i)) : savedpower); } @@ -15356,7 +15361,7 @@ void Player::_LoadAuras(QueryResult* result, uint32 timediff) for (int i = UNIT_FIELD_AURA; i <= UNIT_FIELD_AURASTATE; ++i) SetUInt32Value(i, 0); - //QueryResult* result = CharacterDatabase.PQuery("SELECT caster_guid,item_guid,spell,stackcount,remaincharges,basepoints0,basepoints1,basepoints2,periodictime0,periodictime1,periodictime2,maxduration,remaintime,effIndexMask FROM character_aura WHERE guid = '%u'",GetGUIDLow()); + //QueryResult* result = CharacterDatabase.PQuery("SELECT caster_guid, item_guid, spell, stacks, charges, base_points0, base_points1, base_points2, periodic_time0, periodic_time1, periodic_time2, max_duration, duration, effect_index_mask FROM character_aura WHERE guid = '%u'",GetGUIDLow()); if (result) { @@ -15364,21 +15369,21 @@ void Player::_LoadAuras(QueryResult* result, uint32 timediff) { Field* fields = result->Fetch(); AuraSaveStruct s; - s.caster_guid = ObjectGuid(fields[0].GetUInt64()); - s.item_lowguid = fields[1].GetUInt32(); - s.spellid = fields[2].GetUInt32(); - s.stackcount = fields[3].GetUInt32(); - s.remaincharges = fields[4].GetUInt32(); + s.casterGuid = ObjectGuid(fields[0].GetUInt64()); + s.itemLowGuid = fields[1].GetUInt32(); + s.spellId = fields[2].GetUInt32(); + s.stacks = fields[3].GetUInt32(); + s.charges = fields[4].GetUInt32(); - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { - s.damage[i] = fields[i + 5].GetFloat(); + s.damage[i] = fields[i + 5].GetFloat(); s.periodicTime[i] = fields[i + 8].GetUInt32(); } - s.maxduration = fields[11].GetInt32(); - s.remaintime = fields[12].GetInt32(); - s.effIndexMask = fields[13].GetUInt32(); + s.maxDuration = fields[11].GetInt32(); + s.duration = fields[12].GetInt32(); + s.effIndexMask = fields[13].GetUInt8(); LoadAura(s, timediff); } @@ -15394,22 +15399,22 @@ void Player::_LoadAuras(QueryResult* result, uint32 timediff) void Player::LoadAura(AuraSaveStruct& s, uint32 timediff) { - SpellEntry const* spellproto = sSpellMgr.GetSpellEntry(s.spellid); + SpellEntry const* spellproto = sSpellMgr.GetSpellEntry(s.spellId); if (!spellproto) { - sLog.outError("Player::_LoadAuras: Unknown spell (spellid %u), ignore.", s.spellid); + sLog.outError("Player::_LoadAuras: Unknown spell (spellid %u), ignore.", s.spellId); return; } - if (s.remaintime != -1 && spellproto->HasRealTimeDuration()) + if (s.duration != -1 && spellproto->HasRealTimeDuration()) { if (timediff > (INT_MAX / IN_MILLISECONDS)) return; - if (s.remaintime <= int32(timediff) * IN_MILLISECONDS) + if (s.duration <= int32(timediff) * IN_MILLISECONDS) return; - s.remaintime -= timediff * IN_MILLISECONDS; + s.duration -= timediff * IN_MILLISECONDS; } // Special case for chat silenced indicator @@ -15419,24 +15424,24 @@ void Player::LoadAura(AuraSaveStruct& s, uint32 timediff) auto muteTime = GetSession()->m_muteTime; if (muteTime <= currTime) return; - s.remaintime = (muteTime - currTime) * IN_MILLISECONDS; + s.duration = (muteTime - currTime) * IN_MILLISECONDS; } // prevent wrong values of remaincharges if (spellproto->procCharges == 0) - s.remaincharges = 0; + s.charges = 0; if (!spellproto->StackAmount) - s.stackcount = 1; - else if (spellproto->StackAmount < s.stackcount) - s.stackcount = spellproto->StackAmount; - else if (!s.stackcount) - s.stackcount = 1; + s.stacks = 1; + else if (spellproto->StackAmount < s.stacks) + s.stacks = spellproto->StackAmount; + else if (!s.stacks) + s.stacks = 1; SpellAuraHolder* holder = CreateSpellAuraHolder(spellproto, this, nullptr, nullptr); - holder->SetLoadedState(s.caster_guid, ObjectGuid(HIGHGUID_ITEM, s.item_lowguid), s.stackcount, s.remaincharges, s.maxduration, s.remaintime); + holder->SetLoadedState(s.casterGuid, ObjectGuid(HIGHGUID_ITEM, s.itemLowGuid), s.stacks, s.charges, s.maxDuration, s.duration); - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if ((s.effIndexMask & (1 << i)) == 0 || !spellproto->EffectApplyAuraName[i]) continue; @@ -15452,7 +15457,7 @@ void Player::LoadAura(AuraSaveStruct& s, uint32 timediff) if (!holder->IsEmptyHolder()) { // reset stolen single target auras - if (s.caster_guid != GetObjectGuid() && holder->IsSingleTarget()) + if (s.casterGuid != GetObjectGuid() && holder->IsSingleTarget()) holder->SetIsSingleTarget(false); if (!AddSpellAuraHolder(holder)) @@ -15481,8 +15486,8 @@ void Player::LoadCorpse() bool Player::_LoadInventory(QueryResult* result, uint32 timediff, bool& hasEpicMount) { - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 - //SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, text, bag, slot, item, itemEntry, generated_loot + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 + //SELECT creator_guid, gift_creator_guid, count, duration, charges, flags, enchantments, random_property_id, durability, text, bag, slot, item_guid, item_id, generated_loot if (result) { @@ -15511,9 +15516,9 @@ bool Player::_LoadInventory(QueryResult* result, uint32 timediff, bool& hasEpicM if (!proto) { - CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item` = '%u'", item_lowguid); + CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item_guid` = '%u'", item_lowguid); CharacterDatabase.PExecute("DELETE FROM `item_instance` WHERE `guid` = '%u'", item_lowguid); - CharacterDatabase.PExecute("INSERT INTO `character_deleted_items` (`player_guid`, `item_entry`, `stack_count`) VALUES ('%u', '%u', '%u')", GetGUIDLow(), item_id, fields[2].GetUInt32()); + CharacterDatabase.PExecute("INSERT INTO `character_deleted_items` (`player_guid`, `item_id`, `stack_count`) VALUES ('%u', '%u', '%u')", GetGUIDLow(), item_id, fields[2].GetUInt32()); sLog.outError("Player::_LoadInventory: Player %s has an unknown item (id: #%u) in inventory, deleted.", GetName(), item_id); continue; } @@ -15528,7 +15533,7 @@ bool Player::_LoadInventory(QueryResult* result, uint32 timediff, bool& hasEpicM { std::stringstream oss; oss << "Duplicate item (via AH) " << item_id << " GUID:" << item_lowguid << ", count: " << item->GetCount() << ", bag: " << bag_guid << ", slot: " << uint32(slot); - CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item` = '%u'", item_lowguid); + CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item_guid` = '%u'", item_lowguid); GetSession()->ProcessAnticheatAction("PassiveAnticheat", oss.str().c_str(), CHEAT_ACTION_LOG | CHEAT_ACTION_REPORT_GMS); DETAIL_LOG(oss.str().c_str()); continue; @@ -15545,7 +15550,7 @@ bool Player::_LoadInventory(QueryResult* result, uint32 timediff, bool& hasEpicM if (!item->LoadFromDB(item_lowguid, GetObjectGuid(), fields, item_id)) { sLog.outError("Player::_LoadInventory: Player %s has broken item (id: #%u) in inventory, deleted.", GetName(), item_id); - CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item` = '%u'", item_lowguid); + CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item_guid` = '%u'", item_lowguid); item->FSetState(ITEM_REMOVED); item->SaveToDB(); // it also deletes item object ! continue; @@ -15563,7 +15568,7 @@ bool Player::_LoadInventory(QueryResult* result, uint32 timediff, bool& hasEpicM // not allow have in alive state item limited to another map/zone if (IsAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(), zone)) { - CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item` = '%u'", item_lowguid); + CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item_guid` = '%u'", item_lowguid); item->FSetState(ITEM_REMOVED); item->SaveToDB(); // it also deletes item object ! continue; @@ -15572,7 +15577,7 @@ bool Player::_LoadInventory(QueryResult* result, uint32 timediff, bool& hasEpicM // "Conjured items disappear if you are logged out for more than 15 minutes" if (timediff > 15 * MINUTE && (item->GetProto()->Flags & ITEM_FLAG_CONJURED)) { - CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item` = '%u'", item_lowguid); + CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item_guid` = '%u'", item_lowguid); item->FSetState(ITEM_REMOVED); item->SaveToDB(); // it also deletes item object ! continue; @@ -15665,7 +15670,7 @@ bool Player::_LoadInventory(QueryResult* result, uint32 timediff, bool& hasEpicM // Un probleme avec la maniere // dont le PNJ de Bienvenue ajoute le stuff ... //sLog.outError("Player::_LoadInventory: Player %s has item (GUID: %u Entry: %u) can't be loaded to inventory (Bag GUID: %u Slot: %u) by some reason, will send by mail.", GetName(),item_lowguid, item_id, bag_guid, slot); - CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item` = '%u'", item_lowguid); + CharacterDatabase.PExecute("DELETE FROM `character_inventory` WHERE `item_guid` = '%u'", item_lowguid); problematicItems.push_back(item); std::stringstream oss; oss << "Broken item " << item->GetEntry() << " GUID:" << item->GetGUIDLow() << " count:" << item->GetCount() << " bag:" << bag_guid << " slot:" << uint32(slot); @@ -15704,7 +15709,7 @@ bool Player::_LoadInventory(QueryResult* result, uint32 timediff, bool& hasEpicM void Player::_LoadItemLoot(QueryResult* result) { - //QueryResult* result = CharacterDatabase.PQuery("SELECT guid,itemid,amount,property FROM item_loot WHERE guid = '%u'", GetGUIDLow()); + //QueryResult* result = CharacterDatabase.PQuery("SELECT guid, item_id, amount, property FROM item_loot WHERE guid = '%u'", GetGUIDLow()); if (result) { @@ -15747,8 +15752,8 @@ void Player::_LoadQuestStatus(QueryResult* result) uint32 slot = 0; - //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 - //QueryResult* result = CharacterDatabase.PQuery("SELECT quest, status, rewarded, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, itemcount1, itemcount2, itemcount3, itemcount4, reward_choice FROM character_queststatus WHERE guid = '%u'", GetGUIDLow()); + //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 + //QueryResult* result = CharacterDatabase.PQuery("SELECT quest, status, rewarded, explored, timer, mob_count1, mob_count2, mob_count3, mob_count4, item_count1, item_count2, item_count3, item_count4, reward_choice FROM character_queststatus WHERE guid = '%u'", GetGUIDLow()); if (result) { @@ -15853,9 +15858,9 @@ void Player::_LoadSpells(QueryResult* result) { Field* fields = result->Fetch(); - uint32 spell_id = fields[0].GetUInt32(); + uint32 spellId = fields[0].GetUInt32(); - AddSpell(spell_id, fields[1].GetBool(), false, false, fields[2].GetBool()); + AddSpell(spellId, fields[1].GetBool(), false, false, fields[2].GetBool()); } while (result->NextRow()); } @@ -15863,7 +15868,7 @@ void Player::_LoadSpells(QueryResult* result) void Player::_LoadGroup(QueryResult* result) { - //QueryResult* result = CharacterDatabase.PQuery("SELECT groupId FROM group_member WHERE memberGuid='%u'", GetGUIDLow()); + //QueryResult* result = CharacterDatabase.PQuery("SELECT group_id FROM group_member WHERE member_guid='%u'", GetGUIDLow()); if (result) { uint32 groupId = (*result)[0].GetUInt32(); @@ -15883,7 +15888,7 @@ void Player::_LoadBoundInstances(QueryResult* result) Group* group = GetGroup(); - //QueryResult* result = CharacterDatabase.PQuery("SELECT id, permanent, map, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid)); + //QueryResult* result = CharacterDatabase.PQuery("SELECT id, permanent, map, reset_time FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid)); if (result) { do @@ -15893,7 +15898,7 @@ void Player::_LoadBoundInstances(QueryResult* result) uint32 mapId = fields[2].GetUInt32(); uint32 instanceId = fields[0].GetUInt32(); time_t resetTime = (time_t)fields[3].GetUInt64(); - // the resettime for normal instances is only saved when the InstanceSave is unloaded + // the reset_time for normal instances is only saved when the InstanceSave is unloaded // so the value read from the DB may be wrong here but only if the InstanceSave is loaded // and in that case it is not used @@ -16180,7 +16185,7 @@ bool Player::_LoadHomeBind(QueryResult* result) void Player::_LoadGuild(QueryResult* result) { - //"SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow()); + //"SELECT guild_id, rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow()); if (result) { @@ -16211,19 +16216,19 @@ void Player::_LoadGuild(QueryResult* result) /*** SAVE SYSTEM ***/ /*********************************************************/ -bool Player::SaveNewPlayer(WorldSession* session, uint32 guidlow, std::string const& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint32 cinematic) +bool Player::SaveNewPlayer(WorldSession* session, uint32 guidlow, std::string const& name, uint8 raceId, uint8 classId, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair) { - PlayerInfo const* info = sObjectMgr.GetPlayerInfo(race, class_); + PlayerInfo const* info = sObjectMgr.GetPlayerInfo(raceId, classId); if (!info) { sLog.outError("Player have incorrect race/class pair. Can't be loaded."); return false; } - ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(class_); + ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(classId); if (!cEntry) { - sLog.outError("Class %u not found in DBC (Wrong DBC files?)", class_); + sLog.outError("Class %u not found in DBC (Wrong DBC files?)", classId); return false; } @@ -16238,52 +16243,35 @@ bool Player::SaveNewPlayer(WorldSession* session, uint32 guidlow, std::string co static SqlStatementID insChar; - SqlStatement uberInsert = CharacterDatabase.CreateStatement(insChar, "REPLACE INTO `characters` (`guid`, `account`, `name`, `race`, `class`, `gender`, `level`, `xp`, `money`, `playerBytes`, `playerBytes2`, `playerFlags`," + SqlStatement uberInsert = CharacterDatabase.CreateStatement(insChar,"REPLACE INTO `characters` (`guid`, `account`, `name`, `race`, `class`, `gender`, `level`, `money`, " + "`skin`, `face`, `hair_style`, `hair_color`, `facial_hair`, " "`map`, `position_x`, `position_y`, `position_z`, `orientation`, " - "`taximask`, `online`, `cinematic`, " - "`totaltime`, `leveltime`, `rest_bonus`, `logout_time`, `is_logout_resting`, `resettalents_multiplier`, `resettalents_time`, " - "`trans_x`, `trans_y`, `trans_z`, `trans_o`, `transguid`, `extra_flags`, `stable_slots`, `at_login`, `zone`, " - "`death_expire_time`, `taxi_path`, " - "`honorRankPoints`, `honorHighestRank`, `honorStanding`, `honorLastWeekHK`, `honorLastWeekCP`, `honorStoredHK`, `honorStoredDK`, " - "`watchedFaction`, `drunk`, `health`, `power1`, `power2`, `power3`, " - "`power4`, `power5`, `exploredZones`, `equipmentCache`, `ammoId`, `actionBars`, " - "`area`, `world_phase_mask`) " - "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?," + "`known_taxi_mask`, `current_taxi_path`, `online`, `extra_flags`, `at_login_flags`, " + "`health`, `power1`, `power2`, `power3`, `power4`, `power5`, " + "`explored_zones`, `equipment_cache`, `ammo_id`, `world_phase_mask`, `create_time`) " + "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, " "?, ?, ?, ?, ?, " - "?, ?, ?, " - "?, ?, ?, ?, ?, ?, ?, " - "?, ?, ?, ?, ?, ?, ?, ?, ?, " - "?, ?, " - "?, ?, ?, ?, ?, ?, ?, " "?, ?, ?, ?, ?, ?, " - "?, ?, ?, ?, ?, ?, " - "?, ?) "); + "?, ?, ?, ?, ?)"); uberInsert.addUInt32(guidlow); uberInsert.addUInt32(session->GetAccountId()); uberInsert.addString(name); - uberInsert.addUInt8(race); - uberInsert.addUInt8(class_); + uberInsert.addUInt8(raceId); + uberInsert.addUInt8(classId); uberInsert.addUInt8(gender); uint32 const startingLevel = sWorld.getConfig((session->GetSecurity() >= SEC_MODERATOR) ? CONFIG_UINT32_START_GM_LEVEL : CONFIG_UINT32_START_PLAYER_LEVEL); uberInsert.addUInt32(startingLevel); - uberInsert.addUInt32(0); // xp uberInsert.addUInt32(sWorld.getConfig(CONFIG_UINT32_START_PLAYER_MONEY)); - uint32 playerBytes1 = 0; - ::SetByteValue(playerBytes1, 0, skin); - ::SetByteValue(playerBytes1, 1, face); - ::SetByteValue(playerBytes1, 2, hairStyle); - ::SetByteValue(playerBytes1, 3, hairColor); - uberInsert.addUInt32(playerBytes1); - - uint32 playerBytes2 = 0; - ::SetByteValue(playerBytes2, 0, facialHair); - ::SetByteValue(playerBytes2, 3, REST_STATE_NORMAL); - uberInsert.addUInt32(playerBytes2); - - uberInsert.addUInt32(0); // player flags + uberInsert.addInt8(skin); + uberInsert.addInt8(face); + uberInsert.addInt8(hairStyle); + uberInsert.addInt8(hairColor); + uberInsert.addUInt8(facialHair); uberInsert.addUInt32(info->mapId); uberInsert.addFloat(info->positionX); @@ -16292,31 +16280,15 @@ bool Player::SaveNewPlayer(WorldSession* session, uint32 guidlow, std::string co uberInsert.addFloat(info->orientation); PlayerTaxi taxi; - taxi.InitTaxiNodes(race, class_); + taxi.InitTaxiNodes(raceId, classId); std::ostringstream ss; ss << taxi; // string with TaxiMaskSize numbers uberInsert.addString(ss); + ss << taxi.SaveTaxiDestinationsToString(); // string + uberInsert.addString(ss); + uberInsert.addUInt32(0); // online - uberInsert.addUInt32(cinematic); - - uberInsert.addUInt32(0); // total played time - uberInsert.addUInt32(0); // level played time - - uberInsert.addFloat(0); // rest bonus - uberInsert.addUInt64(uint64(time(nullptr))); - uberInsert.addUInt32(0); // resting - - //save, far from tavern/city - //save, but in tavern/city - uberInsert.addUInt32(0); // reset talents multiplier - uberInsert.addUInt64(0); // reset talents time - - uberInsert.addFloat(0); // transport position x - uberInsert.addFloat(0); // transport position y - uberInsert.addFloat(0); // transport position z - uberInsert.addFloat(0); // transport position o - uberInsert.addUInt32(0); // transport guid uint32 extraFlags = 0; if (session->GetSecurity() > SEC_PLAYER) @@ -16325,43 +16297,13 @@ bool Player::SaveNewPlayer(WorldSession* session, uint32 guidlow, std::string co extraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; uberInsert.addUInt32(extraFlags); - uberInsert.addUInt32(0); // stable slots - uberInsert.addUInt32(AT_LOGIN_FIRST); // login flags - uint32 zoneId = 0; - uint32 areaId = 0; - if (auto map = sMapMgr.FindMap(info->mapId)) - map->GetTerrain()->GetZoneAndAreaId(zoneId, areaId, info->positionX, info->positionY, info->positionZ); - uberInsert.addUInt32(0); // zone id (should be 0 before first login) - - uberInsert.addUInt64(0); // death expire time - - ss << taxi.SaveTaxiDestinationsToString(); // string - uberInsert.addString(ss); - - // Honor stored data - uberInsert.addFloat(0); // rank points - uberInsert.addUInt32(0); // highest rank - uberInsert.addUInt32(0); // standing - uberInsert.addUInt32(0); // last week hk - uberInsert.addFloat(0); // last week cp - uberInsert.addUInt32(0); // stored hk - uberInsert.addUInt32(0); // stored dk - - // FIXME: at this moment send to DB as unsigned, including uint32(-1) - uberInsert.addUInt32(-1); - - uint32 playerBytes3 = 0; - ::SetUInt16Value(playerBytes3, 0, gender); // only GENDER_MALE/GENDER_FEMALE (1 bit) allowed, drunk state = 0 - ::SetByteValue(playerBytes3, 3, 0); // BattlefieldArenaFaction (0 or 1) - uberInsert.addUInt16(uint16(playerBytes3 & 0xFFFE)); - PlayerLevelInfo levelInfo; - sObjectMgr.GetPlayerLevelInfo(race, class_, startingLevel, &levelInfo); + sObjectMgr.GetPlayerLevelInfo(raceId, classId, startingLevel, &levelInfo); PlayerClassLevelInfo classInfo; - sObjectMgr.GetPlayerClassLevelInfo(class_, startingLevel, &classInfo); + sObjectMgr.GetPlayerClassLevelInfo(classId, startingLevel, &classInfo); uint32 hp = uint32(classInfo.basehealth + GetHealthBonusFromStamina(levelInfo.stats[STAT_STAMINA])); uint32 powers[MAX_POWERS] = {}; @@ -16388,7 +16330,7 @@ bool Player::SaveNewPlayer(WorldSession* session, uint32 guidlow, std::string co if (ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(itr.item_id)) { uint8 slots[4]; - pProto->GetAllowedEquipSlots(slots, class_, false); + pProto->GetAllowedEquipSlots(slots, classId, false); for (uint32 i = 0; i < 4; i++) { @@ -16413,11 +16355,8 @@ bool Player::SaveNewPlayer(WorldSession* session, uint32 guidlow, std::string co uberInsert.addString(ss); uberInsert.addUInt32(ammoId); - - uberInsert.addUInt32(0); // action bars - - uberInsert.addUInt32(areaId); uberInsert.addUInt32(WORLD_DEFAULT_CHAR); + uberInsert.addUInt64(uint64(time(nullptr))); uberInsert.Execute(); sObjectMgr.SetPlayerWorldMask(guidlow, WORLD_DEFAULT_CHAR); @@ -16425,10 +16364,15 @@ bool Player::SaveNewPlayer(WorldSession* session, uint32 guidlow, std::string co CharacterDatabase.CommitTransaction(); + uint32 zoneId = 0; + uint32 areaId = 0; + if (auto map = sMapMgr.FindMap(info->mapId)) + map->GetTerrain()->GetZoneAndAreaId(zoneId, areaId, info->positionX, info->positionY, info->positionZ); + MasterPlayer masterPlayer(session); - masterPlayer.Create(ObjectGuid(HIGHGUID_PLAYER, guidlow), race, class_); + masterPlayer.Create(ObjectGuid(HIGHGUID_PLAYER, guidlow), raceId, classId); masterPlayer.SaveToDB(); - PlayerCacheData* cacheData = sObjectMgr.InsertPlayerInCache(guidlow, race, class_, gender, session->GetAccountId(), name, startingLevel, zoneId); + PlayerCacheData* cacheData = sObjectMgr.InsertPlayerInCache(guidlow, raceId, classId, gender, session->GetAccountId(), name, startingLevel, zoneId); sObjectMgr.UpdatePlayerCachedPosition(cacheData, info->mapId, info->positionX, info->positionY, info->positionZ, info->orientation, false); sWorld.LogCharacter(session, guidlow, name, "Create"); @@ -16463,26 +16407,24 @@ void Player::SaveToDB(bool online, bool force) static SqlStatementID insChar; - SqlStatement uberInsert = CharacterDatabase.CreateStatement(insChar, "REPLACE INTO `characters` (`guid`, `account`, `name`, `race`, `class`, `gender`, `level`, `xp`, `money`, `playerBytes`, `playerBytes2`, `playerFlags`," + SqlStatement uberInsert = CharacterDatabase.CreateStatement(insChar, "REPLACE INTO `characters` (`guid`, `account`, `name`, `race`, `class`, `gender`, `level`, `xp`, `money`, `skin`, `face`, `hair_style`, `hair_color`, `facial_hair`, `bank_bag_slots`, `player_flags`," "`map`, `position_x`, `position_y`, `position_z`, `orientation`, " - "`taximask`, `online`, `cinematic`, " - "`totaltime`, `leveltime`, `rest_bonus`, `logout_time`, `is_logout_resting`, `resettalents_multiplier`, `resettalents_time`, " - "`trans_x`, `trans_y`, `trans_z`, `trans_o`, `transguid`, `extra_flags`, `stable_slots`, `at_login`, `zone`, " - "`death_expire_time`, `taxi_path`, " - "`honorRankPoints`, `honorHighestRank`, `honorStanding`, `honorLastWeekHK`, `honorLastWeekCP`, `honorStoredHK`, `honorStoredDK`, " - "`watchedFaction`, `drunk`, `health`, `power1`, `power2`, `power3`, " - "`power4`, `power5`, `exploredZones`, `equipmentCache`, `ammoId`, `actionBars`, " - "`area`, `world_phase_mask`) " - "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?," + "`transport_guid`, `transport_x`, `transport_y`, `transport_z`, `transport_o`, " + "`known_taxi_mask`, `current_taxi_path`, `online`, `played_time_total`, `played_time_level`, " + "`rest_bonus`, `logout_time`, `is_logout_resting`, `reset_talents_multiplier`, `reset_talents_time`, " + "`extra_flags`, `stable_slots`, `at_login_flags`, `zone`, `death_expire_time`," + "`honor_rank_points`, `honor_highest_rank`, `honor_standing`, `honor_last_week_hk`, `honor_last_week_cp`, `honor_stored_hk`, `honor_stored_dk`, " + "`watched_faction`, `drunk`, `health`, `power1`, `power2`, `power3`, `power4`, `power5`, " + "`explored_zones`, `equipment_cache`, `ammo_id`, `action_bars`, `world_phase_mask`, `create_time`) " + "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, " "?, ?, ?, ?, ?, " - "?, ?, ?, " "?, ?, ?, ?, ?, ?, ?, " - "?, ?, ?, ?, ?, ?, ?, ?, ?, " - "?, ?, " - "?, ?, ?, ?, ?, ?, ?, " - "?, ?, ?, ?, ?, ?, " - "?, ?, ?, ?, ?, ?, " - "?, ?) "); + "?, ?, ?, ?, ?, ?, ?, ?, " + "?, ?, ?, ?, ?, ?)"); uberInsert.addUInt32(GetGUIDLow()); uberInsert.addUInt32(GetSession()->GetAccountId()); @@ -16493,8 +16435,12 @@ void Player::SaveToDB(bool online, bool force) uberInsert.addUInt32(GetLevel()); uberInsert.addUInt32(GetUInt32Value(PLAYER_XP)); uberInsert.addUInt32(GetMoney()); - uberInsert.addUInt32(GetUInt32Value(PLAYER_BYTES)); - uberInsert.addUInt32(GetUInt32Value(PLAYER_BYTES_2)); + uberInsert.addUInt8(GetByteValue(PLAYER_BYTES, 0)); // skin + uberInsert.addUInt8(GetByteValue(PLAYER_BYTES, 1)); // face + uberInsert.addUInt8(GetByteValue(PLAYER_BYTES, 2)); // hair style + uberInsert.addUInt8(GetByteValue(PLAYER_BYTES, 3)); // hair color + uberInsert.addUInt32(GetByteValue(PLAYER_BYTES_2, 0)); // facial hair + uberInsert.addUInt32(GetByteValue(PLAYER_BYTES_2, 2)); // bank bag slots // Nostalrius: Fix toggled PvP flag after relog. uint32 playerFlags = GetUInt32Value(PLAYER_FLAGS) & ~(PLAYER_FLAGS_PVP_DESIRED); @@ -16519,36 +16465,36 @@ void Player::SaveToDB(bool online, bool force) uberInsert.addFloat(MapManager::NormalizeOrientation(finiteAlways(GetTeleportDest().o))); } + if (m_transport) + uberInsert.addUInt32(m_transport->GetGUIDLow()); + else + uberInsert.addUInt32(0); + uberInsert.addFloat(finiteAlways(m_movementInfo.GetTransportPos().x)); + uberInsert.addFloat(finiteAlways(m_movementInfo.GetTransportPos().y)); + uberInsert.addFloat(finiteAlways(m_movementInfo.GetTransportPos().z)); + uberInsert.addFloat(MapManager::NormalizeOrientation(finiteAlways(m_movementInfo.GetTransportPos().o))); + std::ostringstream ss; ss << m_taxi; // string with TaxiMaskSize numbers uberInsert.addString(ss); + ss << m_taxi.SaveTaxiDestinationsToString(); + uberInsert.addString(ss); + if (!IsInWorld()) online = false; uberInsert.addUInt32(online); - uberInsert.addUInt32(m_cinematic); - - uberInsert.addUInt32(m_Played_time[PLAYED_TIME_TOTAL]); - uberInsert.addUInt32(m_Played_time[PLAYED_TIME_LEVEL]); + uberInsert.addUInt32(m_playedTime[PLAYED_TIME_TOTAL]); + uberInsert.addUInt32(m_playedTime[PLAYED_TIME_LEVEL]); uberInsert.addFloat(finiteAlways(m_restBonus)); uberInsert.addUInt64(uint64(time(nullptr))); uberInsert.addUInt32(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) ? 1 : 0); - //save, far from tavern/city - //save, but in tavern/city + uberInsert.addUInt32(m_resetTalentsMultiplier); uberInsert.addUInt64(uint64(m_resetTalentsTime)); - uberInsert.addFloat(finiteAlways(m_movementInfo.GetTransportPos().x)); - uberInsert.addFloat(finiteAlways(m_movementInfo.GetTransportPos().y)); - uberInsert.addFloat(finiteAlways(m_movementInfo.GetTransportPos().z)); - uberInsert.addFloat(MapManager::NormalizeOrientation(finiteAlways(m_movementInfo.GetTransportPos().o))); - if (m_transport) - uberInsert.addUInt32(m_transport->GetGUIDLow()); - else - uberInsert.addUInt32(0); - uberInsert.addUInt32(m_ExtraFlags); uberInsert.addUInt32(uint32(m_stableSlots)); // to prevent save uint8 as char @@ -16559,9 +16505,6 @@ void Player::SaveToDB(bool online, bool force) uberInsert.addUInt64(uint64(m_deathExpireTime)); - ss << m_taxi.SaveTaxiDestinationsToString(); //string - uberInsert.addString(ss); - // Honor stored data uberInsert.addFloat(finiteAlways(m_honorMgr.GetRankPoints())); uberInsert.addUInt32(uint32(m_honorMgr.GetHighestRank().rank)); @@ -16571,11 +16514,10 @@ void Player::SaveToDB(bool online, bool force) uberInsert.addUInt32(m_honorMgr.GetStoredHK()); uberInsert.addUInt32(m_honorMgr.GetStoredDK()); - // FIXME: at this moment send to DB as unsigned, including unit32(-1) #if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 - uberInsert.addUInt32(GetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX)); + uberInsert.addInt32(GetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX)); #else - uberInsert.addUInt32(0); + uberInsert.addInt32(-1); #endif uberInsert.addUInt16(uint16(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFE)); @@ -16608,9 +16550,8 @@ void Player::SaveToDB(bool online, bool force) uberInsert.addUInt32(GetUInt32Value(PLAYER_AMMO_ID)); uberInsert.addUInt32(uint32(GetByteValue(PLAYER_FIELD_BYTES, 2))); - // Nostalrius - uberInsert.addUInt32(GetAreaId()); uberInsert.addUInt32(GetWorldMask()); + uberInsert.addUInt64(uint64(m_createTime)); uberInsert.Execute(); _SaveBGData(); @@ -16685,8 +16626,8 @@ void Player::_SaveAuras() if (auraHolders.empty()) return; - stmt = CharacterDatabase.CreateStatement(insertAuras, "INSERT INTO `character_aura` (`guid`, `caster_guid`, `item_guid`, `spell`, `stackcount`, `remaincharges`, " - "`basepoints0`, `basepoints1`, `basepoints2`, `periodictime0`, `periodictime1`, `periodictime2`, `maxduration`, `remaintime`, `effIndexMask`) " + stmt = CharacterDatabase.CreateStatement(insertAuras, "INSERT INTO `character_aura` (`guid`, `caster_guid`, `item_guid`, `spell`, `stacks`, `charges`, " + "`base_points0`, `base_points1`, `base_points2`, `periodic_time0`, `periodic_time1`, `periodic_time2`, `max_duration`, `duration`, `effect_index_mask`) " "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); AuraSaveStruct s; @@ -16698,11 +16639,11 @@ void Player::_SaveAuras() continue; stmt.addUInt32(GetGUIDLow()); - stmt.addUInt64(s.caster_guid.GetRawValue()); - stmt.addUInt32(s.item_lowguid); - stmt.addUInt32(s.spellid); - stmt.addUInt32(s.stackcount); - stmt.addUInt8(s.remaincharges); + stmt.addUInt64(s.casterGuid.GetRawValue()); + stmt.addUInt32(s.itemLowGuid); + stmt.addUInt32(s.spellId); + stmt.addUInt32(s.stacks); + stmt.addUInt8(s.charges); for (float i : s.damage) stmt.addFloat(i); @@ -16710,9 +16651,9 @@ void Player::_SaveAuras() for (uint32 i : s.periodicTime) stmt.addUInt32(i); - stmt.addInt32(s.maxduration); - stmt.addInt32(s.remaintime); - stmt.addUInt32(s.effIndexMask); + stmt.addInt32(s.maxDuration); + stmt.addInt32(s.duration); + stmt.addInt8(s.effIndexMask); stmt.Execute(); } } @@ -16729,7 +16670,7 @@ bool Player::SaveAura(SpellAuraHolder* holder, AuraSaveStruct& saveStruct) { saveStruct.effIndexMask = 0; - for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { saveStruct.damage[i] = 0; saveStruct.periodicTime[i] = 0; @@ -16749,15 +16690,15 @@ bool Player::SaveAura(SpellAuraHolder* holder, AuraSaveStruct& saveStruct) if (!saveStruct.effIndexMask) return false; - saveStruct.caster_guid = holder->GetCasterGuid(); - saveStruct.item_lowguid = holder->GetCastItemGuid().GetCounter(); - saveStruct.spellid = holder->GetId(); - saveStruct.stackcount = holder->GetStackAmount(); - saveStruct.remaincharges = holder->GetAuraCharges(); - saveStruct.remaintime = holder->GetAuraDuration(); - saveStruct.maxduration = holder->GetAuraMaxDuration(); - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) - saveStruct.remaincharges = holder->GetAuraCharges(); + saveStruct.casterGuid = holder->GetCasterGuid(); + saveStruct.itemLowGuid = holder->GetCastItemGuid().GetCounter(); + saveStruct.spellId = holder->GetId(); + saveStruct.stacks = holder->GetStackAmount(); + saveStruct.charges = holder->GetAuraCharges(); + saveStruct.duration = holder->GetAuraDuration(); + saveStruct.maxDuration = holder->GetAuraMaxDuration(); + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) + saveStruct.charges = holder->GetAuraCharges(); return true; } return false; @@ -16775,7 +16716,7 @@ void Player::_SaveInventory() static SqlStatementID delInv ; static SqlStatementID delItemInst ; - SqlStatement stmt = CharacterDatabase.CreateStatement(delInv, "DELETE FROM `character_inventory` WHERE `item` = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(delInv, "DELETE FROM `character_inventory` WHERE `item_guid` = ?"); stmt.PExecute(item->GetGUIDLow()); stmt = CharacterDatabase.CreateStatement(delItemInst, "DELETE FROM `item_instance` WHERE `guid` = ?"); @@ -16840,7 +16781,7 @@ void Player::_SaveInventory() { case ITEM_NEW: { - SqlStatement stmt = CharacterDatabase.CreateStatement(insertInventory, "INSERT INTO `character_inventory` (`guid`, `bag`, `slot`, `item`, `item_template`) VALUES (?, ?, ?, ?, ?)"); + SqlStatement stmt = CharacterDatabase.CreateStatement(insertInventory, "INSERT INTO `character_inventory` (`guid`, `bag`, `slot`, `item_guid`, `item_id`) VALUES (?, ?, ?, ?, ?)"); stmt.addUInt32(GetGUIDLow()); stmt.addUInt32(bag_guid); stmt.addUInt8(item->GetSlot()); @@ -16851,7 +16792,7 @@ void Player::_SaveInventory() break; case ITEM_CHANGED: { - SqlStatement stmt = CharacterDatabase.CreateStatement(updateInventory, "UPDATE `character_inventory` SET `guid` = ?, `bag` = ?, `slot` = ?, `item_template` = ? WHERE `item` = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(updateInventory, "UPDATE `character_inventory` SET `guid` = ?, `bag` = ?, `slot` = ?, `item_id` = ? WHERE `item_guid` = ?"); stmt.addUInt32(GetGUIDLow()); stmt.addUInt32(bag_guid); stmt.addUInt8(item->GetSlot()); @@ -16862,7 +16803,7 @@ void Player::_SaveInventory() break; case ITEM_REMOVED: { - SqlStatement stmt = CharacterDatabase.CreateStatement(deleteInventory, "DELETE FROM `character_inventory` WHERE `item` = ?"); + SqlStatement stmt = CharacterDatabase.CreateStatement(deleteInventory, "DELETE FROM `character_inventory` WHERE `item_guid` = ?"); stmt.PExecute(item->GetGUIDLow()); } break; @@ -16898,7 +16839,7 @@ void Player::_SaveQuestStatus() { case QUEST_NEW : { - SqlStatement stmt = CharacterDatabase.CreateStatement(insertQuestStatus, "INSERT INTO `character_queststatus` (`guid`, `quest`, `status`, `rewarded`, `explored`, `timer`, `mobcount1`, `mobcount2`, `mobcount3`, `mobcount4`, `itemcount1`, `itemcount2`, `itemcount3`, `itemcount4`, `reward_choice`) " + SqlStatement stmt = CharacterDatabase.CreateStatement(insertQuestStatus, "INSERT INTO `character_queststatus` (`guid`, `quest`, `status`, `rewarded`, `explored`, `timer`, `mob_count1`, `mob_count2`, `mob_count3`, `mob_count4`, `item_count1`, `item_count2`, `item_count3`, `item_count4`, `reward_choice`) " "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); stmt.addUInt32(GetGUIDLow()); @@ -16918,7 +16859,7 @@ void Player::_SaveQuestStatus() case QUEST_CHANGED : { SqlStatement stmt = CharacterDatabase.CreateStatement(updateQuestStatus, "UPDATE `character_queststatus` SET `status` = ?, `rewarded` = ?, `reward_choice` = ?, `explored` = ?, `timer` = ?," - "`mobcount1` = ?, `mobcount2` = ?, `mobcount3` = ?, `mobcount4` = ?, `itemcount1` = ?, `itemcount2` = ?, `itemcount3` = ?, `itemcount4` = ? WHERE `guid` = ? AND `quest` = ?"); + "`mob_count1` = ?, `mob_count2` = ?, `mob_count3` = ?, `mob_count4` = ?, `item_count1` = ?, `item_count2` = ?, `item_count3` = ?, `item_count4` = ? WHERE `guid` = ? AND `quest` = ?"); stmt.addUInt8(i->second.m_status); stmt.addUInt8(i->second.m_rewarded); @@ -17051,9 +16992,9 @@ void Player::_SaveStats() SqlStatement stmt = CharacterDatabase.CreateStatement(delStats, "DELETE FROM `character_stats` WHERE `guid` = ?"); stmt.PExecute(GetGUIDLow()); - stmt = CharacterDatabase.CreateStatement(insertStats, "INSERT INTO `character_stats` (`guid`, `maxhealth`, `maxpower1`, `maxpower2`, `maxpower3`, `maxpower4`, `maxpower5`, " - "`strength`, `agility`, `stamina`, `intellect`, `spirit`, `armor`, `resHoly`, `resFire`, `resNature`, `resFrost`, `resShadow`, `resArcane`, " - "`blockPct`, `dodgePct`, `parryPct`, `critPct`, `rangedCritPct`, `attackPower`, `rangedAttackPower`) " + stmt = CharacterDatabase.CreateStatement(insertStats, "INSERT INTO `character_stats` (`guid`, `max_health`, `max_power1`, `max_power2`, `max_power3`, `max_power4`, `max_power5`, " + "`strength`, `agility`, `stamina`, `intellect`, `spirit`, `armor`, `holy_res`, `fire_res`, `nature_res`, `frost_res`, `shadow_res`, `arcane_res`, " + "`block_chance`, `dodge_chance`, `parry_chance`, `crit_chance`, `ranged_crit_chance`, `attack_power`, `ranged_attack_power`) " "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); stmt.addUInt32(GetGUIDLow()); @@ -17112,10 +17053,10 @@ bool Player::CanSpeak() const void Player::SavePositionInDB(ObjectGuid guid, uint32 mapid, float x, float y, float z, float o, uint32 zone) { std::ostringstream ss; - ss << "UPDATE `characters` SET `position_x`='" << x << "',`position_y`='" << y - << "',`position_z`='" << z << "',`orientation`='" << o << "',`map`='" << mapid - << "',`zone`='" << zone << "',`trans_x`='0',`trans_y`='0',`trans_z`='0'," - << "`transguid`='0',`taxi_path`='' WHERE `guid`='" << guid.GetCounter() << "'"; + ss << "UPDATE `characters` SET `position_x`=" << x << ", `position_y`=" << y + << ", `position_z`=" << z << ", `orientation`=" << o << " ,`map`=" << mapid + << " ,`zone`=" << zone << " ,`transport_x`=0, `transport_y`=0, `transport_z`=0, " + << "`transport_guid`=0, `current_taxi_path`='' WHERE `guid`=" << guid.GetCounter(); DEBUG_LOG("%s", ss.str().c_str()); CharacterDatabase.Execute(ss.str().c_str()); } @@ -17777,35 +17718,9 @@ void Player::RemovePetitionsAndSigns(ObjectGuid guid) { uint32 lowguid = guid.GetCounter(); - // Blocking query, can cause lag at character deletion if MySQL table is locked. - /* - QueryResult* result = CharacterDatabase.PQuery("SELECT ownerguid,petitionguid FROM petition_sign WHERE playerguid = '%u'", lowguid); - if (result) - { - do // this part effectively does nothing, since the deletion / modification only takes place _after_ the PetitionQuery. Though I don't know if the result remains intact if I execute the delete query beforehand. - { - // and SendPetitionQueryOpcode reads data from the DB - Field* fields = result->Fetch(); - ObjectGuid ownerguid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()); - ObjectGuid petitionguid = ObjectGuid(HIGHGUID_ITEM, fields[1].GetUInt32()); - - // send update if charter owner in game - Player* owner = sObjectMgr.GetPlayer(ownerguid); - if (owner) - owner->GetSession()->SendPetitionQueryOpcode(petitionguid); - - } - while (result->NextRow()); - - delete result; - - CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u'", lowguid); - } - */ - CharacterDatabase.BeginTransaction(); - CharacterDatabase.PExecute("DELETE FROM `petition` WHERE `ownerguid` = '%u'", lowguid); - CharacterDatabase.PExecute("DELETE FROM `petition_sign` WHERE `ownerguid` = '%u'", lowguid); + CharacterDatabase.PExecute("DELETE FROM `petition` WHERE `owner_guid` = '%u'", lowguid); + CharacterDatabase.PExecute("DELETE FROM `petition_sign` WHERE `owner_guid` = '%u'", lowguid); CharacterDatabase.CommitTransaction(); } @@ -19163,19 +19078,19 @@ void Player::LearnDefaultSpells() void Player::LearnQuestRewardedSpells(Quest const* quest) { - uint32 spell_id = quest->GetRewSpellCast(); + uint32 spellId = quest->GetRewSpellCast(); // skip quests without rewarded spell - if (!spell_id) + if (!spellId) return; - SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(spell_id); + SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(spellId); if (!spellInfo) return; // check learned spells state bool found = false; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellInfo->Effect[i] == SPELL_EFFECT_LEARN_SPELL && !HasSpell(spellInfo->EffectTriggerSpell[i])) { @@ -19229,7 +19144,7 @@ void Player::LearnQuestRewardedSpells(Quest const* quest) } } - CastSpell(this, spell_id, true); + CastSpell(this, spellId, true); } void Player::LearnQuestRewardedSpells() @@ -19373,17 +19288,17 @@ float Player::GetReputationPriceDiscount(Creature const* pCreature) const * Check spell availability for training base at SkillLineAbility/SkillRaceClassInfo data. * Checked allowed race/class and dependent from race/class allowed min level * - * @param spell_id checked spell id + * @param spellId checked spell id * @param pReqlevel if arg provided then function work in view mode (level check not applied but detected minlevel returned to var by arg pointer. if arg not provided then considered train action mode and level checked * @return true if spell available for show in trainer list (with skip level check) or training. */ -bool Player::IsSpellFitByClassAndRace(uint32 spell_id, uint32* pReqlevel /*= nullptr*/) const +bool Player::IsSpellFitByClassAndRace(uint32 spellId, uint32* pReqlevel /*= nullptr*/) const { uint32 racemask = GetRaceMask(); uint32 classmask = GetClassMask(); - SkillLineAbilityMapBounds bounds = sSpellMgr.GetSkillLineAbilityMapBoundsBySpellId(spell_id); + SkillLineAbilityMapBounds bounds = sSpellMgr.GetSkillLineAbilityMapBoundsBySpellId(spellId); if (bounds.first == bounds.second) return true; @@ -19725,7 +19640,7 @@ uint32 Player::GetResurrectionSpellId() const { // search priceless resurrection possibilities uint32 prio = 0; - uint32 spell_id = 0; + uint32 spellId = 0; AuraList const& dummyAuras = GetAurasByType(SPELL_AURA_DUMMY); for (const auto dummyAura : dummyAuras) { @@ -19735,22 +19650,22 @@ uint32 Player::GetResurrectionSpellId() const switch (dummyAura->GetId()) { case 20707: - spell_id = 3026; + spellId = 3026; break; // rank 1 case 20762: - spell_id = 20758; + spellId = 20758; break; // rank 2 case 20763: - spell_id = 20759; + spellId = 20759; break; // rank 3 case 20764: - spell_id = 20760; + spellId = 20760; break; // rank 4 case 20765: - spell_id = 20761; + spellId = 20761; break; // rank 5 case 27239: - spell_id = 27240; + spellId = 27240; break; // rank 6 default: sLog.outError("Unhandled spell %u: S.Resurrection", dummyAura->GetId()); @@ -19763,15 +19678,15 @@ uint32 Player::GetResurrectionSpellId() const else if (dummyAura->GetId() == 23701 && roll_chance_i(10)) { prio = 2; - spell_id = 23700; + spellId = 23700; } } // Reincarnation (passive spell) // prio: 1 if (prio < 1 && HasSpell(20608) && IsSpellReady(21169) && HasItemCount(17030, EFFECT_INDEX_1)) - spell_id = 21169; + spellId = 21169; - return spell_id; + return spellId; } // Used in triggers for check "Only to targets that grant experience or honor" req @@ -20336,9 +20251,9 @@ uint32 Player::CalculateTalentsPoints() const struct DoPlayerLearnSpell { DoPlayerLearnSpell(Player& _player) : player(_player) {} - void operator()(uint32 spell_id) + void operator()(uint32 spellId) { - player.LearnSpell(spell_id, false); + player.LearnSpell(spellId, false); } Player& player; }; @@ -20755,13 +20670,13 @@ void Player::RemoveAtLoginFlag(AtLoginFlags f, bool in_db_also /*= false*/) m_atLoginFlags &= ~f; if (in_db_also) - CharacterDatabase.PExecute("UPDATE `characters` SET `at_login` = `at_login` & ~ %u WHERE `guid` ='%u'", uint32(f), GetGUIDLow()); + CharacterDatabase.PExecute("UPDATE `characters` SET `at_login_flags` = `at_login_flags` & ~ %u WHERE `guid` ='%u'", uint32(f), GetGUIDLow()); } -void Player::SendClearCooldown(uint32 spell_id, Unit* target) const +void Player::SendClearCooldown(uint32 spellId, Unit* target) const { WorldPacket data(SMSG_CLEAR_COOLDOWN, 4 + 8); - data << uint32(spell_id); + data << uint32(spellId); data << target->GetObjectGuid(); SendDirectMessage(&data); } @@ -20782,10 +20697,10 @@ void Player::SendSpellCooldown(uint32 spellId, uint32 cooldown, ObjectGuid targe GetSession()->SendPacket(&data); } -void Player::SendSpellRemoved(uint32 spell_id) const +void Player::SendSpellRemoved(uint32 spellId) const { WorldPacket data(SMSG_REMOVED_SPELL, 4); - data << uint16(spell_id); + data << uint16(spellId); GetSession()->SendPacket(&data); } diff --git a/src/game/Objects/Player.h b/src/game/Objects/Player.h index 7616eac1f..95ee213f6 100644 --- a/src/game/Objects/Player.h +++ b/src/game/Objects/Player.h @@ -835,7 +835,7 @@ class TradeData public: // access functions void SetItem(TradeSlots slot, Item* item); - void SetSpell(uint32 spell_id, Item* castItem = nullptr); + void SetSpell(uint32 spellId, Item* castItem = nullptr); void SetMoney(uint32 money); void SetAccepted(bool state, bool crosssend = false); @@ -885,17 +885,16 @@ class MovementAnticheat; struct AuraSaveStruct { - ObjectGuid caster_guid = 0; - uint32 item_lowguid = 0; - uint32 spellid = 0; - uint32 stackcount = 0; - uint32 remaincharges = 0; + ObjectGuid casterGuid = 0; + uint32 itemLowGuid = 0; + uint32 spellId = 0; + uint32 stacks = 0; + uint32 charges = 0; float damage[MAX_EFFECT_INDEX] = { 0 }; uint32 periodicTime[MAX_EFFECT_INDEX] = { 0 }; - - int32 maxduration = 0; - int32 remaintime = 0; - uint32 effIndexMask = 0; + int32 maxDuration = 0; + int32 duration = 0; + uint8 effIndexMask = 0; }; struct ScheduledTeleportData @@ -1110,8 +1109,8 @@ class Player final: public Unit void AutoUnequipItemFromSlot(uint32 slot); void SatisfyItemRequirements(ItemPrototype const* pItem); void AddStartingItems(); - bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count, uint32 enchantId = 0); - Item* StoreNewItemInInventorySlot(uint32 itemEntry, uint32 amount); + bool StoreNewItemInBestSlots(uint32 itemId, uint32 amount, uint32 enchantId = 0); + Item* StoreNewItemInInventorySlot(uint32 itemId, uint32 amount); void AutoStoreLoot(Loot& loot, bool broadcast = false, uint8 bag = NULL_BAG, uint8 slot = NULL_SLOT); void SetAmmo(uint32 item); void RemoveAmmo(); @@ -1323,7 +1322,7 @@ class Player final: public Unit void ItemRemovedQuestCheck(uint32 entry, uint32 count); void KilledMonster(CreatureInfo const* cInfo, ObjectGuid guid); void KilledMonsterCredit(uint32 entry, ObjectGuid guid = ObjectGuid()); - void CastedCreatureOrGO(uint32 entry, ObjectGuid guid, uint32 spell_id, bool original_caster = true); + void CastedCreatureOrGO(uint32 entry, ObjectGuid guid, uint32 spellId, bool originalCaster = true); void TalkedToCreature(uint32 entry, ObjectGuid guid); void MoneyChanged(uint32 value); void ReputationChanged(FactionEntry const* factionEntry); @@ -1407,13 +1406,13 @@ class Player final: public Unit uint32 m_nextSave; public: // Saves a new character directly in the database, without creating a Player object in memory. - static bool SaveNewPlayer(WorldSession* session, uint32 guidlow, std::string const& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint32 cinematic); + static bool SaveNewPlayer(WorldSession* session, uint32 guidlow, std::string const& name, uint8 raceId, uint8 classId, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair); void SaveToDB(bool online = true, bool force = false); void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing void SaveGoldToDB(); static void SavePositionInDB(ObjectGuid guid, uint32 mapid, float x,float y,float z,float o,uint32 zone); - static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars = true, bool deleteFinally = false); + static void DeleteFromDB(ObjectGuid playerGuid, uint32 accountId, bool updateRealmChars = true, bool deleteFinally = false); static void DeleteOldCharacters(); static void DeleteOldCharacters(uint32 keepDays); @@ -1453,7 +1452,7 @@ class Player final: public Unit // Temporarily removed pet cache uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; } - void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; } + void SetTemporaryUnsummonedPetNumber(uint32 petNumber) { m_temporaryUnsummonedPetNumber = petNumber; } void UnsummonPetTemporaryIfAny(); void ResummonPetTemporaryUnSummonedIfAny(); bool IsPetNeedBeTemporaryUnsummoned() const { return !IsInWorld() || !IsAlive() || IsMounted() /*+in flight*/; } @@ -1471,16 +1470,16 @@ class Player final: public Unit bool IsNeedCastPassiveLikeSpellAtLearn(SpellEntry const* spellInfo) const; void SendInitialSpells() const; - bool AddSpell(uint32 spell_id, bool active, bool learning, bool dependent, bool disabled); + bool AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled); public: bool HasSpell(uint32 spell) const override; bool HasActiveSpell(uint32 spell) const; // show in spellbook TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const; - bool IsSpellFitByClassAndRace(uint32 spell_id, uint32* pReqlevel = nullptr) const; + bool IsSpellFitByClassAndRace(uint32 spellId, uint32* pReqlevel = nullptr) const; bool IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index, bool castOnSelf) const override; - void SendSpellRemoved(uint32 spell_id) const; - void LearnSpell(uint32 spell_id, bool dependent, bool talent = false); - void RemoveSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true); + void SendSpellRemoved(uint32 spellId) const; + void LearnSpell(uint32 spellId, bool dependent, bool talent = false); + void RemoveSpell(uint32 spellId, bool disabled = false, bool learn_low_rank = true); void ResetSpells(); void LearnDefaultSpells(); void LearnQuestRewardedSpells(); @@ -1512,7 +1511,7 @@ class Player final: public Unit virtual void RemoveAllCooldowns(bool sendOnly = false); virtual void LockOutSpells(SpellSchoolMask schoolMask, uint32 duration) override; void RemoveSpellLockout(SpellSchoolMask spellSchoolMask, std::set* spellAlreadySent = nullptr); - void SendClearCooldown(uint32 spell_id, Unit* target) const; + void SendClearCooldown(uint32 spellId, Unit* target) const; void SendClearAllCooldowns(Unit* target) const; void SendSpellCooldown(uint32 spellId, uint32 cooldown, ObjectGuid target) const; void _LoadSpellCooldowns(QueryResult* result); @@ -2066,15 +2065,12 @@ class Player final: public Unit /*********************************************************/ private: - uint32 m_cinematic; uint32 m_currentCinematicEntry; Position m_cinematicStartPos; uint32 m_cinematicLastCheck; uint32 m_cinematicElapsedTime; void UpdateCinematic(uint32 diff); public: - uint32 GetCinematic() { return m_cinematic; } - void SetCinematic(uint32 cine) { m_cinematic = cine; } void SendCinematicStart(uint32 CinematicSequenceId); uint32 GetCurrentCinematicEntry() const { return m_currentCinematicEntry; } @@ -2130,9 +2126,10 @@ class Player final: public Unit private: WorldSession* m_session; uint32 m_skippedUpdateTime; - time_t m_logintime; - time_t m_Last_tick; - uint32 m_Played_time[MAX_PLAYED_TIME_INDEX]; + time_t m_createTime; + time_t m_loginTime; + time_t m_lastTick; + uint32 m_playedTime[MAX_PLAYED_TIME_INDEX]; public: WorldSession* GetSession() const { return m_session; } void SetSession(WorldSession* s); @@ -2149,8 +2146,8 @@ class Player final: public Unit void SendUpdateWorldState(uint32 Field, uint32 Value) const; void SendDirectMessage(WorldPacket* data) const; - uint32 GetTotalPlayedTime() const { return m_Played_time[PLAYED_TIME_TOTAL]; } - uint32 GetLevelPlayedTime() const { return m_Played_time[PLAYED_TIME_LEVEL]; } + uint32 GetTotalPlayedTime() const { return m_playedTime[PLAYED_TIME_TOTAL]; } + uint32 GetLevelPlayedTime() const { return m_playedTime[PLAYED_TIME_LEVEL]; } void AddSkippedUpdateTime(uint32 t) { m_skippedUpdateTime += t; } uint32 GetSkippedUpdateTime() const { return m_skippedUpdateTime; } diff --git a/src/game/Objects/Unit.cpp b/src/game/Objects/Unit.cpp index 4033b8508..1e7f26889 100644 --- a/src/game/Objects/Unit.cpp +++ b/src/game/Objects/Unit.cpp @@ -3309,7 +3309,7 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder* holder) // add aura, register in lists and arrays m_spellAuraHolders.insert(SpellAuraHolderMap::value_type(holder->GetId(), holder)); - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) if (Aura* aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) AddAuraToModList(aur); @@ -3402,7 +3402,7 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder* holder) uint32 firstInChain = 0; bool dmgPeriodic = false; - for (int eff = 0; eff < MAX_EFFECT_INDEX; ++eff) + for (uint8 eff = 0; eff < MAX_EFFECT_INDEX; ++eff) { if (Aura* aura = holder->GetAuraByEffectIndex(SpellEffectIndex(eff))) { @@ -4297,7 +4297,7 @@ void Unit::HandleTriggers(Unit* pVictim, uint32 procExtra, uint32 amount, SpellE if (spellProcEvent && spellProcEvent->cooldown) cooldown = spellProcEvent->cooldown; - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { Aura* triggeredByAura = triggeredByHolder->GetAuraByEffectIndex(SpellEffectIndex(i)); if (!triggeredByAura) @@ -7870,11 +7870,11 @@ CharmInfo* Unit::InitCharmInfo(Unit* charm) } CharmInfo::CharmInfo(Unit* unit) - : m_unit(unit), m_originalFactionTemplate(nullptr), m_CommandState(COMMAND_FOLLOW), m_reactState(REACT_PASSIVE), m_petnumber(0), + : m_unit(unit), m_originalFactionTemplate(nullptr), m_commandState(COMMAND_FOLLOW), m_reactState(REACT_PASSIVE), m_petNumber(0), m_isCommandAttack(false), m_isCommandFollow(false), m_isAtStay(false), m_isFollowing(false), m_isReturning(false), m_stayX(0.0f), m_stayY(0.0f), m_stayZ(0.0f) { - for (auto& itr : m_charmspells) + for (auto& itr : m_charmSpells) itr.SetActionAndType(0, ACT_DISABLED); } @@ -7943,18 +7943,18 @@ void CharmInfo::InitCharmCreateSpells() if (!spellId) { - m_charmspells[x].SetActionAndType(spellId, ACT_DISABLED); + m_charmSpells[x].SetActionAndType(spellId, ACT_DISABLED); continue; } if (Spells::IsPassiveSpell(spellId)) { m_unit->CastSpell(m_unit, spellId, true); - m_charmspells[x].SetActionAndType(spellId, ACT_PASSIVE); + m_charmSpells[x].SetActionAndType(spellId, ACT_PASSIVE); } else { - m_charmspells[x].SetActionAndType(spellId, ACT_DISABLED); + m_charmSpells[x].SetActionAndType(spellId, ACT_DISABLED); ActiveStates newstate; bool onlyselfcast = true; @@ -7987,18 +7987,18 @@ void CharmInfo::InitCharmCreateSpells() } } -bool CharmInfo::AddSpellToActionBar(uint32 spell_id, ActiveStates newstate) +bool CharmInfo::AddSpellToActionBar(uint32 spellId, ActiveStates newstate) { - uint32 first_id = sSpellMgr.GetFirstSpellInChain(spell_id); + uint32 first_id = sSpellMgr.GetFirstSpellInChain(spellId); // new spell rank can be already listed - for (auto& i : PetActionBar) + for (auto& i : m_petActionBar) { if (uint32 action = i.GetAction()) { if (i.IsActionBarForSpell() && sSpellMgr.GetFirstSpellInChain(action) == first_id) { - i.SetAction(spell_id); + i.SetAction(spellId); return true; } } @@ -8007,24 +8007,24 @@ bool CharmInfo::AddSpellToActionBar(uint32 spell_id, ActiveStates newstate) // or use empty slot in other case for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) { - if (!PetActionBar[i].GetAction() && PetActionBar[i].IsActionBarForSpell()) + if (!m_petActionBar[i].GetAction() && m_petActionBar[i].IsActionBarForSpell()) { - SetActionBar(i, spell_id, newstate == ACT_DECIDE ? ACT_DISABLED : newstate); + SetActionBar(i, spellId, newstate == ACT_DECIDE ? ACT_DISABLED : newstate); return true; } } return false; } -bool CharmInfo::RemoveSpellFromActionBar(uint32 spell_id) +bool CharmInfo::RemoveSpellFromActionBar(uint32 spellId) { - uint32 first_id = sSpellMgr.GetFirstSpellInChain(spell_id); + uint32 first_id = sSpellMgr.GetFirstSpellInChain(spellId); for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) { - if (uint32 action = PetActionBar[i].GetAction()) + if (uint32 action = m_petActionBar[i].GetAction()) { - if (PetActionBar[i].IsActionBarForSpell() && sSpellMgr.GetFirstSpellInChain(action) == first_id) + if (m_petActionBar[i].IsActionBarForSpell() && sSpellMgr.GetFirstSpellInChain(action) == first_id) { SetActionBar(i, 0, ACT_DISABLED); return true; @@ -8040,16 +8040,16 @@ void CharmInfo::ToggleCreatureAutocast(uint32 spellid, bool apply) if (Spells::IsPassiveSpell(spellid)) return; - for (auto& itr : m_charmspells) + for (auto& itr : m_charmSpells) if (spellid == itr.GetAction()) itr.SetType(apply ? ACT_ENABLED : ACT_DISABLED); } -void CharmInfo::SetPetNumber(uint32 petnumber, bool statwindow) +void CharmInfo::SetPetNumber(uint32 petNumber, bool statWindow) { - m_petnumber = petnumber; - if (statwindow) - m_unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, m_petnumber); + m_petNumber = petNumber; + if (statWindow) + m_unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, m_petNumber); else m_unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, 0); } @@ -8072,25 +8072,25 @@ void CharmInfo::LoadPetActionBar(std::string const& data) ++iter; uint32 action = atol((*iter).c_str()); - PetActionBar[index].SetActionAndType(action, ActiveStates(type)); + m_petActionBar[index].SetActionAndType(action, ActiveStates(type)); // check correctness - if (PetActionBar[index].IsActionBarForSpell() && !sSpellMgr.GetSpellEntry(PetActionBar[index].GetAction())) + if (m_petActionBar[index].IsActionBarForSpell() && !sSpellMgr.GetSpellEntry(m_petActionBar[index].GetAction())) SetActionBar(index, 0, ACT_DISABLED); } } void CharmInfo::BuildActionBar(WorldPacket* data) { - for (const auto& i : PetActionBar) + for (const auto& i : m_petActionBar) *data << uint32(i.packedData); } -void CharmInfo::SetSpellAutocast(uint32 spell_id, bool state) +void CharmInfo::SetSpellAutocast(uint32 spellId, bool state) { - for (auto& i : PetActionBar) + for (auto& i : m_petActionBar) { - if (spell_id == i.GetAction() && i.IsActionBarForSpell()) + if (spellId == i.GetAction() && i.IsActionBarForSpell()) { i.SetType(state ? ACT_ENABLED : ACT_DISABLED); break; @@ -9815,7 +9815,7 @@ SpellAuraHolder* Unit::AddAura(uint32 spellId, uint32 addAuraFlags, Unit* pCaste if (addAuraFlags & ADD_AURA_PERMANENT) holder->SetPermanent(true); - for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { uint8 eff = spellInfo->Effect[i]; if (eff >= TOTAL_SPELL_EFFECTS) diff --git a/src/game/Objects/Unit.h b/src/game/Objects/Unit.h index 11ff5fd9a..c07ae26ee 100644 --- a/src/game/Objects/Unit.h +++ b/src/game/Objects/Unit.h @@ -228,12 +228,12 @@ typedef UnitActionBarEntry CharmSpellEntry; struct CharmInfo { explicit CharmInfo(Unit* unit); - uint32 GetPetNumber() const { return m_petnumber; } - void SetPetNumber(uint32 petnumber, bool statwindow); + uint32 GetPetNumber() const { return m_petNumber; } + void SetPetNumber(uint32 petNumber, bool statWindow); - void SetCommandState(CommandStates st) { m_CommandState = st; } - CommandStates GetCommandState() const { return m_CommandState; } - bool HasCommandState(CommandStates state) const { return m_CommandState == state; } + void SetCommandState(CommandStates state) { m_commandState = state; } + CommandStates GetCommandState() const { return m_commandState; } + bool HasCommandState(CommandStates state) const { return m_commandState == state; } void SetReactState(ReactStates st) { m_reactState = st; } ReactStates GetReactState() const { return m_reactState; } bool HasReactState(ReactStates state) const { return m_reactState == state; } @@ -247,20 +247,20 @@ struct CharmInfo void InitEmptyActionBar(); //return true if successful - bool AddSpellToActionBar(uint32 spellid, ActiveStates newstate = ACT_DECIDE); - bool RemoveSpellFromActionBar(uint32 spell_id); + bool AddSpellToActionBar(uint32 spellId, ActiveStates newstate = ACT_DECIDE); + bool RemoveSpellFromActionBar(uint32 spellId); void LoadPetActionBar(std::string const& data); void BuildActionBar(WorldPacket* data); - void SetSpellAutocast(uint32 spell_id, bool state); + void SetSpellAutocast(uint32 spellId, bool state); void SetActionBar(uint8 index, uint32 spellOrAction,ActiveStates type) { - PetActionBar[index].SetActionAndType(spellOrAction,type); + m_petActionBar[index].SetActionAndType(spellOrAction,type); } - UnitActionBarEntry const* GetActionBarEntry(uint8 index) const { return &(PetActionBar[index]); } + UnitActionBarEntry const* GetActionBarEntry(uint8 index) const { return &(m_petActionBar[index]); } void ToggleCreatureAutocast(uint32 spellid, bool apply); - CharmSpellEntry* GetCharmSpell(uint8 index) { return &(m_charmspells[index]); } + CharmSpellEntry* GetCharmSpell(uint8 index) { return &(m_charmSpells[index]); } void SetIsCommandAttack(bool val); bool IsCommandAttack(); @@ -279,11 +279,11 @@ private: Unit* m_unit; FactionTemplateEntry const* m_originalFactionTemplate; - UnitActionBarEntry PetActionBar[MAX_UNIT_ACTION_BAR_INDEX]; - CharmSpellEntry m_charmspells[CREATURE_MAX_SPELLS]; - CommandStates m_CommandState; + UnitActionBarEntry m_petActionBar[MAX_UNIT_ACTION_BAR_INDEX]; + CharmSpellEntry m_charmSpells[CREATURE_MAX_SPELLS]; + CommandStates m_commandState; ReactStates m_reactState; - uint32 m_petnumber; + uint32 m_petNumber; bool m_isCommandAttack; bool m_isCommandFollow; @@ -805,13 +805,13 @@ class Unit : public SpellCaster uint64 GetAuraApplicationMask() const; uint64 GetNegativeAuraApplicationMask() const; - SpellAuraHolderBounds GetSpellAuraHolderBounds(uint32 spell_id) + SpellAuraHolderBounds GetSpellAuraHolderBounds(uint32 spellId) { - return m_spellAuraHolders.equal_range(spell_id); + return m_spellAuraHolders.equal_range(spellId); } - SpellAuraHolderConstBounds GetSpellAuraHolderBounds(uint32 spell_id) const + SpellAuraHolderConstBounds GetSpellAuraHolderBounds(uint32 spellId) const { - return m_spellAuraHolders.equal_range(spell_id); + return m_spellAuraHolders.equal_range(spellId); } bool HasAuraType(AuraType auraType) const; diff --git a/src/game/PlayerBots/CombatBotBaseAI.cpp b/src/game/PlayerBots/CombatBotBaseAI.cpp index 9342bb0cf..ce3bfc450 100644 --- a/src/game/PlayerBots/CombatBotBaseAI.cpp +++ b/src/game/PlayerBots/CombatBotBaseAI.cpp @@ -2263,7 +2263,7 @@ bool CombatBotBaseAI::IsValidDispelTarget(Unit const* pTarget, SpellEntry const* uint32 dispelMask = 0; bool bFoundOneDispell = false; // Compute Dispel Mask - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (pSpellEntry->Effect[i] != SPELL_EFFECT_DISPEL) continue; diff --git a/src/game/PlayerBots/PlayerBotAI.cpp b/src/game/PlayerBots/PlayerBotAI.cpp index a8b1db2b8..73ee26f86 100644 --- a/src/game/PlayerBots/PlayerBotAI.cpp +++ b/src/game/PlayerBots/PlayerBotAI.cpp @@ -92,7 +92,6 @@ bool PlayerBotAI::SpawnNewPlayer(WorldSession* sess, uint8 class_, uint32 race_, newChar->SetLocationInstanceId(instanceId); newChar->SetAutoInstanceSwitch(false); newChar->GetMotionMaster()->Initialize(); - newChar->SetCinematic(1); // Set instance if (instanceId && mapId > 1) // Not a continent { diff --git a/src/game/PlayerBots/PlayerBotAI.h b/src/game/PlayerBots/PlayerBotAI.h index c0fb7e68c..c78ed7801 100644 --- a/src/game/PlayerBots/PlayerBotAI.h +++ b/src/game/PlayerBots/PlayerBotAI.h @@ -41,7 +41,7 @@ class PlayerBotAI: public PlayerAI virtual void OnPlayerLogin() {} virtual void BeforeAddToMap(Player* player) {} // me=nullptr at call // Helpers - bool SpawnNewPlayer(WorldSession* sess, uint8 _class, uint32 _race, uint32 mapId, uint32 instanceId, float dx, float dy, float dz, float o, Player* pClone = nullptr); + bool SpawnNewPlayer(WorldSession* sess, uint8 classId, uint32 raceId, uint32 mapId, uint32 instanceId, float dx, float dy, float dz, float o, Player* pClone = nullptr); PlayerBotEntry* botEntry; }; @@ -49,23 +49,23 @@ class PlayerCreatorAI: public PlayerBotAI { public: explicit PlayerCreatorAI(Player* pPlayer, uint8 _race_, uint8 _class_, uint32 mapId, uint32 instanceId, float x, float y, float z, float o) : - PlayerBotAI(pPlayer), _race(_race_), _class(_class_), _mapId(mapId), _instanceId(instanceId), _x(x), _y(y), _z(z), _o(o) + PlayerBotAI(pPlayer), m_race(_race_), m_class(_class_), m_mapId(mapId), m_instanceId(instanceId), m_x(x), m_y(y), m_z(z), m_o(o) { } ~PlayerCreatorAI() override {} bool OnSessionLoaded(PlayerBotEntry* entry, WorldSession* sess) override { - return SpawnNewPlayer(sess, _class, _race, _mapId, _instanceId, _x, _y, _z, _o); + return SpawnNewPlayer(sess, m_class, m_race, m_mapId, m_instanceId, m_x, m_y, m_z, m_o); } protected: - uint8 _race; - uint8 _class; - uint32 _mapId; - uint32 _instanceId; - float _x; - float _y; - float _z; - float _o; + uint8 m_race; + uint8 m_class; + uint32 m_mapId; + uint32 m_instanceId; + float m_x; + float m_y; + float m_z; + float m_o; }; class PlayerBotFleeingAI : public PlayerBotAI diff --git a/src/game/PlayerDump.cpp b/src/game/PlayerDump.cpp index 6918a892e..43380a5aa 100644 --- a/src/game/PlayerDump.cpp +++ b/src/game/PlayerDump.cpp @@ -53,7 +53,6 @@ static DumpTable dumpTables[] = { "character_skills", DTT_CHAR_TABLE }, { "character_spell", DTT_CHAR_TABLE }, { "character_spell_cooldown", DTT_CHAR_TABLE }, - { "character_ticket", DTT_CHAR_TABLE }, { "mail", DTT_MAIL }, // -> mail guids { "mail_items", DTT_MAIL_ITEM }, // -> item guids <- mail guids { "pet_aura", DTT_PET_TABLE }, // <- pet number @@ -357,7 +356,7 @@ void PlayerDumpWriter::DumpTableContent(std::string& dump, uint32 guid, char con // item text id collection case DTT_PET: StoreGUID(result, 0, pets); - break; // pet petnumber collection (character_pet.id) + break; // pet pet number collection (character_pet.id) case DTT_MAIL: StoreGUID(result, 0, mails); // mail id collection (mail.id) StoreGUID(result, 7, texts); @@ -583,7 +582,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s { delete result; - if (!changenth(line, 35, "1")) // characters.at_login set to "rename on login" + if (!changenth(line, 35, "1")) // characters.at_login_flags set to "rename on login" ROLLBACK(DUMP_FILE_BROKEN); } } @@ -654,7 +653,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s if (!changenth(line, 1, newpetid)) // character_pet.id update ROLLBACK(DUMP_FILE_BROKEN); - if (!changenth(line, 3, newguid)) // character_pet.owner update + if (!changenth(line, 3, newguid)) // character_pet.owner_guid update ROLLBACK(DUMP_FILE_BROKEN); break; @@ -691,7 +690,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s ROLLBACK(DUMP_FILE_BROKEN); // mail_items.id if (!changeGuid(line, 2, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) ROLLBACK(DUMP_FILE_BROKEN); // mail_items.item_guid - if (!changenth(line, 4, newguid)) // mail_items.receiver + if (!changenth(line, 4, newguid)) // mail_items.receiver_guid ROLLBACK(DUMP_FILE_BROKEN); break; } diff --git a/src/game/PlayerDump.h b/src/game/PlayerDump.h index 7c7e188a9..e778f1517 100644 --- a/src/game/PlayerDump.h +++ b/src/game/PlayerDump.h @@ -32,7 +32,7 @@ enum DumpTableType DTT_CHAR_TABLE, // // character_action, character_aura, character_homebind, // character_queststatus, character_reputation, - // character_spell, character_spell_cooldown, character_ticket, + // character_spell, character_spell_cooldown, // character_tutorial DTT_INVENTORY, // -> item guids collection // character_inventory diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp index 6d1b11a87..27b6f45a1 100644 --- a/src/game/ScriptMgr.cpp +++ b/src/game/ScriptMgr.cpp @@ -439,12 +439,12 @@ void ScriptMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename) case SCRIPT_COMMAND_REMOVE_ITEM: case SCRIPT_COMMAND_CREATE_ITEM: { - if (!ObjectMgr::GetItemPrototype(tmp.createItem.itemEntry)) + if (!ObjectMgr::GetItemPrototype(tmp.createItem.itemId)) { - if (!sObjectMgr.IsExistingItemId(tmp.createItem.itemEntry)) + if (!sObjectMgr.IsExistingItemId(tmp.createItem.itemId)) { sLog.outErrorDb("Table `%s` has nonexistent item (entry: %u) in SCRIPT_COMMAND_*_ITEM for script id %u", - tablename, tmp.createItem.itemEntry, tmp.id); + tablename, tmp.createItem.itemId, tmp.id); continue; } else @@ -473,7 +473,7 @@ void ScriptMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename) { if (!ObjectMgr::GetItemPrototype(tmp.setEquipment.slot[i])) { - if (!sObjectMgr.IsExistingItemId(tmp.createItem.itemEntry)) + if (!sObjectMgr.IsExistingItemId(tmp.createItem.itemId)) { sLog.outErrorDb("Table `%s` has nonexistent item (dataint%i: %u) in SCRIPT_COMMAND_SET_EQUIPMENT for script id %u", tablename, i, tmp.setEquipment.slot[i], tmp.id); @@ -2495,7 +2495,7 @@ void ScriptMgr::CollectPossibleEventIds(std::set& eventIds) SpellEntry const* spell = sSpellMgr.GetSpellEntry(i); if (spell) { - for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { if (spell->Effect[j] == SPELL_EFFECT_SEND_EVENT) { diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp index ae4f8fe1f..733766dd9 100644 --- a/src/game/Spells/Spell.cpp +++ b/src/game/Spells/Spell.cpp @@ -300,7 +300,7 @@ Spell::Spell(Unit* caster, SpellEntry const* info, bool triggered, ObjectGuid or m_originalCasterGUID = originalCasterGUID ? originalCasterGUID : caster->GetObjectGuid(); UpdateOriginalCasterPointer(); - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) m_currentBasePoints[i] = m_spellInfo->CalculateSimpleValue(SpellEffectIndex(i)); m_TriggerSpells.clear(); @@ -333,7 +333,7 @@ Spell::Spell(GameObject* caster, SpellEntry const* info, bool triggered, ObjectG m_originalCasterGUID = originalCasterGUID ? originalCasterGUID : caster->GetObjectGuid(); UpdateOriginalCasterPointer(); - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) m_currentBasePoints[i] = m_spellInfo->CalculateSimpleValue(SpellEffectIndex(i)); m_TriggerSpells.clear(); @@ -385,7 +385,7 @@ void Spell::FillTargetMap() { // TODO: ADD the correct target FILLS!!!!!! - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { // not call for empty effect. // Also some spells use not used effect targets for store targets for dummy effect in triggered spells @@ -873,7 +873,7 @@ void Spell::prepareDataForTriggerSystem() // some negative spells have positive effects to another or same targets // avoid triggering negative hit for only positive targets m_negativeEffectMask = 0x0; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (!m_spellInfo->IsPositiveEffect(SpellEffectIndex(i))) m_negativeEffectMask |= (1 << i); @@ -1188,7 +1188,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) if (m_delayed) { // mark effects that were already handled in Spell::HandleDelayedSpellLaunch on spell launch as processed - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) if (m_spellInfo->IsEffectHandledOnDelayedSpellLaunch(SpellEffectIndex(i))) mask &= ~(1 << i); @@ -1283,7 +1283,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) #if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_9_4 // If healing crits, we need to update the execute log data. - for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (m_executeLogInfo[i].empty()) continue; @@ -1587,7 +1587,7 @@ void Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask) } // Check mechanic resistance for each effect - for (int eff = 0; eff < MAX_EFFECT_INDEX; ++eff) + for (uint8 eff = 0; eff < MAX_EFFECT_INDEX; ++eff) if (unit->IsEffectResist(m_spellInfo, eff)) { effectMask &= ~(1 << eff); @@ -1921,7 +1921,7 @@ void Spell::HandleDelayedSpellLaunch(TargetInfo *target) void Spell::InitializeDamageMultipliers() { - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (m_spellInfo->Effect[i] == 0) continue; @@ -1946,7 +1946,7 @@ bool Spell::HasValidUnitPresentInTargetList() { uint8 foundMask = 0; uint8 needTargetsMask = 0; - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) if (m_spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && m_spellInfo->EffectApplyAuraName[i]) if (m_spellInfo->EffectImplicitTargetA[i] != TARGET_UNIT_CASTER) needTargetsMask |= 1 << i; @@ -4055,7 +4055,7 @@ void Spell::_handle_immediate_phase() HandleThreatSpells(); m_needSpellLog = IsNeedSendToClient(); - for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { if (m_spellInfo->Effect[j] == 0) continue; @@ -4081,7 +4081,7 @@ void Spell::_handle_immediate_phase() DoAllEffectOnTarget(&ihit); // process ground - for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { // persistent area auras target only the ground if (m_spellInfo->Effect[j] == SPELL_EFFECT_PERSISTENT_AREA_AURA) @@ -4149,7 +4149,7 @@ void Spell::update(uint32 difftime) if (m_casterUnit) { // except if its a self root, since player could have moved a bit before root ack (ravager proc) - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if ((m_spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA) && ((m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_ROOT) || (m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STUN)) && @@ -4810,7 +4810,7 @@ void Spell::SendLogExecute() data << uint32(effectCount); - for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (m_executeLogInfo[i].empty()) continue; @@ -5287,7 +5287,7 @@ void Spell::HandleThreatSpells() bool positive = true; uint8 effectMask = 0; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) if (m_spellInfo->Effect[i]) effectMask |= (1 << i); @@ -5880,7 +5880,7 @@ SpellCastResult Spell::CheckCast(bool strict) // Database based targets from spell_target_script if (m_UniqueTargetInfo.empty()) // skip second CheckCast apply (for delayed spells for example) { - for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_UNIT_SCRIPT_NEAR_CASTER || (m_spellInfo->EffectImplicitTargetB[j] == TARGET_UNIT_SCRIPT_NEAR_CASTER && m_spellInfo->EffectImplicitTargetA[j] != TARGET_UNIT_CASTER) || @@ -6107,7 +6107,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_BAD_TARGETS; } - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { // for effects of spells that have only one target switch (m_spellInfo->Effect[i]) @@ -6677,7 +6677,7 @@ SpellCastResult Spell::CheckCast(bool strict) uint32 dispelMask = 0; bool bFoundOneDispell = false; // Compute Dispel Mask - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (m_spellInfo->Effect[i] != SPELL_EFFECT_DISPEL) continue; @@ -6753,7 +6753,7 @@ SpellCastResult Spell::CheckCast(bool strict) #endif } - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { switch (m_spellInfo->EffectApplyAuraName[i]) { @@ -7087,7 +7087,7 @@ SpellCastResult Spell::CheckCasterAuras() const // We use bitmasks so the loop is done only once and not on every aura check below. if (m_spellInfo->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) { - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_SCHOOL_IMMUNITY) school_immune |= uint32(m_spellInfo->EffectMiscValue[i]); @@ -7134,7 +7134,7 @@ SpellCastResult Spell::CheckCasterAuras() const if ((1 << (pEntry->Dispel)) & dispel_immune) continue; - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { Aura* aura = holder->GetAuraByEffectIndex(SpellEffectIndex(i)); if (!aura) @@ -7200,7 +7200,7 @@ bool Spell::CanAutoCast(Unit* target) if (!m_spellInfo->HasEffect(SPELL_EFFECT_SCHOOL_DAMAGE)) { - for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { if (m_spellInfo->Effect[j] == SPELL_EFFECT_APPLY_AURA) { @@ -7506,7 +7506,7 @@ SpellCastResult Spell::CheckItems() { // such items should only fail if there is no suitable effect at all - see Rejuvenation Potions for example SpellCastResult failReason = SPELL_CAST_OK; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { // skip check, pet not required like checks, and for TARGET_UNIT_CASTER_PET m_targets.getUnitTarget() is not the real target but the caster if (m_spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_CASTER_PET) @@ -7716,7 +7716,7 @@ SpellCastResult Spell::CheckItems() } } } - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { switch (m_spellInfo->Effect[i]) { @@ -7946,7 +7946,7 @@ void Spell::DelayedChannel() } } - for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { // partially interrupt persistent area auras if (DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id, SpellEffectIndex(j))) diff --git a/src/game/Spells/SpellAuras.cpp b/src/game/Spells/SpellAuras.cpp index 73eae9712..4250c8168 100644 --- a/src/game/Spells/SpellAuras.cpp +++ b/src/game/Spells/SpellAuras.cpp @@ -346,7 +346,7 @@ void SpellAuraHolder::Refresh(Unit* caster, Unit* target, SpellAuraHolder* pRefr m_applyTime = time(nullptr); m_duration = pRefreshWithHolder->GetAuraDuration(); m_maxDuration = pRefreshWithHolder->GetAuraMaxDuration(); - for (int i = 0 ; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0 ; i < MAX_EFFECT_INDEX; ++i) { if (Aura* pAura = GetAuraByEffectIndex(SpellEffectIndex(i))) pAura->Refresh(caster, target, pRefreshWithHolder); @@ -6468,7 +6468,7 @@ void Aura::HandleManaShield(bool apply, bool Real) bool Aura::IsLastAuraOnHolder() { - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) if (i != GetEffIndex() && GetHolder()->m_auras[i]) return false; return true; @@ -6565,7 +6565,7 @@ void SpellAuraHolder::RemoveAura(SpellEffectIndex index) void SpellAuraHolder::ApplyAuraModifiers(bool apply, bool real) { - for (int32 i = 0; i < MAX_EFFECT_INDEX && !IsDeleted(); ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX && !IsDeleted(); ++i) if (Aura* aur = GetAuraByEffectIndex(SpellEffectIndex(i))) aur->ApplyModifier(apply, real); } @@ -6739,7 +6739,7 @@ void SpellAuraHolder::_RemoveSpellAuraHolder() void SpellAuraHolder::CleanupTriggeredSpells() { - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (!m_spellProto->EffectApplyAuraName[i]) continue; @@ -6801,7 +6801,7 @@ void SpellAuraHolder::SetStackAmount(uint32 stackAmount) m_stackAmount = stackAmount; UpdateAuraApplication(); - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (Aura* aur = m_auras[i]) { @@ -6898,7 +6898,7 @@ bool SpellAuraHolder::IsNeedVisibleSlot(Unit const* caster) const bool persistent = m_spellProto->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_PERSISTENT_AREA_AURA; bool persistentWithSecondaryEffect = false; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { // Check for persistent aura here since the effect aura is applied to the holder // by a dynamic object as the target passes through the object field, meaning @@ -7218,7 +7218,7 @@ void SpellAuraHolder::RefreshHolder() */ void SpellAuraHolder::RefreshAuraPeriodicTimers(int32 duration) { - for (int i = 0 ; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0 ; i < MAX_EFFECT_INDEX; ++i) { if (Aura* pAura = GetAuraByEffectIndex(SpellEffectIndex(i))) { @@ -7247,7 +7247,7 @@ bool SpellAuraHolder::HasMechanic(uint32 mechanic) const if (mechanic == m_spellProto->Mechanic) return true; - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) if (m_auras[i] && m_spellProto->EffectMechanic[i] == mechanic) return true; return false; @@ -7258,7 +7258,7 @@ bool SpellAuraHolder::HasMechanicMask(uint32 mechanicMask) const if (m_spellProto->Mechanic && mechanicMask & (1 << (m_spellProto->Mechanic - 1))) return true; - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) if (m_auras[i] && m_spellProto->EffectMechanic[i] && ((1 << (m_spellProto->EffectMechanic[i] - 1)) & mechanicMask)) return true; return false; diff --git a/src/game/Spells/SpellEffects.cpp b/src/game/Spells/SpellEffects.cpp index 5e45b671d..19b3c4953 100644 --- a/src/game/Spells/SpellEffects.cpp +++ b/src/game/Spells/SpellEffects.cpp @@ -4143,7 +4143,7 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) // multiple weapon dmg effect workaround // execute only the last weapon damage // and handle all effects at once - for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { switch (m_spellInfo->Effect[j]) { @@ -4151,7 +4151,7 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: - if (j < int(eff_idx)) // we must calculate only at last weapon effect + if (j < uint8(eff_idx)) // we must calculate only at last weapon effect return; break; } @@ -4178,7 +4178,7 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) } float bonus = 0.f; - for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { switch (m_spellInfo->Effect[j]) { diff --git a/src/game/Spells/SpellEntry.cpp b/src/game/Spells/SpellEntry.cpp index d493ebaa8..7d4e89509 100644 --- a/src/game/Spells/SpellEntry.cpp +++ b/src/game/Spells/SpellEntry.cpp @@ -157,7 +157,7 @@ SpellSpecific Spells::GetSpellSpecific(uint32 spellId) // Attack speed reduction if (spellInfo->HasSingleAura(SPELL_AURA_MOD_MELEE_HASTE)) - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) if (AuraType(spellInfo->EffectApplyAuraName[i]) == SPELL_AURA_MOD_MELEE_HASTE && spellInfo->EffectBasePoints[i] < 0) return SPELL_NEGATIVE_HASTE; @@ -176,7 +176,7 @@ int32 Spells::CompareAuraRanks(uint32 spellId_1, uint32 spellId_2) if (!spellInfo_1 || !spellInfo_2) return 0; if (spellId_1 == spellId_2) return 0; - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellInfo_1->Effect[i] != 0 && spellInfo_2->Effect[i] != 0 && spellInfo_1->Effect[i] == spellInfo_2->Effect[i]) { @@ -194,9 +194,9 @@ bool Spells::CompareSpellSpecificAuras(SpellEntry const* spellInfo_1, SpellEntry if (!spellInfo_1 || !spellInfo_2) return 0; if (spellInfo_1 == spellInfo_2) return 0; - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { - for (int32 j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { if (spellInfo_1->Effect[i] == SPELL_EFFECT_APPLY_AURA && spellInfo_1->EffectApplyAuraName[i] == spellInfo_2->EffectApplyAuraName[j]) @@ -626,11 +626,11 @@ uint32 SpellEntry::GetCastTimeForBonus(DamageEffectType damagetype) const bool DirectDamage = false; bool AreaEffect = false; - for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) if (IsAreaEffectTarget(SpellTarget(EffectImplicitTargetA[i])) || IsAreaEffectTarget(SpellTarget(EffectImplicitTargetB[i]))) AreaEffect = true; - for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { switch (Effect[i]) { @@ -696,10 +696,10 @@ uint32 SpellEntry::GetCastTimeForBonus(DamageEffectType damagetype) const CastingTime /= 2; // 50% for damage and healing spells for leech spells from damage bonus and 0% from healing - for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { if (Effect[j] == SPELL_EFFECT_HEALTH_LEECH || - (Effect[j] == SPELL_EFFECT_APPLY_AURA && EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH)) + (Effect[j] == SPELL_EFFECT_APPLY_AURA && EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH)) { CastingTime /= 2; break; @@ -853,7 +853,7 @@ uint16 SpellEntry::GetAuraMaxTicks() const if (DotDuration > 30000) DotDuration = 30000; - for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { if (Effect[j] == SPELL_EFFECT_APPLY_AURA && ( EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_DAMAGE || @@ -875,7 +875,7 @@ bool SpellEntry::IsPositiveSpell(WorldObject const* caster, WorldObject const* v return false; // spells with at least one negative effect are considered negative // some self-applied spells have negative effects but in self casting case negative check ignored. - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) if (Effect[i] && !IsPositiveEffect(SpellEffectIndex(i), caster, victim)) return false; return true; @@ -991,7 +991,7 @@ bool SpellEntry::IsPositiveEffect(SpellEffectIndex effIndex, WorldObject const* if (spellTriggeredProto) { // non-positive targets of main spell return early - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { // if non-positive trigger cast targeted to positive target this main cast is non-positive // this will place this spell auras as debuffs diff --git a/src/game/Spells/SpellEntry.h b/src/game/Spells/SpellEntry.h index 859ac9170..cd855b221 100644 --- a/src/game/Spells/SpellEntry.h +++ b/src/game/Spells/SpellEntry.h @@ -597,7 +597,7 @@ class SpellEntry inline bool IsSpellAppliesAura(uint32 effectMask) const { - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (effectMask & (1 << i)) { @@ -692,7 +692,7 @@ class SpellEntry inline bool HasSingleAura(AuraType aura) const { bool hasAura = false; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) if (AuraType(EffectApplyAuraName[i]) == aura) hasAura = true; else if (Effect[i] == SPELL_EFFECT_APPLY_AURA) @@ -789,7 +789,7 @@ class SpellEntry { // spells with at least one negative effect are considered negative // some self-applied spells have negative effects but in self casting case negative check ignored. - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) if (Effect[i] && (effectMask & (1 << i)) && !IsPositiveEffect(SpellEffectIndex(i), caster, target)) return false; return true; @@ -904,7 +904,7 @@ class SpellEntry // Spell effects require a specific power type on the target inline bool IsTargetPowerTypeValid(Powers powerType) const { - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (Effect[i] == SPELL_EFFECT_NONE) continue; @@ -940,7 +940,7 @@ class SpellEntry if (Mechanic) mask |= 1 << (Mechanic - 1); - for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (!(effectMask & (1 << i))) continue; diff --git a/src/game/Spells/SpellMgr.cpp b/src/game/Spells/SpellMgr.cpp index 926e1d872..765a68566 100644 --- a/src/game/Spells/SpellMgr.cpp +++ b/src/game/Spells/SpellMgr.cpp @@ -101,7 +101,7 @@ void SpellMgr::LoadSpellTargetPositions() } bool found = false; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellInfo->EffectImplicitTargetA[i] == TARGET_LOCATION_DATABASE || spellInfo->EffectImplicitTargetB[i] == TARGET_LOCATION_DATABASE) { @@ -202,7 +202,7 @@ struct DoSpellProcEvent if (spe.spellFamilyName != r_spe.spellFamilyName) sLog.outErrorDb("Spell %u listed in `spell_proc_event` as custom rank have different spellFamilyName from first rank in chain", spell_id); - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spe.spellFamilyMask[i] != r_spe.spellFamilyMask[i]) { @@ -345,7 +345,7 @@ void SpellMgr::LoadSpellProcEvents() spe.schoolMask = fields[1].GetUInt32(); spe.spellFamilyName = fields[2].GetUInt32(); - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) spe.spellFamilyMask[i] = fields[3 + i].GetUInt64(); spe.procFlags = fields[6].GetUInt32(); @@ -1230,7 +1230,7 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons ) { bool isModifier = false; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellInfo_1->EffectApplyAuraName[i] == SPELL_AURA_ADD_FLAT_MODIFIER || spellInfo_1->EffectApplyAuraName[i] == SPELL_AURA_ADD_PCT_MODIFIER || @@ -1263,7 +1263,7 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons return false; bool dummy_only = true; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellInfo_1->Effect[i] != spellInfo_2->Effect[i] || spellInfo_1->EffectItemType[i] != spellInfo_2->EffectItemType[i] || @@ -1357,7 +1357,7 @@ SpellEntry const* SpellMgr::SelectAuraRankForLevel(SpellEntry const* spellInfo, return spellInfo; bool needRankSelection = false; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { // for simple aura in check apply to any non caster based targets, in rank search mode to any explicit targets if (((spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && @@ -1819,7 +1819,7 @@ void SpellMgr::LoadSpellLearnSkills() if (!entry) continue; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (entry->Effect[i] == SPELL_EFFECT_SKILL) { @@ -1955,7 +1955,7 @@ void SpellMgr::LoadSpellLearnSpells() if (!entry) continue; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (entry->Effect[i] == SPELL_EFFECT_LEARN_SPELL) { @@ -2067,7 +2067,7 @@ void SpellMgr::LoadSpellScriptTarget() } bool targetfound = false; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellProto->EffectImplicitTargetA[i] == TARGET_UNIT_SCRIPT_NEAR_CASTER || spellProto->EffectImplicitTargetB[i] == TARGET_UNIT_SCRIPT_NEAR_CASTER || @@ -2157,7 +2157,7 @@ void SpellMgr::LoadSpellScriptTarget() continue; bool found = false; - for(int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (uint8 j = 0; j < MAX_EFFECT_INDEX; ++j) { if (spellInfo->EffectImplicitTargetA[j] == TARGET_UNIT_SCRIPT_NEAR_CASTER || spellInfo->EffectImplicitTargetA[j] != TARGET_UNIT_CASTER && spellInfo->EffectImplicitTargetB[j] == TARGET_UNIT_SCRIPT_NEAR_CASTER) { @@ -2220,7 +2220,7 @@ void SpellMgr::LoadSpellPetAuras() sLog.outErrorDb("Spell %u listed in `spell_pet_auras` does not exist", spell); continue; } - int i = 0; + uint8 i = 0; for (; i < MAX_EFFECT_INDEX; ++i) if ((spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && spellInfo->EffectApplyAuraName[i] == SPELL_AURA_DUMMY) || @@ -2262,7 +2262,7 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg) bool need_check_reagents = false; // check effects - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { switch (spellInfo->Effect[i]) { @@ -2446,7 +2446,7 @@ void SpellMgr::LoadSpellAreas() } bool validSpellEffect = false; - for (uint32 i = EFFECT_INDEX_0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = EFFECT_INDEX_0; i < MAX_EFFECT_INDEX; ++i) { switch (spellInfo->EffectApplyAuraName[i]) { @@ -3097,7 +3097,7 @@ void SpellMgr::LoadSpellAffects() if (!spellInfo) continue; - for (int effectId = 0; effectId < MAX_EFFECT_INDEX; ++effectId) + for (uint8 effectId = 0; effectId < MAX_EFFECT_INDEX; ++effectId) { if (spellInfo->Effect[effectId] != SPELL_EFFECT_APPLY_AURA || ( spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_FLAT_MODIFIER && @@ -3138,7 +3138,7 @@ namespace SpellInternal { bool IsSpellAppliesAura(SpellEntry const* spellInfo) { - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (IsEffectAppliesAura(spellInfo->Effect[i]) && spellInfo->EffectApplyAuraName[i]) return true; @@ -3152,7 +3152,7 @@ namespace SpellInternal { bool periodic = false; bool direct = false; - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { switch (spellInfo->Effect[i]) { @@ -3211,7 +3211,7 @@ namespace SpellInternal return true; } - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { switch (spellInfo->Effect[i]) { @@ -3250,7 +3250,7 @@ namespace SpellInternal bool IsSpellWithCasterSourceTargetsOnly(SpellEntry const* spellInfo) { - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { uint32 targetA = spellInfo->EffectImplicitTargetA[i]; if (targetA && !IsCasterSourceTarget(targetA)) @@ -3287,7 +3287,7 @@ namespace SpellInternal bool IsDismountSpell(SpellEntry const* spellInfo) { - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if ((spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA) && (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MECHANIC_IMMUNITY) && (spellInfo->EffectMiscValue[i] == MECHANIC_MOUNT)) return true; @@ -3328,7 +3328,7 @@ namespace SpellInternal if (spellInfo->IsChanneledSpell() || spellInfo->IsNextMeleeSwingSpell() || spellInfo->IsRangedSpell()) return false; - for (auto i = 0; i < MAX_EFFECT_INDEX; ++i) + for (uint8 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellInfo->Effect[i] && !spellInfo->IsDelayableEffect(i)) return false; diff --git a/src/game/World.cpp b/src/game/World.cpp index be5a07df6..f4647ab9a 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -574,7 +574,7 @@ void World::LoadConfigSettings(bool reload) setConfigMinMax(CONFIG_UINT32_CHARACTERS_PER_REALM, "CharactersPerRealm", 10, 1, 10); setConfigMin(CONFIG_UINT32_CHARACTERS_PER_ACCOUNT, "CharactersPerAccount", 50, getConfig(CONFIG_UINT32_CHARACTERS_PER_REALM)); - setConfigMinMax(CONFIG_UINT32_SKIP_CINEMATICS, "SkipCinematics", 0, 0, 2); + setConfig(CONFIG_BOOL_SKIP_CINEMATICS, "SkipCinematics", false); setConfig(CONFIG_BOOL_OBJECT_HEALTH_VALUE_SHOW, "ShowHealthValues", false); if (configNoReload(reload, CONFIG_UINT32_MAX_PLAYER_LEVEL, "MaxPlayerLevel", PLAYER_MAX_LEVEL)) setConfigMinMax(CONFIG_UINT32_MAX_PLAYER_LEVEL, "MaxPlayerLevel", PLAYER_MAX_LEVEL, 1, PLAYER_STRONG_MAX_LEVEL); diff --git a/src/game/World.h b/src/game/World.h index 5f1475dc6..8a36b6023 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -188,7 +188,6 @@ enum eConfigUInt32Values CONFIG_UINT32_CHARACTERS_CREATING_DISABLED, CONFIG_UINT32_CHARACTERS_PER_ACCOUNT, CONFIG_UINT32_CHARACTERS_PER_REALM, - CONFIG_UINT32_SKIP_CINEMATICS, CONFIG_UINT32_MAX_PLAYER_LEVEL, CONFIG_UINT32_START_PLAYER_LEVEL, CONFIG_UINT32_START_PLAYER_MONEY, @@ -466,6 +465,7 @@ enum eConfigBoolValues CONFIG_BOOL_OUTDOORPVP_EP_ENABLE, CONFIG_BOOL_OUTDOORPVP_SI_ENABLE, CONFIG_BOOL_MMAP_ENABLED, + CONFIG_BOOL_SKIP_CINEMATICS, CONFIG_BOOL_PLAYER_COMMANDS, CONFIG_BOOL_FORCE_LOGOUT_DELAY, CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY, diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 53635b4c1..2394ebfb3 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -372,7 +372,7 @@ class WorldSession void SendCancelTrade(); // Pet - void SendPetNameQuery(ObjectGuid guid, uint32 petnumber); + void SendPetNameQuery(ObjectGuid guid, uint32 petNumber); void SendStablePet(ObjectGuid guid); void SendStableResult(uint8 res); bool CheckStableMaster(ObjectGuid guid); @@ -422,7 +422,6 @@ class WorldSession void SendGuildCommandResult(uint32 typecmd, std::string const& str, uint32 cmdresult); void SendPetitionShowList(ObjectGuid& guid); void SendSaveGuildEmblem(uint32 msg); - void SendPetitionQueryOpcode(uint32 petitionguid); // Battleground void SendBattleGroundJoinError(uint8 err); diff --git a/src/scripts/battlegrounds/battleground_alterac.cpp b/src/scripts/battlegrounds/battleground_alterac.cpp index 140a843fc..ba995232d 100644 --- a/src/scripts/battlegrounds/battleground_alterac.cpp +++ b/src/scripts/battlegrounds/battleground_alterac.cpp @@ -1371,11 +1371,11 @@ bool GossipHello_AV_npc_ram_wolf(Player* pPlayer, Creature* pCreature) pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetObjectGuid()); /** Select corresponding item depending on NPC faction */ - uint32 itemEntry = 0; + uint32 itemId = 0; if (pCreature->GetEntry() == NPC_TAME_MASTER_HORDE) - itemEntry = FROSTWOLF_MUZZLE; + itemId = FROSTWOLF_MUZZLE; else if (pCreature->GetEntry() == NPC_TAME_MASTER_ALLIANCE) - itemEntry = STORMPIKE_TRAINING_COLLAR; + itemId = STORMPIKE_TRAINING_COLLAR; /** Prepare Quest and Creature ID depending on the NPC faction */ if (pCreature->GetEntry() == NPC_TAME_MASTER_HORDE) @@ -1399,15 +1399,15 @@ bool GossipHello_AV_npc_ram_wolf(Player* pPlayer, Creature* pCreature) } /** Give the corresponding item to the player if he don't have one already */ - if (!pPlayer->HasItemCount(itemEntry, 1, true) && isAllowedToGetItem) + if (!pPlayer->HasItemCount(itemId, 1, true) && isAllowedToGetItem) { uint32 noSpaceForCount = 0; ItemPosCountVec dest; - uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemEntry, 1, &noSpaceForCount); + uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, 1, &noSpaceForCount); if (msg == EQUIP_ERR_OK) { - Item* pItem = pPlayer->StoreNewItem(dest, itemEntry, true, Item::GenerateItemRandomPropertyId(5060)); + Item* pItem = pPlayer->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(5060)); pPlayer->SendNewItem(pItem, 1, true, false); } }