diff options
author | glighta <glighta@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-12-30 16:00:24 +0000 |
---|---|---|
committer | glighta <glighta@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-12-30 16:00:24 +0000 |
commit | e81fad940ac591a6a76ecd0aa0b1d26cff688705 (patch) | |
tree | 03e7cad0b1bd243837b40cd5045957806291b992 /src/map/npc.c | |
parent | a31cce3c60cc170db0d4a8ff707626e8777b0801 (diff) | |
download | hercules-e81fad940ac591a6a76ecd0aa0b1d26cff688705.tar.gz hercules-e81fad940ac591a6a76ecd0aa0b1d26cff688705.tar.bz2 hercules-e81fad940ac591a6a76ecd0aa0b1d26cff688705.tar.xz hercules-e81fad940ac591a6a76ecd0aa0b1d26cff688705.zip |
-Harmonize skillid, skill_num, skillnum, skill, to skill_id and same for skill_lv
-Optimise type from int to int16 in order to reduce ram consumtion.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@17065 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r-- | src/map/npc.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/map/npc.c b/src/map/npc.c index 67eff6f8c..5d8a0274e 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -874,7 +874,7 @@ int npc_touchnext_areanpc(struct map_session_data* sd, bool leavemap) /*========================================== * Exec OnTouch for player if in range of area event *------------------------------------------*/ -int npc_touch_areanpc(struct map_session_data* sd, int m, int x, int y) +int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) { int xs,ys; int f = 1; @@ -1023,7 +1023,7 @@ int npc_touch_areanpc2(struct mob_data *md) //Flag determines the type of object to check for: //&1: NPC Warps //&2: NPCs with on-touch events. -int npc_check_areanpc(int flag, int m, int x, int y, int range) +int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range) { int i; int x0,y0,x1,y1; @@ -1734,7 +1734,7 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list) //This doesn't remove it from map_db int npc_remove_map(struct npc_data* nd) { - int m,i; + int16 m,i; nullpo_retr(1, nd); if(nd->bl.prev == NULL || nd->bl.m < 0) @@ -2045,11 +2045,11 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short nd->bl.m = from_mapid; nd->bl.x = from_x; nd->bl.y = from_y; - + safestrncpy(nd->exname, name, ARRAYLENGTH(nd->exname)); if (npc_name2id(nd->exname) != NULL) flag = 1; - + if (flag == 1) snprintf(nd->exname, ARRAYLENGTH(nd->exname), "warp_%d_%d_%d", from_mapid, from_x, from_y); @@ -2652,7 +2652,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch return end; } -int npc_duplicate4instance(struct npc_data *snd, int m) { +int npc_duplicate4instance(struct npc_data *snd, int16 m) { char newname[NAME_LENGTH]; if( map[m].instance_id == 0 ) @@ -2728,7 +2728,7 @@ int npc_duplicate4instance(struct npc_data *snd, int m) { //Set mapcell CELL_NPC to trigger event later void npc_setcells(struct npc_data* nd) { - int m = nd->bl.m, x = nd->bl.x, y = nd->bl.y, xs, ys; + int16 m = nd->bl.m, x = nd->bl.x, y = nd->bl.y, xs, ys; int i,j; switch(nd->subtype) @@ -2768,7 +2768,7 @@ int npc_unsetcells_sub(struct block_list* bl, va_list ap) void npc_unsetcells(struct npc_data* nd) { - int m = nd->bl.m, x = nd->bl.x, y = nd->bl.y, xs, ys; + int16 m = nd->bl.m, x = nd->bl.x, y = nd->bl.y, xs, ys; int i,j, x0, x1, y0, y1; if (nd->subtype == WARP) { @@ -2798,9 +2798,9 @@ void npc_unsetcells(struct npc_data* nd) map_foreachinarea( npc_unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id ); } -void npc_movenpc(struct npc_data* nd, int x, int y) +void npc_movenpc(struct npc_data* nd, int16 x, int16 y) { - const int m = nd->bl.m; + const int16 m = nd->bl.m; if (m < 0 || nd->bl.prev == NULL) return; //Not on a map. x = cap_value(x, 0, map[m].xs-1); @@ -3013,19 +3013,19 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c ShowError("npc_parse_mob: Invalid number of monsters %d, must be inside the range [1,1000] (file '%s', line '%d').\n", num, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue } - + if( (mob.state.size < 0 || mob.state.size > 2) && size != -1 ) { ShowError("npc_parse_mob: Invalid size number %d for mob ID %d (file '%s', line '%d').\n", mob.state.size, class_, filepath, strline(buffer, start - buffer)); return strchr(start, '\n'); } - + if( (mob.state.ai < 0 || mob.state.ai > 4) && ai != -1 ) { ShowError("npc_parse_mob: Invalid ai %d for mob ID %d (file '%s', line '%d').\n", mob.state.ai, class_, filepath, strline(buffer, start - buffer)); return strchr(start, '\n'); } - + if( (mob_lv == 0 || mob_lv > MAX_LEVEL) && mob_lv != -1 ) { ShowError("npc_parse_mob: Invalid level %d for mob ID %d (file '%s', line '%d').\n", mob_lv, class_, filepath, strline(buffer, start - buffer)); @@ -3140,7 +3140,7 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c *------------------------------------------*/ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) { - int m; + int16 m; char mapname[32]; int state = 1; @@ -3405,7 +3405,8 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con //@runOnInit should we exec OnInit when it's done ? void npc_parsesrcfile(const char* filepath, bool runOnInit) { - int m, x, y, lines = 0; + int16 m, x, y; + int lines = 0; FILE* fp; size_t len; char* buffer; @@ -3488,7 +3489,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit) {// w1 = <map name>,<x>,<y>,<facing> char mapname[MAP_NAME_LENGTH*2]; x = y = 0; - sscanf(w1,"%23[^,],%d,%d[^,]",mapname,&x,&y); + sscanf(w1,"%23[^,],%hd,%hd[^,]",mapname,&x,&y); if( !mapindex_name2id(mapname) ) {// Incorrect map, we must skip the script info... ShowError("npc_parsesrcfile: Unknown map '%s' in file '%s', line '%d'. Skipping line...\n", mapname, filepath, strline(buffer,p-buffer)); @@ -3654,14 +3655,14 @@ void npc_clear_pathlist(void) { //Clear then reload npcs files int npc_reload(void) { struct npc_src_list *nsl; - int m, i; + int16 m, i; int npc_new_min = npc_id; struct s_mapiterator* iter; struct block_list* bl; /* clear guild flag cache */ guild_flags_clear(); - + npc_clear_pathlist(); db_clear(npc_path_db); @@ -3794,7 +3795,7 @@ int do_final_npc(void) { static void npc_debug_warps_sub(struct npc_data* nd) { - int m; + int16 m; if (nd->bl.type != BL_NPC || nd->subtype != WARP || nd->bl.m < 0) return; @@ -3820,7 +3821,7 @@ static void npc_debug_warps_sub(struct npc_data* nd) static void npc_debug_warps(void) { - int m, i; + int16 m, i; for (m = 0; m < map_num; m++) for (i = 0; i < map[m].npc_num; i++) npc_debug_warps_sub(map[m].npc[i]); |