Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional parameter for *showscript to send target to SELF only #2415

Merged
merged 2 commits into from Apr 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion doc/script_commands.txt
Expand Up @@ -4443,11 +4443,14 @@ if <color> field is left out.

---------------------------------------

*showscript("<message>"{, <GID>})
*showscript("<message>"{, <GID>{, <send_target>}})

Makes the attached player or GID, display a message similiar to a chat,
this will be seen by everyone near the invoking character but will not
be displayed in the chat window.
send_target: (optional)
AREA: show the message to everyone within the view range (default)
SELF: show the message to the given unit GID only

---------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions src/map/clif.c
Expand Up @@ -19360,7 +19360,7 @@ static void clif_partytickack(struct map_session_data *sd, bool flag)
WFIFOSET(sd->fd, packet_len(0x2c9));
}

static void clif_ShowScript(struct block_list *bl, const char *message)
static void clif_ShowScript(struct block_list *bl, const char *message, enum send_target target)
{
#if PACKETVER >= 20110111
char buf[256];
Expand All @@ -19381,7 +19381,7 @@ static void clif_ShowScript(struct block_list *bl, const char *message)
WBUFW(buf,2) = len+8;
WBUFL(buf,4) = bl->id;
safestrncpy(WBUFP(buf,8),message,len);
clif->send(buf,WBUFW(buf,2),bl,AREA);
clif->send(buf, WBUFW(buf,2), bl, target);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/map/clif.h
Expand Up @@ -1009,7 +1009,7 @@ struct clif_interface {
void (*wisexin) (struct map_session_data *sd,int type,int flag);
void (*wisall) (struct map_session_data *sd,int type,int flag);
void (*PMIgnoreList) (struct map_session_data* sd);
void (*ShowScript) (struct block_list* bl, const char* message);
void (*ShowScript) (struct block_list* bl, const char* message, enum send_target target);
/* trade handling */
void (*traderequest) (struct map_session_data* sd, const char* name);
void (*tradestart) (struct map_session_data* sd, uint8 type);
Expand Down
14 changes: 7 additions & 7 deletions src/map/script.c
Expand Up @@ -24377,7 +24377,7 @@ static BUILDIN(showscript)
{
struct block_list *bl = NULL;
const char *msg = script_getstr(st, 2);
int id = 0;
int id = 0, flag = AREA;

if (script_hasdata(st, 3)) {
id = script_getnum(st, 3);
Expand All @@ -24389,14 +24389,14 @@ static BUILDIN(showscript)

if (!bl) {
ShowError("buildin_showscript: Script not attached. (id=%d, rid=%d, oid=%d)\n", id, st->rid, st->oid);
script_pushint(st, 0);
return false;
}

clif->ShowScript(bl, msg);

script_pushint(st, 1);

if (script_hasdata(st, 4))
if (script_getnum(st, 4) == SELF)
flag = SELF;

clif->ShowScript(bl, msg, flag);
return true;
}

Expand Down Expand Up @@ -25822,7 +25822,7 @@ static void script_parse_builtin(void)
BUILDIN_DEF(channelmes, "ss"),
BUILDIN_DEF(addchannelhandler, "ss"),
BUILDIN_DEF(removechannelhandler, "ss"),
BUILDIN_DEF(showscript, "s?"),
BUILDIN_DEF(showscript, "s??"),
BUILDIN_DEF(mergeitem,""),
BUILDIN_DEF(getcalendartime, "ii??"),

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/HPMHooking/HPMHooking.Defs.inc
Expand Up @@ -1618,8 +1618,8 @@ typedef void (*HPMHOOK_pre_clif_wisall) (struct map_session_data **sd, int *type
typedef void (*HPMHOOK_post_clif_wisall) (struct map_session_data *sd, int type, int flag);
typedef void (*HPMHOOK_pre_clif_PMIgnoreList) (struct map_session_data **sd);
typedef void (*HPMHOOK_post_clif_PMIgnoreList) (struct map_session_data *sd);
typedef void (*HPMHOOK_pre_clif_ShowScript) (struct block_list **bl, const char **message);
typedef void (*HPMHOOK_post_clif_ShowScript) (struct block_list *bl, const char *message);
typedef void (*HPMHOOK_pre_clif_ShowScript) (struct block_list **bl, const char **message, enum send_target *target);
typedef void (*HPMHOOK_post_clif_ShowScript) (struct block_list *bl, const char *message, enum send_target target);
typedef void (*HPMHOOK_pre_clif_traderequest) (struct map_session_data **sd, const char **name);
typedef void (*HPMHOOK_post_clif_traderequest) (struct map_session_data *sd, const char *name);
typedef void (*HPMHOOK_pre_clif_tradestart) (struct map_session_data **sd, uint8 *type);
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
Expand Up @@ -15758,28 +15758,28 @@ void HP_clif_PMIgnoreList(struct map_session_data *sd) {
}
return;
}
void HP_clif_ShowScript(struct block_list *bl, const char *message) {
void HP_clif_ShowScript(struct block_list *bl, const char *message, enum send_target target) {
int hIndex = 0;
if (HPMHooks.count.HP_clif_ShowScript_pre > 0) {
void (*preHookFunc) (struct block_list **bl, const char **message);
void (*preHookFunc) (struct block_list **bl, const char **message, enum send_target *target);
*HPMforce_return = false;
for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_ShowScript_pre; hIndex++) {
preHookFunc = HPMHooks.list.HP_clif_ShowScript_pre[hIndex].func;
preHookFunc(&bl, &message);
preHookFunc(&bl, &message, &target);
}
if (*HPMforce_return) {
*HPMforce_return = false;
return;
}
}
{
HPMHooks.source.clif.ShowScript(bl, message);
HPMHooks.source.clif.ShowScript(bl, message, target);
}
if (HPMHooks.count.HP_clif_ShowScript_post > 0) {
void (*postHookFunc) (struct block_list *bl, const char *message);
void (*postHookFunc) (struct block_list *bl, const char *message, enum send_target target);
for (hIndex = 0; hIndex < HPMHooks.count.HP_clif_ShowScript_post; hIndex++) {
postHookFunc = HPMHooks.list.HP_clif_ShowScript_post[hIndex].func;
postHookFunc(bl, message);
postHookFunc(bl, message, target);
}
}
return;
Expand Down