@@ -0,0 +1,81 @@
/*
*
* Copyright (C) 2008-2017 Dimension Gamers <http://www.dimensiongamers.net>
*
* File: "TeleportManager.h"
*
*/

#ifndef TELEPORT_TEMPLATE_H
#define TELEPORT_TEMPLATE_H

struct GateData
{
uint16 Id;
uint8 Flag;
uint16 MapId;
int16 X1;
int16 Y1;
int16 X2;
int16 Y2;
uint16 TargetId;
uint8 Direction;
int16 MinLevel;
std::string Description;

int16 GetMinX() const { return X1 == X2 ? X1 : std::min(X1, X2); }
int16 GetMaxX() const { return X1 == X2 ? X2 : std::max(X1, X2); }
int16 GetMinY() const { return Y1 == Y2 ? Y1 : std::min(Y1, Y2); }
int16 GetMaxY() const { return Y1 == Y2 ? Y2 : std::max(Y1, Y2); }
};

struct TeleportData
{
uint8 Id;
std::string Name;
uint32 Zen;
int16 MinLevel;
uint16 Gate;
uint16 MonsterId;
};

struct MoveLevel
{
int16 Level;
uint16 MapId;
int16 X1;
int16 Y1;
int16 X2;
int16 Y2;
bool Disabled;
};

class TeleportManager
{
SingletonInstance(TeleportManager);

public:
TeleportManager();
~TeleportManager();

void LoadGateTemplate();
void LoadTeleportTemplate();
void LoadMoveLevel();

GateData const* GetGate(uint16 id, bool target = false) const;
TeleportData const* GetTeleport(uint8 id) const;
TeleportData const* GetTeleport(std::string const& name) const;

int16 GetMoveLevel(uint16 mapId, int16 x, int16 y) const;

void Update();
void SendBattleZone(Player* player, uint16 mapId);
void SendMonsterInfo(Player* player);

private:
std::map<uint16, GateData*> _gates;
std::map<uint8, TeleportData*> _teleports;
std::vector<MoveLevel*> _moveLevels;
};

#endif

This file was deleted.

This file was deleted.

@@ -287,7 +287,7 @@ class TormentedSquareGround
DECLARE_ENUM(uint32, SecondTick);
DECLARE_BOOL(RankingSent);

DECLARE_ENUM(world_type, WorldID);
DECLARE_ENUM(uint16, WorldID);
DECLARE_ENUM(uint16, RespawnGate);
DECLARE_ENUM(uint16, EnterGate);
};
@@ -15,7 +15,7 @@

static const struct TormentedSquareZone
{
world_type world;
uint16 world;
uint16 gate;
} g_TormentedSquareZone[MAX_TORMENTED_SQUARE_GROUND] =
{
@@ -246,7 +246,7 @@ class TormentedSquareSurvivalGround
DECLARE_ENUM(uint32, SecondTick);
DECLARE_BOOL(RankingSent);

DECLARE_ENUM(world_type, WorldID);
DECLARE_ENUM(uint16, WorldID);
DECLARE_ENUM(uint16, RespawnGate);
DECLARE_ENUM(uint16, EnterGate);

@@ -115,7 +115,7 @@ void Unit::ActionSend(uint16 target, uint8 action, uint8 direction, bool me)
this->sendPacket_viewport(MAKE_PCT(pMsg));
}

void Unit::PositionSend(coord_type x, coord_type y)
void Unit::PositionSend(int16 x, int16 y)
{
this->SetLocation(x, y, this->GetDirection());
this->SetTX(x);
@@ -158,7 +158,7 @@ void Unit::StateInfoSendSingle(Player* pPlayer, uint16 buff, uint8 state)
}
}

void Unit::SetLocation(coord_type x, coord_type y, uint8 direction)
void Unit::SetLocation(int16 x, int16 y, uint8 direction)
{
this->SetX(x);
this->SetY(y);
@@ -170,7 +170,7 @@ void Unit::UpdateLastLocation()
this->GetLastLocation()->Set(this->GetLocation());
}

void Unit::UpdateLastLocation(world_type world, coord_type x, coord_type y, int32 instance, uint8 direction)
void Unit::UpdateLastLocation(uint16 world, int16 x, int16 y, int32 instance, uint8 direction)
{
this->GetLastLocation()->SetWorldId(world);
this->GetLastLocation()->SetX(x);
@@ -343,56 +343,50 @@ bool Unit::MoveToGate(uint16 gate_id)
GateData const* pGate = sTeleport->GetGate(gate_id, true);
SafeRAssert(pGate, "pGate == nullptr", false);

coord_type tmp_x = pGate->x1;
coord_type tmp_y = pGate->y1;
world_type tmp_world = pGate->world;
int16 tmp_x = pGate->X1;
int16 tmp_y = pGate->Y1;
uint16 tmp_world = pGate->MapId;

this->GetValidCoordinates(pGate->id, tmp_world, tmp_x, tmp_y);
this->GetValidCoordinates(pGate->Id, tmp_world, tmp_x, tmp_y);

this->UpdateLastLocation();
this->ClearPathData();

this->SetWorldId(pGate->world);
this->SetWorldId(pGate->MapId);
this->SetX(tmp_x);
this->SetY(tmp_y);
this->SetTX(tmp_x);
this->SetTY(tmp_y);
this->SetDirection(pGate->direction);
this->SetDirection(pGate->Direction);

this->ViewportCreate(VIEWPORT_CREATE_FLAG_ME | VIEWPORT_CREATE_FLAG_GEN | VIEWPORT_CREATE_FLAG_GUILD | VIEWPORT_CREATE_FLAG_SIEGE);
return true;
}

void Unit::GetValidCoordinates(uint16 gate, world_type & world, coord_type & x, coord_type & y)
void Unit::GetValidCoordinates(uint16 gate, uint16 & world, int16 & x, int16 & y)
{
GateData const* pGate = sTeleport->GetGate(gate);

if ( !pGate )
{
auto const gate_data = sTeleport->GetGate(gate);
if (!gate_data)
return;
}

World* pWorld = sWorldMgr->GetWorld(pGate->world);

if ( !pWorld )
{
auto map = sWorldMgr->GetWorld(gate_data->MapId);
if (!map)
return;
}

world = pGate->world;
if ( pGate->x1 == pGate->x2 && pGate->y1 == pGate->y2 )
world = gate_data->MapId;

if (gate_data->X1 == gate_data->X2 && gate_data->Y1 == gate_data->Y2)
{
x = pGate->x1;
y = pGate->y1;
x = gate_data->X1;
y = gate_data->Y1;
}
else
{
pWorld->GetRandomLocation(x, y, pGate->x1, pGate->y1, pGate->x2, pGate->y2);
map->GetRandomLocation(x, y, gate_data->X1, gate_data->Y1, gate_data->X2, gate_data->Y2);
}
}

