summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2020-04-05 23:53:31 +0200
committerGitHub <noreply@github.com>2020-04-05 23:53:31 +0200
commitbdb4e3f63ee1010ae5d7c43818e8b0b32cabc3d5 (patch)
tree6fb37c2467b50b28c653e0b45dc5ec05a25ecef9 /src/map/atcommand.c
parent63ae5dda74c1f79de8d00596b323b0f5ef7c9526 (diff)
parent548a03ec3dafb0521dedd979e01027f0e8cf4177 (diff)
downloadhercules-bdb4e3f63ee1010ae5d7c43818e8b0b32cabc3d5.tar.gz
hercules-bdb4e3f63ee1010ae5d7c43818e8b0b32cabc3d5.tar.bz2
hercules-bdb4e3f63ee1010ae5d7c43818e8b0b32cabc3d5.tar.xz
hercules-bdb4e3f63ee1010ae5d7c43818e8b0b32cabc3d5.zip
Merge pull request #2637 from Kenpachi2k13/fakename_fix
Fix/extend @fakename
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c56
1 files changed, 39 insertions, 17 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 6d7898fde..91ddc3ef9 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -7892,39 +7892,61 @@ ACMD(monsterignore)
return true;
}
-/*==========================================
- * @fakename
- * => Gives your character a fake name. [Valaris]
- *------------------------------------------*/
+
+/**
+ * Temporarily changes the character's name to the specified string.
+ *
+ * @code{.herc}
+ * @fakename {<options>} {<fake_name>}
+ * @endcode
+ *
+ **/
ACMD(fakename)
{
- if (!*message)
- {
- if (sd->fakename[0])
- {
+ if (*message == '\0') {
+ if (sd->fakename[0] != '\0') {
sd->fakename[0] = '\0';
+ sd->fakename_options = FAKENAME_OPTION_NONE;
clif->blname_ack(0, &sd->bl);
- if( sd->disguise )
+
+ if (sd->disguise != 0) // Another packet should be sent so the client updates the name for sd.
clif->blname_ack(sd->fd, &sd->bl);
- clif->message(sd->fd, msg_fd(fd,1307)); // Returned to real name.
+
+ clif->message(sd->fd, msg_fd(fd, 1307)); // Returned to real name.
return true;
}
- clif->message(sd->fd, msg_fd(fd,1308)); // You must enter a name.
+ clif->message(sd->fd, msg_fd(fd, 1308)); // You must enter a name.
return false;
}
- if (strlen(message) < 2)
- {
- clif->message(sd->fd, msg_fd(fd,1309)); // Fake name must be at least two characters.
+ int options = FAKENAME_OPTION_NONE;
+ char buf[NAME_LENGTH] = {'\0'};
+ const char *fake_name = NULL;
+
+ if (sscanf(message, "%d %23[^\n]", &options, buf) == 2) {
+ fake_name = buf;
+ } else {
+ options = FAKENAME_OPTION_NONE;
+ fake_name = message;
+ }
+
+ if (strlen(fake_name) < 2) {
+ clif->message(sd->fd, msg_fd(fd, 1309)); // Fake name must be at least two characters.
return false;
}
- safestrncpy(sd->fakename, message, sizeof(sd->fakename));
+ if (options < FAKENAME_OPTION_NONE)
+ options = FAKENAME_OPTION_NONE;
+
+ safestrncpy(sd->fakename, fake_name, sizeof(sd->fakename));
+ sd->fakename_options = options;
clif->blname_ack(0, &sd->bl);
- if (sd->disguise) // Another packet should be sent so the client updates the name for sd
+
+ if (sd->disguise != 0) // Another packet should be sent so the client updates the name for sd.
clif->blname_ack(sd->fd, &sd->bl);
- clif->message(sd->fd, msg_fd(fd,1310)); // Fake name enabled.
+
+ clif->message(sd->fd, msg_fd(fd, 1310)); // Fake name enabled.
return true;
}