summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/clif.c24
-rw-r--r--src/map/clif.h6
-rw-r--r--src/map/packets_struct.h3
-rw-r--r--src/map/script.c6
-rw-r--r--src/map/skill.c8
-rw-r--r--src/map/status.c32
-rw-r--r--src/map/status.h20
7 files changed, 67 insertions, 32 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 71409fab4..69d9b6779 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1049,6 +1049,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu
#endif
#if PACKETVER >= 20150513
p.body = vd->body_style;
+ safestrncpy(p.name, clif->get_bl_name(bl), NAME_LENGTH);
#endif
clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,target);
@@ -1189,6 +1190,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) {
#endif
#if PACKETVER >= 20150513
p.body = vd->body_style;
+ safestrncpy(p.name, clif->get_bl_name(bl), NAME_LENGTH);
#endif
if( disguised(bl) ) {
nullpo_retv(sd);
@@ -1280,6 +1282,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd,
#endif
#if PACKETVER >= 20150513
p.body = vd->body_style;
+ safestrncpy(p.name, clif->get_bl_name(bl), NAME_LENGTH);
#endif
clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,target);
@@ -13284,7 +13287,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) {
case BL_PC:
{
char command[NAME_LENGTH+6];
- sprintf(command, "%ckick %s", atcommand->at_symbol, status->get_name(target));
+ sprintf(command, "%ckick %s", atcommand->at_symbol, clif->get_bl_name(target));
atcommand->exec(fd, sd, command, true);
}
break;
@@ -13299,7 +13302,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) {
clif->GM_kickack(sd, 0);
return;
}
- sprintf(command, "/kick %s (%d)", status->get_name(target), status->get_class(target));
+ sprintf(command, "/kick %s (%d)", clif->get_bl_name(target), status->get_class(target));
logs->atcommand(sd, command);
status_percent_damage(&sd->bl, target, 100, 0, true); // can invalidate 'target'
}
@@ -18760,6 +18763,22 @@ void clif_selectcart(struct map_session_data *sd)
#endif
}
+/**
+ * Returns the name of the given bl, in a client-friendly format.
+ *
+ * @param bl The requested bl.
+ * @return The bl's name (guaranteed to be non-NULL).
+ */
+const char *clif_get_bl_name(const struct block_list *bl)
+{
+ const char *name = status->get_name(bl);
+
+ if (name == NULL)
+ return "Unknown";
+
+ return name;
+}
+
/* */
unsigned short clif_decrypt_cmd( int cmd, struct map_session_data *sd ) {
if( sd ) {
@@ -19829,4 +19848,5 @@ void clif_defaults(void) {
clif->pHotkeyRowShift = clif_parse_HotkeyRowShift;
clif->dressroom_open = clif_dressroom_open;
clif->pOneClick_ItemIdentify = clif_parse_OneClick_ItemIdentify;
+ clif->get_bl_name = clif_get_bl_name;
}
diff --git a/src/map/clif.h b/src/map/clif.h
index ac0191210..f930e4ca1 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -1334,8 +1334,10 @@ struct clif_interface {
void (*dressroom_open) (struct map_session_data *sd, int view);
void (*pOneClick_ItemIdentify) (int fd,struct map_session_data *sd);
/* Cart Deco */
- void(*selectcart) (struct map_session_data *sd);
- void(*pSelectCart) (int fd, struct map_session_data *sd);
+ void (*selectcart) (struct map_session_data *sd);
+ void (*pSelectCart) (int fd, struct map_session_data *sd);
+
+ const char *(*get_bl_name) (const struct block_list *bl);
};
#ifdef HERCULES_CORE
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index f23cefb26..e8f04c653 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -584,6 +584,7 @@ struct packet_spawn_unit {
#endif
#if PACKETVER >= 20150513
short body;
+ char name[NAME_LENGTH];
#endif
} __attribute__((packed));
@@ -651,6 +652,7 @@ struct packet_unit_walking {
#endif
#if PACKETVER >= 20150513
short body;
+ char name[NAME_LENGTH];
#endif
} __attribute__((packed));
@@ -716,6 +718,7 @@ struct packet_idle_unit {
#endif
#if PACKETVER >= 20150513
short body;
+ char name[NAME_LENGTH];
#endif
} __attribute__((packed));
diff --git a/src/map/script.c b/src/map/script.c
index 67413669b..1128f400f 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -235,9 +235,9 @@ void script_reportsrc(struct script_state *st) {
break;
default:
if( bl->m >= 0 )
- ShowDebug("Source (Non-NPC type %u): name %s at %s (%d,%d)\n", bl->type, status->get_name(bl), map->list[bl->m].name, bl->x, bl->y);
+ ShowDebug("Source (Non-NPC type %u): name %s at %s (%d,%d)\n", bl->type, clif->get_bl_name(bl), map->list[bl->m].name, bl->x, bl->y);
else
- ShowDebug("Source (Non-NPC type %u): name %s (invisible/not on a map)\n", bl->type, status->get_name(bl));
+ ShowDebug("Source (Non-NPC type %u): name %s (invisible/not on a map)\n", bl->type, clif->get_bl_name(bl));
break;
}
}
@@ -16817,7 +16817,7 @@ BUILDIN(unittalk) {
if( bl != NULL ) {
struct StringBuf sbuf;
StrBuf->Init(&sbuf);
- StrBuf->Printf(&sbuf, "%s : %s", status->get_name(bl), message);
+ StrBuf->Printf(&sbuf, "%s : %s", clif->get_bl_name(bl), message);
clif->disp_overhead(bl, StrBuf->Value(&sbuf));
StrBuf->Destroy(&sbuf);
}
diff --git a/src/map/skill.c b/src/map/skill.c
index 8271991fe..13418fece 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -9667,7 +9667,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
if(sd) {
struct mob_data *summon_md;
- summon_md = mob->once_spawn_sub(src, src->m, src->x, src->y, status->get_name(src), MOBID_KO_KAGE, "", SZ_SMALL, AI_NONE);
+ summon_md = mob->once_spawn_sub(src, src->m, src->x, src->y, clif->get_bl_name(src), MOBID_KO_KAGE, "", SZ_SMALL, AI_NONE);
if( summon_md ) {
summon_md->master_id = src->id;
summon_md->special_state.ai = AI_ZANZOU;
@@ -9847,7 +9847,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
for (i = 0; i < summons[skill_lv-1].quantity; i++) {
- struct mob_data *summon_md = mob->once_spawn_sub(src, src->m, src->x, src->y, status->get_name(src),
+ struct mob_data *summon_md = mob->once_spawn_sub(src, src->m, src->x, src->y, clif->get_bl_name(src),
summons[skill_lv-1].mob_id, "", SZ_SMALL, AI_ATTACK);
if (summon_md != NULL) {
summon_md->master_id = src->id;
@@ -10588,7 +10588,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
}
// Correct info, don't change any of this! [Celest]
- md = mob->once_spawn_sub(src, src->m, x, y, status->get_name(src), class_, "", SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(src, src->m, x, y, clif->get_bl_name(src), class_, "", SZ_SMALL, AI_NONE);
if (md) {
md->master_id = src->id;
md->special_state.ai = (skill_id == AM_SPHEREMINE) ? AI_SPHERE : AI_FLORA;
@@ -10833,7 +10833,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case NC_SILVERSNIPER:
{
- struct mob_data *md = mob->once_spawn_sub(src, src->m, x, y, status->get_name(src), MOBID_SILVERSNIPER, "", SZ_SMALL, AI_NONE);
+ struct mob_data *md = mob->once_spawn_sub(src, src->m, x, y, clif->get_bl_name(src), MOBID_SILVERSNIPER, "", SZ_SMALL, AI_NONE);
if (md) {
md->master_id = src->id;
md->special_state.ai = AI_FLORA;
diff --git a/src/map/status.c b/src/map/status.c
index f8cd2940a..2f0007b8f 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -2255,7 +2255,8 @@ int status_calc_pet_(struct pet_data *pd, enum e_status_calc_opt opt)
return 1;
}
-unsigned int status_get_base_maxsp(struct map_session_data* sd, struct status_data *st) {
+unsigned int status_get_base_maxsp(const struct map_session_data *sd, const struct status_data *st)
+{
uint64 val = pc->class2idx(sd->status.class_);
val = status->dbs->SP_table[val][sd->status.base_level];
@@ -2272,7 +2273,8 @@ unsigned int status_get_base_maxsp(struct map_session_data* sd, struct status_da
return (unsigned int)cap_value(val, 0, UINT_MAX);
}
-unsigned int status_get_base_maxhp(struct map_session_data *sd, struct status_data *st) {
+unsigned int status_get_base_maxhp(const struct map_session_data *sd, const struct status_data *st)
+{
uint64 val = pc->class2idx(sd->status.class_);
val = status->dbs->HP_table[val][sd->status.base_level];
@@ -6241,7 +6243,13 @@ uint32 status_calc_mode(const struct block_list *bl, const struct status_change
return mode & MD_MASK;
}
-const char *status_get_name(struct block_list *bl)
+/**
+ * Returns the name of the given bl.
+ *
+ * @param bl The requested bl.
+ * @return The bl's name or NULL if not available.
+ */
+const char *status_get_name(const struct block_list *bl)
{
nullpo_ret(bl);
switch (bl->type) {
@@ -6257,7 +6265,7 @@ const char *status_get_name(struct block_list *bl)
case BL_HOM: return BL_UCCAST(BL_HOM, bl)->homunculus.name;
case BL_NPC: return BL_UCCAST(BL_NPC, bl)->name;
}
- return "Unknown";
+ return NULL;
}
/*==========================================
@@ -6266,7 +6274,7 @@ const char *status_get_name(struct block_list *bl)
* 0 = fail
* class_id = success
*------------------------------------------*/
-int status_get_class(struct block_list *bl)
+int status_get_class(const struct block_list *bl)
{
nullpo_ret(bl);
switch (bl->type) {
@@ -6286,7 +6294,7 @@ int status_get_class(struct block_list *bl)
* 1 = fail
* level = success
*------------------------------------------*/
-int status_get_lv(struct block_list *bl)
+int status_get_lv(const struct block_list *bl)
{
nullpo_ret(bl);
switch (bl->type) {
@@ -6376,7 +6384,8 @@ unsigned short status_get_speed(struct block_list *bl)
return status->get_status_data(bl)->speed;
}
-int status_get_party_id(struct block_list *bl) {
+int status_get_party_id(const struct block_list *bl)
+{
nullpo_ret(bl);
switch (bl->type) {
case BL_PC:
@@ -6431,7 +6440,7 @@ int status_get_party_id(struct block_list *bl) {
return 0;
}
-int status_get_guild_id(struct block_list *bl)
+int status_get_guild_id(const struct block_list *bl)
{
nullpo_ret(bl);
switch (bl->type) {
@@ -6497,7 +6506,8 @@ int status_get_guild_id(struct block_list *bl)
return 0;
}
-int status_get_emblem_id(struct block_list *bl) {
+int status_get_emblem_id(const struct block_list *bl)
+{
nullpo_ret(bl);
switch (bl->type) {
case BL_PC:
@@ -6558,7 +6568,7 @@ int status_get_emblem_id(struct block_list *bl) {
return 0;
}
-int status_get_mexp(struct block_list *bl)
+int status_get_mexp(const struct block_list *bl)
{
nullpo_ret(bl);
if (bl->type == BL_MOB)
@@ -6568,7 +6578,7 @@ int status_get_mexp(struct block_list *bl)
return 0;
}
-int status_get_race2(struct block_list *bl)
+int status_get_race2(const struct block_list *bl)
{
nullpo_ret(bl);
if (bl->type == BL_MOB)
diff --git a/src/map/status.h b/src/map/status.h
index fda700387..2b932b149 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -2219,17 +2219,17 @@ struct status_interface {
struct regen_data * (*get_regen_data) (struct block_list *bl);
struct status_data * (*get_status_data) (struct block_list *bl);
struct status_data * (*get_base_status) (struct block_list *bl);
- const char * (*get_name) (struct block_list *bl);
- int (*get_class) (struct block_list *bl);
- int (*get_lv) (struct block_list *bl);
+ const char *(*get_name) (const struct block_list *bl);
+ int (*get_class) (const struct block_list *bl);
+ int (*get_lv) (const struct block_list *bl);
defType (*get_def) (struct block_list *bl);
unsigned short (*get_speed) (struct block_list *bl);
unsigned char (*calc_attack_element) (struct block_list *bl, struct status_change *sc, int element);
- int (*get_party_id) (struct block_list *bl);
- int (*get_guild_id) (struct block_list *bl);
- int (*get_emblem_id) (struct block_list *bl);
- int (*get_mexp) (struct block_list *bl);
- int (*get_race2) (struct block_list *bl);
+ int (*get_party_id) (const struct block_list *bl);
+ int (*get_guild_id) (const struct block_list *bl);
+ int (*get_emblem_id) (const struct block_list *bl);
+ int (*get_mexp) (const struct block_list *bl);
+ int (*get_race2) (const struct block_list *bl);
struct view_data * (*get_viewdata) (struct block_list *bl);
void (*set_viewdata) (struct block_list *bl, int class_);
void (*change_init) (struct block_list *bl);
@@ -2275,8 +2275,8 @@ struct status_interface {
void (*initDummyData) (void);
int (*base_amotion_pc) (struct map_session_data *sd, struct status_data *st);
unsigned short (*base_atk) (const struct block_list *bl, const struct status_data *st);
- unsigned int (*get_base_maxhp) (struct map_session_data *sd, struct status_data *st);
- unsigned int (*get_base_maxsp) (struct map_session_data *sd, struct status_data *st);
+ unsigned int (*get_base_maxhp) (const struct map_session_data *sd, const struct status_data *st);
+ unsigned int (*get_base_maxsp) (const struct map_session_data *sd, const struct status_data *st);
int (*calc_npc_) (struct npc_data *nd, enum e_status_calc_opt opt);
unsigned short (*calc_str) (struct block_list *bl, struct status_change *sc, int str);
unsigned short (*calc_agi) (struct block_list *bl, struct status_change *sc, int agi);