void Unit::TeleportToLocation(world_type world, coord_type x, coord_type y, uint8 direction, int32 instance)
void Unit::TeleportToLocation(uint16 world, int16 x, int16 y, uint8 direction, int32 instance)
{
this->UpdateLastLocation();

@@ -406,7 +400,7 @@ void Unit::TeleportToLocation(world_type world, coord_type x, coord_type y, uint
this->GetRegenLocation()->Set(this->GetLocation());
}

void Unit::TeleportToLocation(world_type world)
void Unit::TeleportToLocation(uint16 world)
{
World * pWorld = sWorldMgr->GetWorld(world);

@@ -417,8 +411,8 @@ void Unit::TeleportToLocation(world_type world)

this->UpdateLastLocation();

coord_type x = 0;
coord_type y = 0;
int16 x = 0;
int16 y = 0;
pWorld->GetRespawn(world, x, y);
this->SetWorldId(world);
this->SetX(x);
@@ -444,7 +438,7 @@ void Unit::TeleportToObject(Unit* pUnit)
this->TeleportToLocation(pUnit->GetWorldId(), pUnit->GetX(), pUnit->GetY(), pUnit->GetDirection(), pUnit->GetInstance());
}

bool Unit::TeleportAreaCheck(coord_type x, coord_type y)
bool Unit::TeleportAreaCheck(int16 x, int16 y)
{
if ( !InRange(x, y, 8) )
return false;
@@ -1917,8 +1911,8 @@ void Unit::PushBackSimple(Unit* mTarget)
limitmin(target_direction, 0);
limitmax(target_direction, Path::Max - 1);

coord_type x = mTarget->GetX() + Path::Table[target_direction];
coord_type y = mTarget->GetY() + Path::Table[target_direction + 1];
int16 x = mTarget->GetX() + Path::Table[target_direction];
int16 y = mTarget->GetY() + Path::Table[target_direction + 1];

World* pWorld = mTarget->GetWorld();

@@ -1955,8 +1949,8 @@ void Unit::PushBackCount(Unit* mTarget, uint8 count)

int32 target_direction = GetPathPacketDirPos(mTarget->GetX() - this->GetX(), mTarget->GetY() - this->GetY()) * 2;

coord_type x = mTarget->GetX();
coord_type y = mTarget->GetY();
int16 x = mTarget->GetX();
int16 y = mTarget->GetY();

for ( uint8 n = 0; n < count; ++n )
{
@@ -2023,11 +2017,11 @@ bool Unit::PushBackAllowed()
return true;
}

bool Unit::PushBackCheck(coord_type & x, coord_type & y, int32 & direction)
bool Unit::PushBackCheck(int16 & x, int16 & y, int32 & direction)
{
int32 tdir = direction / 2;
coord_type tx = x + Path::Table[direction];
coord_type ty = y + Path::Table[direction+1];
int16 tx = x + Path::Table[direction];
int16 ty = y + Path::Table[direction+1];

World* pWorld = this->GetWorld();

@@ -4557,7 +4551,7 @@ void Unit::SetSummonedTarget(Unit* mTarget)
mMonster->SetTarget(mTarget);
}

uint8 Unit::GetPathPacketDirPos(coord_type px, coord_type py)
uint8 Unit::GetPathPacketDirPos(int16 px, int16 py)
{
uint8 pos = 0;

@@ -4605,7 +4599,7 @@ bool Unit::IsInDragonTower() const
return ( (this->GetX() >= 159 && this->GetX() <= 190) && (this->GetY() >= 189 && this->GetY() <= 217) );
}

bool Unit::IsInDragonTower(coord_type x1, coord_type y1, coord_type x2, coord_type y2)
bool Unit::IsInDragonTower(int16 x1, int16 y1, int16 x2, int16 y2)
{
return ( (x1 >= 160 && x2 <= 189) && (y1 >= 190 && y2 <= 217) );
}
@@ -4792,7 +4786,7 @@ void Unit::KillCountReset()
this->KillCountSend();
}

void Unit::GenerateRandomLocation(World* pWorld, coord_type &x, coord_type &y, int32 length, uint8 exclude, int32 instance)
void Unit::GenerateRandomLocation(World* pWorld, int16 &x, int16 &y, int32 length, uint8 exclude, int32 instance)
{
if ( !pWorld )
return;
@@ -4805,8 +4799,8 @@ void Unit::GenerateRandomLocation(World* pWorld, coord_type &x, coord_type &y, i

while( count-- > 0 )
{
coord_type px = (x - length) + Random(max_length);
coord_type py = (y - length) + Random(max_length);
int16 px = (x - length) + Random(max_length);
int16 py = (y - length) + Random(max_length);

if ( !(pWorld->GetGrid(px, py).attribute & exclude) )
{
@@ -5935,7 +5929,7 @@ void Unit::ProcessReflect(Unit* pTarget, int32 damage)
pTarget->Unit::AfterHitCheck(this, send_damage, shield_damage, DAMAGE_TYPE_REFLECT);
}

void Unit::MoveSend(coord_type x, coord_type y, uint8 dir)
void Unit::MoveSend(int16 x, int16 y, uint8 dir)
{
MOVE_RESULT pMsg(this->GetEntry(), x, y, dir);
this->sendPacket_viewport(MAKE_PCT(pMsg));
@@ -10,10 +10,10 @@

struct PathPosition
{
DECLARE_ENUM(coord_type, Ori);
DECLARE_ENUM(coord_type, X);
DECLARE_ENUM(coord_type, Y);
DECLARE_ENUM(coord_type, Dir);
DECLARE_ENUM(int16, Ori);
DECLARE_ENUM(int16, X);
DECLARE_ENUM(int16, Y);
DECLARE_ENUM(int16, Dir);

void Reset()
{
@@ -340,14 +340,14 @@ class Unit: public Object
void SendCustomObjectData();

void ActionSend(uint16 target, uint8 action, uint8 direction, bool me = false);
void PositionSend(coord_type x, coord_type y);
void PositionSend(int16 x, int16 y);
void EffectSend(uint8 effect);
void StateInfoSend(uint16 buff, uint8 state);
void StateInfoSendSingle(Player* pPlayer, uint16 buff, uint8 state);

void SetLocation(coord_type x, coord_type y, uint8 direction);
void SetLocation(int16 x, int16 y, uint8 direction);
void UpdateLastLocation();
void UpdateLastLocation(world_type world_id, coord_type x, coord_type y, int32 instance, uint8 direction);
void UpdateLastLocation(uint16 world_id, int16 x, int16 y, int32 instance, uint8 direction);
virtual void UpdateDelayedTeleport();
void CancelDelayedTeleport();

@@ -362,7 +362,7 @@ class Unit: public Object
virtual void UpdatePowers(uint8 type, bool max = false) = 0;

virtual bool MoveToGate(uint16 gate);
virtual void GetValidCoordinates(uint16 gate, world_type & world, coord_type & x, coord_type & y);
virtual void GetValidCoordinates(uint16 gate, uint16 & world, int16 & x, int16 & y);

int32 MagicAdd(uint16 skill, uint8 level, bool weapon = false);
int32 MagicRemove(uint16 skill);
@@ -384,19 +384,19 @@ class Unit: public Object
return (GetTickCount() - this->GetShieldTick()) < (4 * IN_MILLISECONDS);
}

virtual void TeleportToLocation(world_type world, coord_type x, coord_type y, uint8 direction, int32 instance); // Lo mueve a una zona definida
virtual void TeleportToLocation(world_type world);
virtual void TeleportToLocation(uint16 world, int16 x, int16 y, uint8 direction, int32 instance); // Lo mueve a una zona definida
virtual void TeleportToLocation(uint16 world);
virtual void TeleportToLocation(); // Lo mueve al ultimo lugar donde estuvo
virtual void TeleportToObject(Unit* pUnit);
virtual bool TeleportAreaCheck(coord_type x, coord_type y);
virtual void StartRegen(world_type world, coord_type x, coord_type y, uint8 direction, int32 instance, uint16 gate_id = 0) { }
virtual bool TeleportAreaCheck(int16 x, int16 y);
virtual void StartRegen(uint16 world, int16 x, int16 y, uint8 direction, int32 instance, uint16 gate_id = 0) { }

static uint8 GetPathPacketDirPos(coord_type px, coord_type py);
static uint8 GetPathPacketDirPos(int16 px, int16 py);

bool IsRest() const { return this->GetRest() != 0; }

bool IsInDragonTower() const;
static bool IsInDragonTower(coord_type x1, coord_type y1, coord_type x2, coord_type y2);
static bool IsInDragonTower(int16 x1, int16 y1, int16 x2, int16 y2);

virtual int32 GetBookHitCount() const { return 5; }

@@ -416,7 +416,7 @@ class Unit: public Object
void KillCountDecrease(uint8 count);
void KillCountReset();

void GenerateRandomLocation(World* pWorld, coord_type &x, coord_type &y, int32 length, uint8 exclude, int32 instance);
void GenerateRandomLocation(World* pWorld, int16 &x, int16 &y, int32 length, uint8 exclude, int32 instance);

int32 PowerGetTotal(uint8 id) const;
int32 PowerGet(uint8 id) const;
@@ -490,7 +490,7 @@ class Unit: public Object
void PushBackSimple(Unit* mTarget);
void PushBackCount(Unit* mTarget, uint8 count);
bool PushBackAllowed();
bool PushBackCheck(coord_type & x, coord_type & y, int32 & direction);
bool PushBackCheck(int16 & x, int16 & y, int32 & direction);

bool MissCheck(Unit * pTarget, Skill* pSkill, bool send, int32 count, bool & miss_all);
bool MissCheckNormal(Unit * pTarget, Skill* pSkill, bool send, int32 count, bool & miss_all);
@@ -507,8 +507,8 @@ class Unit: public Object
int32 GetMajesticSpecialDamage(int32 t_defense, uint16 & damage_type, Skill const* mSkill, Unit* pTarget);

void SkillAngleCalculate(float angle, float tx, float ty, float sx, float sy, bool convert = true, int32 add_x = -1, int32 add_y = -1);
bool SkillInAngle(coord_type x, coord_type y);
int32 GetAngle(coord_type x, coord_type y);
bool SkillInAngle(int16 x, int16 y);
int32 GetAngle(int16 x, int16 y);

virtual void GetPartyMembers(Unit* mMember[MAX_PARTY_MEMBERS], uint8 & count, uint8 distance);

@@ -518,7 +518,7 @@ class Unit: public Object

virtual void SkillGetDamage(uint16 skill, int32 & damage_min, int32 & damage_max);
void RunNova();
void SkillTeleportUse(coord_type x, coord_type y);
void SkillTeleportUse(int16 x, int16 y);
void UpdateTeleport();

void MissSend(Unit* pTarget, Skill* pSkill, bool send, int32 count, uint16 effect = 0);
@@ -566,7 +566,7 @@ class Unit: public Object
void UpdateOldPower();
void ApplyOldPower();

void MoveSend(coord_type x, coord_type y, uint8 dir);
void MoveSend(int16 x, int16 y, uint8 dir);

virtual bool InmuneToRadiance() const = 0;
virtual bool InmuneToPunish(Player* pPlayer) = 0;
@@ -584,8 +584,8 @@ class Unit: public Object

DECLARE_ENUM(RegenStatus, RegenStatus);

DECLARE_PROPERTY(coord_type, TX);
DECLARE_PROPERTY(coord_type, TY);
DECLARE_PROPERTY(int16, TX);
DECLARE_PROPERTY(int16, TY);

DECLARE_BOOL(DelayedTeleport);
DECLARE_PROPERTY(int16, DelayedTeleportTime);
@@ -602,8 +602,8 @@ class Unit: public Object
DECLARE_PROPERTY(uint8, CastleSiegeJoinSide);
DECLARE_PROPERTY(uint8, KillCount);
DECLARE_BOOL(ForceUpgrade);
DECLARE_PROPERTY_ARRAY(coord_type, SkillAngleX, MAX_ARRAY_FRUSTRUM);
DECLARE_PROPERTY_ARRAY(coord_type, SkillAngleY, MAX_ARRAY_FRUSTRUM);
DECLARE_PROPERTY_ARRAY(int16, SkillAngleX, MAX_ARRAY_FRUSTRUM);
DECLARE_PROPERTY_ARRAY(int16, SkillAngleY, MAX_ARRAY_FRUSTRUM);
DECLARE_STRUCT(PathData, PathData);
DECLARE_PROPERTY_PTR(Unit, Killer);

@@ -627,8 +627,8 @@ class Unit: public Object
DECLARE_PTR(Unit, LastAttacker);

// Almacena las coordenadas hacia donde tiene intencion de moverse
DECLARE_ENUM(coord_type, TempX);
DECLARE_ENUM(coord_type, TempY);
DECLARE_ENUM(int16, TempX);
DECLARE_ENUM(int16, TempY);

UnitPunishMap punish_map;
};
@@ -79,7 +79,7 @@ void Unit::SkillAngleCalculate(float angle, float tx, float ty, float sx, float
}*/
}

bool Unit::SkillInAngle(coord_type x, coord_type y)
bool Unit::SkillInAngle(int16 x, int16 y)
{
uint8 j = 3;

@@ -169,7 +169,7 @@ void VectorRotate (const vec3_t in1, const float in2[3][4], vec3_t out)
out[2] = DotProduct(in1, in2[2]);
}

int32 Unit::GetAngle(coord_type x, coord_type y)
int32 Unit::GetAngle(int16 x, int16 y)
{
double diffX = this->GetX() - x;
double diffY = this->GetY() - y;
@@ -210,7 +210,7 @@ void Unit::RunNova()
SkillHandler(this, nullptr, this->MagicGet(this->GetNova()->GetSkill())).SkillUseProc();
}

void Unit::SkillTeleportUse(coord_type x, coord_type y)
void Unit::SkillTeleportUse(int16 x, int16 y)
{
if ( this->IsTeleporting() )
return;
@@ -118,112 +118,89 @@ World::~World()

const char* World::GetCurrentStatusName() const
{
if ( this->GetStatus() >= MAX_WORLD_STATUS )
{
if (GetStatus() >= MAX_WORLD_STATUS)
return "";
}

return this->WorldStatus[this->GetStatus()].GetName();
else
return WorldStatus[GetStatus()].GetName();
}

bool World::IsCurrentStatusFlag(uint32 flags) const
{
if ( this->GetStatus() >= MAX_WORLD_STATUS )
{
if (GetStatus() >= MAX_WORLD_STATUS)
return false;
}

return (this->WorldStatus[this->GetStatus()].GetFlags() & flags) != 0;
else
return (WorldStatus[GetStatus()].GetFlags() & flags) != 0;
}

uint32 World::GetCurrentStatusExperienceRate() const
{
if ( this->GetStatus() >= MAX_WORLD_STATUS )
{
if (GetStatus() >= MAX_WORLD_STATUS)
return 0;
}

return this->WorldStatus[this->GetStatus()].GetExperienceRate();
else
return WorldStatus[GetStatus()].GetExperienceRate();
}

uint32 World::GetCurrentStatusZenRate() const
{
if ( this->GetStatus() >= MAX_WORLD_STATUS )
{
if (GetStatus() >= MAX_WORLD_STATUS)
return 0;
}

return this->WorldStatus[this->GetStatus()].GetZenRate();
else
return WorldStatus[GetStatus()].GetZenRate();
}

uint16 World::GetCurrentGate() const
{
if (this->GetStatus() >= MAX_WORLD_STATUS)
{
if (GetStatus() >= MAX_WORLD_STATUS)
return 0;
}

return this->WorldStatus[this->GetStatus()].GetSpawnGate();
else
return WorldStatus[GetStatus()].GetSpawnGate();
}

void World::GetRespawn(world_type & spawn_world, coord_type & x1, coord_type & y1, coord_type & x2, coord_type & y2)
void World::GetRespawn(uint16 & spawn_world, int16 & x1, int16 & y1, int16 & x2, int16 & y2)
{
if ( this->GetStatus() >= MAX_WORLD_STATUS )
{
if (GetStatus() >= MAX_WORLD_STATUS)
return;
}

WorldStatusData const& StatusData = this->WorldStatus[this->GetStatus()];

if ( !StatusData.IsActive() )
{
auto const& status_data = WorldStatus[GetStatus()];
if (!status_data.IsActive())
return;
}

GateData const* pGate = sTeleport->GetGate(StatusData.GetSpawnGate());

if ( pGate )
auto gate_data = sTeleport->GetGate(status_data.GetSpawnGate());
if (gate_data)
{
spawn_world = pGate->world;
x1 = pGate->x1;
y1 = pGate->y1;
x2 = pGate->x2;
y2 = pGate->y2;
spawn_world = gate_data->MapId;
x1 = gate_data->X1;
y1 = gate_data->Y1;
x2 = gate_data->X2;
y2 = gate_data->Y2;
}
}

void World::GetRespawn(world_type & spawn_world, coord_type & x, coord_type & y)
void World::GetRespawn(uint16 & spawn_world, int16 & x, int16 & y)
{
if ( this->GetStatus() >= MAX_WORLD_STATUS )
{
if (GetStatus() >= MAX_WORLD_STATUS)
return;
}

WorldStatusData const& StatusData = this->WorldStatus[this->GetStatus()];

if ( !StatusData.IsActive() )
{
auto const& status_data = WorldStatus[GetStatus()];
if (!status_data.IsActive())
return;
}

GateData const* pGate = sTeleport->GetGate(StatusData.GetSpawnGate());

if ( pGate )
auto gate_data = sTeleport->GetGate(status_data.GetSpawnGate());
if (gate_data)
{
if ( World* pWorld = sWorldMgr->GetWorld(pGate->world) )
if (World* pWorld = sWorldMgr->GetWorld(gate_data->MapId))
{
spawn_world = pGate->world;

pWorld->GetRandomLocation(x, y, pGate->x1, pGate->y1, pGate->x2, pGate->y2);
spawn_world = gate_data->MapId;
pWorld->GetRandomLocation(x, y, gate_data->X1, gate_data->Y1, gate_data->X2, gate_data->Y2);
}
}
}

void World::GetRandomLocation(coord_type & x, coord_type & y, coord_type x1, coord_type y1, coord_type x2, coord_type y2)
void World::GetRandomLocation(int16 & x, int16 & y, int16 x1, int16 y1, int16 x2, int16 y2)
{
int32 loopcount = 50;
coord_type tx = x;
coord_type ty = y;
int16 tx = x;
int16 ty = y;

x = x1;
y = y1;
@@ -258,10 +235,10 @@ void World::GetRandomLocation(coord_type & x, coord_type & y, coord_type x1, coo
}
}

bool World::GetFreeLocation(coord_type & x, coord_type & y, coord_type range_x, coord_type range_y, int32 count)
bool World::GetFreeLocation(int16 & x, int16 & y, int16 range_x, int16 range_y, int32 count)
{
coord_type tx = x;
coord_type ty = y;
int16 tx = x;
int16 ty = y;

while ( count-- > 0 )
{
@@ -284,7 +261,7 @@ bool World::GetFreeLocation(coord_type & x, coord_type & y, coord_type range_x,
return false;
}

bool World::GetRandomLocation(coord_type & x, coord_type & y, int32 length) const
bool World::GetRandomLocation(int16 & x, int16 & y, int32 length) const
{
int32 count = 10;

@@ -295,8 +272,8 @@ bool World::GetRandomLocation(coord_type & x, coord_type & y, int32 length) cons

while ( count-- > 0 )
{
coord_type px = (x - length) + Random(max_length);
coord_type py = (y - length) + Random(max_length);
int16 px = (x - length) + Random(max_length);
int16 py = (y - length) + Random(max_length);

WorldGrid const& grid = this->GetGrid(px, py);

@@ -498,7 +475,7 @@ void World::UpdateItemQueue()
}
}

bool World::add_item(Item item, Unit* owner, coord_type x, coord_type y, bool only_owner, bool visible, bool to_queue)
bool World::add_item(Item item, Unit* owner, int16 x, int16 y, bool only_owner, bool visible, bool to_queue)
{
if ( this->GetGrid(x, y).IsLocked_1() || this->GetGrid(x, y).IsLocked_2() )
{
@@ -602,7 +579,7 @@ void World::ClearItem()
this->m_world_item_loop = 0;
}

WorldGrid World::GetGrid(coord_type x, coord_type y) const
WorldGrid World::GetGrid(int16 x, int16 y) const
{
if ( !IS_COORDINATE_RANGE(x) || !IS_COORDINATE_RANGE(y) )
{
@@ -638,14 +615,14 @@ WorldGrid World::GetGrid(coord_type x, coord_type y) const
return *Grid;
}

bool World::GetRandomDropLocation(coord_type stx, coord_type sty, coord_type & x, coord_type & y, coord_type range_x, coord_type range_y, int32 loop) const
bool World::GetRandomDropLocation(int16 stx, int16 sty, int16 & x, int16 & y, int16 range_x, int16 range_y, int32 loop) const
{
limitmin(range_x, 1);
limitmin(range_y, 1);
limitmin(loop, 1);

coord_type tmp_x = stx;
coord_type tmp_y = sty;
int16 tmp_x = stx;
int16 tmp_y = sty;

while ( loop-- > 0 )
{
@@ -666,7 +643,7 @@ bool World::GetRandomDropLocation(coord_type stx, coord_type sty, coord_type & x
return false;
}

bool World::AddZen(Unit* pUnit, coord_type x, coord_type y, uint32 zen)
bool World::AddZen(Unit* pUnit, int16 x, int16 y, uint32 zen)
{
WorldGrid const& attr = this->GetGrid(x, y);

@@ -679,7 +656,7 @@ bool World::AddZen(Unit* pUnit, coord_type x, coord_type y, uint32 zen)
return this->add_item(item, pUnit, x, y, false);
}

bool World::CheckWall(coord_type sx1, coord_type sy1, coord_type sx2, coord_type sy2) const
bool World::CheckWall(int16 sx1, int16 sy1, int16 sx2, int16 sy2) const
{
if ( this->GetStatus() >= MAX_WORLD_STATUS )
{
@@ -694,14 +671,14 @@ bool World::CheckWall(coord_type sx1, coord_type sy1, coord_type sx2, coord_type
}

int32 Index = WORLD_MAKE_GRID(sx1, sy1);
coord_type nx1;
coord_type ny1;
coord_type d1;
coord_type d2;
coord_type len1;
coord_type len2;
coord_type px1 = sx2 - sx1;
coord_type py1 = sy2 - sy1;
int16 nx1;
int16 ny1;
int16 d1;
int16 d2;
int16 len1;
int16 len2;
int16 px1 = sx2 - sx1;
int16 py1 = sy2 - sy1;

if ( px1 < 0 )
{
@@ -769,7 +746,7 @@ bool World::CheckWall(coord_type sx1, coord_type sy1, coord_type sx2, coord_type
return true;
}

void World::ApplyAttribute(coord_type x, coord_type y, uint8 attr, bool apply)
void World::ApplyAttribute(int16 x, int16 y, uint8 attr, bool apply)
{
if ( !IS_COORDINATE_RANGE(x) || !IS_COORDINATE_RANGE(y) )
{
@@ -798,11 +775,11 @@ void World::ApplyAttribute(coord_type x, coord_type y, uint8 attr, bool apply)
}
}

void World::ApplyAttribute(coord_type const* data, uint8 attr, bool apply)
void World::ApplyAttribute(int16 const* data, uint8 attr, bool apply)
{
for ( coord_type x = data[0]; x <= data[2]; ++x )
for ( int16 x = data[0]; x <= data[2]; ++x )
{
for ( coord_type y = data[1]; y <= data[3]; ++y )
for ( int16 y = data[1]; y <= data[3]; ++y )
{
this->ApplyAttribute(x, y, attr, apply);
}
@@ -831,17 +808,17 @@ void World::MakeItemVisible(Player* pPlayer)
}
}

bool World::IsAreaRestriction(coord_type x, coord_type y, uint8 flag) const
bool World::IsAreaRestriction(int16 x, int16 y, uint8 flag) const
{
for ( WorldAreaList::const_iterator it = this->m_area.begin(); it != this->m_area.end(); ++it )
{
if ( !(*it)->IsFlags(flag) )
continue;

coord_type x1 = (*it)->GetX() - (*it)->GetRange();
coord_type y1 = (*it)->GetY() - (*it)->GetRange();
coord_type x2 = (*it)->GetX() + (*it)->GetRange();
coord_type y2 = (*it)->GetY() + (*it)->GetRange();
int16 x1 = (*it)->GetX() - (*it)->GetRange();
int16 y1 = (*it)->GetY() - (*it)->GetRange();
int16 x2 = (*it)->GetX() + (*it)->GetRange();
int16 y2 = (*it)->GetY() + (*it)->GetRange();

FIX_COORD(x1);
FIX_COORD(y1);
@@ -5,8 +5,8 @@ struct WorldAIPath
{
DECLARE_ENUM(uint32, ID);
DECLARE_ENUM(uint8, Type);
DECLARE_ENUM(coord_type, X);
DECLARE_ENUM(coord_type, Y);
DECLARE_ENUM(int16, X);
DECLARE_ENUM(int16, Y);
};

typedef std::vector<WorldAIPath*> WorldAIPathList;
@@ -21,8 +21,8 @@ typedef std::map<uint16, WorldBuff*> WorldBuffMap;

struct WorldArea
{
DECLARE_ENUM(coord_type, X);
DECLARE_ENUM(coord_type, Y);
DECLARE_ENUM(int16, X);
DECLARE_ENUM(int16, Y);
DECLARE_ENUM(uint8, Range);
DECLARE_FLAG(uint8, Flags);
};
@@ -31,10 +31,10 @@ typedef std::vector<WorldArea*> WorldAreaList;

struct WorldAreaAttribute
{
DECLARE_ENUM(coord_type, X1);
DECLARE_ENUM(coord_type, Y1);
DECLARE_ENUM(coord_type, X2);
DECLARE_ENUM(coord_type, Y2);
DECLARE_ENUM(int16, X1);
DECLARE_ENUM(int16, Y1);
DECLARE_ENUM(int16, X2);
DECLARE_ENUM(int16, Y2);
DECLARE_ENUM(uint8, Attribute);
DECLARE_BOOL(Apply);
DECLARE_BOOL(Send);
@@ -106,11 +106,11 @@ class World

uint8 GetWeatherConverted() const { return (this->GetWeather() << 4) | this->GetWeatherVariation(); }

void GetRespawn(world_type & spawn_world, coord_type & x1, coord_type & y1, coord_type & x2, coord_type & y2);
void GetRespawn(world_type & spawn_world, coord_type & x, coord_type & y);
void GetRandomLocation(coord_type & x, coord_type & y, coord_type x1, coord_type y1, coord_type x2, coord_type y2);
bool GetFreeLocation(coord_type & x, coord_type & y, coord_type range_x, coord_type range_y, int32 count);
bool GetRandomLocation(coord_type & x, coord_type & y, int32 length) const;
void GetRespawn(uint16 & spawn_world, int16 & x1, int16 & y1, int16 & x2, int16 & y2);
void GetRespawn(uint16 & spawn_world, int16 & x, int16 & y);
void GetRandomLocation(int16 & x, int16 & y, int16 x1, int16 y1, int16 x2, int16 y2);
bool GetFreeLocation(int16 & x, int16 & y, int16 range_x, int16 range_y, int32 count);
bool GetRandomLocation(int16 & x, int16 & y, int32 length) const;

bool IsObject(Object* pObject);
void AddObject(Object* pObject);
@@ -121,24 +121,24 @@ class World
void UpdateWeather();
void UpdateItemQueue();

bool add_item(Item item, Unit* owner, coord_type x, coord_type y, bool only_owner = false, bool visible = true, bool to_queue = false);
bool add_item(Item item, Unit* owner, int16 x, int16 y, bool only_owner = false, bool visible = true, bool to_queue = false);
WorldItem * GetItem(uint16 id);
void ClearItem();
WorldGrid GetGrid(coord_type x, coord_type y) const;
WorldGrid GetGrid(int16 x, int16 y) const;

bool GetRandomDropLocation(coord_type stx, coord_type sty, coord_type & x, coord_type & y, coord_type range_x, coord_type range_y, int32 loop) const;
bool AddZen(Unit* pUnit, coord_type x, coord_type y, uint32 zen);
bool GetRandomDropLocation(int16 stx, int16 sty, int16 & x, int16 & y, int16 range_x, int16 range_y, int32 loop) const;
bool AddZen(Unit* pUnit, int16 x, int16 y, uint32 zen);

bool CheckWall(coord_type sx1, coord_type sy1, coord_type sx2, coord_type sy2) const;
bool CheckWall(int16 sx1, int16 sy1, int16 sx2, int16 sy2) const;

void ApplyAttribute(coord_type x, coord_type y, uint8 attr, bool apply);
void ApplyAttribute(coord_type const* data, uint8 attr, bool apply);
void ApplyAttribute(int16 x, int16 y, uint8 attr, bool apply);
void ApplyAttribute(int16 const* data, uint8 attr, bool apply);

void statusChange(uint8 status);

void MakeItemVisible(Player* pPlayer);

bool IsAreaRestriction(coord_type x, coord_type y, uint8 flag) const;
bool IsAreaRestriction(int16 x, int16 y, uint8 flag) const;

WorldItem* GetItemData(uint16 item) const
{
@@ -162,8 +162,8 @@ class World
private:
WorldStatusData WorldStatus[MAX_WORLD_STATUS];

DECLARE_ENUM(world_type, Entry);
DECLARE_ENUM(world_type, Display);
DECLARE_ENUM(uint16, Entry);
DECLARE_ENUM(uint16, Display);
DECLARE_ENUM(uint8, Status);
DECLARE_ENUM(uint8, Weather);
DECLARE_ENUM(uint8, WeatherVariation);
@@ -288,10 +288,10 @@ struct WorldGrid

struct WorldBlockZone
{
coord_type x1;
coord_type y1;
coord_type x2;
coord_type y2;
int16 x1;
int16 y1;
int16 x2;
int16 y2;
};

#define URUK_MOUNTAIN_BLOCK_ZONE 6
@@ -38,8 +38,8 @@ class WorldItem: public Object
struct WorldItemQueued
{
Item item;
DECLARE_ENUM(coord_type, X);
DECLARE_ENUM(coord_type, Y);
DECLARE_ENUM(int16, X);
DECLARE_ENUM(int16, Y);
DECLARE_PTR(Unit, Owner);
DECLARE_BOOL(OnlyOwner);
DECLARE_BOOL(Visible);
@@ -40,8 +40,8 @@ void WorldMgr::LoadWorldList()
{
Field* fields = result->Fetch();

world_type entry = fields[0].GetUInt16();
world_type display_entry = fields[1].GetUInt16();
uint16 entry = fields[0].GetUInt16();
uint16 display_entry = fields[1].GetUInt16();
uint8 status = fields[2].GetUInt8();
std::string file = "World/" + fields[3].GetString();
uint16 spawn_gate = fields[5].GetUInt16();
@@ -115,8 +115,8 @@ void WorldMgr::LoadWorldData()
{
Field* fields = result->Fetch();

world_type entry = fields[0].GetUInt16();
world_type display_entry = fields[1].GetUInt16();
uint16 entry = fields[0].GetUInt16();
uint16 display_entry = fields[1].GetUInt16();
uint8 status = fields[2].GetUInt8();
std::string file = "World/" + fields[3].GetString();
uint16 spawn_gate = fields[5].GetUInt16();
@@ -299,7 +299,7 @@ void WorldMgr::LoadWorldServer()
Field* fields = result->Fetch();

uint16 server = fields[0].GetUInt16();
world_type world = fields[1].GetUInt16();
uint16 world = fields[1].GetUInt16();

if ( (server / MAX_SERVER_PER_GROUP) != sGameServer->GetServerGroup() )
continue;
@@ -433,7 +433,7 @@ void WorldMgr::LoadWorldAreaAttribute()

pWorld->m_attribute.push_back(area);

coord_type coord[4] = { area->GetX1(), area->GetY1(), area->GetX2(), area->GetY2() };
int16 coord[4] = { area->GetX1(), area->GetY1(), area->GetX2(), area->GetY2() };
pWorld->ApplyAttribute(coord, area->GetAttribute(), area->IsApply());

++count;
@@ -536,7 +536,7 @@ void WorldMgr::MakeItemVisible(Player* pPlayer)
}
}

uint16 WorldMgr::AllowMoveToWorld(Player* pPlayer, world_type world)
uint16 WorldMgr::AllowMoveToWorld(Player* pPlayer, uint16 world)
{
if ( !pPlayer )
return -1;
@@ -570,7 +570,7 @@ uint16 WorldMgr::AllowMoveToWorld(Player* pPlayer, world_type world)
return sGameServer->GetServerCode();
}

bool WorldMgr::AllowMoveToWorld(Player* pPlayer, world_type world, uint16 server)
bool WorldMgr::AllowMoveToWorld(Player* pPlayer, uint16 world, uint16 server)
{
if ( !pPlayer )
return false;
@@ -593,7 +593,7 @@ bool WorldMgr::AllowMoveToWorld(Player* pPlayer, world_type world, uint16 server
return true;
}

bool WorldMgr::IsWorldAllowed(world_type world)
bool WorldMgr::IsWorldAllowed(uint16 world)
{
for ( WorldServerMap::const_iterator itr = this->world_server_map.begin(); itr != this->world_server_map.end(); ++itr )
{
@@ -620,12 +620,12 @@ bool WorldMgr::IsWorldAllowed(world_type world)
return true;
}

bool WorldMgr::IsWorld(world_type world)
bool WorldMgr::IsWorld(uint16 world)
{
return this->GetWorld(world) != nullptr;
}

World* WorldMgr::GetWorld(world_type world)
World* WorldMgr::GetWorld(uint16 world)
{
WorldMap::iterator itr = this->world_map.find(world);

@@ -658,7 +658,7 @@ void WorldMgr::UpdateUrukMountainZone(bool apply)

for ( int32 i = 0; i < URUK_MOUNTAIN_BLOCK_ZONE; ++i )
{
coord_type coords[4] = { g_UrukMountainBlock[i].x1, g_UrukMountainBlock[i].y1, g_UrukMountainBlock[i].x2, g_UrukMountainBlock[i].y2 };
int16 coords[4] = { g_UrukMountainBlock[i].x1, g_UrukMountainBlock[i].y1, g_UrukMountainBlock[i].x2, g_UrukMountainBlock[i].y2 };
pWorld->ApplyAttribute(coords, URUK_MOUNTAIN_BLOCK_ATTRIBUTE, apply);
}

@@ -709,7 +709,7 @@ void WorldMgr::SendUrukMountainZone(Player* pPlayer)
return;
}

coord_type coords[4 * URUK_MOUNTAIN_BLOCK_ZONE];
int16 coords[4 * URUK_MOUNTAIN_BLOCK_ZONE];

for ( int32 i = 0; i < URUK_MOUNTAIN_BLOCK_ZONE; ++i )
{
@@ -763,7 +763,7 @@ void WorldMgr::UpdateFereaZone(bool apply)

for ( int32 i = 0; i < FEREA_BLOCK_ZONE; ++i )
{
coord_type coords[4] = { g_FereaBlock[i].x1, g_FereaBlock[i].y1, g_FereaBlock[i].x2, g_FereaBlock[i].y2 };
int16 coords[4] = { g_FereaBlock[i].x1, g_FereaBlock[i].y1, g_FereaBlock[i].x2, g_FereaBlock[i].y2 };
pWorld->ApplyAttribute(coords, FEREA_BLOCK_ATTRIBUTE, apply);
}

@@ -814,7 +814,7 @@ void WorldMgr::SendFereaZone(Player* pPlayer)
return;
}

coord_type coords[4 * FEREA_BLOCK_ZONE];
int16 coords[4 * FEREA_BLOCK_ZONE];

for ( int32 i = 0; i < FEREA_BLOCK_ZONE; ++i )
{
@@ -827,7 +827,7 @@ void WorldMgr::SendFereaZone(Player* pPlayer)
pPlayer->SendWorldAttribute(0, FEREA_BLOCK_ATTRIBUTE, FEREA_BLOCK_ZONE, g_FereaBlockStatus, coords);
}

int32 WorldMgr::GetWorldExperienceRate(world_type world, uint8 count)
int32 WorldMgr::GetWorldExperienceRate(uint16 world, uint8 count)
{
if ( count == 0 )
{
@@ -853,7 +853,7 @@ int32 WorldMgr::GetWorldExperienceRate(world_type world, uint8 count)
}
}

void WorldMgr::SetPKBoss(world_type world, bool enabled)
void WorldMgr::SetPKBoss(uint16 world, bool enabled)
{
World * pWorld = this->GetWorld(world);

@@ -866,7 +866,7 @@ void WorldMgr::SetPKBoss(world_type world, bool enabled)
pWorld->GetPKBossTime()->Start();
}

bool WorldMgr::IsPKBoss(world_type world)
bool WorldMgr::IsPKBoss(uint16 world)
{
if ( !sGameServer->IsPKBossEnabled() )
{
@@ -888,7 +888,7 @@ bool WorldMgr::IsPKBoss(world_type world)
return pWorld->IsPKBossEnabled();
}

bool WorldMgr::IsItemDropAllowed(Player* pPlayer, World* pWorld, coord_type x, coord_type y)
bool WorldMgr::IsItemDropAllowed(Player* pPlayer, World* pWorld, int16 x, int16 y)
{
if ( !pPlayer || !pWorld )
{
@@ -911,7 +911,7 @@ bool WorldMgr::IsItemDropAllowed(Player* pPlayer, World* pWorld, coord_type x, c
return true;
}

bool WorldMgr::IsFreePK(world_type world, coord_type x, coord_type y) const
bool WorldMgr::IsFreePK(uint16 world, int16 x, int16 y) const
{
for (WorldFreePKList::const_iterator itr = this->m_WorldFreePKList.begin(); itr != this->m_WorldFreePKList.end(); ++itr)
{
@@ -1,26 +1,26 @@
#ifndef WORLD_MANAGER_H
#define WORLD_MANAGER_H

typedef std::set<world_type> WorldServerList;
typedef std::set<uint16> WorldServerList;
typedef std::map<uint16, WorldServerList> WorldServerMap;

struct world_experience
{
DECLARE_ENUM(world_type, World);
DECLARE_ENUM(uint16, World);
DECLARE_PROPERTY_ARRAY(int32, Rate, MAX_PARTY_MEMBERS);
};

typedef std::map<world_type, world_experience*> WorldExperienceMap;
typedef std::map<uint16, world_experience*> WorldExperienceMap;

typedef std::map<world_type, World*> WorldMap;
typedef std::map<uint16, World*> WorldMap;

struct WorldFreePK
{
DECLARE_ENUM(world_type, World);
DECLARE_ENUM(coord_type, X1);
DECLARE_ENUM(coord_type, Y1);
DECLARE_ENUM(coord_type, X2);
DECLARE_ENUM(coord_type, Y2);
DECLARE_ENUM(uint16, World);
DECLARE_ENUM(int16, X1);
DECLARE_ENUM(int16, Y1);
DECLARE_ENUM(int16, X2);
DECLARE_ENUM(int16, Y2);
};

typedef std::vector<WorldFreePK*> WorldFreePKList;
@@ -51,16 +51,16 @@ class WorldMgr

void Update();
void UpdateWeather();
bool IsWorld(world_type world);
World* GetWorld(world_type world);
bool IsWorld(uint16 world);
World* GetWorld(uint16 world);

void statusChange(world_type entry, uint8 status);
void statusChange(uint16 entry, uint8 status);
void MakeItemVisible(Player* pPlayer);

uint16 AllowMoveToWorld(Player* pPlayer, world_type world);
bool AllowMoveToWorld(Player* pPlayer, world_type world, uint16 server);
uint16 AllowMoveToWorld(Player* pPlayer, uint16 world);
bool AllowMoveToWorld(Player* pPlayer, uint16 world, uint16 server);

bool IsWorldAllowed(world_type world);
bool IsWorldAllowed(uint16 world);

void UpdateUrukMountainZone(bool apply);
void SendUrukMountainZone();
@@ -73,13 +73,13 @@ class WorldMgr
WorldMap world_map;
WorldExperienceMap world_experience_map;

int32 GetWorldExperienceRate(world_type world, uint8 count);
int32 GetWorldExperienceRate(uint16 world, uint8 count);

void SetPKBoss(world_type world, bool enabled);
bool IsPKBoss(world_type world);
void SetPKBoss(uint16 world, bool enabled);
bool IsPKBoss(uint16 world);

bool IsItemDropAllowed(Player* pPlayer, World* pWorld, coord_type x, coord_type y);
bool IsFreePK(world_type world, coord_type x, coord_type y) const;
bool IsItemDropAllowed(Player* pPlayer, World* pWorld, int16 x, int16 y);
bool IsFreePK(uint16 world, int16 x, int16 y) const;
};

#endif
@@ -13,7 +13,7 @@ void PathFinder::Create(World* pWorld)
this->SetWorld(pWorld);
}

void PathFinder::SetHitMap(coord_type x, coord_type y, bool hit)
void PathFinder::SetHitMap(int16 x, int16 y, bool hit)
{
if ( !IS_COORDINATE_RANGE(x) || !IS_COORDINATE_RANGE(y) )
{
@@ -23,7 +23,7 @@ void PathFinder::SetHitMap(coord_type x, coord_type y, bool hit)
this->HitMap[WORLD_MAKE_GRID(x, y)] = hit;
}

int PathFinder::VerifyThatOnPath(coord_type x, coord_type y)
int PathFinder::VerifyThatOnPath(int16 x, int16 y)
{
for ( int32 i = 0; i < this->NumPath; ++i )
{
@@ -35,7 +35,7 @@ int PathFinder::VerifyThatOnPath(coord_type x, coord_type y)
return -1;
}

bool PathFinder::CanWeMoveForward(coord_type x, coord_type y, Unit* pUnit)
bool PathFinder::CanWeMoveForward(int16 x, int16 y, Unit* pUnit)
{
if ( !IS_COORDINATE_RANGE(x) || !IS_COORDINATE_RANGE(y) )
{
@@ -70,7 +70,7 @@ bool PathFinder::CanWeMoveForward(coord_type x, coord_type y, Unit* pUnit)
return true;
};

bool PathFinder::IsThisSpotOK(coord_type x, coord_type y)
bool PathFinder::IsThisSpotOK(int16 x, int16 y)
{
if ( !IS_COORDINATE_RANGE(x) || !IS_COORDINATE_RANGE(y) )
{
@@ -85,7 +85,7 @@ bool PathFinder::IsThisSpotOK(coord_type x, coord_type y)
return true;
};

int PathFinder::FindNextDir(coord_type sx, coord_type sy, coord_type dx, coord_type dy, int dirstart, bool first, bool error_check, Unit* pUnit)
int PathFinder::FindNextDir(int16 sx, int16 sy, int16 dx, int16 dy, int dirstart, bool first, bool error_check, Unit* pUnit)
{
int32 MinDist = 10000000;
int32 ldir;
@@ -96,8 +96,8 @@ int PathFinder::FindNextDir(coord_type sx, coord_type sy, coord_type dx, coord_t
for (int32 i = 0; i < 8; ++i )
{
ldir = i % 8;
coord_type endx = sx + Path::Table[ldir * 2];
coord_type endy = sy + Path::Table[ldir * 2 + 1];
int16 endx = sx + Path::Table[ldir * 2];
int16 endy = sy + Path::Table[ldir * 2 + 1];
int32 dist = Util::Distance(endx, endy, dx, dy);

if ( MinDist > dist )
@@ -115,8 +115,8 @@ int PathFinder::FindNextDir(coord_type sx, coord_type sy, coord_type dx, coord_t
for (int32 i = dirstart + 7; i <= dirstart + 9; ++i )
{
ldir = i % 8;
coord_type endx = sx + Path::Table[ldir * 2];
coord_type endy = sy + Path::Table[ldir * 2 + 1];
int16 endx = sx + Path::Table[ldir * 2];
int16 endy = sy + Path::Table[ldir * 2 + 1];
int32 dist = Util::Distance(endx, endy, dx, dy);

if ( MinDist > dist )
@@ -134,8 +134,8 @@ int PathFinder::FindNextDir(coord_type sx, coord_type sy, coord_type dx, coord_t
for (int32 i = dirstart + 2; i <= dirstart + 6; ++i )
{
ldir = i % 8;
coord_type endx = sx + Path::Table[ldir * 2];
coord_type endy = sy + Path::Table[ldir * 2 + 1];
int16 endx = sx + Path::Table[ldir * 2];
int16 endy = sy + Path::Table[ldir * 2 + 1];
int32 dist = Util::Distance(endx, endy, dx, dy);

if ( MinDist > dist )
@@ -213,7 +213,7 @@ int PathFinder::FindNextDir(coord_type sx, coord_type sy, coord_type dx, coord_t
return -1;
};

bool PathFinder::AssignPath(coord_type x, coord_type y)
bool PathFinder::AssignPath(int16 x, int16 y)
{
this->PathX[this->NumPath] = x;
this->PathY[this->NumPath] = y;
@@ -227,7 +227,7 @@ bool PathFinder::AssignPath(coord_type x, coord_type y)
return true;
}

bool PathFinder::FindPath(coord_type startx, coord_type starty, coord_type endx, coord_type endy, bool error_check, Unit* pUnit)
bool PathFinder::FindPath(int16 startx, int16 starty, int16 endx, int16 endy, bool error_check, Unit* pUnit)
{
this->NumPath = 0;
int32 WhichDir = 0;
@@ -304,10 +304,10 @@ bool PathFinder::FindPath(Unit* pUnit)

if ( Success && NumPath )
{
coord_type tx;
coord_type ty;
coord_type sx = pUnit->GetX();
coord_type sy = pUnit->GetY();
int16 tx;
int16 ty;
int16 sx = pUnit->GetX();
int16 sy = pUnit->GetY();
uint8 pos = 0;

memset(bPath, 0, sizeof(bPath));
@@ -7,8 +7,8 @@ class PathFinder
{
private:
int32 NumPath;
coord_type PathX[MAX_PATH_FIND];
coord_type PathY[MAX_PATH_FIND];
int16 PathX[MAX_PATH_FIND];
int16 PathY[MAX_PATH_FIND];
int32 LastDir;
int32 NumFails;
WorldGrid* Map;
@@ -21,19 +21,19 @@ class PathFinder

uint8 HitMap[WORLD_MAX_SIZE];
private:
void SetHitMap(coord_type x, coord_type y, bool hit);
int VerifyThatOnPath(coord_type x, coord_type y);
bool CanWeMoveForward(coord_type x, coord_type y, Unit* pUnit);
bool IsThisSpotOK(coord_type x, coord_type y);
int FindNextDir(coord_type sx, coord_type sy, coord_type dx, coord_type dy, int dirstart, bool first, bool error_check, Unit* pUnit);
bool AssignPath(coord_type x, coord_type y);
void SetHitMap(int16 x, int16 y, bool hit);
int VerifyThatOnPath(int16 x, int16 y);
bool CanWeMoveForward(int16 x, int16 y, Unit* pUnit);
bool IsThisSpotOK(int16 x, int16 y);
int FindNextDir(int16 sx, int16 sy, int16 dx, int16 dy, int dirstart, bool first, bool error_check, Unit* pUnit);
bool AssignPath(int16 x, int16 y);

public:
PathFinder();
virtual ~PathFinder();

void Create(World*);
bool FindPath(coord_type startx, coord_type starty, coord_type endx, coord_type endy, bool error_check, Unit* pUnit);
bool FindPath(int16 startx, int16 starty, int16 endx, int16 endy, bool error_check, Unit* pUnit);
bool FindPath(Unit* pUnit);
};

@@ -31,8 +31,8 @@ struct CrownBasicAI: public MonsterAI
{
DECLARE(uint8, state);
DECLARE_PTR(Player, Player);
DECLARE_ENUM(coord_type, X);
DECLARE_ENUM(coord_type, Y);
DECLARE_ENUM(int16, X);
DECLARE_ENUM(int16, Y);
DECLARE_BOOL(Available);

explicit CrownBasicAI(Monster* monster): MonsterAI(monster)
@@ -123,8 +123,8 @@ struct CastleMachineBasicAI: public MonsterAI
DECLARE_PTR(Player, Player);
DECLARE_BOOL(Active);
DECLARE_BOOL(Ready);
DECLARE_ENUM(coord_type, X);
DECLARE_ENUM(coord_type, Y);
DECLARE_ENUM(int16, X);
DECLARE_ENUM(int16, Y);
DECLARE_STRUCT(TickTimer, Time);

struct CastleMachineTargetData
@@ -152,7 +152,7 @@ struct CastleMachineBasicAI: public MonsterAI
LIST_CLEAR(CastleMachineTargetDataList::iterator, this->m_target_data_list);
}

void Start(coord_type x, coord_type y)
void Start(int16 x, int16 y)
{
this->SetX(x);
this->SetY(y);
@@ -191,12 +191,12 @@ class MercenaryScript: public MonsterScriptAI
if ( me()->GetCastleSiegeJoinSide() == pObject->ToUnit()->GetCastleSiegeJoinSide() )
continue;

coord_type distance_x = me()->GetX() - pObject->GetX();
coord_type distance_y = me()->GetY() - pObject->GetY();
int16 distance_x = me()->GetX() - pObject->GetX();
int16 distance_y = me()->GetY() - pObject->GetY();

if ( me()->GetDirection() == 1 && abs(distance_x) <= 2 )
{
coord_type cy = me()->GetY() - me()->GetAttackRange();
int16 cy = me()->GetY() - me()->GetAttackRange();

if ( cy <= pObject->GetY() && me()->GetY() >= pObject->GetY() )
{
@@ -207,7 +207,7 @@ class MercenaryScript: public MonsterScriptAI

if ( me()->GetDirection() == 3 && abs(distance_y) <= 2 )
{
coord_type cx = me()->GetX() - me()->GetAttackRange();
int16 cx = me()->GetX() - me()->GetAttackRange();

if ( cx <= pObject->GetX() && me()->GetX() >= pObject->GetX())
{
@@ -301,8 +301,8 @@ class ChampionScript: public MonsterScriptAI
return;
}

coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

if ( pWorld->GetFreeLocation(x, y, 4, 4, 10) )
{
@@ -91,29 +91,29 @@ class ChaosCastleScript: public MonsterScriptAI
if ( !grid.IsLocked_2() )
return;

coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

this->GetRandomSafeZone(x, y);
me()->PositionSend(x, y);
me()->ViewportCreate(VIEWPORT_CREATE_FLAG_ME);
}

void GetRandomSafeZone(coord_type &x, coord_type &y)
void GetRandomSafeZone(int16 &x, int16 &y)
{
World* pWorld = me()->GetWorld();

if ( !pWorld )
return;

int32 count = 100;
coord_type x_1 = g_ChaosCastle_GroundAxis[0];
coord_type y_1 = g_ChaosCastle_GroundAxis[1];
coord_type x_2 = g_ChaosCastle_GroundAxis[2];
coord_type y_2 = g_ChaosCastle_GroundAxis[3];
int16 x_1 = g_ChaosCastle_GroundAxis[0];
int16 y_1 = g_ChaosCastle_GroundAxis[1];
int16 x_2 = g_ChaosCastle_GroundAxis[2];
int16 y_2 = g_ChaosCastle_GroundAxis[3];

coord_type tmp_x;
coord_type tmp_y;
int16 tmp_x;
int16 tmp_y;

while ( count-- > 0 )
{
@@ -230,29 +230,29 @@ class ChaosCastleSurvivalScript: public MonsterScriptAI
if ( !grid.IsLocked_2() )
return;

coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

this->GetRandomSafeZone(x, y);
me()->PositionSend(x, y);
me()->ViewportCreate(VIEWPORT_CREATE_FLAG_ME);
}

void GetRandomSafeZone(coord_type &x, coord_type &y)
void GetRandomSafeZone(int16 &x, int16 &y)
{
World* pWorld = me()->GetWorld();

if ( !pWorld )
return;

int32 count = 100;
coord_type x_1 = g_ChaosCastle_GroundAxis[0];
coord_type y_1 = g_ChaosCastle_GroundAxis[1];
coord_type x_2 = g_ChaosCastle_GroundAxis[2];
coord_type y_2 = g_ChaosCastle_GroundAxis[3];
int16 x_1 = g_ChaosCastle_GroundAxis[0];
int16 y_1 = g_ChaosCastle_GroundAxis[1];
int16 x_2 = g_ChaosCastle_GroundAxis[2];
int16 y_2 = g_ChaosCastle_GroundAxis[3];

coord_type tmp_x;
coord_type tmp_y;
int16 tmp_x;
int16 tmp_y;

while ( count-- > 0 )
{
@@ -223,8 +223,8 @@ class BossSummonScript : public MonsterScriptAI

if (distance > 10 && pWorld)
{
coord_type x = this->GetBoss()->GetX();
coord_type y = this->GetBoss()->GetY();
int16 x = this->GetBoss()->GetX();
int16 y = this->GetBoss()->GetY();

pWorld->GetFreeLocation(x, y, 3, 3, 10);

@@ -242,7 +242,7 @@ class BossSummonScript : public MonsterScriptAI
this->SetBoss((Monster*)me()->m_AdditionalDataPtr[0]);
}

bool MoveAllowed(coord_type x, coord_type y)
bool MoveAllowed(int16 x, int16 y)
{
if (!MonsterAI::MoveAllowed(x, y))
return false;
@@ -59,8 +59,8 @@ void DoppelgangerBasicAI::FindPath()
return;
}

coord_type tx = me()->GetX();
coord_type ty = me()->GetY();
int16 tx = me()->GetX();
int16 ty = me()->GetY();

int32 maxmoverange = me()->GetMoveRange() * 2 + 1;

@@ -1,7 +1,7 @@
static const struct FereaZoneData
{
coord_type x;
coord_type y;
int16 x;
int16 y;
} g_FereaZoneData[2] =
{
{ 21, 106 },
@@ -233,8 +233,8 @@ class FereaCrystalOrb: public MonsterScriptAI
{
this->pSupport[i] = pMonster;

coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

pWorld->GetRandomLocation(x, y, 10);

@@ -562,7 +562,7 @@ class FereaBoss: public MonsterScriptAI
return true;
}

bool MoveAllowed(coord_type x, coord_type y)
bool MoveAllowed(int16 x, int16 y)
{
if ( this->GetGeneral() )
{
@@ -608,8 +608,8 @@ class FereaBoss: public MonsterScriptAI
{
this->pSupport[i] = pMonster;

coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

pWorld->GetRandomLocation(x, y, 10);

@@ -744,8 +744,8 @@ class FereaBoss: public MonsterScriptAI
return;
}

coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

if ( me()->GetTarget() )
{
@@ -872,8 +872,8 @@ class FereaBoss: public MonsterScriptAI

if ( this->GetGeneral() )
{
coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

//pWorld->GetRandomLocation(x, y, 3);

@@ -72,7 +72,7 @@ class GuardScript: public MonsterScriptAI

bool ManageThreat() const { return false; }

bool MoveAllowed(coord_type x, coord_type y)
bool MoveAllowed(int16 x, int16 y)
{
World* pWorld = me()->GetWorld();

@@ -191,7 +191,7 @@ class MonsterKillBotScript: public MonsterScriptAI

bool ManageThreat() const { return false; }

bool MoveAllowed(coord_type x, coord_type y)
bool MoveAllowed(int16 x, int16 y)
{
World* pWorld = me()->GetWorld();

@@ -253,7 +253,7 @@ class ImperialMonsterScript: public MonsterScriptAI
pInstance->ReduceMonsterCount(1);
}

bool MoveAllowed(coord_type x, coord_type y)
bool MoveAllowed(int16 x, int16 y)
{
ImperialFortressInstance * pInstance = sImperialFortressMgr->GetInstance(this->GetInstance());

@@ -389,7 +389,7 @@ class ImperialBossScript: public MonsterScriptAI
return true;
}

bool MoveAllowed(coord_type x, coord_type y)
bool MoveAllowed(int16 x, int16 y)
{
ImperialFortressInstance * pInstance = sImperialFortressMgr->GetInstance(this->GetInstance());

@@ -470,8 +470,8 @@ class ImperialBossScript: public MonsterScriptAI

Player* pMaxAttacker = me()->GetMaxAttacker();
Unit* pOwner = pMaxAttacker ? pMaxAttacker->ToUnit(): me()->ToUnit();
coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

for( int32 i = 0; i < count; ++i )
{
@@ -174,7 +174,7 @@ class InvasionScript: public MonsterScriptAI
}
}

bool MoveAllowed(coord_type x, coord_type y)
bool MoveAllowed(int16 x, int16 y)
{
if ( !MonsterAI::MoveAllowed(x, y) )
return false;
@@ -254,8 +254,8 @@ class IllusionKundunScript: public MonsterScriptAI
return;
}

coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

WorldGrid const& attr = me()->GetGrid();

@@ -240,8 +240,8 @@ class KanturuMayaHandScript: public MonsterScriptAI

static const struct NightmareTeleportData
{
coord_type x;
coord_type y;
int16 x;
int16 y;
} NightmareTeleport[MAX_NIGHTMARE_STATE] =
{
{79, 100},
@@ -173,8 +173,8 @@ class MedusaSummonScript: public MonsterScriptAI

if ( distance > 10 && pWorld )
{
coord_type x = this->GetMedusa()->GetX();
coord_type y = this->GetMedusa()->GetY();
int16 x = this->GetMedusa()->GetX();
int16 y = this->GetMedusa()->GetY();

pWorld->GetFreeLocation(x, y, 3, 3, 10);

@@ -192,7 +192,7 @@ class MedusaSummonScript: public MonsterScriptAI
this->SetMedusa((Monster*)me()->m_AdditionalDataPtr[0]);
}

bool MoveAllowed(coord_type x, coord_type y)
bool MoveAllowed(int16 x, int16 y)
{
if ( !MonsterAI::MoveAllowed(x, y) )
return false;
@@ -41,7 +41,7 @@ class MovingNPCScript: public MonsterScriptAI
return false;
}

bool MoveAllowed(coord_type x, coord_type y)
bool MoveAllowed(int16 x, int16 y)
{
return me()->GetWorld()->GetGrid(x, y).IsSummonedMoveAllowed();
}
@@ -104,8 +104,8 @@ class NarsBossCommon: public MonsterAI
{
this->pSupport[i] = pMonster;

coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

pWorld->GetRandomLocation(x, y, 10);

@@ -466,8 +466,8 @@ class NarsBoss: public MonsterScriptAI

if ( this->Summoned[i] )
{
coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

pWorld->GetRandomLocation(x, y, 3);

@@ -121,8 +121,8 @@ struct NixiesCircle
this->SetY(0);
}

DECLARE_ENUM(coord_type, X);
DECLARE_ENUM(coord_type, Y);
DECLARE_ENUM(int16, X);
DECLARE_ENUM(int16, Y);
};

enum
@@ -155,8 +155,8 @@ class NixiesLakeScript: public MonsterScriptAI

DECLARE_BOOL(IceBoom);
DECLARE_STRUCT(TickTimer, IceBoomTime);
DECLARE_ENUM(coord_type, IceBoomX);
DECLARE_ENUM(coord_type, IceBoomY);
DECLARE_ENUM(int16, IceBoomX);
DECLARE_ENUM(int16, IceBoomY);

DECLARE_ENUM(uint16, LastSkill);
DECLARE_STRUCT(TickTimer, LastSkillTime);
@@ -233,7 +233,7 @@ class NixiesLakeScript: public MonsterScriptAI
return false;
}

bool MoveAllowed(coord_type x, coord_type y)
bool MoveAllowed(int16 x, int16 y)
{
if ( this->IsAbsorbKnowledge() )
{
@@ -788,8 +788,8 @@ Use ice lane skill for 3 minutes.

if ( pMonster )
{
coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

pWorld->GetRandomLocation(x, y, 5);

@@ -824,8 +824,8 @@ Use ice lane skill for 3 minutes.

if ( pMonster )
{
coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

pWorld->GetRandomLocation(x, y, 10);

@@ -852,8 +852,8 @@ Use ice lane skill for 3 minutes.

for ( int32 i = 0; i < MAX_NIXIES_LAKE_MAGIC_CIRCLE; ++i )
{
coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

pWorld->GetFreeLocation(x, y, 7, 7, 20);

@@ -17,7 +17,7 @@ bool SummonPlayerAI::MoveAttempt()
return true;
}

bool SummonPlayerAI::MoveAllowed(coord_type x, coord_type y)
bool SummonPlayerAI::MoveAllowed(int16 x, int16 y)
{
return me()->GetWorld()->GetGrid(x, y).IsSummonedMoveAllowed();
}
@@ -7,7 +7,7 @@ struct SummonPlayerAI: public MonsterAI
virtual ~SummonPlayerAI() {}
bool ViewportListAddConditions(Unit* pAdd);
virtual bool MoveAttempt();
virtual bool MoveAllowed(coord_type x, coord_type y);
virtual bool MoveAllowed(int16 x, int16 y);
virtual bool SearchEnemy();
virtual void OnDie();
bool ManageThreat() const { return false; }
@@ -352,8 +352,8 @@ class SwampOfDarknessMonsterScript : public MonsterScriptAI

if (pMonster)
{
coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

pWorld->GetRandomLocation(x, y, 15);

@@ -80,7 +80,7 @@ class TrapScript: public MonsterScriptAI
{
Object * pObject = nullptr;
me()->SetTarget(nullptr);
coord_type pos = me()->GetX();
int16 pos = me()->GetX();
int32 count = me()->GetAttackRange() + 1;

for( int32 n = 0; n < count; ++n )
@@ -109,7 +109,7 @@ class TrapScript: public MonsterScriptAI
{
Object * pObject = nullptr;
me()->SetTarget(nullptr);
coord_type pos = me()->GetY();
int16 pos = me()->GetY();
int32 count = me()->GetAttackRange() + 1;

for( int32 n = 0; n < count; ++n )
@@ -329,8 +329,8 @@ class UrukMountainBoss: public MonsterScriptAI
{
this->pSupport[i] = pMonster;

coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

pWorld->GetRandomLocation(x, y, 10);

@@ -485,8 +485,8 @@ class UrukMountainBoss: public MonsterScriptAI

if ( this->Summoned[i] )
{
coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

pWorld->GetRandomLocation(x, y, 3);

@@ -366,8 +366,8 @@ class WorldBossScript: public MonsterScriptAI
return;
}

coord_type x = me()->GetX();
coord_type y = me()->GetY();
int16 x = me()->GetX();
int16 y = me()->GetY();

if ( pWorld->GetFreeLocation(x, y, 4, 4, 10) )
{
@@ -45,7 +45,7 @@ void CServerList::LoadWorldServer()
Field* fields = result->Fetch();

uint16 server = fields[0].GetUInt16();
world_type world = fields[1].GetUInt16();
uint16 world = fields[1].GetUInt16();

this->world_server_map[server].insert(world);

@@ -109,7 +109,7 @@ bool CServerList::IsServerOnlineAndFree(uint16 server)
return data.GetPercent() < 100;
}

bool CServerList::IsWorldInList(world_type world, uint16 server_group)
bool CServerList::IsWorldInList(uint16 world, uint16 server_group)
{
for ( WorldServerMap::const_iterator itr = this->world_server_map.begin(); itr != this->world_server_map.end(); ++itr )
{
@@ -125,7 +125,7 @@ bool CServerList::IsWorldInList(world_type world, uint16 server_group)
return false;
}

uint16 CServerList::CheckDestServer(uint16 server_group, world_type world, uint16 server, uint16 start_server)
uint16 CServerList::CheckDestServer(uint16 server_group, uint16 world, uint16 server, uint16 start_server)
{
bool is_in_list = this->IsWorldInList(world, server_group);

@@ -21,7 +21,7 @@ struct SERVER_INFO_REQUEST
uint16 server_code;
};

typedef std::set<world_type> WorldServerList;
typedef std::set<uint16> WorldServerList;
typedef std::map<uint16, WorldServerList> WorldServerMap;

struct ServerData
@@ -55,7 +55,7 @@ class CServerList
virtual ~CServerList();

bool IsServerOnlineAndFree(uint16 server);
bool IsWorldInList(world_type world, uint16 server_group);
bool IsWorldInList(uint16 world, uint16 server_group);

void Initialize(uint32 updateInterval);
void LoadWorldServer();
@@ -65,7 +65,7 @@ class CServerList
void ServerClose(uint16 server);
void ServerSetInfo(uint16 server, uint8 percent, uint8 flag, uint8 type);

uint16 CheckDestServer(uint16 server_group, world_type world, uint16 server, uint16 start_server);
uint16 CheckDestServer(uint16 server_group, uint16 world, uint16 server, uint16 start_server);

uint32 m_UpdateInterval;
time_t m_NextUpdateTime;
@@ -28,9 +28,9 @@ struct CharacterCreateData
int32 mana;
uint32 points;
uint32 level;
world_type world;
coord_type x;
coord_type y;
uint16 world;
int16 x;
int16 y;
uint8 slot;
std::shared_ptr<ServerSocket> socket;