I'm back OBCircle: The time I've been gone from this list has not gone to waste. This code release is hopefully one of many from the DarkStar codebase. This one is in response to the previously posted ferry code (Snippets page) that I spent hours trying to implement (So sue me, I was lazy and didn't want to rewrite it then :) ) I then had a chat with my lead programmer, and we rewrote the code so that it worked. Anyways, for your viewing pleasure, ferry.c: /*************************************************************************** * ferry.c Added to CircleMUD * * * * Base Programming: Shadowbeam of Darkstar: The Knight of Darkness * * Bug Fixes: Fili of Darkstar: The Knight of Darkness * * (DARKSTAR: telnet://mdarkstar.ml.org:7007, http://mdarkstar.home.ml.org) * ***************************************************************************/ #include "conf.h" #include "sysdep.h" #include "structs.h" #include "utils.h" #include "comm.h" #include "db.h" #define F_FROM_ROOM 1000 #define FERRY_ROOM 1333 #define FERRY_TO FERRY_ROOM #define F_TO_ROOM 6006 #define F_FROM_TO F_TO_ROOM #define F_FROM_ROOM_DIR_FROM_ROOM WEST #define F_FROM_ROOM_DIR_FROM_FERRY EAST #define F_TO_ROOM_DIR_FROM_ROOM EAST #define F_TO_ROOM_DIR_FROM_FERRY WEST #define F_TIME_ARRIVE_FROM_ROOM 6 #define F_TIME_LEAVE_FROM_ROOM 12 #define F_TIME_ARRIVE_TO_ROOM 18 #define F_TIME_LEAVE_TO_ROOM 23 #define F_to_ROOM F_TO_ROOM #define F_FROM_TO_DIR_FROM_ROOM F_TO_ROOM_DIR_FROM_ROOM #define F_ROOM_DIR_FROM_ROOM F_FROM_ROOM_DIR_FROM_ROOM extern struct room_data *world; extern struct time_info_data time_info; int op_dirs[6] = {2, 3, 0, 1, 5, 4}; void create_exit(int vnum_from, int vnum_to, int from_dir) { CREATE(world[real_room(vnum_from)].dir_option[from_dir], struct room_direction_data, 1); world[real_room(vnum_from)].dir_option[from_dir]->to_room = real_room(vnum_to); } void remove_exit(int vnum_from, int vnum_to, int from_dir) { free(world[vnum_from].dir_option[from_dir]); } void update_ferry(void) { if(time_info.hours == F_TIME_ARRIVE_FROM_ROOM){ create_exit(F_FROM_ROOM, FERRY_ROOM, F_FROM_ROOM_DIR_FROM_ROOM); create_exit(FERRY_ROOM, F_FROM_ROOM, F_FROM_ROOM_DIR_FROM_FERRY); } if(time_info.hours == F_TIME_ARRIVE_TO_ROOM){ create_exit(F_TO_ROOM, FERRY_TO, F_TO_ROOM_DIR_FROM_ROOM); create_exit(FERRY_TO, F_TO_ROOM, F_TO_ROOM_DIR_FROM_FERRY); } if(time_info.hours == F_TIME_LEAVE_FROM_ROOM){ remove_exit(F_FROM_ROOM, FERRY_ROOM, F_FROM_ROOM_DIR_FROM_ROOM); remove_exit(FERRY_ROOM, F_FROM_ROOM, F_FROM_ROOM_DIR_FROM_FERRY); } if(time_info.hours == F_TIME_LEAVE_TO_ROOM){ remove_exit(F_TO_ROOM, FERRY_ROOM, F_TO_ROOM_DIR_FROM_ROOM); remove_exit(FERRY_ROOM, F_TO_ROOM, F_TO_ROOM_DIR_FROM_FERRY); } return 1; } In comm.c, in void heartbeat: AFTER: if (!(pulse % (SECS_PER_MUD_HOUR * PASSES_PER_SEC))) { weather_and_time(1); affect_update(); point_update(); fflush(player_fl); ADD: update_ferry(); Note: This is release 1 of this code, release 2 is on the way. In release 2 messages will be put in as well as support for multiple ferries and other room-based events. Fili +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST