From 69e9ab315f760458b7ba8d88019979f815024d1c Mon Sep 17 00:00:00 2001 From: arrai Date: Wed, 10 Dec 2008 14:43:22 +0100 Subject: [PATCH 1/6] [6890] Implemented more correct way of calculating fall damage by using fall distance and not fall time. Thanks to DasMy for finding an appropriate formula --- src/game/MovementHandler.cpp | 20 ++++++++++++-------- src/game/Player.h | 1 + src/shared/revision_nr.h | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 55c7e4cf6..10f8c315b 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -290,22 +290,24 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) // fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map). if (recv_data.GetOpcode() == MSG_MOVE_FALL_LAND && !GetPlayer()->isInFlight()) { + // calculate total z distance of the fall + float z_diff = GetPlayer()->m_fallMovementInfo.z - movementInfo.z; + sLog.outDebug("zDiff = %f", z_diff); Player *target = GetPlayer(); - //Players with Feather Fall or low fall time, or physical immunity (charges used) are ignored - if (movementInfo.fallTime > 1100 && !target->isDead() && !target->isGameMaster() && + //Players with Feather Fall or physical immunity (charges used) are ignored + if (!target->isDead() && !target->isGameMaster() && !target->HasAuraType(SPELL_AURA_HOVER) && !target->HasAuraType(SPELL_AURA_FEATHER_FALL) && !target->HasAuraType(SPELL_AURA_FLY) && !target->IsImmunedToDamage(SPELL_SCHOOL_MASK_NORMAL,true) ) { - //Safe fall, fall time reduction + //Safe fall, fall height reduction int32 safe_fall = target->GetTotalAuraModifier(SPELL_AURA_SAFE_FALL); - uint32 fall_time = (movementInfo.fallTime > (safe_fall*10)) ? movementInfo.fallTime - (safe_fall*10) : 0; - if(fall_time > 1100) //Prevent damage if fall time < 1100 + float damageperc = 0.018f*(z_diff-safe_fall)-0.2426f; + + if(damageperc >0 ) { - //Fall Damage calculation - float fallperc = float(fall_time)/1100; - uint32 damage = (uint32)(((fallperc*fallperc -1) / 9 * target->GetMaxHealth())*sWorld.getRate(RATE_DAMAGE_FALL)); + uint32 damage = (uint32)(damageperc * target->GetMaxHealth()*sWorld.getRate(RATE_DAMAGE_FALL)); float height = movementInfo.z; target->UpdateGroundPositionZ(movementInfo.x,movementInfo.y,height); @@ -359,6 +361,8 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) GetPlayer()->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o); GetPlayer()->m_movementInfo = movementInfo; + if (GetPlayer()->m_fallMovementInfo.fallTime >= movementInfo.fallTime || GetPlayer()->m_fallMovementInfo.z <=movementInfo.z) + GetPlayer()->m_fallMovementInfo = movementInfo; if(GetPlayer()->isMovingOrTurning()) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); diff --git a/src/game/Player.h b/src/game/Player.h index 821f3bb6e..635a7ad76 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1910,6 +1910,7 @@ class MANGOS_DLL_SPEC Player : public Unit /*** VARIOUS SYSTEMS ***/ /*********************************************************/ MovementInfo m_movementInfo; + MovementInfo m_fallMovementInfo; bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask); } bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 23ee369fe..18a39532e 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6889" + #define REVISION_NR "6890" #endif // __REVISION_NR_H__ From 9f8e51ff41e0e39547e33c37e36fa837272e55f5 Mon Sep 17 00:00:00 2001 From: arrai Date: Wed, 10 Dec 2008 16:01:29 +0100 Subject: [PATCH 2/6] [6891] small performance fix for previous commit --- src/game/MovementHandler.cpp | 14 +++++++++----- src/game/Player.h | 3 ++- src/shared/revision_nr.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 10f8c315b..f94718906 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -291,12 +291,13 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) if (recv_data.GetOpcode() == MSG_MOVE_FALL_LAND && !GetPlayer()->isInFlight()) { // calculate total z distance of the fall - float z_diff = GetPlayer()->m_fallMovementInfo.z - movementInfo.z; + float z_diff = GetPlayer()->m_lastFallZ - movementInfo.z; sLog.outDebug("zDiff = %f", z_diff); Player *target = GetPlayer(); - //Players with Feather Fall or physical immunity (charges used) are ignored - if (!target->isDead() && !target->isGameMaster() && + //Players with low fall distance, Feather Fall or physical immunity (charges used) are ignored + // 14.57 can be calculated by resolving damageperc formular below to 0 + if (z_diff >= 14.57f && !target->isDead() && !target->isGameMaster() && !target->HasAuraType(SPELL_AURA_HOVER) && !target->HasAuraType(SPELL_AURA_FEATHER_FALL) && !target->HasAuraType(SPELL_AURA_FLY) && !target->IsImmunedToDamage(SPELL_SCHOOL_MASK_NORMAL,true) ) { @@ -361,8 +362,11 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) GetPlayer()->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o); GetPlayer()->m_movementInfo = movementInfo; - if (GetPlayer()->m_fallMovementInfo.fallTime >= movementInfo.fallTime || GetPlayer()->m_fallMovementInfo.z <=movementInfo.z) - GetPlayer()->m_fallMovementInfo = movementInfo; + if (GetPlayer()->m_lastFallTime >= movementInfo.fallTime || GetPlayer()->m_lastFallZ <=movementInfo.z) + { + GetPlayer()->m_lastFallTime = movementInfo.fallTime; + GetPlayer()->m_lastFallZ= movementInfo.z; + } if(GetPlayer()->isMovingOrTurning()) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); diff --git a/src/game/Player.h b/src/game/Player.h index 635a7ad76..a6915fbf4 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1910,7 +1910,8 @@ class MANGOS_DLL_SPEC Player : public Unit /*** VARIOUS SYSTEMS ***/ /*********************************************************/ MovementInfo m_movementInfo; - MovementInfo m_fallMovementInfo; + uint32 m_lastFallTime; + float m_lastFallZ; bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask); } bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 18a39532e..27a2b558c 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6890" + #define REVISION_NR "6891" #endif // __REVISION_NR_H__ From 2e2055c4693d4cefc514eb58a696a28291bb6df8 Mon Sep 17 00:00:00 2001 From: hunuza Date: Wed, 10 Dec 2008 16:41:46 +0100 Subject: [PATCH 3/6] [6892] Some small code clean ups and optimisations. Signed-off-by: hunuza --- src/game/Channel.cpp | 4 ++-- src/game/Channel.h | 12 +++------- src/game/CharacterHandler.cpp | 29 +++++++++--------------- src/game/Creature.cpp | 42 +++-------------------------------- src/shared/revision_nr.h | 2 +- 5 files changed, 19 insertions(+), 70 deletions(-) diff --git a/src/game/Channel.cpp b/src/game/Channel.cpp index ca7c8ff3e..2fb8b5d09 100644 --- a/src/game/Channel.cpp +++ b/src/game/Channel.cpp @@ -209,7 +209,7 @@ void Channel::KickOrBan(uint64 good, const char *badname, bool ban) if(ban && !IsBanned(bad->GetGUID())) { - banned.push_back(bad->GetGUID()); + banned.insert(bad->GetGUID()); MakePlayerBanned(&data, bad->GetGUID(), good); } else @@ -258,7 +258,7 @@ void Channel::UnBan(uint64 good, const char *badname) } else { - banned.remove(bad->GetGUID()); + banned.erase(bad->GetGUID()); WorldPacket data; MakePlayerUnbanned(&data, bad->GetGUID(), good); diff --git a/src/game/Channel.h b/src/game/Channel.h index 31e196948..fc87efdd0 100644 --- a/src/game/Channel.h +++ b/src/game/Channel.h @@ -147,7 +147,7 @@ class Channel typedef std::map PlayerList; PlayerList players; - typedef std::list BannedList; + typedef std::set BannedList; BannedList banned; bool m_announce; bool m_moderate; @@ -202,15 +202,9 @@ class Channel void SendToAllButOne(WorldPacket *data, uint64 who); void SendToOne(WorldPacket *data, uint64 who); - bool IsOn(uint64 who) const { return players.count(who) > 0; } + bool IsOn(uint64 who) const { return players.count(who) != 0; } - bool IsBanned(const uint64 guid) const - { - for(BannedList::const_iterator i = banned.begin(); i != banned.end(); ++i) - if(*i == guid) - return true; - return false; - } + bool IsBanned(const uint64 guid) const {return banned.count(guid) != 0; } bool IsFirst() const { return !(players.size() > 1); } diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index a09436590..8880a7b2e 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -904,23 +904,8 @@ void WorldSession::HandleChangePlayerNameOpcode(WorldPacket& recv_data) recv_data >> guid; recv_data >> newname; - QueryResult *result = CharacterDatabase.PQuery("SELECT at_login FROM characters WHERE guid ='%u'", GUID_LOPART(guid)); - if (result) - { - uint32 at_loginFlags; - Field *fields = result->Fetch(); - at_loginFlags = fields[0].GetUInt32(); - delete result; - - if (!(at_loginFlags & AT_LOGIN_RENAME)) - { - WorldPacket data(SMSG_CHAR_RENAME, 1); - data << (uint8)CHAR_CREATE_ERROR; - SendPacket( &data ); - return; - } - } - else + QueryResult *result = CharacterDatabase.PQuery("SELECT at_login, name FROM characters WHERE guid ='%u'", GUID_LOPART(guid)); + if (!result) { WorldPacket data(SMSG_CHAR_RENAME, 1); data << (uint8)CHAR_CREATE_ERROR; @@ -928,10 +913,16 @@ void WorldSession::HandleChangePlayerNameOpcode(WorldPacket& recv_data) return; } - if(!objmgr.GetPlayerNameByGUID(guid, oldname)) // character not exist, because we have no name for this guid + uint32 at_loginFlags; + Field *fields = result->Fetch(); + at_loginFlags = fields[0].GetUInt32(); + oldname = fields[1].GetCppString(); + delete result; + + if (!(at_loginFlags & AT_LOGIN_RENAME)) { WorldPacket data(SMSG_CHAR_RENAME, 1); - data << (uint8)CHAR_LOGIN_NO_CHARACTER; + data << (uint8)CHAR_CREATE_ERROR; SendPacket( &data ); return; } diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 880427b81..8ab1b3258 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -926,44 +926,7 @@ void Creature::OnPoiSelect(Player* player, GossipOption const *gossip) { if(gossip->GossipId==GOSSIP_GUARD_SPELLTRAINER || gossip->GossipId==GOSSIP_GUARD_SKILLTRAINER) { - //float x,y; - //bool findnpc=false; Poi_Icon icon = ICON_POI_0; - //QueryResult *result; - //Field *fields; - uint32 mapid=GetMapId(); - Map const* map=MapManager::Instance().GetBaseMap( mapid ); - uint16 areaflag=map->GetAreaFlag(GetPositionX(),GetPositionY()); - uint32 zoneid=Map::GetZoneId(areaflag,mapid); - std::string areaname= gossip->OptionText; - /* - uint16 pflag; - - // use the action relate to creaturetemplate.trainer_type ? - result= WorldDatabase.PQuery("SELECT creature.position_x,creature.position_y FROM creature,creature_template WHERE creature.map = '%u' AND creature.id = creature_template.entry AND creature_template.trainer_type = '%u'", mapid, gossip->Action ); - if(!result) - return; - do - { - fields = result->Fetch(); - x=fields[0].GetFloat(); - y=fields[1].GetFloat(); - pflag=map->GetAreaFlag(GetPositionX(),GetPositionY()); - if(pflag==areaflag) - { - findnpc=true; - break; - } - }while(result->NextRow()); - - delete result; - - if(!findnpc) - { - player->PlayerTalkClass->SendTalking( "$NSorry", "Here no this person."); - return; - }*/ - //need add more case. switch(gossip->Action) { @@ -980,8 +943,9 @@ void Creature::OnPoiSelect(Player* player, GossipOption const *gossip) icon=ICON_POI_TOWER; break; } - uint32 textid=GetGossipTextId( gossip->Action, zoneid ); - player->PlayerTalkClass->SendTalking( textid ); + uint32 textid = GetGossipTextId( gossip->Action, GetZoneId() ); + player->PlayerTalkClass->SendTalking(textid); + // std::string areaname= gossip->OptionText; // how this could worked player->PlayerTalkClass->SendPointOfInterest( x, y, icon, 2, 15, areaname.c_str() ); } } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 27a2b558c..ae4d0945a 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6891" + #define REVISION_NR "6892" #endif // __REVISION_NR_H__ From 477ba707820e266d3e4795c1396d692482590a6c Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 10 Dec 2008 18:06:37 +0300 Subject: [PATCH 4/6] [6893] Fixes in waypoint movement code. Initilize variables and reset last movment timer for correct waypoints work at reset movement. --- src/game/WaypointMovementGenerator.h | 14 ++++++++++---- src/shared/revision_nr.h | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/game/WaypointMovementGenerator.h b/src/game/WaypointMovementGenerator.h index bcd14d893..d6cb21752 100644 --- a/src/game/WaypointMovementGenerator.h +++ b/src/game/WaypointMovementGenerator.h @@ -73,10 +73,8 @@ class MANGOS_DLL_SPEC WaypointMovementGenerator : public MovementGeneratorMedium< Creature, WaypointMovementGenerator >, public PathMovementBase { - TimeTrackerSmall i_nextMoveTime; - std::vector i_hasDone; public: - WaypointMovementGenerator(Creature &) : i_nextMoveTime(0) {} + WaypointMovementGenerator(Creature &) : i_nextMoveTime(0), b_StopedByPlayer(false) {} ~WaypointMovementGenerator() { ClearWaypoints(); } void Initialize(Creature &u) { @@ -85,7 +83,12 @@ public PathMovementBase LoadPath(u); } void Finalize(Creature &) {} - void Reset(Creature &u) { ReloadPath(u); } + void Reset(Creature &u) + { + ReloadPath(u); + b_StopedByPlayer = false; + i_nextMoveTime.Reset(0); + } bool Update(Creature &u, const uint32 &diff); void MovementInform(Creature &); @@ -104,6 +107,9 @@ public PathMovementBase static void Initialize(void); private: void ClearWaypoints(); + + TimeTrackerSmall i_nextMoveTime; + std::vector i_hasDone; bool b_StopedByPlayer; }; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index ae4d0945a..783240f02 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6892" + #define REVISION_NR "6893" #endif // __REVISION_NR_H__ From 467090e817256265b5d49e8e8f95a8d264b01ada Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 10 Dec 2008 19:24:15 +0300 Subject: [PATCH 5/6] [6894] Backport file name preparing code in VMapManager from 303 branch that fix also possible memory corruption. --- src/shared/revision_nr.h | 2 +- src/shared/vmap/VMapManager.cpp | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 783240f02..313811fc1 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6893" + #define REVISION_NR "6894" #endif // __REVISION_NR_H__ diff --git a/src/shared/vmap/VMapManager.cpp b/src/shared/vmap/VMapManager.cpp index 86e017c96..49fec68b5 100644 --- a/src/shared/vmap/VMapManager.cpp +++ b/src/shared/vmap/VMapManager.cpp @@ -275,10 +275,8 @@ namespace VMAP { dirFileName = getDirFileName(pMapId); } - size_t len = pBasePath.length() + dirFileName.length(); - char *filenameBuffer = new char[len+1]; - sprintf(filenameBuffer, "%s%s", pBasePath.c_str(), dirFileName.c_str()); - FILE* df = fopen(filenameBuffer, "rb"); + std::string fb = pBasePath + dirFileName; + FILE* df = fopen(fb.c_str(), "rb"); if(df) { char lineBuffer[FILENAMEBUFFER_SIZE]; @@ -288,8 +286,8 @@ namespace VMAP chomp(name); if(name.length() >1) { - sprintf(filenameBuffer, "%s%s", pBasePath.c_str(), name.c_str()); - FILE* df2 = fopen(filenameBuffer, "rb"); + std::string fb2 = pBasePath + name; + FILE* df2 = fopen(fb2.c_str(), "rb"); if(df2) { char magic[8]; @@ -302,7 +300,6 @@ namespace VMAP } fclose(df); } - delete[] filenameBuffer; return result; } @@ -659,14 +656,12 @@ namespace VMAP bool MapTree::loadMap(const std::string& pDirFileName, unsigned int pMapTileIdent) { bool result = true; - size_t len = iBasePath.length() + pDirFileName.length(); - char *filenameBuffer = new char[len+1]; if(!hasDirFile(pDirFileName)) { FilesInDir filesInDir; result = false; - sprintf(filenameBuffer, "%s%s", iBasePath.c_str(), pDirFileName.c_str()); - FILE* df = fopen(filenameBuffer, "rb"); + std::string fb = iBasePath + pDirFileName; + FILE* df = fopen(fb.c_str(), "rb"); if(df) { char lineBuffer[FILENAMEBUFFER_SIZE]; @@ -726,7 +721,6 @@ namespace VMAP filesInDir.incRefCount(); } } - delete [] filenameBuffer; return (result); } From 54207e753cc76cc8233a801121d09f1b5189a464 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 10 Dec 2008 19:48:40 +0300 Subject: [PATCH 6/6] [6895] Fix unexpected change backported in [6889]. Rebuild ad.exe with recent changes. --- contrib/extractor/System.cpp | 2 +- contrib/extractor/ad.exe | Bin 167936 -> 167936 bytes src/shared/revision_nr.h | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/extractor/System.cpp b/contrib/extractor/System.cpp index 19c0e7159..978a7d2d9 100644 --- a/contrib/extractor/System.cpp +++ b/contrib/extractor/System.cpp @@ -261,7 +261,7 @@ void LoadCommonMPQFiles() { char filename[512]; - sprintf(filename,"%s/Data/common-2.MPQ", input_path); + sprintf(filename,"%s/Data/common.MPQ", input_path); new MPQArchive(filename); sprintf(filename,"%s/Data/expansion.MPQ", input_path); new MPQArchive(filename); diff --git a/contrib/extractor/ad.exe b/contrib/extractor/ad.exe index 1f2c45dfc5628396d14318608d799122738f8f4e..2dc24c0872e709084426117c84055c1e2579e576 100755 GIT binary patch delta 32 ocmZozz}2vTYr+fWqo3?2zV>Cld6lWznz7xQk#V~