Skip to content

Commit

Permalink
Replaced radio crypt with an (Encrypted) tag
Browse files Browse the repository at this point in the history
  • Loading branch information
luciensadi committed Jul 1, 2024
1 parent 15c8745 commit 3606c87
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
36 changes: 30 additions & 6 deletions src/act.comm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,21 +732,29 @@ ACMD(do_radio)
any_one_arg(any_one_arg(argument, one), two);

int *freq;
if (cyberware) {
freq = &GET_CYBERWARE_RADIO_FREQ(radio);
} else if (vehicle) {
freq = &GET_VEHICLE_MOD_RADIO_FREQ(radio);
} else {
freq = &GET_RADIO_CENTERED_FREQUENCY(radio);
}

#ifdef ENABLE_RADIO_CRYPT
int *crypt_rating;
int max_crypt = 0;

if (cyberware) {
freq = &GET_CYBERWARE_RADIO_FREQ(radio);
crypt_rating = &GET_CYBERWARE_RADIO_CRYPT(radio);
max_crypt = GET_CYBERWARE_RADIO_MAX_CRYPT(radio);
} else if (vehicle) {
freq = &GET_VEHICLE_MOD_RADIO_FREQ(radio);
crypt_rating = &GET_VEHICLE_MOD_RADIO_CRYPT(radio);
max_crypt = GET_VEHICLE_MOD_RADIO_MAX_CRYPT(radio);
} else {
freq = &GET_RADIO_CENTERED_FREQUENCY(radio);
crypt_rating = &GET_RADIO_CURRENT_CRYPT(radio);
max_crypt = GET_RADIO_MAX_CRYPT(radio);
}
#endif

if (!*one) {
act("$p:", FALSE, ch, radio, 0, TO_CHAR);
Expand All @@ -757,11 +765,13 @@ ACMD(do_radio)
else
send_to_char(ch, " Mode: center @ %d MHz\r\n", *freq);

#ifdef ENABLE_RADIO_CRYPT
if (*crypt_rating)
send_to_char(ch, " Crypt (max %d): on (level %d)\r\n", max_crypt, *crypt_rating);
else
send_to_char(ch, " Crypt (max %d): off\r\n", max_crypt);
return;
#endif
} else if (!str_cmp(one, "off")) {
act("You turn $p off.", FALSE, ch, radio, 0, TO_CHAR);
*freq = 0;
Expand All @@ -785,6 +795,7 @@ ACMD(do_radio)
*freq = i;
WAIT_STATE(ch, 16); /* Takes time to adjust */
}
#ifdef ENABLE_RADIO_CRYPT
} else if (!str_cmp(one, "crypt")) {
if ((i = atoi(two))) {
if (i > max_crypt) {
Expand All @@ -808,6 +819,7 @@ ACMD(do_radio)
*crypt_rating = 0;
}
}
#endif // radio crypt
} else if (!str_cmp(one, "mode")) {
if (*freq == -1)
send_to_char(ch, "Your radio is currently scanning all frequencies. You can change the mode with ^WRADIO CENTER <frequency>, or turn it off with ^WRADIO OFF^n^n.\r\n");
Expand All @@ -816,8 +828,13 @@ ACMD(do_radio)
else
send_to_char(ch, "Your radio is currently centered at %d MHz. You can change the mode with ^WRADIO SCAN^n, or turn it off with ^WRADIO OFF^n.\r\n",
*freq);
} else
} else {
#ifdef ENABLE_RADIO_CRYPT
send_to_char("Valid commands are ^WRADIO OFF^n, ^WRADIO SCAN^n, ^WRADIO CENTER <frequency>^n, ^WRADIO CRYPT <level>^n, and ^WRADIO MODE^n. See ^WHELP RADIO^n for more.\r\n", ch);
#else
send_to_char("Valid commands are ^WRADIO OFF^n, ^WRADIO SCAN^n, ^WRADIO CENTER <frequency>^n, and ^WRADIO MODE^n. See ^WHELP RADIO^n for more.\r\n", ch);
#endif
}
}

