On Sat, 27 Jan 2001, Brian Hartvigsen wrote:
> What about doing it similar to a mount patch? An IN_VEH(ch) check and
> VER_ID(ch) to see if characters are in the same vehicle. It would
> require that you only have 1 of each Vehicle ID but it would stop the
> problem of people in other vehicles. This would also keep you from
> having to extract them from the world list.
If IN_VEH(ch) is a pointer to the vehicle they're in, then IN_VEH(ch) can
have (a) a 'people' linked list -- you would need, however, a
next_in_vehicle pointer on the character, or make the object duplicate the
room code wherever necessary [at that point, it'd be better to just use a
separate room], or (b) be compared against another IN_VEH(ch) pointer to
see if the person is in the same room.
A better solution might be to create a special room, vehicle_room, where
anyone in a vehicle anywhere is placed, and setup a spec_proc on it to
catch all of the room-based commands. You can then either handle them
specially, or move the player to IN_VEH(ch)->in_room, execute the command,
and move them back.
SPECIAL(vehicles)
{
char buf[MAX_STRING_LENGTH];
char arg[MAX_INPUT_LENGTH];
struct char_data *ich;
if (CMD_IS("look")) {
if (AFF_FLAGGED(ch, AFF_BLIND))
return (FALSE);
one_argument(argument, arg);
if (!str_cmp(arg, "out")) {
act("You look out of $p . . .", FALSE, ch, IN_VEH(ch), 0, TO_CHAR);
return (FALSE);
}
send_to_char(CCCYN(ch, C_NRM), ch);
act("Inside of $p", FALSE, ch, IN_VEH(ch), 0, TO_CHAR);
send_to_char(CCNRM(ch, C_NRM), ch);
for (ich = ch->in_room->people; ich; ich = ich->next_in_room)
if (ich != ch && IN_VEH(ich) == IN_VEH(ch) && CAN_SEE(ich))
list_one_char(ich, ch);
list_obj_to_char(obj->contains, ch, 2, TRUE);
return (TRUE);
} else if (CMD_IS("drop")) {
/* drop adds it to the vehicle's contains rather than to the
* room. */
} else if (CMD_IS("get")) {
/* from the rooms contains */
} else if (...)
.
.
.
}
You get the idea. That leaves the code nicely encapsulated and general.
-dak
--
+---------------------------------------------------------------+
| FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
| Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
+---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/03/01 PST