]> jfr.im git - irc/gameservirc.git/blame - gameserv/do_logout.cpp
Added code for the start of the DataLayer format as well as a basic FilePlayerDAO...
[irc/gameservirc.git] / gameserv / do_logout.cpp
CommitLineData
857510e8 1#include "extern.h"
2#include "config.h"
3#include "aClient.h"
4#include "flags.h"
5#include "player.h"
6#include "options.h"
7
8
9void do_logout(char *u)
10{
11 aClient *user;
12 Player *p;
13 char *name = strtok(NULL, " ");
14
15 if (!(user = find(u)))
16 {
17 notice(s_GameServ, u, "Fatal error. Cannot find aClient. "\
18 "Buf: %s LOGOUT", u);
19 log("Could not find aClient Buf: %s LOGOUT",
20 u);
21 return;
22 }
23 else if (isIgnore(user))
24 {
25#ifdef DEBUGMODE
26 log("Ignoring %s.", user->getNick());
27#endif
28 return;
29 }
30
31 if (name)
32 {
33 if (!isAdmin(user))
34 {
35 notice(s_GameServ, u, "You must be a <S admin to use this command!");
36 }
37 else if (!(p = findplayer(name)))
38 {
39 notice(s_GameServ, u, "Couldn't find a player named %s", name);
40 }
41 else
42 {
43 notice(s_GameServ, u, "Logging out %s", p->getName().c_str());
44 logout(p->getClient());
45 }
46 }
47 else if (!name)
48 {
49 if (!is_playing(user))
50 {
51 notice(s_GameServ, u, "You're not logged in!");
52 }
53 else if (is_fighting(user))
54 {
55 notice(s_GameServ, u, "You can't logout while fighting!");
56 }
57 else
58 {
59 notice(s_GameServ, u, "You have left the fields. You have lived to kill another day!");
60 logout(user);
61 }
62 }
63}