[Sep 25 2007] - Rumble
  Added set/not set to extra descriptions menu in oedit so a builder can tell if
  they exist or not without having to enter the extra desc menu or stat the object.
  Replaced [TRIG] flag (showvnum enabled) with [T<vnum>] to make things easier to stat.
[Sep 24 2007] - Rumble
  Added %is_pc% to return -1 for objects. (thanks Jamdog)
  Fixed do_gen_comm color bleed into last apostrophe in gossip/shout/grat/etc.
  Fixed bug where object keywords took precedence over door keywords. i.e. open door would try to open an object with keyword door. (thanks Trulight)
[Sep 23 2007] - Rumble
  Fixed minlev checks in do_grab, do_wield, and do_wear. (thanks Trulight)
  Added trigedit variables(modifiable) Hunger, Thirst, and Drunk.
[Sep 15 2007] - Rumble
  Fixed bug in unlimited drinks showing as empty. (thanks AaronGoulet)
This commit is contained in:
Rumble 2007-09-26 19:40:22 +00:00
parent 6c84a36236
commit 1f7a7b4182
25 changed files with 259 additions and 194 deletions

View file

@ -4,7 +4,19 @@ Rumble
The Builder Academy The Builder Academy
builderacademy.net 9091 builderacademy.net 9091
tbaMUD 3.53 tbaMUD 3.54
[Sep 25 2007] - Rumble
Added set/not set to extra descriptions menu in oedit so a builder can tell if they exist or not without having to enter the extra desc menu or stat the object.
Replaced [TRIG] flag (showvnum enabled) with [T<vnum>] to make things easier to stat.
[Sep 24 2007] - Rumble
Added %is_pc% to return -1 for objects. (thanks Jamdog)
Fixed do_gen_comm color bleed into last apostrophe in gossip/shout/grat/etc.
Fixed bug where object keywords took precedence over door keywords. i.e. open door would try to open an object with keyword door. (thanks Trulight)
[Sep 23 2007] - Rumble
Fixed minlev checks in do_grab, do_wield, and do_wear. (thanks Trulight)
Added trigedit variables(modifiable) Hunger, Thirst, and Drunk.
[Sep 15 2007] - Rumble
Fixed bug in unlimited drinks showing as empty. (thanks AaronGoulet)
[Sep 13 2007] - Rumble [Sep 13 2007] - Rumble
Changed binary search functions (real_xxxx, real_zone_by_thing), except real_shop. (thanks Neme) Changed binary search functions (real_xxxx, real_zone_by_thing), except real_shop. (thanks Neme)
script_proto list freed when exiting without saving in oedit/medit/redit. (thanks Neme) script_proto list freed when exiting without saving in oedit/medit/redit. (thanks Neme)
@ -17,11 +29,11 @@ tbaMUD 3.53
Changed NUM_BOARDS from 10 to 7 (the actual num of boards). (thanks Neme) Changed NUM_BOARDS from 10 to 7 (the actual num of boards). (thanks Neme)
Removed the Keywords option in hedit since they have to be in the body. Removed the Keywords option in hedit since they have to be in the body.
[Sep 12 2007] - Rumble [Sep 12 2007] - Rumble
Fixed crash bug caused by olist with no objects. (Thanks Rhade) Fixed crash bug caused by olist with no objects. (thanks Rhade)
Several changes made to compile clean on older versions of GCC. (Thanks Neme) Several changes made to compile clean on older versions of GCC. (thanks Neme)
[Sep 10 2007] - Rumble [Sep 10 2007] - Rumble
Fixed items with rnum = NOTHING or NOBODY being changed to rnum = 0. (Thanks Neme) Fixed items with rnum = NOTHING or NOBODY being changed to rnum = 0. (thanks Neme)
Fixed memory leak in dg_olc.c trigedit save. (Thanks Neme) Fixed memory leak in dg_olc.c trigedit save. (thanks Neme)
[Sep 04 2007] - Rumble [Sep 04 2007] - Rumble
Changed CLSOLC to LVL_BUILDER. Changed CLSOLC to LVL_BUILDER.
removed delete_doubledollar from do_say. (thanks Rhade) removed delete_doubledollar from do_say. (thanks Rhade)
@ -30,8 +42,10 @@ tbaMUD 3.53
Fixed dg_affect to not add 1 to the desired affect duration. Fixed dg_affect to not add 1 to the desired affect duration.
Fixed dg_affect to work with 128 bits. Fixed dg_affect to work with 128 bits.
[Aug 17 2007] - Rumble [Aug 17 2007] - Rumble
128 bit fixes: pfile conversion, world sector conversion, and player flags. Thanks Jamdog 128 bit fixes: pfile conversion, world sector conversion, and player flags.
Added stop_fighting calls in do_flee to fix stock bug. Thanks Juras (thanks Jamdog)
Added stop_fighting calls in do_flee to fix stock bug. (thanks Juras)
tbaMUD 3.53
[Jul 01 2007] - Rumble [Jul 01 2007] - Rumble
Added run_autowiz to do_cheat. (thanks Fizban) Added run_autowiz to do_cheat. (thanks Fizban)
Updated World and files for 3.53 release. Updated World and files for 3.53 release.

View file

@ -1,10 +1,9 @@
* Note: all lines between records which start with '*' are comments and * Note: all lines between records which start with '*' are comments and
* are ignored. Comments can only be between records, not within them. * are ignored. Comments can only be between records, not within them.
* *
* This file is where the damage messages go for offensive spells, and * This file is where the damage messages go for offensive spells, skills
* skills such as kick and backstab. Also, starting with Circle 3.0, these * (such as kick and backstab), failed spells, and weapon messages for
* messages are used for failed spells, and weapon messages for misses and * misses and death blows.
* death blows.
* *
* All records must start with 'M' in the first column (for 'Message'). * All records must start with 'M' in the first column (for 'Message').
* The next line must contain the damage number (defined in spells.h), * The next line must contain the damage number (defined in spells.h),

View file

@ -1216,7 +1216,7 @@ a nice mug~
A nice mug of tea has been left here.~ A nice mug of tea has been left here.~
~ ~
17 i 0 0 0 a 0 0 0 0 0 0 0 17 i 0 0 0 a 0 0 0 0 0 0 0
2 2 11 0 -1 0 0 0
7 1 0 0 7 1 0 0
E E
mug cup tea nice~ mug cup tea nice~

View file

@ -125,7 +125,7 @@ a spring well~
A mountain spring bubbles up fresh water here.~ A mountain spring bubbles up fresh water here.~
~ ~
23 0 0 0 0 0 0 0 0 0 0 0 0 23 0 0 0 0 0 0 0 0 0 0 0 0
500 500 15 0 -1 1 15 0
0 0 0 0 0 0 0 0
E E
spring fountain water~ spring fountain water~
@ -208,9 +208,9 @@ trial vnum assigner limiter~
free~ free~
A trial vnum assigner helps people work on thier trial vnum.~ A trial vnum assigner helps people work on thier trial vnum.~
~ ~
12 0 0 0 0 a 0 0 0 0 0 0 0 12 0 0 0 0 acno 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1 1 0 0 1 1 0 34
E E
trial vnum assigner limiter~ trial vnum assigner limiter~
This object was created to help new builders follow the directions under HELP This object was created to help new builders follow the directions under HELP

View file

@ -67,7 +67,7 @@ copper dragon claw key~
large. large.
~ ~
#25005 #25005
pixie king key~ pixie king key door~
a very small key~ a very small key~
The key to the Pixie King's bedroom is here, it is almost impossible find.~ The key to the Pixie King's bedroom is here, it is almost impossible find.~
~ ~

View file

@ -53,7 +53,7 @@ if %object.vnum% == 1
* Reward the actor with an entire gold coin! * Reward the actor with an entire gold coin!
nop %actor.gold(1)% nop %actor.gold(1)%
wait 5 sec wait 5 sec
%purge% obj 1 %purge% %object%
else else
* This isn't the right object - don't accept it. * This isn't the right object - don't accept it.
say I don't want that - bring me back my wings. say I don't want that - bring me back my wings.

View file

@ -7,62 +7,16 @@ General trigger keeper. Only for use in room 0.~
* Trying to access Global var list of void. Apparently this has not been set up! * Trying to access Global var list of void. Apparently this has not been set up!
~ ~
#1201 #1201
Calculator By Mordecai~ crash test trigger~
2 d 100 2 c 100
*~ target~
* By Mordecai %echo% %actor.name% is targetting %%arg.name%% IS_PC: %arg.is_pc%
if %actor.is_pc% if %arg.is_pc% == 1
Return 0 %echo% It is a player.
Eval sum %speech% elseif %arg.is_pc% == 0
Eval test1 "%speech%" %echo% It is a mob.
Eval test %test1.strlen% else
Eval che %sum%/1 %echo It is an object.
If %che% == %sum%
%echo% @WComputing results...@n
if (%speech%/===)
if (%sum%==1)
set sum Yes
elseif (%sum%==0)
set sum No
end
end
Eval st 2+%test%
Eval o .
Eval sumslen "%sum%
Eval len %st% - (%sumslen.strlen%-2)
If %len% > 0
Eval dif (%len%/2)
While %y.strlen% < %st%
Eval o .%o%
Eval y %o%
Eval m ?%m%
Eval p %m%
If %dif% == %y.strlen%
Eval wid1 %p%
end
done
end
eval opt1 8 + %test%
eval opt2 (2*%wid1.strlen%)+%sumslen.strlen%+5
%echo% @WWizzzzzzzzzz....@n
if (%opt1%-2) == (%opt2%)
%echo% @c...%y%...@n
%echo% @c:@C..%y%..@c:@n
%echo% @c:@C:@G %speech% @C :@c:@n
%echo% @c:@C:.%y%.:@c:@n
%echo% @c:@C: %wid1%@G %sum% @C%wid1% :@c:@n
%echo% @c:@C:.%y%.:@c:@n
%echo% @c:..%y%..:@n
else
%echo% @r....%y%...@n
%echo% @r:@R...%y%..@r:@n
%echo% @r:@R:@G %speech% @R :@r:@n
%echo% @r:@R:..%y%.:@r:@n
%echo% @r:@R: %wid1%@G %sum% @R%wid1% :@r:@n
%echo% @r:@R:..%y%.:@r:@n
%echo% @r:...%y%..:@n
end
end
end end
~ ~
#1202 #1202
@ -805,6 +759,36 @@ while %self.varexists(%j%)%
done done
%echo% O=#==================================================O %echo% O=#==================================================O
~ ~
#1215
Hunger, Thirst, Drunk Test Trigger~
2 g 100
~
wait 1
%echo% Hello %actor.name%
%echo% Hunger: %actor.hunger% Thirst: %actor.thirst% Drunk: %actor.drunk%
nop %actor.hunger(50)
nop %actor.thirst(50)
nop %actor.drunk(50)
%echo% Hunger: %actor.hunger% Thirst: %actor.thirst% Drunk: %actor.drunk%
nop %actor.hunger(-10)
nop %actor.thirst(-10)
nop %actor.drunk(-10)
%echo% Hunger: %actor.hunger% Thirst: %actor.thirst% Drunk: %actor.drunk%
nop %actor.hunger(20)
nop %actor.thirst(21)
nop %actor.drunk(22)
%echo% Hunger: %actor.hunger% Thirst: %actor.thirst% Drunk: %actor.drunk%
*
while %actor.hunger% >= 0
nop %actor.hunger(-1)
done
while %actor.thirst% >= 0
nop %actor.thirst(-1)
done
while %actor.drunk% >= 0
nop %actor.drunk(-1)
done
~
#1217 #1217
new trigger~ new trigger~
1 c 1 1 c 1

View file

@ -180,4 +180,5 @@
325.trg 325.trg
326.trg 326.trg
345.trg 345.trg
$ $

View file

@ -559,6 +559,14 @@ while the mark of the mature man is that he wants to live humbly for one.
--Wilhelm Stekel --Wilhelm Stekel
~ ~
0 8 0 0 0 0 0 8 0 0 0 0
D0
~
~
0 0 33
D2
~
~
0 0 33
E E
.test~ .test~
can you see this with look around? can you see this with look around?
@ -659,6 +667,7 @@ from you. It's a beautiful reciprocal arrangement.
--The Catcher in the Rye --The Catcher in the Rye
~ ~
S S
T 1201
#34 #34
Pool of Images~ Pool of Images~
A broad mosaic walkway wraps around the natural hotsprings in this cavernous A broad mosaic walkway wraps around the natural hotsprings in this cavernous

View file

