From: Keith F. <ven...@us...> - 2002-02-23 08:55:48
|
Update of /cvsroot/planeshift/planeshift/src/server In directory usw-pr-cvs1:/tmp/cvs-serv12355 Modified Files: command.cpp Log Message: Added newguild command. Cleaned up Help a little bit. Index: command.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/command.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** command.cpp 22 Feb 2002 09:17:52 -0000 1.23 --- command.cpp 23 Feb 2002 08:55:44 -0000 1.24 *************** *** 39,54 **** int printed = 0; for (i = 0; commands[i].name; i++) { ! if (!*arg || (strcmp (arg, commands[i].name) == 0)) ! { ! CPrintf ("%s\t\t%s.\n", commands[i].name, commands[i].doc); ! printed++; ! } } if (!printed) { ! CPrintf ("No commands match `%s'. Possibilties are:\n", arg); for (i = 0; commands[i].name; i++) --- 39,55 ---- int printed = 0; + CPrintf("\n"); for (i = 0; commands[i].name; i++) { ! if (!*arg || (strcmp (arg, commands[i].name) == 0)) ! { ! CPrintf ("%-12s %s.\n", commands[i].name, commands[i].doc); ! printed++; ! } } if (!printed) { ! CPrintf ("No commands match `%s'. Possibilities are:\n", arg); for (i = 0; commands[i].name; i++) *************** *** 68,71 **** --- 69,75 ---- CPrintf("\n"); } + + CPrintf("\n"); + return (0); } *************** *** 153,165 **** } /* add all new commands here */ COMMAND commands[] = { ! { "help", com_help, "Display this text" }, ! { "status", com_status, "Displays server status"}, ! { "quit", com_quit, "quits the program"}, ! { "loadmap", com_loadmap, "loads a map into the server"}, ! { "test", com_test, "testcommands everything can happen"}, ! { "newacct", com_newacct, "Create a new account: newacct <user/passwd>"}, { 0, 0, 0 } }; --- 157,202 ---- } + int com_newguild(char *nameleader) + { + if (!nameleader) + { + CPrintf("Please specify guildname/leader.\n"); + return 0; + } + char *slash = strchr(nameleader,'/'); + if (!slash) + { + CPrintf("Please specify guildname/leader with a slash (/) between them.\n"); + return 0; + } + *slash = 0; + + int rc = psserver->GetDatabase()->CreateGuild(nameleader,slash+1); + + switch(rc) + { + case 0: CPrintf("Guild created successfully.\n"); + break; + case 1: CPrintf("That guildname already exists.\n"); + break; + case 2: CPrintf("That leader name was not found.\n"); + break; + default: CPrintf("SQL Error: %s\n",psserver->GetDatabase()->GetLastError()); + break; + } + + return 0; + } + /* add all new commands here */ COMMAND commands[] = { ! { "help", com_help, "Display this text" }, ! { "status", com_status, "Displays server status"}, ! { "quit", com_quit, "Makes the server exit"}, ! { "loadmap", com_loadmap, "Loads a map into the server"}, ! { "test", com_test, "Testcommands everything can happen"}, ! { "newacct", com_newacct, "Create a new account: newacct <user/passwd/playername>" }, ! { "newguild", com_newguild, "Create a new guild: newguild <name/leader>" }, { 0, 0, 0 } }; |