dw_fluffos_v2/
dw_fluffos_v2/fluffos-2.9-ds2.05/
dw_fluffos_v2/fluffos-2.9-ds2.05/ChangeLog.old/
dw_fluffos_v2/fluffos-2.9-ds2.05/Win32/
dw_fluffos_v2/fluffos-2.9-ds2.05/compat/
dw_fluffos_v2/fluffos-2.9-ds2.05/compat/simuls/
dw_fluffos_v2/fluffos-2.9-ds2.05/include/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/clone/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/command/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/data/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/etc/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/include/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/inherit/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/inherit/master/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/log/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/single/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/single/tests/compiler/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/single/tests/efuns/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/single/tests/operators/
dw_fluffos_v2/fluffos-2.9-ds2.05/testsuite/u/
dw_fluffos_v2/fluffos-2.9-ds2.05/tmp/
dw_fluffos_v2/fluffos-2.9-ds2.05/windows/
dw_fluffos_v2/lib/
dw_fluffos_v2/lib/binaries/cmds/
dw_fluffos_v2/lib/binaries/cmds/creator/
dw_fluffos_v2/lib/binaries/cmds/living/
dw_fluffos_v2/lib/binaries/cmds/player/
dw_fluffos_v2/lib/binaries/d/admin/obj/
dw_fluffos_v2/lib/binaries/d/liaison/
dw_fluffos_v2/lib/binaries/global/virtual/
dw_fluffos_v2/lib/binaries/global/virtual/setup_compiler/
dw_fluffos_v2/lib/binaries/obj/handlers/autodoc/
dw_fluffos_v2/lib/binaries/obj/handlers/terrain_things/
dw_fluffos_v2/lib/binaries/obj/misc/
dw_fluffos_v2/lib/binaries/obj/misc/buckets/
dw_fluffos_v2/lib/binaries/obj/monster/
dw_fluffos_v2/lib/binaries/obj/reactions/
dw_fluffos_v2/lib/binaries/obj/reagents/
dw_fluffos_v2/lib/binaries/secure/cmds/creator/
dw_fluffos_v2/lib/binaries/secure/master/
dw_fluffos_v2/lib/binaries/std/
dw_fluffos_v2/lib/binaries/std/dom/
dw_fluffos_v2/lib/binaries/std/effects/object/
dw_fluffos_v2/lib/binaries/std/guilds/
dw_fluffos_v2/lib/binaries/std/languages/
dw_fluffos_v2/lib/binaries/std/races/
dw_fluffos_v2/lib/binaries/std/room/
dw_fluffos_v2/lib/binaries/std/room/basic/
dw_fluffos_v2/lib/binaries/std/shops/
dw_fluffos_v2/lib/binaries/std/shops/inherit/
dw_fluffos_v2/lib/binaries/www/
dw_fluffos_v2/lib/cmds/guild-race/
dw_fluffos_v2/lib/cmds/guild-race/crafts/
dw_fluffos_v2/lib/cmds/guild-race/other/
dw_fluffos_v2/lib/cmds/playtester/
dw_fluffos_v2/lib/cmds/playtester/senior/
dw_fluffos_v2/lib/d/admin/
dw_fluffos_v2/lib/d/admin/log/
dw_fluffos_v2/lib/d/admin/mapper/31-10-01/mapmaker/event/
dw_fluffos_v2/lib/d/admin/meetings/
dw_fluffos_v2/lib/d/admin/obj/
dw_fluffos_v2/lib/d/admin/room/we_care/
dw_fluffos_v2/lib/d/admin/save/
dw_fluffos_v2/lib/d/dist/
dw_fluffos_v2/lib/d/dist/mtf/
dw_fluffos_v2/lib/d/dist/pumpkin/
dw_fluffos_v2/lib/d/dist/pumpkin/chars/
dw_fluffos_v2/lib/d/dist/pumpkin/desert/
dw_fluffos_v2/lib/d/dist/pumpkin/gumboot/
dw_fluffos_v2/lib/d/dist/pumpkin/hospital/
dw_fluffos_v2/lib/d/dist/pumpkin/inherit/
dw_fluffos_v2/lib/d/dist/pumpkin/map/
dw_fluffos_v2/lib/d/dist/pumpkin/plain/
dw_fluffos_v2/lib/d/dist/pumpkin/pumpkin/
dw_fluffos_v2/lib/d/dist/pumpkin/save/
dw_fluffos_v2/lib/d/dist/pumpkin/squash/
dw_fluffos_v2/lib/d/dist/pumpkin/terrain/
dw_fluffos_v2/lib/d/dist/pumpkin/woods/
dw_fluffos_v2/lib/d/dist/start/
dw_fluffos_v2/lib/d/learning/TinyTown/buildings/
dw_fluffos_v2/lib/d/learning/TinyTown/map/
dw_fluffos_v2/lib/d/learning/TinyTown/roads/
dw_fluffos_v2/lib/d/learning/add_command/
dw_fluffos_v2/lib/d/learning/arms_and_weps/
dw_fluffos_v2/lib/d/learning/chars/
dw_fluffos_v2/lib/d/learning/cutnpaste/
dw_fluffos_v2/lib/d/learning/examples/npcs/
dw_fluffos_v2/lib/d/learning/examples/player_houses/npcs/
dw_fluffos_v2/lib/d/learning/examples/terrain_map/basic/
dw_fluffos_v2/lib/d/learning/functions/
dw_fluffos_v2/lib/d/learning/handlers/
dw_fluffos_v2/lib/d/learning/help_topics/npcs/
dw_fluffos_v2/lib/d/learning/help_topics/objects/
dw_fluffos_v2/lib/d/learning/help_topics/rcs_demo/
dw_fluffos_v2/lib/d/learning/help_topics/rooms/
dw_fluffos_v2/lib/d/learning/help_topics/rooms/crowd/
dw_fluffos_v2/lib/d/learning/help_topics/rooms/situations/
dw_fluffos_v2/lib/d/learning/items/
dw_fluffos_v2/lib/d/learning/save/
dw_fluffos_v2/lib/d/liaison/
dw_fluffos_v2/lib/d/liaison/NEWBIE/doc/
dw_fluffos_v2/lib/d/liaison/NEWBIE/save/oldlog/
dw_fluffos_v2/lib/db/
dw_fluffos_v2/lib/doc/
dw_fluffos_v2/lib/doc/creator/
dw_fluffos_v2/lib/doc/creator/autodoc/include/reaction/
dw_fluffos_v2/lib/doc/creator/autodoc/include/ritual_system/
dw_fluffos_v2/lib/doc/creator/autodoc/include/talker/
dw_fluffos_v2/lib/doc/creator/autodoc/include/terrain_map/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/baggage/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/clock/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/clothing/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/cont_save/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/corpse/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/money/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/monster/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/scabbard/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/service_provider/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/state_changer/
dw_fluffos_v2/lib/doc/creator/autodoc/obj/wand/
dw_fluffos_v2/lib/doc/creator/autodoc/std/book_dir/
dw_fluffos_v2/lib/doc/creator/autodoc/std/key/
dw_fluffos_v2/lib/doc/creator/autodoc/std/learning/
dw_fluffos_v2/lib/doc/creator/autodoc/std/map/
dw_fluffos_v2/lib/doc/creator/autodoc/std/race/
dw_fluffos_v2/lib/doc/creator/autodoc/std/weapon_logic/
dw_fluffos_v2/lib/doc/creator/files/
dw_fluffos_v2/lib/doc/creator/policy/
dw_fluffos_v2/lib/doc/creator/room/
dw_fluffos_v2/lib/doc/effects/
dw_fluffos_v2/lib/doc/ideas/
dw_fluffos_v2/lib/doc/known_command/
dw_fluffos_v2/lib/doc/lpc/basic_manual/
dw_fluffos_v2/lib/doc/lpc/intermediate/
dw_fluffos_v2/lib/doc/new/add_command/
dw_fluffos_v2/lib/doc/new/handlers/
dw_fluffos_v2/lib/doc/new/living/
dw_fluffos_v2/lib/doc/new/living/race/
dw_fluffos_v2/lib/doc/new/living/spells/
dw_fluffos_v2/lib/doc/new/player/
dw_fluffos_v2/lib/doc/new/room/guild/
dw_fluffos_v2/lib/doc/new/room/outside/
dw_fluffos_v2/lib/doc/new/room/storeroom/
dw_fluffos_v2/lib/doc/object/
dw_fluffos_v2/lib/doc/playtesters/
dw_fluffos_v2/lib/doc/policy/
dw_fluffos_v2/lib/doc/weapons/
dw_fluffos_v2/lib/global/handlers/
dw_fluffos_v2/lib/global/virtual/setup_compiler/
dw_fluffos_v2/lib/include/
dw_fluffos_v2/lib/include/cmds/
dw_fluffos_v2/lib/include/effects/
dw_fluffos_v2/lib/include/npc/
dw_fluffos_v2/lib/include/shops/
dw_fluffos_v2/lib/net/daemon/chars/
dw_fluffos_v2/lib/net/inherit/
dw_fluffos_v2/lib/net/intermud3/
dw_fluffos_v2/lib/net/intermud3/services/
dw_fluffos_v2/lib/net/obj/
dw_fluffos_v2/lib/net/save/
dw_fluffos_v2/lib/net/smnmp/
dw_fluffos_v2/lib/net/snmp/
dw_fluffos_v2/lib/obj/amulets/
dw_fluffos_v2/lib/obj/b_day/
dw_fluffos_v2/lib/obj/examples/
dw_fluffos_v2/lib/obj/food/alcohol/
dw_fluffos_v2/lib/obj/food/chocolates/
dw_fluffos_v2/lib/obj/food/fruits/
dw_fluffos_v2/lib/obj/food/meat/
dw_fluffos_v2/lib/obj/food/nuts/
dw_fluffos_v2/lib/obj/food/seafood/
dw_fluffos_v2/lib/obj/food/vegetables/
dw_fluffos_v2/lib/obj/fungi/
dw_fluffos_v2/lib/obj/furnitures/artwork/
dw_fluffos_v2/lib/obj/furnitures/bathroom/
dw_fluffos_v2/lib/obj/furnitures/beds/
dw_fluffos_v2/lib/obj/furnitures/cabinets/
dw_fluffos_v2/lib/obj/furnitures/chairs/
dw_fluffos_v2/lib/obj/furnitures/chests/
dw_fluffos_v2/lib/obj/furnitures/clocks/
dw_fluffos_v2/lib/obj/furnitures/crockery/
dw_fluffos_v2/lib/obj/furnitures/cupboards/
dw_fluffos_v2/lib/obj/furnitures/cushions/
dw_fluffos_v2/lib/obj/furnitures/fake_plants/
dw_fluffos_v2/lib/obj/furnitures/lamps/
dw_fluffos_v2/lib/obj/furnitures/mirrors/
dw_fluffos_v2/lib/obj/furnitures/outdoor/
dw_fluffos_v2/lib/obj/furnitures/safes/
dw_fluffos_v2/lib/obj/furnitures/shelves/
dw_fluffos_v2/lib/obj/furnitures/sideboards/
dw_fluffos_v2/lib/obj/furnitures/sofas/
dw_fluffos_v2/lib/obj/furnitures/stoves/
dw_fluffos_v2/lib/obj/furnitures/tables/
dw_fluffos_v2/lib/obj/furnitures/wardrobes/
dw_fluffos_v2/lib/obj/handlers/
dw_fluffos_v2/lib/obj/handlers/autodoc/
dw_fluffos_v2/lib/obj/jewellery/anklets/
dw_fluffos_v2/lib/obj/jewellery/bracelets/
dw_fluffos_v2/lib/obj/jewellery/earrings/
dw_fluffos_v2/lib/obj/jewellery/misc/
dw_fluffos_v2/lib/obj/jewellery/necklaces/
dw_fluffos_v2/lib/obj/jewellery/rings/
dw_fluffos_v2/lib/obj/media/
dw_fluffos_v2/lib/obj/misc/buckets/
dw_fluffos_v2/lib/obj/misc/jars/
dw_fluffos_v2/lib/obj/misc/papers/
dw_fluffos_v2/lib/obj/misc/player_shop/
dw_fluffos_v2/lib/obj/misc/shops/
dw_fluffos_v2/lib/obj/misc/traps/
dw_fluffos_v2/lib/obj/monster/
dw_fluffos_v2/lib/obj/monster/godmother/
dw_fluffos_v2/lib/obj/monster/transport/
dw_fluffos_v2/lib/obj/plants/inherit/
dw_fluffos_v2/lib/obj/potions/
dw_fluffos_v2/lib/open/boards/
dw_fluffos_v2/lib/save/autodoc/
dw_fluffos_v2/lib/save/bank_accounts/
dw_fluffos_v2/lib/save/boards/frog/
dw_fluffos_v2/lib/save/books/bed_catalog/
dw_fluffos_v2/lib/save/creators/
dw_fluffos_v2/lib/save/mail/
dw_fluffos_v2/lib/save/mail/p/
dw_fluffos_v2/lib/save/soul/data/
dw_fluffos_v2/lib/save/tasks/
dw_fluffos_v2/lib/save/vaults/
dw_fluffos_v2/lib/secure/cmds/lord/
dw_fluffos_v2/lib/secure/config/
dw_fluffos_v2/lib/secure/items/
dw_fluffos_v2/lib/secure/player/
dw_fluffos_v2/lib/soul/
dw_fluffos_v2/lib/soul/i/
dw_fluffos_v2/lib/soul/j/
dw_fluffos_v2/lib/soul/k/
dw_fluffos_v2/lib/soul/o/
dw_fluffos_v2/lib/soul/q/
dw_fluffos_v2/lib/soul/to_approve/
dw_fluffos_v2/lib/soul/u/
dw_fluffos_v2/lib/soul/v/
dw_fluffos_v2/lib/soul/wish_list/
dw_fluffos_v2/lib/soul/y/
dw_fluffos_v2/lib/soul/z/
dw_fluffos_v2/lib/std/creator/
dw_fluffos_v2/lib/std/effects/
dw_fluffos_v2/lib/std/effects/attached/
dw_fluffos_v2/lib/std/effects/external/
dw_fluffos_v2/lib/std/effects/fighting/
dw_fluffos_v2/lib/std/effects/other/
dw_fluffos_v2/lib/std/environ/
dw_fluffos_v2/lib/std/guilds/
dw_fluffos_v2/lib/std/hospital/
dw_fluffos_v2/lib/std/house/
dw_fluffos_v2/lib/std/house/onebedhouse/
dw_fluffos_v2/lib/std/house/onebedhut/
dw_fluffos_v2/lib/std/house/tworoomflat/
dw_fluffos_v2/lib/std/languages/
dw_fluffos_v2/lib/std/liquids/
dw_fluffos_v2/lib/std/nationality/
dw_fluffos_v2/lib/std/nationality/accents/
dw_fluffos_v2/lib/std/nationality/accents/national/
dw_fluffos_v2/lib/std/nationality/accents/regional/
dw_fluffos_v2/lib/std/npc/goals/
dw_fluffos_v2/lib/std/npc/goals/basic/
dw_fluffos_v2/lib/std/npc/goals/misc/
dw_fluffos_v2/lib/std/npc/inherit/
dw_fluffos_v2/lib/std/npc/plans/
dw_fluffos_v2/lib/std/npc/plans/basic/
dw_fluffos_v2/lib/std/outsides/
dw_fluffos_v2/lib/std/races/shadows/
dw_fluffos_v2/lib/std/room/basic/topography/
dw_fluffos_v2/lib/std/room/controller/
dw_fluffos_v2/lib/std/room/controller/topography/
dw_fluffos_v2/lib/std/room/furniture/games/
dw_fluffos_v2/lib/std/room/furniture/inherit/
dw_fluffos_v2/lib/std/room/inherit/carriage/
dw_fluffos_v2/lib/std/room/inherit/topography/
dw_fluffos_v2/lib/std/room/punishments/
dw_fluffos_v2/lib/std/room/topography/area/
dw_fluffos_v2/lib/std/room/topography/iroom/
dw_fluffos_v2/lib/std/room/topography/milestone/
dw_fluffos_v2/lib/std/shadows/
dw_fluffos_v2/lib/std/shadows/attached/
dw_fluffos_v2/lib/std/shadows/curses/
dw_fluffos_v2/lib/std/shadows/disease/
dw_fluffos_v2/lib/std/shadows/fighting/
dw_fluffos_v2/lib/std/shadows/room/
dw_fluffos_v2/lib/std/shops/controllers/
dw_fluffos_v2/lib/std/shops/objs/
dw_fluffos_v2/lib/std/shops/player_shop/
dw_fluffos_v2/lib/std/shops/player_shop/office_code/
dw_fluffos_v2/lib/std/socket/
dw_fluffos_v2/lib/www/
dw_fluffos_v2/lib/www/external/autodoc/
dw_fluffos_v2/lib/www/external/java/telnet/Documentation/
dw_fluffos_v2/lib/www/external/java/telnet/Documentation/images/
dw_fluffos_v2/lib/www/external/java/telnet/examples/
dw_fluffos_v2/lib/www/external/java/telnet/tools/
dw_fluffos_v2/lib/www/pics/
dw_fluffos_v2/lib/www/secure/creator/
dw_fluffos_v2/lib/www/secure/editors/
dw_fluffos_v2/lib/www/secure/survey_results/
dw_fluffos_v2/win32/
/**
 * This handler object deals with all the books that have been published.
 * It keeps a save file of every book and a current book number.
 * It will allow for easy finding again of preprinted books and for the
 * easy removal of any books that happen to contain things like quest
 * solutions and stuff.
 *
 * @author Pinkfish
 * @started Sun Feb  1 20:24:33 CST 1998
 * @see /std/book.c
 * @see /std/print_shop.c
 */

