# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /home/lighta/Documents/Myscript/RO/Servs/ra_pincode
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: conf/char_athena.conf
--- conf/char_athena.conf Base (BASE)
+++ conf/char_athena.conf Locally Modified (Based On LOCAL)
@@ -64,7 +64,7 @@
// Console Commands
// Allow for console commands to be used on/off
// This prevents usage of >& log.file
-console: off
+console: on
// Type of server.
// No functional side effects at the moment.
Index: conf/map_athena.conf
--- conf/map_athena.conf Base (BASE)
+++ conf/map_athena.conf Locally Modified (Based On LOCAL)
@@ -79,7 +79,7 @@
// Console Commands
// Allow for console commands to be used on/off
// This prevents usage of >& log.file
-console: off
+console: on
// Database autosave time
// All characters are saved on this time in seconds (example:
Index: src/char/char.c
--- src/char/char.c Base (BASE)
+++ src/char/char.c Locally Modified (Based On LOCAL)
@@ -14,6 +14,7 @@
#include "../common/utils.h"
#include "../common/cli.h"
#include "../common/random.h"
+#include "../common/ers.h"
#include "int_guild.h"
#include "int_homun.h"
#include "int_mercenary.h"
@@ -4343,21 +4344,35 @@
}
// Console Command Parser [Wizputer]
-int parse_console(const char* command)
+int parse_console(const char* buf)
{
- ShowNotice("Console command: %s\n", command);
+ char type[64];
+ char command[64];
+ int n=0;
- if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 || strcmpi("end", command) == 0 )
+ if( ( n = sscanf(buf, "%63[^:]:%63[^\n]", type, command) ) < 2 ){
+ if((n = sscanf(buf, "%63[^\n]", type))<1) return -1; //nothing to do no arg
+ }
+ if( n != 2 ){ //end string
+ command[0] = '\0';
+ }
+ ShowNotice("Type of command: '%s' || Command: '%s'\n",type,command);
+
+ if( n == 2 && strcmpi("server", type) == 0 ){
+ if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 ){
runflag = 0;
+ }
else if( strcmpi("alive", command) == 0 || strcmpi("status", command) == 0 )
ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n");
- else if( strcmpi("help", command) == 0 )
- {
- ShowInfo("To shutdown the server:\n");
- ShowInfo(" 'shutdown|exit|quit|end'\n");
- ShowInfo("To know if server is alive:\n");
- ShowInfo(" 'alive|status'\n");
}
+ else if( strcmpi("ers_report", type) == 0 ){
+ ers_report();
+ }
+ else if( strcmpi("help", command) == 0 ){
+ ShowInfo("Command available :");
+ ShowInfo("\t server shutdown|alive : stop server\n");
+ ShowInfo("\t ers_report : display the db usage\n");
+ }
return 0;
}
@@ -5182,9 +5197,9 @@
add_timer_func_list(online_data_cleanup, "online_data_cleanup");
add_timer_interval(gettick() + 1000, online_data_cleanup, 0, 0, 600 * 1000);
- if( console )
- {
- //##TODO invoke a CONSOLE_START plugin event
+ if( console ){ //start listening
+ add_timer_func_list(parse_console_timer, "parse_console_timer");
+ add_timer_interval(gettick()+1000, parse_console_timer, 0, 0, 1000); //start in 1s each 1sec
}
//Cleaning the tables for NULL entrys @ startup [Sirius]
Index: src/common/cli.c
--- src/common/cli.c Base (BASE)
+++ src/common/cli.c Locally Modified (Based On LOCAL)
@@ -135,3 +135,12 @@
}
return 1;
}
+
+int parse_console_timer(int tid, unsigned int tick, int id, intptr_t data) {
+ char buf[MAX_CONSOLE_IN]; //max cmd atm is 63+63+63+3+3
+ if(fgets(buf, MAX_CONSOLE_IN, stdin)==NULL)
+ return -1; //an error occur
+ else if(strlen(buf)>MIN_CONSOLE_IN)
+ parse_console(buf);
+ return 0;
+}
\ No newline at end of file
Index: src/common/cli.h
--- src/common/cli.h Base (BASE)
+++ src/common/cli.h Locally Modified (Based On LOCAL)
@@ -12,6 +12,8 @@
extern "C" {
#endif
+#define MAX_CONSOLE_IN 200 //max is map...
+#define MIN_CONSOLE_IN 4 //min is help
//map
extern char* MAP_CONF_NAME;
extern char* INTER_CONF_NAME;
@@ -31,6 +33,8 @@
extern void display_helpscreen(bool exit);
int cli_get_options(int argc, char ** argv);
+int parse_console_timer(int tid, unsigned int tick, int id, intptr_t data);
+extern int parse_console(const char* buf); //particular for each serv
#ifdef __cplusplus
}
Index: src/login/login.c
--- src/login/login.c Base (BASE)
+++ src/login/login.c Locally Modified (Based On LOCAL)
@@ -12,6 +12,7 @@
#include "../common/timer.h"
#include "../common/msg_conf.h"
#include "../common/cli.h"
+#include "../common/ers.h"
#include "account.h"
#include "ipban.h"
#include "login.h"
@@ -366,51 +367,58 @@
//-----------------------
// Console Command Parser [Wizputer]
//-----------------------
-int parse_console(const char* command)
-{
- ShowNotice("Console command: %s\n", command);
+int parse_console(const char* buf){
+ char type[64];
+ char command[64];
+ int n=0;
- if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 || strcmpi("end", command) == 0 )
+ if( ( n = sscanf(buf, "%127[^:]:%255[^\n\r]", type, command) ) < 2 ){
+ if((n = sscanf(buf, "%63[^\n]", type))<1) return -1; //nothing to do no arg
+ }
+ if( n != 2 ){ //end string
+ command[0] = '\0';
+ }
+ ShowNotice("Type of command: '%s' || Command: '%s'\n",type,command);
+
+ if( n == 2){
+ if(strcmpi("server", type) == 0 ){
+ if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 ){
runflag = 0;
+ }
else if( strcmpi("alive", command) == 0 || strcmpi("status", command) == 0 )
ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n");
- else if( strcmpi("help", command) == 0 )
- {
- ShowInfo("To shutdown the server:\n");
- ShowInfo(" 'shutdown|exit|quit|end'\n");
- ShowInfo("To know if server is alive:\n");
- ShowInfo(" 'alive|status'\n");
- ShowInfo("To create a new account:\n");
- ShowInfo(" 'create'\n");
}
- else
- {// commands with parameters
- char cmd[128], params[256];
-
- if( sscanf(command, "%127s %255[^\r\n]", cmd, params) < 2 )
+ if( strcmpi("create",type) == 0 )
{
- return 0;
- }
-
- if( strcmpi(cmd, "create") == 0 )
- {
char username[NAME_LENGTH], password[NAME_LENGTH], sex;
-
- if( sscanf(params, "%23s %23s %c", username, password, &sex) < 3 || strnlen(username, sizeof(username)) < 4 || strnlen(password, sizeof(password)) < 1 )
- {
- ShowWarning("Console: Invalid parameters for '%s'. Usage: %s <username> <password> <sex:F/M>\n", cmd, cmd);
+ if( sscanf(command, "%23s %23s %c", username, password, &sex) < 3 || strnlen(username, sizeof(username)) < 4 || strnlen(password, sizeof(password)) < 1 ){
+ ShowWarning("Console: Invalid parameters for '%s'. Usage: %s <username> <password> <sex:F/M>\n", type, type);
return 0;
}
-
- if( mmo_auth_new(username, password, TOUPPER(sex), "0.0.0.0") != -1 )
- {
+ if( mmo_auth_new(username, password, TOUPPER(sex), "0.0.0.0") != -1 ){
ShowError("Console: Account creation failed.\n");
return 0;
}
ShowStatus("Console: Account '%s' created successfully.\n", username);
}
}
+ else if( strcmpi("ers_report", type) == 0 ){
+ ers_report();
+ }
+ else if( strcmpi("help", command) == 0 ){
+ ShowInfo("Command available :");
+ ShowInfo("\t server shutdown|alive : stop|chk server\n");
+ ShowInfo("\t ers_report : display the db usage\n");
+ ShowInfo("\t create <username> <password> <sex:F|M>: create new account\n");
+ }
+ else
+ {// commands with parameters
+
+
+
+ }
+
return 0;
}
@@ -1904,7 +1912,8 @@
}
if( login_config.console ) {
- //##TODO invoke a CONSOLE_START plugin event
+ add_timer_func_list(parse_console_timer, "parse_console_timer");
+ add_timer_interval(gettick()+1000, parse_console_timer, 0, 0, 1000); //start in 1s each 1sec
}
// server port open & binding
Index: src/map/map.c
--- src/map/map.c Base (BASE)
+++ src/map/map.c Locally Modified (Based On LOCAL)
@@ -3125,8 +3125,7 @@
/*==========================================
* Console Command Parser [Wizputer]
*------------------------------------------*/
-int parse_console(const char* buf)
-{
+int parse_console(const char* buf){
char type[64];
char command[64];
char map[64];
@@ -3139,19 +3138,23 @@
memset(&sd, 0, sizeof(struct map_session_data));
strcpy(sd.status.name, "console");
- if( ( n = sscanf(buf, "%63[^:]:%63[^:]:%63s %hd %hd[^\n]", type, command, map, &x, &y) ) < 5 )
- {
- if( ( n = sscanf(buf, "%63[^:]:%63[^\n]", type, command) ) < 2 )
- {
- n = sscanf(buf, "%63[^\n]", type);
+ if( ( n = sscanf(buf, "%63[^:]:%63[^:]:%63s %hd %hd[^\n]", type, command, map, &x, &y) ) < 5 ){
+ if( ( n = sscanf(buf, "%63[^:]:%63[^\n]", type, command) ) < 2 ) {
+ if((n = sscanf(buf, "%63[^\n]", type))<1) return -1; //nothing to do no arg
}
}
- if( n == 5 )
- {
+ if( n != 5 ){ //end string
+ map[0] = '\0';
+ if( n < 2 )
+ command[0] = '\0';
+ }
+
+ ShowNotice("Type of command: '%s' || Command: '%s' || Map: '%s' Coords: %d %d\n", type, command, map, x, y);
+
+ if(strcmpi("map",type) == 0){
m = map_mapname2mapid(map);
- if( m < 0 )
- {
+ if( m < 0 ){
ShowWarning("Console: Unknown map.\n");
return 0;
}
@@ -3162,42 +3165,24 @@
if( y > 0 )
sd.bl.y = y;
}
- else
- {
- map[0] = '\0';
- if( n < 2 )
- command[0] = '\0';
- if( n < 1 )
- type[0] = '\0';
- }
-
- ShowNotice("Type of command: '%s' || Command: '%s' || Map: '%s' Coords: %d %d\n", type, command, map, x, y);
-
- if( n == 5 && strcmpi("admin",type) == 0 )
- {
+ if(strcmpi("admin",type) == 0 ) {
if( !is_atcommand(sd.fd, &sd, command, 0) )
ShowInfo("Console: not atcommand\n");
}
- else if( n == 2 && strcmpi("server", type) == 0 )
- {
- if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 )
- {
+ else if( n == 2 && strcmpi("server", type) == 0 ){
+ if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 ){
runflag = 0;
}
}
else if( strcmpi("ers_report", type) == 0 ){
ers_report();
}
- else if( strcmpi("help", type) == 0 )
- {
- ShowInfo("To use GM commands:\n");
- ShowInfo(" admin:<gm command>:<map of \"gm\"> <x> <y>\n");
- ShowInfo("You can use any GM command that doesn't require the GM.\n");
- ShowInfo("No using @item or @warp however you can use @charwarp\n");
- ShowInfo("The <map of \"gm\"> <x> <y> is for commands that need coords of the GM\n");
- ShowInfo("IE: @spawn\n");
- ShowInfo("To shutdown the server:\n");
- ShowInfo(" server:shutdown\n");
+ else if( strcmpi("help", type) == 0 ) {
+ ShowInfo("Command available :");
+ ShowInfo("\t map <map><x><y> : change our current map\n");
+ ShowInfo("\t admin @acmd : use an atcommand\n");
+ ShowInfo("\t server shutdown : stop server\n");
+ ShowInfo("\t ers_report : display the db usage\n");
}
return 0;
@@ -3815,6 +3800,7 @@
add_timer_func_list(map_removemobs_timer, "map_removemobs_timer");
add_timer_interval(gettick()+1000, map_freeblock_timer, 0, 0, 60*1000);
+
do_init_atcommand();
do_init_battle();
do_init_instance();
@@ -3842,9 +3828,9 @@
npc_event_do_oninit(); // Init npcs (OnInit)
- if( console )
- {
- //##TODO invoke a CONSOLE_START plugin event
+ if( console ){ //start listening
+ add_timer_func_list(parse_console_timer, "parse_console_timer");
+ add_timer_interval(gettick()+1000, parse_console_timer, 0, 0, 1000); //start in 1s each 1sec
}
if (battle_config.pk_mode)