Fixed the incorrect interpretation of the map-cell height information stored in .gat files; this was causing an overall of 20000 cells to be treated as water when officially they aren't.
A full mapcache rebuild is needed to apply this change. git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11982 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
7906017662
commit
a91d8177c6
@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
|
|||||||
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||||
|
|
||||||
2007/12/26
|
2007/12/26
|
||||||
|
* Fixed the incorrect interpretation of the map-cell height information
|
||||||
|
stored in .gat files; this was causing an overall of 20000 cells to
|
||||||
|
be treated as water when officially they aren't [ultramage]
|
||||||
* Fixed string variables dereferencing directly to the value instead of
|
* Fixed string variables dereferencing directly to the value instead of
|
||||||
dereferencing to a copy of the value. (fixes bugreport:684 bugreport:641) [FlavioJS]
|
dereferencing to a copy of the value. (fixes bugreport:684 bugreport:641) [FlavioJS]
|
||||||
2007/12/23
|
2007/12/23
|
||||||
|
@ -2474,33 +2474,38 @@ int map_waterheight(char* mapname)
|
|||||||
*----------------------------------*/
|
*----------------------------------*/
|
||||||
int map_readgat (struct map_data* m)
|
int map_readgat (struct map_data* m)
|
||||||
{
|
{
|
||||||
char fn[256];
|
char filename[256];
|
||||||
char *gat;
|
uint8* gat;
|
||||||
int wh,x,y,xs,ys;
|
int water_height;
|
||||||
struct gat_1cell {float high[4]; int type;} *p = NULL;
|
size_t xy, off, num_cells;
|
||||||
|
|
||||||
sprintf(fn, "data\\%s.gat", m->name);
|
sprintf(filename, "data\\%s.gat", m->name);
|
||||||
|
|
||||||
// read & convert fn
|
gat = (uint8 *) grfio_read(filename);
|
||||||
gat = (char *) grfio_read (fn);
|
|
||||||
if (gat == NULL)
|
if (gat == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
xs = m->xs = *(int*)(gat+6);
|
m->xs = *(int32*)(gat+6);
|
||||||
ys = m->ys = *(int*)(gat+10);
|
m->ys = *(int32*)(gat+10);
|
||||||
m->gat = (unsigned char *)aMallocA((xs * ys)*sizeof(unsigned char));
|
num_cells = m->xs * m->ys;
|
||||||
|
CREATE(m->gat, uint8, num_cells);
|
||||||
|
|
||||||
|
water_height = map_waterheight(m->name);
|
||||||
|
|
||||||
|
// Set cell properties
|
||||||
|
off = 14;
|
||||||
|
for( xy = 0; xy < num_cells; ++xy )
|
||||||
|
{
|
||||||
|
// read cell data
|
||||||
|
float height = *(float*)( gat + off );
|
||||||
|
uint32 type = *(uint32*)( gat + off + 16 );
|
||||||
|
off += 20;
|
||||||
|
|
||||||
|
if( type == 0 && water_height != NO_WATER && height > water_height )
|
||||||
|
type = 3; // Cell is 0 (walkable) but under water level, set to 3 (walkable water)
|
||||||
|
|
||||||
|
m->gat[xy] = (uint8)type;
|
||||||
|
|
||||||
wh = map_waterheight(m->name);
|
|
||||||
for (y = 0; y < ys; y++) {
|
|
||||||
p = (struct gat_1cell*)(gat+y*xs*20+14);
|
|
||||||
for (x = 0; x < xs; x++) {
|
|
||||||
if (wh != NO_WATER && p->type == 0)
|
|
||||||
// <20>…<EFBFBD>ê”»’è
|
|
||||||
m->gat[x+y*xs] = (p->high[0]>wh || p->high[1]>wh || p->high[2]>wh || p->high[3]>wh) ? 3 : 0;
|
|
||||||
else
|
|
||||||
m->gat[x+y*xs] = p->type;
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aFree(gat);
|
aFree(gat);
|
||||||
|
@ -110,7 +110,7 @@ int read_map(char *name, struct map_data *m)
|
|||||||
unsigned char *gat, *rsw;
|
unsigned char *gat, *rsw;
|
||||||
int water_height;
|
int water_height;
|
||||||
size_t xy, off, num_cells;
|
size_t xy, off, num_cells;
|
||||||
float height[4];
|
float height;
|
||||||
unsigned long type;
|
unsigned long type;
|
||||||
|
|
||||||
// Open map GAT
|
// Open map GAT
|
||||||
@ -140,18 +140,16 @@ int read_map(char *name, struct map_data *m)
|
|||||||
off = 14;
|
off = 14;
|
||||||
for (xy = 0; xy < num_cells; xy++)
|
for (xy = 0; xy < num_cells; xy++)
|
||||||
{
|
{
|
||||||
// Height of the corners
|
// Height of the bottom-left corner
|
||||||
height[0] = GetFloat( gat + off );
|
height = GetFloat( gat + off );
|
||||||
height[1] = GetFloat( gat + off + 4 );
|
|
||||||
height[2] = GetFloat( gat + off + 8 );
|
|
||||||
height[3] = GetFloat( gat + off + 12 );
|
|
||||||
// Type of cell
|
// Type of cell
|
||||||
type = GetULong( gat + off + 16 );
|
type = GetULong( gat + off + 16 );
|
||||||
off += 20;
|
off += 20;
|
||||||
if (water_height != NO_WATER && type == 0 && (height[0] > water_height || height[1] > water_height || height[2] > water_height || height[3] > water_height))
|
|
||||||
m->cells[xy] = 3; // Cell is 0 (walkable) but under water level, set to 3 (walkable water)
|
if (type == 0 && water_height != NO_WATER && height > water_height)
|
||||||
else
|
type = 3; // Cell is 0 (walkable) but under water level, set to 3 (walkable water)
|
||||||
m->cells[xy] = (unsigned char)type;
|
|
||||||
|
m->cells[xy] = (unsigned char)type;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(gat);
|
free(gat);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user