aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/AuctionHouse.cpp9
-rw-r--r--src/game/CharacterHandler.cpp45
-rw-r--r--src/game/Guild.cpp33
-rw-r--r--src/game/MotionMaster.cpp11
-rw-r--r--src/game/ObjectMgr.cpp4
-rw-r--r--src/game/Opcodes.h7
-rw-r--r--src/game/PetitionsHandler.cpp2
-rw-r--r--src/game/Player.cpp4
-rw-r--r--src/game/SpellMgr.cpp6
-rw-r--r--src/game/Unit.cpp17
10 files changed, 86 insertions, 52 deletions
diff --git a/src/game/AuctionHouse.cpp b/src/game/AuctionHouse.cpp
index 8a2ce27d24d..71a8bb495b4 100644
--- a/src/game/AuctionHouse.cpp
+++ b/src/game/AuctionHouse.cpp
@@ -367,10 +367,15 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
return;
}
- if ((price < (auction->bid + objmgr.GetAuctionOutBid(auction->bid))) && ((price < auction->buyout) || (auction->buyout == 0)))
+ // cheating
+ if(price <= auction->bid)
+ return;
+
+ // price too low for next bid if not buyout
+ if ((price < auction->buyout || auction->buyout == 0) &&
+ price < auction->bid + objmgr.GetAuctionOutBid(auction->bid))
{
//auction has already higher bid, client tests it!
- //SendAuctionCommandResult(auction->auctionId, AUCTION_PLACE_BID, ???);
return;
}
diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
index f5d0ff73bbf..aa884ddd2df 100644
--- a/src/game/CharacterHandler.cpp
+++ b/src/game/CharacterHandler.cpp
@@ -937,32 +937,28 @@ void WorldSession::HandleChangePlayerNameOpcode(WorldPacket& recv_data)
return;
}
- CharacterDatabase.escape_string(newname);
-
- CharacterDatabase.AsyncPQuery(&WorldSession::HandleChangePlayerNameOpcodeCallBack, GUID_LOPART(guid), newname, "SELECT guid, at_login, name FROM characters WHERE guid = '%u' XOR name = '%s'", GUID_LOPART(guid), newname.c_str());
+ std::string escaped_newname = newname;
+ CharacterDatabase.escape_string(escaped_newname);
+
+ // make sure that the character belongs to the current account, that rename at login is enabled
+ // and that there is no character with the desired new name
+ CharacterDatabase.AsyncPQuery(&WorldSession::HandleChangePlayerNameOpcodeCallBack,
+ GetAccountId(), newname,
+ "SELECT guid, name FROM characters WHERE guid = %d AND account = %d AND (at_login & %d) = %d AND NOT EXISTS (SELECT NULL FROM characters WHERE name = '%s')",
+ GUID_LOPART(guid), GetAccountId(), AT_LOGIN_RENAME, AT_LOGIN_RENAME, escaped_newname.c_str()
+ );
}
void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uint32 accountId, std::string newname)
{
WorldSession * session = sWorld.FindSession(accountId);
if(!session)
- return;
-
- if (!result || result->GetRowCount() != 1)
{
- WorldPacket data(SMSG_CHAR_RENAME, 1);
- data << (uint8)CHAR_CREATE_ERROR;
- session->SendPacket( &data );
+ if(result) delete result;
return;
}
- Field *fields = result->Fetch();
- uint32 guidLow = fields[0].GetUInt32();
- uint64 guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
- uint32 at_loginFlags = fields[1].GetUInt32();
- std::string oldname = fields[2].GetCppString();
- delete result;
- if(oldname == newname)
+ if (!result)
{
WorldPacket data(SMSG_CHAR_RENAME, 1);
data << (uint8)CHAR_CREATE_ERROR;
@@ -970,19 +966,16 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uin
return;
}
- // we have to check character at_login_flag & AT_LOGIN_RENAME also (fake packets hehe)
- if (!(at_loginFlags & AT_LOGIN_RENAME))
- {
- WorldPacket data(SMSG_CHAR_RENAME, 1);
- data << (uint8)CHAR_CREATE_ERROR;
- session->SendPacket( &data );
- return;
- }
+ uint32 guidLow = result->Fetch()[0].GetUInt32();
+ uint64 guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
+ std::string oldname = result->Fetch()[1].GetCppString();
+
+ delete result;
- 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 = at_login & ~ %u WHERE guid ='%u'", newname.c_str(), uint32(AT_LOGIN_RENAME), guidLow);
CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid ='%u'", guidLow);
- sLog.outChar("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());
+ sLog.outChar("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());
WorldPacket data(SMSG_CHAR_RENAME,1+8+(newname.size()+1));
data << (uint8)RESPONSE_SUCCESS;
diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp
index df2554db9ea..897110afe55 100644
--- a/src/game/Guild.cpp
+++ b/src/game/Guild.cpp
@@ -376,28 +376,41 @@ bool Guild::FillPlayerData(uint64 guid, MemberSlot* memslot)
}
else
{
- if(!objmgr.GetPlayerNameByGUID(guid, plName)) // player doesn't exist
- return false;
+ 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
+
+ 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;
- plLevel = Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL, guid);
if(plLevel<1||plLevel>STRONG_MAX_LEVEL) // can be at broken `data` field
{
sLog.outError("Player (GUID: %u) has a broken data in field `characters`.`data`.",GUID_LOPART(guid));
return false;
}
- plZone = Player::GetZoneIdFromDB(guid);
- QueryResult *result = CharacterDatabase.PQuery("SELECT class FROM characters WHERE guid='%u'", GUID_LOPART(guid));
- if(!result)
- return false;
- plClass = (*result)[0].GetUInt32();
+ if(!plZone)
+ {
+ sLog.outError("Player (GUID: %u) has broken zone-data",GUID_LOPART(guid));
+ //here it will also try the same, to get the zone from characters-table, but additional it tries to find
+ plZone = Player::GetZoneIdFromDB(guid);
+ //the zone through xy coords.. this is a bit redundant, but
+ //shouldn't be called often
+ }
+
if(plClass<CLASS_WARRIOR||plClass>=MAX_CLASSES) // can be at broken `class` field
{
sLog.outError("Player (GUID: %u) has a broken data in field `characters`.`class`.",GUID_LOPART(guid));
return false;
}
-
- delete result;
}
}
diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp
index 4b667ad9ccd..36bdbbb3a01 100644
--- a/src/game/MotionMaster.cpp
+++ b/src/game/MotionMaster.cpp
@@ -163,8 +163,17 @@ MotionMaster::MoveTargetedHome()
}
else if(i_owner->GetTypeId()==TYPEID_UNIT && ((Creature*)i_owner)->GetCharmerOrOwnerGUID())
{
- sLog.outError("Pet or controlled creature (Entry: %u GUID: %u) attempt targeted home",
+ DEBUG_LOG("Pet or controlled creature (Entry: %u GUID: %u) targeting home",
i_owner->GetEntry(), i_owner->GetGUIDLow() );
+ Unit *target = ((Creature*)i_owner)->GetCharmerOrOwner();
+ if(target)
+ {
+ i_owner->addUnitState(UNIT_STAT_FOLLOW);
+ DEBUG_LOG("Following %s (GUID: %u)",
+ target->GetTypeId()==TYPEID_PLAYER ? "player" : "creature",
+ target->GetTypeId()==TYPEID_PLAYER ? target->GetGUIDLow() : ((Creature*)target)->GetDBTableGUIDLow() );
+ Mutate(new TargetedMovementGenerator<Creature>(*target,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE));
+ }
}
else
{
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 06bc3b95304..594cfaf0877 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -640,7 +640,7 @@ void ObjectMgr::LoadCreatureLocales()
sLog.outString();
sLog.outString( ">> Loaded %u creature locale strings", mCreatureLocaleMap.size() );
}
-
+
void ObjectMgr::LoadNpcOptionLocales()
{
mNpcOptionLocaleMap.clear(); // need for reload case
@@ -2194,6 +2194,8 @@ void ObjectMgr::LoadPlayerInfo()
{
barGoLink bar( 1 );
+ bar.step();
+
sLog.outString();
sLog.outString( ">> Loaded %u custom player create items", count );
}
diff --git a/src/game/Opcodes.h b/src/game/Opcodes.h
index 457058b957c..202166a57a0 100644
--- a/src/game/Opcodes.h
+++ b/src/game/Opcodes.h
@@ -27,6 +27,12 @@
#include "Common.h"
+// Note: this include need for be sure have full definition of class WorldSession
+// if this class definition not complite then VS for x64 release use different size for
+// struct OpcodeHandler in this header and Opcode.cpp and get totally wrong data from
+// table opcodeTable in source when Opcode.h included but WorldSession.h not included
+#include "WorldSession.h"
+
/// List of Opcodes
enum Opcodes
{
@@ -1104,7 +1110,6 @@ enum SessionStatus
STATUS_NEVER ///< Opcode not accepted from client (deprecated or server side only)
};
-class WorldSession;
class WorldPacket;
struct OpcodeHandler
diff --git a/src/game/PetitionsHandler.cpp b/src/game/PetitionsHandler.cpp
index 52e6559073b..8fc18b1c259 100644
--- a/src/game/PetitionsHandler.cpp
+++ b/src/game/PetitionsHandler.cpp
@@ -113,7 +113,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
// TODO: find correct opcode
if(_player->getLevel() < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
{
- SendNotification(LANG_ARENA_ONE_TOOLOW, 70);
+ SendNotification(LANG_ARENA_ONE_TOOLOW, sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
return;
}
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 314e6c5ac09..1f3e4e120f9 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -11641,9 +11641,9 @@ void Player::ApplyEnchantment(Item *item,EnchantmentSlot slot,bool apply, bool a
{
if(apply)
{
- int32 basepoints = int32(enchant_amount);
+ int32 basepoints = 0;
// Random Property Exist - try found basepoints for spell (basepoints depends from item suffix factor)
- if (item->GetItemRandomPropertyId() !=0 && !enchant_amount)
+ if (item->GetItemRandomPropertyId())
{
ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId()));
if (item_rand)
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp
index 18fcf5ecdfa..43bb112360c 100644
--- a/src/game/SpellMgr.cpp
+++ b/src/game/SpellMgr.cpp
@@ -2161,15 +2161,15 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg)
}
case SPELL_EFFECT_LEARN_SPELL:
{
- SpellEntry const* spellInfo2 = sSpellStore.LookupEntry(spellInfo->EffectTriggerSpell[0]);
+ SpellEntry const* spellInfo2 = sSpellStore.LookupEntry(spellInfo->EffectTriggerSpell[i]);
if( !IsSpellValid(spellInfo2,pl,msg) )
{
if(msg)
{
if(pl)
- ChatHandler(pl).PSendSysMessage("Spell %u learn to broken spell %u, and then...",spellInfo->Id,spellInfo->EffectTriggerSpell[0]);
+ ChatHandler(pl).PSendSysMessage("Spell %u learn to broken spell %u, and then...",spellInfo->Id,spellInfo->EffectTriggerSpell[i]);
else
- sLog.outErrorDb("Spell %u learn to invalid spell %u, and then...",spellInfo->Id,spellInfo->EffectTriggerSpell[0]);
+ sLog.outErrorDb("Spell %u learn to invalid spell %u, and then...",spellInfo->Id,spellInfo->EffectTriggerSpell[i]);
}
return false;
}
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 6541a098922..50691592983 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -10274,8 +10274,12 @@ bool Unit::CanHaveThreatList() const
if( !isAlive() )
return false;
- // pets and totems can not have threat list
- if( ((Creature*)this)->isPet() || ((Creature*)this)->isTotem() )
+ // totems can not have threat list
+ if( ((Creature*)this)->isTotem() )
+ return false;
+
+ // pets can not have a threat list, unless they are controlled by a creature
+ if( ((Creature*)this)->isPet() && IS_PLAYER_GUID(((Pet*)this)->GetOwnerGUID()) )
return false;
return true;
@@ -10454,9 +10458,12 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde
uint8 comboPoints = unitPlayer ? unitPlayer->GetComboPoints() : 0;
- int32 level = int32(getLevel()) - int32(spellProto->spellLevel);
- if (level > spellProto->maxLevel && spellProto->maxLevel > 0)
- level = spellProto->maxLevel;
+ int32 level = int32(getLevel());
+ if (level > (int32)spellProto->maxLevel && spellProto->maxLevel > 0)
+ level = (int32)spellProto->maxLevel;
+ else if (level < (int32)spellProto->baseLevel)
+ level = (int32)spellProto->baseLevel;
+ level-= (int32)spellProto->spellLevel;
float basePointsPerLevel = spellProto->EffectRealPointsPerLevel[effect_index];
float randomPointsPerLevel = spellProto->EffectDicePerLevel[effect_index];