mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
Cleanup Operator padding
This commit is contained in:
parent
9141299127
commit
e32b9953a1
264 changed files with 6715 additions and 6715 deletions
|
|
@ -77,7 +77,7 @@ bool GridMap::loadData(char* filename)
|
|||
if (!in)
|
||||
return true;
|
||||
|
||||
fread(&header, sizeof(header),1,in);
|
||||
fread(&header, sizeof(header), 1, in);
|
||||
if (header.mapMagic == *((uint32 const*)(MAP_MAGIC)) &&
|
||||
header.versionMagic == *((uint32 const*)(MAP_VERSION_MAGIC)) &&
|
||||
IsAcceptableClientBuild(header.buildMagic))
|
||||
|
|
@ -151,8 +151,8 @@ bool GridMap::loadAreaData(FILE* in, uint32 offset, uint32 /*size*/)
|
|||
m_gridArea = header.gridArea;
|
||||
if (!(header.flags & MAP_AREA_NO_AREA))
|
||||
{
|
||||
m_area_map = new uint16 [16*16];
|
||||
fread(m_area_map, sizeof(uint16), 16*16, in);
|
||||
m_area_map = new uint16 [16 * 16];
|
||||
fread(m_area_map, sizeof(uint16), 16 * 16, in);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -171,28 +171,28 @@ bool GridMap::loadHeightData(FILE* in, uint32 offset, uint32 /*size*/)
|
|||
{
|
||||
if ((header.flags & MAP_HEIGHT_AS_INT16))
|
||||
{
|
||||
m_uint16_V9 = new uint16 [129*129];
|
||||
m_uint16_V8 = new uint16 [128*128];
|
||||
fread(m_uint16_V9, sizeof(uint16), 129*129, in);
|
||||
fread(m_uint16_V8, sizeof(uint16), 128*128, in);
|
||||
m_uint16_V9 = new uint16 [129 * 129];
|
||||
m_uint16_V8 = new uint16 [128 * 128];
|
||||
fread(m_uint16_V9, sizeof(uint16), 129 * 129, in);
|
||||
fread(m_uint16_V8, sizeof(uint16), 128 * 128, in);
|
||||
m_gridIntHeightMultiplier = (header.gridMaxHeight - header.gridHeight) / 65535;
|
||||
m_gridGetHeight = &GridMap::getHeightFromUint16;
|
||||
}
|
||||
else if ((header.flags & MAP_HEIGHT_AS_INT8))
|
||||
{
|
||||
m_uint8_V9 = new uint8 [129*129];
|
||||
m_uint8_V8 = new uint8 [128*128];
|
||||
fread(m_uint8_V9, sizeof(uint8), 129*129, in);
|
||||
fread(m_uint8_V8, sizeof(uint8), 128*128, in);
|
||||
m_uint8_V9 = new uint8 [129 * 129];
|
||||
m_uint8_V8 = new uint8 [128 * 128];
|
||||
fread(m_uint8_V9, sizeof(uint8), 129 * 129, in);
|
||||
fread(m_uint8_V8, sizeof(uint8), 128 * 128, in);
|
||||
m_gridIntHeightMultiplier = (header.gridMaxHeight - header.gridHeight) / 255;
|
||||
m_gridGetHeight = &GridMap::getHeightFromUint8;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_V9 = new float [129*129];
|
||||
m_V8 = new float [128*128];
|
||||
fread(m_V9, sizeof(float), 129*129, in);
|
||||
fread(m_V8, sizeof(float), 128*128, in);
|
||||
m_V9 = new float [129 * 129];
|
||||
m_V8 = new float [128 * 128];
|
||||
fread(m_V9, sizeof(float), 129 * 129, in);
|
||||
fread(m_V8, sizeof(float), 128 * 128, in);
|
||||
m_gridGetHeight = &GridMap::getHeightFromFloat;
|
||||
}
|
||||
}
|
||||
|
|
@ -219,14 +219,14 @@ bool GridMap::loadGridMapLiquidData(FILE* in, uint32 offset, uint32 /*size*/)
|
|||
|
||||
if (!(header.flags & MAP_LIQUID_NO_TYPE))
|
||||
{
|
||||
m_liquid_type = new uint8 [16*16];
|
||||
fread(m_liquid_type, sizeof(uint8), 16*16, in);
|
||||
m_liquid_type = new uint8 [16 * 16];
|
||||
fread(m_liquid_type, sizeof(uint8), 16 * 16, in);
|
||||
}
|
||||
|
||||
if (!(header.flags & MAP_LIQUID_NO_HEIGHT))
|
||||
{
|
||||
m_liquid_map = new float [m_liquid_width*m_liquid_height];
|
||||
fread(m_liquid_map, sizeof(float), m_liquid_width*m_liquid_height, in);
|
||||
m_liquid_map = new float [m_liquid_width * m_liquid_height];
|
||||
fread(m_liquid_map, sizeof(float), m_liquid_width * m_liquid_height, in);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -237,11 +237,11 @@ uint16 GridMap::getArea(float x, float y)
|
|||
if (!m_area_map)
|
||||
return m_gridArea;
|
||||
|
||||
x = 16 * (32 - x/SIZE_OF_GRIDS);
|
||||
y = 16 * (32 - y/SIZE_OF_GRIDS);
|
||||
x = 16 * (32 - x / SIZE_OF_GRIDS);
|
||||
y = 16 * (32 - y / SIZE_OF_GRIDS);
|
||||
int lx = (int)x & 15;
|
||||
int ly = (int)y & 15;
|
||||
return m_area_map[lx*16 + ly];
|
||||
return m_area_map[lx * 16 + ly];
|
||||
}
|
||||
|
||||
float GridMap::getHeightFromFlat(float /*x*/, float /*y*/) const
|
||||
|
|
@ -254,8 +254,8 @@ float GridMap::getHeightFromFloat(float x, float y) const
|
|||
if (!m_V8 || !m_V9)
|
||||
return m_gridHeight;
|
||||
|
||||
x = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS);
|
||||
y = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS);
|
||||
x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS);
|
||||
y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS);
|
||||
|
||||
int x_int = (int)x;
|
||||
int y_int = (int)y;
|
||||
|
|
@ -279,26 +279,26 @@ float GridMap::getHeightFromFloat(float x, float y) const
|
|||
// 2 - solve linear equation from triangle points
|
||||
// Calculate coefficients for solve h = a*x + b*y + c
|
||||
|
||||
float a,b,c;
|
||||
float a, b, c;
|
||||
// Select triangle:
|
||||
if (x+y < 1)
|
||||
if (x + y < 1)
|
||||
{
|
||||
if (x > y)
|
||||
{
|
||||
// 1 triangle (h1, h2, h5 points)
|
||||
float h1 = m_V9[(x_int)*129 + y_int];
|
||||
float h2 = m_V9[(x_int+1)*129 + y_int];
|
||||
float h5 = 2 * m_V8[x_int*128 + y_int];
|
||||
a = h2-h1;
|
||||
b = h5-h1-h2;
|
||||
float h1 = m_V9[(x_int) * 129 + y_int];
|
||||
float h2 = m_V9[(x_int + 1) * 129 + y_int];
|
||||
float h5 = 2 * m_V8[x_int * 128 + y_int];
|
||||
a = h2 - h1;
|
||||
b = h5 - h1 - h2;
|
||||
c = h1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 2 triangle (h1, h3, h5 points)
|
||||
float h1 = m_V9[x_int*129 + y_int ];
|
||||
float h3 = m_V9[x_int*129 + y_int+1];
|
||||
float h5 = 2 * m_V8[x_int*128 + y_int];
|
||||
float h1 = m_V9[x_int * 129 + y_int ];
|
||||
float h3 = m_V9[x_int * 129 + y_int + 1];
|
||||
float h5 = 2 * m_V8[x_int * 128 + y_int];
|
||||
a = h5 - h1 - h3;
|
||||
b = h3 - h1;
|
||||
c = h1;
|
||||
|
|
@ -309,9 +309,9 @@ float GridMap::getHeightFromFloat(float x, float y) const
|
|||
if (x > y)
|
||||
{
|
||||
// 3 triangle (h2, h4, h5 points)
|
||||
float h2 = m_V9[(x_int+1)*129 + y_int ];
|
||||
float h4 = m_V9[(x_int+1)*129 + y_int+1];
|
||||
float h5 = 2 * m_V8[x_int*128 + y_int];
|
||||
float h2 = m_V9[(x_int + 1) * 129 + y_int ];
|
||||
float h4 = m_V9[(x_int + 1) * 129 + y_int + 1];
|
||||
float h5 = 2 * m_V8[x_int * 128 + y_int];
|
||||
a = h2 + h4 - h5;
|
||||
b = h4 - h2;
|
||||
c = h5 - h4;
|
||||
|
|
@ -319,9 +319,9 @@ float GridMap::getHeightFromFloat(float x, float y) const
|
|||
else
|
||||
{
|
||||
// 4 triangle (h3, h4, h5 points)
|
||||
float h3 = m_V9[(x_int)*129 + y_int+1];
|
||||
float h4 = m_V9[(x_int+1)*129 + y_int+1];
|
||||
float h5 = 2 * m_V8[x_int*128 + y_int];
|
||||
float h3 = m_V9[(x_int) * 129 + y_int + 1];
|
||||
float h4 = m_V9[(x_int + 1) * 129 + y_int + 1];
|
||||
float h5 = 2 * m_V8[x_int * 128 + y_int];
|
||||
a = h4 - h3;
|
||||
b = h3 + h4 - h5;
|
||||
c = h5 - h4;
|
||||
|
|
@ -336,8 +336,8 @@ float GridMap::getHeightFromUint8(float x, float y) const
|
|||
if (!m_uint8_V8 || !m_uint8_V9)
|
||||
return m_gridHeight;
|
||||
|
||||
x = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS);
|
||||
y = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS);
|
||||
x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS);
|
||||
y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS);
|
||||
|
||||
int x_int = (int)x;
|
||||
int y_int = (int)y;
|
||||
|
|
@ -347,17 +347,17 @@ float GridMap::getHeightFromUint8(float x, float y) const
|
|||
y_int &= (MAP_RESOLUTION - 1);
|
||||
|
||||
int32 a, b, c;
|
||||
uint8* V9_h1_ptr = &m_uint8_V9[x_int*128 + x_int + y_int];
|
||||
if (x+y < 1)
|
||||
uint8* V9_h1_ptr = &m_uint8_V9[x_int * 128 + x_int + y_int];
|
||||
if (x + y < 1)
|
||||
{
|
||||
if (x > y)
|
||||
{
|
||||
// 1 triangle (h1, h2, h5 points)
|
||||
int32 h1 = V9_h1_ptr[ 0];
|
||||
int32 h2 = V9_h1_ptr[129];
|
||||
int32 h5 = 2 * m_uint8_V8[x_int*128 + y_int];
|
||||
a = h2-h1;
|
||||
b = h5-h1-h2;
|
||||
int32 h5 = 2 * m_uint8_V8[x_int * 128 + y_int];
|
||||
a = h2 - h1;
|
||||
b = h5 - h1 - h2;
|
||||
c = h1;
|
||||
}
|
||||
else
|
||||
|
|
@ -365,7 +365,7 @@ float GridMap::getHeightFromUint8(float x, float y) const
|
|||
// 2 triangle (h1, h3, h5 points)
|
||||
int32 h1 = V9_h1_ptr[0];
|
||||
int32 h3 = V9_h1_ptr[1];
|
||||
int32 h5 = 2 * m_uint8_V8[x_int*128 + y_int];
|
||||
int32 h5 = 2 * m_uint8_V8[x_int * 128 + y_int];
|
||||
a = h5 - h1 - h3;
|
||||
b = h3 - h1;
|
||||
c = h1;
|
||||
|
|
@ -378,7 +378,7 @@ float GridMap::getHeightFromUint8(float x, float y) const
|
|||
// 3 triangle (h2, h4, h5 points)
|
||||
int32 h2 = V9_h1_ptr[129];
|
||||
int32 h4 = V9_h1_ptr[130];
|
||||
int32 h5 = 2 * m_uint8_V8[x_int*128 + y_int];
|
||||
int32 h5 = 2 * m_uint8_V8[x_int * 128 + y_int];
|
||||
a = h2 + h4 - h5;
|
||||
b = h4 - h2;
|
||||
c = h5 - h4;
|
||||
|
|
@ -388,7 +388,7 @@ float GridMap::getHeightFromUint8(float x, float y) const
|
|||
// 4 triangle (h3, h4, h5 points)
|
||||
int32 h3 = V9_h1_ptr[ 1];
|
||||
int32 h4 = V9_h1_ptr[130];
|
||||
int32 h5 = 2 * m_uint8_V8[x_int*128 + y_int];
|
||||
int32 h5 = 2 * m_uint8_V8[x_int * 128 + y_int];
|
||||
a = h4 - h3;
|
||||
b = h3 + h4 - h5;
|
||||
c = h5 - h4;
|
||||
|
|
@ -396,7 +396,7 @@ float GridMap::getHeightFromUint8(float x, float y) const
|
|||
}
|
||||
|
||||
// Calculate height
|
||||
return (float)((a * x) + (b * y) + c)*m_gridIntHeightMultiplier + m_gridHeight;
|
||||
return (float)((a * x) + (b * y) + c) * m_gridIntHeightMultiplier + m_gridHeight;
|
||||
}
|
||||
|
||||
float GridMap::getHeightFromUint16(float x, float y) const
|
||||
|
|
@ -404,8 +404,8 @@ float GridMap::getHeightFromUint16(float x, float y) const
|
|||
if (!m_uint16_V8 || !m_uint16_V9)
|
||||
return m_gridHeight;
|
||||
|
||||
x = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS);
|
||||
y = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS);
|
||||
x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS);
|
||||
y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS);
|
||||
|
||||
int x_int = (int)x;
|
||||
int y_int = (int)y;
|
||||
|
|
@ -415,17 +415,17 @@ float GridMap::getHeightFromUint16(float x, float y) const
|
|||
y_int &= (MAP_RESOLUTION - 1);
|
||||
|
||||
int32 a, b, c;
|
||||
uint16* V9_h1_ptr = &m_uint16_V9[x_int*128 + x_int + y_int];
|
||||
if (x+y < 1)
|
||||
uint16* V9_h1_ptr = &m_uint16_V9[x_int * 128 + x_int + y_int];
|
||||
if (x + y < 1)
|
||||
{
|
||||
if (x > y)
|
||||
{
|
||||
// 1 triangle (h1, h2, h5 points)
|
||||
int32 h1 = V9_h1_ptr[ 0];
|
||||
int32 h2 = V9_h1_ptr[129];
|
||||
int32 h5 = 2 * m_uint16_V8[x_int*128 + y_int];
|
||||
a = h2-h1;
|
||||
b = h5-h1-h2;
|
||||
int32 h5 = 2 * m_uint16_V8[x_int * 128 + y_int];
|
||||
a = h2 - h1;
|
||||
b = h5 - h1 - h2;
|
||||
c = h1;
|
||||
}
|
||||
else
|
||||
|
|
@ -433,7 +433,7 @@ float GridMap::getHeightFromUint16(float x, float y) const
|
|||
// 2 triangle (h1, h3, h5 points)
|
||||
int32 h1 = V9_h1_ptr[0];
|
||||
int32 h3 = V9_h1_ptr[1];
|
||||
int32 h5 = 2 * m_uint16_V8[x_int*128 + y_int];
|
||||
int32 h5 = 2 * m_uint16_V8[x_int * 128 + y_int];
|
||||
a = h5 - h1 - h3;
|
||||
b = h3 - h1;
|
||||
c = h1;
|
||||
|
|
@ -446,7 +446,7 @@ float GridMap::getHeightFromUint16(float x, float y) const
|
|||
// 3 triangle (h2, h4, h5 points)
|
||||
int32 h2 = V9_h1_ptr[129];
|
||||
int32 h4 = V9_h1_ptr[130];
|
||||
int32 h5 = 2 * m_uint16_V8[x_int*128 + y_int];
|
||||
int32 h5 = 2 * m_uint16_V8[x_int * 128 + y_int];
|
||||
a = h2 + h4 - h5;
|
||||
b = h4 - h2;
|
||||
c = h5 - h4;
|
||||
|
|
@ -456,7 +456,7 @@ float GridMap::getHeightFromUint16(float x, float y) const
|
|||
// 4 triangle (h3, h4, h5 points)
|
||||
int32 h3 = V9_h1_ptr[ 1];
|
||||
int32 h4 = V9_h1_ptr[130];
|
||||
int32 h5 = 2 * m_uint16_V8[x_int*128 + y_int];
|
||||
int32 h5 = 2 * m_uint16_V8[x_int * 128 + y_int];
|
||||
a = h4 - h3;
|
||||
b = h3 + h4 - h5;
|
||||
c = h5 - h4;
|
||||
|
|
@ -464,7 +464,7 @@ float GridMap::getHeightFromUint16(float x, float y) const
|
|||
}
|
||||
|
||||
// Calculate height
|
||||
return (float)((a * x) + (b * y) + c)*m_gridIntHeightMultiplier + m_gridHeight;
|
||||
return (float)((a * x) + (b * y) + c) * m_gridIntHeightMultiplier + m_gridHeight;
|
||||
}
|
||||
|
||||
float GridMap::getLiquidLevel(float x, float y)
|
||||
|
|
@ -472,19 +472,19 @@ float GridMap::getLiquidLevel(float x, float y)
|
|||
if (!m_liquid_map)
|
||||
return m_liquidLevel;
|
||||
|
||||
x = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS);
|
||||
y = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS);
|
||||
x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS);
|
||||
y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS);
|
||||
|
||||
int cx_int = ((int)x & (MAP_RESOLUTION-1)) - m_liquid_offY;
|
||||
int cy_int = ((int)y & (MAP_RESOLUTION-1)) - m_liquid_offX;
|
||||
int cx_int = ((int)x & (MAP_RESOLUTION - 1)) - m_liquid_offY;
|
||||
int cy_int = ((int)y & (MAP_RESOLUTION - 1)) - m_liquid_offX;
|
||||
|
||||
if (cx_int < 0 || cx_int >=m_liquid_height)
|
||||
if (cx_int < 0 || cx_int >= m_liquid_height)
|
||||
return INVALID_HEIGHT_VALUE;
|
||||
|
||||
if (cy_int < 0 || cy_int >=m_liquid_width)
|
||||
if (cy_int < 0 || cy_int >= m_liquid_width)
|
||||
return INVALID_HEIGHT_VALUE;
|
||||
|
||||
return m_liquid_map[cx_int*m_liquid_width + cy_int];
|
||||
return m_liquid_map[cx_int * m_liquid_width + cy_int];
|
||||
}
|
||||
|
||||
uint8 GridMap::getTerrainType(float x, float y)
|
||||
|
|
@ -492,11 +492,11 @@ uint8 GridMap::getTerrainType(float x, float y)
|
|||
if (!m_liquid_type)
|
||||
return (uint8)m_liquidType;
|
||||
|
||||
x = 16 * (32 - x/SIZE_OF_GRIDS);
|
||||
y = 16 * (32 - y/SIZE_OF_GRIDS);
|
||||
x = 16 * (32 - x / SIZE_OF_GRIDS);
|
||||
y = 16 * (32 - y / SIZE_OF_GRIDS);
|
||||
int lx = (int)x & 15;
|
||||
int ly = (int)y & 15;
|
||||
return m_liquid_type[lx*16 + ly];
|
||||
return m_liquid_type[lx * 16 + ly];
|
||||
}
|
||||
|
||||
// Get water state on map
|
||||
|
|
@ -507,33 +507,33 @@ GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 Re
|
|||
return LIQUID_MAP_NO_WATER;
|
||||
|
||||
// Get cell
|
||||
float cx = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS);
|
||||
float cy = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS);
|
||||
float cx = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS);
|
||||
float cy = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS);
|
||||
|
||||
int x_int = (int)cx & (MAP_RESOLUTION-1);
|
||||
int y_int = (int)cy & (MAP_RESOLUTION-1);
|
||||
int x_int = (int)cx & (MAP_RESOLUTION - 1);
|
||||
int y_int = (int)cy & (MAP_RESOLUTION - 1);
|
||||
|
||||
// Check water type in cell
|
||||
uint8 type = m_liquid_type ? m_liquid_type[(x_int>>3)*16 + (y_int>>3)] : m_liquidType;
|
||||
uint8 type = m_liquid_type ? m_liquid_type[(x_int >> 3) * 16 + (y_int >> 3)] : m_liquidType;
|
||||
if (type == 0)
|
||||
return LIQUID_MAP_NO_WATER;
|
||||
|
||||
// Check req liquid type mask
|
||||
if (ReqLiquidType && !(ReqLiquidType&type))
|
||||
if (ReqLiquidType && !(ReqLiquidType & type))
|
||||
return LIQUID_MAP_NO_WATER;
|
||||
|
||||
// Check water level:
|
||||
// Check water height map
|
||||
int lx_int = x_int - m_liquid_offY;
|
||||
if (lx_int < 0 || lx_int >=m_liquid_height)
|
||||
if (lx_int < 0 || lx_int >= m_liquid_height)
|
||||
return LIQUID_MAP_NO_WATER;
|
||||
|
||||
int ly_int = y_int - m_liquid_offX;
|
||||
if (ly_int < 0 || ly_int >=m_liquid_width)
|
||||
if (ly_int < 0 || ly_int >= m_liquid_width)
|
||||
return LIQUID_MAP_NO_WATER;
|
||||
|
||||
// Get water level
|
||||
float liquid_level = m_liquid_map ? m_liquid_map[lx_int*m_liquid_width + ly_int] : m_liquidLevel;
|
||||
float liquid_level = m_liquid_map ? m_liquid_map[lx_int * m_liquid_width + ly_int] : m_liquidLevel;
|
||||
|
||||
// Get ground level (sub 0.2 for fix some errors)
|
||||
float ground_level = getHeight(x, y);
|
||||
|
|
@ -566,17 +566,17 @@ GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 Re
|
|||
return LIQUID_MAP_ABOVE_WATER;
|
||||
}
|
||||
|
||||
bool GridMap::ExistMap(uint32 mapid,int gx,int gy)
|
||||
bool GridMap::ExistMap(uint32 mapid, int gx, int gy)
|
||||
{
|
||||
int len = sWorld.GetDataPath().length()+strlen("maps/%03u%02u%02u.map")+1;
|
||||
int len = sWorld.GetDataPath().length() + strlen("maps/%03u%02u%02u.map") + 1;
|
||||
char* tmp = new char[len];
|
||||
snprintf(tmp, len, (char*)(sWorld.GetDataPath()+"maps/%03u%02u%02u.map").c_str(),mapid,gx,gy);
|
||||
snprintf(tmp, len, (char*)(sWorld.GetDataPath() + "maps/%03u%02u%02u.map").c_str(), mapid, gx, gy);
|
||||
|
||||
FILE* pf=fopen(tmp,"rb");
|
||||
FILE* pf = fopen(tmp, "rb");
|
||||
|
||||
if (!pf)
|
||||
{
|
||||
sLog.outError("Check existing of map file '%s': not exist!",tmp);
|
||||
sLog.outError("Check existing of map file '%s': not exist!", tmp);
|
||||
delete[] tmp;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -587,7 +587,7 @@ bool GridMap::ExistMap(uint32 mapid,int gx,int gy)
|
|||
header.versionMagic != *((uint32 const*)(MAP_VERSION_MAGIC)) ||
|
||||
!IsAcceptableClientBuild(header.buildMagic))
|
||||
{
|
||||
sLog.outError("Map file '%s' is non-compatible version (outdated?). Please, create new using ad.exe program.",tmp);
|
||||
sLog.outError("Map file '%s' is non-compatible version (outdated?). Please, create new using ad.exe program.", tmp);
|
||||
delete [] tmp;
|
||||
fclose(pf); //close file before return
|
||||
return false;
|
||||
|
|
@ -598,18 +598,18 @@ bool GridMap::ExistMap(uint32 mapid,int gx,int gy)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GridMap::ExistVMap(uint32 mapid,int gx,int gy)
|
||||
bool GridMap::ExistVMap(uint32 mapid, int gx, int gy)
|
||||
{
|
||||
if (VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager())
|
||||
{
|
||||
if (vmgr->isMapLoadingEnabled())
|
||||
{
|
||||
// x and y are swapped !! => fixed now
|
||||
bool exists = vmgr->existsMap((sWorld.GetDataPath()+ "vmaps").c_str(), mapid, gx,gy);
|
||||
bool exists = vmgr->existsMap((sWorld.GetDataPath() + "vmaps").c_str(), mapid, gx, gy);
|
||||
if (!exists)
|
||||
{
|
||||
std::string name = vmgr->getDirFileName(mapid,gx,gy);
|
||||
sLog.outError("VMap file '%s' is missing or point to wrong version vmap file, redo vmaps with latest vmap_assembler.exe program", (sWorld.GetDataPath()+"vmaps/"+name).c_str());
|
||||
std::string name = vmgr->getDirFileName(mapid, gx, gy);
|
||||
sLog.outError("VMap file '%s' is missing or point to wrong version vmap file, redo vmaps with latest vmap_assembler.exe program", (sWorld.GetDataPath() + "vmaps/" + name).c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -747,7 +747,7 @@ float TerrainInfo::GetHeight(float x, float y, float z, bool pUseVmaps, float ma
|
|||
float z2 = z + 2.f;
|
||||
if (GridMap* gmap = const_cast<TerrainInfo*>(this)->GetGrid(x, y))
|
||||
{
|
||||
float _mapheight = gmap->getHeight(x,y);
|
||||
float _mapheight = gmap->getHeight(x, y);
|
||||
|
||||
// look from a bit higher pos to find the floor, ignore under surface case
|
||||
if (z2 > _mapheight)
|
||||
|
|
@ -790,7 +790,7 @@ float TerrainInfo::GetHeight(float x, float y, float z, bool pUseVmaps, float ma
|
|||
|
||||
// we are already under the surface or vmap height above map heigt
|
||||
// or if the distance of the vmap height is less the land height distance
|
||||
if (z < mapHeight || vmapHeight > mapHeight || fabs(mapHeight-z) > fabs(vmapHeight-z))
|
||||
if (z < mapHeight || vmapHeight > mapHeight || fabs(mapHeight - z) > fabs(vmapHeight - z))
|
||||
return vmapHeight;
|
||||
else
|
||||
return mapHeight; // better use .map surface height
|
||||
|
|
@ -816,14 +816,14 @@ inline bool IsOutdoorWMO(uint32 mogpFlags, int32 adtId, int32 rootId, int32 grou
|
|||
return false;
|
||||
}
|
||||
|
||||
outdoor = mogpFlags&0x8;
|
||||
outdoor = mogpFlags & 0x8;
|
||||
|
||||
if (wmoEntry)
|
||||
{
|
||||
if (wmoEntry->Flags & 4)
|
||||
return true;
|
||||
|
||||
if ((wmoEntry->Flags & 2)!=0)
|
||||
if ((wmoEntry->Flags & 2) != 0)
|
||||
outdoor = false;
|
||||
}
|
||||
return outdoor;
|
||||
|
|
@ -839,7 +839,7 @@ bool TerrainInfo::IsOutdoors(float x, float y, float z) const
|
|||
return true;
|
||||
|
||||
AreaTableEntry const* atEntry = 0;
|
||||
WMOAreaTableEntry const* wmoEntry= GetWMOAreaTableEntryByTripple(rootId, adtId, groupId);
|
||||
WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(rootId, adtId, groupId);
|
||||
if (wmoEntry)
|
||||
{
|
||||
DEBUG_LOG("Got WMOAreaTableEntry! flag %u, areaid %u", wmoEntry->Flags, wmoEntry->areaId);
|
||||
|
|
@ -859,7 +859,7 @@ bool TerrainInfo::GetAreaInfo(float x, float y, float z, uint32& flags, int32& a
|
|||
// check if there's terrain between player height and object height
|
||||
if (GridMap* gmap = const_cast<TerrainInfo*>(this)->GetGrid(x, y))
|
||||
{
|
||||
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 > vmap_z)
|
||||
return false;
|
||||
|
|
@ -917,17 +917,17 @@ uint8 TerrainInfo::GetTerrainType(float x, float y) const
|
|||
|
||||
uint32 TerrainInfo::GetAreaId(float x, float y, float z) const
|
||||
{
|
||||
return TerrainManager::GetAreaIdByAreaFlag(GetAreaFlag(x,y,z),m_mapId);
|
||||
return TerrainManager::GetAreaIdByAreaFlag(GetAreaFlag(x, y, z), m_mapId);
|
||||
}
|
||||
|
||||
uint32 TerrainInfo::GetZoneId(float x, float y, float z) const
|
||||
{
|
||||
return TerrainManager::GetZoneIdByAreaFlag(GetAreaFlag(x,y,z),m_mapId);
|
||||
return TerrainManager::GetZoneIdByAreaFlag(GetAreaFlag(x, y, z), m_mapId);
|
||||
}
|
||||
|
||||
void TerrainInfo::GetZoneAndAreaId(uint32& zoneid, uint32& areaid, float x, float y, float z) const
|
||||
{
|
||||
TerrainManager::GetZoneAndAreaIdByAreaFlag(zoneid,areaid,GetAreaFlag(x,y,z),m_mapId);
|
||||
TerrainManager::GetZoneAndAreaIdByAreaFlag(zoneid, areaid, GetAreaFlag(x, y, z), m_mapId);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -999,7 +999,7 @@ bool TerrainInfo::IsUnderWater(float x, float y, float z) const
|
|||
{
|
||||
if (const_cast<TerrainInfo*>(this)->GetGrid(x, y))
|
||||
{
|
||||
if (getLiquidStatus(x, y, z, MAP_LIQUID_TYPE_WATER|MAP_LIQUID_TYPE_OCEAN)&LIQUID_MAP_UNDER_WATER)
|
||||
if (getLiquidStatus(x, y, z, MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN)&LIQUID_MAP_UNDER_WATER)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -1038,8 +1038,8 @@ float TerrainInfo::GetWaterOrGroundLevel(float x, float y, float z, float* pGrou
|
|||
GridMap* TerrainInfo::GetGrid(const float x, const float y)
|
||||
{
|
||||
// half opt method
|
||||
int gx=(int)(32-x/SIZE_OF_GRIDS); //grid x
|
||||
int gy=(int)(32-y/SIZE_OF_GRIDS); //grid y
|
||||
int gx = (int)(32 - x / SIZE_OF_GRIDS); //grid x
|
||||
int gy = (int)(32 - y / SIZE_OF_GRIDS); //grid y
|
||||
|
||||
//quick check if GridMap already loaded
|
||||
GridMap* pMap = m_GridMaps[gx][gy];
|
||||
|
|
@ -1061,11 +1061,11 @@ GridMap* TerrainInfo::LoadMapAndVMap(const uint32 x, const uint32 y)
|
|||
GridMap* map = new GridMap();
|
||||
|
||||
// map file name
|
||||
char* tmp=NULL;
|
||||
int len = sWorld.GetDataPath().length()+strlen("maps/%03u%02u%02u.map")+1;
|
||||
char* tmp = NULL;
|
||||
int len = sWorld.GetDataPath().length() + strlen("maps/%03u%02u%02u.map") + 1;
|
||||
tmp = new char[len];
|
||||
snprintf(tmp, len, (char*)(sWorld.GetDataPath()+"maps/%03u%02u%02u.map").c_str(),m_mapId, x, y);
|
||||
sLog.outDetail("Loading map %s",tmp);
|
||||
snprintf(tmp, len, (char*)(sWorld.GetDataPath() + "maps/%03u%02u%02u.map").c_str(), m_mapId, x, y);
|
||||
sLog.outDetail("Loading map %s", tmp);
|
||||
|
||||
if (!map->loadData(tmp))
|
||||
{
|
||||
|
|
@ -1080,17 +1080,17 @@ GridMap* TerrainInfo::LoadMapAndVMap(const uint32 x, const uint32 y)
|
|||
const MapEntry* i_mapEntry = sMapStore.LookupEntry(m_mapId);
|
||||
const char* mapName = i_mapEntry ? i_mapEntry->name[sWorld.GetDefaultDbcLocale()] : "UNNAMEDMAP\x0";
|
||||
|
||||
int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapManager()->loadMap((sWorld.GetDataPath()+ "vmaps").c_str(), m_mapId, x, y);
|
||||
int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapManager()->loadMap((sWorld.GetDataPath() + "vmaps").c_str(), m_mapId, x, y);
|
||||
switch (vmapLoadResult)
|
||||
{
|
||||
case VMAP::VMAP_LOAD_RESULT_OK:
|
||||
sLog.outDetail("VMAP loaded name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x,y,x,y);
|
||||
sLog.outDetail("VMAP loaded name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x, y, x, y);
|
||||
break;
|
||||
case VMAP::VMAP_LOAD_RESULT_ERROR:
|
||||
sLog.outDetail("Could not load VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x,y,x,y);
|
||||
sLog.outDetail("Could not load VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x, y, x, y);
|
||||
break;
|
||||
case VMAP::VMAP_LOAD_RESULT_IGNORED:
|
||||
DEBUG_LOG("Ignored VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x,y,x,y);
|
||||
DEBUG_LOG("Ignored VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x, y, x, y);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1191,9 +1191,9 @@ void TerrainManager::UnloadAll()
|
|||
i_TerrainMap.clear();
|
||||
}
|
||||
|
||||
uint32 TerrainManager::GetAreaIdByAreaFlag(uint16 areaflag,uint32 map_id)
|
||||
uint32 TerrainManager::GetAreaIdByAreaFlag(uint16 areaflag, uint32 map_id)
|
||||
{
|
||||
AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag,map_id);
|
||||
AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag, map_id);
|
||||
|
||||
if (entry)
|
||||
return entry->ID;
|
||||
|
|
@ -1201,9 +1201,9 @@ uint32 TerrainManager::GetAreaIdByAreaFlag(uint16 areaflag,uint32 map_id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint32 TerrainManager::GetZoneIdByAreaFlag(uint16 areaflag,uint32 map_id)
|
||||
uint32 TerrainManager::GetZoneIdByAreaFlag(uint16 areaflag, uint32 map_id)
|
||||
{
|
||||
AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag,map_id);
|
||||
AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag, map_id);
|
||||
|
||||
if (entry)
|
||||
return (entry->zone != 0) ? entry->zone : entry->ID;
|
||||
|
|
@ -1211,9 +1211,9 @@ uint32 TerrainManager::GetZoneIdByAreaFlag(uint16 areaflag,uint32 map_id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void TerrainManager::GetZoneAndAreaIdByAreaFlag(uint32& zoneid, uint32& areaid, uint16 areaflag,uint32 map_id)
|
||||
void TerrainManager::GetZoneAndAreaIdByAreaFlag(uint32& zoneid, uint32& areaid, uint16 areaflag, uint32 map_id)
|
||||
{
|
||||
AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag,map_id);
|
||||
AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag, map_id);
|
||||
|
||||
areaid = entry ? entry->ID : 0;
|
||||
zoneid = entry ? ((entry->zone != 0) ? entry->zone : entry->ID) : 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue