If for some reason you HAPPEN to send a vict_obj to act without also sending it an obj or ch pointer as well, it will puke with this error message in your syslog:
Quote:
SYSERR: no valid target to act()!
SYSERR: no valid target to act()!
Which isn't exactly 100% true since we've established that there is one valid target to act, but in a case that requires two of them.
My fix, in comm.c replace:
if (ch && IN_ROOM(ch) != NOWHERE)
to = world[IN_ROOM(ch)].people;
else if (obj && IN_ROOM(obj) != NOWHERE)
to = world[IN_ROOM(obj)].people;
else {
log("SYSERR: no valid target to act()!");
return;
}
With:
if (ch && IN_ROOM(ch) != NOWHERE)
to = world[IN_ROOM(ch)].people;
else if (obj && IN_ROOM(obj) != NOWHERE)
to = world[IN_ROOM(obj)].people;
else if (vict_obj && !ch && !obj) {
log("SYSERR: act() received vict_obj without a valid ch or obj");
return;
} else {
log("SYSERR: no valid target to act()!");
return;
}
Which simply returns a more descriptive error message. It still fails, though this could be coded around by finding out if vict_obj is a char or obj and going to = world[IN_ROOM(vict_obj)].people, however that seems messy and weird to me, since we really shouldn't have a victim without someone or something acting upon said victim.
The second item on today's agenda... keys. On several MUDs I have been on there has been a serious problem with people hoarding keys, especially ones that wont load again if they're in game. This is how I've solved this issue. Also, I would note that I have no idea if the tbaMUD codebase has already implemented something to solve this issue, however I feel my solution is far more elegant than other solutions I've seen... such as dissolving the key on use which is annoying if you need the same key for multiple things. Feedback appreciated, but pointless criticism isn't.
in db.c reset_zone():
In variable declarations add:
struct obj_data *key; /* For key purging */
Now, below the variable declarations add:
/* Purge all keys for this zone that are on a player or in a room */
for (key = object_list; key; key = key->next) {
if (GET_OBJ_TYPE(key) == ITEM_KEY && GET_OBJ_VNUM(key) >= zone_table[zone].bot && GET_OBJ_VNUM(key) <= zone_table[zone].top) {
if (key->in_room && !key->carried_by && !key->worn_by && !key->in_obj) /* Purge a key from a room */
act("$P dissolves into nothingness.", TRUE, NULL, key, NULL, TO_ROOM);
if (key->carried_by && !IS_NPC(key->carried_by)) /* Purge a carried key */
act("$p dissolves into nothingness.", TRUE, key->carried_by, key, NULL, TO_CHAR);
if (key->worn_by && !IS_NPC(key->worn_by)) /* Purge a worn key */
act("$p dissolves into nothingness.", TRUE, key->worn_by, key, NULL, TO_CHAR);
if (key->in_obj) { /* Purge a key from inside another obj */
for (obj = key->in_obj; obj->in_obj == NULL; obj = obj->in_obj) {} /* Get to the top of the container tree... */
if (obj->in_room)
act("$p dissolves into nothingness.", TRUE, NULL, key, NULL, TO_ROOM);
if (obj->carried_by && !IS_NPC(obj->carried_by))
act("$p dissolves into nothingness.", TRUE, obj->carried_by, key, NULL, TO_CHAR);
if (obj->worn_by && !IS_NPC(obj->worn_by))
act("$p dissolves into nothingness.", TRUE, obj->worn_by, key, NULL, TO_CHAR);
}
extract_obj(key);
}
}


