]> jfr.im git - irc/gameservirc.git/blame - gameserv/gameserv.cpp
More exciting additions to FilePlayerDAO!
[irc/gameservirc.git] / gameserv / gameserv.cpp
CommitLineData
96f71fee 1#include "aClient.h"
c1068b6e 2#include "config.h"
3#include "extern.h"
37ed80a9 4#include "player.h"
5#include "pouch.h"
96f71fee 6#include "flags.h"
586cf465 7#include "level.h"
96f71fee 8#include "sockhelp.h"
37ed80a9 9#include "item.h"
67b4ac9a 10#include "script.h"
8cd4c581 11#include "toplist.h"
96f71fee 12
c10b78ac 13#include <algorithm>
85ce9d3e 14#include <cctype>
fb37ecc7 15#include <fstream>
9fe7af4c 16#include <stdlib.h>
37ed80a9 17#include <list>
18#include <iterator>
fb37ecc7 19
37ed80a9 20using namespace std;
c1068b6e 21
22#if defined(HAVE_CRYPT_H)
23
e3c5fe46 24#include <crypt.h>
85ce9d3e 25
c1068b6e 26#elif defined(HAVE_UNISTD_H)
27
28#include <unistd.h>
29
30#endif
c8ada07e 31
857510e8 32
42106907 33Level levels[LEVELS]; // The newest way to store monsters
cd973e97 34list<item*> Items; // The master list of items
d1927afc 35list<tavernItem> tavern; // The list of items available at the tavern
64ed4698 36list<item*> store; // List of items available at the store
71a1182a 37
8cd4c581 38toplist myToplist; // List of the top 10 players
bf3a2ff9 39
85ce9d3e 40
e3c5fe46 41
05c527e6 42bool shuttingdown;
85ce9d3e 43
85ce9d3e 44#define WNA 16
85ce9d3e 45
46int hpbonus[11] = {10, 15, 20, 30, 50, 75, 125, 185, 250, 350, 550};
47int strbonus[11] = {5, 7, 10, 12, 20, 35, 50, 75, 110, 150, 200};
48int defbonus[11] = {2, 3, 5, 10, 15, 22, 35, 60, 80, 120, 150};
49
85ce9d3e 50void gameserv(char *source, char *buf)
51{
c10b78ac 52 char *cmd, z;
53 cmd = strtok(buf, " ");
54
55#ifndef P10
56 source++; // Get rid of that : at the beginning of a :Nick privmsg Gameserv :text
57#endif
58
59 z = cmd[0];
60 if (z == ':')
61 cmd++; // Get rid of that : at the beginning of the :text (command)
62
63#ifdef DEBUGMODE
64 log("Source: %s Command: %s", source, cmd);
65#endif
66
67 if (strnicmp(cmd, "\1PING", 6) == 0)
85ce9d3e 68 {
c10b78ac 69 char *ts;
70 ts = strtok(NULL, "\1");
71 notice(s_GameServ, source, "\1PING %s\1", ts);
72 }
73 else if (stricmp(cmd, "\1VERSION\1") == 0)
74 {
69db6f3f 75 notice(s_GameServ, source, "\1VERSION %s %s\1", PACKAGE.c_str(), VERSION.c_str());
c10b78ac 76 }
77 else if (stricmp(cmd, "SEARCH") == 0)
78 {
79 cmd = strtok(NULL, " ");
80
81 if (!cmd)
abb0a0b9 82 notice(s_GameServ, source, "SYNTAX: /msg <S SEARCH FOREST");
c10b78ac 83 else
85ce9d3e 84 do_forest(source);
c10b78ac 85
86 }
87 else if (stricmp(cmd, "ADMIN") == 0)
88 {
89 do_admin(source);
90 }
91 else if (stricmp(cmd, "ATTACK") == 0)
92 {
93 do_attack(source);
94 }
95 else if (stricmp(cmd, "BANK") == 0)
96 {
97 do_bank(source);
98 }
99 else if (stricmp(cmd, "CHECK") == 0)
100 {
101 do_check(source);
102 }
103 else if (stricmp(cmd, "DRAGON") == 0)
104 {
105 do_dragon(source);
106 }
107 else if (stricmp(cmd, "EQUIP") == 0)
108 {
1781f48a 109 do_equip(source);
c10b78ac 110 }
111 else if (stricmp(cmd, "FIGHT") == 0)
96f71fee 112 {
c10b78ac 113 do_fight(source);
114 }
115 else if (stricmp(cmd, "HEAL") == 0)
45a84400 116 {
c10b78ac 117 do_heal(source);
118 }
119 else if (stricmp(cmd, "HELP") == 0)
96f71fee 120 {
c10b78ac 121 do_help(source);
122 }
123 else if (stricmp(cmd, "IDENTIFY") == 0)
96f71fee 124 {
c10b78ac 125 do_identify(source);
126 }
127 else if (stricmp(cmd, "INVENTORY") == 0)
96f71fee 128 {
c10b78ac 129 do_inventory(source);
130 }
131 else if (stricmp(cmd, "LIST") == 0)
96f71fee 132 {
c10b78ac 133 do_list(source);
134 }
135 else if (stricmp(cmd, "LOGOUT") == 0)
136 {
137 do_logout(source);
138 }
139 else if (stricmp(cmd, "MASTER") == 0)
140 {
141 do_master(source);
142 }
143 else if (stricmp(cmd, "NEWS") == 0)
144 {
145 do_news(source);
146 }
147 else if (stricmp(cmd, "REGISTER") == 0)
148 {
149 do_register(source);
150 }
151 else if (stricmp(cmd, "REFRESH") == 0)
152 {
153 do_refresh(source);
154 }
155 else if (stricmp(cmd, "RESET") == 0)
156 {
157 do_reset(source);
158 }
159 else if (stricmp(cmd, "RUN") == 0)
160 {
161 do_run(source);
162 }
163 else if (stricmp(cmd, "SET") == 0)
164 {
165 do_set(source);
166 }
167 else if (stricmp(cmd, "STATS") == 0)
168 {
169 do_stats(source);
170 }
171 else if (stricmp(cmd, "STORE") == 0)
172 {
173 do_store(source);
174 }
175 else if (stricmp(cmd, "TAVERN") == 0)
176 {
177 do_tavern(source);
178 }
179 else if (stricmp(cmd, "USE") == 0)
180 {
181 do_use(source);
182 }
183 else if (stricmp(cmd, "SHUTDOWN") == 0)
184 {
af02354b 185 do_shutdown(source);
c10b78ac 186 }
187 else if (stricmp(cmd, "SAVE") == 0)
188 {
af02354b 189 do_save(source);
c10b78ac 190 }
191 else if (stricmp(cmd, "LOAD") == 0)
96f71fee 192 {
af02354b 193 do_load(source);
96f71fee 194 }
c10b78ac 195#ifdef DEBUGMODE
196 else if (stricmp(cmd, "RAW") == 0)
96f71fee 197 {
af02354b 198 do_raw(source);
c10b78ac 199 }
c10b78ac 200#endif
201 else
202 {
203 aClient *user;
204 if ((user = find(source)))
205 {
206 if (isIgnore(user))
207 {
208#ifdef DEBUGMODE
209 log("Ignoring %s.", user->getNick());
210#endif
211 }
212 else
213 {
abb0a0b9 214 notice(s_GameServ, source, "Unknown command \002%s\002. Type /msg <S \002HELP\002 to get a list of commands.", cmd);
c10b78ac 215 }
216 }
217 }
85ce9d3e 218
c10b78ac 219#ifndef P10
af02354b 220 source--; // Bring the ':' back
c10b78ac 221#endif
222 if (z == ':')
448a1531 223 cmd--; // Same thing :)
85ce9d3e 224}
225