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 "musicmud.h"
#include "emsg.h"

NativeVerb::NativeVerb(const char *id, int minlen, int priv, verbhandler_t fn, PFlag pf, VFlag vfl) :
Verb(id, minlen, priv, pf, vfl), fn(fn) {
}

bool NativeVerb::invoke(MudObject *invoker, int argc, const char*argv[]) {

  try {
    if (fn) return fn(invoker, argc, argv);
    else return false;
  } catch (emsg &e) {
    if (e.msg.length())
      invoker->printf("%s\n", e.msg.c_str());
    return true;
  }
}

PlayerVerb::PlayerVerb(const char *id, int minlen, int priv, playerverb_t fn, PFlag pf, VFlag vfl) :
Verb(id, minlen, priv, pf, vfl), fn(fn) {
}

bool PlayerVerb::invoke(MudObject *invoker, int argc, const char*argv[]) {

  try {
    Player *who = dynamic_cast<Player*>(invoker);

    if (!who)
      throw emsg("You aren't a player.");
    
    if (fn) return fn(who, argc, argv);
    else return false;
  } catch (emsg &e) {
    if (e.msg.length())
      invoker->printf("%s\n", e.msg.c_str());
    return true;
  }
}