aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/AchievementMgr.cpp2
-rw-r--r--src/game/AchievementMgr.h4
-rw-r--r--src/game/CharacterHandler.cpp38
-rw-r--r--src/game/Chat.cpp1
-rw-r--r--src/game/Chat.h3
-rw-r--r--src/game/Debugcmds.cpp88
-rw-r--r--src/game/Guild.cpp19
-rw-r--r--src/game/GuildHandler.cpp4
-rw-r--r--src/game/Level1.cpp1
-rw-r--r--src/game/Level2.cpp15
-rw-r--r--src/game/Level3.cpp10
-rw-r--r--src/game/LootMgr.cpp2
-rw-r--r--src/game/Mail.cpp2
-rw-r--r--src/game/Player.cpp310
-rw-r--r--src/game/Player.h8
-rw-r--r--src/game/QueryHandler.cpp36
-rw-r--r--src/game/SharedDefines.h23
-rw-r--r--src/game/Spell.cpp3
-rw-r--r--src/game/SpellEffects.cpp1
-rw-r--r--src/game/SpellMgr.cpp62
-rw-r--r--src/game/SpellMgr.h3
-rw-r--r--src/game/Unit.cpp6
-rw-r--r--src/game/Unit.h2
-rw-r--r--src/game/World.cpp4
-rw-r--r--src/shared/Errors.h17
-rw-r--r--src/shared/LockedQueue.h59
-rw-r--r--src/shared/vmap/CoordModelMapping.cpp9
-rw-r--r--src/shared/vmap/CoordModelMapping.h7
-rw-r--r--src/shared/vmap/DebugCmdLogger.cpp1
-rw-r--r--src/trinitycore/Master.cpp2
-rw-r--r--src/trinityrealm/AuthSocket.cpp2
31 files changed, 426 insertions, 318 deletions
diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp
index c6861735906..f73f68e1f89 100644
--- a/src/game/AchievementMgr.cpp
+++ b/src/game/AchievementMgr.cpp
@@ -228,7 +228,7 @@ bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria)
if (!sHolidaysStore.LookupEntry(holiday.id))
{
sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_HOLIDAY (%u) have unknown holiday in value1 (%u), ignore.",
- criteria->ID, criteria->requiredType,dataType,drunk.state);
+ criteria->ID, criteria->requiredType,dataType,holiday.id);
return false;
}
return true;
diff --git a/src/game/AchievementMgr.h b/src/game/AchievementMgr.h
index 9a3ff496e7b..b790716b77a 100644
--- a/src/game/AchievementMgr.h
+++ b/src/game/AchievementMgr.h
@@ -51,8 +51,8 @@ enum AchievementCriteriaDataType
ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AREA = 6, // area id 0
ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA = 7, // spell_id effect_idx
ACHIEVEMENT_CRITERIA_DATA_TYPE_VALUE = 8, // minvalue value provided with achievement update must be not less that limit
- ACHIEVEMENT_CRITERIA_DATA_TYPE_T_LEVEL = 9, // minlevel minlevel of target
- ACHIEVEMENT_CRITERIA_DATA_TYPE_T_GENDER = 10,// gender 0=male; 1=female
+ ACHIEVEMENT_CRITERIA_DATA_TYPE_T_LEVEL = 9, // minlevel minlevel of target
+ ACHIEVEMENT_CRITERIA_DATA_TYPE_T_GENDER = 10,// gender 0=male; 1=female
ACHIEVEMENT_CRITERIA_DATA_TYPE_DISABLED = 11,// used to prevent achievement creteria complete if not all requirement implemented and listed in table
ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY = 12,// difficulty normal/heroic difficulty for current event map
ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT = 13,// count "with less than %u people in the zone"
diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index aca354750f0..6a6371f473d 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -64,7 +64,7 @@ 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, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points,bgid,bgteam,bgmap,bgx,bgy,bgz,bgo,instance_id FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
+ res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, 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_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points,bgid,bgteam,bgmap,bgx,bgy,bgz,bgo,instance_id FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT leaderGuid FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_mask,stackcount,amount0, amount1, amount2 ,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid));
@@ -133,21 +133,15 @@ void WorldSession::HandleCharEnum(QueryResult * result)
if( result )
{
- Player *plr = new Player(this);
do
{
uint32 guidlow = (*result)[0].GetUInt32();
sLog.outDetail("Loading char guid %u from account %u.",guidlow,GetAccountId());
-
- if(plr->MinimalLoadFromDB( result, guidlow ))
- {
- plr->BuildEnumData( result, &data );
+ if(Player::BuildEnumData(result, &data))
++num;
- }
}
while( result->NextRow() );
- delete plr;
delete result;
}
@@ -162,19 +156,23 @@ void WorldSession::HandleCharEnumOpcode( WorldPacket & /*recv_data*/ )
CharacterDatabase.AsyncPQuery(&chrHandler, &CharacterHandler::HandleCharEnumCallback, GetAccountId(),
!sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) ?
// ------- Query Without Declined Names --------
- // 0 1 2 3 4 5 6 7 8
- "SELECT characters.guid, characters.data, characters.name, characters.position_x, characters.position_y, characters.position_z, characters.map, characters.totaltime, characters.leveltime, "
- // 9 10 11 12 13 14
- "characters.at_login, characters.zone, character_pet.entry, character_pet.modelid, character_pet.level, guild_member.guildid "
+ // 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.data "
"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"
:
// --------- Query With Declined Names ---------
- // 0 1 2 3 4 5 6 7 8
- "SELECT characters.guid, characters.data, characters.name, characters.position_x, characters.position_y, characters.position_z, characters.map, characters.totaltime, characters.leveltime, "
- // 9 10 11 12 13 14 15
- "characters.at_login, characters.zone, character_pet.entry, character_pet.modelid, character_pet.level, guild_member.guildid, character_declinedname.genitive "
+ // 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 20
+ "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.data, character_declinedname.genitive "
"FROM characters LEFT JOIN character_pet ON characters.guid = character_pet.owner AND character_pet.slot='%u' "
"LEFT JOIN character_declinedname ON characters.guid = character_declinedname.guid "
"LEFT JOIN guild_member ON characters.guid = guild_member.guid "
@@ -340,7 +338,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
if(!AllowTwoSideAccounts || skipCinematics == 1 || class_ == CLASS_DEATH_KNIGHT)
{
- QueryResult *result2 = CharacterDatabase.PQuery("SELECT guid,race,class FROM characters WHERE account = '%u' %s",
+ QueryResult *result2 = CharacterDatabase.PQuery("SELECT level,race,class FROM characters WHERE account = '%u' %s",
GetAccountId(), (skipCinematics == 1 || class_ == CLASS_DEATH_KNIGHT) ? "" : "LIMIT 1");
if(result2)
{
@@ -367,8 +365,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
if(!have_req_level_for_heroic)
{
- uint32 acc_guid = field[0].GetUInt32();
- uint32 acc_level = Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL,acc_guid);
+ uint32 acc_level = field[0].GetUInt32();
if(acc_level >= req_level_for_heroic)
have_req_level_for_heroic = true;
}
@@ -422,8 +419,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
if(!have_req_level_for_heroic)
{
- uint32 acc_guid = field[0].GetUInt32();
- uint32 acc_level = Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL,acc_guid);
+ uint32 acc_level = field[0].GetUInt32();
if(acc_level >= req_level_for_heroic)
have_req_level_for_heroic = true;
}
diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
index d1e85f6baa0..edd19a746f9 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -160,6 +160,7 @@ ChatCommand * ChatHandler::getCommandTable()
{ "Mod32Value", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugMod32Value, "", NULL },
{ "play", SEC_MODERATOR, false, NULL, "", debugPlayCommandTable },
{ "send", SEC_ADMINISTRATOR, false, NULL, "", debugSendCommandTable },
+ { "setaurastate", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetAuraStateCommand, "", NULL },
{ "setitemflag", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetItemFlagCommand, "", NULL },
{ "setvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetValue, "", NULL },
{ "spawnvehicle", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSpawnVehicle, "", NULL },
diff --git a/src/game/Chat.h b/src/game/Chat.h
index b970628f94f..79a7cb390e0 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -142,9 +142,10 @@ class ChatHandler
bool HandleDebugGetLootRecipient(const char * args);
bool HandleDebugGetValue(const char* args);
bool HandleDebugMod32Value(const char* args);
- bool HandleDebugSetValue(const char* args);
+ bool HandleDebugSetAuraStateCommand(const char * args);
bool HandleDebugSetItemFlagCommand(const char * args);
bool HandleDebugSetVehicleId(const char * args);
+ bool HandleDebugSetValue(const char* args);
bool HandleDebugSpawnVehicle(const char * args);
bool HandleDebugEnterVehicle(const char * args);
bool HandleDebugUpdate(const char* args);
diff --git a/src/game/Debugcmds.cpp b/src/game/Debugcmds.cpp
index d8b94df4e10..2e473bc9b43 100644
--- a/src/game/Debugcmds.cpp
+++ b/src/game/Debugcmds.cpp
@@ -39,7 +39,7 @@
bool ChatHandler::HandleDebugSendSpellFailCommand(const char* args)
{
- if(!args)
+ if (!*args)
return false;
char* px = strtok((char*)args, " ");
@@ -47,7 +47,7 @@ bool ChatHandler::HandleDebugSendSpellFailCommand(const char* args)
return false;
uint8 failnum = (uint8)atoi(px);
- if(failnum==0 && *px!='0')
+ if (failnum==0 && *px!='0')
return false;
char* p1 = strtok(NULL, " ");
@@ -72,20 +72,20 @@ bool ChatHandler::HandleDebugSendSpellFailCommand(const char* args)
bool ChatHandler::HandleDebugSendPoiCommand(const char* args)
{
+ if (!*args)
+ return false;
+
Player *pPlayer = m_session->GetPlayer();
Unit* target = getSelectedUnit();
- if(!target)
+ if (!target)
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
return true;
}
- if(!args)
- return false;
-
char* icon_text = strtok((char*)args, " ");
char* flags_text = strtok(NULL, " ");
- if(!icon_text || !flags_text)
+ if (!icon_text || !flags_text)
return false;
uint32 icon = atol(icon_text);
@@ -98,7 +98,7 @@ bool ChatHandler::HandleDebugSendPoiCommand(const char* args)
bool ChatHandler::HandleDebugSendEquipErrorCommand(const char* args)
{
- if(!args)
+ if (!*args)
return false;
uint8 msg = atoi(args);
@@ -108,7 +108,7 @@ bool ChatHandler::HandleDebugSendEquipErrorCommand(const char* args)
bool ChatHandler::HandleDebugSendSellErrorCommand(const char* args)
{
- if(!args)
+ if (!*args)
return false;
uint8 msg = atoi(args);
@@ -118,7 +118,7 @@ bool ChatHandler::HandleDebugSendSellErrorCommand(const char* args)
bool ChatHandler::HandleDebugSendBuyErrorCommand(const char* args)
{
- if(!args)
+ if (!*args)
return false;
uint8 msg = atoi(args);
@@ -137,7 +137,7 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(const char* /*args*/)
if(!unit) unit = player;
std::ifstream ifs("opcode.txt");
- if(ifs.bad())
+ if (ifs.bad())
return false;
uint32 opcode;
@@ -273,7 +273,7 @@ bool ChatHandler::HandleDebugPlayCinematicCommand(const char* args)
{
// USAGE: .debug play cinematic #cinematicid
// #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column)
- if( !*args )
+ if (!*args)
{
SendSysMessage(LANG_BAD_VALUE);
SetSentErrorMessage(true);
@@ -282,7 +282,7 @@ bool ChatHandler::HandleDebugPlayCinematicCommand(const char* args)
uint32 dwId = atoi((char*)args);
- if(!sCinematicSequencesStore.LookupEntry(dwId))
+ if (!sCinematicSequencesStore.LookupEntry(dwId))
{
PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, dwId);
SetSentErrorMessage(true);
@@ -297,7 +297,7 @@ bool ChatHandler::HandleDebugPlayMovieCommand(const char* args)
{
// USAGE: .debug play movie #movieid
// #movieid - ID decimal number from Movie.dbc (1st column)
- if( !*args )
+ if (!*args)
{
SendSysMessage(LANG_BAD_VALUE);
SetSentErrorMessage(true);
@@ -306,7 +306,7 @@ bool ChatHandler::HandleDebugPlayMovieCommand(const char* args)
uint32 dwId = atoi((char*)args);
- if(!sMovieStore.LookupEntry(dwId))
+ if (!sMovieStore.LookupEntry(dwId))
{
PSendSysMessage(LANG_MOVIE_NOT_EXIST, dwId);
SetSentErrorMessage(true);
@@ -322,7 +322,7 @@ bool ChatHandler::HandleDebugPlaySoundCommand(const char* args)
{
// USAGE: .debug playsound #soundid
// #soundid - ID decimal number from SoundEntries.dbc (1st column)
- if( !*args )
+ if (!*args)
{
SendSysMessage(LANG_BAD_VALUE);
SetSentErrorMessage(true);
@@ -331,7 +331,7 @@ bool ChatHandler::HandleDebugPlaySoundCommand(const char* args)
uint32 dwSoundId = atoi((char*)args);
- if(!sSoundEntriesStore.LookupEntry(dwSoundId))
+ if (!sSoundEntriesStore.LookupEntry(dwSoundId))
{
PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId);
SetSentErrorMessage(true);
@@ -339,14 +339,14 @@ bool ChatHandler::HandleDebugPlaySoundCommand(const char* args)
}
Unit* unit = getSelectedUnit();
- if(!unit)
+ if (!unit)
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true);
return false;
}
- if(m_session->GetPlayer()->GetSelection())
+ if (m_session->GetPlayer()->GetSelection())
unit->PlayDistanceSound(dwSoundId,m_session->GetPlayer());
else
unit->PlayDirectSound(dwSoundId,m_session->GetPlayer());
@@ -358,7 +358,7 @@ bool ChatHandler::HandleDebugPlaySoundCommand(const char* args)
//Send notification in channel
bool ChatHandler::HandleDebugSendChannelNotifyCommand(const char* args)
{
- if(!args)
+ if (!*args)
return false;
const char *name = "test";
@@ -376,7 +376,7 @@ bool ChatHandler::HandleDebugSendChannelNotifyCommand(const char* args)
//Send notification in chat
bool ChatHandler::HandleDebugSendChatMsgCommand(const char* args)
{
- if(!args)
+ if (!*args)
return false;
const char *msg = "testtest";
@@ -397,7 +397,7 @@ bool ChatHandler::HandleDebugSendQuestPartyMsgCommand(const char* args)
bool ChatHandler::HandleDebugGetLootRecipient(const char* /*args*/)
{
Creature* target = getSelectedCreature();
- if(!target)
+ if (!target)
return false;
PSendSysMessage("loot recipient: %s", target->hasLootRecipient()?(target->GetLootRecipient()?target->GetLootRecipient()->GetName():"offline"):"no loot recipient");
@@ -413,7 +413,7 @@ bool ChatHandler::HandleDebugSendQuestInvalidMsgCommand(const char* args)
bool ChatHandler::HandleDebugGetItemState(const char* args)
{
- if (!args)
+ if (!*args)
return false;
std::string state_str = args;
@@ -757,7 +757,7 @@ bool ChatHandler::HandleDebugEnterVehicle(const char * args)
bool ChatHandler::HandleDebugSpawnVehicle(const char* args)
{
- if(!args)
+ if (!*args)
return false;
char* e = strtok((char*)args, " ");
@@ -778,12 +778,12 @@ bool ChatHandler::HandleDebugSpawnVehicle(const char* args)
CreatureInfo const *ci = objmgr.GetCreatureTemplate(entry);
- if(!ci)
+ if (!ci)
return false;
VehicleEntry const *ve = sVehicleStore.LookupEntry(id);
- if(!ve)
+ if (!ve)
return false;
Vehicle *v = new Vehicle;
@@ -812,7 +812,7 @@ bool ChatHandler::HandleDebugSendLargePacketCommand(const char* /*args*/)
bool ChatHandler::HandleDebugSendSetPhaseShiftCommand(const char* args)
{
- if(!args)
+ if (!*args)
return false;
uint32 PhaseShift = atoi(args);
@@ -822,7 +822,7 @@ bool ChatHandler::HandleDebugSendSetPhaseShiftCommand(const char* args)
bool ChatHandler::HandleDebugSetItemFlagCommand(const char* args)
{
- if(!args)
+ if (!*args)
return false;
char* e = strtok((char*)args, " ");
@@ -836,7 +836,7 @@ bool ChatHandler::HandleDebugSetItemFlagCommand(const char* args)
Item *i = m_session->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM));
- if(!i)
+ if (!i)
return false;
i->SetUInt32Value(ITEM_FIELD_FLAGS, flag);
@@ -854,3 +854,33 @@ bool ChatHandler::HandleDebugAnimCommand(const char* args)
m_session->GetPlayer()->HandleEmoteCommand(anim_id);
return true;
}
+
+bool ChatHandler::HandleDebugSetAuraStateCommand(const char* args)
+{
+ if (!*args)
+ {
+ SendSysMessage(LANG_BAD_VALUE);
+ SetSentErrorMessage(true);
+ return false;
+ }
+
+ Unit* unit = getSelectedUnit();
+ if (!unit)
+ {
+ SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
+ SetSentErrorMessage(true);
+ return false;
+ }
+
+ int32 state = atoi((char*)args);
+ if (!state)
+ {
+ // reset all states
+ for(int i = 1; i <= 32; ++i)
+ unit->ModifyAuraState(AuraState(i),false);
+ return true;
+ }
+
+ unit->ModifyAuraState(AuraState(abs(state)),state > 0);
+ return true;
+}
diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp
index 84271f08d04..c227644b0ed 100644
--- a/src/game/Guild.cpp
+++ b/src/game/Guild.cpp
@@ -369,20 +369,17 @@ bool Guild::FillPlayerData(uint64 guid, MemberSlot* memslot)
}
else
{
- QueryResult *result = CharacterDatabase.PQuery("SELECT name,data,zone,class FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
- if(!result)
- return false; // player doesn't exist
+ QueryResult *result = CharacterDatabase.PQuery("SELECT name,level,zone,class FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
+ if(!result)
+ return false; // player doesn't exist
Field *fields = result->Fetch();
- plName = fields[0].GetCppString();
-
- Tokens data = StrSplit(fields[1].GetCppString(), " ");
- plLevel = Player::GetUInt32ValueFromArray(data,UNIT_FIELD_LEVEL);
-
- plZone = fields[2].GetUInt32();
- plClass = fields[3].GetUInt32();
- delete result;
+ plName = fields[0].GetCppString();
+ plLevel = fields[1].GetUInt32();
+ plZone = fields[2].GetUInt32();
+ plClass = fields[3].GetUInt32();
+ delete result;
if(plLevel<1||plLevel>STRONG_MAX_LEVEL) // can be at broken `data` field
{
diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp
index f3f9c6c6758..a8eba52dee0 100644
--- a/src/game/GuildHandler.cpp
+++ b/src/game/GuildHandler.cpp
@@ -976,7 +976,7 @@ void WorldSession::HandleGuildBankDepositMoney( WorldPacket & recv_data )
pGuild->SetBankMoney(pGuild->GetGuildBankMoney()+money);
GetPlayer()->ModifyMoney(-int(money));
- GetPlayer()->SaveDataFieldToDB(); //contains money
+ GetPlayer()->SaveGoldToDB();
CharacterDatabase.CommitTransaction();
@@ -1032,7 +1032,7 @@ void WorldSession::HandleGuildBankWithdrawMoney( WorldPacket & recv_data )
}
GetPlayer()->ModifyMoney(money);
- GetPlayer()->SaveDataFieldToDB(); // contains money
+ GetPlayer()->SaveGoldToDB();
CharacterDatabase.CommitTransaction();
diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp
index 9ec47381f61..7477801dff7 100644
--- a/src/game/Level1.cpp
+++ b/src/game/Level1.cpp
@@ -1472,7 +1472,6 @@ bool ChatHandler::HandleModifyTalentCommand (const char* args)
return false;
Unit* target = getSelectedUnit();
-
if(!target)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index e7a684a8111..901c9ba1d1c 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -2268,22 +2268,17 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
if (HasLowerSecurity(NULL, target_guid))
return false;
- // 0
- QueryResult *result = CharacterDatabase.PQuery("SELECT totaltime FROM characters WHERE guid = '%u'", GUID_LOPART(target_guid));
+ // 0 1 2 3
+ QueryResult *result = CharacterDatabase.PQuery("SELECT totaltime, level, money, account FROM characters WHERE guid = '%u'", GUID_LOPART(target_guid));
if (!result)
return false;
Field *fields = result->Fetch();
total_player_time = fields[0].GetUInt32();
+ level = fields[1].GetUInt32();
+ money = fields[2].GetUInt32();
+ accId = fields[3].GetUInt32();
delete result;
-
- Tokens data;
- if (!Player::LoadValuesArrayFromDB(data,target_guid))
- return false;
-
- money = Player::GetUInt32ValueFromArray(data, PLAYER_FIELD_COINAGE);
- level = Player::GetUInt32ValueFromArray(data, UNIT_FIELD_LEVEL);
- accId = objmgr.GetPlayerAccountIdByGUID(target_guid);
}
std::string username = GetTrinityString(LANG_ERROR);
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
index 647919379d8..39d04cefaf3 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -4668,11 +4668,7 @@ void ChatHandler::HandleCharacterLevel(Player* player, uint64 player_guid, uint3
else
{
// update level and XP at level, all other will be updated at loading
- Tokens values;
- Player::LoadValuesArrayFromDB(values,player_guid);
- Player::SetUInt32ValueInArray(values,UNIT_FIELD_LEVEL,newlevel);
- Player::SetUInt32ValueInArray(values,PLAYER_XP,0);
- Player::SaveValuesArrayInDB(values,player_guid);
+ CharacterDatabase.PExecute("UPDATE characters SET level = '%u', xp = 0 WHERE guid = '%u'", newlevel, GUID_LOPART(player_guid));
}
}
@@ -4697,7 +4693,7 @@ bool ChatHandler::HandleCharacterLevelCommand(const char* args)
if(!extractPlayerTarget(nameStr,&target,&target_guid,&target_name))
return false;
- int32 oldlevel = target ? target->getLevel() : Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL,target_guid);
+ int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromDB(target_guid);
int32 newlevel = levelStr ? atoi(levelStr) : oldlevel;
if(newlevel < 1)
@@ -4736,7 +4732,7 @@ bool ChatHandler::HandleLevelUpCommand(const char* args)
if(!extractPlayerTarget(nameStr,&target,&target_guid,&target_name))
return false;
- int32 oldlevel = target ? target->getLevel() : Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL,target_guid);
+ int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromDB(target_guid);
int32 addlevel = levelStr ? atoi(levelStr) : 1;
int32 newlevel = oldlevel + addlevel;
diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp
index adba36fd301..0490d133bf2 100644
--- a/src/game/LootMgr.cpp
+++ b/src/game/LootMgr.cpp
@@ -1327,7 +1327,7 @@ void LoadLootTemplates_Spell()
// ignore 61756 (Northrend Inscription Research (FAST QA VERSION) for example
if (!(spellInfo->Attributes & SPELL_ATTR_NOT_SHAPESHIFT) || (spellInfo->Attributes & SPELL_ATTR_UNK5))
{
- LootTemplates_Spell.ReportNotExistedId(spell_id);
+ LootTemplates_Spell.ReportNotExistedId(spell_id);
}
}
else
diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp
index 0af4999092f..33ff65e7fe0 100644
--- a/src/game/Mail.cpp
+++ b/src/game/Mail.cpp
@@ -567,7 +567,7 @@ void WorldSession::HandleMailTakeMoney(WorldPacket & recv_data )
// save money and mail to prevent cheating
CharacterDatabase.BeginTransaction();
- pl->SaveDataFieldToDB(); // contains money
+ pl->SaveGoldToDB();
pl->_SaveMail();
CharacterDatabase.CommitTransaction();
}
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 55946030206..5f376b19a91 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -539,9 +539,6 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
for (uint8 i = 0; i < PLAYER_SLOTS_COUNT; i++)
m_items[i] = NULL;
- m_race = race;
- m_class = class_;
-
SetMapId(info->mapId);
Relocate(info->positionX,info->positionY,info->positionZ);
@@ -573,7 +570,7 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
break;
}
- setFactionForRace(m_race);
+ setFactionForRace(race);
uint32 RaceClassGender = ( race ) | ( class_ << 8 ) | ( gender << 16 );
@@ -1452,53 +1449,67 @@ void Player::setDeathState(DeathState s)
}
}
-void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
+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 20
+ // "characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.data, character_declinedname.genitive "
+
Field *fields = result->Fetch();
- *p_data << uint64(GetGUID());
- *p_data << m_name;
+ uint32 guid = fields[0].GetUInt32();
+ uint8 pRace = fields[2].GetUInt8();
+ uint8 pClass = fields[3].GetUInt8();
- *p_data << uint8(getRace());
- uint8 pClass = getClass();
- *p_data << uint8(pClass);
- *p_data << uint8(getGender());
+ PlayerInfo const *info = objmgr.GetPlayerInfo(pRace, pClass);
+ if(!info)
+ {
+ sLog.outError("Player %u have incorrect race/class pair. Don't build enum.", guid);
+ return false;
+ }
+
+ *p_data << uint64(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER));
+ *p_data << fields[1].GetString(); // name
+ *p_data << uint8(pRace); // race
+ *p_data << uint8(pClass); // class
+ *p_data << uint8(fields[4].GetUInt8()); // gender
- uint32 bytes = GetUInt32Value(PLAYER_BYTES);
- *p_data << uint8(bytes);
- *p_data << uint8(bytes >> 8);
- *p_data << uint8(bytes >> 16);
- *p_data << uint8(bytes >> 24);
+ 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
- bytes = GetUInt32Value(PLAYER_BYTES_2);
- *p_data << uint8(bytes);
+ uint32 playerBytes2 = fields[6].GetUInt32();
+ *p_data << uint8(playerBytes2 & 0xFF); // facial hair
- *p_data << uint8(getLevel()); // player level
- // do not use GetMap! it will spawn a new instance since the bound instances are not loaded
- uint32 zoneId = fields[10].GetUInt32();
- sLog.outDebug("Player::BuildEnumData: map:%u, x:%f, y:%f, z:%f zone:%u", GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), zoneId);
- *p_data << uint32(zoneId);
- *p_data << uint32(GetMapId());
+ *p_data << uint8(fields[7].GetUInt8()); // level
+ *p_data << uint32(fields[8].GetUInt32()); // zone
+ *p_data << uint32(fields[9].GetUInt32()); // map
- *p_data << GetPositionX();
- *p_data << GetPositionY();
- *p_data << GetPositionZ();
+ *p_data << fields[10].GetFloat(); // x
+ *p_data << fields[11].GetFloat(); // y
+ *p_data << fields[12].GetFloat(); // z
- // guild id
- *p_data << uint32(fields[14].GetUInt32());
+ *p_data << uint32(fields[13].GetUInt32()); // guild id
uint32 char_flags = 0;
- if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM))
+ uint32 playerFlags = fields[14].GetUInt32();
+ uint32 atLoginFlags = fields[15].GetUInt32();
+ if(playerFlags & PLAYER_FLAGS_HIDE_HELM)
char_flags |= CHARACTER_FLAG_HIDE_HELM;
- if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK))
+ if(playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
char_flags |= CHARACTER_FLAG_HIDE_CLOAK;
- if(HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
+ if(playerFlags & PLAYER_FLAGS_GHOST)
char_flags |= CHARACTER_FLAG_GHOST;
- if(HasAtLoginFlag(AT_LOGIN_RENAME))
+ if(atLoginFlags & AT_LOGIN_RENAME)
char_flags |= CHARACTER_FLAG_RENAME;
if(sWorld.getConfig(CONFIG_DECLINED_NAMES_USED))
{
- if(!fields[15].GetCppString().empty())
+ if(!fields[20].GetCppString().empty())
char_flags |= CHARACTER_FLAG_DECLINED;
}
else
@@ -1506,7 +1517,7 @@ void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
*p_data << uint32(char_flags); // character flags
// character customize (flags?)
- *p_data << uint32(HasAtLoginFlag(AT_LOGIN_CUSTOMIZE) ? 1 : 0);
+ *p_data << uint32(atLoginFlags & AT_LOGIN_CUSTOMIZE ? 1 : 0);
*p_data << uint8(1); // unknown
// Pets info
@@ -1515,15 +1526,15 @@ void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
uint32 petLevel = 0;
uint32 petFamily = 0;
- // show pet at selection character in character list only for non-ghost character
- if (result && isAlive() && (pClass == CLASS_WARLOCK || pClass == CLASS_HUNTER || pClass == CLASS_DEATH_KNIGHT))
+ // 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 || pClass == CLASS_DEATH_KNIGHT))
{
- uint32 entry = fields[11].GetUInt32();
+ uint32 entry = fields[16].GetUInt32();
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(entry);
if(cInfo)
{
- petDisplayId = fields[12].GetUInt32();
- petLevel = fields[13].GetUInt32();
+ petDisplayId = fields[17].GetUInt32();
+ petLevel = fields[18].GetUInt32();
petFamily = cInfo->family;
}
}
@@ -1533,36 +1544,40 @@ void Player::BuildEnumData( QueryResult * result, WorldPacket * p_data )
*p_data << uint32(petFamily);
}
+ // TODO: do not access data field here
+ Tokens data = StrSplit(fields[19].GetCppString(), " ");
+
for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; slot++)
{
uint32 visualbase = PLAYER_VISIBLE_ITEM_1_ENTRYID + (slot * 2);
- uint32 item_id = GetUInt32Value(visualbase);
+ uint32 item_id = GetUInt32ValueFromArray(data, visualbase);
const ItemPrototype * proto = objmgr.GetItemPrototype(item_id);
+ if(!proto)
+ {
+ *p_data << uint32(0);
+ *p_data << uint8(0);
+ *p_data << uint32(0);
+ continue;
+ }
+
SpellItemEnchantmentEntry const *enchant = NULL;
+ uint32 enchants = GetUInt32ValueFromArray(data, visualbase + 1);
for(uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot <= TEMP_ENCHANTMENT_SLOT; ++enchantSlot)
{
- uint32 enchantId = GetUInt16Value(visualbase + 1, enchantSlot);
- if(enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId))
+ if(enchant = sSpellItemEnchantmentStore.LookupEntry(enchantSlot >> enchantSlot*16))
break;
}
- if (proto != NULL)
- {
- *p_data << uint32(proto->DisplayInfoID);
- *p_data << uint8(proto->InventoryType);
- *p_data << uint32(enchant ? enchant->aura_id : 0);
- }
- else
- {
- *p_data << uint32(0);
- *p_data << uint8(0);
- *p_data << uint32(0); // enchant?
- }
+ *p_data << uint32(proto->DisplayInfoID);
+ *p_data << uint8(proto->InventoryType);
+ *p_data << uint32(enchant ? enchant->aura_id : 0);
}
*p_data << uint32(0); // first bag display id
*p_data << uint8(0); // first bag inventory type
*p_data << uint32(0); // enchant?
+
+ return true;
}
bool Player::ToggleAFK()
@@ -2603,7 +2618,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
void Player::SendInitialSpells()
{
time_t curTime = time(NULL);
- time_t infTime = curTime + MONTH/2;
+ time_t infTime = curTime + infinityCooldownDelayCheck;
uint16 spellCount = 0;
@@ -2637,18 +2652,21 @@ void Player::SendInitialSpells()
if(!sEntry)
continue;
- // not send infinity cooldown
- if(itr->second.end > infTime)
- continue;
-
data << uint32(itr->first);
- time_t cooldown = 0;
- if(itr->second.end > curTime)
- cooldown = (itr->second.end-curTime)*IN_MILISECONDS;
-
data << uint16(itr->second.itemid); // cast item id
data << uint16(sEntry->Category); // spell category
+
+ // send infinity cooldown in special format
+ if(itr->second.end >= infTime)
+ {
+ data << uint32(1); // cooldown
+ data << uint32(0x80000000); // category cooldown
+ continue;
+ }
+
+ time_t cooldown = itr->second.end > curTime ? (itr->second.end-curTime)*IN_MILISECONDS : 0;
+
if(sEntry->Category) // may be wrong, but anyway better than nothing...
{
data << uint32(0); // cooldown
@@ -3461,7 +3479,7 @@ void Player::_SaveSpellCooldowns()
CharacterDatabase.PExecute("DELETE FROM character_spell_cooldown WHERE guid = '%u'", GetGUIDLow());
time_t curTime = time(NULL);
- time_t infTime = curTime + MONTH/2;
+ time_t infTime = curTime + infinityCooldownDelayCheck;
// remove outdated and save active
for(SpellCooldowns::iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end();)
@@ -6243,6 +6261,19 @@ uint32 Player::GetZoneIdFromDB(uint64 guid)
return zone;
}
+uint32 Player::GetLevelFromDB(uint64 guid)
+{
+ QueryResult *result = CharacterDatabase.PQuery( "SELECT level FROM characters WHERE guid='%u'", GUID_LOPART(guid) );
+ if (!result)
+ return 0;
+
+ Field* fields = result->Fetch();
+ uint32 level = fields[0].GetUInt32();
+ delete result;
+
+ return level;
+}
+
void Player::UpdateArea(uint32 newArea)
{
// FFA_PVP flags are area and not zone id dependent
@@ -14073,8 +14104,8 @@ bool Player::MinimalLoadFromDB( QueryResult *result, uint32 guid )
bool delete_result = true;
if (!result)
{
- // 0 1 2 3 4 5 6 7 8 9 10
- result = CharacterDatabase.PQuery("SELECT guid, data, name, position_x, position_y, position_z, map, totaltime, leveltime, at_login, zone FROM characters WHERE guid = '%u'",guid);
+ // 0 1 2 3 4 5 6 7 8 9 10 11
+ result = CharacterDatabase.PQuery("SELECT guid, data, name, position_x, position_y, position_z, map, totaltime, leveltime, at_login, zone, level FROM characters WHERE guid = '%u'",guid);
if (!result)
return false;
}
@@ -14307,8 +14338,8 @@ float Player::GetFloatValueFromDB(uint16 index, uint64 guid)
bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
{
- //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [28] [29] 30 31 32 33 34 35 36 37 38 39 40
- //QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points,bgid,bgteam,bgmap,bgx,bgy,bgz,bgo FROM characters WHERE guid = '%u'", guid);
+ //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
+ //QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, 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_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points,bgid,bgteam,bgmap,bgx,bgy,bgz,bgo FROM characters WHERE guid = '%u'", guid);
QueryResult *result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM);
if(!result)
@@ -14352,6 +14383,21 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
// overwrite possible wrong/corrupted guid
SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER));
+ // overwrite some data fields
+ uint32 bytes0 = GetUInt32Value(UNIT_FIELD_BYTES_0) & 0xFF000000;
+ bytes0 |= fields[4].GetUInt8(); // race
+ bytes0 |= fields[5].GetUInt8() << 8; // class
+ bytes0 |= fields[6].GetUInt8() << 16; // gender
+ SetUInt32Value(UNIT_FIELD_BYTES_0, bytes0);
+
+ SetUInt32Value(UNIT_FIELD_LEVEL, fields[7].GetUInt8());
+ SetUInt32Value(PLAYER_XP, fields[8].GetUInt32());
+ SetUInt32Value(PLAYER_FIELD_COINAGE, fields[9].GetUInt32());
+ SetUInt32Value(PLAYER_BYTES, fields[10].GetUInt32());
+ SetUInt32Value(PLAYER_BYTES_2, fields[11].GetUInt32());
+ SetUInt32Value(PLAYER_BYTES_3, (GetUInt32Value(PLAYER_BYTES_3) & ~1) | fields[6].GetUInt8());
+ SetUInt32Value(PLAYER_FLAGS, fields[12].GetUInt32());
+
// cleanup inventory related item value fields (its will be filled correctly in _LoadInventory)
for(uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
{
@@ -14372,12 +14418,9 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
sLog.outDebug("Load Basic value of player %s is: ", m_name.c_str());
outDebugValues();
- m_race = fields[4].GetUInt8();
- //Need to call it to initialize m_team (m_team can be calculated from m_race)
+ //Need to call it to initialize m_team (m_team can be calculated from race)
//Other way is to saves m_team into characters table.
- setFactionForRace(m_race);
-
- m_class = fields[5].GetUInt8();
+ setFactionForRace(getRace());
// load home bind and check in same time class/race pair, it used later for restore broken positions
if(!_LoadHomeBind(holder->GetResult(PLAYER_LOGIN_QUERY_LOADHOMEBIND)))
@@ -14389,17 +14432,18 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
InitPrimaryProfessions(); // to max set before any spell loaded
// init saved position, and fix it later if problematic
- uint32 transGUID = fields[24].GetUInt32();
- Relocate(fields[6].GetFloat(),fields[7].GetFloat(),fields[8].GetFloat(),fields[10].GetFloat());
- SetMapId(fields[9].GetUInt32());
- SetInstanceId(fields[41].GetFloat());
- SetDifficulty(fields[32].GetUInt32()); // may be changed in _LoadGroup
+ uint32 transGUID = fields[31].GetUInt32();
+ Relocate(fields[13].GetFloat(),fields[14].GetFloat(),fields[15].GetFloat(),fields[17].GetFloat());
+ SetMapId(fields[16].GetUInt32());
+ SetDifficulty(fields[39].GetUInt32()); // may be changed in _LoadGroup
+
+ SetInstanceId(fields[47].GetFloat());
_LoadGroup(holder->GetResult(PLAYER_LOGIN_QUERY_LOADGROUP));
_LoadArenaTeamInfo(holder->GetResult(PLAYER_LOGIN_QUERY_LOADARENAINFO));
- uint32 arena_currency = GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY) + fields[33].GetUInt32();
+ uint32 arena_currency = GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY) + fields[40].GetUInt32();
if (arena_currency > sWorld.getConfig(CONFIG_MAX_ARENA_POINTS))
arena_currency = sWorld.getConfig(CONFIG_MAX_ARENA_POINTS);
@@ -14436,12 +14480,12 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
m_movementInfo.t_o = 0.0f;
}
- uint32 bgid = fields[34].GetUInt32();
- uint32 bgteam = fields[35].GetUInt32();
+ uint32 bgid = fields[41].GetUInt32();
+ uint32 bgteam = fields[42].GetUInt32();
if(bgid) //saved in BattleGround
{
- SetBattleGroundEntryPoint(fields[36].GetUInt32(),fields[37].GetFloat(),fields[38].GetFloat(),fields[39].GetFloat(),fields[40].GetFloat());
+ SetBattleGroundEntryPoint(fields[43].GetUInt32(),fields[44].GetFloat(),fields[45].GetFloat(),fields[46].GetFloat(),fields[47].GetFloat());
// check entry point and fix to homebind if need
MapEntry const* mapEntry = sMapStore.LookupEntry(m_bgEntryPoint.mapid);
@@ -14480,8 +14524,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
if(!mapEntry || mapEntry->IsBattleGroundOrArena())
{
// return to BG master
- SetMapId(fields[36].GetUInt32());
- Relocate(fields[37].GetFloat(),fields[38].GetFloat(),fields[39].GetFloat(),fields[40].GetFloat());
+ SetMapId(fields[43].GetUInt32());
+ Relocate(fields[44].GetFloat(),fields[45].GetFloat(),fields[46].GetFloat(),fields[47].GetFloat());
// check entry point and fix to homebind if need
mapEntry = sMapStore.LookupEntry(GetMapId());
@@ -14492,10 +14536,10 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
if (transGUID != 0)
{
- m_movementInfo.t_x = fields[20].GetFloat();
- m_movementInfo.t_y = fields[21].GetFloat();
- m_movementInfo.t_z = fields[22].GetFloat();
- m_movementInfo.t_o = fields[23].GetFloat();
+ m_movementInfo.t_x = fields[27].GetFloat();
+ m_movementInfo.t_y = fields[28].GetFloat();
+ m_movementInfo.t_z = fields[29].GetFloat();
+ m_movementInfo.t_o = fields[30].GetFloat();
if( !Trinity::IsValidMapCoord(
GetPositionX()+m_movementInfo.t_x,GetPositionY()+m_movementInfo.t_y,
@@ -14627,7 +14671,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
SaveRecallPosition();
time_t now = time(NULL);
- time_t logoutTime = time_t(fields[16].GetUInt64());
+ time_t logoutTime = time_t(fields[23].GetUInt64());
// since last logout (in seconds)
uint64 time_diff = uint64(now - logoutTime);
@@ -14642,27 +14686,27 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
uint16 newDrunkenValue = uint16(soberFactor*(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFE));
SetDrunkValue(newDrunkenValue);
- m_rest_bonus = fields[15].GetFloat();
+ m_rest_bonus = fields[22].GetFloat();
//speed collect rest bonus in offline, in logout, far from tavern, city (section/in hour)
float bubble0 = 0.031;
//speed collect rest bonus in offline, in logout, in tavern, city (section/in hour)
float bubble1 = 0.125;
- if((int32)fields[16].GetUInt32() > 0)
+ if(time_diff > 0)
{
- float bubble = fields[17].GetUInt32() > 0
+ float bubble = fields[24].GetUInt32() > 0
? bubble1*sWorld.getRate(RATE_REST_OFFLINE_IN_TAVERN_OR_CITY)
: bubble0*sWorld.getRate(RATE_REST_OFFLINE_IN_WILDERNESS);
SetRestBonus(GetRestBonus()+ time_diff*((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)/72000)*bubble);
}
- m_cinematic = fields[12].GetUInt32();
- m_Played_time[0]= fields[13].GetUInt32();
- m_Played_time[1]= fields[14].GetUInt32();
+ m_cinematic = fields[19].GetUInt32();
+ m_Played_time[0]= fields[20].GetUInt32();
+ m_Played_time[1]= fields[21].GetUInt32();
- m_resetTalentsCost = fields[18].GetUInt32();
- m_resetTalentsTime = time_t(fields[19].GetUInt64());
+ m_resetTalentsCost = fields[25].GetUInt32();
+ m_resetTalentsTime = time_t(fields[26].GetUInt64());
// reserve some flags
uint32 old_safe_flags = GetUInt32Value(PLAYER_FLAGS) & ( PLAYER_FLAGS_HIDE_CLOAK | PLAYER_FLAGS_HIDE_HELM );
@@ -14670,29 +14714,29 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
if( HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM) )
SetUInt32Value(PLAYER_FLAGS, 0 | old_safe_flags);
- m_taxi.LoadTaxiMask( fields[11].GetString() ); // must be before InitTaxiNodesForLevel
+ m_taxi.LoadTaxiMask( fields[18].GetString() ); // must be before InitTaxiNodesForLevel
- uint32 extraflags = fields[25].GetUInt32();
+ uint32 extraflags = fields[32].GetUInt32();
- m_stableSlots = fields[26].GetUInt32();
+ m_stableSlots = fields[33].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[27].GetUInt32();
+ m_atLoginFlags = fields[34].GetUInt32();
// Honor system
// Update Honor kills data
m_lastHonorUpdateTime = logoutTime;
UpdateHonorFields();
- m_deathExpireTime = (time_t)fields[30].GetUInt64();
+ m_deathExpireTime = (time_t)fields[37].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[31].GetCppString();
+ std::string taxi_nodes = fields[38].GetCppString();
delete result;
@@ -15017,7 +15061,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
delete result;
}
- if(m_class == CLASS_WARRIOR)
+ if(getClass() == CLASS_WARRIOR)
CastSpell(this,SPELL_ID_PASSIVE_BATTLE_STANCE,true);
}
@@ -15932,7 +15976,7 @@ void Player::SaveToDB()
CharacterDatabase.escape_string(sql_name);
std::ostringstream ss;
- ss << "INSERT INTO characters (guid,account,name,race,class,"
+ ss << "INSERT INTO characters (guid,account,name,race,class,gender,level,xp,money,playerBytes,playerBytes2,playerFlags,"
"map, instance_id, dungeon_difficulty, position_x, position_y, position_z, orientation, data, "
"taximask, online, cinematic, "
"totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, "
@@ -15941,8 +15985,15 @@ void Player::SaveToDB()
<< GetGUIDLow() << ", "
<< GetSession()->GetAccountId() << ", '"
<< sql_name << "', "
- << m_race << ", "
- << m_class << ", ";
+ << (uint32)getRace() << ", "
+ << (uint32)getClass() << ", "
+ << (uint32)getGender() << ", "
+ << getLevel() << ", "
+ << GetUInt32Value(PLAYER_XP) << ", "
+ << GetMoney() << ", "
+ << GetUInt32Value(PLAYER_BYTES) << ", "
+ << GetUInt32Value(PLAYER_BYTES_2) << ", "
+ << GetUInt32Value(PLAYER_FLAGS) << ", ";
if(!IsBeingTeleported())
{
@@ -16078,8 +16129,12 @@ void Player::SaveToDB()
void Player::SaveInventoryAndGoldToDB()
{
_SaveInventory();
- //money is in data field
- SaveDataFieldToDB();
+ SaveGoldToDB();
+}
+
+void Player::SaveGoldToDB()
+{
+ CharacterDatabase.PExecute("UPDATE characters SET money = '%u' WHERE guid = '%u'", GetMoney(), GetGUIDLow());
}
void Player::_SaveActions()
@@ -16483,38 +16538,31 @@ void Player::SetFloatValueInDB(uint16 index, float value, uint64 guid)
void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair)
{
- Tokens tokens;
- if(!LoadValuesArrayFromDB(tokens, guid))
+ // 0 1 2 3 4
+ QueryResult* result = CharacterDatabase.PQuery("SELECT data, race, class, playerBytes, playerBytes2 FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
+ if(!result)
return;
- uint32 unit_bytes0 = GetUInt32ValueFromArray(tokens, UNIT_FIELD_BYTES_0);
- uint8 race = unit_bytes0 & 0xFF;
- uint8 class_ = (unit_bytes0 >> 8) & 0xFF;
+ Field* fields = result->Fetch();
- PlayerInfo const* info = objmgr.GetPlayerInfo(race, class_);
+ Tokens tokens = StrSplit(fields[0].GetString(), " ");
+
+ PlayerInfo const* info = objmgr.GetPlayerInfo(fields[1].GetUInt8(), fields[2].GetUInt8());
if(!info)
return;
- unit_bytes0 &= ~(0xFF << 16);
- unit_bytes0 |= (gender << 16);
- SetUInt32ValueInArray(tokens, UNIT_FIELD_BYTES_0, unit_bytes0);
-
+ // TODO: do not access data field here
SetUInt32ValueInArray(tokens, UNIT_FIELD_DISPLAYID, gender ? info->displayId_f : info->displayId_m);
SetUInt32ValueInArray(tokens, UNIT_FIELD_NATIVEDISPLAYID, gender ? info->displayId_f : info->displayId_m);
- SetUInt32ValueInArray(tokens, PLAYER_BYTES, (skin | (face << 8) | (hairStyle << 16) | (hairColor << 24)));
-
- uint32 player_bytes2 = GetUInt32ValueFromArray(tokens, PLAYER_BYTES_2);
+ uint32 player_bytes2 = fields[4].GetUInt32();
player_bytes2 &= ~0xFF;
player_bytes2 |= facialHair;
- SetUInt32ValueInArray(tokens, PLAYER_BYTES_2, player_bytes2);
-
- uint32 player_bytes3 = GetUInt32ValueFromArray(tokens, PLAYER_BYTES_3);
- player_bytes3 &= ~0xFF;
- player_bytes3 |= gender;
- SetUInt32ValueInArray(tokens, PLAYER_BYTES_3, player_bytes3);
SaveValuesArrayInDB(tokens, guid);
+ CharacterDatabase.PExecute("UPDATE characters SET gender = '%u', playerBytes = '%u', playerBytes2 = '%u' WHERE guid = '%u'", gender, skin | (face << 8) | (hairStyle << 16) | (hairColor << 24), player_bytes2, GUID_LOPART(guid));
+
+ delete result;
}
void Player::SendAttackSwingDeadTarget()
@@ -18079,8 +18127,8 @@ void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 it
{
// use +MONTH as infinity mark for spell cooldown (will checked as MONTH/2 at save ans skipped)
// but not allow ignore until reset or re-login
- catrecTime = catrec > 0 ? curTime+MONTH : 0;
- recTime = rec > 0 ? curTime+MONTH : catrecTime;
+ catrecTime = catrec > 0 ? curTime+infinityCooldownDelay : 0;
+ recTime = rec > 0 ? curTime+infinityCooldownDelay : catrecTime;
}
else
{
diff --git a/src/game/Player.h b/src/game/Player.h
index 7826ab7495b..12f1ec66722 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -873,7 +873,7 @@ class TRINITY_DLL_SPEC Player : public Unit
void Update( uint32 time );
- void BuildEnumData( QueryResult * result, WorldPacket * p_data );
+ static bool BuildEnumData( QueryResult * result, WorldPacket * p_data );
void SetInWater(bool apply);
@@ -1234,6 +1234,7 @@ class TRINITY_DLL_SPEC Player : public Unit
static uint32 GetUInt32ValueFromDB(uint16 index, uint64 guid);
static float GetFloatValueFromDB(uint16 index, uint64 guid);
static uint32 GetZoneIdFromDB(uint64 guid);
+ static uint32 GetLevelFromDB(uint64 guid);
static bool LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid);
/*********************************************************/
@@ -1242,6 +1243,7 @@ class TRINITY_DLL_SPEC Player : public Unit
void SaveToDB();
void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing
+ void SaveGoldToDB();
void SaveDataFieldToDB();
static bool SaveValuesArrayInDB(Tokens const& data,uint64 guid);
static void SetUInt32ValueInArray(Tokens& data,uint16 index, uint32 value);
@@ -1407,6 +1409,8 @@ class TRINITY_DLL_SPEC Player : public Unit
void DropModCharge(SpellModifier * mod, Spell * spell);
void SetSpellModTakingSpell(Spell* spell, bool apply);
+ static uint32 const infinityCooldownDelay = MONTH; // used for set "infinity cooldowns" for spells and check
+ static uint32 const infinityCooldownDelayCheck = MONTH/2;
bool HasSpellCooldown(uint32 spell_id) const
{
SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
@@ -2179,8 +2183,6 @@ class TRINITY_DLL_SPEC Player : public Unit
void outDebugValues() const;
uint64 m_lootGuid;
- uint32 m_race;
- uint32 m_class;
uint32 m_team;
uint32 m_nextSave;
time_t m_speakTime;
diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp
index 9da24d404f9..7c2bd21e81d 100644
--- a/src/game/QueryHandler.cpp
+++ b/src/game/QueryHandler.cpp
@@ -65,17 +65,17 @@ void WorldSession::SendNameQueryOpcodeFromDB(uint64 guid)
CharacterDatabase.AsyncPQuery(&WorldSession::SendNameQueryOpcodeFromDBCallBack, GetAccountId(),
!sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) ?
// ------- Query Without Declined Names --------
- // 0 1 2
- "SELECT guid, name, SUBSTRING(data, LENGTH(SUBSTRING_INDEX(data, ' ', '%u'))+2, LENGTH(SUBSTRING_INDEX(data, ' ', '%u')) - LENGTH(SUBSTRING_INDEX(data, ' ', '%u'))-1) "
+ // 0 1 2 3 4
+ "SELECT guid, name, race, gender, class "
"FROM characters WHERE guid = '%u'"
:
// --------- Query With Declined Names ---------
- // 0 1 2
- "SELECT characters.guid, name, SUBSTRING(data, LENGTH(SUBSTRING_INDEX(data, ' ', '%u'))+2, LENGTH(SUBSTRING_INDEX(data, ' ', '%u')) - LENGTH(SUBSTRING_INDEX(data, ' ', '%u'))-1), "
- // 3 4 5 6 7
+ // 0 1 2 3 4
+ "SELECT characters.guid, name, race, gender, class, "
+ // 5 6 7 8 9
"genitive, dative, accusative, instrumental, prepositional "
"FROM characters LEFT JOIN character_declinedname ON characters.guid = character_declinedname.guid WHERE characters.guid = '%u'",
- UNIT_FIELD_BYTES_0, UNIT_FIELD_BYTES_0+1, UNIT_FIELD_BYTES_0, GUID_LOPART(guid));
+ GUID_LOPART(guid));
}
void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 accountId)
@@ -93,31 +93,35 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32
Field *fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
std::string name = fields[1].GetCppString();
- uint32 field = 0;
+ uint8 pRace = 0, pGender = 0, pClass = 0;
if(name == "")
name = session->GetTrinityString(LANG_NON_EXIST_CHARACTER);
else
- field = fields[2].GetUInt32();
+ {
+ pRace = fields[2].GetUInt8();
+ pGender = fields[3].GetUInt8();
+ pClass = fields[4].GetUInt8();
+ }
// guess size
WorldPacket data( SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+1+10) );
data.appendPackGUID(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER));
data << uint8(0); // added in 3.1
data << name;
- data << uint8(0);
- data << uint8(field & 0xFF);
- data << uint8((field >> 16) & 0xFF);
- data << uint8((field >> 8) & 0xFF);
+ data << uint8(0); // realm name for cross realm BG usage
+ data << uint8(pRace); // race
+ data << uint8(pGender); // gender
+ data << uint8(pClass); // class
- // if the first declined name field (3) is empty, the rest must be too
- if(sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) && fields[3].GetCppString() != "")
+ // if the first declined name field (5) is empty, the rest must be too
+ if(sWorld.getConfig(CONFIG_DECLINED_NAMES_USED) && fields[5].GetCppString() != "")
{
data << uint8(1); // is declined
- for(int i = 3; i < MAX_DECLINED_NAME_CASES+3; ++i)
+ for(int i = 5; i < MAX_DECLINED_NAME_CASES+5; ++i)
data << fields[i].GetCppString();
}
else
- data << uint8(0); // is declined
+ data << uint8(0); // is not declined
session->SendPacket( &data );
delete result;
diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h
index e63f96e8875..35e16f9d6bf 100644
--- a/src/game/SharedDefines.h
+++ b/src/game/SharedDefines.h
@@ -2384,20 +2384,23 @@ enum DiminishingGroup
{
// Common Groups
DIMINISHING_NONE,
- DIMINISHING_CONTROL_STUN, // Player Controlled stuns
- DIMINISHING_TRIGGER_STUN, // By aura proced stuns, usualy chance on hit talents
- DIMINISHING_CONTROL_ROOT, // Immobilizing effects from casted spells
- DIMINISHING_TRIGGER_ROOT, // Immobilizing effects from triggered spells like Frostbite
+ DIMINISHING_CONTROL_STUN, // Player Controlled stuns
+ DIMINISHING_TRIGGER_STUN, // By aura proced stuns, usualy chance on hit talents
+ DIMINISHING_CONTROL_ROOT, // Immobilizing effects from casted spells
+ DIMINISHING_TRIGGER_ROOT, // Immobilizing effects from triggered spells like Frostbite
DIMINISHING_CHARM,
- DIMINISHING_SLEEP_FREEZE,
DIMINISHING_POLYMORPH, // Also: Gouge, Sap, Repentance, Hungering Cold
- DIMINISHING_CHEAPSHOT_POUNCE,
- DIMINISHING_DEATHCOIL, // Death Coil Diminish only with another Death Coil
- DIMINISHING_SILENCE,
DIMINISHING_KNOCKOUT, // Sap, Knockout mechanics
- DIMINISHING_DISARM,
DIMINISHING_FEAR_BLIND, // Intimidating Shout, Howl of Terror, Blind
- DIMINISHING_FEAR,
+ // Warlock Specific
+ DIMINISHING_DEATHCOIL, // Death Coil Diminish only with another Death Coil
+ // Druid Specific
+ DIMINISHING_CYCLONE, // From 2.3.0
+ // Shared Class Specific
+ DIMINISHING_CHEAPSHOT_POUNCE,
+ DIMINISHING_DISARM, // From 2.3.0
+ DIMINISHING_SILENCE, // From 2.3.0
+ DIMINISHING_FREEZE_SLEEP, // Hunter's Freezing Trap
DIMINISHING_BANISH,
DIMINISHING_TAUNT,
DIMINISHING_LIMITONLY // Don't Diminish, but limit duration to 10s
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 543c56770bd..bb4364f8acf 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -1277,7 +1277,8 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
{
// Now Reduce spell duration using data received at spell hit
int32 duration = Aur->GetAuraMaxDuration();
- unit->ApplyDiminishingToDuration(m_diminishGroup,duration,caster,m_diminishLevel);
+ int32 limitduration = GetDiminishingReturnsLimitDuration(m_diminishGroup,m_spellInfo);
+ unitTarget->ApplyDiminishingToDuration(m_diminishGroup, duration, m_caster, m_diminishLevel,limitduration);
Aur->setDiminishGroup(m_diminishGroup);
duration = caster->ModSpellDuration(m_spellInfo, unit, duration, Aur->IsPositive());
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index d5ee8a0b731..f4d11916fbe 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -2860,6 +2860,7 @@ void Spell::EffectCreateItem2(uint32 i)
Player* player = (Player*)m_caster;
uint32 item_id = m_spellInfo->EffectItemType[i];
+
DoCreateItem(i, item_id);
// special case: fake item replaced by generate using spell_loot_template
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp
index 63aa32aa21c..c020f4f446a 100644
--- a/src/game/SpellMgr.cpp
+++ b/src/game/SpellMgr.cpp
@@ -2561,11 +2561,8 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto
{
case SPELLFAMILY_ROGUE:
{
- // Sap
- if (spellproto->SpellFamilyFlags[0] & 0x80)
- return DIMINISHING_POLYMORPH;
- // Gouge
- else if (spellproto->SpellFamilyFlags[0] & 0x8)
+ // Sap 0x80 Gouge 0x8
+ if (spellproto->SpellFamilyFlags[0] & 0x88)
return DIMINISHING_POLYMORPH;
// Blind
else if (spellproto->SpellFamilyFlags[0] & 0x1000000)
@@ -2586,6 +2583,9 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto
// Howl of Terror
else if (spellproto->SpellFamilyFlags[1] & 0x8)
return DIMINISHING_FEAR_BLIND;
+ // Seduction
+ else if (spellproto->SpellFamilyFlags[1] & 0x40000000)
+ return DIMINISHING_CHARM;
break;
}
case SPELLFAMILY_DRUID:
@@ -2593,7 +2593,9 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto
// Pounce
if (spellproto->SpellFamilyFlags[0] & 0x20000)
return DIMINISHING_CHEAPSHOT_POUNCE;
-
+ // Cyclone
+ else if (spellproto->SpellFamilyFlags[1] & 0x20)
+ return DIMINISHING_CYCLONE;
//Entangling Roots: to force natures grasp proc to be control root
else if (spellproto->SpellFamilyFlags[0] & 0x00000200)
return DIMINISHING_CONTROL_ROOT;
@@ -2624,11 +2626,14 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto
// Repentance
if (spellproto->SpellFamilyFlags[0] & 0x4)
return DIMINISHING_POLYMORPH;
+ // Turn Evil
+ else if (spellproto->SpellFamilyFlags[1] & 0x8040)
+ return DIMINISHING_FEAR_BLIND;
break;
}
case SPELLFAMILY_DEATHKNIGHT:
{
- // Hungering Cold
+ // Hungering Cold (no flags)
if (spellproto->SpellIconID == 2797)
return DIMINISHING_POLYMORPH;
break;
@@ -2641,10 +2646,10 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto
uint32 mechanic = GetAllSpellMechanicMask(spellproto);
if (mechanic == MECHANIC_NONE) return DIMINISHING_NONE;
if (mechanic & (1<<MECHANIC_STUN)) return triggered ? DIMINISHING_TRIGGER_STUN : DIMINISHING_CONTROL_STUN;
- if (mechanic & ((1<<MECHANIC_SLEEP) | (1<<MECHANIC_FREEZE))) return DIMINISHING_SLEEP_FREEZE;
+ if (mechanic & ((1<<MECHANIC_SLEEP) | (1<<MECHANIC_FREEZE))) return DIMINISHING_FREEZE_SLEEP;
if (mechanic & (1<<MECHANIC_POLYMORPH)) return DIMINISHING_POLYMORPH;
if (mechanic & (1<<MECHANIC_ROOT)) return triggered ? DIMINISHING_TRIGGER_ROOT : DIMINISHING_CONTROL_ROOT;
- if (mechanic & (1<<MECHANIC_FEAR)) return DIMINISHING_FEAR;
+ if (mechanic & (1<<MECHANIC_FEAR)) return DIMINISHING_FEAR_BLIND;
if (mechanic & (1<<MECHANIC_CHARM)) return DIMINISHING_CHARM;
if (mechanic & (1<<MECHANIC_SILENCE)) return DIMINISHING_SILENCE;
if (mechanic & (1<<MECHANIC_DISARM)) return DIMINISHING_DISARM;
@@ -2661,20 +2666,49 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto
return DIMINISHING_NONE;
}
+int32 GetDiminishingReturnsLimitDuration(DiminishingGroup group, SpellEntry const* spellproto)
+{
+ if(!IsDiminishingReturnsGroupDurationLimited(group))
+ return 0;
+
+ // Explicit diminishing duration
+ switch(spellproto->SpellFamilyName)
+ {
+ case SPELLFAMILY_HUNTER:
+ {
+ // Wyvern Sting
+ if (spellproto->SpellFamilyFlags[1] & 0x1000)
+ return 6000;
+ break;
+ }
+ case SPELLFAMILY_PALADIN:
+ {
+ // Repentance - limit to 6 seconds in PvP
+ if (spellproto->SpellFamilyFlags[0] & 0x4)
+ return 6000;
+ break;
+ }
+ default:
+ break;
+ }
+
+ return 10000;
+}
+
bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group)
{
switch(group)
{
case DIMINISHING_CONTROL_STUN:
case DIMINISHING_TRIGGER_STUN:
- case DIMINISHING_SLEEP_FREEZE:
+ case DIMINISHING_FREEZE_SLEEP:
case DIMINISHING_CONTROL_ROOT:
case DIMINISHING_TRIGGER_ROOT:
- case DIMINISHING_FEAR:
case DIMINISHING_FEAR_BLIND:
case DIMINISHING_CHARM:
case DIMINISHING_POLYMORPH:
case DIMINISHING_KNOCKOUT:
+ case DIMINISHING_CYCLONE:
case DIMINISHING_BANISH:
case DIMINISHING_LIMITONLY:
case DIMINISHING_CHEAPSHOT_POUNCE:
@@ -2694,17 +2728,17 @@ DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group)
case DIMINISHING_TRIGGER_STUN:
case DIMINISHING_CHEAPSHOT_POUNCE:
case DIMINISHING_FEAR_BLIND:
+ case DIMINISHING_CYCLONE:
return DRTYPE_ALL;
- case DIMINISHING_BANISH:
case DIMINISHING_CONTROL_ROOT:
case DIMINISHING_TRIGGER_ROOT:
- case DIMINISHING_FEAR:
case DIMINISHING_CHARM:
case DIMINISHING_POLYMORPH:
case DIMINISHING_SILENCE:
case DIMINISHING_DISARM:
case DIMINISHING_DEATHCOIL:
- case DIMINISHING_SLEEP_FREEZE:
+ case DIMINISHING_FREEZE_SLEEP:
+ case DIMINISHING_BANISH:
case DIMINISHING_KNOCKOUT:
return DRTYPE_PLAYER;
default:
diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h
index 3616e52e07c..afdf75a8399 100644
--- a/src/game/SpellMgr.h
+++ b/src/game/SpellMgr.h
@@ -218,7 +218,7 @@ inline bool IsExplicitDiscoverySpell(SpellEntry const *spellInfo)
inline bool IsLootCraftingSpell(SpellEntry const *spellInfo)
{
- return spellInfo->Effect[0]==SPELL_EFFECT_CREATE_RANDOM_ITEM ||
+ return spellInfo->Effect[0]==SPELL_EFFECT_CREATE_RANDOM_ITEM ||
// different random cards from Inscription (121==Virtuoso Inking Set category)
spellInfo->Effect[0]==SPELL_EFFECT_CREATE_ITEM_2 && spellInfo->TotemCategory[0] == 121;
}
@@ -380,6 +380,7 @@ inline uint32 GetDispellMask(DispelType dispel)
DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto, bool triggered);
bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group);
DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group);
+int32 GetDiminishingReturnsLimitDuration(DiminishingGroup group, SpellEntry const* spellproto);
// Spell affects related declarations (accessed using SpellMgr functions)
typedef UNORDERED_MAP<uint32, flag96> SpellAffectMap;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 06f2b4e2b93..9fc8a8496e5 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -11537,7 +11537,7 @@ void Unit::IncrDiminishing(DiminishingGroup group)
m_Diminishing.push_back(DiminishingReturn(group,getMSTime(),DIMINISHING_LEVEL_2));
}
-void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster,DiminishingLevels Level)
+void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster,DiminishingLevels Level, int32 limitduration)
{
if(duration == -1 || group == DIMINISHING_NONE || caster->IsFriendlyTo(this) )
return;
@@ -11547,13 +11547,13 @@ void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Un
Unit const* casterOwner = caster->GetCharmerOrOwner();
// Duration of crowd control abilities on pvp target is limited by 10 sec. (2.2.0)
- if(duration > 10000 && IsDiminishingReturnsGroupDurationLimited(group))
+ if(limitduration > 0 && duration > limitduration)
{
Unit const* target = targetOwner ? targetOwner : this;
Unit const* source = casterOwner ? casterOwner : caster;
if(target->GetTypeId() == TYPEID_PLAYER && source->GetTypeId() == TYPEID_PLAYER)
- duration = 10000;
+ duration = limitduration;
}
float mod = 1.0f;
diff --git a/src/game/Unit.h b/src/game/Unit.h
index d55b272e96f..e6dec8a5cc5 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1015,7 +1015,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
DiminishingLevels GetDiminishing(DiminishingGroup group);
void IncrDiminishing(DiminishingGroup group);
- void ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster, DiminishingLevels Level);
+ void ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Unit* caster, DiminishingLevels Level, int32 limitduration);
void ApplyDiminishingAura(DiminishingGroup group, bool apply);
void ClearDiminishings() { m_Diminishing.clear(); }
diff --git a/src/game/World.cpp b/src/game/World.cpp
index 608aaec01d5..e5b6c7e5280 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -2068,8 +2068,8 @@ void World::ScriptsProcess()
sLog.outError("SCRIPT_COMMAND_MOVE_TO call for non-creature (TypeId: %u), skipping.",source->GetTypeId());
break;
}
- ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, step.script->datalong2 );
- ((Unit *)source)->GetMap()->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0);
+ ((Creature*)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, step.script->datalong2 );
+ ((Creature*)source)->GetMap()->CreatureRelocation(((Creature*)source), step.script->x, step.script->y, step.script->z, 0);
break;
case SCRIPT_COMMAND_FLAG_SET:
if(!source)
diff --git a/src/shared/Errors.h b/src/shared/Errors.h
index 218ab561c12..5cfd109ee01 100644
--- a/src/shared/Errors.h
+++ b/src/shared/Errors.h
@@ -21,10 +21,21 @@
#ifndef TRINITYCORE_ERRORS_H
#define TRINITYCORE_ERRORS_H
-//#include <ace/Stack_Trace.h>
+#include "Common.h"
-//#define WPAssert( assertion ) { if (!(assertion)) { ACE_Stack_Trace st; fprintf( stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n%s\n", __FILE__, __LINE__,__FUNCTION__, #assertion, st.c_str()); assert( #assertion &&0 ); } }
-#define WPAssert( assertion ) { if( !(assertion) ) { fprintf( stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n", __FILE__, __LINE__,__FUNCTION__, #assertion ); assert( #assertion &&0 ); } }
+#ifndef HAVE_CONFIG_H
+#define HAVE_ACE_STACK_TRACE_H 1
+#endif
+
+#ifdef HAVE_ACE_STACK_TRACE_H
+#include "ace/Stack_Trace.h"
+#endif
+
+#ifdef HAVE_ACE_STACK_TRACE_H // old versions ACE not have Stack_Trace.h but used at some oS for better compatibility
+#define WPAssert( assertion ) { if (!(assertion)) { ACE_Stack_Trace st; fprintf( stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n%s\n", __FILE__, __LINE__,__FUNCTION__, #assertion, st.c_str()); assert( #assertion &&0 ); } }
+#else
+#define WPAssert( assertion ) { if (!(assertion)) { fprintf( stderr, "\n%s:%i in %s ASSERTION FAILED2:\n %s\n", __FILE__, __LINE__,__FUNCTION__, #assertion); assert( #assertion &&0 ); } }
+#endif
#define WPError( assertion, errmsg ) if( ! (assertion) ) { sLog.outError( "%\n%s:%i in %s ERROR:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg ); assert( false ); }
#define WPWarning( assertion, errmsg ) if( ! (assertion) ) { sLog.outError( "\n%s:%i in %s WARNING:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg ); }
diff --git a/src/shared/LockedQueue.h b/src/shared/LockedQueue.h
index b085dd09b83..4087ebff0cf 100644
--- a/src/shared/LockedQueue.h
+++ b/src/shared/LockedQueue.h
@@ -27,11 +27,9 @@
namespace ACE_Based
{
-
template <class T, class LockType, typename StorageType=std::deque<T> >
class LockedQueue
{
-
//! Serialize access to the Queue
LockType _lock;
@@ -54,14 +52,12 @@ namespace ACE_Based
*/
void add(const T& item)
{
+ ACE_Guard<LockType> g(this->_lock);
- ACE_Guard<LockType> g(_lock);
-
- ASSERT(!_canceled);
- // throw Cancellation_Exception();
-
- _queue.push_back(item);
+ ASSERT(!this->_canceled);
+ // throw Cancellation_Exception();
+ this->_queue.push_back(item);
}
/**
@@ -69,27 +65,25 @@ namespace ACE_Based
*/
T next()
{
+ ACE_Guard<LockType> g(this->_lock);
- ACE_Guard<LockType> g(_lock);
+ ASSERT (!_queue.empty() || !this->_canceled);
+ // throw Cancellation_Exception();
- ASSERT (!_queue.empty() || !_canceled);
- // throw Cancellation_Exception();
-
- T item = _queue.front();
- _queue.pop_front();
+ T item = this->_queue.front();
+ this->_queue.pop_front();
return item;
-
}
T front()
{
- ACE_Guard<LockType> g(_lock);
+ ACE_Guard<LockType> g(this->_lock);
- ASSERT (!_queue.empty());
- // throw NoSuchElement_Exception();
+ ASSERT (!this->_queue.empty());
+ // throw NoSuchElement_Exception();
- return _queue.front();
+ return this->_queue.front();
}
/**
@@ -97,11 +91,9 @@ namespace ACE_Based
*/
void cancel()
{
+ ACE_Guard<LockType> g(this->_lock);
- ACE_Guard<LockType> g(_lock);
-
- _canceled = true;
-
+ this->_canceled = true;
}
/**
@@ -109,15 +101,13 @@ namespace ACE_Based
*/
bool isCanceled()
{
-
// Faster check since the queue will not become un-canceled
- if(_canceled)
+ if(this->_canceled)
return true;
- ACE_Guard<LockType> g(_lock);
-
- return _canceled;
+ ACE_Guard<LockType> g(this->_lock);
+ return this->_canceled;
}
/**
@@ -125,20 +115,15 @@ namespace ACE_Based
*/
size_t size()
{
-
- ACE_Guard<LockType> g(_lock);
- return _queue.size();
-
+ ACE_Guard<LockType> g(this->_lock);
+ return this->_queue.size();
}
bool empty()
{
-
- ACE_Guard<LockType> g(_lock);
- return _queue.empty();
+ ACE_Guard<LockType> g(this->_lock);
+ return this->_queue.empty();
}
-
};
-
}
#endif
diff --git a/src/shared/vmap/CoordModelMapping.cpp b/src/shared/vmap/CoordModelMapping.cpp
index 86e3347a614..39d1165f115 100644
--- a/src/shared/vmap/CoordModelMapping.cpp
+++ b/src/shared/vmap/CoordModelMapping.cpp
@@ -21,7 +21,7 @@
#include "CoordModelMapping.h"
#include <string.h>
-#include <cstdio>
+#include <stdio.h>
using namespace G3D;
@@ -45,6 +45,13 @@ namespace VMAP
return(CMappingEntry::getKeyString(iMapId,xPos, yPos));
}
+ const std::string CMappingEntry::getKeyString( unsigned int pMapId, int pXPos, int pYPos )
+ {
+ char b[100];
+ sprintf(b,"%03u_%d_%d", pMapId, pXPos, pYPos);
+ return(std::string(b));
+ }
+
//============================================================
//============================================================
//============================================================
diff --git a/src/shared/vmap/CoordModelMapping.h b/src/shared/vmap/CoordModelMapping.h
index c1f49462962..7684bf1b373 100644
--- a/src/shared/vmap/CoordModelMapping.h
+++ b/src/shared/vmap/CoordModelMapping.h
@@ -75,12 +75,7 @@ namespace VMAP
const std::string getKeyString() const;
inline const G3D::Array<std::string>& getFilenames() const { return(iFilenames); }
- static const std::string getKeyString(unsigned int pMapId, int pXPos, int pYPos)
- {
- char b[100];
- sprintf(b,"%03u_%d_%d", pMapId, pXPos, pYPos);
- return(std::string(b));
- }
+ static const std::string getKeyString(unsigned int pMapId, int pXPos, int pYPos);
};
diff --git a/src/shared/vmap/DebugCmdLogger.cpp b/src/shared/vmap/DebugCmdLogger.cpp
index e6b36572c45..c899606045b 100644
--- a/src/shared/vmap/DebugCmdLogger.cpp
+++ b/src/shared/vmap/DebugCmdLogger.cpp
@@ -21,6 +21,7 @@
#include <cstdio>
#include "DebugCmdLogger.h"
+#include <stdio.h>
using namespace G3D;
diff --git a/src/trinitycore/Master.cpp b/src/trinitycore/Master.cpp
index 4d7eca8f04e..b7159225f42 100644
--- a/src/trinitycore/Master.cpp
+++ b/src/trinitycore/Master.cpp
@@ -182,7 +182,7 @@ public:
{
while (!World::IsStopped())
{
- ACE_Based::Thread::Sleep (static_cast<unsigned long> (socketSelecttime / 1000));
+ ACE_Based::Thread::Sleep(static_cast<unsigned long> (socketSelecttime / 1000));
checkping ();
}
}
diff --git a/src/trinityrealm/AuthSocket.cpp b/src/trinityrealm/AuthSocket.cpp
index 8c9eab653ec..80e8184605b 100644
--- a/src/trinityrealm/AuthSocket.cpp
+++ b/src/trinityrealm/AuthSocket.cpp
@@ -946,7 +946,7 @@ bool AuthSocket::_HandleXferAccept()
ibuf.Remove(1); //clear input buffer
fseek(pPatch,0,0);
- ACE_Based::Thread u(*new PatcherRunnable(this));
+ ACE_Based::Thread u(*new PatcherRunnable(this));
return true;
}