diff options
-rw-r--r-- | src/emap/clif.c | 2 | ||||
-rw-r--r-- | src/emap/data/mapd.c | 1 | ||||
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/map.c | 84 | ||||
-rw-r--r-- | src/emap/map.h | 5 | ||||
-rw-r--r-- | src/emap/script.c | 16 | ||||
-rw-r--r-- | src/emap/struct/mapdext.h | 5 |
7 files changed, 113 insertions, 1 deletions
diff --git a/src/emap/clif.c b/src/emap/clif.c index 5e6d7e4..b04b3b5 100644 --- a/src/emap/clif.c +++ b/src/emap/clif.c @@ -23,6 +23,7 @@ #include "emap/clif.h" #include "emap/lang.h" +#include "emap/map.h" #include "emap/send.h" #include "emap/data/mapd.h" #include "emap/data/session.h" @@ -530,6 +531,7 @@ void eclif_parse_LoadEndAck_post(int *fdPtr __attribute__ ((unused)), { // some messages not sent if map not changed map->iwall_get(sd); } + map_alwaysVisible_send(sd); } void eclif_changelook2(struct block_list *bl, int type, int val, diff --git a/src/emap/data/mapd.c b/src/emap/data/mapd.c index feaabaf..e7f7ee4 100644 --- a/src/emap/data/mapd.c +++ b/src/emap/data/mapd.c @@ -38,5 +38,6 @@ struct MapdExt *mapd_create(void) data->mask = 1; data->invisible = false; data->flag.nopve = 0; + VECTOR_INIT(data->npcs); return data; } diff --git a/src/emap/init.c b/src/emap/init.c index fbe18d6..5b3352e 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -190,6 +190,7 @@ HPExport void plugin_init (void) addHookPre("unit->can_move", eunit_can_move); addHookPre("unit->walktoxy", eunit_walktoxy); addHookPre("mail->invalid_operation", email_invalid_operation); + addHookPre("map->list_final", edo_final_maps); addHookPre("map->cell2gat", emap_cell2gat); addHookPre("map->gat2cell", emap_gat2cell); addHookPre("map->getcellp", emap_getcellp); diff --git a/src/emap/map.c b/src/emap/map.c index 0a81291..67d279d 100644 --- a/src/emap/map.c +++ b/src/emap/map.c @@ -11,21 +11,25 @@ #include "common/HPMi.h" #include "common/memmgr.h" #include "common/mmo.h" +#include "common/nullpo.h" #include "common/socket.h" #include "common/strlib.h" #include "common/timer.h" #include "map/battle.h" #include "map/itemdb.h" #include "map/map.h" +#include "map/npc.h" #include "map/pc.h" #include "emap/permission.h" #include "emap/send.h" #include "emap/data/itemd.h" +#include "emap/data/mapd.h" #include "emap/data/mobd.h" #include "emap/data/npcd.h" #include "emap/data/session.h" #include "emap/struct/itemdext.h" +#include "emap/struct/mapdext.h" #include "emap/struct/mobdext.h" #include "emap/struct/npcdext.h" #include "emap/struct/sessionext.h" @@ -478,3 +482,83 @@ bool emap_iwall_set2(int m, int layer, int x1, int y1, int x2, int y2, int mask, map->list[m].iwall_num++; return true; } + +void map_alwaysVisible_add(const struct block_list *bl) +{ + if (!bl) + return; + struct MapdExt *data = mapd_get(bl->m); + if (!data) + return; + int f; + for (f = 0; f < VECTOR_LENGTH(data->npcs); f ++) + { + if (VECTOR_INDEX(data->npcs, f) == bl->id) + return; + } + VECTOR_ENSURE(data->npcs, 1, 1); + VECTOR_PUSH(data->npcs, bl->id); +} + +bool map_alwaysVisible_find(const struct block_list *bl) +{ + if (!bl) + return false; + struct MapdExt *data = mapd_get(bl->m); + if (!data) + return false; + int f; + for (f = 0; f < VECTOR_LENGTH(data->npcs); f ++) + { + if (VECTOR_INDEX(data->npcs, f) == bl->id) + return true; + } + return false; +} + +void map_alwaysVisible_delete(const struct block_list *bl) +{ + if (!bl) + return; + struct MapdExt *data = mapd_get(bl->m); + if (!data) + return; + int f; + for (f = 0; f < VECTOR_LENGTH(data->npcs); f ++) + { + if (VECTOR_INDEX(data->npcs, f) == bl->id) + { + VECTOR_ERASE(data->npcs, f); + return; + } + } +} + +void map_alwaysVisible_send(TBL_PC *sd) +{ + if (!sd) + return; + int f; + struct MapdExt *data = mapd_get(sd->bl.m); + if (!data) + return; + + for (f = 0; f < VECTOR_LENGTH(data->npcs); f ++) + { + const int id = VECTOR_INDEX(data->npcs, f); + TBL_NPC *npc = map->id2nd(id); + clif->set_unit_idle(&npc->bl, sd, SELF); + clif->charnameack(sd->fd, &npc->bl); + } +} + +void edo_final_maps(void) +{ + int f; + for (f = 0; f < map->count; f++) + { + struct MapdExt *data = mapd_get(f); + if (data) + VECTOR_CLEAR(data->npcs); + } +} diff --git a/src/emap/map.h b/src/emap/map.h index 1e57749..1813d57 100644 --- a/src/emap/map.h +++ b/src/emap/map.h @@ -39,5 +39,10 @@ bool emap_iwall_set2(int m, int x2, int y2, int mask, const char *name); +void map_alwaysVisible_add(const struct block_list *bl); +void map_alwaysVisible_delete(const struct block_list *bl); +bool map_alwaysVisible_find(const struct block_list *bl); +void map_alwaysVisible_send(TBL_PC *sd); +void edo_final_maps(void); #endif // EVOL_MAP_MAP diff --git a/src/emap/script.c b/src/emap/script.c index b8f54a0..0cadc03 100644 --- a/src/emap/script.c +++ b/src/emap/script.c @@ -177,6 +177,15 @@ void eset_reg_npcscope_num(struct script_state* st, struct reg_db *n, int64 *num ext->walkMask = *val; hookStop(); } + else if (!strcmp(name, ".alwaysVisible")) + { + getExt1(); + if (*val) + map_alwaysVisible_add(&nd->bl); + else + map_alwaysVisible_delete(&nd->bl); + hookStop(); + } } int eget_val_npcscope_num(struct script_state* st, struct reg_db *n, struct script_data* data) @@ -254,6 +263,13 @@ int eget_val_npcscope_num(struct script_state* st, struct reg_db *n, struct scri hookStop(); return ext->walkMask; } + else if (!strcmp(name, ".alwaysVisible")) + { + getExt1Return(0); + bool res = map_alwaysVisible_find(&nd->bl); + hookStop(); + return res; + } return 0; } diff --git a/src/emap/struct/mapdext.h b/src/emap/struct/mapdext.h index fb75dd3..c352221 100644 --- a/src/emap/struct/mapdext.h +++ b/src/emap/struct/mapdext.h @@ -4,14 +4,17 @@ #ifndef EVOL_MAP_MAPDEXT #define EVOL_MAP_MAPDEXT +#include "common/db.h" + struct MapdExt { unsigned int mask; - bool invisible; + VECTOR_DECL(int) npcs; struct MapdExtFlag { unsigned nopve : 1; } flag; + bool invisible; }; #endif // EVOL_MAP_MAPDEXT |