aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorleak <leak@bitmx.net>2014-07-06 20:07:52 +0200
committerleak <leak@bitmx.net>2014-07-06 20:07:52 +0200
commit013e3f4c0ce05f53888a8a88053c613502e52ac6 (patch)
treecf85009dc0bea6cf27bd1d294c0e58bd84ebe786 /src
parent80a8ed23b710459342abd16cda9da6695929c467 (diff)
parenta6494375f9839b8c428c8daa508b9ca93caa0575 (diff)
Merge branch 'master' of github.com:TrinityCore/TrinityCore into boost
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Battlefield/Zones/BattlefieldWG.cpp4
-rw-r--r--src/server/game/Battlegrounds/BattlegroundScore.h4
-rw-r--r--src/server/game/Entities/Object/Object.cpp48
-rw-r--r--src/server/game/Entities/Player/Player.cpp15
-rw-r--r--src/server/game/Maps/Map.cpp5
-rw-r--r--src/server/game/Movement/PathGenerator.cpp38
-rw-r--r--src/server/game/Movement/PathGenerator.h2
-rw-r--r--src/server/game/Spells/Spell.cpp19
-rw-r--r--src/server/game/Spells/SpellEffects.cpp2
-rw-r--r--src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp2
-rw-r--r--src/tools/vmap4_extractor/model.cpp21
11 files changed, 127 insertions, 33 deletions
diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
index 5555f2a824c..41539b9cda6 100644
--- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
+++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
@@ -41,14 +41,14 @@ BattlefieldWG::~BattlefieldWG()
bool BattlefieldWG::SetupBattlefield()
{
- InitStalker(BATTLEFIELD_WG_NPC_STALKER, WintergraspStalkerPos[0], WintergraspStalkerPos[1], WintergraspStalkerPos[2], WintergraspStalkerPos[3]);
-
m_TypeId = BATTLEFIELD_WG; // See enum BattlefieldTypes
m_BattleId = BATTLEFIELD_BATTLEID_WG;
m_ZoneId = BATTLEFIELD_WG_ZONEID;
m_MapId = BATTLEFIELD_WG_MAPID;
m_Map = sMapMgr->FindMap(m_MapId, 0);
+ InitStalker(BATTLEFIELD_WG_NPC_STALKER, WintergraspStalkerPos[0], WintergraspStalkerPos[1], WintergraspStalkerPos[2], WintergraspStalkerPos[3]);
+
m_MaxPlayer = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLR_MAX);
m_IsEnabled = sWorld->getBoolConfig(CONFIG_WINTERGRASP_ENABLE);
m_MinPlayer = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLR_MIN);
diff --git a/src/server/game/Battlegrounds/BattlegroundScore.h b/src/server/game/Battlegrounds/BattlegroundScore.h
index ae65721b516..95d1db2c337 100644
--- a/src/server/game/Battlegrounds/BattlegroundScore.h
+++ b/src/server/game/Battlegrounds/BattlegroundScore.h
@@ -87,7 +87,7 @@ struct BattlegroundScore
}
}
- virtual void AppendToPacket(WorldPacket& data)
+ virtual void AppendToPacket(WorldPacket& data)
{
data << uint64(PlayerGuid);
@@ -108,7 +108,7 @@ struct BattlegroundScore
uint64 PlayerGuid;
- // Default score, present in every type
+ // Default score, present in every type
uint32 KillingBlows;
uint32 Deaths;
uint32 HonorableKills;
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 4ff0153dea8..08d984e0790 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -2603,13 +2603,39 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle)
pos.SetOrientation(GetOrientation());
}
+// @todo: replace with WorldObject::UpdateAllowedPositionZ
+float NormalizeZforCollision(WorldObject* obj, float x, float y, float z)
+{
+ float ground = obj->GetMap()->GetHeight(obj->GetPhaseMask(), x, y, MAX_HEIGHT, true);
+ float floor = obj->GetMap()->GetHeight(obj->GetPhaseMask(), x, y, z + 2.0f, true);
+ float helper = fabs(ground - z) <= fabs(floor - z) ? ground : floor;
+ if (z > helper) // must be above ground
+ {
+ if (Unit* unit = obj->ToUnit())
+ {
+ if (unit->CanFly())
+ return z;
+ }
+ LiquidData liquid_status;
+ ZLiquidStatus res = obj->GetMap()->getLiquidStatus(x, y, z, MAP_ALL_LIQUIDS, &liquid_status);
+ if (res && liquid_status.level > helper) // water must be above ground
+ {
+ if (liquid_status.level > z) // z is underwater
+ return z;
+ else
+ return fabs(liquid_status.level - z) <= fabs(helper - z) ? liquid_status.level : helper;
+ }
+ }
+ return helper;
+}
+
void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float angle)
{
angle += GetOrientation();
- float destx, desty, destz, ground, floor;
- pos.m_positionZ += 2.0f;
+ float destx, desty, destz;
destx = pos.m_positionX + dist * std::cos(angle);
desty = pos.m_positionY + dist * std::sin(angle);
+ destz = NormalizeZforCollision(this, destx, desty, pos.GetPositionZ());
// Prevent invalid coordinates here, position is unchanged
if (!Trinity::IsValidMapCoord(destx, desty))
@@ -2618,11 +2644,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
return;
}
- ground = GetMap()->GetHeight(GetPhaseMask(), destx, desty, MAX_HEIGHT, true);
- floor = GetMap()->GetHeight(GetPhaseMask(), destx, desty, pos.m_positionZ, true);
- destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
-
- bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), pos.m_positionX, pos.m_positionY, pos.m_positionZ+0.5f, destx, desty, destz+0.5f, destx, desty, destz, -0.5f);
+ bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), pos.m_positionX, pos.m_positionY, pos.m_positionZ + 0.5f, destx, desty, destz + 0.5f, destx, desty, destz, -0.5f);
// collision occured
if (col)
@@ -2634,7 +2656,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
}
// check dynamic collision
- col = GetMap()->getObjectHitPos(GetPhaseMask(), pos.m_positionX, pos.m_positionY, pos.m_positionZ+0.5f, destx, desty, destz+0.5f, destx, desty, destz, -0.5f);
+ col = GetMap()->getObjectHitPos(GetPhaseMask(), pos.m_positionX, pos.m_positionY, pos.m_positionZ + 0.5f, destx, desty, destz + 0.5f, destx, desty, destz, -0.5f);
// Collided with a gameobject
if (col)
@@ -2644,18 +2666,16 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
dist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));
}
- float step = dist/10.0f;
+ float step = dist / 10.0f;
for (uint8 j = 0; j < 10; ++j)
{
// do not allow too big z changes
- if (fabs(pos.m_positionZ - destz) > 6)
+ if (fabs(pos.m_positionZ - destz) > 6.0f)
{
destx -= step * std::cos(angle);
desty -= step * std::sin(angle);
- ground = GetMap()->GetHeight(GetPhaseMask(), destx, desty, MAX_HEIGHT, true);
- floor = GetMap()->GetHeight(GetPhaseMask(), destx, desty, pos.m_positionZ, true);
- destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
+ destz = NormalizeZforCollision(this, destx, desty, pos.GetPositionZ());
}
// we have correct destz now
else
@@ -2667,7 +2687,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
Trinity::NormalizeMapCoord(pos.m_positionX);
Trinity::NormalizeMapCoord(pos.m_positionY);
- UpdateAllowedPositionZ(pos.m_positionX, pos.m_positionY, pos.m_positionZ);
+ pos.m_positionZ = NormalizeZforCollision(this, destx, desty, pos.GetPositionZ());
pos.SetOrientation(GetOrientation());
}
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 6a1c91456e5..e00728d25c6 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -3828,7 +3828,7 @@ bool Player::addSpell(uint32 spellId, bool active, bool learning, bool dependent
if (!pSkill)
continue;
- if (!HasSkill(pSkill->id))
+ if (_spell_idx->second->AutolearnType == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(pSkill->id))
LearnDefaultSkill(pSkill->id, 0);
if (pSkill->id == SKILL_MOUNTS && !Has310Flyer(false))
@@ -23119,11 +23119,11 @@ void Player::LearnDefaultSkill(uint32 skillId, uint16 rank)
break;
case SKILL_RANGE_LEVEL:
{
- uint16 skillValue = 0;
+ uint16 skillValue = 1;
uint16 maxValue = GetMaxSkillValueForLevel();
if (rcInfo->Flags & SKILL_FLAG_ALWAYS_MAX_VALUE)
skillValue = maxValue;
- else
+ else if (getClass() == CLASS_DEATH_KNIGHT)
skillValue = std::min(std::max<uint16>({ 1, uint16((getLevel() - 1) * 5) }), maxValue);
SetSkill(skillId, 0, skillValue, maxValue);
@@ -23138,8 +23138,13 @@ void Player::LearnDefaultSkill(uint32 skillId, uint16 rank)
break;
SkillTiersEntry const* tier = sSkillTiersStore.LookupEntry(rcInfo->SkillTier);
- uint16 maxValue = std::max<uint16>(GetMaxSkillValue(skillId), tier->MaxSkill[std::max<int32>(rank - 1, 0)]);
- uint16 skillValue = std::min(std::max<uint16>({ uint16(1), uint16((getLevel() - 1) * 5) }), maxValue);
+ uint16 maxValue = tier->MaxSkill[std::max<int32>(rank - 1, 0)];
+ uint16 skillValue = 1;
+ if (rcInfo->Flags & SKILL_FLAG_ALWAYS_MAX_VALUE)
+ skillValue = maxValue;
+ else if (getClass() == CLASS_DEATH_KNIGHT)
+ skillValue = std::min(std::max<uint16>({ uint16(1), uint16((getLevel() - 1) * 5) }), maxValue);
+
SetSkill(skillId, rank, skillValue, maxValue);
break;
}
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index bdf42a26320..bfb38a31248 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -119,6 +119,9 @@ bool Map::ExistVMap(uint32 mapid, int gx, int gy)
void Map::LoadMMap(int gx, int gy)
{
+ if (!MMAP::MMapFactory::IsPathfindingEnabled(GetId()))
+ return;
+
bool mmapLoadResult = MMAP::MMapFactory::createOrGetMMapManager()->loadMap((sWorld->GetDataPath() + "mmaps").c_str(), GetId(), gx, gy);
if (mmapLoadResult)
@@ -129,6 +132,8 @@ void Map::LoadMMap(int gx, int gy)
void Map::LoadVMap(int gx, int gy)
{
+ if (!VMAP::VMapFactory::createOrGetVMapManager()->isMapLoadingEnabled())
+ return;
// x and y are swapped !!
int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapManager()->loadMap((sWorld->GetDataPath()+ "vmaps").c_str(), GetId(), gx, gy);
switch (vmapLoadResult)
diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp
index d6912bac7c8..3140fc23296 100644
--- a/src/server/game/Movement/PathGenerator.cpp
+++ b/src/server/game/Movement/PathGenerator.cpp
@@ -882,3 +882,41 @@ float PathGenerator::Dist3DSqr(G3D::Vector3 const& p1, G3D::Vector3 const& p2) c
{
return (p1 - p2).squaredLength();
}
+
+void PathGenerator::ReducePathLenghtByDist(float dist)
+{
+ if (GetPathType() == PATHFIND_BLANK)
+ {
+ TC_LOG_ERROR("maps", "PathGenerator::ReducePathLenghtByDist called before path was built");
+ return;
+ }
+
+ if (_pathPoints.size() < 2) // path building failure
+ return;
+
+ uint32 i = _pathPoints.size();
+ G3D::Vector3 nextVec = _pathPoints[--i];
+ while (i > 0)
+ {
+ G3D::Vector3 currVec = _pathPoints[--i];
+ G3D::Vector3 diffVec = (nextVec - currVec);
+ float len = diffVec.length();
+ if (len > dist)
+ {
+ float step = dist / len;
+ // same as nextVec
+ _pathPoints[i + 1] -= diffVec * step;
+ _pathPoints.resize(i + 2);
+ break;
+ }
+ else if (i == 0) // at second point
+ {
+ _pathPoints[1] = _pathPoints[0];
+ _pathPoints.resize(2);
+ break;
+ }
+
+ dist -= len;
+ nextVec = currVec; // we're going backwards
+ }
+}
diff --git a/src/server/game/Movement/PathGenerator.h b/src/server/game/Movement/PathGenerator.h
index 6e0d72ec8da..a9a13c37251 100644
--- a/src/server/game/Movement/PathGenerator.h
+++ b/src/server/game/Movement/PathGenerator.h
@@ -72,6 +72,8 @@ class PathGenerator
PathType GetPathType() const { return _type; }
+ void ReducePathLenghtByDist(float dist); // path must be already built
+
private:
dtPolyRef _pathPolyRefs[MAX_PATH_LENGTH]; // array of detour polygon references
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 0e0443cc675..0d7dd8819af 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -5043,15 +5043,24 @@ SpellCastResult Spell::CheckCast(bool strict)
if (!target)
return SPELL_FAILED_DONT_REPORT;
- //target->GetContactPoint(m_caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ);
- Position pos = target->GetFirstCollisionPosition(CONTACT_DISTANCE, target->GetRelativeAngle(m_caster));
+ float objSize = target->GetObjectSize();
+ float range = m_spellInfo->GetMaxRange(true, m_caster, this) * 1.5f + objSize; // can't be overly strict
- m_preGeneratedPath.SetPathLengthLimit(m_spellInfo->GetMaxRange(true) * 1.5f);
- bool result = m_preGeneratedPath.CalculatePath(pos.m_positionX, pos.m_positionY, pos.m_positionZ + target->GetObjectSize(), false, true);
+ m_preGeneratedPath.SetPathLengthLimit(range);
+ // first try with raycast, if it fails fall back to normal path
+ bool result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + target->GetObjectSize(), false, true);
if (m_preGeneratedPath.GetPathType() & PATHFIND_SHORT)
return SPELL_FAILED_OUT_OF_RANGE;
else if (!result || m_preGeneratedPath.GetPathType() & PATHFIND_NOPATH)
- return SPELL_FAILED_NOPATH;
+ {
+ result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + target->GetObjectSize(), false, false);
+ if (m_preGeneratedPath.GetPathType() & PATHFIND_SHORT)
+ return SPELL_FAILED_OUT_OF_RANGE;
+ else if (!result || m_preGeneratedPath.GetPathType() & PATHFIND_NOPATH)
+ return SPELL_FAILED_NOPATH;
+ }
+
+ m_preGeneratedPath.ReducePathLenghtByDist(objSize); // move back
}
break;
}
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 0a5d265cbfa..abeeb394218 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -4586,7 +4586,7 @@ void Spell::EffectLeap(SpellEffIndex /*effIndex*/)
return;
Position pos = destTarget->GetPosition();
- pos = unitTarget->GetFirstCollisionPosition(unitTarget->GetDistance(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() + 2.0f), 0.0f);
+ pos = unitTarget->GetFirstCollisionPosition(unitTarget->GetDistance(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()), 0.0f);
unitTarget->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), unitTarget == m_caster);
}
diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp
index e0050420a08..1f8ccfbd5d8 100644
--- a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp
+++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp
@@ -159,7 +159,7 @@ class instance_magisters_terrace : public InstanceMapScript
switch (type)
{
case DATA_DELRISSA:
- if (type == IN_PROGRESS)
+ if (state == IN_PROGRESS)
DelrissaDeathCount = 0;
break;
default:
diff --git a/src/tools/vmap4_extractor/model.cpp b/src/tools/vmap4_extractor/model.cpp
index 825a2697c16..c527ec32ddb 100644
--- a/src/tools/vmap4_extractor/model.cpp
+++ b/src/tools/vmap4_extractor/model.cpp
@@ -96,8 +96,19 @@ bool Model::ConvertToVMAPModel(const char * outfilename)
wsize = sizeof(uint32) + sizeof(unsigned short) * nIndexes;
fwrite(&wsize, sizeof(int), 1, output);
fwrite(&nIndexes, sizeof(uint32), 1, output);
- if (nIndexes >0)
+ if (nIndexes > 0)
+ {
+ for (uint32 i = 0; i < nIndexes; ++i)
+ {
+ if ((i % 3) - 1 == 0 && i + 1 < nIndexes)
+ {
+ uint16 tmp = indices[i];
+ indices[i] = indices[i + 1];
+ indices[i + 1] = tmp;
+ }
+ }
fwrite(indices, sizeof(unsigned short), nIndexes, output);
+ }
fwrite("VERT", 4, 1, output);
wsize = sizeof(int) + sizeof(float) * 3 * nVertices;
@@ -105,8 +116,12 @@ bool Model::ConvertToVMAPModel(const char * outfilename)
fwrite(&nVertices, sizeof(int), 1, output);
if (nVertices >0)
{
- for(uint32 vpos=0; vpos <nVertices; ++vpos)
- std::swap(vertices[vpos].y, vertices[vpos].z);
+ for (uint32 vpos = 0; vpos < nVertices; ++vpos)
+ {
+ float tmp = vertices[vpos].y;
+ vertices[vpos].y = -vertices[vpos].z;
+ vertices[vpos].z = tmp;
+ }
fwrite(vertices, sizeof(float)*3, nVertices, output);
}