Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queue updates / refactor #262

Merged
merged 10 commits into from
Sep 16, 2024
10 changes: 8 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
"stopAtEntry": false,
"cwd": "${workspaceRoot}/code/",
"environment": [],
"externalConsole": true,
//"externalConsole": true,
// "miDebuggerPath": "/bin",
"linux": {
"MIMode": "gdb"
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [{
"text": "-enable-pretty-printing",
"description": "enable pretty printing",
"ignoreFailures": true
}]
},
"osx": {
"MIMode": "lldb"
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"codecvt": "cpp",
"charconv": "cpp",
"source_location": "cpp",
"cerrno": "cpp"
"cerrno": "cpp",
"any": "cpp"
},
"testMate.cpp.test.executables": "tests/*{_tests}*",
"testMate.cpp.debug.configTemplate": {
Expand Down
31 changes: 28 additions & 3 deletions code/act_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ void do_say(CHAR_DATA *ch, char *argument)
return;
}

char saymsg[MAX_STRING_LENGTH];
char saymsg[MAX_STRING_LENGTH] = {0};
if (argument[strlen(argument) - 1] == '!')
sprintf(saymsg, "exclaim");
else if (argument[strlen(argument) - 1] == '?')
Expand Down Expand Up @@ -779,6 +779,11 @@ void do_say(CHAR_DATA *ch, char *argument)
}
}

void do_say_queue(CHAR_DATA *ch, std::string argument)
{
do_say(ch, argument.data());
}

void say_to(CHAR_DATA *ch, CHAR_DATA *victim, char *argument, char *extra)
{
if (argument[0] == '\0')
Expand Down Expand Up @@ -855,6 +860,11 @@ void say_to(CHAR_DATA *ch, CHAR_DATA *victim, char *argument, char *extra)
}
}

void say_to_queue (CHAR_DATA *ch, CHAR_DATA *victim, std::string argument, std::string extra)
{
say_to(ch, victim, argument.data(), extra.data());
}

void do_whisper(CHAR_DATA *ch, char *argument) /* whisper -- dioxide */
{
if (!is_npc(ch) && argument[0] == '\0')
Expand Down Expand Up @@ -932,6 +942,11 @@ void do_whisper(CHAR_DATA *ch, char *argument) /* whisper -- dioxide */
check_unholy_communion(ch, argument);
}

void do_whisper_queue (CHAR_DATA *ch, std::string argument)
{
do_whisper(ch, argument.data());
}

void do_sing(CHAR_DATA *ch, char *argument)
{
if (argument[0] == '\0')
Expand Down Expand Up @@ -1256,6 +1271,11 @@ void do_tell(CHAR_DATA *ch, char *argument)
free_pstring(argument);
}

void do_tell_queue (CHAR_DATA *ch, std::string argument)
{
do_tell(ch, argument.data());
}

void do_noreply(CHAR_DATA *ch, char *argument)
{
send_to_char("You concentrate and momentarily close your ears to the replies of others.\n\r", ch);
Expand Down Expand Up @@ -1511,6 +1531,11 @@ void do_emote(CHAR_DATA *ch, char *argument)
act("$n$T", ch, nullptr, buffer, TO_ALL);
}

void do_emote_queue(CHAR_DATA *ch, std::string argument)
{
do_emote(ch, argument.data());
}

void do_pmote(CHAR_DATA *ch, char *argument)
{
if (!is_npc(ch) && IS_SET(ch->comm, COMM_NOEMOTE))
Expand Down Expand Up @@ -1772,7 +1797,7 @@ void do_quit_new(CHAR_DATA *ch, char *argument, bool autoq)
}
}

if (CQueue::HasQueuePending(ch))
if (RS.Queue.HasQueuePending(ch))
{
if (autoq)
RS.Logger.Warn("Trying to autoquit char {} with pending queue.", ch->name);
Expand Down Expand Up @@ -2592,7 +2617,7 @@ void speech_handler(CHAR_DATA *ch, CHAR_DATA *mob, SPEECH_DATA *speech)
return;
}

RS.Queue.AddToQueue(speech->current_line->delay, 3, speech_handler, ch, mob, speech);
RS.Queue.AddToQueue(speech->current_line->delay, "speech_handler", "speech_handler", speech_handler, ch, mob, speech);
}

/*
Expand Down
5 changes: 5 additions & 0 deletions code/act_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,21 @@ void obj_say_heavenly_sceptre (CHAR_DATA *ch, OBJ_DATA *obj,char *argument);
const char *upstring(const char *i);
const char *lowstring(const char *i);
void do_say (CHAR_DATA *ch, char *argument);
void do_say_queue (CHAR_DATA *ch, std::string argument);
void say_to (CHAR_DATA *ch, CHAR_DATA *victim, char *argument, char *extra);
void say_to_queue (CHAR_DATA *ch, CHAR_DATA *victim, std::string argument, std::string extra);
void do_whisper (CHAR_DATA *ch, char *argument);
void do_whisper_queue (CHAR_DATA *ch, std::string argument);
void do_sing (CHAR_DATA *ch, char *argument);
void do_pray (CHAR_DATA *ch, char *argument);
void do_tell (CHAR_DATA *ch, char *argument);
void do_tell_queue (CHAR_DATA *ch, std::string argument);
void do_noreply (CHAR_DATA *ch, char *argument);
void do_reply (CHAR_DATA *ch, char *argument);
void do_yell (CHAR_DATA *ch, char *argument);
void do_myell (CHAR_DATA *ch, char *argument, CHAR_DATA *attacker);
void do_emote (CHAR_DATA *ch, char *argument);
void do_emote_queue (CHAR_DATA *ch, std::string argument);
void do_pmote (CHAR_DATA *ch, char *argument);
/* Simple, yet brilliant. Notify immortals when players are using words that
* are offensive/harassing or commonly associated with OOC speech. Immortals
Expand Down
5 changes: 5 additions & 0 deletions code/act_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -2311,6 +2311,11 @@ void do_look(CHAR_DATA *ch, char *argument)
}
}

void do_look_queue (CHAR_DATA *ch, std::string argument)
{
do_look(ch, argument.data());
}

/* RT added back for the hell of it */
void do_read(CHAR_DATA *ch, char *argument)
{
Expand Down
1 change: 1 addition & 0 deletions code/act_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ bool show_altdesc (ROOM_INDEX_DATA *room);
char *get_room_description(ROOM_INDEX_DATA *room);
char *get_room_name(ROOM_INDEX_DATA *room);
void do_look (CHAR_DATA *ch, char *argument);
void do_look_queue (CHAR_DATA *ch, std::string argument);
/* RT added back for the hell of it */
void do_read (CHAR_DATA *ch, char *argument);
/*
Expand Down
8 changes: 4 additions & 4 deletions code/act_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ void move_char(CHAR_DATA *ch, int door, bool automatic, bool fcharm)

if (td != nullptr && td->trap && td->trap->armed && ch->Profs()->ProfEffect("trap detecting") >= td->trap->quality)
{
RS.Queue.AddToQueue(1, 2, send_to_char, "Something about your surroundings suddenly makes you feel wary.\n\r", ch);
RS.Queue.AddToQueue(1, "move_char", "send_to_char_queue", send_to_char_queue, "Something about your surroundings suddenly makes you feel wary.\n\r", ch);
break;
}
}
Expand Down Expand Up @@ -1048,7 +1048,7 @@ void move_char(CHAR_DATA *ch, int door, bool automatic, bool fcharm)
}
else if (is_npc(fch) && fch->last_fought == ch)
{
RS.Queue.AddToQueue((number_percent() > 25) ? 1 : 2, 2, track_attack, fch, ch);
RS.Queue.AddToQueue((number_percent() > 25) ? 1 : 2, "move_char", "track_attack", track_attack, fch, ch);
}

/* Greet trigger for mobs */
Expand Down Expand Up @@ -1215,7 +1215,7 @@ void trip_trap(CHAR_DATA *ch, ROOM_INDEX_DATA *room, TRAP_DATA *trap)
if (ch->Profs()->GetProf("trap detecting") / 2 >= trap->quality)
{
ch->Profs()->CheckImprove("trap detecting", 400);
RS.Queue.AddToQueue(1, 2, send_to_char, "As you carefully advance, you spot a trap and quickly sidestep it!\n\r", ch);
RS.Queue.AddToQueue(1, "trip_trap", "send_to_char_queue", send_to_char_queue, "As you carefully advance, you spot a trap and quickly sidestep it!\n\r", ch);
return;
}
else
Expand All @@ -1229,7 +1229,7 @@ void trip_trap(CHAR_DATA *ch, ROOM_INDEX_DATA *room, TRAP_DATA *trap)
if (trap->timer)
{
act(trap->trig_echo, ch, 0, 0, TO_CHAR);
RS.Queue.AddToQueue(trap->timer, 3, trap_execute, nullptr, room, trap);
RS.Queue.AddToQueue(trap->timer, "do_down", "trap_execute", trap_execute, nullptr, room, trap);
}
else
{
Expand Down
6 changes: 4 additions & 2 deletions code/act_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -2906,7 +2906,8 @@ void do_quaff(CHAR_DATA *ch, char *argument)
if (!check_deny_magic(ch))
{
RS.Queue.AddToQueue(nDelay,
5,
"do_quaff",
"quaff_potion",
quaff_potion,
ch,
obj->value[0],
Expand Down Expand Up @@ -2950,7 +2951,8 @@ void do_quaff(CHAR_DATA *ch, char *argument)
if (!check_deny_magic(ch))
{
RS.Queue.AddToQueue(nDelay,
5,
"do_quaff",
"quaff_potion",
quaff_potion,
ch,
obj->value[0],
Expand Down
7 changes: 6 additions & 1 deletion code/act_wiz.c
Original file line number Diff line number Diff line change
Expand Up @@ -3454,7 +3454,7 @@ void start_reboot(CHAR_DATA *ch)
do_echo(ch, buf);

reboot_num--;
RS.Queue.AddToQueue(60, 1, (void *)start_reboot, ch);
RS.Queue.AddToQueue(60, "start_reboot", "start_reboot", start_reboot, ch);
}
}
}
Expand Down Expand Up @@ -6322,6 +6322,11 @@ void do_astrip(CHAR_DATA *ch, char *argument)
send_to_char("All affects stripped from yourself.\n\r", ch);
}

void do_astrip_queue (CHAR_DATA *ch, std::string argument)
{
do_astrip(ch, argument.data());
}

void do_limcounter(CHAR_DATA *ch, char *argument)
{
OBJ_INDEX_DATA *pObjIndex;
Expand Down
1 change: 1 addition & 0 deletions code/act_wiz.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ void do_holylight (CHAR_DATA *ch, char *argument);
void do_prefi (CHAR_DATA *ch, char *argument);
void do_prefix (CHAR_DATA *ch, char *argument);
void do_astrip (CHAR_DATA *ch,char *argument);
void do_astrip_queue (CHAR_DATA *ch, std::string argument);
void do_limcounter (CHAR_DATA *ch,char *argument);
void do_classes (CHAR_DATA *ch, char *argument);
void do_rinfo (CHAR_DATA *ch,char *argument);
Expand Down
8 changes: 4 additions & 4 deletions code/aprog.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ void tick_prog_ilopheth(AREA_DATA *area)
END_COLOR(pedroom->people));
act(buf, pedroom->people, 0, 0, TO_ALL);

RS.Queue.AddToQueue(4, 5, act, "The opacity of the crystal sphere appears to fade, and it begins to glow a brilliant white!", pedroom->people, 0, 0, TO_ALL);
RS.Queue.AddToQueue(7, 5, act, "To the northwest, an immense pillar of light ascends from the forest into the heavens!", pedroom->people, 0, 0, TO_ALL);
RS.Queue.AddToQueue(4, "tick_prog_ilopheth", "act_queue", act_queue, "The opacity of the crystal sphere appears to fade, and it begins to glow a brilliant white!", pedroom->people, nullptr, nullptr, TO_ALL);
RS.Queue.AddToQueue(7, "tick_prog_ilopheth", "act_queue", act_queue, "To the northwest, an immense pillar of light ascends from the forest into the heavens!", pedroom->people, nullptr, nullptr, TO_ALL);
}

for (obj = portroom->contents; obj; obj = obj->next_content)
Expand Down Expand Up @@ -416,10 +416,10 @@ void sun_prog_ilopheth(AREA_DATA *area)
switch (sun)
{
case SolarPosition::Sunrise:
RS.Queue.AddToQueue(15, 2, (void *)zone_echo, area, (char *)"With the beginning of the day sounds of life fill the valley, as the forest comes alive.");
RS.Queue.AddToQueue(15, "sun_prog_ilopheth", "zone_echo_queue", zone_echo_queue, area, "With the beginning of the day sounds of life fill the valley, as the forest comes alive.");
break;
case SolarPosition::Sunset:
RS.Queue.AddToQueue(15, 2, (void *)zone_echo, area, (char *)"The forest grows still, as the night sky settles over the valley.");
RS.Queue.AddToQueue(15, "sun_prog_ilopheth", "zone_echo_queue", zone_echo_queue, area, "The forest grows still, as the night sky settles over the valley.");
break;
}
}
Expand Down
Loading
Loading