From 2c0cca1f505fec20fb345209efb780e69f7ad54e Mon Sep 17 00:00:00 2001 From: Vatiken Date: Sun, 10 Jun 2012 19:44:44 +0000 Subject: [PATCH] Cedit Toggle for enabling colour codes in the comm channels --- src/act.comm.c | 40 ++++++++++++++++++++++++++++++++++++++-- src/cedit.c | 15 ++++++++++++++- src/config.c | 3 +++ src/config.h | 1 + src/db.c | 3 +++ src/structs.h | 1 + src/utils.h | 2 ++ 7 files changed, 62 insertions(+), 3 deletions(-) diff --git a/src/act.comm.c b/src/act.comm.c index 37974c8..881526b 100644 --- a/src/act.comm.c +++ b/src/act.comm.c @@ -22,6 +22,21 @@ #include "act.h" #include "modify.h" +static bool legal_communication(char * arg); + +static bool legal_communication(char * arg) +{ + while (*arg) { + if (*arg == '@') { + arg++; + if (*arg == '(' || *arg == ')' || *arg == '<' || *arg == '>') + return FALSE; + } + arg++; + } + return TRUE; +} + ACMD(do_say) { skip_spaces(&argument); @@ -31,6 +46,9 @@ ACMD(do_say) else { char buf[MAX_INPUT_LENGTH + 14], *msg; struct char_data *vict; + + if (CONFIG_SPECIAL_IN_COMM && legal_communication(argument)) + parse_at(argument); snprintf(buf, sizeof(buf), "$n\tn says, '%s'", argument); msg = act(buf, FALSE, ch, 0, 0, TO_ROOM | DG_NO_TRIG); @@ -69,6 +87,9 @@ ACMD(do_gsay) else { char buf[MAX_STRING_LENGTH]; + if (CONFIG_SPECIAL_IN_COMM && legal_communication(argument)) + parse_at(argument); + if (ch->master) k = ch->master; else @@ -182,8 +203,11 @@ ACMD(do_tell) send_to_char(ch, "%s", CONFIG_NOPERSON); else if (GET_LEVEL(ch) >= LVL_IMMORT && !(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_WORLD))) send_to_char(ch, "%s", CONFIG_NOPERSON); - else if (is_tell_ok(ch, vict)) + else if (is_tell_ok(ch, vict)) { + if (CONFIG_SPECIAL_IN_COMM && legal_communication(argument)) + parse_at(buf2); perform_tell(ch, vict, buf2); + } } ACMD(do_reply) @@ -211,8 +235,11 @@ ACMD(do_reply) if (!tch) send_to_char(ch, "They are no longer playing.\r\n"); - else if (is_tell_ok(ch, tch)) + else if (is_tell_ok(ch, tch)) { + if (CONFIG_SPECIAL_IN_COMM && legal_communication(argument)) + parse_at(argument); perform_tell(ch, tch, argument); + } } } @@ -253,6 +280,9 @@ ACMD(do_spec_comm) else { char buf1[MAX_STRING_LENGTH]; + if (CONFIG_SPECIAL_IN_COMM && legal_communication(argument)) + parse_at(buf2); + snprintf(buf1, sizeof(buf1), "$n %s you, '%s'", action_plur, buf2); act(buf1, FALSE, ch, 0, vict, TO_VICT); @@ -493,6 +523,9 @@ ACMD(do_gen_comm) if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT)) send_to_char(ch, "%s", CONFIG_OK); else { + if (CONFIG_SPECIAL_IN_COMM && legal_communication(argument)) + parse_at(argument); + snprintf(buf1, sizeof(buf1), "%sYou %s, '%s%s'%s", COLOR_LEV(ch) >= C_CMP ? color_on : "", com_msgs[subcmd][1], argument, COLOR_LEV(ch) >= C_CMP ? color_on : "", CCNRM(ch, C_CMP)); @@ -535,6 +568,9 @@ ACMD(do_qcomm) else { char buf[MAX_STRING_LENGTH]; struct descriptor_data *i; + + if (CONFIG_SPECIAL_IN_COMM && legal_communication(argument)) + parse_at(argument); if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT)) send_to_char(ch, "%s", CONFIG_OK); diff --git a/src/cedit.c b/src/cedit.c index 8f62505..61bf1e2 100644 --- a/src/cedit.c +++ b/src/cedit.c @@ -131,6 +131,7 @@ static void cedit_setup(struct descriptor_data *d) OLC_CONFIG(d)->operation.medit_advanced = CONFIG_MEDIT_ADVANCED; OLC_CONFIG(d)->operation.ibt_autosave = CONFIG_IBT_AUTOSAVE; OLC_CONFIG(d)->operation.protocol_negotiation = CONFIG_PROTOCOL_NEGOTIATION; + OLC_CONFIG(d)->operation.special_in_comm = CONFIG_SPECIAL_IN_COMM; /* Autowiz */ OLC_CONFIG(d)->autowiz.use_autowiz = CONFIG_USE_AUTOWIZ; @@ -232,6 +233,7 @@ static void cedit_save_internally(struct descriptor_data *d) CONFIG_MEDIT_ADVANCED = OLC_CONFIG(d)->operation.medit_advanced; CONFIG_IBT_AUTOSAVE = OLC_CONFIG(d)->operation.ibt_autosave; CONFIG_PROTOCOL_NEGOTIATION = OLC_CONFIG(d)->operation.protocol_negotiation; + CONFIG_SPECIAL_IN_COMM = OLC_CONFIG(d)->operation.special_in_comm; /* Autowiz */ CONFIG_USE_AUTOWIZ = OLC_CONFIG(d)->autowiz.use_autowiz; @@ -542,10 +544,14 @@ int save_config( IDXTYPE nowhere ) "min_wizlist_lev = %d\n\n", CONFIG_MIN_WIZLIST_LEV); - fprintf(fl, "* If yes, enable the protocol negotiation system?\n" + fprintf(fl, "* If yes, enable the protocol negotiation system.\n" "protocol_negotiation = %d\n\n", CONFIG_PROTOCOL_NEGOTIATION); + fprintf(fl, "* If yes, enable the special character in comm channels.\n" + "special_in_comm = %d\n\n", + CONFIG_SPECIAL_IN_COMM); + fclose(fl); if (in_save_list(NOWHERE, SL_CFG)) @@ -731,6 +737,7 @@ static void cedit_disp_operation_options(struct descriptor_data *d) "%sO%s) Medit Stats Menu : %s%s\r\n" "%sP%s) Autosave bugs when resolved from commandline : %s%s\r\n" "%sR%s) Enable Protocol Negotiation : %s%s\r\n" + "%sS%s) Enable Special Char in Comm : %s%s\r\n" "%sQ%s) Exit To The Main Menu\r\n" "Enter your choice : ", grn, nrm, cyn, OLC_CONFIG(d)->operation.DFLT_PORT, @@ -750,6 +757,7 @@ static void cedit_disp_operation_options(struct descriptor_data *d) grn, nrm, cyn, OLC_CONFIG(d)->operation.medit_advanced ? "Advanced" : "Standard", grn, nrm, cyn, OLC_CONFIG(d)->operation.ibt_autosave ? "Yes" : "No", grn, nrm, cyn, OLC_CONFIG(d)->operation.protocol_negotiation ? "Yes" : "No", + grn, nrm, cyn, OLC_CONFIG(d)->operation.special_in_comm ? "Yes" : "No", grn, nrm ); @@ -1227,6 +1235,11 @@ void cedit_parse(struct descriptor_data *d, char *arg) case 'R': TOGGLE_VAR(OLC_CONFIG(d)->operation.protocol_negotiation); break; + + case 's': + case 'S': + TOGGLE_VAR(OLC_CONFIG(d)->operation.special_in_comm); + break; case 'q': case 'Q': diff --git a/src/config.c b/src/config.c index cddf4dd..98d23b9 100644 --- a/src/config.c +++ b/src/config.c @@ -311,3 +311,6 @@ int ibt_autosave = YES; /* Use the protocol negotiation system */ int protocol_negotiation = YES; + +/* Use the special character in communication channels */ +int special_in_comm = YES; diff --git a/src/config.h b/src/config.h index 1058cc3..1ee208e 100644 --- a/src/config.h +++ b/src/config.h @@ -69,6 +69,7 @@ extern int use_autowiz; extern int min_wizlist_lev; extern int display_closed_doors; extern int protocol_negotiation; +extern int special_in_comm; /* Automap and map options */ extern int map_option; extern int default_map_size; diff --git a/src/db.c b/src/db.c index e31730b..a05a843 100644 --- a/src/db.c +++ b/src/db.c @@ -3766,6 +3766,7 @@ static void load_default_config( void ) CONFIG_NO_MORT_TO_IMMORT = no_mort_to_immort; CONFIG_DISP_CLOSED_DOORS = display_closed_doors; CONFIG_PROTOCOL_NEGOTIATION = protocol_negotiation; + CONFIG_SPECIAL_IN_COMM = special_in_comm; CONFIG_DIAGONAL_DIRS = diagonal_dirs; CONFIG_MAP = map_option; CONFIG_MAP_SIZE = default_map_size; @@ -4026,6 +4027,8 @@ void load_config( void ) CONFIG_SITEOK_ALL = num; else if (!str_cmp(tag, "script_players")) CONFIG_SCRIPT_PLAYERS = num; + else if (!str_cmp(tag, "special_in_comm")) + CONFIG_SPECIAL_IN_COMM = num; else if (!str_cmp(tag, "start_messg")) { strncpy(buf, "Reading start message in load_config()", sizeof(buf)); if (CONFIG_START_MESSG) diff --git a/src/structs.h b/src/structs.h index 8a909a6..e5a4d66 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1349,6 +1349,7 @@ struct game_operation int medit_advanced; /**< Does the medit OLC show the advanced stats menu ? */ int ibt_autosave; /**< Does "bug resolve" autosave ? */ int protocol_negotiation; /**< Enable the protocol negotiation system ? */ + int special_in_comm; /**< Enable use of a special character in communication channels ? */ }; /** The Autowizard options. */ diff --git a/src/utils.h b/src/utils.h index 90bdc65..3129496 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1048,6 +1048,8 @@ do \ #define CONFIG_IBT_AUTOSAVE config_info.operation.ibt_autosave /** Use the protocol negotiation system? */ #define CONFIG_PROTOCOL_NEGOTIATION config_info.operation.protocol_negotiation +/** Use the special character in comm channels? */ +#define CONFIG_SPECIAL_IN_COMM config_info.operation.special_in_comm /* Autowiz */ /** Use autowiz or not? */