@ -516,7 +516,8 @@ ACMD(do_gen_comm)
send_to_char(ch, "%s", CONFIG_OK); send_to_char(ch, "%s", CONFIG_OK);
else { else {
if (!first_word_is_name(ch, argument)) { if (!first_word_is_name(ch, argument)) {
snprintf(buf1, sizeof(buf1), "%sYou %s, '%s'%s", COLOR_LEV(ch) >= C_CMP ? color_on : "", com_msgs[subcmd][1], argument, CCNRM(ch, C_CMP)); snprintf(buf1, sizeof(buf1), "%sYou %s, '%s%s'%s", COLOR_LEV(ch) >= C_CMP ? color_on : "", com_msgs[subcmd][1], argument, COLOR_LEV(ch) >= C_CMP
? color_on : "", CCNRM(ch, C_CMP));
} else { } else {
emoting = TRUE; emoting = TRUE;
snprintf(buf1, sizeof(buf1), "%s%s: %s%s", COLOR_LEV(ch) >= C_CMP ? color_on : "", com_msgs[subcmd][1], CAP(argument), CCNRM(ch, C_CMP)); snprintf(buf1, sizeof(buf1), "%s%s: %s%s", COLOR_LEV(ch) >= C_CMP ? color_on : "", com_msgs[subcmd][1], CAP(argument), CCNRM(ch, C_CMP));

View file

@ -131,17 +131,21 @@ void show_obj_to_char(struct obj_data *obj, struct char_data *ch, int mode)
if (*obj->description == '.' && (IS_NPC(ch) || !PRF_FLAGGED(ch, PRF_HOLYLIGHT))) if (*obj->description == '.' && (IS_NPC(ch) || !PRF_FLAGGED(ch, PRF_HOLYLIGHT)))
return; return;
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_SHOWVNUMS)) if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_SHOWVNUMS)) {
send_to_char(ch, "[%d] %s", GET_OBJ_VNUM(obj), SCRIPT(obj) ? "[TRIG] " : ""); send_to_char(ch, "[%d] ", GET_OBJ_VNUM(obj));
if (SCRIPT(obj))
send_to_char(ch, "[T%d] ", obj->proto_script->vnum);
}
send_to_char(ch, "%s", CCGRN(ch, C_NRM)); send_to_char(ch, "%s", CCGRN(ch, C_NRM));
send_to_char(ch, "%s", obj->description); send_to_char(ch, "%s", obj->description);
break; break;
case SHOW_OBJ_SHORT: case SHOW_OBJ_SHORT:
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_SHOWVNUMS)) if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_SHOWVNUMS)) {
send_to_char(ch, "[%d] %s", GET_OBJ_VNUM(obj), SCRIPT(obj) ? "[TRIG] " : ""); send_to_char(ch, "[%d] ", GET_OBJ_VNUM(obj));
if (SCRIPT(obj))
send_to_char(ch, "[T%d] ", obj->proto_script->vnum);
}
send_to_char(ch, "%s", obj->short_description); send_to_char(ch, "%s", obj->short_description);
break; break;
@ -321,8 +325,11 @@ void list_one_char(struct char_data *i, struct char_data *ch)
" is standing here." " is standing here."
}; };
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_SHOWVNUMS) && IS_NPC(i)) if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_SHOWVNUMS) && IS_NPC(i)) {
send_to_char(ch, "[%d] %s", GET_MOB_VNUM(i), SCRIPT(i) ? "[TRIG] " : ""); send_to_char(ch, "[%d]", GET_MOB_VNUM(i));
if (SCRIPT(i))
send_to_char(ch, "[T%d] ", i->proto_script->vnum);
}
if (IS_NPC(i) && i->player.long_descr && GET_POS(i) == GET_DEFAULT_POS(i)) { if (IS_NPC(i) && i->player.long_descr && GET_POS(i) == GET_DEFAULT_POS(i)) {
if (AFF_FLAGGED(i, AFF_INVISIBLE)) if (AFF_FLAGGED(i, AFF_INVISIBLE))
@ -488,8 +495,10 @@ void look_at_room(struct char_data *ch, int ignore_brief)
sprintbitarray(ROOM_FLAGS(IN_ROOM(ch)), room_bits, RF_ARRAY_MAX, buf); 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, "[%5d] ", GET_ROOM_VNUM(IN_ROOM(ch)));
send_to_char(ch, "%s%s [ %s]", if (SCRIPT(rm))
SCRIPT(rm) ? "[TRIG] " : "", send_to_char(ch, "[T%d] ", rm->proto_script->vnum);
send_to_char(ch, "%s [ %s]",
world[IN_ROOM(ch)].name, buf); world[IN_ROOM(ch)].name, buf);
} else } else
send_to_char(ch, "%s", world[IN_ROOM(ch)].name); send_to_char(ch, "%s", world[IN_ROOM(ch)].name);
@ -561,7 +570,7 @@ void look_in_obj(struct char_data *ch, char *arg)
list_obj_to_char(obj->contains, ch, SHOW_OBJ_SHORT, TRUE); list_obj_to_char(obj->contains, ch, SHOW_OBJ_SHORT, TRUE);
} }
} else { /* item must be a fountain or drink container */ } else { /* item must be a fountain or drink container */
if (GET_OBJ_VAL(obj, 1) <= 0) if ((GET_OBJ_VAL(obj, 1) == 0) && (!GET_OBJ_VAL(obj, 0) == 1))
send_to_char(ch, "It is empty.\r\n"); send_to_char(ch, "It is empty.\r\n");
else { else {
if (GET_OBJ_VAL(obj, 0) < 0) if (GET_OBJ_VAL(obj, 0) < 0)
@ -1554,7 +1563,7 @@ void print_object_location(int num, struct obj_data *obj, struct char_data *ch,
send_to_char(ch, "%33s", " - "); send_to_char(ch, "%33s", " - ");
if (obj->proto_script) if (obj->proto_script)
send_to_char(ch, "[TRIG]"); send_to_char(ch, "[%d]", obj->proto_script->vnum);
if (IN_ROOM(obj) != NOWHERE) if (IN_ROOM(obj) != NOWHERE)
send_to_char(ch, "[%5d] %s%s\r\n", GET_ROOM_VNUM(IN_ROOM(obj)), world[IN_ROOM(obj)].name, QNRM); send_to_char(ch, "[%5d] %s%s\r\n", GET_ROOM_VNUM(IN_ROOM(obj)), world[IN_ROOM(obj)].name, QNRM);
@ -1595,9 +1604,11 @@ void perform_immort_where(struct char_data *ch, char *arg)
for (i = character_list; i; i = i->next) for (i = character_list; i; i = i->next)
if (CAN_SEE(ch, i) && IN_ROOM(i) != NOWHERE && isname(arg, i->player.name)) { if (CAN_SEE(ch, i) && IN_ROOM(i) != NOWHERE && isname(arg, i->player.name)) {
found = 1; found = 1;
send_to_char(ch, "M%3d. %-25s%s - [%5d] %-25s%s %s\r\n", ++num, GET_NAME(i), QNRM, send_to_char(ch, "M%3d. %-25s%s - [%5d] %-25s%s", ++num, GET_NAME(i), QNRM,
GET_ROOM_VNUM(IN_ROOM(i)), world[IN_ROOM(i)].name, QNRM, GET_ROOM_VNUM(IN_ROOM(i)), world[IN_ROOM(i)].name, QNRM);
(IS_NPC(i) && i->proto_script) ? "[TRIG]" : ""); if (SCRIPT(i))
send_to_char(ch, "[T%d] ", i->proto_script->vnum);
send_to_char(ch, "%s\r\n", QNRM);
} }
for (num = 0, k = object_list; k; k = k->next) for (num = 0, k = object_list; k; k = k->next)
if (CAN_SEE_OBJ(ch, k) && isname(arg, k->name)) { if (CAN_SEE_OBJ(ch, k) && isname(arg, k->name)) {

View file

@ -854,8 +854,8 @@ ACMD(do_drink)
send_to_char(ch, "Your stomach can't contain anymore!\r\n"); send_to_char(ch, "Your stomach can't contain anymore!\r\n");
return; return;
} }
if (!GET_OBJ_VAL(temp, 1)) { if ((GET_OBJ_VAL(temp, 1) == 0) && (!GET_OBJ_VAL(temp, 0) == 1)) {
send_to_char(ch, "It's empty.\r\n"); send_to_char(ch, "It is empty.\r\n");
return; return;
} }
@ -1330,8 +1330,12 @@ ACMD(do_wear)
for (obj = ch->carrying; obj; obj = next_obj) { for (obj = ch->carrying; obj; obj = next_obj) {
next_obj = obj->next_content; next_obj = obj->next_content;
if (CAN_SEE_OBJ(ch, obj) && (where = find_eq_pos(ch, obj, 0)) >= 0) { if (CAN_SEE_OBJ(ch, obj) && (where = find_eq_pos(ch, obj, 0)) >= 0) {
items_worn++; if (GET_LEVEL(ch) < GET_OBJ_LEVEL(obj))
perform_wear(ch, obj, where); send_to_char(ch, "You are not experienced enough to use that.\r\n");
else {
items_worn++;
perform_wear(ch, obj, where);
}
} }
} }
if (!items_worn) if (!items_worn)
@ -1357,6 +1361,8 @@ ACMD(do_wear)
} else { } else {
if (!(obj = get_obj_in_list_vis(ch, arg1, NULL, ch->carrying))) if (!(obj = get_obj_in_list_vis(ch, arg1, NULL, ch->carrying)))
send_to_char(ch, "You don't seem to have %s %s.\r\n", AN(arg1), arg1); send_to_char(ch, "You don't seem to have %s %s.\r\n", AN(arg1), arg1);
else if (GET_LEVEL(ch) < GET_OBJ_LEVEL(obj))
send_to_char(ch, "You are not experienced enough to use that.\r\n");
else { else {
if ((where = find_eq_pos(ch, obj, arg2)) >= 0) if ((where = find_eq_pos(ch, obj, arg2)) >= 0)
perform_wear(ch, obj, where); perform_wear(ch, obj, where);
@ -1382,6 +1388,8 @@ ACMD(do_wield)
send_to_char(ch, "You can't wield that.\r\n"); send_to_char(ch, "You can't wield that.\r\n");
else if (GET_OBJ_WEIGHT(obj) > str_app[STRENGTH_APPLY_INDEX(ch)].wield_w) else if (GET_OBJ_WEIGHT(obj) > str_app[STRENGTH_APPLY_INDEX(ch)].wield_w)
send_to_char(ch, "It's too heavy for you to use.\r\n"); send_to_char(ch, "It's too heavy for you to use.\r\n");
else if (GET_LEVEL(ch) < GET_OBJ_LEVEL(obj))
send_to_char(ch, "You are not experienced enough to use that.\r\n");
else else
perform_wear(ch, obj, WEAR_WIELD); perform_wear(ch, obj, WEAR_WIELD);
} }
@ -1398,6 +1406,8 @@ ACMD(do_grab)
send_to_char(ch, "Hold what?\r\n"); send_to_char(ch, "Hold what?\r\n");
else if (!(obj = get_obj_in_list_vis(ch, arg, NULL, ch->carrying))) else if (!(obj = get_obj_in_list_vis(ch, arg, NULL, ch->carrying)))
send_to_char(ch, "You don't seem to have %s %s.\r\n", AN(arg), arg); send_to_char(ch, "You don't seem to have %s %s.\r\n", AN(arg), arg);
else if (GET_LEVEL(ch) < GET_OBJ_LEVEL(obj))
send_to_char(ch, "You are not experienced enough to use that.\r\n");
else { else {
if (GET_OBJ_TYPE(obj) == ITEM_LIGHT) if (GET_OBJ_TYPE(obj) == ITEM_LIGHT)
perform_wear(ch, obj, WEAR_LIGHT); perform_wear(ch, obj, WEAR_LIGHT);

View file

@ -509,6 +509,11 @@ ACMD(do_gen_door)
if (!generic_find(type, FIND_OBJ_INV | FIND_OBJ_ROOM, ch, &victim, &obj)) if (!generic_find(type, FIND_OBJ_INV | FIND_OBJ_ROOM, ch, &victim, &obj))
door = find_door(ch, type, dir, cmd_door[subcmd]); door = find_door(ch, type, dir, cmd_door[subcmd]);
if ((obj) && (GET_OBJ_TYPE(obj) != ITEM_CONTAINER)) {
obj = NULL;
door = find_door(ch, type, dir, cmd_door[subcmd]);
}
if ((obj) || (door >= 0)) { if ((obj) || (door >= 0)) {
keynum = DOOR_KEY(ch, obj, door); keynum = DOOR_KEY(ch, obj, door);
if (!(DOOR_IS_OPENABLE(ch, obj, door))) if (!(DOOR_IS_OPENABLE(ch, obj, door)))

View file

@ -1521,8 +1521,14 @@ ACMD(do_advance)
GET_LEVEL(victim) = newlevel; GET_LEVEL(victim) = newlevel;
send_to_char(victim, "You are momentarily enveloped by darkness!\r\nYou feel somewhat diminished.\r\n"); send_to_char(victim, "You are momentarily enveloped by darkness!\r\nYou feel somewhat diminished.\r\n");
} else { } else {
act("$n advances you.\r\n" , FALSE, ch, 0, victim, TO_VICT); act("$n makes some strange gestures. A strange feeling comes upon you,\r\n"
} "Like a giant hand, light comes down from above, grabbing your body,\r\n"
"that begins to pulse with colored lights from inside.\r\n\r\n"
"Your head seems to be filled with demons from another plane as your\r\n"
"your body dissolves to the elements of time and space itself.\r\n"
"Suddenly a silent explosion of light snaps you back to reality.\r\n\r\n"
"You feel slightly different.", FALSE, ch, 0, victim, TO_VICT);
}
send_to_char(ch, "%s", CONFIG_OK); send_to_char(ch, "%s", CONFIG_OK);
@ -3033,7 +3039,11 @@ int perform_set(struct char_data *ch, struct char_data *vict, int mode, char *va
case 38: /* poofin */ case 38: /* poofin */
if ((vict == ch) || (GET_LEVEL(ch) == LVL_IMPL)) { if ((vict == ch) || (GET_LEVEL(ch) == LVL_IMPL)) {
skip_spaces(&val_arg); skip_spaces(&val_arg);
if (!*val_arg)
if (POOFIN(vict))
free(POOFIN(vict));
if (!*val_arg)
POOFIN(vict) = NULL; POOFIN(vict) = NULL;
else else
POOFIN(vict) = strdup(val_arg); POOFIN(vict) = strdup(val_arg);
@ -3042,7 +3052,11 @@ int perform_set(struct char_data *ch, struct char_data *vict, int mode, char *va
case 39: /* poofout */ case 39: /* poofout */
if ((vict == ch) || (GET_LEVEL(ch) == LVL_IMPL)) { if ((vict == ch) || (GET_LEVEL(ch) == LVL_IMPL)) {
skip_spaces(&val_arg); skip_spaces(&val_arg);
if (!*val_arg)
if (POOFOUT(vict))
free(POOFOUT(vict));
if (!*val_arg)
POOFOUT(vict) = NULL; POOFOUT(vict) = NULL;
else else
POOFOUT(vict) = strdup(val_arg); POOFOUT(vict) = strdup(val_arg);

View file

@ -2100,7 +2100,7 @@ void free_help_table(void)
{ {
if (help_table) { if (help_table) {
int hp; int hp;
for (hp = 0; hp <= top_of_helpt; hp++) { for (hp = 0; hp < top_of_helpt; hp++) {
if (help_table[hp].keywords) if (help_table[hp].keywords)
free(help_table[hp].keywords); free(help_table[hp].keywords);
if (help_table[hp].entry && !help_table[hp].duplicate) if (help_table[hp].entry && !help_table[hp].duplicate)

View file

@ -810,7 +810,7 @@ void script_stat (char_data *ch, struct script_data *sc)
void do_sstat_room(struct char_data * ch, struct room_data *rm) void do_sstat_room(struct char_data * ch, struct room_data *rm)
{ {
send_to_char(ch, "Script information:\r\n"); send_to_char(ch, "Triggers:\r\n");
if (!SCRIPT(rm)) { if (!SCRIPT(rm)) {
send_to_char(ch, " None.\r\n"); send_to_char(ch, " None.\r\n");
return; return;
@ -821,7 +821,7 @@ void do_sstat_room(struct char_data * ch, struct room_data *rm)
void do_sstat_object(char_data *ch, obj_data *j) void do_sstat_object(char_data *ch, obj_data *j)
{ {
send_to_char(ch, "Script information:\r\n"); send_to_char(ch, "Triggers:\r\n");
if (!SCRIPT(j)) { if (!SCRIPT(j)) {
send_to_char(ch, " None.\r\n"); send_to_char(ch, " None.\r\n");
return; return;
@ -832,7 +832,7 @@ void do_sstat_object(char_data *ch, obj_data *j)
void do_sstat_character(char_data *ch, char_data *k) void do_sstat_character(char_data *ch, char_data *k)
{ {
send_to_char(ch, "Script information:\r\n"); send_to_char(ch, "Triggers:\r\n");
if (!SCRIPT(k)) { if (!SCRIPT(k)) {
send_to_char(ch, " None.\r\n"); send_to_char(ch, " None.\r\n");
return; return;

View file

@ -604,6 +604,13 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
} }
snprintf(str, slen, "%d", GET_DEX(c)); snprintf(str, slen, "%d", GET_DEX(c));
} }
else if (!str_cmp(field, "drunk")) {
if (subfield && *subfield) {
int addition = atoi(subfield);
GET_COND(c, DRUNK) = MAX(-1, MIN(addition, 24));
}
snprintf(str, slen, "%d", GET_COND(c, DRUNK));
}
break; break;
case 'e': case 'e':
if (!str_cmp(field, "exp")) { if (!str_cmp(field, "exp")) {
@ -682,6 +689,13 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
} }
snprintf(str, slen, "%d", GET_HIT(c)); snprintf(str, slen, "%d", GET_HIT(c));
} }
else if (!str_cmp(field, "hunger")) {
if (subfield && *subfield) {
int addition = atoi(subfield);
GET_COND(c, HUNGER) = MAX(-1, MIN(addition, 24));
}
snprintf(str, slen, "%d", GET_COND(c, HUNGER));
}
break; break;
case 'i': case 'i':
if (!str_cmp(field, "id")) if (!str_cmp(field, "id"))
@ -970,7 +984,15 @@ void find_replacement(void *go, struct script_data *sc, trig_data *trig,
} }
snprintf(str, slen, "%s", IS_NPC(c) ? "" : GET_TITLE(c)); snprintf(str, slen, "%s", IS_NPC(c) ? "" : GET_TITLE(c));
} }
case 'v': else if (!str_cmp(field, "thirst")) {
if (subfield && *subfield) {
int addition = atoi(subfield);
GET_COND(c, THIRST) = MAX(-1, MIN(addition, 24));
}
snprintf(str, slen, "%d", GET_COND(c, THIRST));
}
break;
case 'v':
if (!str_cmp(field, "vnum")) { if (!str_cmp(field, "vnum")) {
if (subfield && *subfield) { if (subfield && *subfield) {
snprintf(str, slen, "%d", IS_NPC(c) ? (int)(GET_MOB_VNUM(c) == atoi(subfield)) : -1 ); snprintf(str, slen, "%d", IS_NPC(c) ? (int)(GET_MOB_VNUM(c) == atoi(subfield)) : -1 );
@ -1099,7 +1121,10 @@ o->contains) ? "1" : "0"));
else else
*str = '\0'; *str = '\0';
} }
break; else if (!str_cmp(field, "is_pc")) {
strcpy(str, "-1");
}
break;
case 'n': case 'n':
if (!str_cmp(field, "name")) if (!str_cmp(field, "name"))
snprintf(str, slen, "%s", o->name); snprintf(str, slen, "%s", o->name);

View file

@ -160,7 +160,7 @@ int add_to_save_list(zone_vnum zone, int type)
rznum = real_zone(zone); rznum = real_zone(zone);
if (rznum == NOWHERE || rznum > top_of_zone_table) { if (rznum == NOWHERE || rznum > top_of_zone_table) {
if (zone != AEDIT_PERMISSION) { if (zone != AEDIT_PERMISSION || zone != HEDIT_PERMISSION) {
log("SYSERR: add_to_save_list: Invalid zone number passed. (%d => %d, 0-%d)", zone, rznum, top_of_zone_table); log("SYSERR: add_to_save_list: Invalid zone number passed. (%d => %d, 0-%d)", zone, rznum, top_of_zone_table);
return FALSE; return FALSE;
} }

View file

@ -141,7 +141,7 @@ void hedit_save_internally(struct descriptor_data *d)
int i; int i;
CREATE(new_help_table, struct help_index_element, top_of_helpt + 2); CREATE(new_help_table, struct help_index_element, top_of_helpt + 2);
for (i = 0; i <= top_of_helpt; i++) for (i = 0; i < top_of_helpt; i++)
new_help_table[i] = help_table[i]; new_help_table[i] = help_table[i];
new_help_table[++top_of_helpt] = *OLC_HELP(d); new_help_table[++top_of_helpt] = *OLC_HELP(d);
free(help_table); free(help_table);
@ -165,7 +165,7 @@ void hedit_save_to_disk(struct descriptor_data *d)
return; return;
} }
for (i = 0; i <= top_of_helpt; i++) { for (i = 0; i < top_of_helpt; i++) {
if (help_table[i].duplicate) if (help_table[i].duplicate)
continue; continue;
strncpy(buf1, help_table[i].entry ? help_table[i].entry : "Empty\r\n", sizeof(buf1) - 1); strncpy(buf1, help_table[i].entry ? help_table[i].entry : "Empty\r\n", sizeof(buf1) - 1);
@ -245,7 +245,7 @@ void hedit_parse(struct descriptor_data *d, char *arg)
break; break;
case 'n': case 'N': case 'n': case 'N':
OLC_ZNUM(d)++; OLC_ZNUM(d)++;
for (; OLC_ZNUM(d) <= top_of_helpt; OLC_ZNUM(d)++) for (; OLC_ZNUM(d) < top_of_helpt; OLC_ZNUM(d)++)
if (is_abbrev(OLC_STORAGE(d), help_table[OLC_ZNUM(d)].keywords)) if (is_abbrev(OLC_STORAGE(d), help_table[OLC_ZNUM(d)].keywords))
break; break;
else else
@ -310,7 +310,7 @@ void hedit_parse(struct descriptor_data *d, char *arg)
string_write(d, &OLC_HELP(d)->entry, MAX_MESSAGE_LENGTH, 0, oldtext); string_write(d, &OLC_HELP(d)->entry, MAX_MESSAGE_LENGTH, 0, oldtext);
OLC_VAL(d) = 1; OLC_VAL(d) = 1;
break; break;
case 'M': case '2':
write_to_output(d, "Enter min level : "); write_to_output(d, "Enter min level : ");
OLC_MODE(d) = HEDIT_MIN_LEVEL; OLC_MODE(d) = HEDIT_MIN_LEVEL;
break; break;
@ -408,7 +408,7 @@ ACMD(do_hindex)
} }
len = sprintf(buf, "Help index entries based on '%s':\r\n", argument); len = sprintf(buf, "Help index entries based on '%s':\r\n", argument);
for (i = 0; i <= top_of_helpt; i++) for (i = 0; i < top_of_helpt; i++)
if (is_abbrev(argument, help_table[i].keywords) if (is_abbrev(argument, help_table[i].keywords)
&& (GET_LEVEL(ch) >= help_table[i].min_level)) && (GET_LEVEL(ch) >= help_table[i].min_level))
len += len +=

View file

@ -1375,6 +1375,9 @@ void nanny(struct descriptor_data *d, char *arg)
CREATE(d->character, struct char_data, 1); CREATE(d->character, struct char_data, 1);
clear_char(d->character); clear_char(d->character);
CREATE(d->character->player_specials, struct player_special_data, 1); CREATE(d->character->player_specials, struct player_special_data, 1);
if (GET_HOST(d->character))
free(GET_HOST(d->character));
GET_HOST(d->character) = strdup(d->host); GET_HOST(d->character) = strdup(d->host);
d->character->desc = d; d->character->desc = d;

View file

@ -328,7 +328,7 @@ void oedit_disp_extradesc_menu(struct descriptor_data *d)
grn, nrm, yel, (extra_desc->keyword && *extra_desc->keyword) ? extra_desc->keyword : "<NONE>", grn, nrm, yel, (extra_desc->keyword && *extra_desc->keyword) ? extra_desc->keyword : "<NONE>",
grn, nrm, yel, (extra_desc->description && *extra_desc->description) ? extra_desc->description : "<NONE>", grn, nrm, yel, (extra_desc->description && *extra_desc->description) ? extra_desc->description : "<NONE>",
grn, nrm, !extra_desc->next ? "<Not set>\r\n" : "Set.", grn, nrm); grn, nrm, !extra_desc->next ? "Not set." : "Set.", grn, nrm);
OLC_MODE(d) = OEDIT_EXTRADESC_MENU; OLC_MODE(d) = OEDIT_EXTRADESC_MENU;
} }
@ -444,7 +444,7 @@ void oedit_disp_val1_menu(struct descriptor_data *d)
break; break;
case ITEM_DRINKCON: case ITEM_DRINKCON:
case ITEM_FOUNTAIN: case ITEM_FOUNTAIN:
write_to_output(d, "Max drink units : "); write_to_output(d, "Max drink units (-1 for unlimited) : ");
break; break;
case ITEM_FOOD: case ITEM_FOOD:
write_to_output(d, "Hours to fill stomach : "); write_to_output(d, "Hours to fill stomach : ");
@ -488,7 +488,7 @@ void oedit_disp_val2_menu(struct descriptor_data *d)
break; break;
case ITEM_DRINKCON: case ITEM_DRINKCON:
case ITEM_FOUNTAIN: case ITEM_FOUNTAIN:
write_to_output(d, "Initial drink units (-1 for unlimited) : "); write_to_output(d, "Initial drink units : ");
break; break;
default: default:
oedit_disp_menu(d); oedit_disp_menu(d);
@ -648,7 +648,7 @@ void oedit_disp_menu(struct descriptor_data *d)
grn, nrm, yel, (obj->name && *obj->name) ? obj->name : "undefined", grn, nrm, yel, (obj->name && *obj->name) ? obj->name : "undefined",
grn, nrm, yel, (obj->short_description && *obj->short_description) ? obj->short_description : "undefined", grn, nrm, yel, (obj->short_description && *obj->short_description) ? obj->short_description : "undefined",
grn, nrm, yel, (obj->description && *obj->description) ? obj->description : "undefined", grn, nrm, yel, (obj->description && *obj->description) ? obj->description : "undefined",
grn, nrm, yel, (obj->action_description && *obj->action_description) ? obj->action_description : "<not set>\r\n", grn, nrm, yel, (obj->action_description && *obj->action_description) ? obj->action_description : "Not Set.\r\n",
grn, nrm, cyn, buf1, grn, nrm, cyn, buf1,
grn, nrm, cyn, buf2 grn, nrm, cyn, buf2
); );
@ -664,7 +664,7 @@ void oedit_disp_menu(struct descriptor_data *d)
"%sB%s) Timer : %s%d\r\n" "%sB%s) Timer : %s%d\r\n"
"%sC%s) Values : %s%d %d %d %d\r\n" "%sC%s) Values : %s%d %d %d %d\r\n"
"%sD%s) Applies menu\r\n" "%sD%s) Applies menu\r\n"
"%sE%s) Extra descriptions menu\r\n" "%sE%s) Extra descriptions menu: %s%s%s\r\n"
"%sM%s) Min Level : %s%d\r\n" "%sM%s) Min Level : %s%d\r\n"
"%sP%s) Perm Affects: %s%s\r\n" "%sP%s) Perm Affects: %s%s\r\n"
"%sS%s) Script : %s%s\r\n" "%sS%s) Script : %s%s\r\n"
@ -681,7 +681,7 @@ void oedit_disp_menu(struct descriptor_data *d)
GET_OBJ_VAL(obj, 1), GET_OBJ_VAL(obj, 1),
GET_OBJ_VAL(obj, 2), GET_OBJ_VAL(obj, 2),
GET_OBJ_VAL(obj, 3), GET_OBJ_VAL(obj, 3),
grn, nrm, grn, nrm, grn, nrm, grn, nrm, cyn, GET_OBJ_EXTRA(obj) ? "Set." : "Not Set.", grn,
grn, nrm, cyn, GET_OBJ_LEVEL(obj), grn, nrm, cyn, GET_OBJ_LEVEL(obj),
grn, nrm, cyn, buf2, grn, nrm, cyn, buf2,
grn, nrm, cyn, OLC_SCRIPT(d) ? "Set." : "Not Set.", grn, nrm, cyn, OLC_SCRIPT(d) ? "Set." : "Not Set.",

View file

@ -374,22 +374,14 @@ int load_char(const char *name, struct char_data *ch)
else if (!strcmp(tag, "Plyd")) ch->player.time.played = atoi(line); else if (!strcmp(tag, "Plyd")) ch->player.time.played = atoi(line);
else if (!strcmp(tag, "PfIn")) POOFIN(ch) = strdup(line); else if (!strcmp(tag, "PfIn")) POOFIN(ch) = strdup(line);
else if (!strcmp(tag, "PfOt")) POOFOUT(ch) = strdup(line); else if (!strcmp(tag, "PfOt")) POOFOUT(ch) = strdup(line);
/* else if (!strcmp(tag, "Pref")) else if (!strcmp(tag, "Pref"))
sscanf(line, "%s %s %s %s", f1, f2, f3, f4); if (sscanf(line, "%s %s %s %s", f1, f2, f3, f4) == 4) {
PRF_FLAGS(ch)[0] = asciiflag_conv(f1); PRF_FLAGS(ch)[0] = asciiflag_conv(f1);
PRF_FLAGS(ch)[1] = asciiflag_conv(f2); PRF_FLAGS(ch)[1] = asciiflag_conv(f2);
PRF_FLAGS(ch)[2] = asciiflag_conv(f3); PRF_FLAGS(ch)[2] = asciiflag_conv(f3);
PRF_FLAGS(ch)[3] = asciiflag_conv(f4); PRF_FLAGS(ch)[3] = asciiflag_conv(f4);
*/ }
else if (!strcmp(tag, "Pref")) { break;
char *temp = line;
temp = one_argument(temp, line);
for (i = 0; *line && i < PR_ARRAY_MAX; i++) {
PRF_FLAGS(ch)[i] = asciiflag_conv(line);
temp = one_argument(temp, line);
}
}
break;
case 'Q': case 'Q':
if (!strcmp(tag, "Qstp")) GET_QUESTPOINTS(ch) = atoi(line); if (!strcmp(tag, "Qstp")) GET_QUESTPOINTS(ch) = atoi(line);

View file

@ -315,7 +315,7 @@ void redit_disp_extradesc_menu(struct descriptor_data *d)
grn, nrm grn, nrm
); );
write_to_output(d, !extra_desc->next ? "<NOT SET>\r\n" : "Set.\r\n"); write_to_output(d, !extra_desc->next ? "Not Set.\r\n" : "Set.\r\n");
write_to_output(d, "Enter choice (0 to quit) : "); write_to_output(d, "Enter choice (0 to quit) : ");
OLC_MODE(d) = REDIT_EXTRADESC_MENU; OLC_MODE(d) = REDIT_EXTRADESC_MENU;
} }

View file

@ -2,21 +2,14 @@
* File: zmalloc.c Part of tbaMUD * * File: zmalloc.c Part of tbaMUD *
* Usage: A simple memory allocation monitor. * * Usage: A simple memory allocation monitor. *
* * * *
* Version 2. Copyright 1996, 1998, 1999, 2000 Eric Murray. * * Version 2. Copyright 1996, 1998, 1999, 2000 Eric Murray ericm@lne.com *
**************************************************************************/ **************************************************************************/
/* /* Usage: To run tbaMUD in debug mode change the flags line in your Makefile
** Zmalloc, a simple memory-allocation monitor. * as below, make clean, and reboot.
** *
** Copyright 1996,1998,1999,2000 Eric Murray, ericm@lne.com * Makefile: # Any special flags you want to pass to the compiler
** You may make free use of this code but please give me credit. * Makefile: MYFLAGS = -Wall -DMEMORY_DEBUG */
** Documentation: http://www.lne.com/ericm/zmalloc
*
* Usage: to enable call zmalloc_init() at the very start of your
* program to open the logfile and call zmalloc_check() at the end
* to display memory leaks and free all allocated mem.
* See the main() test function at the bottom for an example.
*/
/* protect our calloc() and free() calls from recursive redefinition: */ /* protect our calloc() and free() calls from recursive redefinition: */
#define ZMALLOC_H #define ZMALLOC_H
@ -26,6 +19,9 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#define NUM_ZBUCKETS 256
#define GET_ZBUCKET(addr) (((int)(addr) >> 3) & 0xFF)
//#define NO_MEMORY_PADDING //#define NO_MEMORY_PADDING
#ifndef NO_MEMORY_PADDING #ifndef NO_MEMORY_PADDING
@ -47,7 +43,7 @@ typedef struct meminfo {
int line; /* line in the code where malloc was called */ int line; /* line in the code where malloc was called */
} meminfo; } meminfo;
static meminfo *memlist = NULL; static meminfo *memlist[NUM_ZBUCKETS];
/* /*
* 0 = only end summary * 0 = only end summary
@ -69,7 +65,13 @@ void pad_check(meminfo *m);
void zmalloc_free_list(meminfo *m); void zmalloc_free_list(meminfo *m);
void zmalloc_init(void) { void zmalloc_init(void)
{
int i;
for (i = 0; i < NUM_ZBUCKETS; i++)
memlist[i] = NULL;
zfd = fopen("zmalloc.log","w+"); zfd = fopen("zmalloc.log","w+");
} }
@ -146,18 +148,18 @@ unsigned char *zmalloc(int len, char *file, int line)
return NULL; return NULL;
} }
m->line = line; m->line = line;
m->next = memlist; m->next = memlist[GET_ZBUCKET(ret)];
memlist = m; memlist[GET_ZBUCKET(ret)] = m;
return (ret); return (ret);
} }
unsigned char *zrealloc(unsigned char *what, int len, char *file, int line) unsigned char *zrealloc(unsigned char *what, int len, char *file, int line)
{ {
unsigned char *ret; unsigned char *ret;
meminfo *m; meminfo *m, *prev_m;
if (what) { if (what) {
for (m = memlist; m; m = m->next) { for (prev_m = NULL, m = memlist[GET_ZBUCKET(what)]; m; prev_m = m, m = m->next) {
if (m->addr == what) { if (m->addr == what) {
#ifndef NO_MEMORY_PADDING #ifndef NO_MEMORY_PADDING
ret = (unsigned char *) realloc(what - sizeof(beginPad), len + sizeof(beginPad) + sizeof(endPad)); ret = (unsigned char *) realloc(what - sizeof(beginPad), len + sizeof(beginPad) + sizeof(endPad));
@ -186,6 +188,17 @@ unsigned char *zrealloc(unsigned char *what, int len, char *file, int line)
if (m->file) free(m->file); if (m->file) free(m->file);
m->file = strdup(file); m->file = strdup(file);
m->line = line; m->line = line;
/* detach node */
if (prev_m)
prev_m->next = m->next;
else
memlist[GET_ZBUCKET(what)] = m->next;
/* readd to proper bucket */
m->next = memlist[GET_ZBUCKET(ret)];
memlist[GET_ZBUCKET(ret)] = m;
/* could continue the loop to check for multiply-allocd memory */ /* could continue the loop to check for multiply-allocd memory */
/* but that's highly improbable so lets just return instead. */ /* but that's highly improbable so lets just return instead. */
return (ret); return (ret);
@ -212,7 +225,7 @@ void zfree(unsigned char *what, char *file, int line)
} }
/* look up allocated mem in list: */ /* look up allocated mem in list: */
for (m = memlist; m; m = m->next) { for (m = memlist[GET_ZBUCKET(what)]; m; m = m->next) {
if (m->addr == what) { if (m->addr == what) {
/* got it. Print it if verbose: */ /* got it. Print it if verbose: */
if (zmalloclogging > 2) { if (zmalloclogging > 2) {
@ -268,26 +281,36 @@ char *zstrdup(const char *src, char *file, int line)
void zmalloc_check() void zmalloc_check()
{ {
meminfo *m; meminfo *m, *next_m;
char *admonishemnt; char *admonishemnt;
int total_leak = 0; int total_leak = 0, num_leaks = 0, i;
int num_leaks = 0;
fprintf(zfd, "\n------------ Checking leaks ------------\n\n"); fprintf(zfd, "\n------------ Checking leaks ------------\n\n");
/* look up allocated mem in list: */
for(m = memlist; m; m = m->next) { for (i = 0; i < NUM_ZBUCKETS; i++) {
if (m->addr != 0 && m->frees <= 0) { for (m = memlist[i]; m; m = next_m) {
fprintf(zfd,"zmalloc: UNfreed memory 0x%4.4x %d bytes mallocd at %s:%d\n", next_m = m->next;
if (m->addr != 0 && m->frees <= 0) {
fprintf(zfd,"zmalloc: UNfreed memory 0x%4.4x %d bytes mallocd at %s:%d\n",
(int)m->addr, m->size, m->file, m->line); (int)m->addr, m->size, m->file, m->line);
if (zmalloclogging > 1) zdump(m); if (zmalloclogging > 1) zdump(m);
/* check padding on un-freed memory too: */ /* check padding on un-freed memory too: */
pad_check(m); pad_check(m);
total_leak += m->size; total_leak += m->size;
num_leaks++; num_leaks++;
}
#ifndef NO_MEMORY_PADDING
if (m->addr) free(m->addr - sizeof(beginPad));
#else
if (m->addr) free(m->addr);
#endif
if (m->file) free(m->file);
free(m);
} }
} }
if (total_leak) { if (total_leak) {
if (total_leak > 10000) if (total_leak > 10000)
admonishemnt = "you must work for Microsoft."; admonishemnt = "you must work for Microsoft.";
@ -306,9 +329,6 @@ void zmalloc_check()
fprintf(zfd,"zmalloc: Congratulations: leak-free code!\n"); fprintf(zfd,"zmalloc: Congratulations: leak-free code!\n");
} }
/* free up our own internal list */
zmalloc_free_list(memlist);
if (zfd) { if (zfd) {
fflush(zfd); fflush(zfd);
fclose(zfd); fclose(zfd);
@ -331,22 +351,6 @@ void pad_check(meminfo *m)
} }
void zmalloc_free_list(meminfo *m)
{
meminfo *next_m;
for (; m; m = next_m) {
next_m = m->next;
#ifndef NO_MEMORY_PADDING
if (m->addr) free(m->addr - sizeof(beginPad));
#else
if (m->addr) free(m->addr);
#endif
if (m->file) free(m->file);
free(m);
}
}
#ifdef ZTEST #ifdef ZTEST
#undef ZMALLOC_H #undef ZMALLOC_H

View file

@ -1,16 +1,9 @@
/************************************************************************** /**************************************************************************
* File: zmalloc.h Part of tbaMUD * * File: zmalloc.h Part of tbaMUD *
* Usage: A simple memory allocation monitor, header. * * Usage: A simple memory allocation monitor, header. *
* * * *
* Version 1.1 Copyright 1996, 1998, 1999, 2000 Eric Murray. * * Version 1.1 Copyright 1996, 1998, 1999, 2000 Eric Murray ericm@lne.com *
**************************************************************************/ **************************************************************************/
/*
** Zmalloc, a simple memory-allocation monitor.
**
** Copyright 1996 Eric Murray, ericm@lne.com
** You may make free use of this code but please give me credit.
** Documentation: http://www.lne.com/ericm/zmalloc
*/
#ifndef ZMALLOC_H #ifndef ZMALLOC_H
#define ZMALLOC_H #define ZMALLOC_H