From 4aee20b0e1fdfb23d9336cea77a0985e463ea081 Mon Sep 17 00:00:00 2001 From: mc_cameri Date: Tue, 14 Dec 2004 00:33:01 +0000 Subject: git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@566 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/showmsg.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/common/showmsg.h') diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 03ffe310b..59bd6a090 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -1,6 +1,18 @@ #ifndef _SHOWMSG_H_ #define _SHOWMSG_H_ +#define CL_RESET "\033[0;0m" +#define CL_NORMAL CL_RESET +#define CL_NONE CL_RESET +#define CL_WHITE "\033[1;29m" +#define CL_GRAY "\033[1;30m" +#define CL_RED "\033[1;31m" +#define CL_GREEN "\033[1;32m" +#define CL_YELLOW "\033[1;33m" +#define CL_BLUE "\033[1;34m" +#define CL_MAGENTA "\033[1;35m" +#define CL_CYAN "\033[1;36m" + extern char tmp_output[1024]; enum msg_type {MSG_STATUS,/* MSG_SQL, */MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_ERROR,MSG_FATALERROR}; -- cgit v1.2.3-70-g09d2 From 9fdd623ce57666c39651f17668cfc59a2b977d3d Mon Sep 17 00:00:00 2001 From: mc_cameri Date: Sun, 19 Dec 2004 17:27:17 +0000 Subject: git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@644 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 1 + src/common/showmsg.c | 2 ++ src/common/showmsg.h | 13 +++++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/common/showmsg.h') diff --git a/Changelog.txt b/Changelog.txt index 3c2718950..4d2618fa4 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,7 @@ Date Added 12/19 + * Added ShowDebug(), Debug(), DisplayDebug(), printDebug(), CL_DEBUG, MSG_DEBUG to _ShowMessage() [MC Cameri] * Replaced many \033[x;xm with their corresponding CL_xx constants [MC Cameri] * Separated NPCs and Maps from map_athena.conf into npcs_list.txt and maps_list.conf [MC Cameri] * Modified all the *_athena.conf's to have the import command enabled by default [Ajarn] diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 903fb583b..8c7fc9a13 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -35,6 +35,8 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri case MSG_WARNING: //Bright Yellow strcpy(prefix,CL_YELLOW"[Warning]"CL_RESET":"); break; + case MSG_DEBUG: + strcpy(prefix,CL_CYAN"[Debug]"CL_RESET":"); case MSG_ERROR: //Bright Red (Regular errors) strcpy(prefix,CL_RED"[Error]"CL_RESET":"); break; diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 59bd6a090..2d40255fb 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -1,6 +1,9 @@ #ifndef _SHOWMSG_H_ #define _SHOWMSG_H_ +//davidsiaw, 'lookee' here! +#define SHOW_DEBUG_MSG 1 + #define CL_RESET "\033[0;0m" #define CL_NORMAL CL_RESET #define CL_NONE CL_RESET @@ -15,7 +18,7 @@ extern char tmp_output[1024]; -enum msg_type {MSG_STATUS,/* MSG_SQL, */MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_ERROR,MSG_FATALERROR}; +enum msg_type {MSG_STATUS,/* MSG_SQL, */MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_DEBUG,MSG_ERROR,MSG_FATALERROR}; extern int _ShowMessage(const char *string, enum msg_type flag); @@ -42,11 +45,17 @@ extern int _ShowMessage(const char *string, enum msg_type flag); #define ShowNotice(string) _ShowMessage(string,MSG_NOTICE) // #define DisplayNotice(string) _ShowMessage(string,MSG_NOTICE) -/* */ +/* MSG_WARNING */ #define ShowWarning(string) _ShowMessage(string,MSG_WARNING) // #define DisplayWarning(string) _ShowMessage(string,MSG_WARNING) // #define Warn(string) _ShowMessage(string,MSG_WARNING) +/* MSG_DEBUG */ + #define ShowDebug(string) _ShowMessage(string,MSG_DEBUG) + #define DisplayDebug(string) _ShowMessage(string,MSG_DEBUG) + #define Debug(string) _ShowMessage(string,MSG_DEBUG) + #define printDebug() _ShowMessage(striing,MSG_DEBUG) + /* MSG_ERROR */ #define ShowError(string) _ShowMessage(string,MSG_ERROR) // #define DisplayError(string) _ShowMessage(string,MSG_ERROR) -- cgit v1.2.3-70-g09d2 From 99b156f4ec91f2d52fd57aa1710ae9261b8db356 Mon Sep 17 00:00:00 2001 From: mc_cameri Date: Mon, 27 Dec 2004 14:35:37 +0000 Subject: git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@820 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog.txt | 3 +++ Dev/TODO.txt | 6 ++++++ Dev/bugs.txt | 52 +--------------------------------------------------- db/mob_avail.txt | 4 ++++ db/mob_db.txt | 1 + db/mob_skill_db.txt | 2 ++ src/common/showmsg.c | 26 ++++++++++++-------------- src/common/showmsg.h | 4 ++-- src/map/map.c | 29 +++++++++++++++-------------- 9 files changed, 46 insertions(+), 81 deletions(-) (limited to 'src/common/showmsg.h') diff --git a/Changelog.txt b/Changelog.txt index 10d77b994..adc35d9f0 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,8 @@ Date Added 12/27 + * Removed some printf's from map-sql [MC Cameri] + * Uncommented MSG_SQL, for _ShowMessage(), usage: ShowSQL() [MC Cameri] + * Removed fixed bugs in dev/bugs.txt [MC Cameri] * Now I remember what I was smoking.. (SVN 819) [MouseJstr] * Fixed a bug in the guild_castle persistance code in char_sql. What was I smoking? (SVN: 816) [MouseJstr] diff --git a/Dev/TODO.txt b/Dev/TODO.txt index f44b9d112..ca33ab044 100644 --- a/Dev/TODO.txt +++ b/Dev/TODO.txt @@ -766,3 +766,9 @@ Description add MvM map flag Status: Pending Assignee None Notes for allowing a monster on monster arena +*** +70. +Description Redo the gm help files +Status Pending +Assignee MC_Cameri +Notes Do this after all @char commands are converted to # to avoid any problems. \ No newline at end of file diff --git a/Dev/bugs.txt b/Dev/bugs.txt index 1cfff1fae..eb3e00bd0 100644 --- a/Dev/bugs.txt +++ b/Dev/bugs.txt @@ -46,23 +46,10 @@ Problem: Wierd login-server bug on sql, it displays that the server is full when Assigned: N/A Progress: 0% -Problem: Login-Txt is now crashing when you close it using ^C, Ctrl+C(on windows), it only does that if login was connected with char-server. -Assigned: MC Cameri -Progress: 100% - Problem: MVP cast spells w/o showing "prepare cast line" Assigned: N/A Progress: 0% -Problem: Item duping bug in storage... -Assigned: MouseJstr -Progress: 100% - - Let's say you have 200 arrows and 100 Rosiotti arrow, you'll put 100 and 50 in storage - And you should end when you log back in with 100 of each on you and 100 and 50 in storage - Gain 50 - Repeat - Problem: ~40+ players connected.. and soon can't re-connect, they can enter password, but never see "select character" screen. Assigned: N/A Progress: 0% @@ -73,27 +60,6 @@ Progress: 0% DB server Error - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'n' Sniff')' at line 1 Scratch 'n' Sniff -Problem: Spiral Pierce can cause loss of Skill Points -Assigned: MouseJstr -Progress: 100% - - If you have a skill but due to a job change (or admin update), the - skill tree changes and you no longer can get to that skill, you - will loose the skill points if you log out/i - - The easiest way to reproduce this problem is become a Peco Lord - Knight, get spiral pierce, get off the peco, log off, log in, and - get back on the peco. You will not have Spiral Pierce anymore and - you will have lost the skill points - -Problem: blacksmith hammerfall on the new_1-1.gat's bridge crashes server -Assigned: N/A -Progress: 100% (fixed) - -Problem: hunter spamming traps crashes server -Assigned: N/A -Progress: 100% (fixed) - Problem: PETS can attack Guardians, so players go to enemy castles before WOE and KILL all their Guards with PETS... LoL! Assigned: N/A Progress: 0% @@ -131,25 +97,10 @@ Progress: - Notes: It works differently now, you have to use it once to *allow* it to activate, and once again to stop it from activating. ^^; [Celest] -Problem: When you change JOB, you don't lose skills in DB. It - means if you were Merchant once - you can buy/sell with discount being Mage, etc. - Those skills aren't being shown in the skilltree, but - they do work. - (fixed) - -Assigned: MouseJstr -Progress: 100% - Problem: Due to the Guilds CACHE we see some went-offline members as online ones. It is very confusing. You don't know who's really on. Assigned: N/A Progress: 0% -Problem: When you have UNNAMED Arrows and Named Arrows in the storage and take some arrows then it change amount of other items. - It happens because server doesn't recognize Named and Unnamed Stockable items (Elemental Gems, Iron, Steel, Holy Water, Arrows) -Assigned: MouseJstr -Progress: 100% - Problem: Guilds BUG (it isn't related to the scripts, because noone change them recently) When some guild SEIZE any castle, then Castle N 1 becomes their own, too (not M 0, but M 1) Assigned: N/A @@ -181,5 +132,4 @@ Progress: 0% battle.c:3078: Element size: 4 bytes battle.c:3078: Number of elements: 16 battle.c:3078: Created at: malloc.c, line 23 - battle.c:3078: Storage class: heap - + battle.c:3078: Storage class: heap \ No newline at end of file diff --git a/db/mob_avail.txt b/db/mob_avail.txt index 0a079b507..1220dba3a 100644 --- a/db/mob_avail.txt +++ b/db/mob_avail.txt @@ -9,8 +9,12 @@ //1002,1039 //Poring,Baphomet (Make Porings look like Baphomet) // eAthena Dev Team +// Valaris 1900,12,1,1,1,16,0,67,12,54,16,1 +// Valaris Worshiping 1901,6,1,1,1,1,2,67,12,54,0,1 +// MC Cameri +1902,14,1,6,6,16,14,0,0,0,32,3 1920,1047,0 1921,1093,0 diff --git a/db/mob_db.txt b/db/mob_db.txt index f2d51b7bf..8bd0d26e5 100644 --- a/db/mob_db.txt +++ b/db/mob_db.txt @@ -522,6 +522,7 @@ 1587,KRABEN,Kraben,1,50,0,2,1,1,7,10,0,5,1,1,1,1,6,30,10,12,1,3,21,131,400,1872,672,480,909,7000,1202,100,938,400,512,1000,713,1500,741,5,619,20,4001,20,0,0,0,0,0,0,0,0,, 1900,VALARIS,Valaris,99,668000,0,107250,37895,1,440,510,35,45,1,152,96,85,120,95,10,10,0,7,67,181,100,676,1152,768,1466,200,2256,200,2607,800,714,500,617,3000,984,4300,985,5600,4147,1,13000,0,608,1000,750,400,923,3800,, 1901,VALARIS_WORSHIPPER,Valaris's Worshipper,50,8578,0,2706,1480,1,260,310,15,25,1,75,55,1,93,45,10,12,0,7,27,149,100,868,480,120,923,500,984,63,1464,2,607,50,610,100,503,300,2405,50,4129,1,0,0,0,0,0,0,0,0,, +1902,MC_CAMERI,MC Cameri,99,668000,0,107250,37895,1,440,510,35,45,1,152,96,85,120,95,10,10,0,7,67,181,100,676,1152,768,1466,200,2256,200,2607,800,714,500,617,3000,984,4300,985,5600,4147,1,13000,0,608,1000,750,400,923,3800,, 1920,EASTER_EGG,Easter Egg,3,300,0,4,4,0,1,2,20,20,1,1,1,1,1,20,10,12,0,0,60,128,1000,1001,1,1,1010,250,935,500,558,300,501,200,501,200,713,800,558,300,558,300,0,0,0,0,0,0,0,0,, 1921,EASTER_BUNNY,Easter Bunny,6,1800,0,60,55,1,20,26,0,40,1,36,6,1,11,80,10,10,0,2,60,181,200,1456,456,336,2250,200,515,8000,727,1200,746,1500,706,30,622,50,534,5000,4006,70,0,0,0,0,0,0,0,0,, 1970,PORING_,Poring,1,50,0,2,1,1,7,10,0,5,1,1,1,1,6,30,10,12,1,3,21,131,400,1872,672,480,909,7000,1202,100,938,400,512,1000,713,1500,741,5,619,20,4001,20,0,0,0,0,0,0,0,0,, diff --git a/db/mob_skill_db.txt b/db/mob_skill_db.txt index a3c12702d..f40adeb67 100644 --- a/db/mob_skill_db.txt +++ b/db/mob_skill_db.txt @@ -1996,6 +1996,8 @@ Only place specification skill is good for a round system. friend is good only o 1900,Grimtooth,chase,137,5,2500,0,0,no,target,always,0,,,,,, // Valaris's Worshipper 1901,Envenom,attack,52,10,500,0,10000,no,target,always,0,,,,,, +// MC Cameri + // Easter Bunny 1921,Summon Minions,attack,196,5,1000,3000,10000,no,self,slavele,2,1063,,,,, diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 3488926bf..857a819bb 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -21,11 +21,9 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri case MSG_STATUS: //Bright Green (To inform about good things) strcpy(prefix,CL_GREEN"[Status]"CL_RESET":"); break; -/* //Do we really need this now? [MC Cameri] case MSG_SQL: //Bright Violet (For dumping out anything related with SQL) strcpy(prefix,CL_MAGENTA"[SQL]"CL_RESET":"); break; -*/ case MSG_INFORMATION: //Bright White (Variable information) strcpy(prefix,CL_WHITE"[Info]"CL_RESET":"); break; @@ -49,18 +47,18 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri return 1; } if (!(flag == MSG_DEBUG && !SHOW_DEBUG_MSG)) { - output = (char*)malloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // +2: space and a \0 - if (output == NULL) { - return 1; -// exit(1); // Kill server? Deadly - } - - strcpy(output,prefix); - strcat(output," "); - strcat(output,string); - printf(output); - fflush(stdout); - free(output); + output = (char*)malloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // prefix+string+two chars(space and \0) + if (output == NULL) { + return 1; +// exit(1); // Kill server? Deadly + } + + strcpy(output,prefix); + strcat(output," "); + strcat(output,string); + printf(output); + fflush(stdout); + free(output); } /* if ((core_config.debug_output_level > -1) && (flag >= core_config.debug_output_level)) { diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 2d40255fb..0949d08e4 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -18,7 +18,7 @@ extern char tmp_output[1024]; -enum msg_type {MSG_STATUS,/* MSG_SQL, */MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_DEBUG,MSG_ERROR,MSG_FATALERROR}; +enum msg_type {MSG_STATUS, MSG_SQL, MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_DEBUG,MSG_ERROR,MSG_FATALERROR}; extern int _ShowMessage(const char *string, enum msg_type flag); @@ -32,7 +32,7 @@ extern int _ShowMessage(const char *string, enum msg_type flag); // #define DisplayStatus(string) _ShowMessage(string,MSG_STATUS) /* MSG_SQL*/ -// #define ShowSQL(string) _ShowMessage(string,MSG_SQL) + #define ShowSQL(string) _ShowMessage(string,MSG_SQL) // #define DisplaySQL(string) _ShowMessage(string,MSG_SQL) /* MSG_INFORMATION */ diff --git a/src/map/map.c b/src/map/map.c index cb3a3a0a9..d89bf424d 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2325,7 +2325,8 @@ int sql_config_read(char *cfgName) fp=fopen(cfgName,"r"); if(fp==NULL){ - printf("file not found: %s\n",cfgName); + snprintf(tmp_output,sizeof(tmp_output),"File not found: '%s'.\n",cfgName); + ShowError(tmp_output); return 1; } while(fgets(line,1020,fp)){ @@ -2355,19 +2356,19 @@ int sql_config_read(char *cfgName) //Map Server SQL DB } else if(strcmpi(w1,"map_server_ip")==0){ strcpy(map_server_ip, w2); - printf ("set map_server_ip : %s\n",w2); +// printf ("set map_server_ip : %s\n",w2); } else if(strcmpi(w1,"map_server_port")==0){ map_server_port=atoi(w2); - printf ("set map_server_port : %s\n",w2); +// printf ("set map_server_port : %s\n",w2); } else if(strcmpi(w1,"map_server_id")==0){ strcpy(map_server_id, w2); - printf ("set map_server_id : %s\n",w2); +// printf ("set map_server_id : %s\n",w2); } else if(strcmpi(w1,"map_server_pw")==0){ strcpy(map_server_pw, w2); - printf ("set map_server_pw : %s\n",w2); +// printf ("set map_server_pw : %s\n",w2); } else if(strcmpi(w1,"map_server_db")==0){ strcpy(map_server_db, w2); - printf ("set map_server_db : %s\n",w2); +// printf ("set map_server_db : %s\n",w2); //Map server option to use SQL db or not } else if(strcmpi(w1,"use_sql_db")==0){ if (strcmpi(w2,"yes")){db_use_sqldbs=0;} else if (strcmpi(w2,"no")){db_use_sqldbs=1;} @@ -2375,25 +2376,25 @@ int sql_config_read(char *cfgName) //Login Server SQL DB } else if(strcmpi(w1,"login_server_ip")==0){ strcpy(login_server_ip, w2); - printf ("set login_server_ip : %s\n",w2); +// printf ("set login_server_ip : %s\n",w2); } else if(strcmpi(w1,"login_server_port")==0){ login_server_port = atoi(w2); - printf ("set login_server_port : %s\n",w2); +// printf ("set login_server_port : %s\n",w2); } else if(strcmpi(w1,"login_server_id")==0){ strcpy(login_server_id, w2); - printf ("set login_server_id : %s\n",w2); +// printf ("set login_server_id : %s\n",w2); } else if(strcmpi(w1,"login_server_pw")==0){ strcpy(login_server_pw, w2); - printf ("set login_server_pw : %s\n",w2); +// printf ("set login_server_pw : %s\n",w2); } else if(strcmpi(w1,"login_server_db")==0){ strcpy(login_server_db, w2); - printf ("set login_server_db : %s\n",w2); +// printf ("set login_server_db : %s\n",w2); } else if(strcmpi(w1,"lowest_gm_level")==0){ lowest_gm_level = atoi(w2); - printf ("set lowest_gm_level : %s\n",w2); +// printf ("set lowest_gm_level : %s\n",w2); } else if(strcmpi(w1,"read_gm_interval")==0){ read_gm_interval = ( atoi(w2) * 60 * 1000 ); // Minutes multiplied by 60 secs per min by 1000 milliseconds per second - printf ("set read_gm_interval : %s\n",w2); +// printf ("set read_gm_interval : %s\n",w2); } else if(strcmpi(w1,"log_db")==0) { strcpy(log_db, w2); } else if(strcmpi(w1,"log_db_ip")==0) { @@ -2567,7 +2568,7 @@ void map_helpscreen(int flag) { puts("Usage: map-server [options]"); puts("Options:"); puts(CL_WHITE" Commands\t\t\tDescription"CL_RESET); - puts("---------------------------------------------"); + puts("-----------------------------------------------------------------------------"); puts(" --help, --h, --?, /? Displays this help screen"); puts(" --map-config Load map-server configuration from "); puts(" --battle-config Load battle configuration from "); -- cgit v1.2.3-70-g09d2 From 612a264f1dfa99ff5ee6484139c115200f4bc179 Mon Sep 17 00:00:00 2001 From: celest Date: Fri, 1 Apr 2005 08:36:28 +0000 Subject: * Updated ShowMessage functions to use vprintf git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1372 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/showmsg.c | 10 ++++- src/common/showmsg.h | 114 ++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 93 insertions(+), 31 deletions(-) (limited to 'src/common/showmsg.h') diff --git a/src/common/showmsg.c b/src/common/showmsg.c index ddaae3a52..5587e8658 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -1,12 +1,13 @@ #include #include #include +#include #include "showmsg.h" #include "malloc.h" char tmp_output[1024] = {"\0"}; -int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri +int _ShowMessage(enum msg_type flag, const char *string, ...){ // by MC Cameri /* _ShowMessage MUST be used instead of printf as of 10/24/2004. Return: 0 = Successful, 1 = Failed. @@ -14,6 +15,9 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri // int ret = 0; char prefix[40]; char *output; + va_list ap; + + va_start(ap, string); if (strlen(string) <= 0) { ShowError("Empty string passed to _ShowMessage().\n"); return 1; @@ -57,10 +61,12 @@ int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri strcpy(output,prefix); strcat(output," "); strcat(output,string); - printf(output); + vprintf(output, ap); fflush(stdout); aFree(output); } + + va_end(ap); /* if ((core_config.debug_output_level > -1) && (flag >= core_config.debug_output_level)) { FILE *fp; diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 0949d08e4..2574c3adf 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -20,52 +20,108 @@ extern char tmp_output[1024]; enum msg_type {MSG_STATUS, MSG_SQL, MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_DEBUG,MSG_ERROR,MSG_FATALERROR}; -extern int _ShowMessage(const char *string, enum msg_type flag); +extern int _ShowMessage(enum msg_type flag, const char *string, ...); +#if __GNUC__ >= 2 +/* GCC用 */ /* MSG_XX */ - #define ShowMsg(string,flag) _ShowMessage(string,flag) -// #define DisplayMsg(string,flag) _ShowMessage(string,flag) -// #define ShowMessage(string,flag) _ShowMessage(string,flag) + #define ShowMsg(flag,string...) _ShowMessage(flag, ## string) +// #define DisplayMsg(flag,string,...) _ShowMessage(flag, ## string) +// #define ShowMessage(flag,string,...) _ShowMessage(flag, ## string) /* MSG_STATUS */ - #define ShowStatus(string) _ShowMessage(string,MSG_STATUS) -// #define DisplayStatus(string) _ShowMessage(string,MSG_STATUS) + #define ShowStatus(string...) _ShowMessage(MSG_STATUS, ## string) +// #define DisplayStatus(string...) _ShowMessage(MSG_STATUS, ## string) /* MSG_SQL*/ - #define ShowSQL(string) _ShowMessage(string,MSG_SQL) -// #define DisplaySQL(string) _ShowMessage(string,MSG_SQL) + #define ShowSQL(string...) _ShowMessage(MSG_SQL, ## string) +// #define DisplaySQL(string...) _ShowMessage(MSG_SQL, ## string) /* MSG_INFORMATION */ - #define ShowInfo(string) _ShowMessage(string,MSG_INFORMATION) -// #define DisplayInfo(string) _ShowMessage(string,MSG_INFORMATION) -// #define ShowInformation(string) _ShowMessage(string,MSG_INFORMATION) -// #define DisplayInformation(string) _ShowMessage(string,MSG_INFORMATION) + #define ShowInfo(string...) _ShowMessage(MSG_INFORMATION, ## string) +// #define DisplayInfo(string...) _ShowMessage(MSG_INFORMATION, ## string) +// #define ShowInformation(string...) _ShowMessage(MSG_INFORMATION, ## string) +// #define DisplayInformation(string...) _ShowMessage(MSG_INFORMATION, ## string) /* MSG_NOTICE */ - #define ShowNotice(string) _ShowMessage(string,MSG_NOTICE) -// #define DisplayNotice(string) _ShowMessage(string,MSG_NOTICE) + #define ShowNotice(string...) _ShowMessage(MSG_NOTICE, ## string) +// #define DisplayNotice(string...) _ShowMessage(MSG_NOTICE, ## string) /* MSG_WARNING */ - #define ShowWarning(string) _ShowMessage(string,MSG_WARNING) -// #define DisplayWarning(string) _ShowMessage(string,MSG_WARNING) -// #define Warn(string) _ShowMessage(string,MSG_WARNING) + #define ShowWarning(string...) _ShowMessage(MSG_WARNING, ## string) +// #define DisplayWarning(string...) _ShowMessage(MSG_WARNING, ## string) +// #define Warn(string...) _ShowMessage(MSG_WARNING, ## string) /* MSG_DEBUG */ - #define ShowDebug(string) _ShowMessage(string,MSG_DEBUG) - #define DisplayDebug(string) _ShowMessage(string,MSG_DEBUG) - #define Debug(string) _ShowMessage(string,MSG_DEBUG) - #define printDebug() _ShowMessage(striing,MSG_DEBUG) + #define ShowDebug(string...) _ShowMessage(MSG_DEBUG, ## string) +// #define DisplayDebug(string,...) _ShowMessage(MSG_DEBUG, ## string) +// #define Debug(string,...) _ShowMessage(MSG_DEBUG, ## string) +// #define printDebug() _ShowMessage(MSG_DEBUG, ## string) /* MSG_ERROR */ - #define ShowError(string) _ShowMessage(string,MSG_ERROR) -// #define DisplayError(string) _ShowMessage(string,MSG_ERROR) -// #define OutputError(string) _ShowMessage(string,MSG_ERROR) + #define ShowError(string...) _ShowMessage(MSG_ERROR, ## string) +// #define DisplayError(string...) _ShowMessage(MSG_ERROR, ## string) +// #define OutputError(string...) _ShowMessage(MSG_ERROR, ## string) /* MSG_FATALERROR */ - #define ShowFatalError(string) _ShowMessage(string,MSG_FATALERROR) -// #define DisplayFatalError(string) _ShowMessage(string,MSG_ERROR) -// #define Terminate(string) _ShowMessage(string,MSG_FATALERROR) -// #define Kill(string) _ShowMessage(string,MSG_FATALERROR) -// #define AbortEx(string) _ShowMessage(string,MSG_FATALERROR) + #define ShowFatalError(string...) _ShowMessage(MSG_FATALERROR, ## string) +// #define DisplayFatalError(string...) _ShowMessage(MSG_ERROR, ## string) +// #define Terminate(string...) _ShowMessage(MSG_FATALERROR, ## string) +// #define Kill(string...) _ShowMessage(MSG_FATALERROR, ## string) +// #define AbortEx(string...) _ShowMessage(MSG_FATALERROR, ## string) + +// 可変引数マクロに関する条件コンパイル +#elif __STDC_VERSION__ >= 199901L +/* C99に対応 */ + +/* MSG_XX */ + #define ShowMsg(flag,string...) _ShowMessage(flag, string, __VA_ARGS__) +// #define DisplayMsg(flag,string,...) _ShowMessage(flag, string, __VA_ARGS__) +// #define ShowMessage(flag,string,...) _ShowMessage(flag, string, __VA_ARGS__) + +/* MSG_STATUS */ + #define ShowStatus(string...) _ShowMessage(MSG_STATUS, string, __VA_ARGS__) +// #define DisplayStatus(string...) _ShowMessage(MSG_STATUS, string, __VA_ARGS__) + +/* MSG_SQL*/ + #define ShowSQL(string...) _ShowMessage(MSG_SQL, string, __VA_ARGS__) +// #define DisplaySQL(string...) _ShowMessage(MSG_SQL, string, __VA_ARGS__) + +/* MSG_INFORMATION */ + #define ShowInfo(string...) _ShowMessage(MSG_INFORMATION, string, __VA_ARGS__) +// #define DisplayInfo(string...) _ShowMessage(MSG_INFORMATION, string, __VA_ARGS__) +// #define ShowInformation(string...) _ShowMessage(MSG_INFORMATION, string, __VA_ARGS__) +// #define DisplayInformation(string...) _ShowMessage(MSG_INFORMATION, string, __VA_ARGS__) + +/* MSG_NOTICE */ + #define ShowNotice(string...) _ShowMessage(MSG_NOTICE, string, __VA_ARGS__) +// #define DisplayNotice(string...) _ShowMessage(MSG_NOTICE, string, __VA_ARGS__) + +/* MSG_WARNING */ + #define ShowWarning(string...) _ShowMessage(MSG_WARNING, string, __VA_ARGS__) +// #define DisplayWarning(string...) _ShowMessage(MSG_WARNING, string, __VA_ARGS__) +// #define Warn(string...) _ShowMessage(MSG_WARNING, string, __VA_ARGS__) + +/* MSG_DEBUG */ + #define ShowDebug(string...) _ShowMessage(MSG_DEBUG, MSGSTRING) +// #define DisplayDebug(string,...) _ShowMessage(MSG_DEBUG, string, __VA_ARGS__) +// #define Debug(string,...) _ShowMessage(MSG_DEBUG, string, __VA_ARGS__) +// #define printDebug() _ShowMessage(MSG_DEBUG, string, __VA_ARGS__) + +/* MSG_ERROR */ + #define ShowError(string...) _ShowMessage(MSG_ERROR, string, __VA_ARGS__) +// #define DisplayError(string...) _ShowMessage(MSG_ERROR, string, __VA_ARGS__) +// #define OutputError(string...) _ShowMessage(MSG_ERROR, string, __VA_ARGS__) + +/* MSG_FATALERROR */ + #define ShowFatalError(string...) _ShowMessage(MSG_FATALERROR, string, __VA_ARGS__) +// #define DisplayFatalError(string...) _ShowMessage(MSG_ERROR, string, __VA_ARGS__) +// #define Terminate(string...) _ShowMessage(MSG_FATALERROR, string, __VA_ARGS__) +// #define Kill(string...) _ShowMessage(MSG_FATALERROR, string, __VA_ARGS__) +// #define AbortEx(string...) _ShowMessage(MSG_FATALERROR, string, __VA_ARGS__) + +#else + +#endif #endif -- cgit v1.2.3-70-g09d2 From a25a0d3cb865e0f4669103884a7fa56767249dd6 Mon Sep 17 00:00:00 2001 From: amber Date: Mon, 4 Apr 2005 17:12:05 +0000 Subject: update build failure git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1400 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/showmsg.h | Bin 5256 -> 5307 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'src/common/showmsg.h') diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 2574c3adf..331b5f484 100644 Binary files a/src/common/showmsg.h and b/src/common/showmsg.h differ -- cgit v1.2.3-70-g09d2 From 2af1c6baaaf4a2f839da26bfd88dd3e629623c79 Mon Sep 17 00:00:00 2001 From: amber Date: Mon, 4 Apr 2005 17:45:11 +0000 Subject: Fix show message git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1401 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 1 + src/common/showmsg.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++---- src/common/showmsg.h | Bin 5307 -> 906 bytes 3 files changed, 64 insertions(+), 5 deletions(-) (limited to 'src/common/showmsg.h') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index de6743659..0addf0c4c 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -2,6 +2,7 @@ Date Added 04/04 + * Fix showmsg for Visual Studio [MouseJstr] * Update base code for the UPNP plugin loading [celest] * Removed anti-freeze system for login and char -- Shinomori's update would be enough to keep inter connections alive [celest] diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 5587e8658..da21ad1e6 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -7,7 +7,10 @@ char tmp_output[1024] = {"\0"}; -int _ShowMessage(enum msg_type flag, const char *string, ...){ // by MC Cameri +#undef ShowMessage + +int _vShowMessage(enum msg_type flag, const char *string, va_list ap) +{ // by MC Cameri /* _ShowMessage MUST be used instead of printf as of 10/24/2004. Return: 0 = Successful, 1 = Failed. @@ -15,11 +18,9 @@ int _ShowMessage(enum msg_type flag, const char *string, ...){ // by MC Cameri // int ret = 0; char prefix[40]; char *output; - va_list ap; - va_start(ap, string); if (strlen(string) <= 0) { - ShowError("Empty string passed to _ShowMessage().\n"); + printf("Empty string passed to _ShowMessage().\n"); return 1; } switch (flag) { @@ -48,7 +49,7 @@ int _ShowMessage(enum msg_type flag, const char *string, ...){ // by MC Cameri strcpy(prefix,CL_RED"[Fatal Error]"CL_RESET":"); break; default: - ShowError("In function _ShowMessage() -> Invalid flag passed.\n"); + printf("In function _ShowMessage() -> Invalid flag passed.\n"); return 1; } if (!(flag == MSG_DEBUG && !SHOW_DEBUG_MSG)) { @@ -84,3 +85,60 @@ int _ShowMessage(enum msg_type flag, const char *string, ...){ // by MC Cameri */ return 0; } + +int _ShowMessage(enum msg_type flag, const char *string, ...) +{ + va_list ap; + + va_start(ap, string); + return _vShowMessage(flag, string, ap); +} + +int ShowStatus(const char *string, ...) { + va_list ap; + + va_start(ap, string); + return _vShowMessage(MSG_STATUS, string, ap); +} +int ShowSQL(const char *string, ...) { + va_list ap; + + va_start(ap, string); + return _vShowMessage(MSG_SQL, string, ap); +} +int ShowInfo(const char *string, ...) { + va_list ap; + + va_start(ap, string); + return _vShowMessage(MSG_INFORMATION, string, ap); +} +int ShowNotice(const char *string, ...) { + va_list ap; + + va_start(ap, string); + return _vShowMessage(MSG_NOTICE, string, ap); +} +int ShowWarning(const char *string, ...) { + va_list ap; + + va_start(ap, string); + return _vShowMessage(MSG_WARNING, string, ap); +} +int ShowDebug(const char *string, ...) { + va_list ap; + + va_start(ap, string); + return _vShowMessage(MSG_DEBUG, string, ap); +} +int ShowError(const char *string, ...) { + va_list ap; + + va_start(ap, string); + return _vShowMessage(MSG_ERROR, string, ap); +} +int ShowFatalError(const char *string, ...) { + va_list ap; + + va_start(ap, string); + return _vShowMessage(MSG_FATALERROR, string, ap); +} diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 331b5f484..5b169dc82 100644 Binary files a/src/common/showmsg.h and b/src/common/showmsg.h differ -- cgit v1.2.3-70-g09d2 From 6acbd82fb5b77315853f42a9a31b7439a7e58bb9 Mon Sep 17 00:00:00 2001 From: amber Date: Mon, 4 Apr 2005 19:32:34 +0000 Subject: Fixes for logging trades [MouseJstr] git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1407 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-SVN.txt | 1 + README.win32 | 32 ++++++++ src/common/showmsg.h | 14 ++++ src/map/log.c | 204 +++++++++++++++++++++++++++++++++++---------------- src/map/log.h | 7 +- src/map/storage.c | 14 ++-- src/map/trade.c | 10 ++- 7 files changed, 210 insertions(+), 72 deletions(-) create mode 100644 README.win32 (limited to 'src/common/showmsg.h') diff --git a/Changelog-SVN.txt b/Changelog-SVN.txt index 34cbde33b..5af79523c 100644 --- a/Changelog-SVN.txt +++ b/Changelog-SVN.txt @@ -2,6 +2,7 @@ Date Added 04/04 + * Some work on re-enabling trade and storage logging [MouseJstr] * Updated showmsg with Shinomori's improvements [celest] * Fix showmsg for Visual Studio [MouseJstr] * Update base code for the UPNP plugin loading [celest] diff --git a/README.win32 b/README.win32 new file mode 100644 index 000000000..16a8c9524 --- /dev/null +++ b/README.win32 @@ -0,0 +1,32 @@ + Building eAthena under win32 + +There are currently two ways to build eAthena. The first and oldest way is by using cygwin (www.cygwin.org). This was the only way until the svn 1370 timeframe. The second way is by using Visual Studio .NET 2003. + +Building using cygwin: + + 1) delete every copy of cygwin1.dll on your system + 2) Go to www.cygwin.com and run the setup.exe. + 3) install gcc, make, bash, g++, and gdb. Basically install + all developer tools if possible. If later you find you are + missing something, re-run the setup and install that + 4) make sure the ../bin of wherever you installed cygwin to is in your + path. ie, if you put cygwin in C:/cygwin then add c:/cygwin/bin + to your path + 5) return to this directory and type "make txt" + +Building using Visual Studio .NET 2003 + + 1) Make sure you have the platform SDK installed when you install + this. If you don't have it, you can go to microsoft and download a + copy. + 2) open the eAthena.sln file + 3) Build the components you wish.. + + if you wish mysql support (http://dev.mysql.com/), grab a windows + install of mysql + + http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-4.1.10a-win32.zip/from/pick#mirrors + + and install it into the default location on the C drive. This will + best match how I set up the solutions/project files + diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 5b169dc82..3461369c3 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -4,6 +4,19 @@ //davidsiaw, 'lookee' here! #define SHOW_DEBUG_MSG 1 +#ifdef _WIN32 +#define CL_RESET "" +#define CL_NORMAL CL_RESET +#define CL_NONE CL_RESET +#define CL_WHITE "" +#define CL_GRAY "" +#define CL_RED "" +#define CL_GREEN "" +#define CL_YELLOW "" +#define CL_BLUE "" +#define CL_MAGENTA "" +#define CL_CYAN "" +#else #define CL_RESET "\033[0;0m" #define CL_NORMAL CL_RESET #define CL_NONE CL_RESET @@ -15,6 +28,7 @@ #define CL_BLUE "\033[1;34m" #define CL_MAGENTA "\033[1;35m" #define CL_CYAN "\033[1;36m" +#endif extern char tmp_output[1024]; diff --git a/src/map/log.c b/src/map/log.c index 417d2dcbc..833fb8b16 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -56,15 +56,15 @@ int should_log_item(int nameid) { int log_branch(struct map_session_data *sd) { - #ifndef TXT_ONLY +#ifndef TXT_ONLY char t_name[100]; - #endif +#endif FILE *logfp; if(log_config.enable_logs <= 0) return 0; nullpo_retr(0, sd); - #ifndef TXT_ONLY +#ifndef TXT_ONLY if(log_config.sql_logs > 0) { sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%s')", @@ -72,16 +72,16 @@ int log_branch(struct map_session_data *sd) if(mysql_query(&mmysql_handle, tmp_sql)) printf("DB server Error - %s\n",mysql_error(&mmysql_handle)); } else { - #endif +#endif if((logfp=fopen(log_config.log_branch,"a+")) != NULL) { time(&curtime); strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp,"%s - %s[%d:%d]\t%s%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, sd->mapname, RETCODE); fclose(logfp); } - #ifndef TXT_ONLY +#ifndef TXT_ONLY } - #endif +#endif return 0; } @@ -98,14 +98,14 @@ int log_drop(struct map_session_data *sd, int monster_id, int *log_drop) } if (flag==0) return 0; //we skip logging this items set - they doesn't met our logging conditions [Lupus] - #ifndef TXT_ONLY +#ifndef TXT_ONLY if(log_config.sql_logs > 0) { sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`drop_date`, `kill_char_id`, `monster_id`, `item1`, `item2`, `item3`, `item4`, `item5`, `item6`, `item7`, `item8`, `item9`, `itemCard`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s') ", log_config.log_drop_db, sd->status.char_id, monster_id, log_drop[0], log_drop[1], log_drop[2], log_drop[3], log_drop[4], log_drop[5], log_drop[6], log_drop[7], log_drop[8], log_drop[9], sd->mapname); if(mysql_query(&mmysql_handle, tmp_sql)) printf("DB server Error - %s\n",mysql_error(&mmysql_handle)); } else { - #endif +#endif if((logfp=fopen(log_config.log_drop,"a+")) != NULL) { @@ -115,9 +115,9 @@ int log_drop(struct map_session_data *sd, int monster_id, int *log_drop) fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, log_drop[0], log_drop[1], log_drop[2], log_drop[3], log_drop[4], log_drop[5], log_drop[6], log_drop[7], log_drop[8], log_drop[9], RETCODE); fclose(logfp); } - #ifndef TXT_ONLY +#ifndef TXT_ONLY } - #endif +#endif return 1; //Logged } @@ -128,37 +128,37 @@ int log_mvpdrop(struct map_session_data *sd, int monster_id, int *log_mvp) if(log_config.enable_logs <= 0) return 0; nullpo_retr(0, sd); - #ifndef TXT_ONLY +#ifndef TXT_ONLY if(log_config.sql_logs > 0) { sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", log_config.log_mvpdrop_db, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], sd->mapname); if(mysql_query(&mmysql_handle, tmp_sql)) printf("DB server Error - %s\n",mysql_error(&mmysql_handle)); } else { - #endif +#endif if((logfp=fopen(log_config.log_mvpdrop,"a+")) != NULL) { time(&curtime); strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], RETCODE); fclose(logfp); } - #ifndef TXT_ONLY +#ifndef TXT_ONLY } - #endif +#endif return 0; } int log_present(struct map_session_data *sd, int source_type, int nameid) { FILE *logfp; - #ifndef TXT_ONLY +#ifndef TXT_ONLY char t_name[100]; - #endif +#endif if(log_config.enable_logs <= 0) return 0; nullpo_retr(0, sd); - #ifndef TXT_ONLY +#ifndef TXT_ONLY if(log_config.sql_logs > 0) { sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`present_date`, `src_id`, `account_id`, `char_id`, `char_name`, `nameid`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%s', '%d', '%s') ", @@ -166,30 +166,30 @@ int log_present(struct map_session_data *sd, int source_type, int nameid) if(mysql_query(&mmysql_handle, tmp_sql)) printf("DB server Error - %s\n",mysql_error(&mmysql_handle)); } else { - #endif +#endif if((logfp=fopen(log_config.log_present,"a+")) != NULL) { time(&curtime); strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, source_type, nameid, RETCODE); fclose(logfp); } - #ifndef TXT_ONLY +#ifndef TXT_ONLY } - #endif +#endif return 0; } int log_produce(struct map_session_data *sd, int nameid, int slot1, int slot2, int slot3, int success) { FILE *logfp; - #ifndef TXT_ONLY +#ifndef TXT_ONLY char t_name[100]; - #endif +#endif if(log_config.enable_logs <= 0) return 0; nullpo_retr(0, sd); - #ifndef TXT_ONLY +#ifndef TXT_ONLY if(log_config.sql_logs > 0) { sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`produce_date`, `account_id`, `char_id`, `char_name`, `nameid`, `slot1`, `slot2`, `slot3`, `map`, `success`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%s', '%d') ", @@ -197,16 +197,16 @@ int log_produce(struct map_session_data *sd, int nameid, int slot1, int slot2, i if(mysql_query(&mmysql_handle, tmp_sql)) printf("DB server Error - %s\n",mysql_error(&mmysql_handle)); } else { - #endif +#endif if((logfp=fopen(log_config.log_produce,"a+")) != NULL) { time(&curtime); strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d,%d\t%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, nameid, slot1, slot2, slot3, success, RETCODE); fclose(logfp); } - #ifndef TXT_ONLY +#ifndef TXT_ONLY } - #endif +#endif return 0; } @@ -216,9 +216,9 @@ int log_refine(struct map_session_data *sd, int n, int success) int log_card[4]; int item_level; int i; - #ifndef TXT_ONLY +#ifndef TXT_ONLY char t_name[100]; - #endif +#endif if(log_config.enable_logs <= 0) return 0; @@ -233,7 +233,7 @@ int log_refine(struct map_session_data *sd, int n, int success) for(i=0;i<4;i++) log_card[i] = sd->status.inventory[n].card[i]; - #ifndef TXT_ONLY +#ifndef TXT_ONLY if(log_config.sql_logs > 0) { sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`refine_date`, `account_id`, `char_id`, `char_name`, `nameid`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `success`, `item_level`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%d', '%d')", @@ -241,27 +241,89 @@ int log_refine(struct map_session_data *sd, int n, int success) if(mysql_query(&mmysql_handle, tmp_sql)) printf("DB server Error - %s\n",mysql_error(&mmysql_handle)); } else { - #endif +#endif if((logfp=fopen(log_config.log_refine,"a+")) != NULL) { time(&curtime); strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp,"%s - %s[%d:%d]\t%d,%d\t%d%d%d%d\t%d,%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, sd->status.inventory[n].nameid, sd->status.inventory[n].refine, log_card[0], log_card[1], log_card[2], log_card[3], success, item_level, RETCODE); fclose(logfp); } - #ifndef TXT_ONLY +#ifndef TXT_ONLY } - #endif +#endif return 0; } +int log_tostorage(struct map_session_data *sd,int n, int guild) +{ + FILE *logfp; + + if(log_config.enable_logs <= 0 || log_config.storage == 0 || log_config.log_storage[0] == '\0') + return 0; + + nullpo_retr(0, sd); + + if(sd->status.inventory[n].nameid==0 || sd->inventory_data[n] == NULL) + return 1; + + if(sd->status.inventory[n].amount < 0) + return 1; + + if((logfp=fopen(log_config.log_trade,"a+")) != NULL) { + time(&curtime); + strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); + fprintf(logfp,"%s - to %s: %s[%d:%d]\t%d\t%d\t%d\t%d,%d,%d,%d%s", timestring, guild ? "guild_storage": "storage", sd->status.name, sd->status.account_id, sd->status.char_id, + sd->status.inventory[n].nameid, + sd->status.inventory[n].amount, + sd->status.inventory[n].refine, + sd->status.inventory[n].card[0], + sd->status.inventory[n].card[1], + sd->status.inventory[n].card[2], + sd->status.inventory[n].card[3], RETCODE); + fclose(logfp); + } + return 0; +} + +int log_fromstorage(struct map_session_data *sd,int n, int guild) +{ + FILE *logfp; + + if(log_config.enable_logs <= 0 || log_config.storage == 0 || log_config.log_storage[0] == '\0') + return 0; + + nullpo_retr(0, sd); + + if(sd->status.inventory[n].nameid==0 || sd->inventory_data[n] == NULL) + return 1; + + if(sd->status.inventory[n].amount < 0) + return 1; + + if((logfp=fopen(log_config.log_trade,"a+")) != NULL) { + time(&curtime); + strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); + fprintf(logfp,"%s - from %s: %s[%d:%d]\t%d\t%d\t%d\t%d,%d,%d,%d%s", timestring, guild ? "guild_storage": "storage", sd->status.name, sd->status.account_id, sd->status.char_id, + sd->status.inventory[n].nameid, + sd->status.inventory[n].amount, + sd->status.inventory[n].refine, + sd->status.inventory[n].card[0], + sd->status.inventory[n].card[1], + sd->status.inventory[n].card[2], + sd->status.inventory[n].card[3], RETCODE); + fclose(logfp); + } + return 0; +} + int log_trade(struct map_session_data *sd, struct map_session_data *target_sd, int n,int amount) { FILE *logfp; int log_nameid, log_amount, log_refine, log_card[4]; int i; - #ifndef TXT_ONLY +#ifndef TXT_ONLY char t_name[100],t_name2[100]; - #endif +#endif if(log_config.enable_logs <= 0) return 0; @@ -281,7 +343,7 @@ int log_trade(struct map_session_data *sd, struct map_session_data *target_sd, i for(i=0;i<4;i++) log_card[i] = sd->status.inventory[n].card[i]; - #ifndef TXT_ONLY +#ifndef TXT_ONLY if(log_config.sql_logs > 0) { sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`trade_date`, `src_account_id`, `src_char_id`, `src_char_name`, `des_account_id`, `des_char_id`, `des_char_name`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')", @@ -289,16 +351,16 @@ int log_trade(struct map_session_data *sd, struct map_session_data *target_sd, i if(mysql_query(&mmysql_handle, tmp_sql)) printf("DB server Error - %s\n",mysql_error(&mmysql_handle)); } else { - #endif +#endif if((logfp=fopen(log_config.log_trade,"a+")) != NULL) { time(&curtime); strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp,"%s - %s[%d:%d]\t%s[%d:%d]\t%d\t%d\t%d\t%d,%d,%d,%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, target_sd->status.name, target_sd->status.account_id, target_sd->status.char_id, log_nameid, log_amount, log_refine, log_card[0], log_card[1], log_card[2], log_card[3], RETCODE); fclose(logfp); } - #ifndef TXT_ONLY +#ifndef TXT_ONLY } - #endif +#endif return 0; } @@ -307,9 +369,9 @@ int log_vend(struct map_session_data *sd,struct map_session_data *vsd,int n,int FILE *logfp; int log_nameid, log_amount, log_refine, log_card[4]; int i; - #ifndef TXT_ONLY +#ifndef TXT_ONLY char t_name[100],t_name2[100]; - #endif +#endif if(log_config.enable_logs <= 0) return 0; @@ -326,7 +388,7 @@ int log_vend(struct map_session_data *sd,struct map_session_data *vsd,int n,int for(i=0;i<4;i++) log_card[i] = sd->status.inventory[n].card[i]; - #ifndef TXT_ONLY +#ifndef TXT_ONLY if(log_config.sql_logs > 0) { sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`vend_date`, `vend_account_id`, `vend_char_id`, `vend_char_name`, `buy_account_id`, `buy_char_id`, `buy_char_name`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `zeny`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%d')", @@ -334,30 +396,30 @@ int log_vend(struct map_session_data *sd,struct map_session_data *vsd,int n,int if(mysql_query(&mmysql_handle, tmp_sql)) printf("DB server Error - %s\n",mysql_error(&mmysql_handle)); } else { - #endif +#endif if((logfp=fopen(log_config.log_vend,"a+")) != NULL) { time(&curtime); strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp,"%s - %s[%d:%d]\t%s[%d:%d]\t%d\t%d\t%d\t%d,%d,%d,%d\t%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, vsd->status.name, vsd->status.account_id, vsd->status.char_id, log_nameid, log_amount, log_refine, log_card[0], log_card[1], log_card[2], log_card[3], zeny, RETCODE); fclose(logfp); } - #ifndef TXT_ONLY +#ifndef TXT_ONLY } - #endif +#endif return 0; } int log_zeny(struct map_session_data *sd, struct map_session_data *target_sd,int amount) { FILE *logfp; - #ifndef TXT_ONLY +#ifndef TXT_ONLY char t_name[100],t_name2[100]; - #endif +#endif if(log_config.enable_logs <= 0) return 0; nullpo_retr(0, sd); - #ifndef TXT_ONLY +#ifndef TXT_ONLY if(log_config.sql_logs > 0) { sprintf(tmp_sql,"INSERT DELAYED INTO `%s` (`trade_date`, `src_account_id`, `src_char_id`, `src_char_name`, `des_account_id`, `des_char_id`, `des_char_name`, `map`, `zeny`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%s', '%s', '%d')", @@ -365,30 +427,30 @@ int log_zeny(struct map_session_data *sd, struct map_session_data *target_sd,int if(mysql_query(&mmysql_handle, tmp_sql)) printf("DB server Error - %s\n",mysql_error(&mmysql_handle)); } else { - #endif +#endif if((logfp=fopen(log_config.log_trade,"a+")) != NULL) { time(&curtime); strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp,"%s - %s[%d]\t%s[%d]\t%d\t%s", timestring, sd->status.name, sd->status.account_id, target_sd->status.name, target_sd->status.account_id, sd->deal_zeny, RETCODE); fclose(logfp); } - #ifndef TXT_ONLY +#ifndef TXT_ONLY } - #endif +#endif return 0; } int log_atcommand(struct map_session_data *sd, const char *message) { FILE *logfp; - #ifndef TXT_ONLY +#ifndef TXT_ONLY char t_name[100]; - #endif +#endif if(log_config.enable_logs <= 0) return 0; nullpo_retr(0, sd); - #ifndef TXT_ONLY +#ifndef TXT_ONLY if(log_config.sql_logs > 0) { sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES(NOW(), '%d', '%d', '%s', '%s', '%s') ", @@ -396,16 +458,16 @@ int log_atcommand(struct map_session_data *sd, const char *message) if(mysql_query(&mmysql_handle, tmp_sql)) printf("DB server Error - %s\n",mysql_error(&mmysql_handle)); } else { - #endif +#endif if((logfp=fopen(log_config.log_gm,"a+")) != NULL) { time(&curtime); strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp,"%s - %s[%d]: %s%s",timestring,sd->status.name,sd->status.account_id,message,RETCODE); fclose(logfp); } - #ifndef TXT_ONLY +#ifndef TXT_ONLY } - #endif +#endif return 0; } @@ -419,7 +481,7 @@ int log_npc(struct map_session_data *sd, const char *message) if(log_config.enable_logs <= 0) return 0; nullpo_retr(0, sd); - #ifndef TXT_ONLY +#ifndef TXT_ONLY if(log_config.sql_logs > 0) { sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES(NOW(), '%d', '%d', '%s', '%s', '%s') ", @@ -427,16 +489,16 @@ int log_npc(struct map_session_data *sd, const char *message) if(mysql_query(&mmysql_handle, tmp_sql)) printf("DB server Error - %s\n",mysql_error(&mmysql_handle)); } else { - #endif +#endif if((logfp=fopen(log_config.log_npc,"a+")) != NULL) { time(&curtime); strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime)); fprintf(logfp,"%s - %s[%d]: %s%s",timestring,sd->status.name,sd->status.account_id,message,RETCODE); fclose(logfp); } - #ifndef TXT_ONLY +#ifndef TXT_ONLY } - #endif +#endif return 0; } @@ -445,6 +507,8 @@ int log_config_read(char *cfgName) char line[1024], w1[1024], w2[1024]; FILE *fp; + memset(&log_config, 0, sizeof(log_config)); + if((fp = fopen(cfgName, "r")) == NULL) { printf("Log configuration file not found at: %s\n", cfgName); @@ -510,6 +574,8 @@ int log_config_read(char *cfgName) log_config.refine = (atoi(w2)); } else if(strcmpi(w1,"log_trade") == 0) { log_config.trade = (atoi(w2)); + } else if(strcmpi(w1,"log_storage") == 0) { + log_config.storage = (atoi(w2)); } else if(strcmpi(w1,"log_vend") == 0) { log_config.vend = (atoi(w2)); } else if(strcmpi(w1,"log_zeny") == 0) { @@ -523,7 +589,7 @@ int log_config_read(char *cfgName) log_config.npc = (atoi(w2)); } - #ifndef TXT_ONLY +#ifndef TXT_ONLY else if(strcmpi(w1, "log_branch_db") == 0) { strcpy(log_config.log_branch_db, w2); if(log_config.branch == 1) @@ -557,6 +623,13 @@ int log_config_read(char *cfgName) printf("and Zeny Trades"); printf(" to table `%s`\n", w2); } +// } else if(strcmpi(w1, "log_storage_db") == 0) { +// strcpy(log_config.log_storage_db, w2); +// if(log_config.storage == 1) +// { +// printf("Logging Item Storages"); +// printf(" to table `%s`\n", w2); +// } } else if(strcmpi(w1, "log_vend_db") == 0) { strcpy(log_config.log_vend_db, w2); if(log_config.vend == 1) @@ -570,7 +643,7 @@ int log_config_read(char *cfgName) if(log_config.npc > 0) printf("Logging NPC 'logmes' to table `%s`\n", w2); } - #endif +#endif else if(strcmpi(w1, "log_branch_file") == 0) { strcpy(log_config.log_branch, w2); @@ -605,6 +678,13 @@ int log_config_read(char *cfgName) printf("and Zeny Trades"); printf(" to file `%s`.txt\n", w2); } + } else if(strcmpi(w1, "log_storage_file") == 0) { + strcpy(log_config.log_storage, w2); + if(log_config.storage > 0 && log_config.sql_logs < 1) + { + printf("Logging Item Storages"); + printf(" to file `%s`.txt\n", w2); + } } else if(strcmpi(w1, "log_vend_file") == 0) { strcpy(log_config.log_vend, w2); if(log_config.vend > 0 && log_config.sql_logs < 1) diff --git a/src/map/log.h b/src/map/log.h index 1c72d3f96..f0635b826 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -16,6 +16,9 @@ int log_present(struct map_session_data *sd, int source_type, int nameid); int log_produce(struct map_session_data *sd, int nameid, int slot1, int slot2, int slot3, int success); int log_refine(struct map_session_data *sd, int n, int success); int log_trade(struct map_session_data *sd,struct map_session_data *target_sd,int n,int amount); +int log_tostorage(struct map_session_data *sd,int n, int guild); +int log_fromstorage(struct map_session_data *sd,int n, int guild); + int log_vend(struct map_session_data *sd,struct map_session_data *vsd,int n,int amount,int zeny); int log_zeny(struct map_session_data *sd, struct map_session_data *target_sd,int amount); int log_atcommand(struct map_session_data *sd, const char *message); @@ -27,8 +30,8 @@ extern struct Log_Config { int enable_logs; int sql_logs; int what_items_log,price_items_log,amount_items_log; - int branch, drop, mvpdrop, present, produce, refine, trade, vend, zeny, gm, npc; - char log_branch[32], log_drop[32], log_mvpdrop[32], log_present[32], log_produce[32], log_refine[32], log_trade[32], log_vend[32], log_gm[32], log_npc[32]; + int branch, drop, mvpdrop, present, produce, refine, trade, vend, zeny, gm, npc, storage; + char log_branch[32], log_drop[32], log_mvpdrop[32], log_present[32], log_produce[32], log_refine[32], log_trade[32], log_vend[32], log_gm[32], log_npc[32], log_storage[32]; char log_branch_db[32], log_drop_db[32], log_mvpdrop_db[32], log_present_db[32], log_produce_db[32], log_refine_db[32], log_trade_db[32], log_vend_db[32], log_gm_db[32], log_npc_db[32]; int uptime; char log_uptime[32]; diff --git a/src/map/storage.c b/src/map/storage.c index 6c4d6bea7..82ecd9321 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -233,11 +233,12 @@ int storage_storageadd(struct map_session_data *sd,int index,int amount) if( (stor->storage_amount <= MAX_STORAGE) && (stor->storage_status == 1) ) { // storage not full & storage open if(index>=0 && indexstatus.inventory[index].amount) && (amount > 0) ) { //valid amount - if(storage_additem(sd,stor,&sd->status.inventory[index],amount)==0) - // remove item from inventory - pc_delitem(sd,index,amount,0); - } // valid amount + if( (amount <= sd->status.inventory[index].amount) && (amount > 0) ) { //valid amount +// log_tostorage(sd, index, 0); + if(storage_additem(sd,stor,&sd->status.inventory[index],amount)==0) + // remove item from inventory + pc_delitem(sd,index,amount,0); + } // valid amount }// valid index }// storage not full & storage open @@ -263,6 +264,7 @@ int storage_storageget(struct map_session_data *sd,int index,int amount) storage_delitem(sd,stor,index,amount); else clif_additem(sd,0,0,flag); +// log_fromstorage(sd, index, 0); } // valid amount }// valid index }// storage open @@ -510,6 +512,7 @@ int storage_guild_storageadd(struct map_session_data *sd,int index,int amount) if( (stor->storage_amount <= MAX_GUILD_STORAGE) && (stor->storage_status == 1) ) { // storage not full & storage open if(index>=0 && indexstatus.inventory[index].amount) && (amount > 0) ) { //valid amount +// log_tostorage(sd, index, 1); if(guild_storage_additem(sd,stor,&sd->status.inventory[index],amount)==0) // remove item from inventory pc_delitem(sd,index,amount,0); @@ -536,6 +539,7 @@ int storage_guild_storageget(struct map_session_data *sd,int index,int amount) guild_storage_delitem(sd,stor,index,amount); else clif_additem(sd,0,0,flag); +// log_fromstorage(sd, index, 1); } // valid amount }// valid index }// storage open diff --git a/src/map/trade.c b/src/map/trade.c index d98eed2a0..eb1d45ba2 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -16,6 +16,7 @@ #include "storage.h" #include "intif.h" #include "atcommand.h" +#include "log.h" /*========================================== * 取引要請を相手に送る @@ -33,15 +34,15 @@ void trade_traderequest(struct map_session_data *sd, int target_id) { return; } } - if(pc_isGM(sd) && pc_isGM(sd) < battle_config.gm_can_drop_lv) { + if(pc_isGM(sd) && pc_isGM(target_sd) < battle_config.gm_can_drop_lv) { clif_displaymessage(sd->fd, msg_txt(246)); trade_tradecancel(sd); // GM is not allowed to trade } else if ((target_sd->trade_partner != 0) || (sd->trade_partner != 0)) { trade_tradecancel(sd); // person is in another trade } else { - if (sd->bl.m != target_sd->bl.m || + if (!pc_isGM(sd) && (sd->bl.m != target_sd->bl.m || (sd->bl.x - target_sd->bl.x <= -5 || sd->bl.x - target_sd->bl.x >= 5) || - (sd->bl.y - target_sd->bl.y <= -5 || sd->bl.y - target_sd->bl.y >= 5)) { + (sd->bl.y - target_sd->bl.y <= -5 || sd->bl.y - target_sd->bl.y >= 5))) { clif_tradestart(sd, 0); // too far } else if (sd != target_sd) { target_sd->trade_partner = sd->status.account_id; @@ -328,6 +329,7 @@ void trade_tradecommit(struct map_session_data *sd) { if (sd->status.inventory[n].amount < sd->deal_item_amount[trade_i]) sd->deal_item_amount[trade_i] = sd->status.inventory[n].amount; + log_trade(sd, target_sd, n, sd->deal_item_amount[trade_i]); flag = pc_additem(target_sd, &sd->status.inventory[n], sd->deal_item_amount[trade_i]); if (flag == 0) @@ -336,6 +338,7 @@ void trade_tradecommit(struct map_session_data *sd) { clif_additem(sd, n, sd->deal_item_amount[trade_i], 0); sd->deal_item_index[trade_i] = 0; sd->deal_item_amount[trade_i] = 0; + } if (target_sd->deal_item_amount[trade_i] != 0) { int n = target_sd->deal_item_index[trade_i] - 2; @@ -343,6 +346,7 @@ void trade_tradecommit(struct map_session_data *sd) { if (target_sd->status.inventory[n].amount < target_sd->deal_item_amount[trade_i]) target_sd->deal_item_amount[trade_i] = target_sd->status.inventory[n].amount; + log_trade(target_sd, sd, n, target_sd->deal_item_amount[trade_i]); flag = pc_additem(sd, &target_sd->status.inventory[n], target_sd->deal_item_amount[trade_i]); if (flag == 0) pc_delitem(target_sd, n, target_sd->deal_item_amount[trade_i], 1); -- cgit v1.2.3-70-g09d2 From 573c40f53e1d0fe29c72117fc4ca2d931b274d8c Mon Sep 17 00:00:00 2001 From: celest Date: Tue, 5 Apr 2005 14:32:04 +0000 Subject: * Added SERVER_TYPE to core for future plugins support * Added support for the UPNP plugin to release port mappings and re-close firewall ports on shutdown * Updated showmsg git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1409 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/core.c | 42 ++++++++++++++++++---------------- src/common/core.h | 10 +++++++- src/common/showmsg.c | 64 ++++++++++++++++++++++++---------------------------- src/common/showmsg.h | 13 ++++++++++- src/common/socket.c | 34 +++++++++++++++++++++++++--- 5 files changed, 104 insertions(+), 59 deletions(-) (limited to 'src/common/showmsg.h') diff --git a/src/common/core.c b/src/common/core.c index b325b96e4..0a9e76120 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -14,20 +14,21 @@ #endif #endif -#include "../common/mmo.h" -#include "malloc.h" #include "core.h" -#include "socket.h" -#include "timer.h" -#include "version.h" -#include "showmsg.h" +#include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/socket.h" +#include "../common/timer.h" +#include "../common/version.h" +#include "../common/showmsg.h" #ifdef MEMWATCH #include "memwatch.h" #endif -char server_type[24]; +char *argp; int runflag = 1; +char SERVER_TYPE = SERVER_NONE; unsigned long ticks = 0; // by MC Cameri char pid_file[256]; static void (*term_func)(void)=NULL; @@ -132,7 +133,7 @@ void sig_dump(int sn) // search for a usable filename do { - sprintf (file, "log/%s%04d.stackdump", server_type, ++no); + sprintf (file, "log/%s%04d.stackdump", argp, ++no); } while((fp = fopen(file,"r")) && (fclose(fp), no < 9999)); // dump the trace into the file @@ -171,12 +172,13 @@ int get_svn_revision(char *svnentry) { // Warning: minor syntax checking if ((fp = fopen(svnentry, "r")) == NULL) { return 0; } else { - while (fgets(line,1023,fp)) if (strstr(line,"revision=")) break; + while (fgets(line,1023,fp)) + if (strstr(line,"revision=")) break; fclose(fp); - if (sscanf(line," %*[^\"]\"%d%*[^\n]",&rev)==1) - return rev; + if (sscanf(line," %*[^\"]\"%d%*[^\n]",&rev) == 1) + return rev; else - return 0; + return 0; } // return 0; } @@ -273,7 +275,7 @@ void log_uptime(void) seconds -= (seconds/minute>0)?(seconds/minute)*minute:0; fprintf(fp, "%s: %s uptime - %ld days, %ld hours, %ld minutes, %ld seconds.\n", - curtime2, server_type, days, hours, minutes, seconds); + curtime2, argp, days, hours, minutes, seconds); fclose(fp); } @@ -285,14 +287,15 @@ int main(int argc,char **argv) { int next; - display_title(); - // call this first so it'll be finalised last - do_init_memmgr(argv[0]); // 一番最初に実行する必要がある + if ((argp = strstr(argv[0], "./")) != NULL) + argp+=2; + else argp = argv[0]; - sscanf(argv[0], "./%24[^\n]", server_type); // map/char/login? - atexit(log_uptime); - pid_create(argv[0]); + display_title(); + do_init_memmgr(argp); // 一番最初に実行する必要がある + atexit(log_uptime); + pid_create(argp); Net_Init(); do_socket(); @@ -313,6 +316,7 @@ int main(int argc,char **argv) ticks = gettick(); do_init(argc,argv); + while(runflag){ next=do_timer(gettick_nocache()); do_sendrecv(next); diff --git a/src/common/core.h b/src/common/core.h index 23431f297..e9b5c8227 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -3,11 +3,19 @@ #ifndef _CORE_H_ #define _CORE_H_ +extern char *argp; extern int runflag; extern unsigned long ticks; +extern char SERVER_TYPE; -int do_init(int,char**); +enum { + SERVER_NONE, + SERVER_LOGIN, + SERVER_CHAR, + SERVER_MAP, +}; +int do_init(int,char**); void set_termfunc(void (*termfunc)(void)); #endif // _CORE_H_ diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 9901af81b..24d51d2dc 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -5,15 +5,12 @@ char tmp_output[1024] = {"\0"}; -#undef ShowMessage - // by MC Cameri int _vShowMessage(enum msg_type flag, const char *string, va_list ap) { // _ShowMessage MUST be used instead of printf as of 10/24/2004. // Return: 0 = Successful, 1 = Failed. // int ret = 0; -// char *output; char prefix[40]; if (!string || strlen(string) <= 0) { @@ -21,6 +18,8 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) return 1; } switch (flag) { + case MSG_NONE: // direct printf replacement + break; case MSG_STATUS: //Bright Green (To inform about good things) strcpy(prefix,CL_GREEN"[Status]"CL_RESET":"); break; @@ -49,22 +48,10 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) printf("In function _ShowMessage() -> Invalid flag passed.\n"); return 1; } - if (!(flag == MSG_DEBUG && !SHOW_DEBUG_MSG)) { - -/* output = (char*)aMalloc(sizeof(char)*(strlen(prefix)+strlen(string)+2)); // prefix+string+two chars(space and \0) - if (output == NULL) { - return 1; -// exit(1); // Kill server? Deadly - } - strcpy(output,prefix); - strcat(output," "); - strcat(output,string); - vprintf(output, ap); - fflush(stdout); - aFree(output);*/ - - printf ("%s ", prefix); + if (!(flag == MSG_DEBUG && !SHOW_DEBUG_MSG)) { + if (flag != MSG_NONE) + printf ("%s ", prefix); vprintf (string, ap); fflush (stdout); } @@ -96,51 +83,58 @@ int _ShowMessage(enum msg_type flag, const char *string, ...) return _vShowMessage(flag, string, ap); } +// direct printf replacement +int ShowMessage(const char *string, ...) { + va_list ap; + + va_start(ap, string); + return _vShowMessage(MSG_NONE, string, ap); +} int ShowStatus(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_STATUS, string, ap); + return _vShowMessage(MSG_STATUS, string, ap); } int ShowSQL(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_SQL, string, ap); + return _vShowMessage(MSG_SQL, string, ap); } int ShowInfo(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_INFORMATION, string, ap); + return _vShowMessage(MSG_INFORMATION, string, ap); } int ShowNotice(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_NOTICE, string, ap); + return _vShowMessage(MSG_NOTICE, string, ap); } int ShowWarning(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_WARNING, string, ap); + return _vShowMessage(MSG_WARNING, string, ap); } int ShowDebug(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_DEBUG, string, ap); + return _vShowMessage(MSG_DEBUG, string, ap); } int ShowError(const char *string, ...) { - va_list ap; + va_list ap; va_start(ap, string); - return _vShowMessage(MSG_ERROR, string, ap); + return _vShowMessage(MSG_ERROR, string, ap); } int ShowFatalError(const char *string, ...) { - va_list ap; - + va_list ap; + va_start(ap, string); - return _vShowMessage(MSG_FATALERROR, string, ap); + return _vShowMessage(MSG_FATALERROR, string, ap); } diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 3461369c3..b5f4d4bfd 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -32,8 +32,19 @@ extern char tmp_output[1024]; -enum msg_type {MSG_STATUS, MSG_SQL, MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_DEBUG,MSG_ERROR,MSG_FATALERROR}; +enum msg_type { + MSG_NONE, + MSG_STATUS, + MSG_SQL, + MSG_INFORMATION, + MSG_NOTICE, + MSG_WARNING, + MSG_DEBUG, + MSG_ERROR, + MSG_FATALERROR +}; +extern int ShowMessage(const char *, ...); extern int ShowStatus(const char *, ...); extern int ShowSQL(const char *, ...); extern int ShowInfo(const char *, ...); diff --git a/src/common/socket.c b/src/common/socket.c index 2daf00764..64f660a11 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -54,7 +54,10 @@ int (*upnp_init)(); int (*upnp_final)(); int (*firewall_addport)(char *desc, int port); int (*upnp_addport)(char *desc, char *ip, int port); -extern char server_type[24]; +extern char *argp; + +int release_mappings = 1; +int close_ports = 1; #else #error This doesnt work with non-Windows yet #endif @@ -327,10 +330,10 @@ int make_listen_bind(long ip,int port) char buf[16]; sprintf(buf, "%d.%d.%d.%d", natip[0], natip[1], natip[2], natip[3]); //printf("natip=%d.%d.%d.%d\n", natip[0], natip[1], natip[2], natip[3]); - if (firewall_addport(server_type, port)) + if (firewall_addport(argp, port)) printf ("Firewall port %d successfully opened\n", port); if (natip[0] == 192 && natip[1] == 168) { - if (upnp_addport(server_type, natip, port)) + if (upnp_addport(argp, natip, port)) printf ("Upnp mappings successfull\n"); else printf ("Upnp mapping failed\n"); } @@ -845,6 +848,20 @@ int socket_config_read(const char *cfgName) { else if(strcmpi(w2,"no")==0) access_debug = 0; else access_debug = atoi(w2); + #ifdef UPNP + } else if(!strcmpi(w1,"release_mappings")){ + if(strcmpi(w2,"yes")==0) + release_mappings = 1; + else if(strcmpi(w2,"no")==0) + release_mappings = 0; + else release_mappings = atoi(w2); + } else if(!strcmpi(w1,"close_ports")){ + if(strcmpi(w2,"yes")==0) + close_ports = 1; + else if(strcmpi(w2,"no")==0) + close_ports = 0; + else close_ports = atoi(w2); + #endif } else if (strcmpi(w1, "import") == 0) socket_config_read(w2); } @@ -957,6 +974,9 @@ int Net_Init(void) // not implemented yet ^^; void do_init_upnp(void) { + int *_release_mappings; + int *_close_ports; + upnp_dll = DLL_OPEN ("upnp.dll"); if (!upnp_dll) { printf ("Cannot open upnp.dll: %s\n", dlerror()); @@ -972,6 +992,14 @@ void do_init_upnp(void) upnp_dll = NULL; return; } + + DLL_SYM (_release_mappings, upnp_dll, "release_mappings"); + DLL_SYM (_close_ports, upnp_dll, "close_ports"); + if (release_mappings && _release_mappings) + *_release_mappings = release_mappings; + if (close_ports && _close_ports) + *_close_ports = close_ports; + if (upnp_init() == 0) { printf ("Error initialising upnp.dll, unloading...\n"); DLL_CLOSE (upnp_dll); -- cgit v1.2.3-70-g09d2