More refactoring of code.
This commit is contained in:
@@ -73,7 +73,7 @@ namespace Game.Maps
|
||||
return (offX * offX) + (offY * offY);
|
||||
}
|
||||
|
||||
public Position sync()
|
||||
public Position Sync()
|
||||
{
|
||||
posX = (float)d_positionX;
|
||||
posY = (float)d_positionY;
|
||||
|
||||
+21
-21
@@ -25,19 +25,19 @@ namespace Game.Maps
|
||||
{
|
||||
public Cell(ICoord p)
|
||||
{
|
||||
data.grid_x = p.x_coord / MapConst.MaxCells;
|
||||
data.grid_y = p.y_coord / MapConst.MaxCells;
|
||||
data.cell_x = p.x_coord % MapConst.MaxCells;
|
||||
data.cell_y = p.y_coord % MapConst.MaxCells;
|
||||
data.grid_x = p.X_coord / MapConst.MaxCells;
|
||||
data.grid_y = p.Y_coord / MapConst.MaxCells;
|
||||
data.cell_x = p.X_coord % MapConst.MaxCells;
|
||||
data.cell_y = p.Y_coord % MapConst.MaxCells;
|
||||
}
|
||||
|
||||
public Cell(float x, float y)
|
||||
{
|
||||
ICoord p = GridDefines.ComputeCellCoord(x, y);
|
||||
data.grid_x = p.x_coord / MapConst.MaxCells;
|
||||
data.grid_y = p.y_coord / MapConst.MaxCells;
|
||||
data.cell_x = p.x_coord % MapConst.MaxCells;
|
||||
data.cell_y = p.y_coord % MapConst.MaxCells;
|
||||
data.grid_x = p.X_coord / MapConst.MaxCells;
|
||||
data.grid_y = p.Y_coord / MapConst.MaxCells;
|
||||
data.cell_x = p.X_coord % MapConst.MaxCells;
|
||||
data.cell_y = p.Y_coord % MapConst.MaxCells;
|
||||
}
|
||||
|
||||
public Cell(Cell cell) { data = cell.data; }
|
||||
@@ -153,7 +153,7 @@ namespace Game.Maps
|
||||
//if radius is known to reach cell area more than 4x4 then we should call optimized VisitCircle
|
||||
//currently this technique works with MAX_NUMBER_OF_CELLS 16 and higher, with lower values
|
||||
//there are nothing to optimize because SIZE_OF_GRID_CELL is too big...
|
||||
if ((area.high_bound.x_coord > (area.low_bound.x_coord + 4)) && (area.high_bound.y_coord > (area.low_bound.y_coord + 4)))
|
||||
if ((area.high_bound.X_coord > (area.low_bound.X_coord + 4)) && (area.high_bound.Y_coord > (area.low_bound.Y_coord + 4)))
|
||||
{
|
||||
VisitCircle(visitor, map, area.low_bound, area.high_bound);
|
||||
return;
|
||||
@@ -164,9 +164,9 @@ namespace Game.Maps
|
||||
map.Visit(this, visitor);
|
||||
|
||||
// loop the cell range
|
||||
for (uint x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
|
||||
for (uint x = area.low_bound.X_coord; x <= area.high_bound.X_coord; ++x)
|
||||
{
|
||||
for (uint y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
|
||||
for (uint y = area.low_bound.Y_coord; y <= area.high_bound.Y_coord; ++y)
|
||||
{
|
||||
CellCoord cellCoord = new CellCoord(x, y);
|
||||
//lets skip standing cell since we already visited it
|
||||
@@ -183,15 +183,15 @@ namespace Game.Maps
|
||||
void VisitCircle(Visitor visitor, Map map, ICoord begin_cell, ICoord end_cell)
|
||||
{
|
||||
//here is an algorithm for 'filling' circum-squared octagon
|
||||
uint x_shift = (uint)Math.Ceiling((end_cell.x_coord - begin_cell.x_coord) * 0.3f - 0.5f);
|
||||
uint x_shift = (uint)Math.Ceiling((end_cell.X_coord - begin_cell.X_coord) * 0.3f - 0.5f);
|
||||
//lets calculate x_start/x_end coords for central strip...
|
||||
uint x_start = begin_cell.x_coord + x_shift;
|
||||
uint x_end = end_cell.x_coord - x_shift;
|
||||
uint x_start = begin_cell.X_coord + x_shift;
|
||||
uint x_end = end_cell.X_coord - x_shift;
|
||||
|
||||
//visit central strip with constant width...
|
||||
for (uint x = x_start; x <= x_end; ++x)
|
||||
{
|
||||
for (uint y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
|
||||
for (uint y = begin_cell.Y_coord; y <= end_cell.Y_coord; ++y)
|
||||
{
|
||||
CellCoord cellCoord = new CellCoord(x, y);
|
||||
Cell r_zone = new Cell(cellCoord);
|
||||
@@ -205,10 +205,10 @@ namespace Game.Maps
|
||||
if (x_shift == 0)
|
||||
return;
|
||||
|
||||
uint y_start = end_cell.y_coord;
|
||||
uint y_end = begin_cell.y_coord;
|
||||
uint y_start = end_cell.Y_coord;
|
||||
uint y_end = begin_cell.Y_coord;
|
||||
//now we are visiting borders of an octagon...
|
||||
for (uint step = 1; step <= (x_start - begin_cell.x_coord); ++step)
|
||||
for (uint step = 1; step <= (x_start - begin_cell.X_coord); ++step)
|
||||
{
|
||||
//each step reduces strip height by 2 cells...
|
||||
y_end += 1;
|
||||
@@ -305,12 +305,12 @@ namespace Game.Maps
|
||||
{
|
||||
if (radius <= 0.0f)
|
||||
{
|
||||
CellCoord center = (CellCoord)GridDefines.ComputeCellCoord(x, y).normalize();
|
||||
CellCoord center = (CellCoord)GridDefines.ComputeCellCoord(x, y).Normalize();
|
||||
return new CellArea(center, center);
|
||||
}
|
||||
|
||||
CellCoord centerX = (CellCoord)GridDefines.ComputeCellCoord(x - radius, y - radius).normalize();
|
||||
CellCoord centerY = (CellCoord)GridDefines.ComputeCellCoord(x + radius, y + radius).normalize();
|
||||
CellCoord centerX = (CellCoord)GridDefines.ComputeCellCoord(x - radius, y - radius).Normalize();
|
||||
CellCoord centerY = (CellCoord)GridDefines.ComputeCellCoord(x + radius, y + radius).Normalize();
|
||||
|
||||
return new CellArea(centerX, centerY);
|
||||
}
|
||||
|
||||
+30
-30
@@ -39,32 +39,32 @@ namespace Game.Maps
|
||||
i_unloadExplicitLock = !unload;
|
||||
}
|
||||
|
||||
public TimeTracker getTimeTracker()
|
||||
public TimeTracker GetTimeTracker()
|
||||
{
|
||||
return i_timer;
|
||||
}
|
||||
|
||||
public bool getUnloadLock()
|
||||
public bool GetUnloadLock()
|
||||
{
|
||||
return i_unloadActiveLockCount != 0 || i_unloadExplicitLock;
|
||||
}
|
||||
|
||||
public void setUnloadExplicitLock(bool on)
|
||||
public void SetUnloadExplicitLock(bool on)
|
||||
{
|
||||
i_unloadExplicitLock = on;
|
||||
}
|
||||
|
||||
public void incUnloadActiveLock()
|
||||
public void IncUnloadActiveLock()
|
||||
{
|
||||
++i_unloadActiveLockCount;
|
||||
}
|
||||
|
||||
public void decUnloadActiveLock()
|
||||
public void DecUnloadActiveLock()
|
||||
{
|
||||
if (i_unloadActiveLockCount != 0) --i_unloadActiveLockCount;
|
||||
}
|
||||
|
||||
private void setTimer(TimeTracker pTimer)
|
||||
private void SetTimer(TimeTracker pTimer)
|
||||
{
|
||||
i_timer = pTimer;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ namespace Game.Maps
|
||||
i_timer.Update(diff);
|
||||
}
|
||||
|
||||
public PeriodicTimer getRelocationTimer()
|
||||
public PeriodicTimer GetRelocationTimer()
|
||||
{
|
||||
return vis_Update;
|
||||
}
|
||||
@@ -137,54 +137,54 @@ namespace Game.Maps
|
||||
gridState = s;
|
||||
}
|
||||
|
||||
public uint getX()
|
||||
public uint GetX()
|
||||
{
|
||||
return gridX;
|
||||
}
|
||||
|
||||
public uint getY()
|
||||
public uint GetY()
|
||||
{
|
||||
return gridY;
|
||||
}
|
||||
|
||||
public bool isGridObjectDataLoaded()
|
||||
public bool IsGridObjectDataLoaded()
|
||||
{
|
||||
return gridObjectDataLoaded;
|
||||
}
|
||||
|
||||
public void setGridObjectDataLoaded(bool pLoaded)
|
||||
public void SetGridObjectDataLoaded(bool pLoaded)
|
||||
{
|
||||
gridObjectDataLoaded = pLoaded;
|
||||
}
|
||||
|
||||
public GridInfo getGridInfoRef()
|
||||
public GridInfo GetGridInfoRef()
|
||||
{
|
||||
return gridInfo;
|
||||
}
|
||||
|
||||
private TimeTracker getTimeTracker()
|
||||
private TimeTracker GetTimeTracker()
|
||||
{
|
||||
return gridInfo.getTimeTracker();
|
||||
return gridInfo.GetTimeTracker();
|
||||
}
|
||||
|
||||
public bool getUnloadLock()
|
||||
public bool GetUnloadLock()
|
||||
{
|
||||
return gridInfo.getUnloadLock();
|
||||
return gridInfo.GetUnloadLock();
|
||||
}
|
||||
|
||||
public void setUnloadExplicitLock(bool on)
|
||||
public void SetUnloadExplicitLock(bool on)
|
||||
{
|
||||
gridInfo.setUnloadExplicitLock(on);
|
||||
gridInfo.SetUnloadExplicitLock(on);
|
||||
}
|
||||
|
||||
public void incUnloadActiveLock()
|
||||
public void IncUnloadActiveLock()
|
||||
{
|
||||
gridInfo.incUnloadActiveLock();
|
||||
gridInfo.IncUnloadActiveLock();
|
||||
}
|
||||
|
||||
public void decUnloadActiveLock()
|
||||
public void DecUnloadActiveLock()
|
||||
{
|
||||
gridInfo.decUnloadActiveLock();
|
||||
gridInfo.DecUnloadActiveLock();
|
||||
}
|
||||
|
||||
public void ResetTimeTracker(long interval)
|
||||
@@ -203,8 +203,8 @@ namespace Game.Maps
|
||||
{
|
||||
case GridState.Active:
|
||||
// Only check grid activity every (grid_expiry/10) ms, because it's really useless to do it every cycle
|
||||
getGridInfoRef().UpdateTimeTracker(diff);
|
||||
if (getGridInfoRef().getTimeTracker().Passed())
|
||||
GetGridInfoRef().UpdateTimeTracker(diff);
|
||||
if (GetGridInfoRef().GetTimeTracker().Passed())
|
||||
{
|
||||
if (GetWorldObjectCountInNGrid<Player>() == 0 && !map.ActiveObjectsNearGrid(this))
|
||||
{
|
||||
@@ -212,7 +212,7 @@ namespace Game.Maps
|
||||
var visitor = new Visitor(worker, GridMapTypeMask.AllGrid);
|
||||
VisitAllGrids(visitor);
|
||||
SetGridState(GridState.Idle);
|
||||
Log.outDebug(LogFilter.Maps, "Grid[{0}, {1}] on map {2} moved to IDLE state", getX(), getY(),
|
||||
Log.outDebug(LogFilter.Maps, "Grid[{0}, {1}] on map {2} moved to IDLE state", GetX(), GetY(),
|
||||
map.GetId());
|
||||
}
|
||||
else
|
||||
@@ -222,20 +222,20 @@ namespace Game.Maps
|
||||
case GridState.Idle:
|
||||
map.ResetGridExpiry(this);
|
||||
SetGridState(GridState.Removal);
|
||||
Log.outDebug(LogFilter.Maps, "Grid[{0}, {1}] on map {2} moved to REMOVAL state", getX(), getY(),
|
||||
Log.outDebug(LogFilter.Maps, "Grid[{0}, {1}] on map {2} moved to REMOVAL state", GetX(), GetY(),
|
||||
map.GetId());
|
||||
break;
|
||||
case GridState.Removal:
|
||||
if (!getGridInfoRef().getUnloadLock())
|
||||
if (!GetGridInfoRef().GetUnloadLock())
|
||||
{
|
||||
getGridInfoRef().UpdateTimeTracker(diff);
|
||||
if (getGridInfoRef().getTimeTracker().Passed())
|
||||
GetGridInfoRef().UpdateTimeTracker(diff);
|
||||
if (GetGridInfoRef().GetTimeTracker().Passed())
|
||||
{
|
||||
if (!map.UnloadGrid(this, false))
|
||||
{
|
||||
Log.outDebug(LogFilter.Maps,
|
||||
"Grid[{0}, {1}] for map {2} differed unloading due to players or active objects nearby",
|
||||
getX(), getY(), map.GetId());
|
||||
GetX(), GetY(), map.GetId());
|
||||
map.ResetGridExpiry(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,63 +98,63 @@ namespace Game.Maps
|
||||
|
||||
public CellCoord(uint x, uint y)
|
||||
{
|
||||
x_coord = x;
|
||||
y_coord = y;
|
||||
X_coord = x;
|
||||
Y_coord = y;
|
||||
}
|
||||
public CellCoord(CellCoord obj)
|
||||
{
|
||||
x_coord = obj.x_coord;
|
||||
y_coord = obj.y_coord;
|
||||
X_coord = obj.X_coord;
|
||||
Y_coord = obj.Y_coord;
|
||||
}
|
||||
|
||||
public bool IsCoordValid()
|
||||
{
|
||||
return x_coord < Limit && y_coord < Limit;
|
||||
return X_coord < Limit && Y_coord < Limit;
|
||||
}
|
||||
public ICoord normalize()
|
||||
public ICoord Normalize()
|
||||
{
|
||||
x_coord = Math.Min(x_coord, Limit - 1);
|
||||
y_coord = Math.Min(y_coord, Limit - 1);
|
||||
X_coord = Math.Min(X_coord, Limit - 1);
|
||||
Y_coord = Math.Min(Y_coord, Limit - 1);
|
||||
return this;
|
||||
}
|
||||
public uint GetId()
|
||||
{
|
||||
return y_coord * Limit + x_coord;
|
||||
return Y_coord * Limit + X_coord;
|
||||
}
|
||||
|
||||
public void dec_x(uint val)
|
||||
public void Dec_x(uint val)
|
||||
{
|
||||
if (x_coord > val)
|
||||
x_coord -= val;
|
||||
if (X_coord > val)
|
||||
X_coord -= val;
|
||||
else
|
||||
x_coord = 0;
|
||||
X_coord = 0;
|
||||
}
|
||||
public void inc_x(uint val)
|
||||
public void Inc_x(uint val)
|
||||
{
|
||||
if (x_coord + val < Limit)
|
||||
x_coord += val;
|
||||
if (X_coord + val < Limit)
|
||||
X_coord += val;
|
||||
else
|
||||
x_coord = Limit - 1;
|
||||
X_coord = Limit - 1;
|
||||
}
|
||||
|
||||
public void dec_y(uint val)
|
||||
public void Dec_y(uint val)
|
||||
{
|
||||
if (y_coord > val)
|
||||
y_coord -= val;
|
||||
if (Y_coord > val)
|
||||
Y_coord -= val;
|
||||
else
|
||||
y_coord = 0;
|
||||
Y_coord = 0;
|
||||
}
|
||||
public void inc_y(uint val)
|
||||
public void Inc_y(uint val)
|
||||
{
|
||||
if (y_coord + val < Limit)
|
||||
y_coord += val;
|
||||
if (Y_coord + val < Limit)
|
||||
Y_coord += val;
|
||||
else
|
||||
y_coord = Limit - 1;
|
||||
Y_coord = Limit - 1;
|
||||
}
|
||||
|
||||
public static bool operator ==(CellCoord p1, CellCoord p2)
|
||||
{
|
||||
return (p1.x_coord == p2.x_coord && p1.y_coord == p2.y_coord);
|
||||
return (p1.X_coord == p2.X_coord && p1.Y_coord == p2.Y_coord);
|
||||
}
|
||||
|
||||
public static bool operator !=(CellCoord p1, CellCoord p2)
|
||||
@@ -172,11 +172,11 @@ namespace Game.Maps
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return x_coord.GetHashCode() ^ y_coord.GetHashCode();
|
||||
return X_coord.GetHashCode() ^ Y_coord.GetHashCode();
|
||||
}
|
||||
|
||||
public uint x_coord { get; set; }
|
||||
public uint y_coord { get; set; }
|
||||
public uint X_coord { get; set; }
|
||||
public uint Y_coord { get; set; }
|
||||
}
|
||||
|
||||
public class GridCoord : ICoord
|
||||
@@ -185,58 +185,58 @@ namespace Game.Maps
|
||||
|
||||
public GridCoord(uint x, uint y)
|
||||
{
|
||||
x_coord = x;
|
||||
y_coord = y;
|
||||
X_coord = x;
|
||||
Y_coord = y;
|
||||
}
|
||||
public GridCoord(GridCoord obj)
|
||||
{
|
||||
x_coord = obj.x_coord;
|
||||
y_coord = obj.y_coord;
|
||||
X_coord = obj.X_coord;
|
||||
Y_coord = obj.Y_coord;
|
||||
}
|
||||
|
||||
public bool IsCoordValid()
|
||||
{
|
||||
return x_coord < Limit && y_coord < Limit;
|
||||
return X_coord < Limit && Y_coord < Limit;
|
||||
}
|
||||
public ICoord normalize()
|
||||
public ICoord Normalize()
|
||||
{
|
||||
x_coord = Math.Min(x_coord, Limit - 1);
|
||||
y_coord = Math.Min(y_coord, Limit - 1);
|
||||
X_coord = Math.Min(X_coord, Limit - 1);
|
||||
Y_coord = Math.Min(Y_coord, Limit - 1);
|
||||
return this;
|
||||
}
|
||||
public uint GetId()
|
||||
{
|
||||
return y_coord * Limit + x_coord;
|
||||
return Y_coord * Limit + X_coord;
|
||||
}
|
||||
|
||||
public void dec_x(uint val)
|
||||
public void Dec_x(uint val)
|
||||
{
|
||||
if (x_coord > val)
|
||||
x_coord -= val;
|
||||
if (X_coord > val)
|
||||
X_coord -= val;
|
||||
else
|
||||
x_coord = 0;
|
||||
X_coord = 0;
|
||||
}
|
||||
public void inc_x(uint val)
|
||||
public void Inc_x(uint val)
|
||||
{
|
||||
if (x_coord + val < Limit)
|
||||
x_coord += val;
|
||||
if (X_coord + val < Limit)
|
||||
X_coord += val;
|
||||
else
|
||||
x_coord = Limit - 1;
|
||||
X_coord = Limit - 1;
|
||||
}
|
||||
|
||||
public void dec_y(uint val)
|
||||
public void Dec_y(uint val)
|
||||
{
|
||||
if (y_coord > val)
|
||||
y_coord -= val;
|
||||
if (Y_coord > val)
|
||||
Y_coord -= val;
|
||||
else
|
||||
y_coord = 0;
|
||||
Y_coord = 0;
|
||||
}
|
||||
public void inc_y(uint val)
|
||||
public void Inc_y(uint val)
|
||||
{
|
||||
if (y_coord + val < Limit)
|
||||
y_coord += val;
|
||||
if (Y_coord + val < Limit)
|
||||
Y_coord += val;
|
||||
else
|
||||
y_coord = Limit - 1;
|
||||
Y_coord = Limit - 1;
|
||||
}
|
||||
|
||||
public static bool operator ==(GridCoord first, GridCoord other)
|
||||
@@ -244,7 +244,7 @@ namespace Game.Maps
|
||||
if (ReferenceEquals(first, other))
|
||||
return true;
|
||||
|
||||
if ((object)first == null || (object)other == null)
|
||||
if (ReferenceEquals(first, null) || ReferenceEquals(other, null))
|
||||
return false;
|
||||
|
||||
return first.Equals(other);
|
||||
@@ -262,30 +262,30 @@ namespace Game.Maps
|
||||
|
||||
public bool Equals(GridCoord other)
|
||||
{
|
||||
return other.x_coord == x_coord && other.y_coord == y_coord;
|
||||
return other.X_coord == X_coord && other.Y_coord == Y_coord;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return new { x_coord, y_coord }.GetHashCode();
|
||||
return new { X_coord, Y_coord }.GetHashCode();
|
||||
}
|
||||
|
||||
|
||||
public uint x_coord { get; set; }
|
||||
public uint y_coord { get; set; }
|
||||
public uint X_coord { get; set; }
|
||||
public uint Y_coord { get; set; }
|
||||
}
|
||||
|
||||
public interface ICoord
|
||||
{
|
||||
bool IsCoordValid();
|
||||
ICoord normalize();
|
||||
ICoord Normalize();
|
||||
uint GetId();
|
||||
void dec_x(uint val);
|
||||
void inc_x(uint val);
|
||||
void dec_y(uint val);
|
||||
void inc_y(uint val);
|
||||
void Dec_x(uint val);
|
||||
void Inc_x(uint val);
|
||||
void Dec_y(uint val);
|
||||
void Inc_y(uint val);
|
||||
|
||||
uint x_coord { get; set; }
|
||||
uint y_coord { get; set; }
|
||||
uint X_coord { get; set; }
|
||||
uint Y_coord { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
+34
-34
@@ -30,22 +30,22 @@ namespace Game.Maps
|
||||
{
|
||||
// Height level data
|
||||
_gridHeight = MapConst.InvalidHeight;
|
||||
_gridGetHeight = getHeightFromFlat;
|
||||
_gridGetHeight = GetHeightFromFlat;
|
||||
|
||||
// Liquid data
|
||||
_liquidLevel = MapConst.InvalidHeight;
|
||||
}
|
||||
|
||||
public bool loadData(string filename)
|
||||
public bool LoadData(string filename)
|
||||
{
|
||||
unloadData();
|
||||
UnloadData();
|
||||
if (!File.Exists(filename))
|
||||
return true;
|
||||
|
||||
_fileExists = true;
|
||||
using (BinaryReader reader = new BinaryReader(new FileStream(filename, FileMode.Open, FileAccess.Read)))
|
||||
{
|
||||
mapFileHeader header = reader.Read<mapFileHeader>();
|
||||
MapFileHeader header = reader.Read<MapFileHeader>();
|
||||
if (header.mapMagic != MapConst.MapMagic || header.versionMagic != MapConst.MapVersionMagic)
|
||||
{
|
||||
Log.outError(LogFilter.Maps, $"Map file '{filename}' is from an incompatible map version. Please recreate using the mapextractor.");
|
||||
@@ -74,7 +74,7 @@ namespace Game.Maps
|
||||
}
|
||||
}
|
||||
|
||||
public void unloadData()
|
||||
public void UnloadData()
|
||||
{
|
||||
_areaMap = null;
|
||||
m_V9 = null;
|
||||
@@ -82,14 +82,14 @@ namespace Game.Maps
|
||||
_liquidEntry = null;
|
||||
_liquidFlags = null;
|
||||
_liquidMap = null;
|
||||
_gridGetHeight = getHeightFromFlat;
|
||||
_gridGetHeight = GetHeightFromFlat;
|
||||
_fileExists = false;
|
||||
}
|
||||
|
||||
bool LoadAreaData(BinaryReader reader, uint offset)
|
||||
{
|
||||
reader.BaseStream.Seek(offset, SeekOrigin.Begin);
|
||||
map_AreaHeader areaHeader = reader.Read<map_AreaHeader>();
|
||||
MapAreaHeader areaHeader = reader.Read<MapAreaHeader>();
|
||||
if (areaHeader.fourcc != MapConst.MapAreaMagic)
|
||||
return false;
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Game.Maps
|
||||
bool LoadHeightData(BinaryReader reader, uint offset)
|
||||
{
|
||||
reader.BaseStream.Seek(offset, SeekOrigin.Begin);
|
||||
map_HeightHeader mapHeader = reader.Read<map_HeightHeader>();
|
||||
MapHeightHeader mapHeader = reader.Read<MapHeightHeader>();
|
||||
|
||||
if (mapHeader.fourcc != MapConst.MapHeightMagic)
|
||||
return false;
|
||||
@@ -120,25 +120,25 @@ namespace Game.Maps
|
||||
m_uint16_V8 = reader.ReadArray<ushort>(128 * 128);
|
||||
|
||||
_gridIntHeightMultiplier = (mapHeader.gridMaxHeight - mapHeader.gridHeight) / 65535;
|
||||
_gridGetHeight = getHeightFromUint16;
|
||||
_gridGetHeight = GetHeightFromUint16;
|
||||
}
|
||||
else if (mapHeader.flags.HasAnyFlag(HeightHeaderFlags.HeightAsInt8))
|
||||
{
|
||||
m_ubyte_V9 = reader.ReadBytes(129 * 129);
|
||||
m_ubyte_V8 = reader.ReadBytes(128 * 128);
|
||||
_gridIntHeightMultiplier = (mapHeader.gridMaxHeight - mapHeader.gridHeight) / 255;
|
||||
_gridGetHeight = getHeightFromUint8;
|
||||
_gridGetHeight = GetHeightFromUint8;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_V9 = reader.ReadArray<float>(129 * 129);
|
||||
m_V8 = reader.ReadArray<float>(128 * 128);
|
||||
|
||||
_gridGetHeight = getHeightFromFloat;
|
||||
_gridGetHeight = GetHeightFromFloat;
|
||||
}
|
||||
}
|
||||
else
|
||||
_gridGetHeight = getHeightFromFlat;
|
||||
_gridGetHeight = GetHeightFromFlat;
|
||||
|
||||
if (mapHeader.flags.HasAnyFlag(HeightHeaderFlags.HeightHasFlightBounds))
|
||||
{
|
||||
@@ -185,7 +185,7 @@ namespace Game.Maps
|
||||
bool LoadLiquidData(BinaryReader reader, uint offset)
|
||||
{
|
||||
reader.BaseStream.Seek(offset, SeekOrigin.Begin);
|
||||
map_LiquidHeader liquidHeader = reader.Read<map_LiquidHeader>();
|
||||
MapLiquidHeader liquidHeader = reader.Read<MapLiquidHeader>();
|
||||
|
||||
if (liquidHeader.fourcc != MapConst.MapLiquidMagic)
|
||||
return false;
|
||||
@@ -210,7 +210,7 @@ namespace Game.Maps
|
||||
return true;
|
||||
}
|
||||
|
||||
public ushort getArea(float x, float y)
|
||||
public ushort GetArea(float x, float y)
|
||||
{
|
||||
if (_areaMap == null)
|
||||
return _gridArea;
|
||||
@@ -222,12 +222,12 @@ namespace Game.Maps
|
||||
return _areaMap[lx * 16 + ly];
|
||||
}
|
||||
|
||||
float getHeightFromFlat(float x, float y)
|
||||
float GetHeightFromFlat(float x, float y)
|
||||
{
|
||||
return _gridHeight;
|
||||
}
|
||||
|
||||
float getHeightFromFloat(float x, float y)
|
||||
float GetHeightFromFloat(float x, float y)
|
||||
{
|
||||
if (m_uint16_V8 == null || m_uint16_V9 == null)
|
||||
return _gridHeight;
|
||||
@@ -293,7 +293,7 @@ namespace Game.Maps
|
||||
return a * x + b * y + c;
|
||||
}
|
||||
|
||||
float getHeightFromUint8(float x, float y)
|
||||
float GetHeightFromUint8(float x, float y)
|
||||
{
|
||||
if (m_ubyte_V8 == null || m_ubyte_V9 == null)
|
||||
return _gridHeight;
|
||||
@@ -366,7 +366,7 @@ namespace Game.Maps
|
||||
}
|
||||
}
|
||||
|
||||
float getHeightFromUint16(float x, float y)
|
||||
float GetHeightFromUint16(float x, float y)
|
||||
{
|
||||
if (m_uint16_V8 == null || m_uint16_V9 == null)
|
||||
return _gridHeight;
|
||||
@@ -438,7 +438,7 @@ namespace Game.Maps
|
||||
}
|
||||
}
|
||||
|
||||
public float getMinHeight(float x, float y)
|
||||
public float GetMinHeight(float x, float y)
|
||||
{
|
||||
if (_minHeightPlanes == null)
|
||||
return -500.0f;
|
||||
@@ -448,8 +448,8 @@ namespace Game.Maps
|
||||
int doubleGridX = (int)(Math.Floor(-(x - MapConst.MapHalfSize) / MapConst.CenterGridOffset));
|
||||
int doubleGridY = (int)(Math.Floor(-(y - MapConst.MapHalfSize) / MapConst.CenterGridOffset));
|
||||
|
||||
float gx = x - ((int)gridCoord.x_coord - MapConst.CenterGridId + 1) * MapConst.SizeofGrids;
|
||||
float gy = y - ((int)gridCoord.y_coord - MapConst.CenterGridId + 1) * MapConst.SizeofGrids;
|
||||
float gx = x - ((int)gridCoord.X_coord - MapConst.CenterGridId + 1) * MapConst.SizeofGrids;
|
||||
float gy = y - ((int)gridCoord.Y_coord - MapConst.CenterGridId + 1) * MapConst.SizeofGrids;
|
||||
|
||||
uint quarterIndex = 0;
|
||||
if (Convert.ToBoolean(doubleGridY & 1))
|
||||
@@ -469,7 +469,7 @@ namespace Game.Maps
|
||||
return ray.intersection(_minHeightPlanes[quarterIndex]).Z;
|
||||
}
|
||||
|
||||
public float getLiquidLevel(float x, float y)
|
||||
public float GetLiquidLevel(float x, float y)
|
||||
{
|
||||
if (_liquidMap == null)
|
||||
return _liquidLevel;
|
||||
@@ -489,7 +489,7 @@ namespace Game.Maps
|
||||
}
|
||||
|
||||
// Why does this return LIQUID data?
|
||||
public byte getTerrainType(float x, float y)
|
||||
public byte GetTerrainType(float x, float y)
|
||||
{
|
||||
if (_liquidFlags == null)
|
||||
return 0;
|
||||
@@ -502,7 +502,7 @@ namespace Game.Maps
|
||||
}
|
||||
|
||||
// Get water state on map
|
||||
public ZLiquidStatus getLiquidStatus(float x, float y, float z, uint ReqLiquidType, LiquidData data)
|
||||
public ZLiquidStatus GetLiquidStatus(float x, float y, float z, uint ReqLiquidType, LiquidData data)
|
||||
{
|
||||
// Check water type (if no water return)
|
||||
if (_liquidGlobalFlags == 0 && _liquidFlags == null)
|
||||
@@ -526,7 +526,7 @@ namespace Game.Maps
|
||||
uint liqTypeIdx = liquidEntry.SoundBank;
|
||||
if (entry < 21)
|
||||
{
|
||||
var area = CliDB.AreaTableStorage.LookupByKey(getArea(x, y));
|
||||
var area = CliDB.AreaTableStorage.LookupByKey(GetArea(x, y));
|
||||
if (area != null)
|
||||
{
|
||||
uint overrideLiquid = area.LiquidTypeID[liquidEntry.SoundBank];
|
||||
@@ -566,7 +566,7 @@ namespace Game.Maps
|
||||
// Get water level
|
||||
float liquid_level = _liquidMap != null ? _liquidMap[lx_int * _liquidWidth + ly_int] : _liquidLevel;
|
||||
// Get ground level (sub 0.2 for fix some errors)
|
||||
float ground_level = getHeight(x, y);
|
||||
float ground_level = GetHeight(x, y);
|
||||
|
||||
// Check water level and ground level
|
||||
if (liquid_level < ground_level || z < ground_level - 2)
|
||||
@@ -594,14 +594,14 @@ namespace Game.Maps
|
||||
return ZLiquidStatus.AboveWater;
|
||||
}
|
||||
|
||||
public float getHeight(float x, float y) { return _gridGetHeight(x, y); }
|
||||
public float GetHeight(float x, float y) { return _gridGetHeight(x, y); }
|
||||
|
||||
public bool fileExists() { return _fileExists; }
|
||||
public bool GileExists() { return _fileExists; }
|
||||
|
||||
#region Fields
|
||||
delegate float GetHeight(float x, float y);
|
||||
delegate float GetHeightDel(float x, float y);
|
||||
|
||||
GetHeight _gridGetHeight;
|
||||
GetHeightDel _gridGetHeight;
|
||||
uint _flags;
|
||||
|
||||
public float[] m_V9;
|
||||
@@ -634,7 +634,7 @@ namespace Game.Maps
|
||||
#endregion
|
||||
}
|
||||
|
||||
public struct mapFileHeader
|
||||
public struct MapFileHeader
|
||||
{
|
||||
public uint mapMagic;
|
||||
public uint versionMagic;
|
||||
@@ -649,14 +649,14 @@ namespace Game.Maps
|
||||
public uint holesSize;
|
||||
}
|
||||
|
||||
public struct map_AreaHeader
|
||||
public struct MapAreaHeader
|
||||
{
|
||||
public uint fourcc;
|
||||
public AreaHeaderFlags flags;
|
||||
public ushort gridArea;
|
||||
}
|
||||
|
||||
public struct map_HeightHeader
|
||||
public struct MapHeightHeader
|
||||
{
|
||||
public uint fourcc;
|
||||
public HeightHeaderFlags flags;
|
||||
@@ -664,7 +664,7 @@ namespace Game.Maps
|
||||
public float gridMaxHeight;
|
||||
}
|
||||
|
||||
public struct map_LiquidHeader
|
||||
public struct MapLiquidHeader
|
||||
{
|
||||
public uint fourcc;
|
||||
public LiquidHeaderFlags flags;
|
||||
|
||||
@@ -717,7 +717,7 @@ namespace Game.Maps
|
||||
{
|
||||
Group grp = player.GetGroup();
|
||||
if (grp != null)
|
||||
if (grp.isLFGGroup())
|
||||
if (grp.IsLFGGroup())
|
||||
{
|
||||
Global.LFGMgr.FinishDungeon(grp.GetGUID(), dungeonId, instance);
|
||||
return;
|
||||
|
||||
@@ -252,8 +252,8 @@ namespace Game.Maps
|
||||
// should only unload VMaps if this is the last instance and grid unloading is enabled
|
||||
if (m_InstancedMaps.Count <= 1 && WorldConfig.GetBoolValue(WorldCfg.GridUnload))
|
||||
{
|
||||
Global.VMapMgr.unloadMap(pair.Value.GetId());
|
||||
Global.MMapMgr.unloadMap(pair.Value.GetId());
|
||||
Global.VMapMgr.UnloadMap(pair.Value.GetId());
|
||||
Global.MMapMgr.UnloadMap(pair.Value.GetId());
|
||||
// in that case, unload grids of the base map, too
|
||||
// so in the next map creation, (EnsureGridCreated actually) VMaps will be reloaded
|
||||
base.UnloadAll();
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Game
|
||||
return loadedMMaps.LookupByKey(mapId);
|
||||
}
|
||||
|
||||
bool loadMapData(string basePath, uint mapId)
|
||||
bool LoadMapData(string basePath, uint mapId)
|
||||
{
|
||||
// we already have this map loaded?
|
||||
if (loadedMMaps.ContainsKey(mapId) && loadedMMaps[mapId] != null)
|
||||
@@ -84,30 +84,30 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
uint packTileID(uint x, uint y)
|
||||
uint PackTileID(uint x, uint y)
|
||||
{
|
||||
return (x << 16 | y);
|
||||
}
|
||||
|
||||
public bool loadMap(string basePath, uint mapId, uint x, uint y)
|
||||
public bool LoadMap(string basePath, uint mapId, uint x, uint y)
|
||||
{
|
||||
// make sure the mmap is loaded and ready to load tiles
|
||||
if (!loadMapImpl(basePath, mapId, x, y))
|
||||
if (!LoadMapImpl(basePath, mapId, x, y))
|
||||
return false;
|
||||
|
||||
bool success = true;
|
||||
var childMaps = childMapData.LookupByKey(mapId);
|
||||
foreach (uint childMapId in childMaps)
|
||||
if (!loadMapImpl(basePath, childMapId, x, y))
|
||||
if (!LoadMapImpl(basePath, childMapId, x, y))
|
||||
success = false;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool loadMapImpl(string basePath, uint mapId, uint x, uint y)
|
||||
bool LoadMapImpl(string basePath, uint mapId, uint x, uint y)
|
||||
{
|
||||
// make sure the mmap is loaded and ready to load tiles
|
||||
if (!loadMapData(basePath, mapId))
|
||||
if (!LoadMapData(basePath, mapId))
|
||||
return false;
|
||||
|
||||
// get this mmap data
|
||||
@@ -115,7 +115,7 @@ namespace Game
|
||||
Cypher.Assert(mmap.navMesh != null);
|
||||
|
||||
// check if we already have this tile loaded
|
||||
uint packedGridPos = packTileID(x, y);
|
||||
uint packedGridPos = PackTileID(x, y);
|
||||
if (mmap.loadedTileRefs.ContainsKey(packedGridPos))
|
||||
return false;
|
||||
|
||||
@@ -167,23 +167,23 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
public bool loadMapInstance(string basePath, uint mapId, uint instanceId)
|
||||
public bool LoadMapInstance(string basePath, uint mapId, uint instanceId)
|
||||
{
|
||||
if (!loadMapInstanceImpl(basePath, mapId, instanceId))
|
||||
if (!LoadMapInstanceImpl(basePath, mapId, instanceId))
|
||||
return false;
|
||||
|
||||
bool success = true;
|
||||
var childMaps = childMapData.LookupByKey(mapId);
|
||||
foreach (uint childMapId in childMaps)
|
||||
if (!loadMapInstanceImpl(basePath, childMapId, instanceId))
|
||||
if (!LoadMapInstanceImpl(basePath, childMapId, instanceId))
|
||||
success = false;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool loadMapInstanceImpl(string basePath, uint mapId, uint instanceId)
|
||||
bool LoadMapInstanceImpl(string basePath, uint mapId, uint instanceId)
|
||||
{
|
||||
if (!loadMapData(basePath, mapId))
|
||||
if (!LoadMapData(basePath, mapId))
|
||||
return false;
|
||||
|
||||
MMapData mmap = loadedMMaps[mapId];
|
||||
@@ -203,16 +203,16 @@ namespace Game
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool unloadMap(uint mapId, uint x, uint y)
|
||||
public bool UnloadMap(uint mapId, uint x, uint y)
|
||||
{
|
||||
var childMaps = childMapData.LookupByKey(mapId);
|
||||
foreach (uint childMapId in childMaps)
|
||||
unloadMapImpl(childMapId, x, y);
|
||||
UnloadMapImpl(childMapId, x, y);
|
||||
|
||||
return unloadMapImpl(mapId, x, y);
|
||||
return UnloadMapImpl(mapId, x, y);
|
||||
}
|
||||
|
||||
bool unloadMapImpl(uint mapId, uint x, uint y)
|
||||
bool UnloadMapImpl(uint mapId, uint x, uint y)
|
||||
{
|
||||
// check if we have this map loaded
|
||||
MMapData mmap = GetMMapData(mapId);
|
||||
@@ -224,7 +224,7 @@ namespace Game
|
||||
}
|
||||
|
||||
// check if we have this tile loaded
|
||||
uint packedGridPos = packTileID(x, y);
|
||||
uint packedGridPos = PackTileID(x, y);
|
||||
if (!mmap.loadedTileRefs.ContainsKey(packedGridPos))
|
||||
{
|
||||
// file may not exist, therefore not loaded
|
||||
@@ -255,7 +255,7 @@ namespace Game
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool unloadMap(uint mapId)
|
||||
public bool UnloadMap(uint mapId)
|
||||
{
|
||||
if (!loadedMMaps.ContainsKey(mapId))
|
||||
{
|
||||
@@ -286,7 +286,7 @@ namespace Game
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool unloadMapInstance(uint mapId, uint instanceId)
|
||||
public bool UnloadMapInstance(uint mapId, uint instanceId)
|
||||
{
|
||||
// check if we have this map loaded
|
||||
MMapData mmap = GetMMapData(mapId);
|
||||
@@ -327,8 +327,8 @@ namespace Game
|
||||
return mmap.navMeshQueries[instanceId];
|
||||
}
|
||||
|
||||
public uint getLoadedTilesCount() { return loadedTiles; }
|
||||
public int getLoadedMapsCount() { return loadedMMaps.Count; }
|
||||
public uint GetLoadedTilesCount() { return loadedTiles; }
|
||||
public int GetLoadedMapsCount() { return loadedMMaps.Count; }
|
||||
|
||||
Dictionary<uint, MMapData> loadedMMaps = new Dictionary<uint, MMapData>();
|
||||
uint loadedTiles;
|
||||
|
||||
+131
-131
@@ -69,7 +69,7 @@ namespace Game.Maps
|
||||
{
|
||||
//z code
|
||||
GridMaps[x][y] = null;
|
||||
setGrid(null, x, y);
|
||||
SetGrid(null, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Game.Maps
|
||||
|
||||
GetGuidSequenceGenerator(HighGuid.Transport).Set(Global.ObjectMgr.GetGenerator(HighGuid.Transport).GetNextAfterMaxUsed());
|
||||
|
||||
Global.MMapMgr.loadMapInstance(Global.WorldMgr.GetDataPath(), GetId(), i_InstanceId);
|
||||
Global.MMapMgr.LoadMapInstance(Global.WorldMgr.GetDataPath(), GetId(), i_InstanceId);
|
||||
|
||||
Global.ScriptMgr.OnCreateMap(this);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ namespace Game.Maps
|
||||
if (m_parentMap == this)
|
||||
m_childTerrainMaps = null;
|
||||
|
||||
Global.MMapMgr.unloadMapInstance(GetId(), i_InstanceId);
|
||||
Global.MMapMgr.UnloadMapInstance(GetId(), i_InstanceId);
|
||||
}
|
||||
|
||||
public static bool ExistMap(uint mapid, uint gx, uint gy)
|
||||
@@ -117,7 +117,7 @@ namespace Game.Maps
|
||||
|
||||
using (var reader = new BinaryReader(new FileStream(fileName, FileMode.Open, FileAccess.Read)))
|
||||
{
|
||||
var header = reader.Read<mapFileHeader>();
|
||||
var header = reader.Read<MapFileHeader>();
|
||||
if (header.mapMagic != MapConst.MapMagic || header.versionMagic != MapConst.MapVersionMagic)
|
||||
{
|
||||
Log.outError(LogFilter.Maps, "Map file '{0}' is from an incompatible map version ({1}), {2} is expected. Please recreate using the mapextractor.",
|
||||
@@ -130,10 +130,10 @@ namespace Game.Maps
|
||||
|
||||
public static bool ExistVMap(uint mapid, uint gx, uint gy)
|
||||
{
|
||||
if (Global.VMapMgr.isMapLoadingEnabled())
|
||||
if (Global.VMapMgr.IsMapLoadingEnabled())
|
||||
{
|
||||
LoadResult result = Global.VMapMgr.existsMap(mapid, gx, gy);
|
||||
string name = VMapManager.getMapFileName(mapid);
|
||||
LoadResult result = Global.VMapMgr.ExistsMap(mapid, gx, gy);
|
||||
string name = VMapManager.GetMapFileName(mapid);
|
||||
switch (result)
|
||||
{
|
||||
case LoadResult.Success:
|
||||
@@ -156,7 +156,7 @@ namespace Game.Maps
|
||||
if (!Global.DisableMgr.IsPathfindingEnabled(GetId()))
|
||||
return;
|
||||
|
||||
if (Global.MMapMgr.loadMap(Global.WorldMgr.GetDataPath(), GetId(), gx, gy))
|
||||
if (Global.MMapMgr.LoadMap(Global.WorldMgr.GetDataPath(), GetId(), gx, gy))
|
||||
Log.outInfo(LogFilter.Maps, "MMAP loaded name:{0}, id:{1}, x:{2}, y:{3} (mmap rep.: x:{4}, y:{5})", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
else
|
||||
Log.outInfo(LogFilter.Maps, "Could not load MMAP name:{0}, id:{1}, x:{2}, y:{3} (mmap rep.: x:{4}, y:{5})", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
@@ -164,11 +164,11 @@ namespace Game.Maps
|
||||
|
||||
void LoadVMap(uint gx, uint gy)
|
||||
{
|
||||
if (!Global.VMapMgr.isMapLoadingEnabled())
|
||||
if (!Global.VMapMgr.IsMapLoadingEnabled())
|
||||
return;
|
||||
|
||||
// x and y are swapped !!
|
||||
VMAPLoadResult vmapLoadResult = Global.VMapMgr.loadMap(GetId(), gx, gy);
|
||||
VMAPLoadResult vmapLoadResult = Global.VMapMgr.LoadMap(GetId(), gx, gy);
|
||||
switch (vmapLoadResult)
|
||||
{
|
||||
case VMAPLoadResult.OK:
|
||||
@@ -214,7 +214,7 @@ namespace Game.Maps
|
||||
Log.outInfo(LogFilter.Maps, "Loading map {0}", filename);
|
||||
// loading data
|
||||
map.GridMaps[gx][gy] = new GridMap();
|
||||
if (!map.GridMaps[gx][gy].loadData(filename))
|
||||
if (!map.GridMaps[gx][gy].LoadData(filename))
|
||||
Log.outError(LogFilter.Maps, "Error loading map file: {0}", filename);
|
||||
|
||||
Global.ScriptMgr.OnLoadGridMap(map, map.GridMaps[gx][gy], gx, gy);
|
||||
@@ -236,7 +236,7 @@ namespace Game.Maps
|
||||
|
||||
if ((--parent.GridMapReference[gx][gy]) == 0)
|
||||
{
|
||||
parent.GridMaps[gx][gy].unloadData();
|
||||
parent.GridMaps[gx][gy].UnloadData();
|
||||
parent.GridMaps[gx][gy] = null;
|
||||
}
|
||||
}
|
||||
@@ -267,11 +267,11 @@ namespace Game.Maps
|
||||
|
||||
public void AddToGrid<T>(T obj, Cell cell)where T : WorldObject
|
||||
{
|
||||
Grid grid = getGrid(cell.GetGridX(), cell.GetGridY());
|
||||
Grid grid = GetGrid(cell.GetGridX(), cell.GetGridY());
|
||||
switch (obj.GetTypeId())
|
||||
{
|
||||
case TypeId.Corpse:
|
||||
if (grid.isGridObjectDataLoaded())
|
||||
if (grid.IsGridObjectDataLoaded())
|
||||
{
|
||||
// Corpses are a special object type - they can be added to grid via a call to AddToMap
|
||||
// or loaded through ObjectGridLoader.
|
||||
@@ -309,7 +309,7 @@ namespace Game.Maps
|
||||
if (cell == null)
|
||||
return;
|
||||
|
||||
Grid grid = getGrid(cell.GetGridX(), cell.GetGridY());
|
||||
Grid grid = GetGrid(cell.GetGridX(), cell.GetGridY());
|
||||
if (grid == null)
|
||||
return;
|
||||
|
||||
@@ -330,7 +330,7 @@ namespace Game.Maps
|
||||
if (!p.IsCoordValid())
|
||||
{
|
||||
Log.outError(LogFilter.Maps, "Map.SwitchGridContainers: Object {0} has invalid coordinates X:{1} Y:{2} grid cell [{3}:{4}]",
|
||||
obj.GetGUID(), obj.GetPositionX(), obj.GetPositionY(), p.x_coord, p.y_coord);
|
||||
obj.GetGUID(), obj.GetPositionX(), obj.GetPositionY(), p.X_coord, p.Y_coord);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace Game.Maps
|
||||
return;
|
||||
|
||||
Log.outDebug(LogFilter.Maps, "Switch object {0} from grid[{1}, {2}] {3}", obj.GetGUID(), cell.GetGridX(), cell.GetGridY(), on);
|
||||
Grid ngrid = getGrid(cell.GetGridX(), cell.GetGridY());
|
||||
Grid ngrid = GetGrid(cell.GetGridX(), cell.GetGridY());
|
||||
Cypher.Assert(ngrid != null);
|
||||
|
||||
RemoveFromGrid(obj, cell);
|
||||
@@ -390,18 +390,18 @@ namespace Game.Maps
|
||||
|
||||
void EnsureGridCreated_i(GridCoord p)
|
||||
{
|
||||
if (getGrid(p.x_coord, p.y_coord) == null)
|
||||
if (GetGrid(p.X_coord, p.Y_coord) == null)
|
||||
{
|
||||
Log.outDebug(LogFilter.Maps, "Creating grid[{0}, {1}] for map {2} instance {3}", p.x_coord, p.y_coord,
|
||||
Log.outDebug(LogFilter.Maps, "Creating grid[{0}, {1}] for map {2} instance {3}", p.X_coord, p.Y_coord,
|
||||
GetId(), i_InstanceId);
|
||||
|
||||
var grid = new Grid(p.x_coord * MapConst.MaxGrids + p.y_coord, p.x_coord, p.y_coord, i_gridExpiry, WorldConfig.GetBoolValue(WorldCfg.GridUnload));
|
||||
var grid = new Grid(p.X_coord * MapConst.MaxGrids + p.Y_coord, p.X_coord, p.Y_coord, i_gridExpiry, WorldConfig.GetBoolValue(WorldCfg.GridUnload));
|
||||
grid.SetGridState(GridState.Idle);
|
||||
setGrid(grid, p.x_coord, p.y_coord);
|
||||
SetGrid(grid, p.X_coord, p.Y_coord);
|
||||
|
||||
//z coord
|
||||
uint gx = (MapConst.MaxGrids - 1) - p.x_coord;
|
||||
uint gy = (MapConst.MaxGrids - 1) - p.y_coord;
|
||||
uint gx = (MapConst.MaxGrids - 1) - p.X_coord;
|
||||
uint gy = (MapConst.MaxGrids - 1) - p.Y_coord;
|
||||
|
||||
if (GridMaps[gx][gy] == null)
|
||||
m_parentTerrainMap.LoadMapAndVMap(gx, gy);
|
||||
@@ -411,7 +411,7 @@ namespace Game.Maps
|
||||
void EnsureGridLoadedForActiveObject(Cell cell, WorldObject obj)
|
||||
{
|
||||
EnsureGridLoaded(cell);
|
||||
Grid grid = getGrid(cell.GetGridX(), cell.GetGridY());
|
||||
Grid grid = GetGrid(cell.GetGridX(), cell.GetGridY());
|
||||
|
||||
// refresh grid state & timer
|
||||
if (grid.GetGridState() != GridState.Active)
|
||||
@@ -426,14 +426,14 @@ namespace Game.Maps
|
||||
private bool EnsureGridLoaded(Cell cell)
|
||||
{
|
||||
EnsureGridCreated(new GridCoord(cell.GetGridX(), cell.GetGridY()));
|
||||
Grid grid = getGrid(cell.GetGridX(), cell.GetGridY());
|
||||
Grid grid = GetGrid(cell.GetGridX(), cell.GetGridY());
|
||||
|
||||
if (!isGridObjectDataLoaded(cell.GetGridX(), cell.GetGridY()))
|
||||
if (!IsGridObjectDataLoaded(cell.GetGridX(), cell.GetGridY()))
|
||||
{
|
||||
Log.outDebug(LogFilter.Maps, "Loading grid[{0}, {1}] for map {2} instance {3}", cell.GetGridX(),
|
||||
cell.GetGridY(), GetId(), i_InstanceId);
|
||||
|
||||
setGridObjectDataLoaded(true, cell.GetGridX(), cell.GetGridY());
|
||||
SetGridObjectDataLoaded(true, cell.GetGridX(), cell.GetGridY());
|
||||
|
||||
LoadGridObjects(grid, cell);
|
||||
|
||||
@@ -513,7 +513,7 @@ namespace Game.Maps
|
||||
{
|
||||
Log.outError(LogFilter.Maps,
|
||||
"Map.Add: Object {0} has invalid coordinates X:{1} Y:{2} grid cell [{3}:{4}]", obj.GetGUID(),
|
||||
obj.GetPositionX(), obj.GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
|
||||
obj.GetPositionX(), obj.GetPositionY(), cellCoord.X_coord, cellCoord.Y_coord);
|
||||
return false; //Should delete object
|
||||
}
|
||||
|
||||
@@ -549,7 +549,7 @@ namespace Game.Maps
|
||||
{
|
||||
Log.outError(LogFilter.Maps,
|
||||
"Map.Add: Object {0} has invalid coordinates X:{1} Y:{2} grid cell [{3}:{4}]", obj.GetGUID(),
|
||||
obj.GetPositionX(), obj.GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
|
||||
obj.GetPositionX(), obj.GetPositionY(), cellCoord.X_coord, cellCoord.Y_coord);
|
||||
return false; //Should delete object
|
||||
}
|
||||
|
||||
@@ -580,7 +580,7 @@ namespace Game.Maps
|
||||
|
||||
public bool IsGridLoaded(GridCoord p)
|
||||
{
|
||||
return (getGrid(p.x_coord, p.y_coord) != null && isGridObjectDataLoaded(p.x_coord, p.y_coord));
|
||||
return (GetGrid(p.X_coord, p.Y_coord) != null && IsGridObjectDataLoaded(p.X_coord, p.Y_coord));
|
||||
}
|
||||
|
||||
void VisitNearbyCellsOf(WorldObject obj, Visitor gridVisitor, Visitor worldVisitor)
|
||||
@@ -592,17 +592,17 @@ namespace Game.Maps
|
||||
// Update mobs/objects in ALL visible cells around object!
|
||||
CellArea area = Cell.CalculateCellArea(obj.GetPositionX(), obj.GetPositionY(), obj.GetGridActivationRange());
|
||||
|
||||
for (uint x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
|
||||
for (uint x = area.low_bound.X_coord; x <= area.high_bound.X_coord; ++x)
|
||||
{
|
||||
for (uint y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
|
||||
for (uint y = area.low_bound.Y_coord; y <= area.high_bound.Y_coord; ++y)
|
||||
{
|
||||
// marked cells are those that have been visited
|
||||
// don't visit the same cell twice
|
||||
uint cell_id = (y * MapConst.TotalCellsPerMap) + x;
|
||||
if (isCellMarked(cell_id))
|
||||
if (IsCellMarked(cell_id))
|
||||
continue;
|
||||
|
||||
markCell(cell_id);
|
||||
MarkCell(cell_id);
|
||||
var pair = new CellCoord(x, y);
|
||||
var cell = new Cell(pair);
|
||||
cell.SetNoCreate();
|
||||
@@ -614,7 +614,7 @@ namespace Game.Maps
|
||||
|
||||
public virtual void Update(uint diff)
|
||||
{
|
||||
_dynamicTree.update(diff);
|
||||
_dynamicTree.Update(diff);
|
||||
|
||||
// update worldsessions for existing players
|
||||
for (var i = 0; i < m_activePlayers.Count; ++i)
|
||||
@@ -629,7 +629,7 @@ namespace Game.Maps
|
||||
}
|
||||
|
||||
// update active cells around players and active objects
|
||||
resetMarkedCells();
|
||||
ResetMarkedCells();
|
||||
|
||||
var update = new UpdaterNotifier(diff);
|
||||
|
||||
@@ -656,7 +656,7 @@ namespace Game.Maps
|
||||
if (player.IsInCombat())
|
||||
{
|
||||
List<Creature> updateList = new List<Creature>();
|
||||
HostileReference refe = player.GetHostileRefManager().getFirst();
|
||||
HostileReference refe = player.GetHostileRefManager().GetFirst();
|
||||
|
||||
while (refe != null)
|
||||
{
|
||||
@@ -665,7 +665,7 @@ namespace Game.Maps
|
||||
if (unit.ToCreature() && unit.GetMapId() == player.GetMapId() && !unit.IsWithinDistInMap(player, GetVisibilityRange(), false))
|
||||
updateList.Add(unit.ToCreature());
|
||||
|
||||
refe = refe.next();
|
||||
refe = refe.Next();
|
||||
}
|
||||
|
||||
// Process deferred update list for player
|
||||
@@ -729,29 +729,29 @@ namespace Game.Maps
|
||||
{
|
||||
for (uint y = 0; y < MapConst.MaxGrids; ++y)
|
||||
{
|
||||
Grid grid = getGrid(x, y);
|
||||
Grid grid = GetGrid(x, y);
|
||||
if (grid == null)
|
||||
continue;
|
||||
|
||||
if (grid.GetGridState() != GridState.Active)
|
||||
continue;
|
||||
|
||||
grid.getGridInfoRef().getRelocationTimer().TUpdate((int)diff);
|
||||
if (!grid.getGridInfoRef().getRelocationTimer().TPassed())
|
||||
grid.GetGridInfoRef().GetRelocationTimer().TUpdate((int)diff);
|
||||
if (!grid.GetGridInfoRef().GetRelocationTimer().TPassed())
|
||||
continue;
|
||||
|
||||
uint gx = grid.getX();
|
||||
uint gy = grid.getY();
|
||||
uint gx = grid.GetX();
|
||||
uint gy = grid.GetY();
|
||||
|
||||
var cell_min = new CellCoord(gx * MapConst.MaxCells, gy * MapConst.MaxCells);
|
||||
var cell_max = new CellCoord(cell_min.x_coord + MapConst.MaxCells, cell_min.y_coord + MapConst.MaxCells);
|
||||
var cell_max = new CellCoord(cell_min.X_coord + MapConst.MaxCells, cell_min.Y_coord + MapConst.MaxCells);
|
||||
|
||||
for (uint xx = cell_min.x_coord; xx < cell_max.x_coord; ++xx)
|
||||
for (uint xx = cell_min.X_coord; xx < cell_max.X_coord; ++xx)
|
||||
{
|
||||
for (uint yy = cell_min.y_coord; yy < cell_max.y_coord; ++yy)
|
||||
for (uint yy = cell_min.Y_coord; yy < cell_max.Y_coord; ++yy)
|
||||
{
|
||||
uint cell_id = (yy * MapConst.TotalCellsPerMap) + xx;
|
||||
if (!isCellMarked(cell_id))
|
||||
if (!IsCellMarked(cell_id))
|
||||
continue;
|
||||
|
||||
var pair = new CellCoord(xx, yy);
|
||||
@@ -776,31 +776,31 @@ namespace Game.Maps
|
||||
{
|
||||
for (uint y = 0; y < MapConst.MaxGrids; ++y)
|
||||
{
|
||||
Grid grid = getGrid(x, y);
|
||||
Grid grid = GetGrid(x, y);
|
||||
if (grid == null)
|
||||
continue;
|
||||
|
||||
if (grid.GetGridState() != GridState.Active)
|
||||
continue;
|
||||
|
||||
if (!grid.getGridInfoRef().getRelocationTimer().TPassed())
|
||||
if (!grid.GetGridInfoRef().GetRelocationTimer().TPassed())
|
||||
continue;
|
||||
|
||||
grid.getGridInfoRef().getRelocationTimer().TReset((int)diff, m_VisibilityNotifyPeriod);
|
||||
grid.GetGridInfoRef().GetRelocationTimer().TReset((int)diff, m_VisibilityNotifyPeriod);
|
||||
|
||||
uint gx = grid.getX();
|
||||
uint gy = grid.getY();
|
||||
uint gx = grid.GetX();
|
||||
uint gy = grid.GetY();
|
||||
|
||||
var cell_min = new CellCoord(gx * MapConst.MaxCells, gy * MapConst.MaxCells);
|
||||
var cell_max = new CellCoord(cell_min.x_coord + MapConst.MaxCells,
|
||||
cell_min.y_coord + MapConst.MaxCells);
|
||||
var cell_max = new CellCoord(cell_min.X_coord + MapConst.MaxCells,
|
||||
cell_min.Y_coord + MapConst.MaxCells);
|
||||
|
||||
for (uint xx = cell_min.x_coord; xx < cell_max.x_coord; ++xx)
|
||||
for (uint xx = cell_min.X_coord; xx < cell_max.X_coord; ++xx)
|
||||
{
|
||||
for (uint yy = cell_min.y_coord; yy < cell_max.y_coord; ++yy)
|
||||
for (uint yy = cell_min.Y_coord; yy < cell_max.Y_coord; ++yy)
|
||||
{
|
||||
uint cell_id = (yy * MapConst.TotalCellsPerMap) + xx;
|
||||
if (!isCellMarked(cell_id))
|
||||
if (!IsCellMarked(cell_id))
|
||||
continue;
|
||||
|
||||
var pair = new CellCoord(xx, yy);
|
||||
@@ -818,7 +818,7 @@ namespace Game.Maps
|
||||
{
|
||||
Global.ScriptMgr.OnPlayerLeaveMap(this, player);
|
||||
|
||||
player.GetHostileRefManager().deleteReferences(); // multithreading crashfix
|
||||
player.GetHostileRefManager().DeleteReferences(); // multithreading crashfix
|
||||
|
||||
bool inWorld = player.IsInWorld;
|
||||
player.RemoveFromWorld();
|
||||
@@ -935,7 +935,7 @@ namespace Game.Maps
|
||||
Cell old_cell = creature.GetCurrentCell();
|
||||
var new_cell = new Cell(x, y);
|
||||
|
||||
if (!respawnRelocationOnFail && getGrid(new_cell.GetGridX(), new_cell.GetGridY()) == null)
|
||||
if (!respawnRelocationOnFail && GetGrid(new_cell.GetGridX(), new_cell.GetGridY()) == null)
|
||||
return;
|
||||
|
||||
//! If hovering, always increase our server-side Z position
|
||||
@@ -967,7 +967,7 @@ namespace Game.Maps
|
||||
Cell old_cell = go.GetCurrentCell();
|
||||
|
||||
var new_cell = new Cell(x, y);
|
||||
if (!respawnRelocationOnFail && getGrid(new_cell.GetGridX(), new_cell.GetGridY()) == null)
|
||||
if (!respawnRelocationOnFail && GetGrid(new_cell.GetGridX(), new_cell.GetGridY()) == null)
|
||||
return;
|
||||
|
||||
// delay creature move for grid/cell to grid/cell moves
|
||||
@@ -999,7 +999,7 @@ namespace Game.Maps
|
||||
|
||||
Cell new_cell = new Cell(x, y);
|
||||
|
||||
if (getGrid(new_cell.GetGridX(), new_cell.GetGridY()) == null)
|
||||
if (GetGrid(new_cell.GetGridX(), new_cell.GetGridY()) == null)
|
||||
return;
|
||||
|
||||
// delay creature move for grid/cell to grid/cell moves
|
||||
@@ -1033,7 +1033,7 @@ namespace Game.Maps
|
||||
Cypher.Assert(integrity_check == old_cell);
|
||||
Cell new_cell = new Cell(x, y);
|
||||
|
||||
if (getGrid(new_cell.GetGridX(), new_cell.GetGridY()) == null)
|
||||
if (GetGrid(new_cell.GetGridX(), new_cell.GetGridY()) == null)
|
||||
return;
|
||||
|
||||
// delay areatrigger move for grid/cell to grid/cell moves
|
||||
@@ -1557,8 +1557,8 @@ namespace Game.Maps
|
||||
|
||||
public bool UnloadGrid(Grid grid, bool unloadAll)
|
||||
{
|
||||
uint x = grid.getX();
|
||||
uint y = grid.getY();
|
||||
uint x = grid.GetX();
|
||||
uint y = grid.GetY();
|
||||
|
||||
if (!unloadAll)
|
||||
{
|
||||
@@ -1606,7 +1606,7 @@ namespace Game.Maps
|
||||
}
|
||||
|
||||
Cypher.Assert(i_objectsToRemove.Empty());
|
||||
setGrid(null, x, y);
|
||||
SetGrid(null, x, y);
|
||||
|
||||
uint gx = (MapConst.MaxGrids - 1) - x;
|
||||
uint gy = (MapConst.MaxGrids - 1) - y;
|
||||
@@ -1615,8 +1615,8 @@ namespace Game.Maps
|
||||
if (GridMaps[gx][gy] != null)
|
||||
{
|
||||
m_parentTerrainMap.UnloadMap(gx, gy);
|
||||
Global.VMapMgr.unloadMap(m_parentTerrainMap.GetId(), gx, gy);
|
||||
Global.MMapMgr.unloadMap(m_parentTerrainMap.GetId(), gx, gy);
|
||||
Global.VMapMgr.UnloadMap(m_parentTerrainMap.GetId(), gx, gy);
|
||||
Global.MMapMgr.UnloadMap(m_parentTerrainMap.GetId(), gx, gy);
|
||||
}
|
||||
|
||||
Log.outDebug(LogFilter.Maps, "Unloading grid[{0}, {1}] for map {2} finished", x, y, GetId());
|
||||
@@ -1651,7 +1651,7 @@ namespace Game.Maps
|
||||
{
|
||||
for (uint y = 0; y < MapConst.MaxGrids; ++y)
|
||||
{
|
||||
var grid = getGrid(x, y);
|
||||
var grid = GetGrid(x, y);
|
||||
if (grid == null)
|
||||
continue;
|
||||
|
||||
@@ -1702,7 +1702,7 @@ namespace Game.Maps
|
||||
|
||||
GridMap grid = GridMaps[gx][gy];
|
||||
var childMap = m_childTerrainMaps.Find(childTerrainMap => childTerrainMap.GetId() == mapId);
|
||||
if (childMap != null && childMap.GridMaps[gx][gy].fileExists())
|
||||
if (childMap != null && childMap.GridMaps[gx][gy].GileExists())
|
||||
grid = childMap.GridMaps[gx][gy];
|
||||
|
||||
return grid;
|
||||
@@ -1711,7 +1711,7 @@ namespace Game.Maps
|
||||
public bool HasGridMap(uint mapId, uint gx, uint gy)
|
||||
{
|
||||
var childMap = m_childTerrainMaps.Find(childTerrainMap => childTerrainMap.GetId() == mapId);
|
||||
return childMap != null && childMap.GridMaps[gx][gy] != null && childMap.GridMaps[gx][gy].fileExists();
|
||||
return childMap != null && childMap.GridMaps[gx][gy] != null && childMap.GridMaps[gx][gy].GileExists();
|
||||
}
|
||||
|
||||
public float GetWaterOrGroundLevel(PhaseShift phaseShift, float x, float y, float z)
|
||||
@@ -1730,7 +1730,7 @@ namespace Game.Maps
|
||||
|
||||
LiquidData liquid_status;
|
||||
|
||||
ZLiquidStatus res = getLiquidStatus(phaseShift, x, y, ground_z, MapConst.MapAllLiquidTypes, out liquid_status);
|
||||
ZLiquidStatus res = GetLiquidStatus(phaseShift, x, y, ground_z, MapConst.MapAllLiquidTypes, out liquid_status);
|
||||
return res != ZLiquidStatus.NoWater ? liquid_status.level : ground_z;
|
||||
}
|
||||
|
||||
@@ -1745,7 +1745,7 @@ namespace Game.Maps
|
||||
GridMap gmap = m_parentTerrainMap.GetGridMap(terrainMapId, x, y);
|
||||
if (gmap != null)
|
||||
{
|
||||
float gridHeight = gmap.getHeight(x, y);
|
||||
float gridHeight = gmap.GetHeight(x, y);
|
||||
// look from a bit higher pos to find the floor, ignore under surface case
|
||||
if (z + 2.0f > gridHeight)
|
||||
mapHeight = gridHeight;
|
||||
@@ -1754,8 +1754,8 @@ namespace Game.Maps
|
||||
float vmapHeight = MapConst.VMAPInvalidHeightValue;
|
||||
if (checkVMap)
|
||||
{
|
||||
if (Global.VMapMgr.isHeightCalcEnabled())
|
||||
vmapHeight = Global.VMapMgr.getHeight(terrainMapId, x, y, z + 2.0f, maxSearchDist);
|
||||
if (Global.VMapMgr.IsHeightCalcEnabled())
|
||||
vmapHeight = Global.VMapMgr.GetHeight(terrainMapId, x, y, z + 2.0f, maxSearchDist);
|
||||
// look from a bit higher pos to find the floor
|
||||
}
|
||||
|
||||
@@ -1783,7 +1783,7 @@ namespace Game.Maps
|
||||
{
|
||||
GridMap grid = GetGridMap(x, y);
|
||||
if (grid != null)
|
||||
return grid.getMinHeight(x, y);
|
||||
return grid.GetMinHeight(x, y);
|
||||
|
||||
return -500.0f;
|
||||
}
|
||||
@@ -1852,8 +1852,8 @@ namespace Game.Maps
|
||||
int drootId;
|
||||
int dgroupId;
|
||||
|
||||
bool hasVmapAreaInfo = Global.VMapMgr.getAreaInfo(terrainMapId, x, y, ref vmap_z, out vflags, out vadtId, out vrootId, out vgroupId);
|
||||
bool hasDynamicAreaInfo = _dynamicTree.getAreaInfo(x, y, ref dynamic_z, phaseShift, out dflags, out dadtId, out drootId, out dgroupId);
|
||||
bool hasVmapAreaInfo = Global.VMapMgr.GetAreaInfo(terrainMapId, x, y, ref vmap_z, out vflags, out vadtId, out vrootId, out vgroupId);
|
||||
bool hasDynamicAreaInfo = _dynamicTree.GetAreaInfo(x, y, ref dynamic_z, phaseShift, out dflags, out dadtId, out drootId, out dgroupId);
|
||||
|
||||
if (hasVmapAreaInfo)
|
||||
{
|
||||
@@ -1890,7 +1890,7 @@ namespace Game.Maps
|
||||
GridMap gmap = m_parentTerrainMap.GetGridMap(terrainMapId, x, y);
|
||||
if (gmap != null)
|
||||
{
|
||||
float mapHeight = gmap.getHeight(x, y);
|
||||
float mapHeight = gmap.GetHeight(x, y);
|
||||
// z + 2.0f condition taken from GetHeight(), not sure if it's such a great choice...
|
||||
if (z + 2.0f > mapHeight && mapHeight > check_z)
|
||||
return false;
|
||||
@@ -1931,7 +1931,7 @@ namespace Game.Maps
|
||||
{
|
||||
GridMap gmap = m_parentTerrainMap.GetGridMap(PhasingHandler.GetTerrainMapId(phaseShift, this, x, y), x, y);
|
||||
if (gmap != null)
|
||||
areaId = gmap.getArea(x, y);
|
||||
areaId = gmap.GetArea(x, y);
|
||||
|
||||
// this used while not all *.map files generated (instances)
|
||||
if (areaId == 0)
|
||||
@@ -1970,17 +1970,17 @@ namespace Game.Maps
|
||||
{
|
||||
GridMap gmap = m_parentTerrainMap.GetGridMap(PhasingHandler.GetTerrainMapId(phaseShift, this, x, y), x, y);
|
||||
if (gmap != null)
|
||||
return gmap.getTerrainType(x, y);
|
||||
return gmap.GetTerrainType(x, y);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ZLiquidStatus getLiquidStatus(PhaseShift phaseShift, float x, float y, float z, uint ReqLiquidType)
|
||||
public ZLiquidStatus GetLiquidStatus(PhaseShift phaseShift, float x, float y, float z, uint ReqLiquidType)
|
||||
{
|
||||
LiquidData throwaway;
|
||||
return getLiquidStatus(phaseShift, x, y, z, ReqLiquidType, out throwaway);
|
||||
return GetLiquidStatus(phaseShift, x, y, z, ReqLiquidType, out throwaway);
|
||||
}
|
||||
|
||||
public ZLiquidStatus getLiquidStatus(PhaseShift phaseShift, float x, float y, float z, uint ReqLiquidType, out LiquidData data)
|
||||
public ZLiquidStatus GetLiquidStatus(PhaseShift phaseShift, float x, float y, float z, uint ReqLiquidType, out LiquidData data)
|
||||
{
|
||||
data = new LiquidData();
|
||||
var result = ZLiquidStatus.NoWater;
|
||||
@@ -2050,7 +2050,7 @@ namespace Game.Maps
|
||||
if (gmap != null)
|
||||
{
|
||||
var map_data = new LiquidData();
|
||||
ZLiquidStatus map_result = gmap.getLiquidStatus(x, y, z, ReqLiquidType, map_data);
|
||||
ZLiquidStatus map_result = gmap.GetLiquidStatus(x, y, z, ReqLiquidType, map_data);
|
||||
// Not override LIQUID_MAP_ABOVE_WATER with LIQUID_MAP_NO_WATER:
|
||||
if (map_result != ZLiquidStatus.NoWater && (map_data.level > ground_level))
|
||||
{
|
||||
@@ -2070,23 +2070,23 @@ namespace Game.Maps
|
||||
{
|
||||
GridMap gmap = m_parentTerrainMap.GetGridMap(PhasingHandler.GetTerrainMapId(phaseShift, this, x, y), x, y);
|
||||
if (gmap != null)
|
||||
return gmap.getLiquidLevel(x, y);
|
||||
return gmap.GetLiquidLevel(x, y);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public bool isInLineOfSight(PhaseShift phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, ModelIgnoreFlags ignoreFlags)
|
||||
public bool IsInLineOfSight(PhaseShift phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, ModelIgnoreFlags ignoreFlags)
|
||||
{
|
||||
return Global.VMapMgr.isInLineOfSight(PhasingHandler.GetTerrainMapId(phaseShift, this, x1, y1), x1, y1, z1, x2, y2, z2, ignoreFlags)
|
||||
&& _dynamicTree.isInLineOfSight(new Vector3(x1, y1, z1), new Vector3(x2, y2, z2), phaseShift);
|
||||
return Global.VMapMgr.IsInLineOfSight(PhasingHandler.GetTerrainMapId(phaseShift, this, x1, y1), x1, y1, z1, x2, y2, z2, ignoreFlags)
|
||||
&& _dynamicTree.IsInLineOfSight(new Vector3(x1, y1, z1), new Vector3(x2, y2, z2), phaseShift);
|
||||
}
|
||||
|
||||
public bool getObjectHitPos(PhaseShift phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, out float rx, out float ry, out float rz, float modifyDist)
|
||||
public bool GetObjectHitPos(PhaseShift phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, out float rx, out float ry, out float rz, float modifyDist)
|
||||
{
|
||||
var startPos = new Vector3(x1, y1, z1);
|
||||
var dstPos = new Vector3(x2, y2, z2);
|
||||
|
||||
var resultPos = new Vector3();
|
||||
bool result = _dynamicTree.getObjectHitPos(startPos, dstPos, ref resultPos, modifyDist, phaseShift);
|
||||
bool result = _dynamicTree.GetObjectHitPos(startPos, dstPos, ref resultPos, modifyDist, phaseShift);
|
||||
|
||||
rx = resultPos.X;
|
||||
ry = resultPos.Y;
|
||||
@@ -2096,17 +2096,17 @@ namespace Game.Maps
|
||||
|
||||
public float GetHeight(PhaseShift phaseShift, float x, float y, float z, bool vmap = true, float maxSearchDist = MapConst.DefaultHeightSearch)
|
||||
{
|
||||
return Math.Max(GetStaticHeight(phaseShift, x, y, z, vmap, maxSearchDist), _dynamicTree.getHeight(x, y, z, maxSearchDist, phaseShift));
|
||||
return Math.Max(GetStaticHeight(phaseShift, x, y, z, vmap, maxSearchDist), _dynamicTree.GetHeight(x, y, z, maxSearchDist, phaseShift));
|
||||
}
|
||||
|
||||
public bool IsInWater(PhaseShift phaseShift, float x, float y, float pZ)
|
||||
{
|
||||
return Convert.ToBoolean(getLiquidStatus(phaseShift, x, y, pZ, MapConst.MapAllLiquidTypes) & (ZLiquidStatus.InWater | ZLiquidStatus.UnderWater));
|
||||
return Convert.ToBoolean(GetLiquidStatus(phaseShift, x, y, pZ, MapConst.MapAllLiquidTypes) & (ZLiquidStatus.InWater | ZLiquidStatus.UnderWater));
|
||||
}
|
||||
|
||||
public bool IsUnderWater(PhaseShift phaseShift, float x, float y, float z)
|
||||
{
|
||||
return Convert.ToBoolean(getLiquidStatus(phaseShift, x, y, z, MapConst.MapLiquidTypeWater | MapConst.MapLiquidTypeOcean) & ZLiquidStatus.UnderWater);
|
||||
return Convert.ToBoolean(GetLiquidStatus(phaseShift, x, y, z, MapConst.MapLiquidTypeWater | MapConst.MapLiquidTypeOcean) & ZLiquidStatus.UnderWater);
|
||||
}
|
||||
|
||||
private bool CheckGridIntegrity(Creature c, bool moved)
|
||||
@@ -2214,7 +2214,7 @@ namespace Game.Maps
|
||||
player.SendPacket(packet);
|
||||
}
|
||||
|
||||
void setGrid(Grid grid, uint x, uint y)
|
||||
void SetGrid(Grid grid, uint x, uint y)
|
||||
{
|
||||
if (x >= MapConst.MaxGrids || y >= MapConst.MaxGrids)
|
||||
{
|
||||
@@ -2265,7 +2265,7 @@ namespace Game.Maps
|
||||
{
|
||||
for (uint y = 0; y < MapConst.MaxGrids; ++y)
|
||||
{
|
||||
Grid grid = getGrid(x, y);
|
||||
Grid grid = GetGrid(x, y);
|
||||
if (grid != null)
|
||||
grid.Update(this, diff);
|
||||
}
|
||||
@@ -2387,33 +2387,33 @@ namespace Game.Maps
|
||||
|
||||
public bool ActiveObjectsNearGrid(Grid grid)
|
||||
{
|
||||
var cell_min = new CellCoord(grid.getX() * MapConst.MaxCells,
|
||||
grid.getY() * MapConst.MaxCells);
|
||||
var cell_max = new CellCoord(cell_min.x_coord + MapConst.MaxCells,
|
||||
cell_min.y_coord + MapConst.MaxCells);
|
||||
var cell_min = new CellCoord(grid.GetX() * MapConst.MaxCells,
|
||||
grid.GetY() * MapConst.MaxCells);
|
||||
var cell_max = new CellCoord(cell_min.X_coord + MapConst.MaxCells,
|
||||
cell_min.Y_coord + MapConst.MaxCells);
|
||||
|
||||
//we must find visible range in cells so we unload only non-visible cells...
|
||||
float viewDist = GetVisibilityRange();
|
||||
uint cell_range = (uint)Math.Ceiling(viewDist / MapConst.SizeofCells) + 1;
|
||||
|
||||
cell_min.dec_x(cell_range);
|
||||
cell_min.dec_y(cell_range);
|
||||
cell_max.inc_x(cell_range);
|
||||
cell_max.inc_y(cell_range);
|
||||
cell_min.Dec_x(cell_range);
|
||||
cell_min.Dec_y(cell_range);
|
||||
cell_max.Inc_x(cell_range);
|
||||
cell_max.Inc_y(cell_range);
|
||||
|
||||
foreach (Player pl in m_activePlayers)
|
||||
{
|
||||
CellCoord p = GridDefines.ComputeCellCoord(pl.GetPositionX(), pl.GetPositionY());
|
||||
if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
|
||||
(cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord))
|
||||
if ((cell_min.X_coord <= p.X_coord && p.X_coord <= cell_max.X_coord) &&
|
||||
(cell_min.Y_coord <= p.Y_coord && p.Y_coord <= cell_max.Y_coord))
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (WorldObject obj in m_activeNonPlayers)
|
||||
{
|
||||
CellCoord p = GridDefines.ComputeCellCoord(obj.GetPositionX(), obj.GetPositionY());
|
||||
if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
|
||||
(cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord))
|
||||
if ((cell_min.X_coord <= p.X_coord && p.X_coord <= cell_max.X_coord) &&
|
||||
(cell_min.Y_coord <= p.Y_coord && p.Y_coord <= cell_max.Y_coord))
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2433,14 +2433,14 @@ namespace Game.Maps
|
||||
float x, y, z;
|
||||
c.GetRespawnPosition(out x, out y, out z);
|
||||
GridCoord p = GridDefines.ComputeGridCoord(x, y);
|
||||
if (getGrid(p.x_coord, p.y_coord) != null)
|
||||
getGrid(p.x_coord, p.y_coord).incUnloadActiveLock();
|
||||
if (GetGrid(p.X_coord, p.Y_coord) != null)
|
||||
GetGrid(p.X_coord, p.Y_coord).IncUnloadActiveLock();
|
||||
else
|
||||
{
|
||||
GridCoord p2 = GridDefines.ComputeGridCoord(c.GetPositionX(), c.GetPositionY());
|
||||
Log.outError(LogFilter.Maps,
|
||||
"Active creature (GUID: {0} Entry: {1}) added to grid[{2}, {3}] but spawn grid[{4}, {5}] was not loaded.",
|
||||
c.GetGUID().ToString(), c.GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord);
|
||||
c.GetGUID().ToString(), c.GetEntry(), p.X_coord, p.Y_coord, p2.X_coord, p2.Y_coord);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2464,14 +2464,14 @@ namespace Game.Maps
|
||||
float x, y, z;
|
||||
c.GetRespawnPosition(out x, out y, out z);
|
||||
GridCoord p = GridDefines.ComputeGridCoord(x, y);
|
||||
if (getGrid(p.x_coord, p.y_coord) != null)
|
||||
getGrid(p.x_coord, p.y_coord).decUnloadActiveLock();
|
||||
if (GetGrid(p.X_coord, p.Y_coord) != null)
|
||||
GetGrid(p.X_coord, p.Y_coord).DecUnloadActiveLock();
|
||||
else
|
||||
{
|
||||
GridCoord p2 = GridDefines.ComputeGridCoord(c.GetPositionX(), c.GetPositionY());
|
||||
Log.outDebug(LogFilter.Maps,
|
||||
"Active creature (GUID: {0} Entry: {1}) removed from grid[{2}, {3}] but spawn grid[{4}, {5}] was not loaded.",
|
||||
c.GetGUID().ToString(), c.GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord);
|
||||
c.GetGUID().ToString(), c.GetEntry(), p.X_coord, p.Y_coord, p2.X_coord, p2.Y_coord);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2968,18 +2968,18 @@ namespace Game.Maps
|
||||
public bool IsRemovalGrid(float x, float y)
|
||||
{
|
||||
GridCoord p = GridDefines.ComputeGridCoord(x, y);
|
||||
return getGrid(p.x_coord, p.y_coord) == null ||
|
||||
getGrid(p.x_coord, p.y_coord).GetGridState() == GridState.Removal;
|
||||
return GetGrid(p.X_coord, p.Y_coord) == null ||
|
||||
GetGrid(p.X_coord, p.Y_coord).GetGridState() == GridState.Removal;
|
||||
}
|
||||
|
||||
private bool GetUnloadLock(GridCoord p)
|
||||
{
|
||||
return getGrid(p.x_coord, p.y_coord).getUnloadLock();
|
||||
return GetGrid(p.X_coord, p.Y_coord).GetUnloadLock();
|
||||
}
|
||||
|
||||
void SetUnloadLock(GridCoord p, bool on)
|
||||
{
|
||||
getGrid(p.x_coord, p.y_coord).setUnloadExplicitLock(on);
|
||||
GetGrid(p.X_coord, p.Y_coord).SetUnloadExplicitLock(on);
|
||||
}
|
||||
|
||||
public void ResetGridExpiry(Grid grid, float factor = 1)
|
||||
@@ -3106,17 +3106,17 @@ namespace Game.Maps
|
||||
return i_mapRecord.GetEntrancePos(out mapid, out x, out y);
|
||||
}
|
||||
|
||||
void resetMarkedCells()
|
||||
void ResetMarkedCells()
|
||||
{
|
||||
marked_cells.SetAll(false);
|
||||
}
|
||||
|
||||
private bool isCellMarked(uint pCellId)
|
||||
private bool IsCellMarked(uint pCellId)
|
||||
{
|
||||
return marked_cells.Get((int)pCellId);
|
||||
}
|
||||
|
||||
void markCell(uint pCellId)
|
||||
void MarkCell(uint pCellId)
|
||||
{
|
||||
marked_cells.Set((int)pCellId, true);
|
||||
}
|
||||
@@ -3163,22 +3163,22 @@ namespace Game.Maps
|
||||
|
||||
void Balance()
|
||||
{
|
||||
_dynamicTree.balance();
|
||||
_dynamicTree.Balance();
|
||||
}
|
||||
|
||||
public void RemoveGameObjectModel(GameObjectModel model)
|
||||
{
|
||||
_dynamicTree.remove(model);
|
||||
_dynamicTree.Remove(model);
|
||||
}
|
||||
|
||||
public void InsertGameObjectModel(GameObjectModel model)
|
||||
{
|
||||
_dynamicTree.insert(model);
|
||||
_dynamicTree.Insert(model);
|
||||
}
|
||||
|
||||
public bool ContainsGameObjectModel(GameObjectModel model)
|
||||
{
|
||||
return _dynamicTree.contains(model);
|
||||
return _dynamicTree.Contains(model);
|
||||
}
|
||||
|
||||
public virtual uint GetOwnerGuildId(Team team = Team.Other)
|
||||
@@ -3201,19 +3201,19 @@ namespace Game.Maps
|
||||
i_gridExpiry = t < MapConst.MinGridDelay ? MapConst.MinGridDelay : t;
|
||||
}
|
||||
|
||||
private Grid getGrid(uint x, uint y)
|
||||
private Grid GetGrid(uint x, uint y)
|
||||
{
|
||||
return i_grids[x][y];
|
||||
}
|
||||
|
||||
private bool isGridObjectDataLoaded(uint x, uint y)
|
||||
private bool IsGridObjectDataLoaded(uint x, uint y)
|
||||
{
|
||||
return getGrid(x, y).isGridObjectDataLoaded();
|
||||
return GetGrid(x, y).IsGridObjectDataLoaded();
|
||||
}
|
||||
|
||||
void setGridObjectDataLoaded(bool pLoaded, uint x, uint y)
|
||||
void SetGridObjectDataLoaded(bool pLoaded, uint x, uint y)
|
||||
{
|
||||
getGrid(x, y).setGridObjectDataLoaded(pLoaded);
|
||||
GetGrid(x, y).SetGridObjectDataLoaded(pLoaded);
|
||||
}
|
||||
|
||||
public AreaTrigger GetAreaTrigger(ObjectGuid guid)
|
||||
@@ -3291,7 +3291,7 @@ namespace Game.Maps
|
||||
if (!cell.NoCreate() || IsGridLoaded(new GridCoord(x, y)))
|
||||
{
|
||||
EnsureGridLoaded(cell);
|
||||
getGrid(x, y).VisitGrid(cell_x, cell_y, visitor);
|
||||
GetGrid(x, y).VisitGrid(cell_x, cell_y, visitor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4414,7 +4414,7 @@ namespace Game.Maps
|
||||
Group group = player.GetGroup();
|
||||
|
||||
// increase current instances (hourly limit)
|
||||
if (!group || !group.isLFGGroup())
|
||||
if (!group || !group.IsLFGGroup())
|
||||
player.AddInstanceEnterTime(GetInstanceId(), Time.UnixTime);
|
||||
|
||||
// get or create an instance save for the map
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace Game.Entities
|
||||
|
||||
Group group = player.GetGroup();
|
||||
if (entry.IsRaid() && entry.Expansion() >= (Expansion)WorldConfig.GetIntValue(WorldCfg.Expansion)) // can only enter in a raid group but raids from old expansion don't need a group
|
||||
if ((!group || !group.isRaidGroup()) && WorldConfig.GetBoolValue(WorldCfg.InstanceIgnoreRaid))
|
||||
if ((!group || !group.IsRaidGroup()) && WorldConfig.GetBoolValue(WorldCfg.InstanceIgnoreRaid))
|
||||
return EnterState.CannotEnterNotInRaid;
|
||||
|
||||
if (!player.IsAlive())
|
||||
@@ -198,7 +198,7 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
// players are only allowed to enter 10 instances per hour
|
||||
if (entry.IsDungeon() && (player.GetGroup() == null || (player.GetGroup() != null && !player.GetGroup().isLFGGroup())))
|
||||
if (entry.IsDungeon() && (player.GetGroup() == null || (player.GetGroup() != null && !player.GetGroup().IsLFGGroup())))
|
||||
{
|
||||
uint instaceIdToCheck = 0;
|
||||
InstanceSave save = player.GetInstanceSave(mapid);
|
||||
@@ -245,8 +245,8 @@ namespace Game.Entities
|
||||
{
|
||||
GridCoord p = GridDefines.ComputeGridCoord(x, y);
|
||||
|
||||
uint gx = 63 - p.x_coord;
|
||||
uint gy = 63 - p.y_coord;
|
||||
uint gx = 63 - p.X_coord;
|
||||
uint gy = 63 - p.Y_coord;
|
||||
|
||||
return Map.ExistMap(mapid, gx, gy) && Map.ExistVMap(mapid, gx, gy);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace Game.Maps
|
||||
creature.RemoveAllDynObjects();
|
||||
creature.RemoveAllAreaTriggers();
|
||||
|
||||
if (creature.IsInCombat() || !creature.GetThreatManager().areThreatListsEmpty())
|
||||
if (creature.IsInCombat() || !creature.GetThreatManager().IsThreatListsEmpty())
|
||||
{
|
||||
creature.CombatStop();
|
||||
creature.DeleteThreatList();
|
||||
|
||||
@@ -115,8 +115,8 @@ namespace Game.Maps
|
||||
|
||||
SplineRawInitializer initer = new SplineRawInitializer(allPoints);
|
||||
Spline orientationSpline = new Spline();
|
||||
orientationSpline.init_spline_custom(initer);
|
||||
orientationSpline.initLengths();
|
||||
orientationSpline.InitSplineCustom(initer);
|
||||
orientationSpline.InitLengths();
|
||||
|
||||
for (uint i = 0; i < path.Length; ++i)
|
||||
{
|
||||
@@ -204,12 +204,12 @@ namespace Game.Maps
|
||||
int extra = !keyFrames[i - 1].Teleport ? 1 : 0;
|
||||
Spline spline = new Spline();
|
||||
Span<Vector3> span = splinePath.ToArray();
|
||||
spline.Init_Spline(span.Slice(start), i - start + extra, Spline.EvaluationMode.Catmullrom);
|
||||
spline.initLengths();
|
||||
spline.InitSpline(span.Slice(start), i - start + extra, Spline.EvaluationMode.Catmullrom);
|
||||
spline.InitLengths();
|
||||
for (int j = start; j < i + extra; ++j)
|
||||
{
|
||||
keyFrames[j].Index = (uint)(j - start + 1);
|
||||
keyFrames[j].DistFromPrev = spline.length(j - start, j + 1 - start);
|
||||
keyFrames[j].DistFromPrev = spline.Length(j - start, j + 1 - start);
|
||||
if (j > 0)
|
||||
keyFrames[j - 1].NextDistFromPrev = keyFrames[j].DistFromPrev;
|
||||
keyFrames[j].Spline = spline;
|
||||
|
||||
Reference in New Issue
Block a user