#include <book_handler.h>
#include <language.h>

#define SAVE_DIR "/save/book_handler/"
#define SAVE_FILE (SAVE_DIR "main_save")

#define OWNER_INDEX "owner"
#define PAGES_INDEX "pages"

int current_book_number;
mapping banished_books;

int compare_page(object page1, object page2);
void load_it();
void save_it();
int check_book_same(object book, int num);
protected string *query_pages(object book);
int compare_pages(string *pages1, string *pages2);
string *query_book_pages(int book_num);

void create() {
   banished_books = ([ ]);
   seteuid(getuid());
   load_it();
} /* create() */

/**
 * This tests to see if the given book number exists.
 * @param book_num the number to test.
 * @return 1 if it exists, 0 if it does not.
 */
int query_book_exists(int book_num) {
   return unguarded((: file_size(SAVE_DIR + $(book_num) + ".o") :)) > 0;
} /* query_book_exists() */

/**
 * Adds a newly minted book into our nice list of stuff.  This returns the
 * book number for this book.  You can use this to add a book if you already
 * know its book number, if it does not match to the saved book number then
 * it will return a new number.  If it does match it will return the
 * same number.
 * @param book the book to add
 * @param num the possible book number it already has
 * @see check_book_same()
 */
int add_book(object book, int num, string pl_name) {
   string *stuff;
   mapping bing;

   if (num) {
      if (check_book_same(book, num)) {
         return num;
      }
   }

   /* Make sure if the save file gets stuffed up we don't overwrite things. */
   while (query_book_exists(current_book_number)) {
      current_book_number++;
   }
   stuff = query_pages(book);
   bing = ([ OWNER_INDEX : pl_name, PAGES_INDEX : stuff ]);
   unguarded( (: write_file(SAVE_DIR + current_book_number + ".o",
              save_variable($(bing))) :) );
   num = current_book_number++;
   save_it();
   return num;
} /* add_book() */

