musicmud-2.1.6/data/
musicmud-2.1.6/data/help/
musicmud-2.1.6/data/policy/
musicmud-2.1.6/data/wild/
musicmud-2.1.6/data/world/
musicmud-2.1.6/doc/
musicmud-2.1.6/src/ident/
musicmud-2.1.6/src/lua/
musicmud-2.1.6/src/lua/include/
musicmud-2.1.6/src/lua/src/lib/
musicmud-2.1.6/src/lua/src/lua/
musicmud-2.1.6/src/lua/src/luac/
/*
 * MusicMUD Daemon, version 1.0
 * Copyright (C) 1998-2003 Abigail Brady
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#include <string.h>
#include <ctype.h>

#include "musicmud.h"
#include "misc.h"
#include "util.h"
#include "rooms.h"
#include "Player.h"
#include "events.h"
#include "trap.h"
#include "pflags.h"
#include "death.h"
#include "Mission.h"
#include "zoneload.h"
#include "msi.h"
#include "paths.h"
#include "privs.h"
#include "vsprintf.h"
#include "prep.h"
#include "units.h"
#include "shared.h"
#include "pos.h"
#include "levels.h"
#include "hooks.h"

void newplace(MudObject *player, MudObject *old_loc)
{
  MudObject *dest = player->owner;
  if (Player *p=dynamic_cast<Player*>(player)) {
    if (p->p && (p->p->mplex || p->p->mxp)) {
      if (old_loc && old_loc->get("lua.mplex")) {
	if (p->p->mxp)
	  p->printf("\3frame Sub CLOSE\4");
	else
	  p->p->mplex_hide(1);
      }
      if (dest && dest->get("lua.mplex")) {
	dotrap("mplex", player, dest);
	if (p->p->mplex)
	  p->p->mplex_show(1);
      }
    }
  }
}

void shipmsg(MudObject *ship, const char *fmt, PRINT_PARMS) 
{
  PARMS p = GET_PARMS();

  int roomcount = ship->array_size("room");

  MudObject *o;
  int l;
  foreach(ship->children, o, l) {
    o->real_printf(fmt, p);
  }
  
  for (int i=0;i<roomcount;i++) {
    MudObject *room = ship->array_get_object("room", i);
    if (room && room != ship) {
      MudObject *o;
      int l;
      foreach(room->children, o, l) {
	o->real_printf(fmt, p);
      }
    }
  }
}

const char *exit_rev(const char *what) {
  if (streq(what, "north")) return "the south";
  if (streq(what, "south")) return "the north";
  if (streq(what, "east")) return "the west";
  if (streq(what, "west")) return "the east";
  if (streq(what, "up")) return "below";
  if (streq(what, "down")) return "above";
  if (streq(what, "in")) return "the outside";

  if (streq(what, "rimwards")) return "hubwards";
  if (streq(what, "hubwards")) return "rimwards";
  if (streq(what, "clockwise")) return "anticlockwise";
  if (streq(what, "anticlockwise")) return "clockwise";
  if (streq(what, "aft")) return "fore";
  if (streq(what, "fore")) return "aft";
  if (streq(what, "starboard")) return "port";
  if (streq(what, "port")) return "starboard";

  return 0;
}

int traverse(MudObject *player, MudObject *ext, const char *mvrb, MudObject *whofollow) {
  if (DO_TRAVERSE)
    return DO_TRAVERSE(player, ext, mvrb, whofollow);

  return 0;
}



bool plural(const NewWorld &a) 
{
  if (a.getsize()>1)
    return 1;
  if (a.getsize()==0)
    return 1;
  MudObject *o = a.get_nth(0);
  if (!o)
    return 1;
  if (o->get_flag(FL_PLURAL))
    return 1;
  return 0;
}


MudObject *find_pit(MudObject *where)
{
  MudObject *pit=get_flagged_object(where, FL_PIT);
  if (pit && pit->owner==where) 
    return pit;
  int s = where->array_size("tele");
  for (int i=0;i<s;i++) {
    MudObject *pit = where->array_get_object("tele", i);
    if (pit && pit->get_flag(FL_PIT))
      return pit;
  }
  return 0;
}