diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/mob.c | 9 | ||||
-rw-r--r-- | src/map/npc.c | 85 | ||||
-rw-r--r-- | src/map/npc.h | 3 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc | 12 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc | 3 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 80 |
6 files changed, 141 insertions, 51 deletions
diff --git a/src/map/mob.c b/src/map/mob.c index cb22f71c0..629653c8d 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -141,14 +141,9 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time) if ( md->tomb_nid ) mob->mvptomb_destroy(md); - CREATE(nd, struct npc_data, 1); - - nd->bl.id = md->tomb_nid = npc->get_new_npc_id(); - + nd = npc->create_npc(md->bl.m, md->bl.x, md->bl.y); + md->tomb_nid = nd->bl.id; nd->dir = md->ud.dir; - nd->bl.m = md->bl.m; - nd->bl.x = md->bl.x; - nd->bl.y = md->bl.y; nd->bl.type = BL_NPC; safestrncpy(nd->name, msg_txt(856), sizeof(nd->name)); // "Tomb" diff --git a/src/map/npc.c b/src/map/npc.c index ce668bfae..8c2f61d58 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2495,18 +2495,27 @@ bool npc_viewisid(const char * viewid) return true; } +struct npc_data* npc_create_npc(int m, int x, int y) +{ + struct npc_data *nd; + + CREATE(nd, struct npc_data, 1); + nd->bl.id = npc->get_new_npc_id(); + nd->bl.prev = nd->bl.next = NULL; + nd->bl.m = m; + nd->bl.x = x; + nd->bl.y = y; + + return nd; +} + //Add then display an npc warp on map struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y) { int i, flag = 0; struct npc_data *nd; - CREATE(nd, struct npc_data, 1); - nd->bl.id = npc->get_new_npc_id(); + nd = npc->create_npc(from_mapid, from_x, from_y); map->addnpc(from_mapid, nd); - nd->bl.prev = nd->bl.next = NULL; - 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) @@ -2574,14 +2583,8 @@ const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* s return strchr(start,'\n');;//try next } - CREATE(nd, struct npc_data, 1); - - nd->bl.id = npc->get_new_npc_id(); + nd = npc->create_npc(m, x, y); map->addnpc(m, nd); - nd->bl.prev = nd->bl.next = NULL; - nd->bl.m = m; - nd->bl.x = x; - nd->bl.y = y; npc->parsename(nd, w3, start, buffer, filepath); if (!battle_config.warp_point_debug) @@ -2716,17 +2719,12 @@ const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* s return strchr(start,'\n');// continue } - CREATE(nd, struct npc_data, 1); + nd = npc->create_npc(m, x, y); CREATE(nd->u.shop.shop_item, struct npc_item_list, i); memcpy(nd->u.shop.shop_item, items, sizeof(items[0])*i); aFree(items); nd->u.shop.count = i; - nd->bl.prev = nd->bl.next = NULL; - nd->bl.m = m; - nd->bl.x = x; - nd->bl.y = y; - nd->bl.id = npc->get_new_npc_id(); npc->parsename(nd, w3, start, buffer, filepath); nd->class_ = m == -1 ? -1 : npc->parseview(w4, start, buffer, filepath); nd->speed = 200; @@ -2890,8 +2888,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* npc->convertlabel_db(label_list,filepath); } - CREATE(nd, struct npc_data, 1); - + nd = npc->create_npc(m, x, y); if( sscanf(w4, "%*[^,],%d,%d", &xs, &ys) == 2 ) {// OnTouch area defined nd->u.scr.xs = xs; @@ -2903,12 +2900,7 @@ const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* nd->u.scr.ys = -1; } - nd->bl.prev = nd->bl.next = NULL; - nd->bl.m = m; - nd->bl.x = x; - nd->bl.y = y; npc->parsename(nd, w3, start, buffer, filepath); - nd->bl.id = npc->get_new_npc_id(); nd->class_ = m == -1 ? -1 : npc->parseview(w4, start, buffer, filepath); nd->speed = 200; nd->u.scr.script = scriptroot; @@ -3040,14 +3032,8 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch return end;// next line, try to continue } - CREATE(nd, struct npc_data, 1); - - nd->bl.prev = nd->bl.next = NULL; - nd->bl.m = m; - nd->bl.x = x; - nd->bl.y = y; + nd = npc->create_npc(m, x, y); npc->parsename(nd, w3, start, buffer, filepath); - nd->bl.id = npc->get_new_npc_id(); nd->class_ = m == -1 ? -1 : npc->parseview(w4, start, buffer, filepath); nd->speed = 200; nd->src_id = src_id; @@ -3159,13 +3145,8 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) { return 1; } - CREATE(wnd, struct npc_data, 1); - wnd->bl.id = npc->get_new_npc_id(); + wnd = npc->create_npc(m, snd->bl.x, snd->bl.y); map->addnpc(m, wnd); - wnd->bl.prev = wnd->bl.next = NULL; - wnd->bl.m = m; - wnd->bl.x = snd->bl.x; - wnd->bl.y = snd->bl.y; safestrncpy(wnd->name, "", ARRAYLENGTH(wnd->name)); safestrncpy(wnd->exname, newname, ARRAYLENGTH(wnd->exname)); wnd->class_ = WARP_CLASS; @@ -3606,6 +3587,14 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st return strchr(start,'\n');// continue } + +void npc_parse_unknown_mapflag(const char *name, char *w3, char *w4, const char* start, const char* buffer, const char* filepath, int *retval) +{ + ShowError("npc_parse_mapflag: unrecognized mapflag '%s' in file '%s', line '%d'.\n", w3, filepath, strline(buffer,start-buffer)); + if (retval) + *retval = EXIT_FAILURE; +} + /*========================================== * Set or disable mapflag on map * eg : bat_c01<TAB>mapflag<TAB>battleground<TAB>2 @@ -4013,13 +4002,20 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char } else if ( !strcmpi(w3,"nocashshop") ) { map->list[m].flag.nocashshop = (state) ? 1 : 0; } else { - ShowError("npc_parse_mapflag: unrecognized mapflag '%s' in file '%s', line '%d'.\n", w3, filepath, strline(buffer,start-buffer)); - if (retval) *retval = EXIT_FAILURE; + npc->parse_unknown_mapflag(mapname, w3, w4, start, buffer, filepath, retval); } return strchr(start,'\n');// continue } +const char* npc_parse_unknown_object(char *w1, char *w2, char *w3, char *w4, const char* start, const char* buffer, const char* filepath, int *retval) +{ + 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,start-buffer), w1, w2, w3, w4); + start = strchr(start,'\n');// skip and continue + *retval = EXIT_FAILURE; + return start; +} + /** * Parses a script file and creates NPCs/functions/mapflags/monsters/etc * accordingly. @@ -4208,9 +4204,7 @@ int npc_parsesrcfile(const char* filepath, bool runOnInit) { } 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); - p = strchr(p,'\n');// skip and continue - success = EXIT_FAILURE; + p = npc->parse_unknown_object(w1, w2, w3, w4, p, buffer, filepath, &success); } } aFree(buffer); @@ -4663,6 +4657,7 @@ void npc_defaults(void) { npc->parsename = npc_parsename; npc->parseview = npc_parseview; npc->viewisid = npc_viewisid; + npc->create_npc = npc_create_npc; npc->add_warp = npc_add_warp; npc->parse_warp = npc_parse_warp; npc->parse_shop = npc_parse_shop; @@ -4682,7 +4677,9 @@ void npc_defaults(void) { npc->parse_mob2 = npc_parse_mob2; npc->parse_mob = npc_parse_mob; npc->parse_mapflag = npc_parse_mapflag; + npc->parse_unknown_mapflag = npc_parse_unknown_mapflag; npc->parsesrcfile = npc_parsesrcfile; + npc->parse_unknown_object = npc_parse_unknown_object; npc->script_event = npc_script_event; npc->read_event_script = npc_read_event_script; npc->path_db_clear_sub = npc_path_db_clear_sub; diff --git a/src/map/npc.h b/src/map/npc.h index 9c497ffe9..fba14d485 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -231,9 +231,11 @@ struct npc_interface { void (*parsename) (struct npc_data *nd, const char *name, const char *start, const char *buffer, const char *filepath); int (*parseview) (const char *w4, const char *start, const char *buffer, const char *filepath); bool (*viewisid) (const char *viewid); + struct npc_data* (*create_npc) (int m, int x, int y); struct npc_data* (*add_warp) (char *name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y); const char* (*parse_warp) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval); const char* (*parse_shop) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval); + const char* (*parse_unknown_object) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval); void (*convertlabel_db) (struct npc_label_list *label_list, const char *filepath); const char* (*skip_script) (const char *start, const char *buffer, const char *filepath, int *retval); const char* (*parse_script) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int options, int *retval); @@ -250,6 +252,7 @@ struct npc_interface { void (*parse_mob2) (struct spawn_data *mobspawn); const char* (*parse_mob) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval); const char* (*parse_mapflag) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval); + void (*parse_unknown_mapflag) (const char *name, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval); int (*parsesrcfile) (const char *filepath, bool runOnInit); int (*script_event) (struct map_session_data *sd, enum npce_event type); void (*read_event_script) (void); diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index 6e982bb70..6e98d1aad 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -3301,12 +3301,16 @@ struct { struct HPMHookPoint *HP_npc_parseview_post; struct HPMHookPoint *HP_npc_viewisid_pre; struct HPMHookPoint *HP_npc_viewisid_post; + struct HPMHookPoint *HP_npc_create_npc_pre; + struct HPMHookPoint *HP_npc_create_npc_post; struct HPMHookPoint *HP_npc_add_warp_pre; struct HPMHookPoint *HP_npc_add_warp_post; struct HPMHookPoint *HP_npc_parse_warp_pre; struct HPMHookPoint *HP_npc_parse_warp_post; struct HPMHookPoint *HP_npc_parse_shop_pre; struct HPMHookPoint *HP_npc_parse_shop_post; + struct HPMHookPoint *HP_npc_parse_unknown_object_pre; + struct HPMHookPoint *HP_npc_parse_unknown_object_post; struct HPMHookPoint *HP_npc_convertlabel_db_pre; struct HPMHookPoint *HP_npc_convertlabel_db_post; struct HPMHookPoint *HP_npc_skip_script_pre; @@ -3339,6 +3343,8 @@ struct { struct HPMHookPoint *HP_npc_parse_mob_post; struct HPMHookPoint *HP_npc_parse_mapflag_pre; struct HPMHookPoint *HP_npc_parse_mapflag_post; + struct HPMHookPoint *HP_npc_parse_unknown_mapflag_pre; + struct HPMHookPoint *HP_npc_parse_unknown_mapflag_post; struct HPMHookPoint *HP_npc_parsesrcfile_pre; struct HPMHookPoint *HP_npc_parsesrcfile_post; struct HPMHookPoint *HP_npc_script_event_pre; @@ -8360,12 +8366,16 @@ struct { int HP_npc_parseview_post; int HP_npc_viewisid_pre; int HP_npc_viewisid_post; + int HP_npc_create_npc_pre; + int HP_npc_create_npc_post; int HP_npc_add_warp_pre; int HP_npc_add_warp_post; int HP_npc_parse_warp_pre; int HP_npc_parse_warp_post; int HP_npc_parse_shop_pre; int HP_npc_parse_shop_post; + int HP_npc_parse_unknown_object_pre; + int HP_npc_parse_unknown_object_post; int HP_npc_convertlabel_db_pre; int HP_npc_convertlabel_db_post; int HP_npc_skip_script_pre; @@ -8398,6 +8408,8 @@ struct { int HP_npc_parse_mob_post; int HP_npc_parse_mapflag_pre; int HP_npc_parse_mapflag_post; + int HP_npc_parse_unknown_mapflag_pre; + int HP_npc_parse_unknown_mapflag_post; int HP_npc_parsesrcfile_pre; int HP_npc_parsesrcfile_post; int HP_npc_script_event_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 00bd82f94..aec67b694 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -1677,9 +1677,11 @@ struct HookingPointData HookingPoints[] = { { HP_POP(npc->parsename, HP_npc_parsename) }, { HP_POP(npc->parseview, HP_npc_parseview) }, { HP_POP(npc->viewisid, HP_npc_viewisid) }, + { HP_POP(npc->create_npc, HP_npc_create_npc) }, { HP_POP(npc->add_warp, HP_npc_add_warp) }, { HP_POP(npc->parse_warp, HP_npc_parse_warp) }, { HP_POP(npc->parse_shop, HP_npc_parse_shop) }, + { HP_POP(npc->parse_unknown_object, HP_npc_parse_unknown_object) }, { HP_POP(npc->convertlabel_db, HP_npc_convertlabel_db) }, { HP_POP(npc->skip_script, HP_npc_skip_script) }, { HP_POP(npc->parse_script, HP_npc_parse_script) }, @@ -1696,6 +1698,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(npc->parse_mob2, HP_npc_parse_mob2) }, { HP_POP(npc->parse_mob, HP_npc_parse_mob) }, { HP_POP(npc->parse_mapflag, HP_npc_parse_mapflag) }, + { HP_POP(npc->parse_unknown_mapflag, HP_npc_parse_unknown_mapflag) }, { HP_POP(npc->parsesrcfile, HP_npc_parsesrcfile) }, { HP_POP(npc->script_event, HP_npc_script_event) }, { HP_POP(npc->read_event_script, HP_npc_read_event_script) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 57a609024..2e1c95573 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -44115,6 +44115,33 @@ bool HP_npc_viewisid(const char *viewid) { } return retVal___; } +struct npc_data* HP_npc_create_npc(int m, int x, int y) { + int hIndex = 0; + struct npc_data* retVal___ = NULL; + if( HPMHooks.count.HP_npc_create_npc_pre ) { + struct npc_data* (*preHookFunc) (int *m, int *x, int *y); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_create_npc_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_npc_create_npc_pre[hIndex].func; + retVal___ = preHookFunc(&m, &x, &y); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.npc.create_npc(m, x, y); + } + if( HPMHooks.count.HP_npc_create_npc_post ) { + struct npc_data* (*postHookFunc) (struct npc_data* retVal___, int *m, int *x, int *y); + for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_create_npc_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_npc_create_npc_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &m, &x, &y); + } + } + return retVal___; +} struct npc_data* HP_npc_add_warp(char *name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y) { int hIndex = 0; struct npc_data* retVal___ = NULL; @@ -44196,6 +44223,33 @@ const char* HP_npc_parse_shop(char *w1, char *w2, char *w3, char *w4, const char } return retVal___; } +const char* HP_npc_parse_unknown_object(char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval) { + int hIndex = 0; + const char* retVal___ = NULL; + if( HPMHooks.count.HP_npc_parse_unknown_object_pre ) { + const char* (*preHookFunc) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_parse_unknown_object_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_npc_parse_unknown_object_pre[hIndex].func; + retVal___ = preHookFunc(w1, w2, w3, w4, start, buffer, filepath, retval); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.npc.parse_unknown_object(w1, w2, w3, w4, start, buffer, filepath, retval); + } + if( HPMHooks.count.HP_npc_parse_unknown_object_post ) { + const char* (*postHookFunc) (const char* retVal___, char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval); + for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_parse_unknown_object_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_npc_parse_unknown_object_post[hIndex].func; + retVal___ = postHookFunc(retVal___, w1, w2, w3, w4, start, buffer, filepath, retval); + } + } + return retVal___; +} void HP_npc_convertlabel_db(struct npc_label_list *label_list, const char *filepath) { int hIndex = 0; if( HPMHooks.count.HP_npc_convertlabel_db_pre ) { @@ -44627,6 +44681,32 @@ const char* HP_npc_parse_mapflag(char *w1, char *w2, char *w3, char *w4, const c } return retVal___; } +void HP_npc_parse_unknown_mapflag(const char *name, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval) { + int hIndex = 0; + if( HPMHooks.count.HP_npc_parse_unknown_mapflag_pre ) { + void (*preHookFunc) (const char *name, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_parse_unknown_mapflag_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_npc_parse_unknown_mapflag_pre[hIndex].func; + preHookFunc(name, w3, w4, start, buffer, filepath, retval); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.npc.parse_unknown_mapflag(name, w3, w4, start, buffer, filepath, retval); + } + if( HPMHooks.count.HP_npc_parse_unknown_mapflag_post ) { + void (*postHookFunc) (const char *name, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval); + for(hIndex = 0; hIndex < HPMHooks.count.HP_npc_parse_unknown_mapflag_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_npc_parse_unknown_mapflag_post[hIndex].func; + postHookFunc(name, w3, w4, start, buffer, filepath, retval); + } + } + return; +} int HP_npc_parsesrcfile(const char *filepath, bool runOnInit) { int hIndex = 0; int retVal___ = 0; |