/**
 * Checks to see if the passed in book is the same as the current book
 * number that is set on it.  We only look at the text and ignore the
 * type and language with which it is written.
 * @param book the book to check
 * @param num the book number to check against
 * @see compare_pages()
 * @see add_book()
 */
int check_book_same(object book, int num) {
   string *bing;
   string *fluff;
   int old_open_page;
   int same;

   old_open_page = book->query_open_page();
   same = 0;
   if (query_book_exists(num) > 0) {
      bing = query_book_pages(num);
      fluff = query_pages(book);
      if (compare_pages(bing, fluff) > 90) {
         same = 1;
      }
   } else {
      same = 0;
   }
   book->set_open_page(old_open_page);
   return same;
} /* check_book_same() */

/**
 * This method returns the pages associated with the book of a given
 * number.
 * @return the pages for the book
 * @param book_num the book number to get the pages for
 * @see query_book_owner()
 */
string *query_book_pages(int book_num) {
   mapping bing;
   string tmp;

   tmp = unguarded((: read_file(SAVE_DIR + $(book_num) + ".o") :));
   if (tmp) {
      bing = restore_variable(tmp);
      return bing[PAGES_INDEX];
   }
   return 0;
} /* query_book_pages() */

/**
 * This method returns the owner associated with the book of a given
 * number.
 * @return the owner of the book
 * @param book_num the book number to get the pages for
 * @see query_book_pages()
 */
