version 1.80, 2018/02/16 09:51:41 |
version 1.81, 2018/04/18 14:31:42 |
|
|
|
|
/* Check grid y position. */ |
/* Check grid y position. */ |
static int |
static int |
grid_check_y(struct grid *gd, u_int py) |
grid_check_y(struct grid *gd, const char* from, u_int py) |
{ |
{ |
if (py >= gd->hsize + gd->sy) { |
if (py >= gd->hsize + gd->sy) { |
log_debug("y out of range: %u", py); |
log_debug("%s: y out of range: %u", from, py); |
return (-1); |
return (-1); |
} |
} |
return (0); |
return (0); |
|
|
const struct grid_line * |
const struct grid_line * |
grid_peek_line(struct grid *gd, u_int py) |
grid_peek_line(struct grid *gd, u_int py) |
{ |
{ |
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, __func__, py) != 0) |
return (NULL); |
return (NULL); |
return (&gd->linedata[py]); |
return (&gd->linedata[py]); |
} |
} |
|
|
void |
void |
grid_get_cell(struct grid *gd, u_int px, u_int py, struct grid_cell *gc) |
grid_get_cell(struct grid *gd, u_int px, u_int py, struct grid_cell *gc) |
{ |
{ |
if (grid_check_y(gd, py) != 0 || px >= gd->linedata[py].cellsize) { |
if (grid_check_y(gd, __func__, py) != 0 || |
|
px >= gd->linedata[py].cellsize) { |
memcpy(gc, &grid_default_cell, sizeof *gc); |
memcpy(gc, &grid_default_cell, sizeof *gc); |
return; |
return; |
} |
} |
|
|
struct grid_line *gl; |
struct grid_line *gl; |
struct grid_cell_entry *gce; |
struct grid_cell_entry *gce; |
|
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, __func__, py) != 0) |
return; |
return; |
|
|
grid_expand_line(gd, py, px + 1, 8); |
grid_expand_line(gd, py, px + 1, 8); |
|
|
struct grid_cell *gcp; |
struct grid_cell *gcp; |
u_int i; |
u_int i; |
|
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, __func__, py) != 0) |
return; |
return; |
|
|
grid_expand_line(gd, py, px + slen, 8); |
grid_expand_line(gd, py, px + slen, 8); |
|
|
return; |
return; |
} |
} |
|
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, __func__, py) != 0) |
return; |
return; |
if (grid_check_y(gd, py + ny - 1) != 0) |
if (grid_check_y(gd, __func__, py + ny - 1) != 0) |
return; |
return; |
|
|
for (yy = py; yy < py + ny; yy++) { |
for (yy = py; yy < py + ny; yy++) { |
|
|
if (ny == 0) |
if (ny == 0) |
return; |
return; |
|
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, __func__, py) != 0) |
return; |
return; |
if (grid_check_y(gd, py + ny - 1) != 0) |
if (grid_check_y(gd, __func__, py + ny - 1) != 0) |
return; |
return; |
|
|
for (yy = py; yy < py + ny; yy++) { |
for (yy = py; yy < py + ny; yy++) { |
|
|
if (ny == 0 || py == dy) |
if (ny == 0 || py == dy) |
return; |
return; |
|
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, __func__, py) != 0) |
return; |
return; |
if (grid_check_y(gd, py + ny - 1) != 0) |
if (grid_check_y(gd, __func__, py + ny - 1) != 0) |
return; |
return; |
if (grid_check_y(gd, dy) != 0) |
if (grid_check_y(gd, __func__, dy) != 0) |
return; |
return; |
if (grid_check_y(gd, dy + ny - 1) != 0) |
if (grid_check_y(gd, __func__, dy + ny - 1) != 0) |
return; |
return; |
|
|
/* Free any lines which are being replaced. */ |
/* Free any lines which are being replaced. */ |
|
|
if (nx == 0 || px == dx) |
if (nx == 0 || px == dx) |
return; |
return; |
|
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, __func__, py) != 0) |
return; |
return; |
gl = &gd->linedata[py]; |
gl = &gd->linedata[py]; |
|
|