ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_new.C
Revision: 1.19
Committed: Fri Dec 19 22:47:30 2008 UTC (15 years, 5 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-2_80, rel-2_76, rel-2_77, rel-2_74, rel-2_75, rel-2_79, rel-2_78
Changes since 1.18: +2 -2 lines
Log Message:
new los code

File Contents

# Content
1 /*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 *
8 * Deliantra is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */
23
24 /* This file deals with administrative commands from the client. */
25 #include <global.h>
26 #include <commands.h>
27 #include <sproto.h>
28
29 static int
30 compare_A (const void *a, const void *b)
31 {
32 return strcmp (((CommArray_s *)a)->name, ((CommArray_s *)b)->name);
33 }
34
35 static CommArray_s *
36 find_command_element (char *cmd, CommArray_s *commarray, int commsize)
37 {
38 CommArray_s *asp, dummy;
39
40 dummy.name = cmd;
41 asp = (CommArray_s *) bsearch ((void *) &dummy, (void *) commarray, commsize, sizeof (CommArray_s), compare_A);
42 return asp;
43 }
44
45 /* This function is called from the new client/server code.
46 * pl is the player who is issuing the command, command is the
47 * command.
48 */
49 void
50 execute_newserver_command (object *pl, char *command)
51 {
52 CommArray_s *csp;
53 char *cp;
54
55 /*
56 * remove trailing spaces from commant
57 */
58 cp = command + strlen (command) - 1;
59 while ((cp >= command) && (*cp == ' '))
60 {
61 *cp = '\0';
62 cp--;
63 }
64
65 cp = strchr (command, ' ');
66 if (cp)
67 {
68 *(cp++) = '\0';
69 while (*cp == ' ')
70 cp++;
71 }
72
73 if (!INVOKE_PLAYER (COMMAND, pl->contr, ARG_STRING (command), ARG_STRING (cp)))
74 {
75 csp = find_command_element (command, Commands, CommandsSize);
76
77 if (!csp && QUERY_FLAG (pl, FLAG_WIZ))
78 csp = find_command_element (command, WizCommands, WizCommandsSize);
79
80 if (!csp)
81 {
82 new_draw_info_format (NDI_UNIQUE, 0, pl, "'%s' is not a valid command.", command);
83 return;
84 }
85
86 pl->speed_left -= csp->time;
87
88 csp->func (pl, cp);
89 }
90 }
91
92 int
93 bad_command (object *op, char *params)
94 {
95 new_draw_info (NDI_UNIQUE, 0, op, "bind and unbind are no longer handled on the server");
96 return 1;
97 }