From ff2dd3a0c696cbcd659837ff736f927fab8937e3 Mon Sep 17 00:00:00 2001 From: ultramage Date: Fri, 4 Jan 2008 12:41:49 +0000 Subject: Modified the map_setcell() code to to use a boolean flag instead of needing SET_ / CLR_ pairs of defines (topic:174323). Also removed script object 'setcell', added script function 'setcell'. - Now you can manipulate cell information without needing @loadnpc - You can also manipulate the terrain ('gat') type itself, using the new cell_walkable, cell_shootable and cell_water constants (currently the implementation uses bit flags too, so to get the type you want, you need to adjust the flags one by one) - This breaks current scripts, so please adjust places that use setcell (also be sure to _only_ use predefined constants, not direct numbers) - Details can be found in the script reference. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12009 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/npc.c | 49 ++----------------------------------------------- 1 file changed, 2 insertions(+), 47 deletions(-) (limited to 'src/map/npc.c') diff --git a/src/map/npc.c b/src/map/npc.c index f18ba07a1..79747dbf3 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1970,7 +1970,7 @@ void npc_setcells(struct npc_data* nd) for (j = x-xs; j <= x+xs; j++) { if (map_getcell(m, j, i, CELL_CHKNOPASS)) continue; - map_setcell(m, j, i, CELL_SETNPC); + map_setcell(m, j, i, CELL_NPC, true); } } } @@ -2010,7 +2010,7 @@ void npc_unsetcells(struct npc_data* nd) //Erase this npc's cells for (i = y-ys; i <= y+ys; i++) for (j = x-xs; j <= x+xs; j++) - map_setcell(m, j, i, CELL_CLRNPC); + map_setcell(m, j, i, CELL_NPC, false); //Re-deploy NPC cells for other nearby npcs. map_foreachinarea( npc_unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id ); @@ -2512,47 +2512,6 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con return strchr(start,'\n');// continue } -/*========================================== - * Setting up map cells - *------------------------------------------*/ -static const char* npc_parse_mapcell(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) -{ - int m, cell, x, y, x0, y0, x1, y1; - char type[32], mapname[32]; - - // w1= - // w3=,,,, - if( sscanf(w1, "%31[^,]", mapname) != 1 - || sscanf(w3, "%31[^,],%d,%d,%d,%d", type, &x0, &y0, &x1, &y1) < 5 ) - { - ShowError("npc_parse_mapcell: Invalid mapcell definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); - return strchr(start,'\n');// skip and continue - } - m = map_mapname2mapid(mapname); - if( m < 0 ) - { - ShowWarning("npc_parse_mapcell: Unknown map in file '%s', line '%d' : %s\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", mapname, filepath, strline(buffer,start-buffer), w1, w2, w3, w4); - return strchr(start,'\n');// skip and continue - } - - cell = strtol(type, (char **)NULL, 0); - - if( x0 > x1 ) - swap(x0, x1); - if( y0 > y1 ) - swap(y0, y1); - - for( x = x0; x <= x1; ++x ) - for( y = y0; y <= y1; ++y ) - { - if( map_getcell(m, x, y, CELL_CHKWALL) || map_getcell(m, x, y, CELL_CHKCLIFF) ) - continue; - map_setcell(m, x, y, cell); - } - - return strchr(start,'\n');// continue -} - void npc_parsesrcfile(const char* filepath) { int m, lines = 0; @@ -2678,10 +2637,6 @@ void npc_parsesrcfile(const char* filepath) { p = npc_parse_mapflag(w1, w2, w3, w4, p, buffer, filepath); } - else if( strcmpi(w2,"setcell") == 0 && count >= 3 ) - { - p = npc_parse_mapcell(w1, w2, w3, w4, p, buffer, filepath); - } else { ShowError("npc_parsesrcfile: Unable to parse, probably a missing or extra TAB in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,p-buffer), w1, w2, w3, w4); -- cgit v1.2.3-60-g2f50