friend ostream &operator<<( ostream &output, const aClient &c);
public:
- aClient(char *);
- aClient(const aClient &);
- aClient();
- ~aClient();
+ aClient(char *); // Constructor takes a char for the nick
+ aClient(const aClient &); // Copy constructor
+ aClient(); // Default constructor
+ ~aClient(); // Destructor
+ // Sets the client's player struct data to the same thing as another aClient's
+ // player struct data
void setData(const aClient *);
- void setNick(char *n) { strcpy(nick, n);};
- //const char *getNick() { return nick; };
- char *getNick() { return nick; };
- Player *stats;
+
+ void setNick(char *n) { strcpy(nick, n);}; // Sets the client's nick
+ char *getNick() { return nick; }; // Returns the client's nick
+ Player *stats; // Pointer to the client's player struct
+
+ long int getFlags() { return flags; }; // Returns the Client's current flags
+
+ // Functions also return the flags after modifying them
+ long int setFlags(long int); // Sets the clients flags to a new value
+ long int addFlag(long int); // Adds a flag to the client's flags
+ long int remFlag(long int); // Removes a flag from the client's current flags
private:
- char nick[32];
+ char nick[32]; // Client's current nickname.
+ long int flags; // Client's current flags.
};
#endif
+#include "aClient.h"
#include "config.h"
#include "extern.h"
-#include "sockhelp.h"
-#include "aClient.h"
+#include "flags.h"
#include "list.h"
+#include "sockhelp.h"
+
#include <cctype>
#include <fstream.h>
void delete_monsters();
void delete_masters();
+void do_admin(char *u);
void do_attack(char *u);
void do_bank(char *u);
void do_fight(char *u);
do_store(source);
} else if (stricmp(cmd, "BANK") == 0) {
do_bank(source);
+ } else if (stricmp(cmd, "ADMIN") == 0) {
+ do_admin(source);
} else if (stricmp(cmd, "REFRESH") == 0) {
- char *pass = strtok(NULL, " ");
- if (pass != NULL && (stricmp(pass, adminpass) == 0))
- {
- do_refresh(source);
- }
- else
- {
- notice(s_GameServ, source, "SYNTAX: /msg %S REFRESH <password> {ALL | NICK}");
- }
+ do_refresh(source);
} else if (stricmp(cmd, "PRINT") == 0) {
cout << "Printing Clients List: " << endl;
clients.print();
} else if (stricmp(cmd, "STATS") == 0) {
do_stats(source);
} else if (stricmp(cmd, "SHUTDOWN") == 0) {
- char *pass = strtok(NULL, " ");
- if (pass != NULL && (stricmp(pass, adminpass) == 0))
+ aClient *user;
+
+ if (!(user = find(source)))
{
- save_gs_dbase();
- raw("SQUIT %s :leaving", servername);
+ notice(s_GameServ, source, "Error: aClient not found. Contact a %S admin");
+ cout << "Error: aClient not found: " << source << endl;
+ }
+ else if (!isAdmin(user))
+ {
+ notice(s_GameServ, source, "You must be a %S admin to use this command!");
}
else
{
- notice(s_GameServ, source, "SYNTAX: /msg %S SHUTDOWN <password>");
+ save_gs_dbase();
+ raw("SQUIT %s :leaving", servername);
}
} else if (stricmp(cmd, "SAVE") == 0) {
- char *pass = strtok(NULL, " ");
- if (pass != NULL && (stricmp(pass, adminpass) == 0))
+ aClient *user;
+
+ if (!(user = find(source)))
+ {
+ notice(s_GameServ, source, "Error: aClient not found. Contact a %S admin");
+ cout << "Error: aClient not found: " << source << endl;
+ }
+ else if (!isAdmin(user))
+ {
+ notice(s_GameServ, source, "You must be a %S admin to use this command!");
+ }
+ else
{
save_gs_dbase();
}
- else
- {
- notice(s_GameServ, source, "SYNTAX: /msg %S SAVE <password>");
- }
} else if (stricmp(cmd, "LOAD") == 0) {
- char *pass = strtok(NULL, " ");
- if (pass != NULL && (stricmp(pass, adminpass) == 0))
+ aClient *user;
+
+ if (!(user = find(source)))
+ {
+ notice(s_GameServ, source, "Error: aClient not found. Contact a %S admin");
+ cout << "Error: aClient not found: " << source << endl;
+ }
+ else if (!isAdmin(user))
+ {
+ notice(s_GameServ, source, "You must be a %S admin to use this command!");
+ }
+ else
{
load_gs_dbase();
}
- else
- {
- notice(s_GameServ, source, "SYNTAX: /msg %S LOAD <password>");
- }
} else if (stricmp(cmd, "RAW") == 0) {
- char *pass = strtok(NULL, " ");
- if (pass != NULL && (stricmp(pass, adminpass) == 0))
+ aClient *user;
+
+ if (!(user = find(source)))
+ {
+ notice(s_GameServ, source, "Error: aClient not found. Contact a %S admin");
+ cout << "Error: aClient not found: " << source << endl;
+ }
+ else if (!isAdmin(user))
+ {
+ notice(s_GameServ, source, "You must be a %S admin to use this command!");
+ }
+ else
{
char *rest = strtok(NULL, "");
raw("%s", rest);
}
- else
- {
- notice(s_GameServ, source, "SYNTAX: /msg %S RAW <password> <raw>");
- }
}
source--; // Bring the ':' back so we don't leak memory
char *nick = strtok(NULL, " ");
aClient *user;
+ if (!(user = find(u)))
+ {
+ notice(s_GameServ, u, "Error: aClient not found. Contact a %S admin");
+ cout << "Error: aClient not found: " << u << endl;
+ return;
+ }
+ else if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "You must be a %S admin to use this command!");
+ return;
+ }
if (!nick)
{
- notice(s_GameServ, u, "SYNTAX: REFRESH <password> {ALL | NICK}");
+ notice(s_GameServ, u, "SYNTAX: REFRESH {ALL | NICK}");
return;
}
else if (stricmp(nick, "ALL") == 0)
}
// Minor recursion
- display_help(u, "admin");
+ aClient *user = find(u);
+ if (user && isAdmin(user))
+ display_help(u, "admin_commands");
}
else
{
infile.close();
delete [] buf;
}
+
+void do_admin(char *u)
+{
+ aClient *user;
+ char *pass = strtok(NULL, " ");
+
+ if (!(user = find(u)))
+ {
+ cout << "Error: aClient not found: " << u << endl;
+ notice(s_GameServ, u, "Error: aClient not found. Contact %S admin.");
+ return;
+ }
+ if (!pass)
+ {
+ notice(s_GameServ, u, "SYNTAX: \ 2ADMIN\ 2 \ 2\1fpassword\1f\ 2");
+ return;
+ }
+
+ if (strcmp(pass, adminpass) == 0)
+ {
+ notice(s_GameServ, u, "Password accepted. You now have administrator privledges.");
+ setAdmin(user);
+ }
+ else
+ {
+ notice(s_GameServ, u, "Invalid password. Remember: case sensitive");
+ return;
+ }
+}
Here are the basic commands available to everyone:
- \ 2HELP\ 2 \1fBrings up this help menu\1f
- \ 2LIST\ 2 \1fList who is currently in the realm\1f
- \ 2SEARCH\ 2 \1fSearch the forest for a monster to kill\1f
\ 2ATTACK\ 2 \1fAttack with your weapon while in battle\1f
- \ 2RUN\ 2 \1fFlee from battle to save yourself\1f
- \ 2FIGHT\ 2 \1fFight another player in the realm\1f
+ \ 2ADMIN\ 2 \1fIdentify yourself as a gameserv administrator\1f
\ 2BANK\ 2 \1fWithdraw and deposit gold from your bank account\1f
+ \ 2FIGHT\ 2 \1fFight another player in the realm\1f
\ 2HEAL\ 2 \1fHeal yourself. Replenishes Hit points\1f
- \ 2STORE\ 2 \1fBuy and Sell weapons and armor\1f
+ \ 2HELP\ 2 \1fBrings up this help menu\1f
+ \ 2IDENTIFY\ 2 \1fIdentify yourself with a previously registered login\1f
+ \ 2LIST\ 2 \1fList who is currently in the realm\1f
\ 2MASTER\ 2 \1fQuestion and fight your master to gain a level\1f
\ 2REGISTER\ 2 \1fRegister a login and join the realm\1f
- \ 2IDENTIFY\ 2 \1fIdentify yourself with a previously registered login\1f
+ \ 2RUN\ 2 \1fFlee from battle to save yourself\1f
+ \ 2SEARCH\ 2 \1fSearch the forest for a monster to kill\1f
\ 2STATS\ 2 \1fGet a stats listing of you or another player in the realm\1f
+ \ 2STORE\ 2 \1fBuy and Sell weapons and armor\1f
Further help on individual commands can be accessed by typing /msg %S \ 2HELP\ 2 \ 2\1fcommand\1f\ 2