From 2b6f23670b3add2cb845b9606d13e6aad6360f11 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 3 Oct 2015 00:46:44 +0300 Subject: Add basic support for own collision types. --- src/emap/map.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'src/emap/map.c') diff --git a/src/emap/map.c b/src/emap/map.c index fc5e37d..97aa464 100644 --- a/src/emap/map.c +++ b/src/emap/map.c @@ -134,3 +134,82 @@ void emap_online_list(int fd) send_online_list(fd, buf, ptr - buf); aFree(buf); } + +int emap_getcellp(struct map_data* m, + const struct block_list *bl, + int16 *xPtr, int16 *yPtr, + cell_chk *cellchkPtr) +{ + if (bl) + { + const cell_chk cellchk = *cellchkPtr; + if (cellchk == CELL_CHKWALL || + cellchk == CELL_CHKPASS || + cellchk == CELL_CHKNOPASS || + cellchk == CELL_CHKNOREACH) + { + if (bl->type == BL_NPC) + { + } + } + } + return 0; +} + +struct mapcell emap_gat2cell(int *gatPtr) +{ + struct mapcell cell; + const int gat = *gatPtr; + + memset(&cell, 0, sizeof(struct mapcell)); + + switch (gat) + { + case 0: // walkable ground + cell.walkable = 1; + cell.shootable = 1; + cell.water = 0; + break; + case 1: // wall + cell.walkable = 0; + cell.shootable = 0; + cell.water = 0; + break; + case 2: // air allowed + cell.walkable = 0; + cell.shootable = 0; + cell.water = 0; + break; + case 3: // unwalkable water + cell.walkable = 0; + cell.shootable = 1; + cell.water = 1; + break; + case 4: // sit, walkable ground + cell.walkable = 1; + cell.shootable = 1; + cell.water = 0; + break; + default: + ShowWarning("map_gat2cell: unrecognized gat type '%d'\n", gat); + break; + } + + hookStop(); + return cell; +} + +int emap_cell2gat(struct mapcell *cellPtr) +{ + struct mapcell cell = *cellPtr; + hookStop(); + if (cell.walkable == 1 && cell.shootable == 1 && cell.water == 0) + return 0; + if (cell.walkable == 0 && cell.shootable == 0 && cell.water == 0) + return 1; + if (cell.walkable == 0 && cell.shootable == 1 && cell.water == 1) + return 3; + + ShowWarning("map_cell2gat: cell has no matching gat type\n"); + return 1; +} -- cgit v1.2.3-70-g09d2