]>
Commit | Line | Data |
---|---|---|
0bbd37a7 | 1 | #include "extern.h" |
857510e8 | 2 | #include "options.h" |
0bbd37a7 | 3 | #include "aClient.h" |
4 | #include "player.h" | |
5 | #include "flags.h" | |
6 | ||
7 | void do_identify(char *u) | |
8 | { | |
9 | char *password, *name; | |
10 | aClient *user; | |
11 | Player *p; | |
12 | name = strtok(NULL, " "); | |
13 | password = strtok(NULL, " "); | |
14 | if (!password || !name) | |
15 | { | |
16 | notice(s_GameServ, u, "SYNTAX: /msg <S IDENTIFY NAME PASSWORD"); | |
17 | } | |
18 | else if (!(user = find(u))) | |
19 | { | |
20 | notice(s_GameServ, u, "Fatal error. Cannot find aClient. Buf: %s", strtok(NULL, "")); | |
21 | log("Error: aClient not found: %s", u); | |
22 | } | |
23 | else if (isIgnore(user)) | |
24 | { | |
25 | #ifdef DEBUGMODE | |
26 | log("Ignoring %s.", user->getNick()); | |
27 | #endif | |
28 | return; | |
29 | } | |
30 | else if (!(p = findplayer(name))) | |
31 | { | |
32 | notice(s_GameServ, u, "Player %s not found", name); | |
33 | } | |
34 | else if (is_playing(user)) | |
35 | { | |
36 | notice(s_GameServ, u, "You are already playing!"); | |
37 | } | |
38 | else if (is_playing(p->getClient()) && !isAdmin(user)) | |
39 | { | |
40 | notice(s_GameServ, u, "That player has already identified."); | |
41 | } | |
42 | else if (!check_password(name, password) && !isAdmin(user)) | |
43 | { | |
44 | notice(s_GameServ, u, "Password incorrect"); | |
45 | } | |
46 | else | |
47 | { | |
48 | list<Player*>::iterator iter; | |
49 | unsigned long hv = iHASH((unsigned char *) p->getName().c_str()); | |
50 | ||
51 | iter = find(players[hv].begin(), players[hv].end(), p); | |
52 | ||
53 | if (iter == players[hv].end()) | |
54 | { | |
55 | notice(s_GameServ, u, "Fatal error. Contact <S Admin. Buf: %s", | |
56 | strtok(NULL, "")); | |
57 | return; | |
58 | } | |
59 | // Make sure the other user is logged out | |
60 | logout(p->getClient()); | |
61 | ||
62 | user->stats = p; | |
63 | p->setClient(user); | |
64 | updateTS(p); | |
65 | ||
66 | ||
67 | #ifdef DEBUGMODE | |
68 | log("Player %s IRC: %s Identified", user->stats->getName().c_str(), | |
69 | user->getNick()); | |
70 | #endif | |
71 | //Set the playing flag | |
72 | setPlaying(user); | |
73 | ||
74 | // Update the last login time | |
75 | user->stats->lastlogin = time(NULL); | |
76 | ||
77 | notice(s_GameServ, u, "Password Accepted. Identified."); | |
78 | showNews(u, todaysnews); | |
79 | } | |
80 | } |