From 5bdcba2a30ed389b6bbf2710be4e28a16206f5c5 Mon Sep 17 00:00:00 2001 From: kinther Date: Sat, 30 Aug 2025 19:35:52 -0700 Subject: [PATCH] Think command for RP --- src/act.comm.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ src/act.h | 1 + src/interpreter.c | 1 + 3 files changed, 52 insertions(+) diff --git a/src/act.comm.c b/src/act.comm.c index 45ace62..153e836 100644 --- a/src/act.comm.c +++ b/src/act.comm.c @@ -198,6 +198,56 @@ ACMD(do_feel) send_to_char(ch, "You feel %s\r\n", rendered); } +ACMD(do_think) +{ + char thought[MAX_INPUT_LENGTH]; + char feeling[MAX_INPUT_LENGTH]; + char *p = argument; /* must be mutable for skip_spaces */ + char *close; + + thought[0] = '\0'; + feeling[0] = '\0'; + + skip_spaces(&p); + + if (!*p) { + send_to_char(ch, "Think what?\r\n"); + return; + } + + /* Optional leading "(...)" becomes the feeling block. */ + if (*p == '(') { + close = strchr(p + 1, ')'); + if (close) { + size_t len = (size_t)(close - (p + 1)); + if (len >= sizeof(feeling)) len = sizeof(feeling) - 1; + strncpy(feeling, p + 1, len); + feeling[len] = '\0'; + + p = close + 1; /* move past ')' */ + while (*p && isspace((unsigned char)*p)) p++; /* skip spaces after ) */ + } + /* If there's no closing ')', we ignore and treat entire line as thought. */ + } + + if (!*p) { + send_to_char(ch, "Think what?\r\n"); + return; + } + + /* The rest is the thought text */ + strlcpy(thought, p, sizeof(thought)); + delete_doubledollar(thought); + if (*feeling) delete_doubledollar(feeling); + + /* Output (two lines; second indented two spaces) */ + if (*feeling) { + send_to_char(ch, "You think, feeling %s,\r\n \"%s\"\r\n", feeling, thought); + } else { + send_to_char(ch, "You think,\r\n \"%s\"\r\n", thought); + } +} + static void perform_tell(struct char_data *ch, struct char_data *vict, char *arg) { char buf[MAX_STRING_LENGTH], *msg; diff --git a/src/act.h b/src/act.h index affb474..3080d24 100644 --- a/src/act.h +++ b/src/act.h @@ -39,6 +39,7 @@ ACMD(do_spec_comm); ACMD(do_say); ACMD(do_ooc); ACMD(do_feel); +ACMD(do_think); ACMD(do_page); ACMD(do_reply); ACMD(do_tell); diff --git a/src/interpreter.c b/src/interpreter.c index 0798bca..a68bfcc 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -297,6 +297,7 @@ cpp_extern const struct command_info cmd_info[] = { { "teleport" , "tele" , POS_DEAD , do_teleport , LVL_BUILDER, 0 }, { "tedit" , "tedit" , POS_DEAD , do_tedit , LVL_GOD, 0 }, /* XXX: Oasisify */ { "thaw" , "thaw" , POS_DEAD , do_wizutil , LVL_GRGOD, SCMD_THAW }, + { "think" , "thin" , POS_RESTING , do_think , 0, 0 }, { "title" , "title" , POS_DEAD , do_title , LVL_IMMORT, 0 }, { "time" , "time" , POS_DEAD , do_time , 0, 0 }, { "toggle" , "toggle" , POS_DEAD , do_toggle , 0, 0 },