string query_book_owner(int book_num) {
   mapping bing;
   string tmp;
 
   tmp = unguarded((: read_file(SAVE_DIR + $(book_num) + ".o") :));
   if (tmp) {
      bing = restore_variable(tmp);
      return bing[OWNER_INDEX];
   }
   return 0;
} /* query_book_owner() */

/**
 * This method returns the array of useful pages in a book.  It removes
 * torn out pages and pages which are added by specific things in the
 * game, like the print shop adding a fly leaf.  It just returns the text
 * for the pages, since this is what we are interested in.
 * @param book the book to get the pages from
 * @return the array of pages
 */
string *query_pages(object book) {
   int i;
   string *ret;
   mixed *stuff;
   mixed *group;
   string text;
   int old_open_page;
   object ob;

   ret = ({ });
   old_open_page = book->query_open_page();
   for (i = 0; i < book->query_num_pages(); i++) {
      book->set_open_page(i);
      ob = book->query_current_page();
      /* Make sure it is not torn out and that it is not auto generated. */
      if (!book->is_current_page_torn_out() &&
          !ob->query_property(BH_IGNORE_PAGE)) {
         stuff = ob->query_read_mess();
         text = "";
         foreach (group in stuff) {
            text += group[READ_MESS];
         }
         ret += ({ text  });
      }
   }
   book->set_open_page(old_open_page);
   return ret;
} /* query_pages() */

