From 3635026433fcdeeba3aa83a2476f0dd1131d4cb3 Mon Sep 17 00:00:00 2001 From: tjr1974 <116045172+tjr1974@users.noreply.github.com> Date: Sun, 23 Oct 2022 14:57:14 -0500 Subject: [PATCH 1/6] Update handler.c Fixes the display order of objects in obj_to_room(). Objects are now displayed in the order they are placed/dropped. This prevents fountains, boards, etcetera from "moving" around the room. --- src/handler.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/handler.c b/src/handler.c index 61bca67..d6660f4 100644 --- a/src/handler.c +++ b/src/handler.c @@ -671,17 +671,25 @@ struct char_data *get_char_num(mob_rnum nr) /* put an object in a room */ void obj_to_room(struct obj_data *object, room_rnum room) { - if (!object || room == NOWHERE || room > top_of_world) + if (!object || room == NOWHERE || room > top_of_world){ log("SYSERR: Illegal value(s) passed to obj_to_room. (Room #%d/%d, obj %p)", room, top_of_world, (void *)object); - else { - object->next_content = world[room].contents; - world[room].contents = object; - IN_ROOM(object) = room; - object->carried_by = NULL; - if (ROOM_FLAGGED(room, ROOM_HOUSE)) - SET_BIT_AR(ROOM_FLAGS(room), ROOM_HOUSE_CRASH); } + else { + if (world[room].contents == NULL){ // if list is empty + world[room].contents = object; // add object to list + } + else { + struct obj_data *i = world[room].contents; // define a temporary pointer + while (i->next_content != NULL) i = i->next_content; // find the first without a next_content + i->next_content = object; // add object at the end + } + object->next_content = NULL; // mostly for sanity. should do nothing. + IN_ROOM(object) = room + object->carried_by = NULL; + if (ROOM_FLAGGED(room, ROOM_HOUSE)) + SET_BIT_AR(ROOM_FLAGS(room), ROOM_HOUSE_CRASH); + } } /* Take an object from a room */ From 7039f9c402b8fad3ba37184b992853cb1ec74b0f Mon Sep 17 00:00:00 2001 From: tjr1974 <116045172+tjr1974@users.noreply.github.com> Date: Sun, 23 Oct 2022 15:12:57 -0500 Subject: [PATCH 2/6] Update act.informative.c Fixes unguarded else clauses due to inconsistent use of {} in look_at_room(). --- src/act.informative.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/act.informative.c b/src/act.informative.c index e1187ef..443aff6 100644 --- a/src/act.informative.c +++ b/src/act.informative.c @@ -492,7 +492,8 @@ void look_at_room(struct char_data *ch, int ignore_brief) if (IS_DARK(IN_ROOM(ch)) && !CAN_SEE_IN_DARK(ch)) { send_to_char(ch, "It is pitch black...\r\n"); return; - } else if (AFF_FLAGGED(ch, AFF_BLIND) && GET_LEVEL(ch) < LVL_IMMORT) { + } + else if (AFF_FLAGGED(ch, AFF_BLIND) && GET_LEVEL(ch) < LVL_IMMORT) { send_to_char(ch, "You see nothing but infinite darkness...\r\n"); return; } @@ -511,17 +512,19 @@ void look_at_room(struct char_data *ch, int ignore_brief) send_to_char(ch, "]"); } } - else + else { send_to_char(ch, "%s", world[IN_ROOM(ch)].name); - send_to_char(ch, "%s\r\n", CCNRM(ch, C_NRM)); + } + send_to_char(ch, "%s\r\n", CCCYN(ch, C_NRM)); if ((!IS_NPC(ch) && !PRF_FLAGGED(ch, PRF_BRIEF)) || ignore_brief || ROOM_FLAGGED(IN_ROOM(ch), ROOM_DEATH)) { if(!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOMAP) && can_see_map(ch)) str_and_map(world[target_room].description, ch, target_room); - else + } + else { send_to_char(ch, "%s", world[IN_ROOM(ch)].description); - } + } /* autoexits */ if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOEXIT)) From 97bd28ffd37e1562485bf8d0bfcb0caaf03212de Mon Sep 17 00:00:00 2001 From: tjr1974 <116045172+tjr1974@users.noreply.github.com> Date: Sun, 23 Oct 2022 15:29:43 -0500 Subject: [PATCH 3/6] Update act.informative.c Fixes unguarded blocks of code in ACMD(do_exits) that could cause the server to report scripted trigger events (mob movements, exit links to rooms being reassigned, and doors being opened or closed) as script errors. Particularly, if this code is copy and pasted into the do_auto_exits(). --- src/act.informative.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/act.informative.c b/src/act.informative.c index 443aff6..22a8636 100644 --- a/src/act.informative.c +++ b/src/act.informative.c @@ -443,39 +443,44 @@ ACMD(do_exits) { int door, len = 0; - if (AFF_FLAGGED(ch, AFF_BLIND) && GET_LEVEL(ch) < LVL_IMMORT) { + if (AFF_FLAGGED(ch, AFF_BLIND) && GET_LEVEL(ch) < LVL_IMMORT) + { send_to_char(ch, "You can't see a damned thing, you're blind!\r\n"); return; } - + send_to_char(ch, "Obvious exits:\r\n"); - for (door = 0; door < DIR_COUNT; door++) { + for (door = 0; door < DIR_COUNT; door++) + { if (!EXIT(ch, door) || EXIT(ch, door)->to_room == NOWHERE) continue; if (EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED) && !CONFIG_DISP_CLOSED_DOORS) continue; if (EXIT_FLAGGED(EXIT(ch, door), EX_HIDDEN) && !PRF_FLAGGED(ch, PRF_HOLYLIGHT)) - continue; + continue; len++; if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_SHOWVNUMS) && !EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED)) - send_to_char(ch, "%-5s - [%5d]%s %s\r\n", dirs[door], GET_ROOM_VNUM(EXIT(ch, door)->to_room), - EXIT_FLAGGED(EXIT(ch, door), EX_HIDDEN) ? " [HIDDEN]" : "", world[EXIT(ch, door)->to_room].name); + { + send_to_char(ch, "%-5s -[%5d]%s %s\r\n", dirs[door], GET_ROOM_VNUM(EXIT(ch, door)->to_room), + EXIT_FLAGGED(EXIT(ch, door), EX_HIDDEN) ? "[HIDDEN]" : "", world[EXIT(ch, door)->to_room].name); + } else if (CONFIG_DISP_CLOSED_DOORS && EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED)) { /* But we tell them the door is closed */ send_to_char(ch, "%-5s - The %s is closed%s\r\n", dirs[door], - (EXIT(ch, door)->keyword)? fname(EXIT(ch, door)->keyword) : "opening", - EXIT_FLAGGED(EXIT(ch, door), EX_HIDDEN) ? " and hidden." : "."); - } + (EXIT(ch, door)->keyword) ? fname(EXIT(ch, door)->keyword) : "opening", + EXIT_FLAGGED(EXIT(ch, door), EX_HIDDEN) ? " and hidden." : "."); + } else + { send_to_char(ch, "%-5s - %s\r\n", dirs[door], IS_DARK(EXIT(ch, door)->to_room) && - !CAN_SEE_IN_DARK(ch) ? "Too dark to tell." : world[EXIT(ch, door)->to_room].name); + !CAN_SEE_IN_DARK(ch) ? "Too dark to tell." : world[EXIT(ch, door)->to_room].name); + } + if (!len) + send_to_char(ch, " None.\r\n"); } - - if (!len) - send_to_char(ch, " None.\r\n"); } void look_at_room(struct char_data *ch, int ignore_brief) From 59398b2fdca8be5ac65cf7f7043056c9cf95e6bc Mon Sep 17 00:00:00 2001 From: tjr1974 <116045172+tjr1974@users.noreply.github.com> Date: Mon, 24 Oct 2022 16:07:49 -0500 Subject: [PATCH 4/6] Update handler.c Fixes indentations in obj_to_room() --- src/handler.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/handler.c b/src/handler.c index d6660f4..72eaf9a 100644 --- a/src/handler.c +++ b/src/handler.c @@ -675,21 +675,21 @@ void obj_to_room(struct obj_data *object, room_rnum room) log("SYSERR: Illegal value(s) passed to obj_to_room. (Room #%d/%d, obj %p)", room, top_of_world, (void *)object); } - else { - if (world[room].contents == NULL){ // if list is empty - world[room].contents = object; // add object to list + else { + if (world[room].contents == NULL){ // if list is empty + world[room].contents = object; // add object to list } - else { - struct obj_data *i = world[room].contents; // define a temporary pointer - while (i->next_content != NULL) i = i->next_content; // find the first without a next_content - i->next_content = object; // add object at the end - } - object->next_content = NULL; // mostly for sanity. should do nothing. - IN_ROOM(object) = room - object->carried_by = NULL; - if (ROOM_FLAGGED(room, ROOM_HOUSE)) - SET_BIT_AR(ROOM_FLAGS(room), ROOM_HOUSE_CRASH); - } + else { + struct obj_data *i = world[room].contents; // define a temporary pointer + while (i->next_content != NULL) i = i->next_content; // find the first without a next_content + i->next_content = object; // add object at the end + } + object->next_content = NULL; // mostly for sanity. should do nothing. + IN_ROOM(object) = room + object->carried_by = NULL; + if (ROOM_FLAGGED(room, ROOM_HOUSE)) + SET_BIT_AR(ROOM_FLAGS(room), ROOM_HOUSE_CRASH); + } } /* Take an object from a room */ From 041765438a6052726ce1018468e396aa0d526fda Mon Sep 17 00:00:00 2001 From: tjr1974 <116045172+tjr1974@users.noreply.github.com> Date: Mon, 24 Oct 2022 16:38:11 -0500 Subject: [PATCH 5/6] Update act.informative.c Used code formatter to correct indentations and align all {} in the look_at_room() Checked for unmactched braces and found none. My code editor shows all {} are matched. --- src/act.informative.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/src/act.informative.c b/src/act.informative.c index 22a8636..48516ac 100644 --- a/src/act.informative.c +++ b/src/act.informative.c @@ -485,7 +485,7 @@ ACMD(do_exits) void look_at_room(struct char_data *ch, int ignore_brief) { - trig_data *t; + trig_data * t; struct room_data *rm = &world[IN_ROOM(ch)]; room_vnum target_room; @@ -494,48 +494,57 @@ void look_at_room(struct char_data *ch, int ignore_brief) if (!ch->desc) return; - if (IS_DARK(IN_ROOM(ch)) && !CAN_SEE_IN_DARK(ch)) { + if (IS_DARK(IN_ROOM(ch)) && !CAN_SEE_IN_DARK(ch)) + { send_to_char(ch, "It is pitch black...\r\n"); return; - } - else if (AFF_FLAGGED(ch, AFF_BLIND) && GET_LEVEL(ch) < LVL_IMMORT) { + } + else if (AFF_FLAGGED(ch, AFF_BLIND) && GET_LEVEL(ch) < LVL_IMMORT) + { send_to_char(ch, "You see nothing but infinite darkness...\r\n"); return; } + send_to_char(ch, "%s", CCCYN(ch, C_NRM)); - if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_SHOWVNUMS)) { + if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_SHOWVNUMS)) + { char buf[MAX_STRING_LENGTH]; sprintbitarray(ROOM_FLAGS(IN_ROOM(ch)), room_bits, RF_ARRAY_MAX, buf); send_to_char(ch, "[%5d] ", GET_ROOM_VNUM(IN_ROOM(ch))); - send_to_char(ch, "%s [ %s] [ %s ]", world[IN_ROOM(ch)].name, buf, sector_types[world[IN_ROOM(ch)].sector_type]); + send_to_char(ch, "%s[ %s][ %s ]", world[IN_ROOM(ch)].name, buf, sector_types[world[IN_ROOM(ch)].sector_type]); - if (SCRIPT(rm)) { + if (SCRIPT(rm)) + { send_to_char(ch, "[T"); for (t = TRIGGERS(SCRIPT(rm)); t; t = t->next) send_to_char(ch, " %d", GET_TRIG_VNUM(t)); send_to_char(ch, "]"); } } - else { + else + { send_to_char(ch, "%s", world[IN_ROOM(ch)].name); } + send_to_char(ch, "%s\r\n", CCCYN(ch, C_NRM)); if ((!IS_NPC(ch) && !PRF_FLAGGED(ch, PRF_BRIEF)) || ignore_brief || - ROOM_FLAGGED(IN_ROOM(ch), ROOM_DEATH)) { - if(!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOMAP) && can_see_map(ch)) - str_and_map(world[target_room].description, ch, target_room); - } - else { - send_to_char(ch, "%s", world[IN_ROOM(ch)].description); - } + ROOM_FLAGGED(IN_ROOM(ch), ROOM_DEATH)) + { + if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOMAP) && can_see_map(ch)) + str_and_map(world[target_room].description, ch, target_room); + } + else + { + send_to_char(ch, "%s", world[IN_ROOM(ch)].description); + } - /* autoexits */ + /*autoexits */ if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOEXIT)) do_auto_exits(ch); - /* now list characters & objects */ + /*now list characters &objects */ list_obj_to_char(world[IN_ROOM(ch)].contents, ch, SHOW_OBJ_LONG, FALSE); list_char_to_char(world[IN_ROOM(ch)].people, ch); } From 34aca229df79dc14c73e811ae7fc169b0f466c26 Mon Sep 17 00:00:00 2001 From: tjr1974 <116045172+tjr1974@users.noreply.github.com> Date: Mon, 24 Oct 2022 17:07:54 -0500 Subject: [PATCH 6/6] Update act.informative.c Used code formatter to correct indentations and align all {} in lACMD(do_exits) Checked for unmactched braces and found none. My code editor shows all {} are matched. --- src/act.informative.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/act.informative.c b/src/act.informative.c index 48516ac..6964a20 100644 --- a/src/act.informative.c +++ b/src/act.informative.c @@ -448,7 +448,7 @@ ACMD(do_exits) send_to_char(ch, "You can't see a damned thing, you're blind!\r\n"); return; } - + send_to_char(ch, "Obvious exits:\r\n"); for (door = 0; door < DIR_COUNT; door++) @@ -467,8 +467,9 @@ ACMD(do_exits) send_to_char(ch, "%-5s -[%5d]%s %s\r\n", dirs[door], GET_ROOM_VNUM(EXIT(ch, door)->to_room), EXIT_FLAGGED(EXIT(ch, door), EX_HIDDEN) ? "[HIDDEN]" : "", world[EXIT(ch, door)->to_room].name); } - else if (CONFIG_DISP_CLOSED_DOORS && EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED)) { - /* But we tell them the door is closed */ + else if (CONFIG_DISP_CLOSED_DOORS && EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED)) + { + /*But we tell them the door is closed */ send_to_char(ch, "%-5s - The %s is closed%s\r\n", dirs[door], (EXIT(ch, door)->keyword) ? fname(EXIT(ch, door)->keyword) : "opening", EXIT_FLAGGED(EXIT(ch, door), EX_HIDDEN) ? " and hidden." : "."); @@ -478,9 +479,9 @@ ACMD(do_exits) send_to_char(ch, "%-5s - %s\r\n", dirs[door], IS_DARK(EXIT(ch, door)->to_room) && !CAN_SEE_IN_DARK(ch) ? "Too dark to tell." : world[EXIT(ch, door)->to_room].name); } - if (!len) - send_to_char(ch, " None.\r\n"); } + if (!len) + send_to_char(ch, " None.\r\n"); } void look_at_room(struct char_data *ch, int ignore_brief)