/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
*
* Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992,2007 Frank Tore Johansen
*
* Deliantra 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 3 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, see .
*
* The authors can be reached via e-mail to
*/
/* This file deals with administrative commands from the client. */
#include
#include
#include
static int
compare_A (const void *a, const void *b)
{
return strcmp (((CommArray_s *)a)->name, ((CommArray_s *)b)->name);
}
static CommArray_s *
find_command_element (char *cmd, CommArray_s *commarray, int commsize)
{
CommArray_s *asp, dummy;
dummy.name = cmd;
asp = (CommArray_s *) bsearch ((void *) &dummy, (void *) commarray, commsize, sizeof (CommArray_s), compare_A);
return asp;
}
/* This function is called from the new client/server code.
* pl is the player who is issuing the command, command is the
* command.
*/
void
execute_newserver_command (object *pl, char *command)
{
CommArray_s *csp;
char *cp;
/*
* remove trailing spaces from commant
*/
cp = command + strlen (command) - 1;
while ((cp >= command) && (*cp == ' '))
{
*cp = '\0';
cp--;
}
cp = strchr (command, ' ');
if (cp)
{
*(cp++) = '\0';
while (*cp == ' ')
cp++;
}
if (!INVOKE_PLAYER (COMMAND, pl->contr, ARG_STRING (command), ARG_STRING (cp)))
{
csp = find_command_element (command, Commands, CommandsSize);
if (!csp) csp = find_command_element (command, CommunicationCommands, CommunicationCommandSize);
if (!csp && QUERY_FLAG (pl, FLAG_WIZ))
csp = find_command_element (command, WizCommands, WizCommandsSize);
if (!csp)
{
new_draw_info_format (NDI_UNIQUE, 0, pl, "'%s' is not a valid command.", command);
return;
}
pl->speed_left -= csp->time;
csp->func (pl, cp);
}
}
int
bad_command (object *op, char *params)
{
new_draw_info (NDI_UNIQUE, 0, op, "bind and unbind are no longer handled on the server");
return 1;
}