/**
 * This method will try and figure out the percentage changed between the
 * two page arrays.
 * @param pages1 the first page array
 * @param pages2 the second page array
 * @return the percentage the same
 */
int compare_pages(string *pages1, string *pages2) {
   int no_chars;
   int no_same;
   int pos;
   int start;
   string page;
   string *tmp;

   pos = 0;
   if (sizeof(pages1) > sizeof(pages2)) {
      tmp = pages1;
      pages1 = pages2;
      pages2 = tmp;
   }
   /* Now we go through the smaller array... */
   foreach (page in pages1) {
      /*
       * Ok, now see if we can find where this page might start in the
       * other book.
       *
       * We will assume that all books will start the same.  Therefor
       * if we cannot find a match for the first page...  The rest of the
       * book does not match.  We assume that the one stored in the
       * book handler is the complete one.
       */
      pos = 0;
      do {
         start = strsrch(page, pages2[pos]);
         if (start == -1) {
            start = strsrch(pages2[pos], page);
            if (start == -1) {
               pos++;
            } else {
               no_same += strlen(page);
            }
         } else {
            no_same += strlen(pages2[pos]);
         }
      } while ((start == -1) && (pos < sizeof(pages2)));
      no_chars += strlen(page);
   }

   /* Calculate the percentage the same and return it. */
   if (no_chars > 0) {
      return (no_same * 100) / no_chars;
   }
   return 0;
} /* compare_pages() */

