summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-01-08 08:35:32 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-01-08 08:35:32 +0000
commit4e5a65295ad732fd53630d8c29912ec047038d9d (patch)
tree863815cddc095c55fa3c7645e4c52cffc9e744b9 /src/map
parent8fd7ea9e4f38bd02b99e4fa42fc2003390a25adc (diff)
downloadhercules-4e5a65295ad732fd53630d8c29912ec047038d9d.tar.gz
hercules-4e5a65295ad732fd53630d8c29912ec047038d9d.tar.bz2
hercules-4e5a65295ad732fd53630d8c29912ec047038d9d.tar.xz
hercules-4e5a65295ad732fd53630d8c29912ec047038d9d.zip
- Added a precompiler error when the shutdown defines are not found.
- Added parse_console to the plugin API. - Added plugin for parsing the console. (working with cygwin) - Added the console plugin to plugin_athena.conf commented out. - Copied the parse_console code form login txt to login sql and char. - Added propper plugin version compatibility tests. - Better output when a plugin fails to load. ----- The console plugin (at it's 3rd version) uses two pipes and another thread. - the other thread reads data from stdin and sends it through one of the pipes - the other pipe serves as semaphore (and terminator) to that thread - the normal thread checks if the pipe has data once every timer cycle, if data is found it invokes parse_console with that data Worth noting: the first version didn't use another thread and just checked if data was available on the input stream, but apparently that can't be done to standard input in windows It's only been tested on cygwin (and should work on most *nix systems), can't test native windows right now because I'm having trouble exporting the required plugin variables in VS8 src/plugins/Makefile hasn't been updated because it's not working properly for me git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9631 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/map.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/map/map.c b/src/map/map.c
index f17b05e02..6d1bb490d 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3247,44 +3247,54 @@ static int char_ip_set = 0;
* Console Command Parser [Wizputer]
*------------------------------------------
*/
-int parse_console(char *buf) {
- char type[64],command[64],map[64];
- int x = 0, y = 0;
- int m, n;
+int parse_console(char* buf)
+{
+ char type[64];
+ char command[64];
+ char map[64];
+ int x = 0;
+ int y = 0;
+ int m;
+ int n;
struct map_session_data sd;
memset(&sd, 0, sizeof(struct map_session_data));
- strcpy( sd.status.name , "console");
+ strcpy(sd.status.name, "console");
- if ( ( n = sscanf(buf, "%[^:]:%[^:]:%99s %d %d[^\n]", type , command , map , &x , &y )) < 5 )
- if ( ( n = sscanf(buf, "%[^:]:%[^\n]", type , command )) < 2 )
+ if( (n=sscanf(buf, "%[^:]:%[^:]:%99s %d %d[^\n]",type,command,map,&x,&y)) < 5 )
+ if( (n=sscanf(buf, "%[^:]:%[^\n]",type,command)) < 2 )
n = sscanf(buf,"%[^\n]",type);
- if ( n == 5 ) {
+ if( n == 5 ) {
m = map_mapname2mapid(map);
- if ( m < 0 ) {
+ if( m < 0 ){
ShowWarning("Console: Unknown map\n");
return 0;
}
sd.bl.m = m;
map_search_freecell(&sd.bl, m, &sd.bl.x, &sd.bl.y, -1, -1, 0);
- if (x > 0)
+ if( x > 0 )
sd.bl.x = x;
-
- if (y > 0)
+ if( y > 0 )
sd.bl.y = y;
+ } else {
+ map[0] = '\0';
+ if( n < 2 ) command[0] = '\0';
+ if( n < 1 ) type[0] = '\0';
}
- ShowInfo("Type of command: %s || Command: %s || Map: %s Coords: %d %d\n",type,command,map,x,y);
+ ShowInfo("Type of command: '%s' || Command: '%s' || Map: '%s' Coords: %d %d\n", type, command, map, x, y);
- if ( strcmpi("admin",type) == 0 && n == 5 ) {
+ if( n == 5 && strcmpi("admin",type) == 0 ){
if( is_atcommand_sub(sd.fd,&sd,command,99) == AtCommand_None )
printf("Console: not atcommand\n");
- } else if ( strcmpi("server",type) == 0 && n == 2 ) {
- 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("help",type) == 0 ) {
+ } else if( strcmpi("help",type) == 0 ){
ShowNotice("To use GM commands:\n");
printf("admin:<gm command>:<map of \"gm\"> <x> <y>\n");
printf("You can use any GM command that doesn't require the GM.\n");