/* * MusicMUD - interpreter bolt-on features * 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 "musicmud.h" #include "util.h" #include "verbs.h" #include "State.h" #include "Interpret.h" #include "misc.h" #include "util.h" #include "hooks.h" #define MAX(a,b) (a>b?a:b) static bool isperson(const TeleObject &who) { return is_person(who.what); } class Implicit_Tell : public Interpreter { public: Implicit_Tell() : Interpreter("50.implicit_tell") { }; virtual int invoke(MudObject *who, const char *string, int argc, const char **argv) { if (string[0]=='\'' || string[0]=='\"') { std::string s = "say "; s += string + 1; who->interpret(s.c_str()); return 0; } if (string[0]==':' || string[0]==';') { std::string s; if (string[1] != ':' && string[1] != ';') { s = "emote "; s += string + 1; } else { s = "pemote "; s += string + 2; } who->interpret(s.c_str()); return 0; } if (string[0]=='.') { std::string s = "tell "; s += string+1; who->interpret(s.c_str()); return 0; } MudObject *o = planet->get(argv[0]); if (strlen(argv[0])>=3) o = get_player(who, argv[0]); if (!o) { NewWorld ply; MudObject *o; int i; foreach(players, o, i) ply.add(*o); NewWorld blah = match(who, 1, argv, isperson, LOOK_ROOM|IGNORE_EXITS| LOOK_SPECIAL| IGNORE_CATEGORIES, 0, &ply); MudObject *targ = blah.getsize()?blah.get(0):0; if (targ && is_person(targ)) { if (DO_TELL) DO_TELL(who, targ, argv+1, argc-1); return 0; } } if (o) { if (DO_TELL) DO_TELL(who, o, argv+1, argc-1); return 0; } if (strchr(argv[0], '@')) { who->interpretf("tell %s", string); return 0; } return -1; } }; Implicit_Tell *teller; extern "C" void register_verbs() { teller = new Implicit_Tell(); interpreters->add(*teller); } extern "C" void remove_verbs() { interpreters->remove(*teller); delete teller; }