/**
 * Compares the open pages of two books to see if the text is the
 * same.  It ignores language and style of writing.  This would also
 * work on two pieces of paper.
 * @param page1 the first book
 * @param page2 the second book
 * @see check_book_same()
 * @see add_book()
 */
int compare_page(string page1, string page2) {
   mixed *stuff1;
   mixed *stuff2;
   string text1;
   string text2;
   int i;

   stuff2 = page2->query_read_mess();
   text1 = "";
   for (i = 0; i < sizeof(stuff1); i++) {
      text1 += stuff1[READ_MESS];
   }

   text2 = "";
   for (i = 0; i < sizeof(stuff2); i++) {
      text2 += stuff2[READ_MESS];
   }

   return (text1 == text2);
} /* compare_page() */

/**
 * This method banishes a book number for a certain reason.
 * @param book_num the book number to banish
 * @param reason the reason it was banished
 * @return 1 on success and 0 on failure.
 * @see query_banished_book()
 * @see query_all_banished_books()
 */
int add_banished_book(int book_num, string reason) {
   if (!stringp(reason) || !intp(book_num)) {
      /* Need a reason. */
      return 0;
   }
   if (!query_book_exists(book_num)) {
      /* Does not exist. */
      return 0;
   }

   banished_books[book_num] = reason;
} /* banish_book_num() */

/**
 * This method returns the banish string for the book.
 * @param book_num the book number to check
 * @return the banish reason, or 0 if none
 * @see add_banished_book()
 * @see query_all_banished_books()
 */
string query_banished_book(int book_num) {
   return banished_books[book_num];
} /* query_banished_book() */

/**
 * This method returns all the banished books.  The keys are the
 * numbers which are banished and the values are the reason for
 * the banishment.
 * @return the banished books mapping
 * @see add_banished_book()
 * @see query_banished_book()
 */
mapping query_all_banished_books() {
   return banished_books;
} /* query_all_banished_books() */

/**
 * Saves the current state information to the save file.
 * @see save_it()
 */
void save_it() {
   unguarded((: save_object(SAVE_FILE) :));
} /* save_it() */

/**
 * Loads the state information from the save file.
 * @see load_it()
 */
void load_it() {
   unguarded((: restore_object(SAVE_FILE) :));
   if (!current_book_number) {
      current_book_number = 1;
   }
   if (!banished_books) {
      banished_books = ([ ]);
   }
} /* load_it() */