]>
jfr.im git - irc/gameservirc.git/blob - gameserv/do_register.cpp
c205e83bb5ff5fa69680ca41772383587f4f2e25
10 void do_register(char *u
)
12 char *password
, *name
;
15 name
= strtok(NULL
, " ");
16 password
= strtok(NULL
, " ");
20 notice(s_GameServ
, u
, "SYNTAX: /msg <S REGISTER NAME PASSWORD");
22 else if (stricmp(name
, s_GameServ
) == 0)
24 notice(s_GameServ
, u
, "You can't use <S as a name!");
28 notice(s_GameServ
, u
, "SYNTAX: /msg <S REGISTER NAME PASSWORD");
30 else if (strlen(name
) > maxnicklen
)
32 notice(s_GameServ
, u
, "Name too long. Maximum length: %d", maxnicklen
);
34 else if (!alphaNumeric(name
))
36 notice(s_GameServ
, u
, "That is not a valid name. Please use only AlphaNumeric (A-Z, 0-9) characters!");
38 else if ((p
= findplayer(name
)))
40 notice(s_GameServ
, u
, "%s is already registered!", name
);
41 notice(s_GameServ
, u
, "Choose another name!");
43 else if (!(user
= find(u
)))
45 log("Fatal Error: Couldn't find %s in the clients list", u
);
47 else if (isIgnore(user
))
50 log("Ignoring %s.", user
->getNick());
55 if (!is_playing(user
))
58 unsigned long hv
= iHASH((unsigned char *) name
);
60 // First create the Player
61 user
->stats
= new Player();
63 // Set the backwards pointer
64 user
->stats
->setClient(user
);
66 // Set the player's password
67 user
->stats
->setPassword(password
);
69 // Set the player's name
70 user
->stats
->setName(name
);
72 // Make sure they have a proper time stamp
73 updateTS(user
->stats
);
75 // Update the last login time
76 user
->stats
->lastlogin
= time(NULL
);
78 // Send notification of success
79 notice(s_GameServ
, u
, "Player %s registered with password %s.", user
->stats
->getName().c_str(), password
);
80 notice(s_GameServ
, u
, "Write this password down. If you lose it, there is no way to retrieve it!");
83 log("Nickname %s registered player %s.", u
, user
->stats
->getName().c_str());
88 // Start the player at the beginning
91 // Add the stick and clothes
92 tempItem
= findItemByID(3001);
93 user
->stats
->inventory
->addItem((*Items
.begin()))->use(user
->stats
); // Add the stick
94 user
->stats
->inventory
->addItem(tempItem
)->use(user
->stats
); // Add Clothes
96 // Add the player to the list
97 players
[hv
].push_back(user
->stats
);
99 // Attempt to add the player to the top list
100 // The class takes care of pruning the user out if they don't deserve to be in the list
101 myToplist
.insertPlayer(user
->stats
);
105 notice(s_GameServ
, u
, "Already registered. Contact a <S admin for help.");