Skip to content

Commit

Permalink
Pocsecs now buzz regularly when you have unread mail.
Browse files Browse the repository at this point in the history
  • Loading branch information
luciensadi committed Feb 10, 2024
1 parent 1e959ae commit b3c76f2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
14 changes: 14 additions & 0 deletions src/dblist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "newmatrix.hpp"
#include "deck_build.hpp"
#include "redit.hpp"
#include "newmail.hpp"

// extern vars
extern class helpList Help;
Expand All @@ -32,6 +33,8 @@ extern class helpList WizHelp;
extern void print_object_location(int, struct obj_data *, struct char_data *, int);
#define OBJ temp->data

SPECIAL(pocket_sec);

int objList::PrintList(struct char_data *ch, const char *arg, bool override_vis_check)
{
nodeStruct<struct obj_data *> *temp = head;
Expand Down Expand Up @@ -244,6 +247,17 @@ void objList::UpdateCounters(void)
continue;
}

// We use the trideo broadcast tick, because why not.
if (trideo_plays && GET_OBJ_SPEC(OBJ) == pocket_sec) {
struct char_data *carried_by = get_obj_carried_by_recursive(OBJ);
struct char_data *worn_by = get_obj_worn_by_recursive(OBJ);
struct char_data *recipient = carried_by ? carried_by : worn_by;

if (recipient) {
send_to_char(recipient, "%s buzzes quietly, reminding you that you have mail waiting.\r\n", CAP(GET_OBJ_NAME(OBJ)));
}
}

// Decay evaluate programs. This only fires when they're completed, as non-finished software is ITEM_DESIGN instead.
if (GET_OBJ_TYPE(OBJ) == ITEM_PROGRAM && GET_PROGRAM_TYPE(OBJ) == SOFT_EVALUATE) {
if (!GET_OBJ_VAL(OBJ, 5)) {
Expand Down
1 change: 1 addition & 0 deletions src/dblist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class objList : public List<struct obj_data *>
void CallSpec();
void RemoveObjNum(int num);
void RemoveQuestObjs(int id);
void BuzzPocsecs(void);

#ifdef ENABLE_THIS_IF_YOU_WANT_TO_HATE_YOUR_LIFE
void CheckPointers();
Expand Down
15 changes: 7 additions & 8 deletions src/newmail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,13 @@ void raw_store_mail(long to, long from_id, const char *from_name, const char *me
}

// Notify pocket secretaries of online characters.
#define IS_VALID_POCKET_SEC(obj) ((obj) && GET_OBJ_SPEC((obj)) == pocket_sec && (obj)->contains)
for (struct descriptor_data *desc = descriptor_list; desc; desc = desc->next)
for (struct descriptor_data *desc = descriptor_list; desc; desc = desc->next) {
if (desc->character && GET_IDNUM(desc->character) == to && STATE(desc) == CON_PLAYING) {
bool has_beeped = FALSE;

for (struct obj_data *obj = desc->character->carrying; obj && !has_beeped; obj = obj->next_content) {
if (IS_VALID_POCKET_SEC(obj)) {
send_to_char(desc->character, "%s beeps.\r\n", GET_OBJ_NAME(obj));
send_to_char(desc->character, "%s beeps.\r\n", CAP(GET_OBJ_NAME(obj)));
has_beeped = TRUE;
break;
}
Expand All @@ -97,22 +96,22 @@ void raw_store_mail(long to, long from_id, const char *from_name, const char *me
if (!eq)
continue;

if (IS_VALID_POCKET_SEC(eq)) {
send_to_char(desc->character, "%s beeps.\r\n", GET_OBJ_NAME(eq));
if (IS_VALID_POCKET_SEC(eq) && POCKET_SEC_USABLE_BY(eq, desc->character)) {
send_to_char(desc->character, "%s beeps.\r\n", CAP(GET_OBJ_NAME(eq)));
has_beeped = TRUE;
break;
} else {
for (struct obj_data *obj = eq->contains; obj && !has_beeped; obj = obj->next_content) {
if (IS_VALID_POCKET_SEC(obj)) {
send_to_char(desc->character, "From inside %s, %s beeps.\r\n", GET_OBJ_NAME(eq), GET_OBJ_NAME(obj));
if (IS_VALID_POCKET_SEC(eq) && POCKET_SEC_USABLE_BY(obj, desc->character)) {
send_to_char(desc->character, "From inside %s, %s beeps.\r\n", decapitalize_a_an(GET_OBJ_NAME(eq)), GET_OBJ_NAME(obj));
has_beeped = TRUE;
break;
}
}
}
}
}

}
}

int amount_of_mail_waiting(struct char_data *ch) {
Expand Down
8 changes: 8 additions & 0 deletions src/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,11 @@ bool is_weapon_focus_usable_by(struct obj_data *focus, struct char_data *ch);
#define GET_SLOTMACHINE_PLAY_TICKS(obj) (GET_OBJ_VAL((obj), 2))
#define GET_SLOTMACHINE_MONEY_EXTRACTED(obj) (GET_OBJ_VAL((obj), 9))

// Which vector in the map this deck uses (0 for unallocated)
#define GET_CARD_VECTOR_IDNUM(obj) (GET_OBJ_VAL((obj), 0))
// Which player this stack belongs to (0 for none)
#define GET_CARD_PLAYER_IDNUM(obj) (GET_OBJ_VAL((obj), 0))

// ITEM_MAGIC_TOOL convenience defines
#define GET_MAGIC_TOOL_TYPE(tool) (GET_OBJ_VAL((tool), 0))
#define GET_MAGIC_TOOL_RATING(tool) (GET_OBJ_VAL((tool), 1))
Expand Down Expand Up @@ -1494,4 +1499,7 @@ void lose_nuyen_from_credstick(struct char_data *ch, struct obj_data *credstick,
#define GET_DATAJACK_ERROR_CANT_USE_TRODES_TO_RIG 3
struct obj_data *get_datajack(struct char_data *ch, bool is_rigging);

#define IS_VALID_POCKET_SEC(obj) ((obj) && GET_OBJ_SPEC((obj)) == pocket_sec && (obj)->contains)
#define POCKET_SEC_USABLE_BY(obj, ch) ((ch) && (obj) && (!GET_POCKET_SECRETARY_LOCKED_BY((obj)) || GET_POCKET_SECRETARY_LOCKED_BY((obj)) == GET_IDNUM((ch))))

#endif

0 comments on commit b3c76f2

Please sign in to comment.