Ferry Code Update

From: Fili (cybom@NETROPOLIS.NET)
Date: 12/18/97


Here is an update to my nice little ferry code :) This one has 2 main
updates:

1 - Recreate support added, should fix crashbug
2 - Addition of messaging to ferry rooms and dock rooms

Anyways, begin code:


/***************************************************************************

* ferry.c                                               Added to
CircleMUD *
*   V.
1.1                                                                 *
* 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 // One of the dock rooms
#define FERRY_ROOM                  1333 // The room of the ferry
#define F_TO_ROOM                   6006 // The second dock room
#define F_FROM_ROOM_DIR_FROM_ROOM   WEST // F_FROM_ROOM Exit to ferry
#define F_FROM_ROOM_DIR_FROM_FERRY  EAST // Exit from ferry to
F_FROM_ROOM
#define F_TO_ROOM_DIR_FROM_ROOM     EAST // F_TO_ROOM Exit to ferry
#define F_TO_ROOM_DIR_FROM_FERRY    WEST // Exit from ferry to
F_FROM_ROOM
#define F_TIME_ARRIVE_FROM_ROOM     6//Time ferry arrives from
F_FROM_ROOM
#define F_TIME_LEAVE_FROM_ROOM      12//Time ferry leaves from
F_FROM_ROOM
#define F_TIME_ARRIVE_TO_ROOM       18 //Time ferry arrives from
F_TO_ROOM
#define F_TIME_LEAVE_TO_ROOM        23  //Time ferry leaves from
F_TO_ROOM


extern struct room_data *world;
extern struct time_info_data time_info;

int op_dirs[6] = {2, 3, 0, 1, 5, 4};
int created = FALSE;

void create_exit(int vnum_from, int vnum_to, int from_dir) {
 if(created == FALSE)
 {
 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);
 }
 else if(created == TRUE)
 {
 RECREATE(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);
 }
} // Or malloc? Who knows...

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);
      send_to_room("The ferry sails up and docks\r\n",
real_room(F_FROM_ROOM));
      send_to_room("The ferry sails up to the docks\r\n",
real_room(FERRY_ROOM));
 }

   if(time_info.hours == F_TIME_ARRIVE_TO_ROOM){
      create_exit(F_TO_ROOM, FERRY_ROOM, F_TO_ROOM_DIR_FROM_ROOM);
      create_exit(FERRY_ROOM, F_TO_ROOM, F_TO_ROOM_DIR_FROM_FERRY);
            send_to_room("The ferry sails up and docks\r\n",
real_room(F_FROM_ROOM));
      send_to_room("The ferry sails up to the docks\r\n",
real_room(FERRY_ROOM));
 }

   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);
      send_to_room("The ferry sails off into the distance\r\n",
real_room(F_FROM_ROOM));
      send_to_room("The ferry begins its voyage\r\n",
real_room(FERRY_ROOM));
 }

   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);
      send_to_room("The ferry sails off into the distance\r\n",
real_room(F_TO_ROOM));
      send_to_room("The ferry begins its voyage\r\n",
real_room(FERRY_ROOM));

      created = TRUE;
 }

   return;
}


     +------------------------------------------------------------+
     | 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