From f34cc2c8ed6b5e85ff22e138416174a3ae3803b8 Mon Sep 17 00:00:00 2001 From: Rumble Date: Tue, 20 Mar 2007 22:26:58 +0000 Subject: [PATCH] - Added object type CHAIR (thanks Dark). - Added ZZZ directories to plrfiles and plrvars (thanks Zizazat). - Added 00 files to plrfiles directories (thanks Khorlane). - Added mail check at reconnect and when coming back from AFK. - Added JamDog's updated levenshtein_distance that compiles clean with MSVC++. - Added AFK to player L-desc. --Rumble --- changelog | 9 +- lib/plrfiles/A-E/00 | 1 + lib/plrfiles/F-J/00 | 1 + lib/plrfiles/K-O/00 | 1 + lib/plrfiles/P-T/00 | 1 + lib/plrfiles/U-Z/00 | 1 + lib/plrfiles/ZZZ/00 | 1 + lib/plrvars/ZZZ/00 | 1 + lib/world/obj/12.obj | 10 +- lib/world/zon/12.zon | 1 + src/act.informative.c | 41 ++++++- src/act.movement.c | 142 ++++++++++++------------ src/act.other.c | 8 +- src/act.wizard.c | 8 ++ src/constants.c | 4 +- src/db.c | 11 +- src/genobj.c | 126 +++++++-------------- src/handler.c | 113 +++++++------------ src/interpreter.c | 2 + src/oasis.h | 8 +- src/objsave.c | 212 ++++++++++++------------------------ src/oedit.c | 47 ++++---- src/players.c | 2 + src/structs.h | 4 + src/utils.c | 247 ++++++++++++++++++++---------------------- src/utils.h | 118 +++++++------------- 26 files changed, 494 insertions(+), 626 deletions(-) create mode 100644 lib/plrfiles/A-E/00 create mode 100644 lib/plrfiles/F-J/00 create mode 100644 lib/plrfiles/K-O/00 create mode 100644 lib/plrfiles/P-T/00 create mode 100644 lib/plrfiles/U-Z/00 create mode 100644 lib/plrfiles/ZZZ/00 create mode 100644 lib/plrvars/ZZZ/00 diff --git a/changelog b/changelog index 52e0f9a..b880a7f 100644 --- a/changelog +++ b/changelog @@ -5,7 +5,14 @@ The Builder Academy builderacademy.net 9091 tbaMUD 3.52 -[Mar 18 2007] - Rumble +[Mar 20 2007] - Rumble + Added object type CHAIR (thanks Dark). + Added ZZZ directories to plrfiles and plrvars (thanks Zizazat). + Added 00 files to plrfiles directories (thanks Khorlane). + Added mail check at reconnect and when coming back from AFK. +[Mar 19 2007] - Rumble + Added JamDog's updated levenshtein_distance that compiles clean with MSVC++. + Added AFK to player L-desc. Cleaned up the code by running it through a g++ compiler (thanks Rhade). Added AFK to the prompt. Stop snooping at do_quit to prevent snooping of passwords on deletion or password reset. diff --git a/lib/plrfiles/A-E/00 b/lib/plrfiles/A-E/00 new file mode 100644 index 0000000..0805cef --- /dev/null +++ b/lib/plrfiles/A-E/00 @@ -0,0 +1 @@ +This is a placeholder file so the directory will be created diff --git a/lib/plrfiles/F-J/00 b/lib/plrfiles/F-J/00 new file mode 100644 index 0000000..0805cef --- /dev/null +++ b/lib/plrfiles/F-J/00 @@ -0,0 +1 @@ +This is a placeholder file so the directory will be created diff --git a/lib/plrfiles/K-O/00 b/lib/plrfiles/K-O/00 new file mode 100644 index 0000000..0805cef --- /dev/null +++ b/lib/plrfiles/K-O/00 @@ -0,0 +1 @@ +This is a placeholder file so the directory will be created diff --git a/lib/plrfiles/P-T/00 b/lib/plrfiles/P-T/00 new file mode 100644 index 0000000..0805cef --- /dev/null +++ b/lib/plrfiles/P-T/00 @@ -0,0 +1 @@ +This is a placeholder file so the directory will be created diff --git a/lib/plrfiles/U-Z/00 b/lib/plrfiles/U-Z/00 new file mode 100644 index 0000000..0805cef --- /dev/null +++ b/lib/plrfiles/U-Z/00 @@ -0,0 +1 @@ +This is a placeholder file so the directory will be created diff --git a/lib/plrfiles/ZZZ/00 b/lib/plrfiles/ZZZ/00 new file mode 100644 index 0000000..0805cef --- /dev/null +++ b/lib/plrfiles/ZZZ/00 @@ -0,0 +1 @@ +This is a placeholder file so the directory will be created diff --git a/lib/plrvars/ZZZ/00 b/lib/plrvars/ZZZ/00 new file mode 100644 index 0000000..0805cef --- /dev/null +++ b/lib/plrvars/ZZZ/00 @@ -0,0 +1 @@ +This is a placeholder file so the directory will be created diff --git a/lib/world/obj/12.obj b/lib/world/obj/12.obj index 58f9a01..af6a611 100644 --- a/lib/world/obj/12.obj +++ b/lib/world/obj/12.obj @@ -3,7 +3,7 @@ email list staff~ a list of the staff's emails~ A list of the staff's emails has been left here.~ ~ -12 0 ao 0 +24 0 ao 0 0 0 0 0 1 1 0 0 E @@ -74,13 +74,13 @@ Staff~ 1 3 3 31 1 1 0 0 #1209 -squishy armchair chair~ +chair~ a squishy armchair~ A large squishy armchair sits in front of the fireplace.~ ~ -12 0 0 0 -0 0 0 0 -0 0 0 0 +24 0 a 0 +1 0 0 0 +1 1 0 0 T 1209 T 1286 E diff --git a/lib/world/zon/12.zon b/lib/world/zon/12.zon index 6383453..31e50dd 100644 --- a/lib/world/zon/12.zon +++ b/lib/world/zon/12.zon @@ -2,6 +2,7 @@ CircleMUD~ God Simplex~ 1200 1299 10 0 +O 0 1209 1 1204 (a squishy armchair) R 0 1204 3098 -1 (a holy bulletin board) O 0 3098 99 1204 (a holy bulletin board) R 0 1293 1227 -1 (a staff bulletin board) diff --git a/src/act.informative.c b/src/act.informative.c index fe83124..e8520fe 100644 --- a/src/act.informative.c +++ b/src/act.informative.c @@ -98,6 +98,9 @@ int *cmd_sort_info; void show_obj_to_char(struct obj_data *obj, struct char_data *ch, int mode) { + int found = 0; + struct char_data *temp; + if (!obj || !ch) { log("SYSERR: NULL pointer in show_obj_to_char(): obj=%p ch=%p", obj, ch); /* SYSERR_DESC: Somehow a NULL pointer was sent to show_obj_to_char() in @@ -107,6 +110,21 @@ void show_obj_to_char(struct obj_data *obj, struct char_data *ch, int mode) return; } + if ((mode == 0) && obj->description) { + if (!GET_OBJ_VAL(obj, 1) == 0 || OBJ_SAT_IN_BY(obj)) { + temp = OBJ_SAT_IN_BY(obj); + for (temp = OBJ_SAT_IN_BY(obj); temp; temp = NEXT_SITTING(temp)) { + if (temp == ch) + found++; + } + if (found) { + send_to_char(ch, "You are %s upon %s.", GET_POS(ch) == POS_SITTING ? "sitting" : + "resting", obj->short_description); + goto end; + } + } + } + switch (mode) { case SHOW_OBJ_LONG: /* hide objects starting with . from non-holylighted people Idea from Elaseth of TBA */ @@ -158,6 +176,7 @@ void show_obj_to_char(struct obj_data *obj, struct char_data *ch, int mode) * call with the incorrect mode and change it to an acceptable mode. */ return; } + end: show_obj_modifiers(obj, ch); send_to_char(ch, "\r\n"); @@ -289,6 +308,7 @@ void look_at_char(struct char_data *i, struct char_data *ch) void list_one_char(struct char_data *i, struct char_data *ch) { + struct obj_data *chair; const char *positions[] = { " is lying here, dead.", " is lying here, mortally wounded.", @@ -337,13 +357,21 @@ void list_one_char(struct char_data *i, struct char_data *ch) send_to_char(ch, " (linkless)"); if (!IS_NPC(i) && PLR_FLAGGED(i, PLR_WRITING)) send_to_char(ch, " (writing)"); - if (!IS_NPC(i) && PRF_FLAGGED(i, PRF_BUILDWALK)) send_to_char(ch, " (buildwalk)"); + if (!IS_NPC(i) && PRF_FLAGGED(i, PRF_AFK)) + send_to_char(ch, " (AFK)"); - if (GET_POS(i) != POS_FIGHTING) - send_to_char(ch, "%s", positions[(int) GET_POS(i)]); + if (GET_POS(i) != POS_FIGHTING) { + if (!SITTING(i)) + send_to_char(ch, "%s", positions[(int) GET_POS(i)]); else { + chair = SITTING(i); + send_to_char(ch, " is %s upon %s.", ((GET_POS(i) == POS_SITTING) ? + "sitting" : "resting"), (CAN_SEE_OBJ(ch, chair) ? + chair->short_description : "something")); + } + } else { if (FIGHTING(i)) { send_to_char(ch, " is here, fighting "); if (FIGHTING(i) == ch) @@ -791,7 +819,12 @@ ACMD(do_score) send_to_char(ch, "You are resting.\r\n"); break; case POS_SITTING: - send_to_char(ch, "You are sitting.\r\n"); + if (!SITTING(ch)) + send_to_char(ch, "You are sitting.\r\n"); + else { + struct obj_data *chair = SITTING(ch); + send_to_char(ch, "You are sitting upon %s.\r\n", chair->short_description); + } break; case POS_FIGHTING: send_to_char(ch, "You are fighting %s.\r\n", FIGHTING(ch) ? PERS(FIGHTING(ch), ch) : "thin air"); diff --git a/src/act.movement.c b/src/act.movement.c index 3cff728..008a50d 100644 --- a/src/act.movement.c +++ b/src/act.movement.c @@ -10,8 +10,6 @@ #include "conf.h" #include "sysdep.h" - - #include "structs.h" #include "utils.h" #include "comm.h" @@ -45,18 +43,12 @@ ACMD(do_sleep); ACMD(do_wake); ACMD(do_follow); - /* simple function to determine if char can walk on water */ int has_boat(struct char_data *ch) { struct obj_data *obj; int i; -/* - if (ROOM_IDENTITY(IN_ROOM(ch)) == DEAD_SEA) - return (1); -*/ - if (GET_LEVEL(ch) > LVL_IMMORT) return (1); @@ -76,26 +68,16 @@ int has_boat(struct char_data *ch) return (0); } - - -/* do_simple_move assumes - * 1. That there is no master and no followers. - * 2. That the direction exists. - * - * Returns : - * 1 : If succes. - * 0 : If fail - */ +/* do_simple_move assumes that there is no master, no followers and that the + * direction exists. It returns 1 for success, 0 if failure. */ int do_simple_move(struct char_data *ch, int dir, int need_specials_check) { char throwaway[MAX_INPUT_LENGTH] = ""; /* Functions assume writable. */ room_rnum was_in = IN_ROOM(ch); int need_movement; - /* - * Check for special routines (North is 1 in command list, but 0 here) Note - * -- only check if following; this avoids 'double spec-proc' bug - */ + /* Check for special routines (North is 1 in command list, but 0 here) Note + * -- only check if following; this avoids 'double spec-proc' bug */ if (need_specials_check && special(ch, dir + 1, throwaway)) return (0); @@ -169,8 +151,8 @@ int do_simple_move(struct char_data *ch, int dir, int need_specials_check) char_from_room(ch); char_to_room(ch, world[was_in].dir_option[dir]->to_room); - /* move them first, then move them back if they aren't allowed to go. */ - /* see if an entry trigger disallows the move */ + /* move them first, then move them back if they aren't allowed to go. Also, + * see if an entry trigger disallows the move */ if (!entry_mtrigger(ch) || !enter_wtrigger(&world[IN_ROOM(ch)], ch, dir)) { char_from_room(ch); char_to_room(ch, was_in); @@ -200,7 +182,6 @@ int do_simple_move(struct char_data *ch, int dir, int need_specials_check) return (1); } - int perform_move(struct char_data *ch, int dir, int need_specials_check) { room_rnum was_in; @@ -236,18 +217,14 @@ int perform_move(struct char_data *ch, int dir, int need_specials_check) return (0); } - ACMD(do_move) { - /* - * This is basically a mapping of cmd numbers to perform_move indices. - * It cannot be done in perform_move because perform_move is called - * by other functions which do not require the remapping. - */ + /* This is basically a mapping of cmd numbers to perform_move indices. It + * cannot be done in perform_move because perform_move is called by other + * functions which do not require the remapping. */ perform_move(ch, subcmd - 1, 0); } - int find_door(struct char_data *ch, const char *type, char *dir, const char *cmdname) { int door; @@ -287,7 +264,6 @@ int find_door(struct char_data *ch, const char *type, char *dir, const char *cmd } } - int has_key(struct char_data *ch, obj_vnum key) { struct obj_data *o; @@ -303,8 +279,6 @@ int has_key(struct char_data *ch, obj_vnum key) return (0); } - - #define NEED_OPEN (1 << 0) #define NEED_CLOSED (1 << 1) #define NEED_UNLOCKED (1 << 2) @@ -328,7 +302,6 @@ const int flags_door[] = NEED_CLOSED | NEED_LOCKED }; - #define EXITN(room, door) (world[room].dir_option[door]) #define OPEN_DOOR(room, obj, door) ((obj) ?\ (REMOVE_BIT(GET_OBJ_VAL(obj, 1), CONT_CLOSED)) :\ @@ -417,7 +390,6 @@ void do_doorcmd(struct char_data *ch, struct obj_data *obj, int door, int scmd) scmd == SCMD_CLOSE ? "d" : "ed"); } - int ok_pick(struct char_data *ch, obj_vnum keynum, int pickproof, int scmd) { int percent, skill_lvl; @@ -440,25 +412,19 @@ int ok_pick(struct char_data *ch, obj_vnum keynum, int pickproof, int scmd) return (0); } - -#define DOOR_IS_OPENABLE(ch, obj, door) ((obj) ? \ - ((GET_OBJ_TYPE(obj) == ITEM_CONTAINER) && \ - OBJVAL_FLAGGED(obj, CONT_CLOSEABLE)) :\ - (EXIT_FLAGGED(EXIT(ch, door), EX_ISDOOR))) -#define DOOR_IS_OPEN(ch, obj, door) ((obj) ? \ - (!OBJVAL_FLAGGED(obj, CONT_CLOSED)) :\ - (!EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED))) -#define DOOR_IS_UNLOCKED(ch, obj, door) ((obj) ? \ - (!OBJVAL_FLAGGED(obj, CONT_LOCKED)) :\ - (!EXIT_FLAGGED(EXIT(ch, door), EX_LOCKED))) -#define DOOR_IS_PICKPROOF(ch, obj, door) ((obj) ? \ - (OBJVAL_FLAGGED(obj, CONT_PICKPROOF)) : \ - (EXIT_FLAGGED(EXIT(ch, door), EX_PICKPROOF))) - -#define DOOR_IS_CLOSED(ch, obj, door) (!(DOOR_IS_OPEN(ch, obj, door))) -#define DOOR_IS_LOCKED(ch, obj, door) (!(DOOR_IS_UNLOCKED(ch, obj, door))) -#define DOOR_KEY(ch, obj, door) ((obj) ? (GET_OBJ_VAL(obj, 2)) : \ - (EXIT(ch, door)->key)) +#define DOOR_IS_OPENABLE(ch, obj, door) ((obj) ? ((GET_OBJ_TYPE(obj) == \ + ITEM_CONTAINER) && OBJVAL_FLAGGED(obj, CONT_CLOSEABLE)) :\ + (EXIT_FLAGGED(EXIT(ch, door), EX_ISDOOR))) +#define DOOR_IS_OPEN(ch, obj, door) ((obj) ? (!OBJVAL_FLAGGED(obj, \ + CONT_CLOSED)) : (!EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED))) +#define DOOR_IS_UNLOCKED(ch, obj, door) ((obj) ? (!OBJVAL_FLAGGED(obj, \ + CONT_LOCKED)) : (!EXIT_FLAGGED(EXIT(ch, door), EX_LOCKED))) +#define DOOR_IS_PICKPROOF(ch, obj, door) ((obj) ? (OBJVAL_FLAGGED(obj, \ + CONT_PICKPROOF)) : (EXIT_FLAGGED(EXIT(ch, door), EX_PICKPROOF))) +#define DOOR_IS_CLOSED(ch, obj, door) (!(DOOR_IS_OPEN(ch, obj, door))) +#define DOOR_IS_LOCKED(ch, obj, door) (!(DOOR_IS_UNLOCKED(ch, obj, door))) +#define DOOR_KEY(ch, obj, door) ((obj) ? (GET_OBJ_VAL(obj, 2)) : \ + (EXIT(ch, door)->key)) ACMD(do_gen_door) { @@ -502,8 +468,6 @@ ACMD(do_gen_door) return; } - - ACMD(do_enter) { char buf[MAX_INPUT_LENGTH]; @@ -537,7 +501,6 @@ ACMD(do_enter) } } - ACMD(do_leave) { int door; @@ -557,7 +520,6 @@ ACMD(do_leave) } } - ACMD(do_stand) { switch (GET_POS(ch)) { @@ -567,6 +529,8 @@ ACMD(do_stand) case POS_SITTING: send_to_char(ch, "You stand up.\r\n"); act("$n clambers to $s feet.", TRUE, ch, 0, 0, TO_ROOM); + /* Were they sitting in a chair? */ + char_from_chair(ch); /* Will be sitting after a successful bash and may still be fighting. */ GET_POS(ch) = FIGHTING(ch) ? POS_FIGHTING : POS_STANDING; break; @@ -574,6 +538,8 @@ ACMD(do_stand) send_to_char(ch, "You stop resting, and stand up.\r\n"); act("$n stops resting, and clambers on $s feet.", TRUE, ch, 0, 0, TO_ROOM); GET_POS(ch) = POS_STANDING; + /* Were they sitting in the chair */ + char_from_chair(ch); break; case POS_SLEEPING: send_to_char(ch, "You have to wake up first!\r\n"); @@ -590,14 +556,56 @@ ACMD(do_stand) } } - ACMD(do_sit) { + char arg[MAX_STRING_LENGTH]; + struct obj_data *chair; + struct char_data *tempch; + int found; + + one_argument(argument, arg); + + if (!*arg) + found = 0; + if (!(chair = get_obj_in_list_vis(ch, arg, NULL, world[ch->in_room].contents))) + found = 0; + else + found = 1; + switch (GET_POS(ch)) { case POS_STANDING: - send_to_char(ch, "You sit down.\r\n"); - act("$n sits down.", FALSE, ch, 0, 0, TO_ROOM); - GET_POS(ch) = POS_SITTING; + if (found == 0) { + send_to_char(ch, "You sit down.\r\n"); + act("$n sits down.", FALSE, ch, 0, 0, TO_ROOM); + GET_POS(ch) = POS_SITTING; + } else { + if (GET_OBJ_TYPE(chair) != ITEM_CHAIR) { + send_to_char(ch, "You can't sit on that!\r\n"); + return; + } else if (GET_OBJ_VAL(chair, 1) > GET_OBJ_VAL(chair, 0)) { + /* val 1 is current number in chair, 0 is max in chair */ + act("$p looks like it's all full.", TRUE, ch, chair, 0, TO_CHAR); + log("SYSERR: chair %d holding too many people.", GET_OBJ_VNUM(chair)); + return; + } else if (GET_OBJ_VAL(chair, 1) == GET_OBJ_VAL(chair, 0)) { + act("There is no where left to sit upon $p.", TRUE, ch, chair, 0, TO_CHAR); + return; + } else { + if (OBJ_SAT_IN_BY(chair) == NULL) + OBJ_SAT_IN_BY(chair) = ch; + for (tempch = OBJ_SAT_IN_BY(chair); tempch != ch ; tempch = NEXT_SITTING(tempch)) { + if (NEXT_SITTING(tempch)) + continue; + NEXT_SITTING(tempch) = ch; + } + act("You sit down upon $p.", TRUE, ch, chair, 0, TO_CHAR); + act("$n sits down upon $p.", TRUE, ch, chair, 0, TO_ROOM); + SITTING(ch) = chair; + NEXT_SITTING(ch) = NULL; + GET_OBJ_VAL(chair, 1) += 1; + GET_POS(ch) = POS_SITTING; + } + } break; case POS_SITTING: send_to_char(ch, "You're sitting already.\r\n"); @@ -621,7 +629,6 @@ ACMD(do_sit) } } - ACMD(do_rest) { switch (GET_POS(ch)) { @@ -652,7 +659,6 @@ ACMD(do_rest) } } - ACMD(do_sleep) { switch (GET_POS(ch)) { @@ -678,7 +684,6 @@ ACMD(do_sleep) } } - ACMD(do_wake) { char arg[MAX_INPUT_LENGTH]; @@ -714,11 +719,12 @@ ACMD(do_wake) else { send_to_char(ch, "You awaken, and sit up.\r\n"); act("$n awakens.", TRUE, ch, 0, 0, TO_ROOM); + /* Were they asleep in a chair? */ + char_from_chair(ch); GET_POS(ch) = POS_SITTING; } } - ACMD(do_follow) { char buf[MAX_INPUT_LENGTH]; diff --git a/src/act.other.c b/src/act.other.c index b7b3efb..e6aaffc 100644 --- a/src/act.other.c +++ b/src/act.other.c @@ -28,7 +28,7 @@ extern struct spell_info_type spell_info[]; extern const char *class_abbrevs[]; -/* extern procedures */ +/* extern functions */ void list_skills(struct char_data *ch); void appear(struct char_data *ch); void perform_immort_vis(struct char_data *ch); @@ -36,6 +36,7 @@ SPECIAL(shop_keeper); ACMD(do_gen_comm); void die(struct char_data *ch, struct char_data * killer); void Crash_rentsave(struct char_data *ch, int cost); +int has_mail(long id); /* local functions */ ACMD(do_quit); @@ -879,8 +880,11 @@ ACMD(do_gen_tog) result = PRF_TOG_CHK(ch, PRF_AFK); if (PRF_FLAGGED(ch, PRF_AFK)) act("$n has gone AFK.", TRUE, ch, 0, 0, TO_ROOM); - else + else { act("$n has come back from AFK.", TRUE, ch, 0, 0, TO_ROOM); + if (has_mail(GET_IDNUM(ch))) + send_to_char(ch, "You have mail waiting.\r\n"); + } break; default: log("SYSERR: Unknown subcmd %d in do_gen_toggle.", subcmd); diff --git a/src/act.wizard.c b/src/act.wizard.c index be28a55..60c286f 100644 --- a/src/act.wizard.c +++ b/src/act.wizard.c @@ -644,6 +644,7 @@ void do_stat_object(struct char_data *ch, struct obj_data *j) struct obj_data *j2; struct extra_descr_data *desc; char buf[MAX_STRING_LENGTH]; + struct char_data *tempch; send_to_char(ch, "Name: '%s%s%s', Aliases: %s\r\n", CCYEL(ch, C_NRM), j->short_description ? j->short_description : "", @@ -743,6 +744,13 @@ void do_stat_object(struct char_data *ch, struct obj_data *j) case ITEM_MONEY: send_to_char(ch, "Coins: %d\r\n", GET_OBJ_VAL(j, 0)); break; + case ITEM_CHAIR: + send_to_char(ch, "Can hold: [%d] Num. of People in Chair: [%d]\r\n", GET_OBJ_VAL(j, 0), GET_OBJ_VAL(j, 1)); + send_to_char(ch, "Holding : "); + for (tempch = OBJ_SAT_IN_BY(j); tempch; tempch = NEXT_SITTING(tempch)) + send_to_char(ch, "%s ", GET_NAME(tempch)); + send_to_char(ch, "\r\n"); + break; default: send_to_char(ch, "Values 0-3: [%d] [%d] [%d] [%d]\r\n", GET_OBJ_VAL(j, 0), GET_OBJ_VAL(j, 1), diff --git a/src/constants.c b/src/constants.c index 293d1aa..049313a 100644 --- a/src/constants.c +++ b/src/constants.c @@ -319,6 +319,7 @@ const char *item_types[] = { "PEN", "BOAT", "FOUNTAIN", + "CHAIR", "\n" }; @@ -498,8 +499,7 @@ const char *fullness[] = "" }; -/* str, int, wis, dex, con applies **************************************/ -/* [ch] strength apply (all) */ +/* str, int, wis, dex, con applies, [ch] strength apply (all) */ cpp_extern const struct str_app_type str_app[] = { {-5, -4, 0, 0}, /* str = 0 */ {-5, -4, 3, 1}, /* str = 1 */ diff --git a/src/db.c b/src/db.c index 86b65e0..f1e39aa 100644 --- a/src/db.c +++ b/src/db.c @@ -1719,6 +1719,8 @@ char *parse_object(FILE *obj_f, int nr) GET_OBJ_RENT(obj_proto + i) = t[2]; GET_OBJ_LEVEL(obj_proto + i) = t[3]; + obj_proto[i].sitting_here = NULL; + /* check to make sure that weight of containers exceeds curr. quantity */ if (GET_OBJ_TYPE(obj_proto + i) == ITEM_DRINKCON || GET_OBJ_TYPE(obj_proto + i) == ITEM_FOUNTAIN) { @@ -2665,6 +2667,7 @@ void reset_char(struct char_data *ch) ch->next_fighting = NULL; ch->next_in_room = NULL; FIGHTING(ch) = NULL; + char_from_chair(ch); ch->char_specials.position = POS_STANDING; ch->mob_specials.default_pos = POS_STANDING; ch->char_specials.carry_weight = 0; @@ -2954,7 +2957,13 @@ int check_object(struct obj_data *obj) } while (onealias && *onealias); } break; -} + case ITEM_CHAIR: + if (GET_OBJ_VAL(obj, 1) > GET_OBJ_VAL(obj, 0) && (error = TRUE)) + log("SYSERR: Object #%d (%s) contains (%d) more than maximum (%d).", + GET_OBJ_VNUM(obj), obj->short_description, GET_OBJ_VAL(obj, 1), + GET_OBJ_VAL(obj, 0)); + break; + } return (error); } diff --git a/src/genobj.c b/src/genobj.c index f05b38b..c3864e9 100644 --- a/src/genobj.c +++ b/src/genobj.c @@ -31,9 +31,7 @@ obj_rnum add_object(struct obj_data *newobj, obj_vnum ovnum) int found = NOTHING; zone_rnum rznum = real_zone_by_thing(ovnum); - /* - * Write object to internal tables. - */ + /* Write object to internal tables. */ if ((newobj->item_number = real_object(ovnum)) != NOTHING) { copy_object(&obj_proto[newobj->item_number], newobj); update_all_objects(&obj_proto[newobj->item_number]); @@ -47,15 +45,10 @@ obj_rnum add_object(struct obj_data *newobj, obj_vnum ovnum) return found; } -/* ------------------------------------------------------------------------------------------------------------------------------ */ - -/* - * Fix all existing objects to have these values. - * We need to run through each and every object currently in the - * game to see which ones are pointing to this prototype. - * if object is pointing to this prototype, then we need to replace it - * with the new one. - */ +/* Fix all existing objects to have these values. We need to run through each + * and every object currently in the game to see which ones are pointing to + * this prototype. If object is pointing to this prototype, then we need to + * replace it with the new one. */ int update_all_objects(struct obj_data *refobj) { struct obj_data *obj, swap; @@ -80,17 +73,15 @@ int update_all_objects(struct obj_data *refobj) obj->contains = swap.contains; obj->next_content = swap.next_content; obj->next = swap.next; + obj->sitting_here = swap.sitting_here; } return count; } -/* ------------------------------------------------------------------------------------------------------------------------------ */ - -/* - * Adjust the internal values of other objects as if something was inserted at the given array index. - * Might also be useful to make 'holes' in the array for some reason. - */ +/* Adjust the internal values of other objects as if something was inserted at + * the given array index. Might also be useful to make 'holes' in the array + * for some reason. */ obj_rnum adjust_objects(obj_rnum refpt) { int shop, i, zone, cmd_no; @@ -103,23 +94,17 @@ obj_rnum adjust_objects(obj_rnum refpt) #endif return NOTHING; - /* - * Renumber live objects. - */ + /* Renumber live objects. */ for (obj = object_list; obj; obj = obj->next) GET_OBJ_RNUM(obj) += (GET_OBJ_RNUM(obj) >= refpt); - /* - * Renumber zone table. - */ + /* Renumber zone table. */ for (zone = 0; zone <= top_of_zone_table; zone++) { for (cmd_no = 0; ZCMD(zone, cmd_no).command != 'S'; cmd_no++) { switch (ZCMD(zone, cmd_no).command) { case 'P': ZCMD(zone, cmd_no).arg3 += (ZCMD(zone, cmd_no).arg3 >= refpt); - /* - * No break here - drop into next case. - */ + /* No break here - drop into next case. */ case 'O': case 'G': case 'E': @@ -132,15 +117,11 @@ obj_rnum adjust_objects(obj_rnum refpt) } } - /* - * Renumber notice boards. - */ + /* Renumber notice boards. */ for (i = 0; i < NUM_OF_BOARDS; i++) BOARD_RNUM(i) += (BOARD_RNUM(i) >= refpt); - /* - * Renumber shop produce. - */ + /* Renumber shop produce. */ for (shop = 0; shop <= top_shop - top_shop_offset; shop++) for (i = 0; SHOP_PRODUCT(shop, i) != NOTHING; i++) SHOP_PRODUCT(shop, i) += (SHOP_PRODUCT(shop, i) >= refpt); @@ -148,12 +129,9 @@ obj_rnum adjust_objects(obj_rnum refpt) return refpt; } -/* ------------------------------------------------------------------------------------------------------------------------------ */ - -/* - * Function handle the insertion of an object within the prototype framework. Note that this does not adjust internal values - * of other objects, use add_object() for that. - */ +/* Function handle the insertion of an object within the prototype framework. + * Note that this does not adjust internal values of other objects, use + * add_object() for that. */ obj_rnum insert_object(struct obj_data *obj, obj_vnum ovnum) { obj_rnum i; @@ -162,13 +140,9 @@ obj_rnum insert_object(struct obj_data *obj, obj_vnum ovnum) RECREATE(obj_index, struct index_data, top_of_objt + 1); RECREATE(obj_proto, struct obj_data, top_of_objt + 1); - /* - * Start counting through both tables. - */ + /* Start counting through both tables. */ for (i = top_of_objt; i > 0; i--) { - /* - * Check if current virtual is bigger than our virtual number. - */ + /* Check if current virtual is bigger than our virtual number. */ if (ovnum > obj_index[i - 1].vnum) return index_object(obj, ovnum, i); @@ -182,8 +156,6 @@ obj_rnum insert_object(struct obj_data *obj, obj_vnum ovnum) return index_object(obj, ovnum, 0); } -/* ------------------------------------------------------------------------------------------------------------------------------ */ - obj_rnum index_object(struct obj_data *obj, obj_vnum ovnum, obj_rnum ornum) { #if CIRCLE_UNSIGNED_INDEX @@ -204,8 +176,6 @@ obj_rnum index_object(struct obj_data *obj, obj_vnum ovnum, obj_rnum ornum) return ornum; } -/* ------------------------------------------------------------------------------------------------------------------------------ */ - int save_objects(zone_rnum zone_num) { char fname[128], buf[MAX_STRING_LENGTH], bit1[64], bit2[64]; @@ -228,9 +198,7 @@ int save_objects(zone_rnum zone_num) mudlog(BRF, LVL_IMMORT, TRUE, "SYSERR: OLC: Cannot open objects file %s!", fname); return FALSE; } - /* - * Start running through all objects in this zone. - */ + /* Start running through all objects in this zone. */ for (counter = genolc_zone_bottom(zone_num); counter <= zone_table[zone_num].top; counter++) { if ((realcounter = real_object(counter)) != NOTHING) { if ((obj = &obj_proto[realcounter])->action_description) { @@ -266,19 +234,13 @@ int save_objects(zone_rnum zone_num) GET_OBJ_WEIGHT(obj), GET_OBJ_COST(obj), GET_OBJ_RENT(obj), GET_OBJ_LEVEL(obj) ); - /* - * Do we have script(s) attached ? - */ + /* Do we have script(s) attached? */ script_save_to_disk(fp, obj, OBJ_TRIGGER); - /* - * Do we have extra descriptions? - */ + /* Do we have extra descriptions? */ if (obj->ex_description) { /* Yes, save them too. */ for (ex_desc = obj->ex_description; ex_desc; ex_desc = ex_desc->next) { - /* - * Sanity check to prevent nasty protection faults. - */ + /* Sanity check to prevent nasty protection faults. */ if (!ex_desc->keyword || !ex_desc->description || !*ex_desc->keyword || !*ex_desc->description) { mudlog(BRF, LVL_IMMORT, TRUE, "SYSERR: OLC: oedit_save_to_disk: Corrupt ex_desc!"); continue; @@ -290,9 +252,7 @@ int save_objects(zone_rnum zone_num) "%s~\n", ex_desc->keyword, buf); } } - /* - * Do we have affects? - */ + /* Do we have affects? */ for (counter2 = 0; counter2 < MAX_OBJ_AFFECT; counter2++) if (obj->affected[counter2].modifier) fprintf(fp, "A\n" @@ -301,9 +261,7 @@ int save_objects(zone_rnum zone_num) } } - /* - * Write the final line, close the file. - */ + /* Write the final line, close the file. */ fprintf(fp, "$~\n"); fclose(fp); snprintf(buf, sizeof(buf), "%s/%d.obj", OBJ_PREFIX, zone_table[zone_num].number); @@ -315,9 +273,7 @@ int save_objects(zone_rnum zone_num) return TRUE; } -/* - * Free all, unconditionally. - */ +/* Free all, unconditionally. */ void free_object_strings(struct obj_data *obj) { if (obj->name) @@ -332,9 +288,7 @@ void free_object_strings(struct obj_data *obj) free_ex_descriptions(obj->ex_description); } -/* - * For object instances that are not the prototype. - */ +/* For object instances that are not the prototype. */ void free_object_strings_proto(struct obj_data *obj) { int robj_num = GET_OBJ_RNUM(obj); @@ -421,34 +375,34 @@ int delete_object(obj_rnum rnum) if (tmp->item_number != obj->item_number) continue; - // extract_obj() will just axe contents. + /* extract_obj() will just axe contents. */ if (tmp->contains) { struct obj_data *this_content, *next_content; for (this_content = tmp->contains; this_content; this_content = next_content) { next_content = this_content->next_content; if (IN_ROOM(tmp)) { - // transfer stuff from object to room + /* Transfer stuff from object to room. */ obj_from_obj(this_content); obj_to_room(this_content, IN_ROOM(tmp)); } else if (tmp->worn_by || tmp->carried_by) { - // transfer stuff from object to person inventory + /* Transfer stuff from object to person inventory. */ obj_from_char(this_content); obj_to_char(this_content, tmp->carried_by); } else if (tmp->in_obj) { - // transfer stuff from object to containing object + /* Transfer stuff from object to containing object. */ obj_from_obj(this_content); obj_to_obj(this_content, tmp->in_obj); } } } - // remove from object_list, etc. - handles weightchanges, and similar. + /* Remove from object_list, etc. - handles weightchanges, and similar. */ extract_obj(tmp); } - // make sure all are removed. + /* Make sure all are removed. */ assert(obj_index[rnum].number == 0); - // adjust rnums of all other objects. + /* Adjust rnums of all other objects. */ for (tmp = object_list; tmp; tmp = tmp->next) { GET_OBJ_RNUM(tmp) -= (GET_OBJ_RNUM(tmp) > rnum); } @@ -463,22 +417,16 @@ int delete_object(obj_rnum rnum) RECREATE(obj_index, struct index_data, top_of_objt + 1); RECREATE(obj_proto, struct obj_data, top_of_objt + 1); - /* - * Renumber notice boards. - */ + /* Renumber notice boards. */ for (j = 0; j < NUM_OF_BOARDS; j++) BOARD_RNUM(j) -= (BOARD_RNUM(j) > rnum); - /* - * Renumber shop produce; - */ + /* Renumber shop produce. */ for (shop = 0; shop <= top_shop - top_shop_offset; shop++) for (j = 0; SHOP_PRODUCT(shop, j) != NOTHING; j++) SHOP_PRODUCT(shop, j) -= (SHOP_PRODUCT(shop, j) > rnum); - /* - * Renumber zone table. - */ + /* Renumber zone table. */ int zone, cmd_no; for (zone = 0; zone <= top_of_zone_table; zone++) { for (cmd_no = 0; ZCMD(zone, cmd_no).command != 'S'; cmd_no++) { diff --git a/src/handler.c b/src/handler.c index 72dadd1..33c4439 100644 --- a/src/handler.c +++ b/src/handler.c @@ -800,10 +800,10 @@ void object_list_new_owner(struct obj_data *list, struct char_data *ch) } } - /* Extract an object from the world */ void extract_obj(struct obj_data *obj) { + struct char_data *ch, *next = NULL; struct obj_data *temp; if (obj->worn_by != NULL) @@ -816,6 +816,17 @@ void extract_obj(struct obj_data *obj) else if (obj->in_obj) obj_from_obj(obj); + if (OBJ_SAT_IN_BY(obj)){ + for (ch = OBJ_SAT_IN_BY(obj); OBJ_SAT_IN_BY(obj); ch = next){ + if (!NEXT_SITTING(ch)) + OBJ_SAT_IN_BY(obj) = NULL; + else + OBJ_SAT_IN_BY(obj) = (next = NEXT_SITTING(ch)); + SITTING(ch) = NULL; + NEXT_SITTING(ch) = NULL; + } + } + /* Get rid of the contents of the object, as well. */ while (obj->contains) extract_obj(obj->contains); @@ -834,8 +845,6 @@ void extract_obj(struct obj_data *obj) free_obj(obj); } - - void update_object(struct obj_data *obj, int use) { /* dont update objects with a timer trigger */ @@ -847,7 +856,6 @@ void update_object(struct obj_data *obj, int use) update_object(obj->next_content, use); } - void update_char_objects(struct char_data *ch) { int i; @@ -874,7 +882,6 @@ void update_char_objects(struct char_data *ch) update_object(ch->carrying, 1); } - /* Extract a ch completely from the world, and leave his stuff behind */ void extract_char_final(struct char_data *ch) { @@ -889,11 +896,9 @@ void extract_char_final(struct char_data *ch) exit(1); } - /* - * We're booting the character of someone who has switched so first we - * need to stuff them back into their own body. This will set ch->desc - * we're checking below this loop to the proper value. - */ + /* We're booting the character of someone who has switched so first we need + * to stuff them back into their own body. This will set ch->desc we're + * checking below this loop to the proper value. */ if (!IS_NPC(ch) && !ch->desc) { for (d = descriptor_list; d; d = d->next) if (d->original == ch) { @@ -903,24 +908,18 @@ void extract_char_final(struct char_data *ch) } if (ch->desc) { - /* - * This time we're extracting the body someone has switched into - * (not the body of someone switching as above) so we need to put - * the switcher back to their own body. - * - * If this body is not possessed, the owner won't have a - * body after the removal so dump them to the main menu. - */ + /* This time we're extracting the body someone has switched into (not the + * body of someone switching as above) so we need to put the switcher back + * to their own body. If this body is not possessed, the owner won't have a + * body after the removal so dump them to the main menu. */ if (ch->desc->original) do_return(ch, NULL, 0, 0); else { - /* - * Now we boot anybody trying to log in with the same character, to - * help guard against duping. CON_DISCONNECT is used to close a - * descriptor without extracting the d->character associated with it, - * for being link-dead, so we want CON_CLOSE to clean everything up. - * If we're here, we know it's a player so no IS_NPC check required. - */ + /* Now we boot anybody trying to log in with the same character, to help + * guard against duping. CON_DISCONNECT is used to close a descriptor + * without extracting the d->character associated with it, for being + * link-dead, so we want CON_CLOSE to clean everything up. If we're + * here, we know it's a player so no IS_NPC check required. */ for (d = descriptor_list; d; d = d->next) { if (d == ch->desc) continue; @@ -933,7 +932,6 @@ void extract_char_final(struct char_data *ch) } /* On with the character's assets... */ - if (ch->followers || ch->master) die_follower(ch); @@ -985,21 +983,16 @@ void extract_char_final(struct char_data *ch) } -/* - * Q: Why do we do this? - * A: Because trying to iterate over the character - * list with 'ch = ch->next' does bad things if - * the current character happens to die. The - * trivial workaround of 'vict = next_vict' - * doesn't work if the _next_ person in the list - * gets killed, for example, by an area spell. - * - * Q: Why do we leave them on the character_list? - * A: Because code doing 'vict = vict->next' would - * get really confused otherwise. - */ +/* Why do we do this? Because trying to iterate over the character list with + * 'ch = ch->next' does bad things if the current character happens to die. The + * trivial workaround of 'vict = next_vict' doesn't work if the _next_ person + * in the list gets killed, for example, by an area spell. Why do we leave them + * on the character_list? Because code doing 'vict = vict->next' would get + * really confused otherwise. */ void extract_char(struct char_data *ch) { + char_from_chair(ch); + if (IS_NPC(ch)) SET_BIT(MOB_FLAGS(ch), MOB_NOTDEADYET); else @@ -1008,17 +1001,10 @@ void extract_char(struct char_data *ch) extractions_pending++; } - -/* - * I'm not particularly pleased with the MOB/PLR - * hoops that have to be jumped through but it - * hardly calls for a completely new variable. - * Ideally it would be its own list, but that - * would change the '->next' pointer, potentially - * confusing some code. Ugh. -gg 3/15/2001 - * - * NOTE: This doesn't handle recursive extractions. - */ +/* I'm not particularly pleased with the MOB/PLR hoops that have to be jumped + * through but it hardly calls for a completely new variable. Ideally it would + * be its own list, but that would change the '->next' pointer, potentially + * confusing some code. -gg This doesn't handle recursive extractions. */ void extract_pending_chars(void) { struct char_data *vict, *next_vict, *prev_vict; @@ -1054,13 +1040,8 @@ void extract_pending_chars(void) extractions_pending = 0; } - -/* *********************************************************************** -* Here follows high-level versions of some earlier routines, ie functions* -* which incorporate the actual player-data *. -*********************************************************************** */ - - +/* Here follows high-level versions of some earlier routines, ie functions + * which incorporate the actual player-data */ struct char_data *get_player_vis(struct char_data *ch, char *name, int *number, int inroom) { struct char_data *i; @@ -1088,7 +1069,6 @@ struct char_data *get_player_vis(struct char_data *ch, char *name, int *number, return (NULL); } - struct char_data *get_char_room_vis(struct char_data *ch, char *name, int *number) { struct char_data *i; @@ -1116,7 +1096,6 @@ struct char_data *get_char_room_vis(struct char_data *ch, char *name, int *numbe return (NULL); } - struct char_data *get_char_world_vis(struct char_data *ch, char *name, int *number) { struct char_data *i; @@ -1148,7 +1127,6 @@ struct char_data *get_char_world_vis(struct char_data *ch, char *name, int *numb return (NULL); } - struct char_data *get_char_vis(struct char_data *ch, char *name, int *number, int where) { if (where == FIND_CHAR_ROOM) @@ -1159,7 +1137,6 @@ struct char_data *get_char_vis(struct char_data *ch, char *name, int *number, in return (NULL); } - struct obj_data *get_obj_in_list_vis(struct char_data *ch, char *name, int *number, struct obj_data *list) { struct obj_data *i; @@ -1182,7 +1159,6 @@ struct obj_data *get_obj_in_list_vis(struct char_data *ch, char *name, int *numb return (NULL); } - /* search the entire world for an object, and return a pointer */ struct obj_data *get_obj_vis(struct char_data *ch, char *name, int *number) { @@ -1215,7 +1191,6 @@ struct obj_data *get_obj_vis(struct char_data *ch, char *name, int *number) return (NULL); } - struct obj_data *get_obj_in_equip_vis(struct char_data *ch, char *arg, int *number, struct obj_data *equipment[]) { int j, num; @@ -1236,7 +1211,6 @@ struct obj_data *get_obj_in_equip_vis(struct char_data *ch, char *arg, int *numb return (NULL); } - int get_obj_pos_in_equip_vis(struct char_data *ch, char *arg, int *number, struct obj_data *equipment[]) { int j, num; @@ -1257,7 +1231,6 @@ int get_obj_pos_in_equip_vis(struct char_data *ch, char *arg, int *number, struc return (-1); } - const char *money_desc(int amount) { int cnt; @@ -1294,7 +1267,6 @@ const char *money_desc(int amount) return ("an absolutely colossal mountain of gold coins"); } - struct obj_data *create_money(int amount) { struct obj_data *obj; @@ -1347,10 +1319,7 @@ struct obj_data *create_money(int amount) return (obj); } - -/* Generic Find, designed to find any object/character - * - * Calling: +/* Generic Find, designed to find any object orcharacter. * *arg is the pointer containing the string to be searched for. * This string doesn't have to be a single word, the routine * extracts the next word itself. @@ -1362,8 +1331,7 @@ struct obj_data *create_money(int amount) * * The routine used to return a pointer to the next word in *arg (just * like the one_argument routine), but now it returns an integer that - * describes what it filled in. - */ + * describes what it filled in. */ int generic_find(char *arg, bitvector_t bitvector, struct char_data *ch, struct char_data **tar_ch, struct obj_data **tar_obj) { @@ -1419,7 +1387,6 @@ int generic_find(char *arg, bitvector_t bitvector, struct char_data *ch, return (0); } - /* a function to scan for "all" or "all.x" */ int find_all_dots(char *arg) { diff --git a/src/interpreter.c b/src/interpreter.c index 5fedf39..3001ef1 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -1213,6 +1213,8 @@ int perform_dupe_check(struct descriptor_data *d) write_to_output(d, "Reconnecting.\r\n"); act("$n has reconnected.", TRUE, d->character, 0, 0, TO_ROOM); mudlog(NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(d->character)), TRUE, "%s [%s] has reconnected.", GET_NAME(d->character), d->host); + if (has_mail(GET_IDNUM(d->character))) + write_to_output(d, "You have mail waiting.\r\n"); break; case USURP: write_to_output(d, "You take over your own body, already in use!\r\n"); diff --git a/src/oasis.h b/src/oasis.h index 91e604a..fc4784d 100644 --- a/src/oasis.h +++ b/src/oasis.h @@ -24,7 +24,7 @@ #define NUM_AFF_FLAGS 22 #define NUM_ATTACK_TYPES 15 -#define NUM_ITEM_TYPES 24 +#define NUM_ITEM_TYPES 25 #define NUM_ITEM_FLAGS 17 #define NUM_ITEM_WEARS 15 #define NUM_APPLIES 25 @@ -36,6 +36,8 @@ #define NUM_SHOP_FLAGS 3 #define NUM_TRADERS 7 +#define MAX_PEOPLE_IN_CHAIR 10 /* The maximum number of people you want + to sit in a chair at the same time. */ /* Limit information. */ #define MAX_ROOM_NAME 75 #define MAX_MOB_NAME 50 @@ -64,8 +66,8 @@ #define MAX_OBJ_TIMER 1071000 -/* this defines how much memory is alloacted for 'bit strings' when - saving in OLC. Remember to change it if you go for longer bitvectors. */ +/* this defines how much memory is alloacted for 'bit strings' when saving in + * OLC. Remember to change it if you go for longer bitvectors. */ #define BIT_STRING_LENGTH 33 /* The data types for miscellaneous functions. */ diff --git a/src/objsave.c b/src/objsave.c index c28b284..c6946ce 100644 --- a/src/objsave.c +++ b/src/objsave.c @@ -188,11 +188,7 @@ int objsave_save_obj_record(struct obj_data *obj, FILE *fp, int locate) #undef TEST_OBJS #undef TEST_OBJN - -/* - * AutoEQ by Burkhard Knopf - */ - +/* AutoEQ by Burkhard Knopf */ void auto_equip(struct char_data *ch, struct obj_data *obj, int location) { int j; @@ -270,10 +266,8 @@ void auto_equip(struct char_data *ch, struct obj_data *obj, int location) if (location > 0) { /* Wearable. */ if (!GET_EQ(ch,j)) { - /* - * Check the characters's alignment to prevent them from being - * zapped through the auto-equipping. - */ + /* Check the characters's alignment to prevent them from being zapped + * through the auto-equipping. */ if (invalid_align(ch, obj) || invalid_class(ch, obj)) location = LOC_INVENTORY; else @@ -311,7 +305,6 @@ int Crash_delete_file(char *name) return TRUE; } - int Crash_delete_crashfile(struct char_data *ch) { char fname[MAX_INPUT_LENGTH]; @@ -341,7 +334,6 @@ int Crash_delete_crashfile(struct char_data *ch) return TRUE; } - int Crash_clean_file(char *name) { char fname[MAX_INPUT_LENGTH], filetype[20]; @@ -353,10 +345,7 @@ int Crash_clean_file(char *name) if (!get_filename(fname, sizeof(fname), CRASH_FILE, name)) return FALSE; - /* - * open for write so that permission problems will be flagged now, at boot - * time. - */ + /* Open so that permission problems will be flagged now, at boot time. */ if (!(fl = fopen(fname, "rw"))) { if (errno != ENOENT) /* if it fails, NOT because of no file */ log("SYSERR: OPENING OBJECT FILE %s (4): %s", fname, strerror(errno)); @@ -403,7 +392,6 @@ int Crash_clean_file(char *name) return FALSE; } - void update_obj_file(void) { int i; @@ -413,7 +401,6 @@ void update_obj_file(void) Crash_clean_file(player_table[i].name); } - void Crash_listrent(struct char_data *ch, char *name) { FILE *fl; @@ -469,9 +456,7 @@ void Crash_listrent(struct char_data *ch, char *name) GET_OBJ_RENT(current->obj), current->obj->short_description); - /* - * now it's safe to free the obj_save_data list and the objects on it. - */ + /* Now it's safe to free the obj_save_data list and the objects on it. */ while (loaded != NULL) { current = loaded; loaded = loaded->next; @@ -483,19 +468,15 @@ void Crash_listrent(struct char_data *ch, char *name) fclose(fl); } -/* - * Return values: +/* Return values: * 0 - successful load, keep char in rent room. * 1 - load failure or load of crash items -- put char in temple. - * 2 - rented equipment lost (no $) - */ + * 2 - rented equipment lost (no $) */ int Crash_load(struct char_data *ch) { return (Crash_load_objs(ch)); } - - int Crash_save(struct obj_data *obj, FILE *fp, int location) { struct obj_data *tmp; @@ -516,7 +497,6 @@ int Crash_save(struct obj_data *obj, FILE *fp, int location) return (TRUE); } - void Crash_restore_weight(struct obj_data *obj) { if (obj) { @@ -527,10 +507,8 @@ void Crash_restore_weight(struct obj_data *obj) } } -/* - * Get !RENT items from equipment to inventory and - * extract !RENT out of worn containers. - */ +/* Get !RENT items from equipment to inventory and extract !RENT out of worn + * containers. */ void Crash_extract_norent_eq(struct char_data *ch) { int j; @@ -555,7 +533,6 @@ void Crash_extract_objs(struct obj_data *obj) } } - int Crash_is_unrentable(struct obj_data *obj) { if (!obj) @@ -572,7 +549,6 @@ int Crash_is_unrentable(struct obj_data *obj) return FALSE; } - void Crash_extract_norents(struct obj_data *obj) { if (obj) { @@ -583,7 +559,6 @@ void Crash_extract_norents(struct obj_data *obj) } } - void Crash_extract_expensive(struct obj_data *obj) { struct obj_data *tobj, *max; @@ -595,8 +570,6 @@ void Crash_extract_expensive(struct obj_data *obj) extract_obj(max); } - - void Crash_calculate_rent(struct obj_data *obj, int *cost) { if (obj) { @@ -606,7 +579,6 @@ void Crash_calculate_rent(struct obj_data *obj, int *cost) } } - void Crash_crashsave(struct char_data *ch) { char buf[MAX_INPUT_LENGTH]; @@ -645,7 +617,6 @@ void Crash_crashsave(struct char_data *ch) REMOVE_BIT(PLR_FLAGS(ch), PLR_CRASH); } - void Crash_idlesave(struct char_data *ch) { char buf[MAX_INPUT_LENGTH]; @@ -720,7 +691,6 @@ void Crash_idlesave(struct char_data *ch) Crash_extract_objs(ch->carrying); } - void Crash_rentsave(struct char_data *ch, int cost) { char buf[MAX_INPUT_LENGTH]; @@ -823,11 +793,7 @@ void Crash_cryosave(struct char_data *ch, int cost) SET_BIT(PLR_FLAGS(ch), PLR_CRYO); } - -/* ************************************************************************ -* Routines used for the receptionist * -************************************************************************* */ - +/* Routines used for the receptionist. */ void Crash_rent_deadline(struct char_data *ch, struct char_data *recep, long cost) { @@ -861,11 +827,8 @@ int Crash_report_unrentables(struct char_data *ch, struct char_data *recep, return (has_norents); } - - -void Crash_report_rent(struct char_data *ch, struct char_data *recep, - struct obj_data *obj, long *cost, long *nitems, - int display, int factor) +void Crash_report_rent(struct char_data *ch, struct char_data *recep, struct + obj_data *obj, long *cost, long *nitems, int display, int factor) { static char buf[256]; @@ -884,8 +847,6 @@ void Crash_report_rent(struct char_data *ch, struct char_data *recep, } } - - int Crash_offer_rent(struct char_data *ch, struct char_data *receptionist, int display, int factor) { @@ -935,8 +896,8 @@ int Crash_offer_rent(struct char_data *ch, struct char_data *receptionist, return (totalcost); } -int gen_receptionist(struct char_data *ch, struct char_data *recep, - int cmd, char *arg, int mode) +int gen_receptionist(struct char_data *ch, struct char_data *recep, int cmd, + char *arg, int mode) { int cost; const char *action_table[] = { "smile", "dance", "sigh", "blush", "burp", @@ -1014,19 +975,16 @@ int gen_receptionist(struct char_data *ch, struct char_data *recep, return (TRUE); } - SPECIAL(receptionist) { return (gen_receptionist(ch, (struct char_data *)me, cmd, argument, RENT_FACTOR)); } - SPECIAL(cryogenicist) { return (gen_receptionist(ch, (struct char_data *)me, cmd, argument, CRYO_FACTOR)); } - void Crash_save_all(void) { struct descriptor_data *d; @@ -1041,21 +999,19 @@ void Crash_save_all(void) } } -/* - * parses the object records stored in fl, and returns the first object in a - * linked list, which also handles location if worn. - * this list can then be handled by house code, listrent code, autoeq code, etc. - */ +/* Parses the object records stored in fl, and returns the first object in a + * linked list, which also handles location if worn. This list can then be + * handled by house code, listrent code, autoeq code, etc. */ obj_save_data *objsave_parse_objects(FILE *fl) { - obj_save_data *head, *current; + obj_save_data *head, *current; char line[READ_SIZE]; int t[4],i, nr; struct obj_data *temp; - CREATE(current, obj_save_data, 1); - head = current; - current->locate = 0; + CREATE(current, obj_save_data, 1); + head = current; + current->locate = 0; temp = NULL; while (TRUE) { @@ -1063,59 +1019,45 @@ obj_save_data *objsave_parse_objects(FILE *fl) int num; /* if the file is done, wrap it all up */ - if(get_line(fl, line) == FALSE || (*line == '$' && line[1] == '~')) - { - if (temp == NULL && current->obj == NULL) - { - // remove current from list - obj_save_data *t = head; - if (t == current) - { - free(current); - head = NULL; - } - else - { - while (t) - { - if (t->next == current) - t->next = NULL; + if(get_line(fl, line) == FALSE || (*line == '$' && line[1] == '~')) { + if (temp == NULL && current->obj == NULL) { + /* Remove current from list. */ + obj_save_data *t = head; + if (t == current) { + free(current); + head = NULL; + } else { + while (t) { + if (t->next == current) + t->next = NULL; + t = t->next; + } + free(current); + } + } + else if (temp != NULL && current->obj == NULL) + current->obj = temp; + else if (temp == NULL && current->obj != NULL) { + /* Do nothing. */ + } else if (temp != NULL && current->obj != NULL) { + if (temp != current->obj) + log("inconsistent object pointers in objsave_parse_objects: %p/%p", temp, current->obj); + } - t = t->next; - } - free(current); - } - } - else if (temp != NULL && current->obj == NULL) - { - current->obj = temp; - } - else if (temp == NULL && current->obj != NULL) - { - // do nothing - } - else if (temp != NULL && current->obj != NULL) - { - if (temp != current->obj) - log("inconsistent object pointers in objsave_parse_objects: %p/%p", temp, current->obj); - } - - break; + break; } /* if it's a new record, wrap up the old one, and make space for a new one */ if (*line == '#') { /* check for false alarm. */ - if (sscanf(line, "#%d", &nr) == 1) - { - if (temp) - { + if (sscanf(line, "#%d", &nr) == 1) { + if (temp) { current->obj = temp; - CREATE(current->next, obj_save_data, 1); - current=current->next; + CREATE(current->next, obj_save_data, 1); + current=current->next; - current->locate = 0; - temp = NULL; + current->locate = 0; + temp = NULL; } } else @@ -1129,12 +1071,12 @@ obj_save_data *objsave_parse_objects(FILE *fl) } else { if(real_object(nr) != NOTHING) { temp=read_object(nr,VIRTUAL); - // go read next line - nothing more to see here + /* Go read next line - nothing more to see here. */ } else { log("Nonexistent object %d found in rent file.", nr); } } - // go read next line - nothing more to see here + /* go read next line - nothing more to see here. */ continue; } @@ -1221,14 +1163,13 @@ obj_save_data *objsave_parse_objects(FILE *fl) } break; default: - log("Unknown tag in rentfile: %s", tag); + log("Unknown tag in rentfile: %s", tag); } } - return head; + return head; } - int Crash_load_objs(struct char_data *ch) { FILE *fl; char fname[MAX_STRING_LENGTH]; @@ -1306,10 +1247,8 @@ int Crash_load_objs(struct char_data *ch) { for (current = loaded; current != NULL; current=current->next) num_objs += handle_obj(current->obj, ch, current->locate, cont_row); - /* - * now it's safe to free the obj_save_data list - all members of it - * have been put in the correct lists by handle_obj() - */ + /* now it's safe to free the obj_save_data list - all members of it + * have been put in the correct lists by handle_obj() */ while (loaded != NULL) { current = loaded; loaded = loaded->next; @@ -1328,7 +1267,6 @@ int Crash_load_objs(struct char_data *ch) { return 1; } - int handle_obj(struct obj_data *temp, struct char_data *ch, int locate, struct obj_data **cont_row) { int j; @@ -1339,29 +1277,17 @@ int handle_obj(struct obj_data *temp, struct char_data *ch, int locate, struct o auto_equip(ch, temp, locate); - /* - what to do with a new loaded item: - - if there's a list with less than 1 below this: - (equipped items are assumed to have ==0 here) then its - container has disappeared from the file *gasp* - -> put all the list back to ch's inventory - if there's a list of contents with 1 below this: - check if it's a container - - if so: get it from ch, fill it, and give it back to ch (this way the - container has its correct weight before modifying ch) - - if not: the container is missing -> put all the list to ch's inventory - - for items with negative : - if there's already a list of contents with the same put obj to it - if not, start a new list - - Confused? Well maybe you can think of some better text to be put here ... - - since for contents is < 0 the list indices are switched to - non-negative - */ - + /* What to do with a new loaded item: + * If there's a list with less than 1 below this: (equipped items + * are assumed to have ==0 here) then its container has disappeared + * from the file *gasp* -> put all the list back to ch's inventory if + * there's a list of contents with 1 below this: check if it's a + * container - if so: get it from ch, fill it, and give it back to ch (this + * way the container has its correct weight before modifying ch) - if not: + * the container is missing -> put all the list to ch's inventory. For items + * with negative : If there's already a list of contents with the + * same put obj to it if not, start a new list. Since for + * contents is < 0 the list indices are switched to non-negative. */ if (locate > 0) { /* item equipped */ for (j = MAX_BAG_ROWS-1;j > 0;j--) diff --git a/src/oedit.c b/src/oedit.c index 52233c0..989fbee 100644 --- a/src/oedit.c +++ b/src/oedit.c @@ -65,8 +65,7 @@ ACMD(do_oasis_oedit) /* Parse any arguments. */ buf3 = two_arguments(argument, buf1, buf2); - /* If there aren't any arguments...well...they can't modify nothing now - can they? */ + /* If there aren't any arguments they can't modify anything. */ if (!*buf1) { send_to_char(ch, "Specify an object VNUM to edit.\r\n"); return; @@ -164,8 +163,7 @@ ACMD(do_oasis_oedit) OLC_NUM(d) = number; - /* If this is a new object, setup a new object, otherwise setup the existing - object. */ + /* If a new object, setup new, otherwise setup the existing object. */ if ((real_num = real_object(number)) != NOTHING) oedit_setup_existing(d, real_num); else @@ -213,8 +211,8 @@ void oedit_setup_existing(struct descriptor_data *d, int real_num) OLC_VAL(d) = 0; OLC_ITEM_TYPE(d) = OBJ_TRIGGER; dg_olc_script_copy(d); - /* The edited obj must not have a script. It will be assigned to the updated - obj later, after editing. */ + /* The edited obj must not have a script. It will be assigned to the updated + * obj later, after editing. */ SCRIPT(obj) = NULL; OLC_OBJ(d)->proto_script = NULL; @@ -411,7 +409,7 @@ void oedit_disp_spells_menu(struct descriptor_data *d) get_char_colors(d->character); clear_screen(d); - for (counter = 0; counter < NUM_SPELLS; counter++) { + for (counter = 1; counter <= NUM_SPELLS; counter++) { write_to_output(d, "%s%2d%s) %s%-20.20s %s", grn, counter, nrm, yel, spell_info[counter].name, !(++columns % 3) ? "\r\n" : ""); } @@ -424,9 +422,7 @@ void oedit_disp_val1_menu(struct descriptor_data *d) OLC_MODE(d) = OEDIT_VALUE_1; switch (GET_OBJ_TYPE(OLC_OBJ(d))) { case ITEM_LIGHT: - /* - * values 0 and 1 are unused.. jump to 2 - */ + /* values 0 and 1 are unused.. jump to 2 */ oedit_disp_val3_menu(d); break; case ITEM_SCROLL: @@ -436,9 +432,7 @@ void oedit_disp_val1_menu(struct descriptor_data *d) write_to_output(d, "Spell level : "); break; case ITEM_WEAPON: - /* - * This doesn't seem to be used if I remembe right. - */ + /* This doesn't seem to be used if I remembe right. */ write_to_output(d, "Modifier to Hitroll : "); break; case ITEM_ARMOR: @@ -458,9 +452,9 @@ void oedit_disp_val1_menu(struct descriptor_data *d) write_to_output(d, "Number of gold coins : "); break; case ITEM_NOTE: - /* - * This is supposed to be language, but it's unused. - */ + break; + case ITEM_CHAIR: + write_to_output(d, "Number of people the chair can hold : "); break; default: oedit_disp_menu(d); @@ -488,9 +482,7 @@ void oedit_disp_val2_menu(struct descriptor_data *d) oedit_disp_val4_menu(d); break; case ITEM_CONTAINER: - /* - * These are flags, needs a bit of special handling. - */ + /* These are flags, needs a bit of special handling. */ oedit_disp_container_flags_menu(d); break; case ITEM_DRINKCON: @@ -846,9 +838,7 @@ void oedit_parse(struct descriptor_data *d, char *arg) oedit_disp_menu(d); break; } - return; /* - * end of OEDIT_MAIN_MENU - */ + return; /* end of OEDIT_MAIN_MENU */ case OLC_SCRIPT_EDIT: if (dg_script_edit_parse(d, arg)) return; @@ -950,7 +940,16 @@ void oedit_parse(struct descriptor_data *d, char *arg) return; case OEDIT_VALUE_1: + number = atoi(arg); switch (GET_OBJ_TYPE(OLC_OBJ(d))) { + case ITEM_CHAIR: + if (number < 0 || number > MAX_PEOPLE_IN_CHAIR) + oedit_disp_val1_menu(d); + else { + GET_OBJ_VAL(OLC_OBJ(d), 0) = number; + oedit_disp_val2_menu(d); + } + break; case ITEM_WEAPON: GET_OBJ_VAL(OLC_OBJ(d), 0) = MIN(MAX(atoi(arg), -50), 50); break; @@ -1168,9 +1167,7 @@ void oedit_parse(struct descriptor_data *d, char *arg) OLC_DESC(d) = OLC_DESC(d)->next; } } - /* - * No break - drop into default case. - */ + /* No break - drop into default case. */ default: oedit_disp_extradesc_menu(d); return; diff --git a/src/players.c b/src/players.c index 0345633..6edc4a4 100644 --- a/src/players.c +++ b/src/players.c @@ -295,6 +295,8 @@ int load_char(const char *name, struct char_data *ch) GET_HOST(ch) = NULL; GET_PAGE_LENGTH(ch) = PFDEF_PAGELENGTH; GET_ALIASES(ch) = NULL; + SITTING(ch) = NULL; + NEXT_SITTING(ch) = NULL; while (get_line(fl, line)) { tag_argument(line, tag); diff --git a/src/structs.h b/src/structs.h index f59cff2..4d1ab81 100644 --- a/src/structs.h +++ b/src/structs.h @@ -312,6 +312,7 @@ #define ITEM_PEN 21 /* Item is a pen */ #define ITEM_BOAT 22 /* Item is a boat */ #define ITEM_FOUNTAIN 23 /* Item is a fountain */ +#define ITEM_CHAIR 24 /* Item is a chair */ /* Take/Wear flags: used by obj_data.obj_flags.wear_flags */ #define ITEM_WEAR_TAKE (1 << 0) /* Item can be taken */ @@ -585,6 +586,7 @@ struct obj_data { struct obj_data *next_content; /* For 'contains' lists */ struct obj_data *next; /* For the object list */ + struct char_data *sitting_here;/* who is sitting in it */ }; /* File Element for Objects BEWARE: Changing it will ruin rent files */ @@ -745,6 +747,8 @@ struct char_special_data_saved { struct char_special_data { struct char_data *fighting; /* Opponent */ struct char_data *hunting; /* Char hunted by this char */ + struct obj_data *chair; /* Object the char is sitting in */ + struct char_data *next_in_chair; /* The next person in the chair */ byte position; /* Standing, fighting, sleeping, etc. */ diff --git a/src/utils.c b/src/utils.c index cbd042e..0d5e8ef 100644 --- a/src/utils.c +++ b/src/utils.c @@ -10,8 +10,6 @@ #include "conf.h" #include "sysdep.h" - - #include "structs.h" #include "utils.h" #include "db.h" @@ -21,7 +19,6 @@ #include "handler.h" #include "interpreter.h" - /* external globals */ extern struct time_data time_info; @@ -30,7 +27,6 @@ struct time_info_data *real_time_passed(time_t t2, time_t t1); struct time_info_data *mud_time_passed(time_t t2, time_t t1); void prune_crlf(char *txt); - /* creates a random number in interval [from;to] */ int rand_number(int from, int to) { @@ -42,21 +38,15 @@ int rand_number(int from, int to) log("SYSERR: rand_number() should be called with lowest, then highest. (%d, %d), not (%d, %d).", from, to, to, from); } - /* - * This should always be of the form: - * - * ((float)(to - from + 1) * rand() / (float)(RAND_MAX + from) + from); - * - * if you are using rand() due to historical non-randomness of the - * lower bits in older implementations. We always use circle_random() - * though, which shouldn't have that problem. Mean and standard - * deviation of both are identical (within the realm of statistical - * identity) if the rand() implementation is non-broken. - */ + /* This should always be of the form: ((float)(to - from + 1) * rand() / + * (float)(RAND_MAX + from) + from); If you are using rand() due to historical + * non-randomness of the lower bits in older implementations. We always use + * circle_random() though, which shouldn't have that problem. Mean and + * standard deviation of both are identical (within the realm of statistical + * identity) if the rand() implementation is non-broken. */ return ((circle_random() % (to - from + 1)) + from); } - /* simulates dice roll */ int dice(int num, int size) { @@ -71,7 +61,6 @@ int dice(int num, int size) return (sum); } - /* Be wary of sign issues with this. */ int MIN(int a, int b) { @@ -84,7 +73,6 @@ int MAX(int a, int b) return (a > b ? a : b); } - /* color issue fix -- skip color codes, _then_ capitalize */ char *CAP(char *txt) { @@ -97,19 +85,13 @@ char *CAP(char *txt) return (txt); } - #if !defined(HAVE_STRLCPY) -/* - * A 'strlcpy' function in the same fashion as 'strdup' below. - * - * This copies up to totalsize - 1 bytes from the source string, placing - * them and a trailing NUL into the destination string. - * - * Returns the total length of the string it tried to copy, not including - * the trailing NUL. So a '>= totalsize' test says it was truncated. - * (Note that you may have _expected_ truncation because you only wanted - * a few characters from the source string.) - */ +/* A 'strlcpy' function in the same fashion as 'strdup' below. This copies up + * to totalsize - 1 bytes from the source string, placing them and a trailing + * NUL into the destination string. Returns the total length of the string it + * tried to copy, not including the trailing NUL. So a '>= totalsize' test + * says it was truncated. (Note that you may have _expected_ truncation + * because you only wanted a few characters from the source string.) */ size_t strlcpy(char *dest, const char *source, size_t totalsize) { strncpy(dest, source, totalsize - 1); /* strncpy: OK (we must assume 'totalsize' is correct) */ @@ -118,7 +100,6 @@ size_t strlcpy(char *dest, const char *source, size_t totalsize) } #endif - #if !defined(HAVE_STRDUP) /* Create a duplicate of a string */ char *strdup(const char *source) @@ -130,10 +111,7 @@ char *strdup(const char *source) } #endif - -/* - * Strips \r\n from end of string. - */ +/* Strips \r\n from end of string. */ void prune_crlf(char *txt) { int i = strlen(txt) - 1; @@ -142,14 +120,10 @@ void prune_crlf(char *txt) txt[i--] = '\0'; } - #ifndef str_cmp -/* - * str_cmp: a case-insensitive version of strcmp(). - * Returns: 0 if equal, > 0 if arg1 > arg2, or < 0 if arg1 < arg2. - * - * Scan until strings are found different or we reach the end of both. - */ +/* str_cmp: a case-insensitive version of strcmp(). Returns: 0 if equal, > 0 + * if arg1 > arg2, or < 0 if arg1 < arg2. Scan until strings are found + * different or we reach the end of both. */ int str_cmp(const char *arg1, const char *arg2) { int chk, i; @@ -167,14 +141,10 @@ int str_cmp(const char *arg1, const char *arg2) } #endif - #ifndef strn_cmp -/* - * strn_cmp: a case-insensitive version of strncmp(). - * Returns: 0 if equal, > 0 if arg1 > arg2, or < 0 if arg1 < arg2. - * - * Scan until strings are found different, the end of both, or n is reached. - */ +/* strn_cmp: a case-insensitive version of strncmp(). Returns: 0 if equal, > 0 + * if arg1 > arg2, or < 0 if arg1 < arg2. Scan until strings are found + * different, the end of both, or n is reached. */ int strn_cmp(const char *arg1, const char *arg2, int n) { int chk, i; @@ -192,10 +162,8 @@ int strn_cmp(const char *arg1, const char *arg2, int n) } #endif -/* - * New variable argument log() function. Works the same as the old for - * previously written code but is very nice for new code. - */ +/* New variable argument log() function. Works the same as the old for + * previously written code but is very nice for new code. */ void basic_mud_vlog(const char *format, va_list args) { time_t ct = time(0); @@ -217,7 +185,6 @@ void basic_mud_vlog(const char *format, va_list args) fflush(logfile); } - /* So mudlog() can use the same function. */ void basic_mud_log(const char *format, ...) { @@ -228,7 +195,6 @@ void basic_mud_log(const char *format, ...) va_end(args); } - /* the "touch" command, essentially. */ int touch(const char *path) { @@ -243,11 +209,8 @@ int touch(const char *path) } } - -/* - * mudlog -- log mud messages to a file & to online imm's syslogs - * based on syslog by Fen Jul 3, 1992 - */ +/* mudlog -- log mud messages to a file & to online imm's syslogs based on + * syslog by Fen Jul 3, 1992 */ void mudlog(int type, int level, int file, const char *str, ...) { char buf[MAX_STRING_LENGTH]; @@ -288,11 +251,9 @@ void mudlog(int type, int level, int file, const char *str, ...) -/* - * If you don't have a 'const' array, just cast it as such. It's safer - * to cast a non-const array as const than to cast a const one as non-const. - * Doesn't really matter since this function doesn't change the array though. - */ +/* If you don't have a 'const' array, just cast it as such. It's safer to cast + * a non-const array as const than to cast a const one as non-const. Doesn't + * really matter since this function doesn't change the array though. */ size_t sprintbit(bitvector_t bitvector, const char *names[], char *result, size_t reslen) { size_t len = 0; @@ -319,7 +280,6 @@ size_t sprintbit(bitvector_t bitvector, const char *names[], char *result, size_ return (len); } - size_t sprinttype(int type, const char *names[], char *result, size_t reslen) { int nr = 0; @@ -332,7 +292,6 @@ size_t sprinttype(int type, const char *names[], char *result, size_t reslen) return strlcpy(result, *names[nr] != '\n' ? names[nr] : "UNDEFINED", reslen); } - /* Calculate the REAL time passed over the last t2-t1 centuries (secs) */ struct time_info_data *real_time_passed(time_t t2, time_t t1) { @@ -353,8 +312,6 @@ struct time_info_data *real_time_passed(time_t t2, time_t t1) return (&now); } - - /* Calculate the MUD time passed over the last t2-t1 centuries (secs) */ struct time_info_data *mud_time_passed(time_t t2, time_t t1) { @@ -377,7 +334,6 @@ struct time_info_data *mud_time_passed(time_t t2, time_t t1) return (&now); } - time_t mud_time_to_secs(struct time_info_data *now) { time_t when = 0; @@ -390,7 +346,6 @@ time_t mud_time_to_secs(struct time_info_data *now) return (time(NULL) - when); } - struct time_info_data *age(struct char_data *ch) { static struct time_info_data player_age; @@ -402,9 +357,7 @@ struct time_info_data *age(struct char_data *ch) return (&player_age); } - -/* Check if making CH follow VICTIM will create an illegal */ -/* Follow "Loop/circle" */ +/* Check if making CH follow VICTIM will create an illegal Follow Loop. */ bool circle_follow(struct char_data *ch, struct char_data *victim) { struct char_data *k; @@ -417,10 +370,8 @@ bool circle_follow(struct char_data *ch, struct char_data *victim) return (FALSE); } - - -/* Called when stop following persons, or stopping charm */ -/* This will NOT do if a character quits/dies!! */ +/* Called when stop following persons, or stopping charm. This will NOT do if + * a character quits or dies. */ void stop_follower(struct char_data *ch) { struct follow_type *j, *k; @@ -458,7 +409,6 @@ void stop_follower(struct char_data *ch) REMOVE_BIT(AFF_FLAGS(ch), AFF_CHARM | AFF_GROUP); } - int num_followers_charmed(struct char_data *ch) { struct follow_type *lackey; @@ -471,7 +421,6 @@ int num_followers_charmed(struct char_data *ch) return (total); } - /* Called when a character that follows/is followed dies */ void die_follower(struct char_data *ch) { @@ -486,10 +435,8 @@ void die_follower(struct char_data *ch) } } - - -/* Do NOT call this before having checked if a circle of followers */ -/* will arise. CH will follow leader */ +/* Do NOT call this before having checked if a circle of followers will arise. + * CH will follow leader. */ void add_follower(struct char_data *ch, struct char_data *leader) { struct follow_type *k; @@ -513,15 +460,10 @@ void add_follower(struct char_data *ch, struct char_data *leader) act("$n starts to follow $N.", TRUE, ch, 0, leader, TO_NOTVICT); } - -/* - * get_line reads the next non-blank line off of the input stream. - * The newline character is removed from the input. Lines which begin - * with '*' are considered to be comments. - * - * Returns the number of lines advanced in the file. Buffer given must - * be at least READ_SIZE (256) characters large. - */ +/* get_line reads the next non-blank line off of the input stream. The newline + * character is removed from the input. Lines which begin with '*' are + * considered to be comments. Returns the number of lines advanced in the file. + * Buffer given must be at least READ_SIZE (256) characters large. */ int get_line(FILE *fl, char *buf) { char temp[READ_SIZE]; @@ -543,7 +485,6 @@ int get_line(FILE *fl, char *buf) return (lines); } - int get_filename(char *filename, size_t fbufsize, int mode, const char *orig_name) { const char *prefix, *middle, *suffix; @@ -609,7 +550,6 @@ int get_filename(char *filename, size_t fbufsize, int mode, const char *orig_nam return (1); } - int num_pc_in_room(struct room_data *room) { int i = 0; @@ -622,19 +562,13 @@ int num_pc_in_room(struct room_data *room) return (i); } -/* - * This function (derived from basic fork(); abort(); idea by Erwin S. - * Andreasen) causes your MUD to dump core (assuming you can) but - * continue running. The core dump will allow post-mortem debugging - * that is less severe than assert(); Don't call this directly as - * core_dump_unix() but as simply 'core_dump()' so that it will be - * excluded from systems not supporting them. (e.g. Windows '95). - * - * You still want to call abort() or exit(1) for - * non-recoverable errors, of course... - * - * XXX: Wonder if flushing streams includes sockets? - */ +/* This function (derived from basic fork() abort() idea by Erwin S. Andreasen) + * causes your MUD to dump core (assuming you can) but continue running. The + * core dump will allow post-mortem debugging that is less severe than assert(); + * Don't call this directly as core_dump_unix() but as simply 'core_dump()' so + * that it will be excluded from systems not supporting them. You still want to + * call abort() or exit(1) for non-recoverable errors, of course. Wonder if + * flushing streams includes sockets? */ extern FILE *player_fl; void core_dump_real(const char *who, int line) { @@ -649,10 +583,8 @@ void core_dump_real(const char *who, int line) /* Everything, just in case, for the systems that support it. */ fflush(NULL); - /* - * Kill the child so the debugger or script doesn't think the MUD - * crashed. The 'autorun' script would otherwise run it again. - */ + /* Kill the child so the debugger or script doesn't think the MUD crashed. + * The 'autorun' script would otherwise run it again. */ if (fork() == 0) abort(); #endif @@ -679,12 +611,8 @@ int count_color_chars(char *string) } return num; } -/* - * Rules (unless overridden by ROOM_DARK): - * - * Inside and City rooms are always lit. - * Outside rooms are dark at sunset and night. - */ +/* Rules (unless overridden by ROOM_DARK): Inside and City rooms are always + * lit. Outside rooms are dark at sunset and night. */ int room_is_dark(room_rnum room) { if (!VALID_ROOM_RNUM(room)) { @@ -710,19 +638,78 @@ int room_is_dark(room_rnum room) int levenshtein_distance(char *s1, char *s2) { int s1_len = strlen(s1), s2_len = strlen(s2); - int d[s1_len + 1][s2_len + 1]; - int i, j; + int *d = NULL; + int i, j, k; - for (i = 0; i <= s1_len; i++) - d[i][0] = i; - for (j = 0; j <= s2_len; j++) - d[0][j] = j; + s1_len++; + s2_len++; - for (i = 1; i <= s1_len; i++) - for (j = 1; j <= s2_len; j++) - d[i][j] = MIN(d[i - 1][j] + 1, - MIN(d[i][j - 1] + 1, - d[i - 1][j - 1] + ((s1[i - 1] == s2[j - 1]) ? 0 : 1))); + CREATE(d, int, (s1_len * s2_len)); - return d[s1_len][s2_len]; + for (i = 0; i < s1_len; i++) + d[i] = i; + for (j = 0; j < s2_len; j++) + d[j*s1_len] = j; + + for (i = 1; i < s1_len; i++) + for (j = 1; j < s2_len; j++) + d[(j*s1_len)+i] = MIN(d[(j*s1_len) + i - 1] + 1, MIN(d[i+((j-1)*s1_len)] + + 1, d[((j-1)*s1_len) + i - 1] + ((s1[i - 1] == s2[j - 1]) ? 0 : 1))); + + k = d[s1_len*s2_len-1]; + + free (d); + + return k; +} + +void char_from_chair(struct char_data *ch) +{ + struct obj_data *chair; + struct char_data *tempch; + int i, found = 0; + + if (!SITTING(ch)) + return; + + if (!(chair = SITTING(ch))){ + log("SYSERR: ACK, no chair for char in char from chair"); + SITTING(ch) = NULL; + NEXT_SITTING(ch) = NULL; + return; + } + + if (!(tempch = OBJ_SAT_IN_BY(chair))){ + log("SYSERR: Char from chair, but no chair!"); + SITTING(ch) = NULL; + NEXT_SITTING(ch) = NULL; + return; + } + + if (tempch == ch){ + if (!NEXT_SITTING(ch)) + OBJ_SAT_IN_BY(chair) = NULL; + else + OBJ_SAT_IN_BY(chair) = NEXT_SITTING(ch); + GET_OBJ_VAL(chair, 1) -= 1; + SITTING(ch) = NULL; + NEXT_SITTING(ch) = NULL; + return; + } + + for (i = 0; i < GET_OBJ_VAL(chair, 1) && found == 0; i++){ + if (NEXT_SITTING(tempch) == ch){ + NEXT_SITTING(tempch) = NEXT_SITTING(ch); + found++; + } + } + if (found) + log("SYSERR: Char flagged as sitting, but not in chair"); + else + GET_OBJ_VAL(chair, 1) -= 1; + + SITTING(ch) = NULL; + NEXT_SITTING(ch) = NULL; + + return; } diff --git a/src/utils.h b/src/utils.h index 5647c0c..b5bb9a4 100644 --- a/src/utils.h +++ b/src/utils.h @@ -8,9 +8,7 @@ * CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. * ************************************************************************ */ - -/* external declarations and prototypes **********************************/ - +/* external declarations and prototypes */ extern struct weather_data weather_info; extern FILE *logfile; @@ -40,10 +38,8 @@ int levenshtein_distance(char *s1, char *s2); #define core_dump() core_dump_real(__FILE__, __LINE__) -/* - * Only provide our versions if one isn't in the C library. These macro names - * will be defined by sysdep.h if a strcasecmp or stricmp exists. - */ +/* Only provide our versions if one isn't in the C library. These macro names + * will be defined by sysdep.h if a strcasecmp or stricmp exists. */ #ifndef str_cmp int str_cmp(const char *arg1, const char *arg2); #endif @@ -95,8 +91,12 @@ void gain_condition(struct char_data *ch, int condition, int value); void point_update(void); void update_pos(struct char_data *victim); +void char_from_chair(struct char_data *ch); +#define SITTING(ch) ((ch)->char_specials.chair) +#define NEXT_SITTING(ch) ((ch)->char_specials.next_in_chair) +#define OBJ_SAT_IN_BY(obj) ((obj)->sitting_here) -/* various constants *****************************************************/ +/* various constants */ /* defines for mudlog() */ #define OFF 0 @@ -117,10 +117,8 @@ void update_pos(struct char_data *victim); #define BFS_ALREADY_THERE (-2) #define BFS_NO_PATH (-3) -/* - * XXX: These constants should be configurable. See act.informative.c - * and utils.c for other places to change. - */ +/* These constants should be configurable. See act.informative.c and utils.c + * for other places to change. */ /* mud-life time */ #define SECS_PER_MUD_HOUR 75 #define SECS_PER_MUD_DAY (24*SECS_PER_MUD_HOUR) @@ -133,10 +131,7 @@ void update_pos(struct char_data *victim); #define SECS_PER_REAL_DAY (24*SECS_PER_REAL_HOUR) #define SECS_PER_REAL_YEAR (365*SECS_PER_REAL_DAY) - -/* string utils **********************************************************/ - - +/* string utils */ #define YESNO(a) ((a) ? "YES" : "NO") #define ONOFF(a) ((a) ? "ON" : "OFF") @@ -148,10 +143,7 @@ void update_pos(struct char_data *victim); /* See also: ANA, SANA */ #define AN(string) (strchr("aeiouAEIOU", *string) ? "an" : "a") - -/* memory utils **********************************************************/ - - +/* memory utils */ #define CREATE(result, type, number) do {\ if ((number) * sizeof(type) <= 0) \ log("SYSERR: Zero bytes or less requested at %s:%d.", __FILE__, __LINE__); \ @@ -162,14 +154,12 @@ void update_pos(struct char_data *victim); if (!((result) = (type *) realloc ((result), sizeof(type) * (number))))\ { perror("SYSERR: realloc failure"); abort(); } } while(0) -/* - * the source previously used the same code in many places to remove an item +/* the source previously used the same code in many places to remove an item * from a list: if it's the list head, change the head, else traverse the * list looking for the item before the one to be removed. Now, we have a * macro to do this. To use, just make sure that there is a variable 'temp' * declared as the same type as the list to be manipulated. BTW, this is - * a great application for C++ templates but, alas, this is not C++. - */ + * a great application for C++ templates but, alas, this is not C++. */ #define REMOVE_FROM_LIST(item, head, next) \ if ((item) == (head)) \ head = (item)->next; \ @@ -181,22 +171,17 @@ void update_pos(struct char_data *victim); temp->next = (item)->next; \ } \ - -/* basic bitvector utils *************************************************/ - - +/* basic bitvector utils */ #define IS_SET(flag,bit) ((flag) & (bit)) #define SET_BIT(var,bit) ((var) |= (bit)) #define REMOVE_BIT(var,bit) ((var) &= ~(bit)) #define TOGGLE_BIT(var,bit) ((var) ^= (bit)) -/* - * Accessing player specific data structures on a mobile is a very bad thing +/* Accessing player specific data structures on a mobile is a very bad thing * to do. Consider that changing these variables for a single mob will change * it for every other single mob in the game. If we didn't specifically check * for it, 'wimpy' would be an extremely bad thing for a mob to do, as an - * example. If you really couldn't care less, change this to a '#if 0'. - */ + * example. If you really couldn't care less, change this to a '#if 0'. */ #if 1 /* Subtle bug in the '#var', but works well for now. */ #define CHECK_PLAYER_SPECIAL(ch, var) \ @@ -238,9 +223,7 @@ void update_pos(struct char_data *victim); /* new define for quick check */ #define DEAD(ch) (PLR_FLAGGED((ch), PLR_NOTDEADYET) || MOB_FLAGGED((ch), MOB_NOTDEADYET)) -/* room utils ************************************************************/ - - +/* room utils */ #define SECT(room) (VALID_ROOM_RNUM(room) ? \ world[(room)].sector_type : SECT_INSIDE) @@ -253,9 +236,7 @@ void update_pos(struct char_data *victim); #define GET_ROOM_SPEC(room) \ (VALID_ROOM_RNUM(room) ? world[(room)].func : NULL) -/* char utils ************************************************************/ - - +/* char utils */ #define IN_ROOM(ch) ((ch)->in_room) #define GET_WAS_IN(ch) ((ch)->was_in_room) #define GET_AGE(ch) (age(ch)->year) @@ -268,10 +249,8 @@ void update_pos(struct char_data *victim); #define GET_PASSWD(ch) ((ch)->player.passwd) #define GET_PFILEPOS(ch)((ch)->pfilepos) -/* - * I wonder if this definition of GET_REAL_LEVEL should be the definition - * of GET_LEVEL? JE - */ +/* I wonder if this definition of GET_REAL_LEVEL should be the definition of + * GET_LEVEL? JE */ #define GET_REAL_LEVEL(ch) \ (ch->desc && ch->desc->original ? GET_LEVEL(ch->desc->original) : \ GET_LEVEL(ch)) @@ -363,7 +342,6 @@ void update_pos(struct char_data *victim); #define IS_EVIL(ch) (GET_ALIGNMENT(ch) <= -350) #define IS_NEUTRAL(ch) (!IS_GOOD(ch) && !IS_EVIL(ch)) - /* These three deprecated. */ #define WAIT_STATE(ch, cycle) do { GET_WAIT_STATE(ch) = (cycle); } while(0) #define CHECK_WAIT(ch) ((ch)->wait > 0) @@ -371,10 +349,7 @@ void update_pos(struct char_data *victim); /* New, preferred macro. */ #define GET_WAIT_STATE(ch) ((ch)->wait) - -/* descriptor-based utils ************************************************/ - -/* Hrm, not many. We should make more. -gg 3/4/99 */ +/* descriptor-based utils. We should make more. -gg */ #define STATE(d) ((d)->connected) #define IS_PLAYING(d) (STATE(d) == CON_TEDIT || STATE(d) == CON_REDIT || \ @@ -387,13 +362,11 @@ void update_pos(struct char_data *victim); #define SENDOK(ch) (((ch)->desc || SCRIPT_CHECK((ch), MTRIG_ACT)) && \ (to_sleeping || AWAKE(ch)) && \ !PLR_FLAGGED((ch), PLR_WRITING)) -/* object utils **********************************************************/ -/* - * Check for NOWHERE or the top array index? - * If using unsigned types, the top array index will catch everything. - * If using signed types, NOTHING will catch the majority of bad accesses. - */ +/* object utils */ +/* Check for NOWHERE or the top array index? If using unsigned types, the top + * array index will catch everything. If using signed types, NOTHING will + * catch the majority of bad accesses. */ #define VALID_OBJ_RNUM(obj) (GET_OBJ_RNUM(obj) <= top_of_objt && \ GET_OBJ_RNUM(obj) != NOTHING) @@ -420,12 +393,9 @@ void update_pos(struct char_data *victim); #define CAN_WEAR(obj, part) OBJWEAR_FLAGGED((obj), (part)) #define GET_OBJ_SHORT(obj) ((obj)->short_description) -/* compound utilities and other macros **********************************/ - -/* - * Used to compute CircleMUD version. To see if the code running is newer - * than 3.0pl13, you would use: #if _CIRCLEMUD > CIRCLEMUD_VERSION(3,0,13) - */ +/* compound utilities and other macros */ +/* Used to compute CircleMUD version. To see if the code running is newer than + * 3.0pl13, you would use: #if _CIRCLEMUD > CIRCLEMUD_VERSION(3,0,13) */ #define CIRCLEMUD_VERSION(major, minor, patchlevel) \ (((major) << 16) + ((minor) << 8) + (patchlevel)) @@ -436,7 +406,6 @@ void update_pos(struct char_data *victim); #define ANA(obj) (strchr("aeiouAEIOU", *(obj)->name) ? "An" : "A") #define SANA(obj) (strchr("aeiouAEIOU", *(obj)->name) ? "an" : "a") - /* Various macros building up to CAN_SEE */ #define LIGHT_OK(sub) (!AFF_FLAGGED(sub, AFF_BLIND) && \ @@ -457,10 +426,8 @@ void update_pos(struct char_data *victim); #define CAN_SEE(sub, obj) (SELF(sub, obj) || \ ((GET_REAL_LEVEL(sub) >= (IS_NPC(obj) ? 0 : GET_INVIS_LEV(obj))) && \ IMM_CAN_SEE(sub, obj))) - /* End of CAN_SEE */ - #define INVIS_OK_OBJ(sub, obj) \ (!OBJ_FLAGGED((obj), ITEM_INVISIBLE) || AFF_FLAGGED((sub), AFF_DETECT_INVIS)) @@ -491,7 +458,6 @@ void update_pos(struct char_data *victim); #define OBJN(obj, vict) (CAN_SEE_OBJ((vict), (obj)) ? \ fname((obj)->name) : "something") - #define EXIT(ch, door) (world[IN_ROOM(ch)].dir_option[door]) #define W_EXIT(room, num) (world[(room)].dir_option[(num)]) #define R_EXIT(room, num) ((room)->dir_option[(num)]) @@ -500,7 +466,6 @@ void update_pos(struct char_data *victim); (EXIT(ch,door)->to_room != NOWHERE) && \ !IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED)) - #define CLASS_ABBR(ch) (IS_NPC(ch) ? "--" : class_abbrevs[(int)GET_CLASS(ch)]) #define IS_MAGIC_USER(ch) (!IS_NPC(ch) && \ @@ -514,10 +479,7 @@ void update_pos(struct char_data *victim); #define OUTSIDE(ch) (!ROOM_FLAGGED(IN_ROOM(ch), ROOM_INDOORS)) - -/* OS compatibility ******************************************************/ - - +/* OS compatibility */ /* there could be some strange OS which doesn't have NULL... */ #ifndef NULL #define NULL (void *)0 @@ -546,20 +508,16 @@ void update_pos(struct char_data *victim); #define SEEK_END 2 #endif -/* - * NOCRYPT can be defined by an implementor manually in sysdep.h. - * CIRCLE_CRYPT is a variable that the 'configure' script - * automatically sets when it determines whether or not the system is - * capable of encrypting. - */ +/* NOCRYPT can be defined by an implementor manually in sysdep.h. CIRCLE_CRYPT + * is a variable that the 'configure' script automatically sets when it + * determines whether or not the system is capable of encrypting. */ #if defined(NOCRYPT) || !defined(CIRCLE_CRYPT) #define CRYPT(a,b) (a) #else #define CRYPT(a,b) ((char *) crypt((a),(b))) #endif -/******************* Config macros *********************/ - +/* Config macros */ #define CONFIG_CONFFILE config_info.CONFFILE #define CONFIG_PK_ALLOWED config_info.play.pk_allowed @@ -582,7 +540,7 @@ void update_pos(struct char_data *victim); #define CONFIG_NOPERSON config_info.play.NOPERSON #define CONFIG_NOEFFECT config_info.play.NOEFFECT - /** Crash Saves **/ +/* Crash Saves */ #define CONFIG_FREE_RENT config_info.csd.free_rent #define CONFIG_MAX_OBJ_SAVE config_info.csd.max_obj_save #define CONFIG_MIN_RENT_COST config_info.csd.min_rent_cost @@ -591,7 +549,7 @@ void update_pos(struct char_data *victim); #define CONFIG_CRASH_TIMEOUT config_info.csd.crash_file_timeout #define CONFIG_RENT_TIMEOUT config_info.csd.rent_file_timeout - /** Room Numbers **/ +/* Room Numbers */ #define CONFIG_MORTAL_START config_info.room_nums.mortal_start_room #define CONFIG_IMMORTAL_START config_info.room_nums.immort_start_room #define CONFIG_FROZEN_START config_info.room_nums.frozen_start_room @@ -599,7 +557,7 @@ void update_pos(struct char_data *victim); #define CONFIG_DON_ROOM_2 config_info.room_nums.donation_room_2 #define CONFIG_DON_ROOM_3 config_info.room_nums.donation_room_3 - /** Game Operation **/ +/* Game Operation */ #define CONFIG_DFLT_PORT config_info.operation.DFLT_PORT #define CONFIG_DFLT_IP config_info.operation.DFLT_IP #define CONFIG_MAX_PLAYING config_info.operation.max_playing @@ -615,7 +573,7 @@ void update_pos(struct char_data *victim); #define CONFIG_WELC_MESSG config_info.operation.WELC_MESSG #define CONFIG_START_MESSG config_info.operation.START_MESSG - /** Autowiz **/ +/* Autowiz */ #define CONFIG_USE_AUTOWIZ config_info.autowiz.use_autowiz #define CONFIG_MIN_WIZLIST_LEV config_info.autowiz.min_wizlist_lev