struct obj_data *find_radio(struct char_data *ch, bool *is_cyberware, bool *is_vehicular, bool must_be_on=FALSE) {
Expand Down Expand Up @@ -952,6 +969,11 @@ ACMD(do_broadcast)
if (!char_can_make_noise(ch, "You can't seem to make any noise.\r\n"))
return;

#ifndef ENABLE_RADIO_CRYPT
// Disable crypt.
crypt_lvl = 0;
#endif

// Forbid usage of common smilies.
FAILURE_CASE(str_str(argument, ":)") || str_str(argument, ":D") || str_str(argument, ":("), "The radio is for in-character voice comms. Please refrain from using smilies etc.");

Expand All @@ -966,12 +988,12 @@ ACMD(do_broadcast)
if (crypt_lvl)
snprintf(untouched_message, sizeof(untouched_message), "^y\\%s^y/[%d MHz, %s](CRYPTO-%d): %s^N", voice, frequency, skills[language].name, crypt_lvl, capitalized_and_punctuated);
else
snprintf(untouched_message, sizeof(untouched_message), "^y\\%s^y/[%d MHz, %s]: %s^N", voice, frequency, skills[language].name, capitalized_and_punctuated);
snprintf(untouched_message, sizeof(untouched_message), "^y\\%s^y/[%d MHz, %s](Encrypted): %s^N", voice, frequency, skills[language].name, capitalized_and_punctuated);
} else {
if (crypt_lvl)
snprintf(untouched_message, sizeof(untouched_message), "^y\\%s^y/[All Frequencies, %s](CRYPTO-%d): %s^N", voice, skills[language].name, crypt_lvl, capitalized_and_punctuated);
else
snprintf(untouched_message, sizeof(untouched_message), "^y\\%s^y/[All Frequencies, %s]: %s^N", voice, skills[language].name, capitalized_and_punctuated);
snprintf(untouched_message, sizeof(untouched_message), "^y\\%s^y/[All Frequencies, %s](Encrypted): %s^N", voice, skills[language].name, capitalized_and_punctuated);
}

if (PRF_FLAGGED(ch, PRF_NOREPEAT))
Expand Down Expand Up @@ -1088,6 +1110,8 @@ ACMD(do_broadcast)
// Append crypt info to radio string (if any).
if (crypt_lvl) {
snprintf(ENDOF(radio_string), sizeof(radio_string) - strlen(radio_string), "(CRYPTO-%d)", crypt_lvl);
} else {
strlcat(radio_string, "(Encrypted)", sizeof(radio_string));
}

// If we have bad reception, add the static modifier.
Expand Down
12 changes: 11 additions & 1 deletion src/act.informative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3703,8 +3703,13 @@ void do_probe_object(struct char_data * ch, struct obj_data * j, bool is_in_shop
snprintf(ENDOF(buf), sizeof(buf) - strlen(buf), "It is a ^crating-^c%d %s^n.", GET_OBJ_VAL(j, 1), magic_tool_types[GET_OBJ_VAL(j, 0)]);
break;
case ITEM_RADIO:
#ifdef ENABLE_RADIO_CRYPT
snprintf(ENDOF(buf), sizeof(buf) - strlen(buf), "It has a ^c%d/5^n range and can encrypt and decrypt signals up to crypt level ^c%d^n.",
GET_OBJ_VAL(j, 1), GET_OBJ_VAL(j, 2));
GET_RADIO_FREQ_RANGE(j), GET_RADIO_MAX_CRYPT(j));
#else
snprintf(ENDOF(buf), sizeof(buf) - strlen(buf), "It has a ^c%d/5^n range.",
GET_RADIO_FREQ_RANGE(j));
#endif
break;
case ITEM_GUN_ACCESSORY:
if (GET_ACCESSORY_TYPE(j) == ACCESS_SMARTGOGGLE) { /* pass */ }
Expand Down Expand Up @@ -3817,9 +3822,14 @@ void do_probe_object(struct char_data * ch, struct obj_data * j, bool is_in_shop
engine_types[GET_VEHICLE_MOD_RATING(j)]);
} else if (GET_VEHICLE_MOD_TYPE(j) == MOD_RADIO) {
// radio range 0-5
#ifdef ENABLE_RADIO_CRYPT
snprintf(ENDOF(buf), sizeof(buf) - strlen(buf), "\r\nIt has a ^c%d/5^n range and can encrypt and decrypt signals up to crypt level ^c%d^n.",
GET_VEHICLE_MOD_RATING(j),
GET_VEHICLE_MOD_RADIO_MAX_CRYPT(j));
#else
snprintf(ENDOF(buf), sizeof(buf) - strlen(buf), "\r\nIt has a ^c%d/5^n range.",
GET_VEHICLE_MOD_RATING(j));
#endif
} else if (GET_VEHICLE_MOD_LOCATION(j) == MOD_GRABBER) {
// grabber arm
snprintf(ENDOF(buf), sizeof(buf) - strlen(buf), "\r\nIt has a lifting capacity of ^c%d^n kilograms.", GET_VEHICLE_MOD_RATING(j));
Expand Down

0 comments on commit 3606c87

Please sign in to comment.