summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-01-04 12:41:49 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-01-04 12:41:49 +0000
commitff2dd3a0c696cbcd659837ff736f927fab8937e3 (patch)
tree03aec2e46cbd950af34cfcb4995580e6a1deeae4 /src/map/map.c
parent1903717ee1d6f3d7834b8ed807cf40f52364129b (diff)
downloadhercules-ff2dd3a0c696cbcd659837ff736f927fab8937e3.tar.gz
hercules-ff2dd3a0c696cbcd659837ff736f927fab8937e3.tar.bz2
hercules-ff2dd3a0c696cbcd659837ff736f927fab8937e3.tar.xz
hercules-ff2dd3a0c696cbcd659837ff736f927fab8937e3.zip
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
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 2d11b5725..bc5235192 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -468,7 +468,7 @@ int map_count_oncell(int m, int x, int y, int type)
/*
* «»«E¾ªÎõÌôøªË̸ªÄª±ª¿«¹«­«Eæ«Ë«Ã«ÈªòÚ÷ª¹
*/
-struct skill_unit *map_find_skill_unit_oncell(struct block_list *target,int x,int y,int skill_id,struct skill_unit *out_unit)
+struct skill_unit* map_find_skill_unit_oncell(struct block_list* target,int x,int y,int skill_id,struct skill_unit* out_unit)
{
int m,bx,by;
struct block_list *bl;
@@ -485,10 +485,11 @@ struct skill_unit *map_find_skill_unit_oncell(struct block_list *target,int x,in
{
if (bl->x != x || bl->y != y || bl->type != BL_SKILL)
continue;
+
unit = (struct skill_unit *) bl;
- if (unit==out_unit || !unit->alive || !unit->group || unit->group->skill_id!=skill_id)
+ if( unit == out_unit || !unit->alive || !unit->group || unit->group->skill_id != skill_id )
continue;
- if (battle_check_target(&unit->bl,target,unit->group->target_flag)>0)
+ if( battle_check_target(&unit->bl,target,unit->group->target_flag) > 0 )
return unit;
}
return NULL;
@@ -2136,12 +2137,12 @@ static int map_cell2gat(struct mapcell cell)
/*==========================================
* (m,x,y)‚Ìó‘Ԃ𒲂ׂé
*------------------------------------------*/
-int map_getcell(int m,int x,int y,cell_t cellchk)
+int map_getcell(int m,int x,int y,cell_chk cellchk)
{
return (m < 0 || m >= MAX_MAP_PER_SERVER) ? 0 : map_getcellp(&map[m],x,y,cellchk);
}
-int map_getcellp(struct map_data* m,int x,int y,cell_t cellchk)
+int map_getcellp(struct map_data* m,int x,int y,cell_chk cellchk)
{
struct mapcell cell;
@@ -2149,10 +2150,7 @@ int map_getcellp(struct map_data* m,int x,int y,cell_t cellchk)
//NOTE: this intentionally overrides the last row and column
if(x<0 || x>=m->xs-1 || y<0 || y>=m->ys-1)
- {
- if(cellchk==CELL_CHKNOPASS) return 1;
- return 0;
- }
+ return( cellchk == CELL_CHKNOPASS );
cell = m->cell[x + y*m->xs];
@@ -2213,28 +2211,31 @@ int map_getcellp(struct map_data* m,int x,int y,cell_t cellchk)
}
/*==========================================
- * (m,x,y)‚Ìó‘Ô‚ðÝ’è‚·‚é
+ * Change the type/flags of a map cell
+ * 'cell' - which flag to modify
+ * 'flag' - true = on, false = off
*------------------------------------------*/
-void map_setcell(int m,int x,int y,int cell)
+void map_setcell(int m, int x, int y, cell_t cell, bool flag)
{
int j;
- if(x<0 || x>=map[m].xs || y<0 || y>=map[m].ys)
+
+ if( m < 0 || m >= map_num || x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys )
return;
- j=x+y*map[m].xs;
-
- switch (cell) {
- case CELL_SETNPC: map[m].cell[j].npc = 1; break;
- case CELL_CLRNPC: map[m].cell[j].npc = 0; break;
- case CELL_SETICEWALL: map[m].cell[j].icewall = 1; break;
- case CELL_CLRICEWALL: map[m].cell[j].icewall = 0; break;
- case CELL_SETBASILICA: map[m].cell[j].basilica = 1; break;
- case CELL_CLRBASILICA: map[m].cell[j].basilica = 0; break;
- case CELL_SETLANDPROTECTOR: map[m].cell[j].landprotector = 1; break;
- case CELL_CLRLANDPROTECTOR: map[m].cell[j].landprotector = 0; break;
- case CELL_SETNOVENDING: map[m].cell[j].novending = 1; break;
- case CELL_CLRNOVENDING: map[m].cell[j].novending = 0; break;
+
+ j = x + y*map[m].xs;
+
+ switch( cell ) {
+ case CELL_WALKABLE: map[m].cell[j].walkable = flag; break;
+ case CELL_SHOOTABLE: map[m].cell[j].shootable = flag; break;
+ case CELL_WATER: map[m].cell[j].water = flag; break;
+
+ case CELL_NPC: map[m].cell[j].npc = flag; break;
+ case CELL_ICEWALL: map[m].cell[j].icewall = flag; break;
+ case CELL_BASILICA: map[m].cell[j].basilica = flag; break;
+ case CELL_LANDPROTECTOR: map[m].cell[j].landprotector = flag; break;
+ case CELL_NOVENDING: map[m].cell[j].novending = flag; break;
default:
- //map[m].gat[j] = cell; FIXME
+ ShowWarning("map_setcell: invalid cell type '%d'\n", (int)cell);
break;
}
}