ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_new.C
Revision: 1.18
Committed: Tue May 6 16:55:26 2008 UTC (16 years, 1 month ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-2_6, rel-2_7, rel-2_72, rel-2_73, rel-2_71, rel-2_54, rel-2_55, rel-2_56, rel-2_61
Changes since 1.17: +1 -1 lines
Log Message:
update copyright

File Contents

# User Rev Content
1 elmex 1.1 /*
2 root 1.17 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 pippijn 1.12 *
4 root 1.18 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 root 1.15 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6     * Copyright (©) 1992,2007 Frank Tore Johansen
7 pippijn 1.12 *
8 root 1.17 * Deliantra is free software: you can redistribute it and/or modify
9 root 1.16 * 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 pippijn 1.12 *
13 root 1.16 * 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 pippijn 1.12 *
18 root 1.16 * 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 root 1.15 *
21 root 1.17 * The authors can be reached via e-mail to <support@deliantra.net>
22 pippijn 1.12 */
23 elmex 1.1
24     /* This file deals with administrative commands from the client. */
25     #include <global.h>
26     #include <commands.h>
27 root 1.9 #include <sproto.h>
28 elmex 1.1
29 root 1.4 static int
30     compare_A (const void *a, const void *b)
31 elmex 1.1 {
32 root 1.7 return strcmp (((CommArray_s *)a)->name, ((CommArray_s *)b)->name);
33 elmex 1.1 }
34    
35 root 1.4 static CommArray_s *
36 root 1.7 find_command_element (char *cmd, CommArray_s *commarray, int commsize)
37 elmex 1.1 {
38     CommArray_s *asp, dummy;
39    
40 root 1.4 dummy.name = cmd;
41     asp = (CommArray_s *) bsearch ((void *) &dummy, (void *) commarray, commsize, sizeof (CommArray_s), compare_A);
42 elmex 1.1 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 root 1.7 void
50 root 1.4 execute_newserver_command (object *pl, char *command)
51 elmex 1.1 {
52 root 1.4 CommArray_s *csp;
53     char *cp;
54 elmex 1.1
55 root 1.4 /*
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 elmex 1.1 }
64 root 1.7
65 root 1.4 cp = strchr (command, ' ');
66     if (cp)
67     {
68     *(cp++) = '\0';
69     while (*cp == ' ')
70     cp++;
71 elmex 1.1 }
72    
73 root 1.7 if (!INVOKE_PLAYER (COMMAND, pl->contr, ARG_STRING (command), ARG_STRING (cp)))
74     {
75 pippijn 1.13 csp = find_command_element (command, Commands, CommandsSize);
76 root 1.7 if (!csp) csp = find_command_element (command, CommunicationCommands, CommunicationCommandSize);
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 elmex 1.1
86 root 1.7 pl->speed_left -= csp->time;
87 root 1.4
88 root 1.7 csp->func (pl, cp);
89 elmex 1.1 }
90     }
91    
92 root 1.4 int
93     bad_command (object *op, char *params)
94 elmex 1.1 {
95 root 1.4 new_draw_info (NDI_UNIQUE, 0, op, "bind and unbind are no longer handled on the server");
96     return 1;
97 elmex 1.1 }