From 620e60eebce2c1f35c5c9a82f6ca365b316587f5 Mon Sep 17 00:00:00 2001 From: Valaris Date: Sun, 29 Jan 2006 16:10:48 +0000 Subject: AS OF SVN REV. 5901, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EVERYTHING ELSE GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5094 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/cbasetypes.h | 253 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 src/common/cbasetypes.h (limited to 'src/common/cbasetypes.h') diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h new file mode 100644 index 000000000..ec539a3db --- /dev/null +++ b/src/common/cbasetypes.h @@ -0,0 +1,253 @@ +#ifndef _CBASETYPES_H_ +#define _CBASETYPES_H_ +/* +--------+-----------+--------+---------+ + * | ILP32 | LP64 | ILP64 | (LL)P64 | + * +------------+--------+-----------+--------+---------+ + * | ints | 32-bit | 32-bit | 64-bit | 32-bit | + * | longs | 32-bit | 64-bit | 64-bit | 32-bit | + * | long-longs | 64-bit | 64-bit | 64-bit | 64-bit | + * | pointers | 32-bit | 64-bit | 64-bit | 64-bit | + * +------------+--------+-----------+--------+---------+ + * | where | -- | Tiger | Alpha | Windows | + * | used | | Unix | Cray | | + * | | | Sun & SGI | | | + * +------------+--------+-----------+--------+---------+ + * Taken from http://developer.apple.com/macosx/64bit.html + */ + +////////////////////////////////////////////////////////////////////////// +// basic include for all basics +// introduces types and global functions +////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +// setting some defines on platforms +////////////////////////////////////////////////////////////////////////// +#if (defined(__WIN32__) || defined(__WIN32) || defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(WIN32) +#define WIN32 +#endif + +// __APPLE__ is the only predefined macro on MacOS X +#if defined(__APPLE__) +#define __DARWIN__ +#endif + +// 64bit OS +#if defined(_M_IA64) || defined(_M_X64) || defined(_WIN64) || defined(_LP64) || defined(_ILP64) || defined(__LP64__) || defined(__ppc64__) +#define __64BIT__ +#endif + +#if defined(_ILP64) +#error "this specific 64bit architecture is not supported" +#endif + +// debug mode +#if defined(_DEBUG) && !defined(DEBUG) +#define DEBUG +#endif + +// disable attributed stuff on non-GNU +#ifndef __GNUC__ +# define __attribute__(x) +#endif + + +////////////////////////////////////////////////////////////////////////// +// useful typedefs +////////////////////////////////////////////////////////////////////////// +typedef unsigned char uchar; +typedef signed char schar; +typedef signed short sshort; +typedef unsigned short ushort; +typedef signed int sint; // don't use (only for ie. scanf) +typedef unsigned int uint; // don't use +typedef signed long slong; // don't use (only for ie. file-io) +typedef unsigned long ulong; // don't use + +typedef char* pchar; +typedef const char* cchar; +typedef unsigned char* puchar; +typedef void* ptr; +typedef int* pint; + + +////////////////////////////////////////////////////////////////////////// +// typedefs to compensate type size change from 32bit to 64bit +// MS implements LLP64 model, normal unix does LP64, +// only Silicon Graphics/Cray goes ILP64 so don't care (and don't support) +////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////// +// Integers with guaranteed _exact_ size. +////////////////////////////////////////////////////////////////////////// + +////////////////////////////// +#ifdef WIN32 +////////////////////////////// +typedef __int8 int8; +typedef __int16 int16; +typedef __int32 int32; + +typedef signed __int8 sint8; +typedef signed __int16 sint16; +typedef signed __int32 sint32; + +typedef unsigned __int8 uint8; +typedef unsigned __int16 uint16; +typedef unsigned __int32 uint32; +////////////////////////////// +#else // GNU +////////////////////////////// +typedef char int8; +typedef short int16; +typedef int int32; + +typedef signed char sint8; +typedef signed short sint16; +typedef signed int sint32; + +typedef unsigned char uint8; +typedef unsigned short uint16; +typedef unsigned int uint32; +////////////////////////////// +#endif +////////////////////////////// + +#undef UINT8_MIN +#undef UINT16_MIN +#undef UINT32_MIN +#define UINT8_MIN (uint8) 0 +#define UINT16_MIN (uint16)0 +#define UINT32_MIN (uint32)0 + +#undef UINT8_MAX +#undef UINT16_MAX +#undef UINT32_MAX +#define UINT8_MAX (uint8) 0xFF +#define UINT16_MAX (uint16)0xFFFF +#define UINT32_MAX (uint32)0xFFFFFFFF + +#undef SINT8_MIN +#undef SINT16_MIN +#undef SINT32_MIN +#define SINT8_MIN (sint8) 0x80 +#define SINT16_MIN (sint16)0x8000 +#define SINT32_MIN (sint32)0x80000000 + +#undef SINT8_MAX +#undef SINT16_MAX +#undef SINT32_MAX +#define SINT8_MAX (sint8) 0x7F +#define SINT16_MAX (sint16)0x7FFF +#define SINT32_MAX (sint32)0x7FFFFFFF + + +////////////////////////////////////////////////////////////////////////// +// Integers with guaranteed _minimum_ size. +// These could be larger than you expect, +// they are designed for speed. +////////////////////////////////////////////////////////////////////////// +typedef long int ppint; +typedef long int ppint8; +typedef long int ppint16; +typedef long int ppint32; + +typedef unsigned long int ppuint; +typedef unsigned long int ppuint8; +typedef unsigned long int ppuint16; +typedef unsigned long int ppuint32; + + +////////////////////////////////////////////////////////////////////////// +// integer with exact processor width (and best speed) +// size_t already defined in stdio.h +////////////////////////////// +#ifdef WIN32 // does not have a signed size_t +////////////////////////////// +#if defined(_WIN64) // naive 64bit windows platform +typedef __int64 ssize_t; +#else +typedef int ssize_t; +#endif +////////////////////////////// +#endif +////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +// portable 64-bit integers +////////////////////////////////////////////////////////////////////////// +#if defined(_MSC_VER) || defined(__BORLANDC__) +typedef __int64 int64; +typedef signed __int64 sint64; +typedef unsigned __int64 uint64; +#define LLCONST(a) (a##i64) +#else +typedef long long int64; +typedef signed long long sint64; +typedef unsigned long long uint64; +#define LLCONST(a) (a##ll) +#endif + +#ifndef INT64_MIN +#define INT64_MIN (LLCONST(-9223372036854775807)-1) +#endif +#ifndef INT64_MAX +#define INT64_MAX (LLCONST(9223372036854775807)) +#endif +#ifndef UINT64_MAX +#define UINT64_MAX (LLCONST(18446744073709551615u)) +#endif + + +////////////////////////////////////////////////////////////////////////// +// some redefine of function redefines for some Compilers +////////////////////////////////////////////////////////////////////////// +#if defined(_MSC_VER) || defined(__BORLANDC__) +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define snprintf _snprintf +#define vsnprintf _vsnprintf +#endif + +// keyword replacement in windows +#ifdef _WIN32 +#define inline __inline +#endif + +///////////////////////////// +// for those still not building c++ +#ifndef __cplusplus +////////////////////////////// + +// boolean types for C +typedef int bool; +#define false (1==0) +#define true (1==1) + +////////////////////////////// +#endif // not cplusplus +////////////////////////////// + +#ifdef swap // just to be sure +#undef swap +#endif +// hmm only ints? +//#define swap(a,b) { int temp=a; a=b; b=temp;} +// if using macros then something that is type independent +#define swap(a,b) ((a == b) || ((a ^= b), (b ^= a), (a ^= b))) + +////////////////////////////////////////////////////////////////////////// +// should not happen +#ifndef NULL +#define NULL (void *)0 +#endif + +////////////////////////////////////////////////////////////////////////// +// number of bits in a byte +#ifndef NBBY +#define NBBY 8 +#endif + +#endif /* _CBASETYPES_H_ */ -- cgit v1.2.3-70-g09d2 From ce90e748fccfaf86c857b94a604044b9dd53b3e7 Mon Sep 17 00:00:00 2001 From: skotlex Date: Fri, 17 Feb 2006 13:48:04 +0000 Subject: - Applied the suggested fixes by Joshuaali to fix the compiling of the sql map server on Win32 systems. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5308 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 +++ src/common/cbasetypes.h | 4 +++- src/mysql/my_global.h | 7 ++----- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 08774b908..8245ef236 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -5,6 +5,9 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EV GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS 2006/02/17 + * Applied the suggested fixes by Joshuaali to fix the compiling of the sql + map server on Win32 systems. [Skotlex] + - note that irc.c is still uncompilable, but the rest "should be fine" now. * Fixed the memory leak on opt_2str as pointed out by End of Exam [Skotlex] * Fixed a few char SQL memory leaks as pointed out by End of Exam [Skotlex] 2006/02/16 diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index ec539a3db..ff9109dd1 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -65,9 +65,11 @@ typedef unsigned int uint; // don't use typedef signed long slong; // don't use (only for ie. file-io) typedef unsigned long ulong; // don't use +#ifndef WIN32 typedef char* pchar; -typedef const char* cchar; typedef unsigned char* puchar; +#endif +typedef const char* cchar; typedef void* ptr; typedef int* pint; diff --git a/src/mysql/my_global.h b/src/mysql/my_global.h index 10d667b95..65e251ab3 100644 --- a/src/mysql/my_global.h +++ b/src/mysql/my_global.h @@ -497,11 +497,8 @@ typedef char pbool; /* Mixed prototypes can take char */ typedef short pshort; /* Mixed prototypes can take short int */ typedef float pfloat; /* Mixed prototypes can take float */ #else -//These types already exist in WinNT systems... -//...but what do we do about Win9X ones? [Skotlex] -//typedef int pchar; /* Mixed prototypes can't take char */ -//typedef uint puchar; /* Mixed prototypes can't take char */ -#include +typedef int pchar; /* Mixed prototypes can't take char */ +typedef uint puchar; /* Mixed prototypes can't take char */ typedef int pbool; /* Mixed prototypes can't take char */ typedef int pshort; /* Mixed prototypes can't take short int */ typedef double pfloat; /* Mixed prototypes can't take float */ -- cgit v1.2.3-70-g09d2 From 32ebde394d7762fdbb28ba9b5c3ce9a232292bb7 Mon Sep 17 00:00:00 2001 From: skotlex Date: Thu, 2 Mar 2006 16:17:47 +0000 Subject: - Applied Snufkin's patch to fix compilation on FreeBSD. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5428 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 1 + Makefile | 33 +++++++++++++++++++++++++++++++++ src/common/cbasetypes.h | 4 ++++ src/common/grfio.c | 4 +++- src/common/mapindex.c | 2 +- 5 files changed, 42 insertions(+), 2 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index a080b8536..f6fffb1d0 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -5,6 +5,7 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EV GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS 2006/03/02 + * Applied Snufkin's patch to fix compilation on FreeBSD. [Skotlex] * Fixed mobs targetting themselves after using a support skill. [Skotlex] * Gospel no longer blocks item usage of whoever is in the area of effect, only the caster of Gospel can't use healing items now. [Skotlex] diff --git a/Makefile b/Makefile index e2c37ffe3..14bc1b204 100644 --- a/Makefile +++ b/Makefile @@ -208,3 +208,36 @@ src/map/GNUmakefile: src/map/Makefile src/plugins/GNUmakefile: src/plugins/Makefile src/ladmin/GNUmakefile: src/ladmin/Makefile src/txt-converter/GNUmakefile: src/txt-converter/Makefile + +install: conf/%.conf conf/%.txt + $(shell mkdir -p /opt/eathena/bin/) + $(shell mkdir -p /opt/eathena/etc/eathena/) + $(shell mkdir -p /opt/eathena/var/log/eathena/) + $(shell mv save /opt/eathena/etc/eathena/save) + $(shell mv db /opt/eathena/etc/eathena/db) + $(shell mv conf /opt/eathena/etc/eathena/conf) + $(shell mv npc /opt/eathena/etc/eathena/npc) + $(shell mv log/* /opt/eathena/var/log/eathena/) + $(shell cp *-server* /opt/eathena/bin/) + $(shell cp ladmin /opt/eathena/bin/) + $(shell ln -s /opt/eathena/etc/eathena/save/ /opt/eathena/bin/) + $(shell ln -s /opt/eathena/etc/eathena/db/ /opt/eathena/bin/) + $(shell ln -s /opt/eathena/etc/eathena/conf/ /opt/eathena/bin/) + $(shell ln -s /opt/eathena/etc/eathena/npc/ /opt/eathena/bin/) + $(shell ln -s /opt/eathena/var/log/eathena/ /opt/eathena/bin/log) + +bin-clean: + $(shell rm /opt/eathena/bin/login-server*) + $(shell rm /opt/eathena/bin/char-server*) + $(shell rm /opt/eathena/bin/map-server*) + $(shell rm /opt/eathena/bin/ladmin) + +uninstall: + bin-clean + $(shell rm /opt/eathena/bin/save) + $(shell rm /opt/eathena/bin/db) + $(shell rm /opt/eathena/bin/conf) + $(shell rm /opt/eathena/bin/npc) + $(shell rm /opt/eathena/bin/log) + $(shell rm -rf /opt/eathena/etc/eathena) + $(shell rm -rf /opt/eathena/var/log/eathena) diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index ff9109dd1..505eb6752 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -59,9 +59,13 @@ typedef unsigned char uchar; typedef signed char schar; typedef signed short sshort; +#ifndef __FREEBSD__ typedef unsigned short ushort; +#endif typedef signed int sint; // don't use (only for ie. scanf) +#ifndef __FREEBSD__ typedef unsigned int uint; // don't use +#endif typedef signed long slong; // don't use (only for ie. file-io) typedef unsigned long ulong; // don't use diff --git a/src/common/grfio.c b/src/common/grfio.c index eef4ea654..fcc1ee461 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -40,7 +40,9 @@ #include "../zlib/zlib.h" #include "../zlib/iowin32.h" #else - #include + #ifndef __FREEBSD__ + #include + #endif #endif typedef unsigned char BYTE; diff --git a/src/common/mapindex.c b/src/common/mapindex.c index e600b5ad7..156dc6243 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include "showmsg.h" #define MAX_MAPINDEX 2000 -- cgit v1.2.3-70-g09d2 From 045c123351a3ed8596799d57ae79165e76ed771a Mon Sep 17 00:00:00 2001 From: skotlex Date: Fri, 10 Mar 2006 19:26:56 +0000 Subject: - Added a few dummy times in skill_cast_db for some GS skills. - Autoskills now won't trigger on maps where said skill are not allowed. - Some compilation warning fixes git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5565 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 2 ++ db/Changelog.txt | 2 ++ db/skill_cast_db.txt | 7 +++---- src/common/cbasetypes.h | 8 ++++++-- src/map/npc.c | 2 +- src/map/skill.c | 13 +++++++------ 6 files changed, 21 insertions(+), 13 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 429e509db..980ffd5a6 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -5,6 +5,8 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EV GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS 2006/03/10 + * Autospells won't trigger now on maps where said skills are forbidden. + [Skotlex] * Changed div (multi-hit) behaviour. Skills with div above zero will get their total damage increased by the number of hits, div less than zero is just for "show", total number of hits displayed is abs(div), but damage diff --git a/db/Changelog.txt b/db/Changelog.txt index b9b4b864c..458630fe0 100644 --- a/db/Changelog.txt +++ b/db/Changelog.txt @@ -27,6 +27,8 @@ ========================= 03/10 + * Added a few dummy duration values on skill_cast_db for some GS skills + (better than leaving them on 0...) [Skotlex] * Updated div of LoV, Combo Skills and other such skills whose damage equation does not really scales well with the number of hits. [Skotlex] * Made G_Giant_Hornet Agressive, thanks to Blackgatomon [Lupus] diff --git a/db/skill_cast_db.txt b/db/skill_cast_db.txt index d274a7958..6e9800799 100644 --- a/db/skill_cast_db.txt +++ b/db/skill_cast_db.txt @@ -825,14 +825,13 @@ //-- GS_MAGICALBULLET 507,0,0,0,0,0 //-- GS_CRACKER -508,0,0,0,0,0 +508,0,0,0,0,5000 //-- GS_TRACKING - 512,1200:1400:1600:1800:2000:2200:2400:2600:2800:3000,0,0,0,0 //-- GS_DISARM 513,0,0,0,0,0 //-- GS_PIERCINGSHOT -514,0,0,0,0,0 +514,0,0,0,0,60000 //-- GS_RAPIDSHOWER 515,0,0,0,0,0 //-- GS_DESPERADO @@ -883,7 +882,7 @@ //-- NJ_SUITON 538,0,0,0,15000:20000:25000:30000:35000:40000:45000:50000:55000:60000,0 //-- NJ_HYOUSYOURAKU -539,0,0,0,0,0 +539,0,0,0,0,10000 //-- NJ_HUUJIN 540,0,0,0,0,0 //-- NJ_RAIGEKISAI diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 505eb6752..b84a0c88e 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -91,9 +91,14 @@ typedef int* pint; ////////////////////////////// #ifdef WIN32 ////////////////////////////// +//These three are already redefined on my_global.h on Windows systems. +#ifdef TXT_ONLY typedef __int8 int8; -typedef __int16 int16; typedef __int32 int32; +typedef unsigned __int32 uint32; +#endif + +typedef __int16 int16; typedef signed __int8 sint8; typedef signed __int16 sint16; @@ -101,7 +106,6 @@ typedef signed __int32 sint32; typedef unsigned __int8 uint8; typedef unsigned __int16 uint16; -typedef unsigned __int32 uint32; ////////////////////////////// #else // GNU ////////////////////////////// diff --git a/src/map/npc.c b/src/map/npc.c index 7ba8be5d5..276d615be 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -441,7 +441,7 @@ int npc_addeventtimer(struct npc_data *nd,int tick,const char *name) if( nd->eventtimer[i]==-1 ) break; if(ibl, bl)),skilllv,skill_get_time(skillid,skilllv)); //Temp stun rate + sc_start(bl,SC_STUN,(100 - 10*distance_bl(src, bl)),skilllv,skill_get_time2(skillid,skilllv)); //Temp stun rate break; case GS_PIERCINGSHOT: - sc_start(bl,SC_BLEEDING,(skilllv*3),skilllv,skill_get_time(skillid,skilllv)); + sc_start(bl,SC_BLEEDING,(skilllv*3),skilllv,skill_get_time2(skillid,skilllv)); break; case NJ_HYOUSYOURAKU: sc_start(bl,SC_FREEZE,(10+10*skilllv),skilllv,skill_get_time2(skillid,skilllv)); @@ -1285,7 +1284,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int skill = (sd->autospell[i].id > 0) ? sd->autospell[i].id : -sd->autospell[i].id; //Prevents skill from retriggering themselves. [Skotlex] - if (skill == skillid) + if (skill == skillid || skillnotok(skill, sd)) continue; //skill2 reused to store skilllv. @@ -1413,6 +1412,8 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * rate = ((sd && !sd->state.arrow_atk) || (status_get_range(src)<=2)) ? dstsd->autospell2[i].rate : dstsd->autospell2[i].rate / 2; + if (skillnotok(skillid, dstsd)) + continue; if (rand()%1000 > rate) continue; if (dstsd->autospell2[i].id < 0) -- cgit v1.2.3-70-g09d2 From 1b8b555e1fcc83cd20ef32c39d767cfaf458bef6 Mon Sep 17 00:00:00 2001 From: skotlex Date: Fri, 10 Mar 2006 20:18:40 +0000 Subject: - Increased the range for unlocking out of Close confine. - Reverted some changes in cbasetypes.h which actually broke compilation. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5566 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/cbasetypes.h | 8 ++------ src/map/status.c | 4 +++- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index b84a0c88e..505eb6752 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -91,14 +91,9 @@ typedef int* pint; ////////////////////////////// #ifdef WIN32 ////////////////////////////// -//These three are already redefined on my_global.h on Windows systems. -#ifdef TXT_ONLY typedef __int8 int8; -typedef __int32 int32; -typedef unsigned __int32 uint32; -#endif - typedef __int16 int16; +typedef __int32 int32; typedef signed __int8 sint8; typedef signed __int16 sint16; @@ -106,6 +101,7 @@ typedef signed __int32 sint32; typedef unsigned __int8 uint8; typedef unsigned __int16 uint16; +typedef unsigned __int32 uint32; ////////////////////////////// #else // GNU ////////////////////////////// diff --git a/src/map/status.c b/src/map/status.c index e85bb0ebf..d360abdab 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -4948,7 +4948,9 @@ int status_change_end( struct block_list* bl , int type,int tid ) break; case SC_CLOSECONFINE: if (sc->data[type].val2 > 0) { //Caster has been unlocked... nearby chars need to be unlocked. - int range = 2*skill_get_range2(bl, StatusSkillChangeTable[type], sc->data[type].val1); + int range = 1 + +skill_get_range2(bl, StatusSkillChangeTable[type], sc->data[type].val1) + +skill_get_range2(bl, TF_BACKSLIDING, 1); //Since most people use this to escape the hold.... map_foreachinarea(status_change_timer_sub, bl->m, bl->x-range, bl->y-range, bl->x+range,bl->y+range,BL_CHAR,bl,sc,type,gettick()); } -- cgit v1.2.3-70-g09d2 From d6f2064fa166cf9df4da17e34dcef4210042e8f5 Mon Sep 17 00:00:00 2001 From: Lance Date: Sun, 16 Apr 2006 02:40:46 +0000 Subject: * Temperory fixed compiler warnings/errors. Please compile before commiting. [Lance] git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6098 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 4 ++++ src/common/cbasetypes.h | 4 ++++ src/common/strlib.h | 1 + src/map/clif.c | 4 ++-- src/mysql/my_global.h | 2 ++ vcproj-7.1/map-server_sql.vcproj | 4 ++-- 6 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 7e656fa5f..1e6f6f817 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,10 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2006/04/16 + * Temperory fixed compiler warnings/errors. Please compile before commiting. + [Lance] + 2006/04/15 * Fixed upgrade_svn5902.sql, thanks to Koshiro for pointing it out. [Skotlex] diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 505eb6752..097b5241c 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -56,6 +56,7 @@ ////////////////////////////////////////////////////////////////////////// // useful typedefs ////////////////////////////////////////////////////////////////////////// +#define HAVE_UCHAR typedef unsigned char uchar; typedef signed char schar; typedef signed short sshort; @@ -91,6 +92,9 @@ typedef int* pint; ////////////////////////////// #ifdef WIN32 ////////////////////////////// +#define SIZEOF_LONG 4 +#define SIZEOF_INT 4 +#define HAVE_INT_8_16_32 typedef __int8 int8; typedef __int16 int16; typedef __int32 int32; diff --git a/src/common/strlib.h b/src/common/strlib.h index 09eac0048..51d865149 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -12,6 +12,7 @@ char* jstrescapecpy (char* pt,char* spt); int jmemescapecpy (char* pt,char* spt, int size); #ifdef __WIN32 +#define HAVE_STRTOK_R #define strtok_r(s,delim,save_ptr) _strtok_r((s),(delim),(save_ptr)) char *_strtok_r(char *s1, const char *s2, char **lasts); #endif diff --git a/src/map/clif.c b/src/map/clif.c index 48216e412..c0304f7b6 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -3800,7 +3800,7 @@ void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fi */ int clif_getareachar_skillunit(struct map_session_data *sd,struct skill_unit *unit) { - int fd, unit_id; + int fd/*, unit_id*/; // Unused? [Lance] struct block_list *bl; fd=sd->fd; @@ -3813,7 +3813,7 @@ int clif_getareachar_skillunit(struct map_session_data *sd,struct skill_unit *un WFIFOL(fd, 2)=unit->bl.id; WFIFOL(fd, 6)=unit->group->src_id; WFIFOW(fd,10)=unit->bl.x; - WFIFOW(fd,12)=unit_id; + WFIFOW(fd,12)=unit->bl.y; // might be typo? [Lance] WFIFOB(fd,14)=unit->group->unit_id; WFIFOB(fd,15)=1; WFIFOB(fd,16)=1; diff --git a/src/mysql/my_global.h b/src/mysql/my_global.h index 969617c08..2417477e2 100644 --- a/src/mysql/my_global.h +++ b/src/mysql/my_global.h @@ -93,6 +93,8 @@ #define NETWARE_SET_SCREEN_MODE(A) #endif +#include "../common/strlib.h" + /* The macros below are borrowed from include/linux/compiler.h in the Linux kernel. Use them to indicate the likelyhood of the truthfulness diff --git a/vcproj-7.1/map-server_sql.vcproj b/vcproj-7.1/map-server_sql.vcproj index b51597b30..32fa2e42a 100644 --- a/vcproj-7.1/map-server_sql.vcproj +++ b/vcproj-7.1/map-server_sql.vcproj @@ -38,7 +38,7 @@ Name="VCCustomBuildTool"/> Date: Fri, 28 Jul 2006 09:36:47 +0000 Subject: Fixed "warning: redefinition of [ushort/uint/ulong]" git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7938 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 1 + src/common/cbasetypes.h | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 7f7bcf337..a54b28885 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2006/07/28 + * Fixed "warning: redefinition of [ushort/uint/ulong]" [Toms] * Fixed duplicate case value on NJ_SUITON [Toms] 2006/07/27 * Fixed a memory leak when there exists more than one user function with diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 097b5241c..fe31f4c8d 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -60,15 +60,18 @@ typedef unsigned char uchar; typedef signed char schar; typedef signed short sshort; -#ifndef __FREEBSD__ -typedef unsigned short ushort; + +#if !defined(__FREEBSD__) && !defined(_SYS_TYPES_H) + typedef unsigned short ushort; +#endif +typedef signed int sint; // don't use (only for ie. scanf) +#if !defined(__FREEBSD__) && !defined(_SYS_TYPES_H) + typedef unsigned int uint; // don't use #endif -typedef signed int sint; // don't use (only for ie. scanf) -#ifndef __FREEBSD__ -typedef unsigned int uint; // don't use +typedef signed long slong; // don't use (only for ie. file-io) +#ifndef _SYS_TYPES_H + typedef unsigned long ulong; // don't use #endif -typedef signed long slong; // don't use (only for ie. file-io) -typedef unsigned long ulong; // don't use #ifndef WIN32 typedef char* pchar; -- cgit v1.2.3-70-g09d2 From 7777bb2be759a3de32f5edbb53ae3d8b6396c563 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Sat, 2 Dec 2006 04:41:23 +0000 Subject: - Added missing min/max definitions to cbasetypes.h, needed for the @send change. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9388 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 1 + src/common/cbasetypes.h | 540 ++++++++++++++++++++++++------------------------ src/map/atcommand.c | 1 + 3 files changed, 276 insertions(+), 266 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index d4b5ebe64..c9c3eba7f 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2006/12/02 + * Added missing min/max definitions to cbasetypes.h, needed for the @send change. [FlavioJS] * Replaced @send with the version I use for testing packets. Can display the packet length. Supports dynamic packets, quoted strings with escaped characters and fixed/variable length, and normal/hex diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index fe31f4c8d..0f443192d 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -1,266 +1,274 @@ -#ifndef _CBASETYPES_H_ -#define _CBASETYPES_H_ -/* +--------+-----------+--------+---------+ - * | ILP32 | LP64 | ILP64 | (LL)P64 | - * +------------+--------+-----------+--------+---------+ - * | ints | 32-bit | 32-bit | 64-bit | 32-bit | - * | longs | 32-bit | 64-bit | 64-bit | 32-bit | - * | long-longs | 64-bit | 64-bit | 64-bit | 64-bit | - * | pointers | 32-bit | 64-bit | 64-bit | 64-bit | - * +------------+--------+-----------+--------+---------+ - * | where | -- | Tiger | Alpha | Windows | - * | used | | Unix | Cray | | - * | | | Sun & SGI | | | - * +------------+--------+-----------+--------+---------+ - * Taken from http://developer.apple.com/macosx/64bit.html - */ - -////////////////////////////////////////////////////////////////////////// -// basic include for all basics -// introduces types and global functions -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -// setting some defines on platforms -////////////////////////////////////////////////////////////////////////// -#if (defined(__WIN32__) || defined(__WIN32) || defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(WIN32) -#define WIN32 -#endif - -// __APPLE__ is the only predefined macro on MacOS X -#if defined(__APPLE__) -#define __DARWIN__ -#endif - -// 64bit OS -#if defined(_M_IA64) || defined(_M_X64) || defined(_WIN64) || defined(_LP64) || defined(_ILP64) || defined(__LP64__) || defined(__ppc64__) -#define __64BIT__ -#endif - -#if defined(_ILP64) -#error "this specific 64bit architecture is not supported" -#endif - -// debug mode -#if defined(_DEBUG) && !defined(DEBUG) -#define DEBUG -#endif - -// disable attributed stuff on non-GNU -#ifndef __GNUC__ -# define __attribute__(x) -#endif - - -////////////////////////////////////////////////////////////////////////// -// useful typedefs -////////////////////////////////////////////////////////////////////////// -#define HAVE_UCHAR -typedef unsigned char uchar; -typedef signed char schar; -typedef signed short sshort; - -#if !defined(__FREEBSD__) && !defined(_SYS_TYPES_H) - typedef unsigned short ushort; -#endif -typedef signed int sint; // don't use (only for ie. scanf) -#if !defined(__FREEBSD__) && !defined(_SYS_TYPES_H) - typedef unsigned int uint; // don't use -#endif -typedef signed long slong; // don't use (only for ie. file-io) -#ifndef _SYS_TYPES_H - typedef unsigned long ulong; // don't use -#endif - -#ifndef WIN32 -typedef char* pchar; -typedef unsigned char* puchar; -#endif -typedef const char* cchar; -typedef void* ptr; -typedef int* pint; - - -////////////////////////////////////////////////////////////////////////// -// typedefs to compensate type size change from 32bit to 64bit -// MS implements LLP64 model, normal unix does LP64, -// only Silicon Graphics/Cray goes ILP64 so don't care (and don't support) -////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////// -// Integers with guaranteed _exact_ size. -////////////////////////////////////////////////////////////////////////// - -////////////////////////////// -#ifdef WIN32 -////////////////////////////// -#define SIZEOF_LONG 4 -#define SIZEOF_INT 4 -#define HAVE_INT_8_16_32 -typedef __int8 int8; -typedef __int16 int16; -typedef __int32 int32; - -typedef signed __int8 sint8; -typedef signed __int16 sint16; -typedef signed __int32 sint32; - -typedef unsigned __int8 uint8; -typedef unsigned __int16 uint16; -typedef unsigned __int32 uint32; -////////////////////////////// -#else // GNU -////////////////////////////// -typedef char int8; -typedef short int16; -typedef int int32; - -typedef signed char sint8; -typedef signed short sint16; -typedef signed int sint32; - -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned int uint32; -////////////////////////////// -#endif -////////////////////////////// - -#undef UINT8_MIN -#undef UINT16_MIN -#undef UINT32_MIN -#define UINT8_MIN (uint8) 0 -#define UINT16_MIN (uint16)0 -#define UINT32_MIN (uint32)0 - -#undef UINT8_MAX -#undef UINT16_MAX -#undef UINT32_MAX -#define UINT8_MAX (uint8) 0xFF -#define UINT16_MAX (uint16)0xFFFF -#define UINT32_MAX (uint32)0xFFFFFFFF - -#undef SINT8_MIN -#undef SINT16_MIN -#undef SINT32_MIN -#define SINT8_MIN (sint8) 0x80 -#define SINT16_MIN (sint16)0x8000 -#define SINT32_MIN (sint32)0x80000000 - -#undef SINT8_MAX -#undef SINT16_MAX -#undef SINT32_MAX -#define SINT8_MAX (sint8) 0x7F -#define SINT16_MAX (sint16)0x7FFF -#define SINT32_MAX (sint32)0x7FFFFFFF - - -////////////////////////////////////////////////////////////////////////// -// Integers with guaranteed _minimum_ size. -// These could be larger than you expect, -// they are designed for speed. -////////////////////////////////////////////////////////////////////////// -typedef long int ppint; -typedef long int ppint8; -typedef long int ppint16; -typedef long int ppint32; - -typedef unsigned long int ppuint; -typedef unsigned long int ppuint8; -typedef unsigned long int ppuint16; -typedef unsigned long int ppuint32; - - -////////////////////////////////////////////////////////////////////////// -// integer with exact processor width (and best speed) -// size_t already defined in stdio.h -////////////////////////////// -#ifdef WIN32 // does not have a signed size_t -////////////////////////////// -#if defined(_WIN64) // naive 64bit windows platform -typedef __int64 ssize_t; -#else -typedef int ssize_t; -#endif -////////////////////////////// -#endif -////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -// portable 64-bit integers -////////////////////////////////////////////////////////////////////////// -#if defined(_MSC_VER) || defined(__BORLANDC__) -typedef __int64 int64; -typedef signed __int64 sint64; -typedef unsigned __int64 uint64; -#define LLCONST(a) (a##i64) -#else -typedef long long int64; -typedef signed long long sint64; -typedef unsigned long long uint64; -#define LLCONST(a) (a##ll) -#endif - -#ifndef INT64_MIN -#define INT64_MIN (LLCONST(-9223372036854775807)-1) -#endif -#ifndef INT64_MAX -#define INT64_MAX (LLCONST(9223372036854775807)) -#endif -#ifndef UINT64_MAX -#define UINT64_MAX (LLCONST(18446744073709551615u)) -#endif - - -////////////////////////////////////////////////////////////////////////// -// some redefine of function redefines for some Compilers -////////////////////////////////////////////////////////////////////////// -#if defined(_MSC_VER) || defined(__BORLANDC__) -#define strcasecmp stricmp -#define strncasecmp strnicmp -#define snprintf _snprintf -#define vsnprintf _vsnprintf -#endif - -// keyword replacement in windows -#ifdef _WIN32 -#define inline __inline -#endif - -///////////////////////////// -// for those still not building c++ -#ifndef __cplusplus -////////////////////////////// - -// boolean types for C -typedef int bool; -#define false (1==0) -#define true (1==1) - -////////////////////////////// -#endif // not cplusplus -////////////////////////////// - -#ifdef swap // just to be sure -#undef swap -#endif -// hmm only ints? -//#define swap(a,b) { int temp=a; a=b; b=temp;} -// if using macros then something that is type independent -#define swap(a,b) ((a == b) || ((a ^= b), (b ^= a), (a ^= b))) - -////////////////////////////////////////////////////////////////////////// -// should not happen -#ifndef NULL -#define NULL (void *)0 -#endif - -////////////////////////////////////////////////////////////////////////// -// number of bits in a byte -#ifndef NBBY -#define NBBY 8 -#endif - -#endif /* _CBASETYPES_H_ */ +#ifndef _CBASETYPES_H_ +#define _CBASETYPES_H_ +/* +--------+-----------+--------+---------+ + * | ILP32 | LP64 | ILP64 | (LL)P64 | + * +------------+--------+-----------+--------+---------+ + * | ints | 32-bit | 32-bit | 64-bit | 32-bit | + * | longs | 32-bit | 64-bit | 64-bit | 32-bit | + * | long-longs | 64-bit | 64-bit | 64-bit | 64-bit | + * | pointers | 32-bit | 64-bit | 64-bit | 64-bit | + * +------------+--------+-----------+--------+---------+ + * | where | -- | Tiger | Alpha | Windows | + * | used | | Unix | Cray | | + * | | | Sun & SGI | | | + * +------------+--------+-----------+--------+---------+ + * Taken from http://developer.apple.com/macosx/64bit.html + */ + +////////////////////////////////////////////////////////////////////////// +// basic include for all basics +// introduces types and global functions +////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +// setting some defines on platforms +////////////////////////////////////////////////////////////////////////// +#if (defined(__WIN32__) || defined(__WIN32) || defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(WIN32) +#define WIN32 +#endif + +// __APPLE__ is the only predefined macro on MacOS X +#if defined(__APPLE__) +#define __DARWIN__ +#endif + +// 64bit OS +#if defined(_M_IA64) || defined(_M_X64) || defined(_WIN64) || defined(_LP64) || defined(_ILP64) || defined(__LP64__) || defined(__ppc64__) +#define __64BIT__ +#endif + +#if defined(_ILP64) +#error "this specific 64bit architecture is not supported" +#endif + +// debug mode +#if defined(_DEBUG) && !defined(DEBUG) +#define DEBUG +#endif + +// disable attributed stuff on non-GNU +#ifndef __GNUC__ +# define __attribute__(x) +#endif + + +////////////////////////////////////////////////////////////////////////// +// useful typedefs +////////////////////////////////////////////////////////////////////////// +#define HAVE_UCHAR +typedef unsigned char uchar; +typedef signed char schar; +typedef signed short sshort; + +#if !defined(__FREEBSD__) && !defined(_SYS_TYPES_H) + typedef unsigned short ushort; +#endif +typedef signed int sint; // don't use (only for ie. scanf) +#if !defined(__FREEBSD__) && !defined(_SYS_TYPES_H) + typedef unsigned int uint; // don't use +#endif +typedef signed long slong; // don't use (only for ie. file-io) +#ifndef _SYS_TYPES_H + typedef unsigned long ulong; // don't use +#endif + +#ifndef WIN32 +typedef char* pchar; +typedef unsigned char* puchar; +#endif +typedef const char* cchar; +typedef void* ptr; +typedef int* pint; + + +////////////////////////////////////////////////////////////////////////// +// typedefs to compensate type size change from 32bit to 64bit +// MS implements LLP64 model, normal unix does LP64, +// only Silicon Graphics/Cray goes ILP64 so don't care (and don't support) +////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////// +// Integers with guaranteed _exact_ size. +////////////////////////////////////////////////////////////////////////// + +////////////////////////////// +#ifdef WIN32 +////////////////////////////// +#define SIZEOF_LONG 4 +#define SIZEOF_INT 4 +#define HAVE_INT_8_16_32 +typedef __int8 int8; +typedef __int16 int16; +typedef __int32 int32; + +typedef signed __int8 sint8; +typedef signed __int16 sint16; +typedef signed __int32 sint32; + +typedef unsigned __int8 uint8; +typedef unsigned __int16 uint16; +typedef unsigned __int32 uint32; +////////////////////////////// +#else // GNU +////////////////////////////// +typedef char int8; +typedef short int16; +typedef int int32; + +typedef signed char sint8; +typedef signed short sint16; +typedef signed int sint32; + +typedef unsigned char uint8; +typedef unsigned short uint16; +typedef unsigned int uint32; +////////////////////////////// +#endif +////////////////////////////// + +#undef UINT8_MIN +#undef UINT16_MIN +#undef UINT32_MIN +#define UINT8_MIN (uint8) 0 +#define UINT16_MIN (uint16)0 +#define UINT32_MIN (uint32)0 + +#undef UINT8_MAX +#undef UINT16_MAX +#undef UINT32_MAX +#define UINT8_MAX (uint8) 0xFF +#define UINT16_MAX (uint16)0xFFFF +#define UINT32_MAX (uint32)0xFFFFFFFF + +#undef SINT8_MIN +#undef SINT16_MIN +#undef SINT32_MIN +#define SINT8_MIN (sint8) 0x80 +#define SINT16_MIN (sint16)0x8000 +#define SINT32_MIN (sint32)0x80000000 + +#undef SINT8_MAX +#undef SINT16_MAX +#undef SINT32_MAX +#define SINT8_MAX (sint8) 0x7F +#define SINT16_MAX (sint16)0x7FFF +#define SINT32_MAX (sint32)0x7FFFFFFF + + +////////////////////////////////////////////////////////////////////////// +// Integers with guaranteed _minimum_ size. +// These could be larger than you expect, +// they are designed for speed. +////////////////////////////////////////////////////////////////////////// +typedef long int ppint; +typedef long int ppint8; +typedef long int ppint16; +typedef long int ppint32; + +typedef unsigned long int ppuint; +typedef unsigned long int ppuint8; +typedef unsigned long int ppuint16; +typedef unsigned long int ppuint32; + + +////////////////////////////////////////////////////////////////////////// +// integer with exact processor width (and best speed) +// size_t already defined in stdio.h +////////////////////////////// +#ifdef WIN32 // does not have a signed size_t +////////////////////////////// +#if defined(_WIN64) // naive 64bit windows platform +typedef __int64 ssize_t; +#else +typedef int ssize_t; +#endif +////////////////////////////// +#endif +////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +// portable 64-bit integers +////////////////////////////////////////////////////////////////////////// +#if defined(_MSC_VER) || defined(__BORLANDC__) +typedef __int64 int64; +typedef signed __int64 sint64; +typedef unsigned __int64 uint64; +#define LLCONST(a) (a##i64) +#else +typedef long long int64; +typedef signed long long sint64; +typedef unsigned long long uint64; +#define LLCONST(a) (a##ll) +#endif + +#ifndef INT64_MIN +#define INT64_MIN (LLCONST(-9223372036854775807)-1) +#endif +#ifndef INT64_MAX +#define INT64_MAX (LLCONST(9223372036854775807)) +#endif +#ifndef UINT64_MAX +#define UINT64_MAX (LLCONST(18446744073709551615u)) +#endif + + +////////////////////////////////////////////////////////////////////////// +// some redefine of function redefines for some Compilers +////////////////////////////////////////////////////////////////////////// +#if defined(_MSC_VER) || defined(__BORLANDC__) +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define snprintf _snprintf +#define vsnprintf _vsnprintf +#endif + +// keyword replacement in windows +#ifdef _WIN32 +#define inline __inline +#endif + +///////////////////////////// +// for those still not building c++ +#ifndef __cplusplus +////////////////////////////// + +// boolean types for C +typedef int bool; +#define false (1==0) +#define true (1==1) + +////////////////////////////// +#endif // not cplusplus +////////////////////////////// + +#ifdef swap // just to be sure +#undef swap +#endif +// hmm only ints? +//#define swap(a,b) { int temp=a; a=b; b=temp;} +// if using macros then something that is type independent +#define swap(a,b) ((a == b) || ((a ^= b), (b ^= a), (a ^= b))) + +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +////////////////////////////////////////////////////////////////////////// +// should not happen +#ifndef NULL +#define NULL (void *)0 +#endif + +////////////////////////////////////////////////////////////////////////// +// number of bits in a byte +#ifndef NBBY +#define NBBY 8 +#endif + +#endif /* _CBASETYPES_H_ */ diff --git a/src/map/atcommand.c b/src/map/atcommand.c index a4badbaef..6289d6027 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -8,6 +8,7 @@ #include #include +#include "../common/cbasetypes.h" #include "../common/timer.h" #include "../common/nullpo.h" #include "../common/mmo.h" -- cgit v1.2.3-70-g09d2 From 59aae2ed7a29f22b90bec24962e83d7a420dc4d1 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Thu, 7 Dec 2006 23:59:26 +0000 Subject: - Fixed ladmin's linux compilation and moved some platform specific defines to cbasetypes.h git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9435 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 4 +++- src/common/Makefile | 6 +++++- src/common/cbasetypes.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/common/mmo.h | 26 +------------------------- src/common/utils.c | 6 ++---- 5 files changed, 55 insertions(+), 31 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 2428b44d3..0ea330629 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,7 +3,9 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. -2004/12/07 +2006/12/07 + * Fixed ladmin's linux compilation and moved some platform specific + defines to cbasetypes.h [FlavioJS] * Cleaned up implementation of NPC_EMOTION/NPC_EMOTION_ON. Now val0 is the emotion, val1 sets the mode, val2 adds to the mode, val3 removes from the mode. val4 asks to remove the previous mode change, otherwise it will stack diff --git a/src/common/Makefile b/src/common/Makefile index 2c929b52b..e601baae4 100644 --- a/src/common/Makefile +++ b/src/common/Makefile @@ -29,9 +29,10 @@ ifeq ($(findstring /,$(HAVESVN)), /) svnversion.h: @printf "#define SVNVERSION " > svnversion.h @svnversion . >> svnversion.h + @printf "\n" >> svnversion.h else svnversion.h: - @printf "" > svnversion.h + @printf "\n" > svnversion.h endif obj/minicore.o: core.c core.h @@ -54,3 +55,6 @@ obj/plugins.o: plugins.c plugins.h plugin.h obj/showmsg.o: showmsg.c showmsg.h obj/strlib.o: strlib.c strlib.h utils.h obj/mapindex.o: mapindex.c mapindex.h +obj/utils.o: utils.c utils.h malloc.h showmsg.h mmo.h +mmo.h: cbasetypes.h + @touch mmo.h diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 0f443192d..ff00aaa49 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -243,6 +243,9 @@ typedef int bool; #endif // not cplusplus ////////////////////////////// +////////////////////////////////////////////////////////////////////////// +// macro tools + #ifdef swap // just to be sure #undef swap #endif @@ -271,4 +274,45 @@ typedef int bool; #define NBBY 8 #endif +////////////////////////////////////////////////////////////////////////// +// path separator + +#if defined(WIN32) +#define PATHSEP '\\' +#elif defined(__APPLE__) +#define PATHSEP ':' +#else +#define PATHSEP '/' +#endif + +////////////////////////////////////////////////////////////////////////// +// EOL separator + +#if defined(WIN32) || defined(CYGWIN) +#define RETCODE "\r\n" // CR/LF : Windows systems +#elif defined(__APPLE__) +#define RETCODE "\r" // CR : Macintosh systems +#else +#define RETCODE "\n" // LF : Unix systems +#endif + +#define RET RETCODE + +////////////////////////////////////////////////////////////////////////// +// Assert + +#if ! defined(Assert) +#if defined(RELEASE) +#define Assert(EX) +#else +// extern "C" { +#include +// } +#if !defined(DEFCPP) && defined(WIN32) && !defined(MINGW) +#include +#endif +#define Assert(EX) assert(EX) +#endif +#endif /* ! defined(Assert) */ + #endif /* _CBASETYPES_H_ */ diff --git a/src/common/mmo.h b/src/common/mmo.h index f65da260b..d0606dd4e 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -5,33 +5,9 @@ #define _MMO_H_ #include +#include "cbasetypes.h" #include "utils.h" // _WIN32 -#if ! defined(Assert) -#if defined(RELEASE) -#define Assert(EX) -#else -// extern "C" { -#include -// } -#ifndef DEFCPP -#if defined(_WIN32) && !defined(MINGW) -#include -#endif -#endif -#define Assert(EX) assert(EX) -#endif -#endif /* ! defined(Assert) */ - -#ifdef CYGWIN -// txtやlogなどの書き出すファイルの改行コード -#define RETCODE "\r\n" // (CR/LF:Windows系) -#else -#define RETCODE "\n" // (LF:Unix系) -#endif - -#define RET RETCODE - #define FIFOSIZE_SERVERLINK 256*1024 // set to 0 to not check IP of player between each server. diff --git a/src/common/utils.c b/src/common/utils.c index c7b3b517a..6d4abb26d 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -8,12 +8,10 @@ #ifdef WIN32 #include - #define PATHSEP '\\' #else #include #include #include - #define PATHSEP '/' #endif #include "utils.h" @@ -285,8 +283,8 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) } }while (FindNextFile(hFind, &FindFileData) != 0); FindClose(hFind); - } - return; + } + return; } #else -- cgit v1.2.3-70-g09d2 From 1427a87a2ad9a4fc947996fff2c7d85d265b67d3 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Tue, 12 Dec 2006 15:24:20 +0000 Subject: - Minor changes to ers. - Removed unused/hardly used cbasetypes typedefs. - Updated txt-converter's makefile to include utils.o git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9473 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 + src/common/cbasetypes.h | 31 +------- src/common/db.c | 4 +- src/common/db.h | 2 +- src/common/ers.c | 137 +++++++++++++++--------------------- src/common/ers.h | 32 +-------- src/common/showmsg.c | 12 ++-- src/map/atcommand.c | 3 +- src/map/battle.c | 2 +- src/map/clif.c | 2 +- src/map/guild.c | 2 +- src/map/mob.c | 4 +- src/map/npc.c | 2 +- src/map/pet.c | 4 +- src/map/skill.c | 4 +- src/txt-converter/Makefile | 4 +- src/txt-converter/char-converter.c | 2 +- src/txt-converter/login-converter.c | 6 +- 18 files changed, 90 insertions(+), 166 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 35b0c92cc..606a3d8eb 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2006/12/12 + * Minor changes to ers. + * Removed unused/hardly used cbasetypes typedefs. + * Updated txt-converter's makefile to include utils.o [FlavioJS] * Updated npc_event_dequeue to free up your current npc information, and not just the npc_id. * Modified the skill damage packet and the knockback packets to mimic aegis diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index ff00aaa49..f02b8734c 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -53,35 +53,6 @@ #endif -////////////////////////////////////////////////////////////////////////// -// useful typedefs -////////////////////////////////////////////////////////////////////////// -#define HAVE_UCHAR -typedef unsigned char uchar; -typedef signed char schar; -typedef signed short sshort; - -#if !defined(__FREEBSD__) && !defined(_SYS_TYPES_H) - typedef unsigned short ushort; -#endif -typedef signed int sint; // don't use (only for ie. scanf) -#if !defined(__FREEBSD__) && !defined(_SYS_TYPES_H) - typedef unsigned int uint; // don't use -#endif -typedef signed long slong; // don't use (only for ie. file-io) -#ifndef _SYS_TYPES_H - typedef unsigned long ulong; // don't use -#endif - -#ifndef WIN32 -typedef char* pchar; -typedef unsigned char* puchar; -#endif -typedef const char* cchar; -typedef void* ptr; -typedef int* pint; - - ////////////////////////////////////////////////////////////////////////// // typedefs to compensate type size change from 32bit to 64bit // MS implements LLP64 model, normal unix does LP64, @@ -235,7 +206,7 @@ typedef unsigned long long uint64; ////////////////////////////// // boolean types for C -typedef int bool; +typedef char bool; #define false (1==0) #define true (1==1) diff --git a/src/common/db.c b/src/common/db.c index 28b5721e9..a65e87918 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -186,7 +186,7 @@ typedef struct db { unsigned int free_max; unsigned int free_lock; // Other - ERInterface nodes; + ERS nodes; DBComparator cmp; DBHasher hash; DBReleaser release; @@ -2165,7 +2165,7 @@ DBInterface db_alloc(const char *file, int line, DBType type, DBOptions options, db->free_max = 0; db->free_lock = 0; /* Other */ - db->nodes = ers_new((uint32)sizeof(struct dbn)); + db->nodes = ers_new(sizeof(struct dbn)); db->cmp = db_default_cmp(type); db->hash = db_default_hash(type); db->release = db_default_release(type, options); diff --git a/src/common/db.h b/src/common/db.h index b17ae27f9..2f02c1bfa 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -159,7 +159,7 @@ typedef enum { typedef union { int i; unsigned int ui; - unsigned char *str; + unsigned char *str;//## TODO change to 'const char *' } DBKey; /** diff --git a/src/common/ers.c b/src/common/ers.c index 22dd8d87e..485bab7d9 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -50,15 +50,14 @@ * ERS_BLOCK_ENTRIES - Number of entries in each block. * * ERS_ROOT_SIZE - Maximum number of root entry managers. * * ERLinkedList - Structure of a linked list of reusable entries. * - * ERSystem - Class of an entry manager. * + * ERS_impl - Class of an entry manager. * * ers_root - Array of root entry managers. * * ers_num - Number of root entry managers in the array. * \*****************************************************************************/ /** * Number of entries in each block. - * @private - * @see #ers_obj_alloc_entry(ERInterface eri) + * @see #ers_obj_alloc_entry(ERS eri) */ #define ERS_BLOCK_ENTRIES 4096 @@ -74,7 +73,7 @@ * Linked list of reusable entries. * The minimum size of the entries is the size of this structure. * @private - * @see ERSystem#reuse + * @see ERS_impl#reuse */ typedef struct ers_ll { struct ers_ll *next; @@ -92,7 +91,7 @@ typedef struct ers_ll { * @param size Size of the entries of the manager * @private */ -typedef struct ers { +typedef struct ers_impl { /** * Public interface of the entry manager. @@ -101,61 +100,45 @@ typedef struct ers { * @param entry_size Return the size of the entries of this manager * @param destroy Destroy this instance of the manager * @public - * @see #ERSystem - * @see common\ers.h#ERInterface */ - struct eri eri; + struct eri vtable; /** * Linked list of reusable entries. - * @private - * @see #ERSystem */ ERLinkedList reuse; /** * Array with blocks of entries. - * @private - * @see #ERSystem */ uint8 **blocks; /** * Number of unused entries in the last block. - * @private - * @see #ERSystem */ uint32 free; /** * Number of blocks in the array. - * @private - * @see #ERSystem */ uint32 num; /** * Current maximum capacity of the array. - * @private - * @see #ERSystem */ uint32 max; /** * Destroy lock. - * @private - * @see #ERSystem */ uint32 destroy; /** * Size of the entries of the manager. - * @private - * @see #ERSystem */ - uint32 size; + size_t size; -} *ERSystem; +} *ERS_impl; /** * Root array with entry managers. @@ -164,7 +147,7 @@ typedef struct ers { * @see #ERS_ROOT_SIZE * @see #ers_num */ -static ERSystem ers_root[ERS_ROOT_SIZE]; +static ERS_impl ers_root[ERS_ROOT_SIZE]; /** * Number of entry managers in the root array. @@ -176,7 +159,7 @@ static ERSystem ers_root[ERS_ROOT_SIZE]; static uint32 ers_num = 0; /*****************************************************************************\ - * (2) Protected functions. * + * (2) Object functions. * * ers_obj_alloc_entry - Allocate an entry from the manager. * * ers_obj_free_entry - Free an entry allocated from the manager. * * ers_obj_entry_size - Return the size of the entries of the manager. * @@ -188,19 +171,17 @@ static uint32 ers_num = 0; * If there are reusable entries available, it reuses one instead. * @param self Interface of the entry manager * @return An entry - * @protected * @see #ERS_BLOCK_ENTRIES * @see #ERLinkedList - * @see #ERSystem - * @see common\ers.h\ERInterface#alloc(ERInterface) + * @see ERS_impl::vtable#alloc */ -static void *ers_obj_alloc_entry(ERInterface self) +static void *ers_obj_alloc_entry(ERS self) { - ERSystem obj = (ERSystem)self; + ERS_impl obj = (ERS_impl)self; void *ret; if (obj == NULL) { - ShowError("ers_obj_alloc_entry: NULL object, aborting entry allocation.\n"); + ShowError("ers::alloc : NULL object, aborting entry allocation.\n"); return NULL; } @@ -213,11 +194,11 @@ static void *ers_obj_alloc_entry(ERInterface self) } else { // allocate a new block if (obj->num == obj->max) { // expand the block array if (obj->max == UINT32_MAX) { // No more space for blocks - ShowFatalError("ers_obj_alloc_entry: maximum number of blocks reached, increase ERS_BLOCK_ENTRIES.\n" + ShowFatalError("ers::alloc : maximum number of blocks reached, increase ERS_BLOCK_ENTRIES.\n" "exiting the program...\n"); exit(EXIT_FAILURE); } - obj->max = (obj->max<<2) +3; // = obj->max*4 +3; - overflow won't happen + obj->max = (obj->max*4)+3; // left shift bits '11' - overflow won't happen RECREATE(obj->blocks, uint8 *, obj->max); } CREATE(obj->blocks[obj->num], uint8, obj->size*ERS_BLOCK_ENTRIES); @@ -234,22 +215,20 @@ static void *ers_obj_alloc_entry(ERInterface self) * Freeing such an entry can lead to unexpected behaviour. * @param self Interface of the entry manager * @param entry Entry to be freed - * @protected * @see #ERLinkedList - * @see #ERSystem - * @see ERSystem#reuse - * @see common\ers.h\ERInterface#free(ERInterface,void *) + * @see ERS_impl#reuse + * @see ERS_impl::vtable#free */ -static void ers_obj_free_entry(ERInterface self, void *entry) +static void ers_obj_free_entry(ERS self, void *entry) { - ERSystem obj = (ERSystem)self; + ERS_impl obj = (ERS_impl)self; ERLinkedList reuse; if (obj == NULL) { - ShowError("ers_obj_free_entry: NULL object, aborting entry freeing.\n"); + ShowError("ers::free : NULL object, aborting entry freeing.\n"); return; } else if (entry == NULL) { - ShowError("ers_obj_free_entry: NULL entry, nothing to free.\n"); + ShowError("ers::free : NULL entry, nothing to free.\n"); return; } @@ -262,17 +241,15 @@ static void ers_obj_free_entry(ERInterface self, void *entry) * Return the size of the entries allocated from this manager. * @param self Interface of the entry manager * @return Size of the entries of this manager in bytes - * @protected - * @see #ERSystem - * @see ERSystem#size - * @see common\ers.h\ERInterface#enty_size(ERInterface) + * @see ERS_impl#size + * @see ERS_impl::vtable#entry_size */ -static uint32 ers_obj_entry_size(ERInterface self) +static uint32 ers_obj_entry_size(ERS self) { - ERSystem obj = (ERSystem)self; + ERS_impl obj = (ERS_impl)self; if (obj == NULL) { - ShowError("ers_obj_entry_size: NULL object, returning 0.\n"); + ShowError("ers::entry_size : NULL object, returning 0.\n"); return 0; } @@ -285,19 +262,18 @@ static uint32 ers_obj_entry_size(ERInterface self) * When destroying the manager a warning is shown if the manager has * missing/extra entries. * @param self Interface of the entry manager - * @protected * @see #ERLinkedList - * @see #ERSystem - * @see common\ers.h\ERInterface#destroy(ERInterface) + * @see ERS_impl::vtable#destroy */ -static void ers_obj_destroy(ERInterface self) +static void ers_obj_destroy(ERS self) { - ERSystem obj = (ERSystem)self; + ERS_impl obj = (ERS_impl)self; ERLinkedList reuse,old; - uint32 i, count; + uint32 i; + uint32 count; if (obj == NULL) { - ShowError("ers_obj_destroy: NULL object, aborting instance destruction.\n"); + ShowError("ers::destroy: NULL object, aborting instance destruction.\n"); return; } @@ -334,14 +310,14 @@ static void ers_obj_destroy(ERInterface self) } } if (count) { // missing entries - ShowWarning("ers_obj_destroy: %u entries missing (possible double free), continuing destruction (entry size=%u).", + ShowWarning("ers::destroy : %u entries missing (possible double free), continuing destruction (entry size=%u).", count, obj->size); } else if (reuse) { // extra entries while (reuse && count != UINT32_MAX) { count++; reuse = reuse->next; } - ShowWarning("ers_obj_destroy: %u extra entries found, continuing destruction (entry size=%u).", + ShowWarning("ers::destroy : %u extra entries found, continuing destruction (entry size=%u).", count, obj->size); } // destroy the entry manager @@ -369,17 +345,13 @@ static void ers_obj_destroy(ERInterface self) * ERS_ALIGNED that is greater or equal to size is what's actually used. * @param The requested size of the entry in bytes * @return Interface of the object - * @public - * @see #ERSystem + * @see #ERS_impl * @see #ers_root * @see #ers_num - * @see common\ers.h#ERInterface - * @see common\ers.h\ERInterface#destroy(ERInterface) - * @see common\ers.h#ers_new_(uint32) */ -ERInterface ers_new(uint32 size) +ERS ers_new(size_t size) { - ERSystem obj; + ERS_impl obj; uint32 i; if (size == 0) { @@ -398,7 +370,7 @@ ERInterface ers_new(uint32 size) if (obj->size == size) { // found a manager that handles the entry size obj->destroy++; - return &obj->eri; + return &obj->vtable; } } // create a new manager to handle the entry size @@ -407,12 +379,12 @@ ERInterface ers_new(uint32 size) "exiting the program...\n"); exit(EXIT_FAILURE); } - obj = (ERSystem)aMalloc(sizeof(struct ers)); + obj = (ERS_impl)aMalloc(sizeof(struct ers_impl)); // Public interface - obj->eri.alloc = ers_obj_alloc_entry; - obj->eri.free = ers_obj_free_entry; - obj->eri.entry_size = ers_obj_entry_size; - obj->eri.destroy = ers_obj_destroy; + obj->vtable.alloc = ers_obj_alloc_entry; + obj->vtable.free = ers_obj_free_entry; + obj->vtable.entry_size = ers_obj_entry_size; + obj->vtable.destroy = ers_obj_destroy; // Block reusage system obj->reuse = NULL; obj->blocks = NULL; @@ -423,7 +395,7 @@ ERInterface ers_new(uint32 size) // Properties obj->size = size; ers_root[ers_num++] = obj; - return &obj->eri; + return &obj->vtable; } /** @@ -432,18 +404,20 @@ ERInterface ers_new(uint32 size) * The number of entries are checked and a warning is shown if extra reusable * entries are found. * The extra entries are included in the count of reusable entries. - * @public * @see #ERLinkedList - * @see #ERSystem + * @see #ERS_impl * @see #ers_root * @see #ers_num - * @see common\ers.h#ers_report(void) */ void ers_report(void) { - uint32 i, j, used, reusable, extra; + uint32 i; + uint32 j; + uint32 used; + uint32 reusable; + uint32 extra; ERLinkedList reuse; - ERSystem obj; + ERS_impl obj; // Root system report ShowMessage(CL_BOLD"Entry Reusage System report:\n"CL_NORMAL); @@ -506,16 +480,15 @@ void ers_report(void) * The use of this is NOT recommended. * It should only be used in extreme situations to make shure all the memory * allocated by this system is released. - * @public - * @see #ERSystem + * @see #ERS_impl * @see #ers_root * @see #ers_num - * @see common\ers.h#ers_force_destroy_all(void) */ void ers_force_destroy_all(void) { - uint32 i, j; - ERSystem obj; + uint32 i; + uint32 j; + ERS_impl obj; for (i = 0; i < ers_num; i++) { obj = ers_root[i]; diff --git a/src/common/ers.h b/src/common/ers.h index 9b6b4b62d..e07ec7137 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -36,7 +36,6 @@ * @version 0.1 - Initial version * * @author Flavio @ Amazon Project * * @encoding US-ASCII * - * @see common#ers.c * \*****************************************************************************/ #ifndef _ERS_H_ #define _ERS_H_ @@ -47,7 +46,7 @@ * (1) All public parts of the Entry Reusage System. * * DISABLE_ERS - Define to disable this system. * * ERS_ALIGNED - Alignment of the entries in the blocks. * - * ERInterface - Interface of the entry manager. * + * ERS - Entry manager. * * ers_new - Allocate an instance of an entry manager. * * ers_report - Print a report about the current state. * * ers_force_destroy_all - Force the destruction of all the managers. * @@ -57,7 +56,6 @@ * Define this to disable the Entry Reusage System. * All code except the typedef of ERInterface will be disabled. * To allow a smooth transition, - * @public */ //#define DISABLE_ERS @@ -67,8 +65,6 @@ * This should NEVER be set to zero or less. * If greater than one, some memory can be wasted. This should never be needed * but is here just in case some aligment issues arise. - * @public - * @see #ers_new(uint32) */ #ifndef ERS_ALIGNED # define ERS_ALIGNED 1 @@ -80,8 +76,6 @@ * @param free Free an entry allocated from this manager * @param entry_size Return the size of the entries of this manager * @param destroy Destroy this instance of the manager - * @public - * @see #ers_new(uint32) */ typedef struct eri { @@ -90,9 +84,6 @@ typedef struct eri { * If there are reusable entries available, it reuses one instead. * @param self Interface of the entry manager * @return An entry - * @protected - * @see #ERInterface - * @see ERInterface#free(ERInterface,void *) */ void *(*alloc)(struct eri *self); @@ -102,9 +93,6 @@ typedef struct eri { * Freeing such an entry can lead to unexpected behaviour. * @param self Interface of the entry manager * @param entry Entry to be freed - * @protected - * @see #ERInterface - * @see ERInterface#alloc(ERInterface) */ void (*free)(struct eri *self, void *entry); @@ -112,8 +100,6 @@ typedef struct eri { * Return the size of the entries allocated from this manager. * @param self Interface of the entry manager * @return Size of the entries of this manager in bytes - * @protected - * @see #ERInterface */ uint32 (*entry_size)(struct eri *self); @@ -123,13 +109,10 @@ typedef struct eri { * When destroying the manager a warning is shown if the manager has * missing/extra entries. * @param self Interface of the entry manager - * @protected - * @see #ERInterface - * @see #ers_new(uint32) */ void (*destroy)(struct eri *self); -} *ERInterface; +} *ERS; #ifdef DISABLE_ERS // Use memory manager to allocate/free and disable other interface functions @@ -158,13 +141,8 @@ typedef struct eri { * ERS_ALIGNED that is greater or equal to size is what's actually used. * @param The requested size of the entry in bytes * @return Interface of the object - * @public - * @see #ERS_ALIGNED - * @see #ERInterface - * @see ERInterface#destroy(ERInterface) - * @see common\ers.c#ers_new(uint32) */ -ERInterface ers_new(uint32 size); +ERS ers_new(size_t size); /** * Print a report about the current state of the Entry Reusage System. @@ -172,8 +150,6 @@ ERInterface ers_new(uint32 size); * The number of entries are checked and a warning is shown if extra reusable * entries are found. * The extra entries are included in the count of reusable entries. - * @public - * @see common\ers.c#ers_report(void) */ void ers_report(void); @@ -184,8 +160,6 @@ void ers_report(void); * The use of this is NOT recommended. * It should only be used in extreme situations to make shure all the memory * allocated by this system is released. - * @public - * @see common\ers.c#ers_force_destroy_all(void) */ void ers_force_destroy_all(void); #endif /* DISABLE_ERS / not DISABLE_ERS */ diff --git a/src/common/showmsg.c b/src/common/showmsg.c index fa9ea650b..4d4fcafd6 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -230,7 +230,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) { // from here, we will skip the '\033[' // we break at the first unprocessible position // assuming regular text is starting there - uchar numbers[16], numpoint=0; + uint8 numbers[16], numpoint=0; CONSOLE_SCREEN_BUFFER_INFO info; // initialize @@ -266,7 +266,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) } else if( *q == 'm' ) { // \033[#;...;#m - Set Graphics Rendition (SGR) - uint i; + uint8 i; for(i=0; i<= numpoint; ++i) { if( 0x00 == (0xF0 & numbers[i]) ) @@ -314,7 +314,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) } else if( 0x30 == (0xF0 & numbers[i]) ) { // foreground - uint num = numbers[i]&0x0F; + uint8 num = numbers[i]&0x0F; if(num==9) info.wAttributes |= FOREGROUND_INTENSITY; if(num>7) num=7; // set white for 37, 38 and 39 info.wAttributes &= ~(FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE); @@ -327,7 +327,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) } else if( 0x40 == (0xF0 & numbers[i]) ) { // background - uint num = numbers[i]&0x0F; + uint8 num = numbers[i]&0x0F; if(num==9) info.wAttributes |= BACKGROUND_INTENSITY; if(num>7) num=7; // set white for 47, 48 and 49 info.wAttributes &= ~(BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE); @@ -347,7 +347,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) // \033[0J - Clears the screen from cursor to end of display. The cursor position is unchanged. // \033[1J - Clears the screen from start to cursor. The cursor position is unchanged. // \033[2J - Clears the screen and moves the cursor to the home position (line 1, column 1). - uint num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F); + uint8 num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F); int cnt; COORD origin = {0,0}; if(num==1) @@ -373,7 +373,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) // \033[1K - Clears all characters from start of line to the cursor position. // \033[2K - Clears all characters of the whole line. - uint num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F); + uint8 num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F); COORD origin = {0,info.dwCursorPosition.Y}; SHORT cnt; if(num==1) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 823dde505..2ee492e53 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -8,10 +8,9 @@ #include #include -#include "../common/cbasetypes.h" +#include "../common/mmo.h" #include "../common/timer.h" #include "../common/nullpo.h" -#include "../common/mmo.h" #include "../common/core.h" #include "../common/showmsg.h" #include "../common/malloc.h" diff --git a/src/map/battle.c b/src/map/battle.c index b1e194247..e315142f9 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -4480,7 +4480,7 @@ int battle_config_read(const char *cfgName) } void do_init_battle(void) { - delay_damage_ers = ers_new((uint32)sizeof(struct delay_damage)); + delay_damage_ers = ers_new(sizeof(struct delay_damage)); } void do_final_battle(void) { diff --git a/src/map/clif.c b/src/map/clif.c index a1fc5447d..78fcb647b 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -3242,7 +3242,7 @@ int clif_changeoption(struct block_list* bl) WBUFW(buf,6) = sc->opt1; WBUFW(buf,8) = sc->opt2; WBUFL(buf,10) = sc->option; - WBUFB(buf,14) = 0; // ?? + WBUFB(buf,14) = 0; // PK??? if(disguised(bl)) { clif_send(buf,packet_len_table[0x229],bl,AREA_WOS); WBUFL(buf,2) = -bl->id; diff --git a/src/map/guild.c b/src/map/guild.c index 6ad15968e..0ddb966d5 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -206,7 +206,7 @@ void do_init_guild(void) castle_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_RELEASE_DATA,sizeof(int)); guild_expcache_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int)); guild_infoevent_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int)); - expcache_ers = ers_new((uint32)sizeof(struct guild_expcache)); + expcache_ers = ers_new(sizeof(struct guild_expcache)); guild_castleinfoevent_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int)); guild_read_castledb(); diff --git a/src/map/mob.c b/src/map/mob.c index d357c1199..286146e5c 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -4195,8 +4195,8 @@ int do_init_mob(void) malloc_set(mob_db_data,0,sizeof(mob_db_data)); //Clear the array mob_db_data[0] = aCalloc(1, sizeof (struct mob_data)); //This mob is used for random spawns mob_makedummymobdb(0); //The first time this is invoked, it creates the dummy mob - item_drop_ers = ers_new((uint32)sizeof(struct item_drop)); - item_drop_list_ers = ers_new((uint32)sizeof(struct item_drop_list)); + item_drop_ers = ers_new(sizeof(struct item_drop)); + item_drop_list_ers = ers_new(sizeof(struct item_drop_list)); #ifndef TXT_ONLY if(db_use_sqldbs) diff --git a/src/map/npc.c b/src/map/npc.c index 6e39f3a20..629d9e94f 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -3013,7 +3013,7 @@ int do_init_npc(void) npcname_db = db_alloc(__FILE__,__LINE__,DB_STRING,DB_OPT_BASE,NAME_LENGTH); malloc_set(&ev_tm_b, -1, sizeof(ev_tm_b)); - timer_event_ers = ers_new((uint32)sizeof(struct timer_event_data)); + timer_event_ers = ers_new(sizeof(struct timer_event_data)); for (nsl = npc_src_first; nsl; nsl = nsl->next) { npc_parsesrcfile(nsl->name); diff --git a/src/map/pet.c b/src/map/pet.c index 4d153be8d..035514bd1 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -1371,8 +1371,8 @@ int do_init_pet(void) malloc_set(pet_db,0,sizeof(pet_db)); read_petdb(); - item_drop_ers = ers_new((uint32)sizeof(struct item_drop)); - item_drop_list_ers = ers_new((uint32)sizeof(struct item_drop_list)); + item_drop_ers = ers_new(sizeof(struct item_drop)); + item_drop_list_ers = ers_new(sizeof(struct item_drop_list)); add_timer_func_list(pet_hungry,"pet_hungry"); add_timer_func_list(pet_ai_hard,"pet_ai_hard"); diff --git a/src/map/skill.c b/src/map/skill.c index fc440ecf0..c7f135df1 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -11647,8 +11647,8 @@ int do_init_skill (void) skill_readdb(); skill_dance_switch_sub(NULL, NULL, 2); //Initialize Song/Dance overlap switch code. - skill_unit_ers = ers_new((uint32)sizeof(struct skill_unit_group)); - skill_timer_ers = ers_new((uint32)sizeof(struct skill_timerskill)); + skill_unit_ers = ers_new(sizeof(struct skill_unit_group)); + skill_timer_ers = ers_new(sizeof(struct skill_timerskill)); if (battle_config.skill_sp_override_grffile) skill_read_skillspamount(); diff --git a/src/txt-converter/Makefile b/src/txt-converter/Makefile index 284f8dc81..2e40e838d 100644 --- a/src/txt-converter/Makefile +++ b/src/txt-converter/Makefile @@ -2,14 +2,14 @@ all sql: char-converter login-converter char-converter: char-converter.o ../common/obj/minicore.o \ ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o \ - ../common/obj/mapindex.o ../common/obj/ers.o \ + ../common/obj/mapindex.o ../common/obj/ers.o ../common/obj/utils.o \ ../char/char.o ../char/int_pet.o ../char/int_storage.o ../char/inter.o \ ../char/int_party.o ../char/int_guild.o \ ../char_sql/char.o ../char_sql/int_pet.o ../char_sql/int_storage.o \ ../char_sql/inter.o ../char_sql/int_party.o ../char_sql/int_guild.o $(CC) -o ../../tools/$@ $^ $(LIB_S) -login-converter: login-converter.o ../common/obj/minicore.o ../common/obj/db.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/ers.o +login-converter: login-converter.o ../common/obj/minicore.o ../common/obj/db.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/ers.o ../common/obj/utils.o $(CC) -o ../../tools/$@ $^ $(LIB_S) clean: diff --git a/src/txt-converter/char-converter.c b/src/txt-converter/char-converter.c index 29d1c393f..6db1aceb6 100644 --- a/src/txt-converter/char-converter.c +++ b/src/txt-converter/char-converter.c @@ -5,9 +5,9 @@ #include #include +#include "../common/mmo.h" #include "../common/core.h" #include "../common/strlib.h" -#include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/mapindex.h" diff --git a/src/txt-converter/login-converter.c b/src/txt-converter/login-converter.c index ab236d322..840d61e1c 100644 --- a/src/txt-converter/login-converter.c +++ b/src/txt-converter/login-converter.c @@ -4,12 +4,16 @@ #include #include #include +#include "cbasetypes.h" +#ifdef __WIN32 #include +#include +#endif #include +#include "../common/mmo.h" #include "../common/core.h" #include "../common/db.h" -#include "../common/mmo.h" struct auth_dat_ { int account_id, sex; -- cgit v1.2.3-70-g09d2 From 70dc3acce080b3c4f5061c2394911149d0d82aa4 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Tue, 19 Dec 2006 09:15:00 +0000 Subject: - Cleanups or minor changes. - Now addtick_timer invokes settick_timer, so keep an eye for whatever timer issues it's supposed to have. - Removed the flush_fifo from clif_parse_TickSend until the socket problems are fixed. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9521 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 6 ++ src/common/cbasetypes.h | 24 ++--- src/common/socket.h | 55 ++++++----- src/common/timer.c | 250 +++++++++++++++++++++++++++--------------------- src/common/timer.h | 24 +++-- src/map/clif.c | 5 +- 6 files changed, 200 insertions(+), 164 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index c21f900a3..f7d8d38bd 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,12 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2006/12/19 + * Cleanups or minor changes. + * Now addtick_timer invokes settick_timer, so keep an eye for whatever + timer issues it's supposed to have. + * Removed the flush_fifo from clif_parse_TickSend until the socket + problems are fixed. [FlavioJS] 2006/12/18 * Updated POS2 macros. The 6th byte is subx0 and suby0. [FlavioJS] * Added hom_setting to specify which homunculus 'quirks' are in effect. The diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index f02b8734c..ad2b7c4ed 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -101,30 +101,30 @@ typedef unsigned int uint32; #undef UINT8_MIN #undef UINT16_MIN #undef UINT32_MIN -#define UINT8_MIN (uint8) 0 -#define UINT16_MIN (uint16)0 -#define UINT32_MIN (uint32)0 +#define UINT8_MIN ((uint8) 0) +#define UINT16_MIN ((uint16)0) +#define UINT32_MIN ((uint32)0) #undef UINT8_MAX #undef UINT16_MAX #undef UINT32_MAX -#define UINT8_MAX (uint8) 0xFF -#define UINT16_MAX (uint16)0xFFFF -#define UINT32_MAX (uint32)0xFFFFFFFF +#define UINT8_MAX ((uint8) 0xFF) +#define UINT16_MAX ((uint16)0xFFFF) +#define UINT32_MAX ((uint32)0xFFFFFFFF) #undef SINT8_MIN #undef SINT16_MIN #undef SINT32_MIN -#define SINT8_MIN (sint8) 0x80 -#define SINT16_MIN (sint16)0x8000 -#define SINT32_MIN (sint32)0x80000000 +#define SINT8_MIN ((sint8) 0x80) +#define SINT16_MIN ((sint16)0x8000) +#define SINT32_MIN ((sint32)0x80000000) #undef SINT8_MAX #undef SINT16_MAX #undef SINT32_MAX -#define SINT8_MAX (sint8) 0x7F -#define SINT16_MAX (sint16)0x7FFF -#define SINT32_MAX (sint32)0x7FFFFFFF +#define SINT8_MAX ((sint8) 0x7F) +#define SINT16_MAX ((sint16)0x7FFF) +#define SINT32_MAX ((sint32)0x7FFFFFFF) ////////////////////////////////////////////////////////////////////////// diff --git a/src/common/socket.h b/src/common/socket.h index b1565b488..fa867a45f 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -34,47 +34,50 @@ extern time_t stall_time; #define RFIFOP(fd,pos) (session[fd]->rdata+session[fd]->rdata_pos+(pos)) #endif // use function instead of macro. -#define RFIFOB(fd,pos) (*(unsigned char*)RFIFOP(fd,pos)) -#define RFIFOW(fd,pos) (*(unsigned short*)RFIFOP(fd,pos)) -#define RFIFOL(fd,pos) (*(unsigned long*)RFIFOP(fd,pos)) +#define RFIFOB(fd,pos) (*(uint8*)RFIFOP(fd,pos)) +#define RFIFOW(fd,pos) (*(uint16*)RFIFOP(fd,pos)) +#define RFIFOL(fd,pos) (*(uint32*)RFIFOP(fd,pos)) #define RFIFOREST(fd) (session[fd]->rdata_size-session[fd]->rdata_pos) #define RFIFOFLUSH(fd) \ - if(session[fd]->rdata_size == session[fd]->rdata_pos) \ - { session[fd]->rdata_size = session[fd]->rdata_pos = 0; } else { \ - session[fd]->rdata_size -= session[fd]->rdata_pos; \ - memmove(session[fd]->rdata, session[fd]->rdata+session[fd]->rdata_pos, session[fd]->rdata_size); \ - session[fd]->rdata_pos=0; \ - } + do { \ + if(session[fd]->rdata_size == session[fd]->rdata_pos){ \ + session[fd]->rdata_size = session[fd]->rdata_pos = 0; \ + } else { \ + session[fd]->rdata_size -= session[fd]->rdata_pos; \ + memmove(session[fd]->rdata, session[fd]->rdata+session[fd]->rdata_pos, session[fd]->rdata_size); \ + session[fd]->rdata_pos=0; \ + } \ + } while(0) //#define RFIFOSKIP(fd,len) ((session[fd]->rdata_size-session[fd]->rdata_pos-(len)<0) ? (fprintf(stderr,"too many skip\n"),exit(1)) : (session[fd]->rdata_pos+=(len))) -#define RBUFP(p,pos) (((unsigned char*)(p))+(pos)) -#define RBUFB(p,pos) (*(unsigned char*)RBUFP((p),(pos))) -#define RBUFW(p,pos) (*(unsigned short*)RBUFP((p),(pos))) -#define RBUFL(p,pos) (*(unsigned long*)RBUFP((p),(pos))) +#define RBUFP(p,pos) (((uint8*)(p))+(pos)) +#define RBUFB(p,pos) (*(uint8*)RBUFP((p),(pos))) +#define RBUFW(p,pos) (*(uint16*)RBUFP((p),(pos))) +#define RBUFL(p,pos) (*(uint32*)RBUFP((p),(pos))) #define WFIFOSPACE(fd) (session[fd]->max_wdata-session[fd]->wdata_size) #ifdef TURBO -#define WFIFOHEAD(fd, x) char *wbPtr ## fd = fd?(session[fd]->wdata+session[fd]->wdata_size):0; +#define WFIFOHEAD(fd, x) uint8 *wbPtr ## fd = fd?(session[fd]->wdata+session[fd]->wdata_size):0; #define WFIFOP(fd,pos) (&wbPtr ## fd[pos]) #else -#define WFIFOHEAD(fd, size) { if((fd) && session[fd]->wdata_size + (size) > session[fd]->max_wdata ) realloc_writefifo(fd, size); } +#define WFIFOHEAD(fd, size) do{ if((fd) && session[fd]->wdata_size + (size) > session[fd]->max_wdata ) realloc_writefifo(fd, size); }while(0) #define WFIFOP(fd,pos) (session[fd]->wdata+session[fd]->wdata_size+(pos)) #endif -#define WFIFOB(fd,pos) (*(unsigned char*)WFIFOP(fd,pos)) -#define WFIFOW(fd,pos) (*(unsigned short*)WFIFOP(fd,pos)) -#define WFIFOL(fd,pos) (*(unsigned long*)WFIFOP(fd,pos)) +#define WFIFOB(fd,pos) (*(uint8*)WFIFOP(fd,pos)) +#define WFIFOW(fd,pos) (*(uint16*)WFIFOP(fd,pos)) +#define WFIFOL(fd,pos) (*(uint32*)WFIFOP(fd,pos)) // use function instead of macro. //#define WFIFOSET(fd,len) (session[fd]->wdata_size = (session[fd]->wdata_size + (len) + 2048 < session[fd]->max_wdata) ? session[fd]->wdata_size + len : session[fd]->wdata_size) -#define WBUFP(p,pos) (((unsigned char*)(p)) + (pos)) -#define WBUFB(p,pos) (*(unsigned char*)((p) + (pos))) -#define WBUFW(p,pos) (*(unsigned short*)((p) + (pos))) -#define WBUFL(p,pos) (*(unsigned long*)((p) + (pos))) - -#define TOB(n) ((unsigned char)(n)) -#define TOW(n) ((unsigned short)(n)) -#define TOL(n) ((unsigned long)(n)) +#define WBUFP(p,pos) (((uint8*)(p)) + (pos)) +#define WBUFB(p,pos) (*(uint8*)((p) + (pos))) +#define WBUFW(p,pos) (*(uint16*)((p) + (pos))) +#define WBUFL(p,pos) (*(uint32*)((p) + (pos))) + +#define TOB(n) ((uint8)((n)&UINT8_MAX)) +#define TOW(n) ((uint16)((n)&UINT16_MAX)) +#define TOL(n) ((uint32)((n)&UINT32_MAX)) //FD_SETSIZE must be modified on the project files/Makefile, since a change here won't affect // dependant windows libraries. diff --git a/src/common/timer.c b/src/common/timer.c index 77d88d17d..34c95fcf6 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -31,66 +31,76 @@ #define TIMER_MIN_INTERVAL 50 +// timers static struct TimerData* timer_data = NULL; static int timer_data_max = 0; static int timer_data_num = 0; +// free timers static int* free_timer_list = NULL; static int free_timer_list_max = 0; static int free_timer_list_pos = 0; +//NOTE: using a binary heap should improve performance [FlavioJS] +// timer heap (ordered array of tid's) static int timer_heap_num = 0; static int timer_heap_max = 0; static int* timer_heap = NULL; - -static int fix_heap_flag =0; //Flag for fixing the stack only once per tick loop. May not be the best way, but it's all I can think of currently :X [Skotlex] +// searches for the target tick's position and stores it in pos (binary search) +#define HEAP_SEARCH(target,from,to,pos) \ + do { \ + int max,pivot; \ + pos = from; \ + max = to; \ + while (pos < max) { \ + pivot = (pos + max) / 2; \ + if (DIFF_TICK(target, timer_data[timer_heap[pivot]].tick) < 0) \ + pos = pivot + 1; \ + else \ + max = pivot; \ + } \ + } while(0) // for debug struct timer_func_list { - int (*func)(int,unsigned int,int,int); struct timer_func_list* next; + TimerFunc func; char* name; }; -static struct timer_func_list* tfl_root; +static struct timer_func_list* tfl_root = NULL; time_t start_time; -#ifdef __WIN32 -/* Modified struct timezone to void - we pass NULL anyway */ -void gettimeofday (struct timeval *t, void *dummy) -{ - DWORD millisec = GetTickCount(); - - t->tv_sec = (int) (millisec / 1000); - t->tv_usec = (millisec % 1000) * 1000; -} -#endif - -// -int add_timer_func_list(int (*func)(int,unsigned int,int,int), char* name) +/// Sets the name of a timer function. +int add_timer_func_list(TimerFunc func, char* name) { struct timer_func_list* tfl; if (name) { - tfl = (struct timer_func_list*) aCalloc (sizeof(struct timer_func_list), 1); - tfl->name = (char *) aMalloc (strlen(name) + 1); - + for( tfl=tfl_root; tfl != NULL; tfl=tfl->next ) + {// check suspicious cases + if( func == tfl->func ) + ShowWarning("add_timer_func_list: duplicating function %08x(%s) as %s.\n",(int)tfl->func,tfl->name,name); + else if( strcmp(name,tfl->name) == 0 ) + ShowWarning("add_timer_func_list: function %08X has the same name as %08X(%s)\n",(int)func,(int)tfl->func,tfl->name); + } + CREATE(tfl,struct timer_func_list,1); tfl->next = tfl_root; tfl->func = func; - strcpy(tfl->name, name); + tfl->name = aStrdup(name); tfl_root = tfl; } return 0; } -char* search_timer_func_list(int (*func)(int,unsigned int,int,int)) +/// Returns the name of the timer function. +char* search_timer_func_list(TimerFunc func) { - struct timer_func_list* tfl = tfl_root; - while (tfl) { + struct timer_func_list* tfl; + + for( tfl=tfl_root; tfl != NULL; tfl=tfl->next ) if (func == tfl->func) return tfl->name; - tfl = tfl->next; - } return "unknown timer function"; } @@ -103,18 +113,22 @@ static int gettick_count; unsigned int gettick_nocache(void) { +#ifdef _WIN32 + gettick_count = 256; + return gettick_cache = GetTickCount(); +#else struct timeval tval; gettimeofday(&tval, NULL); gettick_count = 256; return gettick_cache = tval.tv_sec * 1000 + tval.tv_usec / 1000; +#endif } unsigned int gettick(void) { - gettick_count--; - if (gettick_count < 0) + if (--gettick_count < 0) return gettick_nocache(); return gettick_cache; @@ -124,61 +138,56 @@ unsigned int gettick(void) * CORE : Timer Heap *-------------------------------------- */ -static void push_timer_heap(int index) +/// Adds a timer to the timer_heap +static void push_timer_heap(int tid) { - int i, j; - int min, max, pivot; // for sorting + unsigned int tick; + int pos; + int i; // check number of element if (timer_heap_num >= timer_heap_max) { if (timer_heap_max == 0) { timer_heap_max = 256; - timer_heap = (int *) aCalloc( sizeof(int) , 256); + CREATE(timer_heap, int, 256); } else { timer_heap_max += 256; - timer_heap = (int *) aRealloc( timer_heap, sizeof(int) * timer_heap_max); + RECREATE(timer_heap, int, timer_heap_max); malloc_tsetdword(timer_heap + (timer_heap_max - 256), 0, sizeof(int) * 256); } } // do a sorting from higher to lower - j = timer_data[index].tick; // speed up + tick = timer_data[tid].tick; // speed up // with less than 4 values, it's speeder to use simple loop if (timer_heap_num < 4) { for(i = timer_heap_num; i > 0; i--) + { // if (j < timer_data[timer_heap[i - 1]].tick) //Plain comparisons break on bound looping timers. [Skotlex] - if (DIFF_TICK(j, timer_data[timer_heap[i - 1]].tick) < 0) + if (DIFF_TICK(tick, timer_data[timer_heap[i - 1]].tick) < 0) break; else timer_heap[i] = timer_heap[i - 1]; - timer_heap[i] = index; - // searching by dichotomie + } + timer_heap[i] = tid; + // searching by dichotomy (binary search) } else { // if lower actual item is higher than new // if (j < timer_data[timer_heap[timer_heap_num - 1]].tick) //Plain comparisons break on bound looping timers. [Skotlex] - if (DIFF_TICK(j, timer_data[timer_heap[timer_heap_num - 1]].tick) < 0) - timer_heap[timer_heap_num] = index; + if (DIFF_TICK(tick, timer_data[timer_heap[timer_heap_num - 1]].tick) < 0) + timer_heap[timer_heap_num] = tid; else { // searching position - min = 0; - max = timer_heap_num - 1; - while (min < max) { - pivot = (min + max) / 2; -// if (j < timer_data[timer_heap[pivot]].tick) //Plain comparisons break on bound looping timers. [Skotlex] - if (DIFF_TICK(j, timer_data[timer_heap[pivot]].tick) < 0) - min = pivot + 1; - else - max = pivot; - } + HEAP_SEARCH(tick,0,timer_heap_num-1,pos); // move elements - do loop if there are a little number of elements to move - if (timer_heap_num - min < 5) { - for(i = timer_heap_num; i > min; i--) + if (timer_heap_num - pos < 5) { + for(i = timer_heap_num; i > pos; i--) timer_heap[i] = timer_heap[i - 1]; // move elements - else use memmove (speeder for a lot of elements) } else - memmove(&timer_heap[min + 1], &timer_heap[min], sizeof(int) * (timer_heap_num - min)); + memmove(&timer_heap[pos + 1], &timer_heap[pos], sizeof(int) * (timer_heap_num - pos)); // save new element - timer_heap[min] = index; + timer_heap[pos] = tid; } } @@ -190,34 +199,41 @@ static void push_timer_heap(int index) *-------------------------- */ -int acquire_timer (void) +/// Returns a free timer id. +static int acquire_timer(void) { - int i; + int tid; if (free_timer_list_pos) { do { - i = free_timer_list[--free_timer_list_pos]; - } while(i >= timer_data_num && free_timer_list_pos > 0); + tid = free_timer_list[--free_timer_list_pos]; + } while(tid >= timer_data_num && free_timer_list_pos > 0); } else - i = timer_data_num; + tid = timer_data_num; - if (i >= timer_data_num) - for (i = timer_data_num; i < timer_data_max && timer_data[i].type; i++); - if (i >= timer_data_num && i >= timer_data_max) { - if (timer_data_max == 0) { + if (tid >= timer_data_num) + for (tid = timer_data_num; tid < timer_data_max && timer_data[tid].type; tid++); + if (tid >= timer_data_num && tid >= timer_data_max) + {// expand timer array + if (timer_data_max == 0) + {// create timer data (1st time) timer_data_max = 256; - timer_data = (struct TimerData*) aCalloc( sizeof(struct TimerData) , timer_data_max); - } else { + CREATE(timer_data, struct TimerData, timer_data_max); + } else + {// add more timers timer_data_max += 256; - timer_data = (struct TimerData *) aRealloc( timer_data, sizeof(struct TimerData) * timer_data_max); + RECREATE(timer_data, struct TimerData, timer_data_max); malloc_tsetdword(timer_data + (timer_data_max - 256), 0, sizeof(struct TimerData) * 256); } } - return i; + if (tid >= timer_data_num) + timer_data_num = tid + 1; + + return tid; } -int add_timer(unsigned int tick,int (*func)(int,unsigned int,int,int), int id, int data) +int add_timer(unsigned int tick,TimerFunc func, int id, int data) { int tid = acquire_timer(); @@ -229,13 +245,10 @@ int add_timer(unsigned int tick,int (*func)(int,unsigned int,int,int), int id, i timer_data[tid].interval = 1000; push_timer_heap(tid); - if (tid >= timer_data_num) - timer_data_num = tid + 1; - return tid; } -int add_timer_interval(unsigned int tick, int (*func)(int,unsigned int,int,int), int id, int data, int interval) +int add_timer_interval(unsigned int tick, TimerFunc func, int id, int data, int interval) { int tid; @@ -254,13 +267,10 @@ int add_timer_interval(unsigned int tick, int (*func)(int,unsigned int,int,int), timer_data[tid].interval = interval; push_timer_heap(tid); - if (tid >= timer_data_num) - timer_data_num = tid + 1; - return tid; } -int delete_timer(int id, int (*func)(int,unsigned int,int,int)) +int delete_timer(int id, TimerFunc func) { if (id <= 0 || id >= timer_data_num) { ShowError("delete_timer error : no such timer %d (%08x(%s))\n", id, (int)func, search_timer_func_list(func)); @@ -281,41 +291,59 @@ int delete_timer(int id, int (*func)(int,unsigned int,int,int)) int addtick_timer(int tid, unsigned int tick) { - return timer_data[tid].tick += tick; + // Doesn't adjust the timer position. Might be the root of the FIXME in settick_timer. [FlavioJS] + //return timer_data[tid].tick += tick; + return settick_timer(tid, timer_data[tid].tick+tick); } //Sets the tick at which the timer triggers directly (meant as a replacement of delete_timer + add_timer) [Skotlex] //FIXME: DON'T use this function yet, it is not correctly reorganizing the timer stack causing unexpected problems later on! int settick_timer(int tid, unsigned int tick) { - int i,j; - if (timer_data[tid].tick == tick) + int old_pos,pos; + unsigned int old_tick; + + old_tick = timer_data[tid].tick; + if( old_tick == tick ) return tick; //FIXME: This search is not all that effective... there doesn't seems to be a better way to locate an element in the heap. - for(i = timer_heap_num-1; i >= 0 && timer_heap[i] != tid; i--); - - if (i < 0) - return -1; //Sort of impossible, isn't it? - if (DIFF_TICK(timer_data[tid].tick, tick) > 0) - { //Timer is accelerated, shift timer near the end of the heap. - if (i == timer_heap_num-1) //Nothing to shift. - j = timer_heap_num-1; + //for(i = timer_heap_num-1; i >= 0 && timer_heap[i] != tid; i--); + + // search old_tick position + HEAP_SEARCH(old_tick,0,timer_heap_num-1,old_pos); + while( timer_heap[old_pos] != tid ) + {// skip timers with the same tick + if( DIFF_TICK(old_tick,timer_data[timer_heap[old_pos]].tick) != 0 ) + { + ShowError("settick_timer: no such timer %d (%08x(%s))\n", tid, (int)timer_data[tid].func, search_timer_func_list(timer_data[tid].func)); + return -1; + } + ++old_pos; + } + + if( DIFF_TICK(tick,timer_data[tid].tick) < 0 ) + {// Timer is accelerated, shift timer near the end of the heap. + if (old_pos == timer_heap_num-1) //Nothing to shift. + pos = old_pos; else { - for (j = i+1; j < timer_heap_num && DIFF_TICK(timer_data[j].tick, tick) > 0; j++); - j--; - memmove(&timer_heap[i], &timer_heap[i+1], (j-i)*sizeof(int)); + HEAP_SEARCH(tick,old_pos+1,timer_heap_num-1,pos); + --pos; + if (pos != old_pos) + memmove(&timer_heap[old_pos], &timer_heap[old_pos+1], (pos-old_pos)*sizeof(int)); } - } else { //Timer is delayed, shift timer near the beginning of the heap. - if (i == 0) //Nothing to shift. - j = 0; + } else + {// Timer is delayed, shift timer near the beginning of the heap. + if (old_pos == 0) //Nothing to shift. + pos = old_pos; else { - for (j = i-1; j >= 0 && DIFF_TICK(timer_data[j].tick, tick) < 0; j--); - j++; - memmove(&timer_heap[j+1], &timer_heap[j], (i-j)*sizeof(int)); + HEAP_SEARCH(tick,0,old_pos-1,pos); + ++pos; + if (pos != old_pos) + memmove(&timer_heap[pos+1], &timer_heap[pos], (old_pos-pos)*sizeof(int)); } } - timer_heap[j] = tid; + timer_heap[pos] = tid; timer_data[tid].tick = tick; return tick; } @@ -341,15 +369,16 @@ static void fix_timer_heap(unsigned int tick) } //Move elements to readjust the heap. tmp_heap = aCalloc(sizeof(int), i); - memmove(&tmp_heap[0], &timer_heap[0], i*sizeof(int)); - memmove(&timer_heap[0], &timer_heap[i], (timer_heap_num-i)*sizeof(int)); - memmove(&timer_heap[timer_heap_num-i], &tmp_heap[0], i*sizeof(int)); + memcpy(tmp_heap, timer_heap, i*sizeof(int)); + memmove(timer_heap, &timer_heap[i], (timer_heap_num-i)*sizeof(int)); + memmove(&timer_heap[timer_heap_num-i], tmp_heap, i*sizeof(int)); aFree(tmp_heap); } } int do_timer(unsigned int tick) { + static int fix_heap_flag = 0; //Flag for fixing the stack only once per tick loop. May not be the best way, but it's all I can think of currently :X [Skotlex] int i, nextmin = 1000; if (tick < 0x010000 && fix_heap_flag) @@ -362,8 +391,8 @@ int do_timer(unsigned int tick) i = timer_heap[timer_heap_num - 1]; // next shorter element if ((nextmin = DIFF_TICK(timer_data[i].tick, tick)) > 0) break; - if (timer_heap_num > 0) // suppress the actual element from the table - timer_heap_num--; + + --timer_heap_num; // suppress the actual element from the table timer_data[i].type |= TIMER_REMOVE_HEAP; if (timer_data[i].func) { if (nextmin < -1000) { @@ -382,7 +411,7 @@ int do_timer(unsigned int tick) timer_data[i].type = 0; if (free_timer_list_pos >= free_timer_list_max) { free_timer_list_max += 256; - free_timer_list = (int *) aRealloc(free_timer_list, sizeof(int) * free_timer_list_max); + RECREATE(free_timer_list,int,free_timer_list_max); malloc_tsetdword(free_timer_list + (free_timer_list_max - 256), 0, 256 * sizeof(int)); } free_timer_list[free_timer_list_pos++] = i; @@ -403,14 +432,14 @@ int do_timer(unsigned int tick) if (nextmin < TIMER_MIN_INTERVAL) nextmin = TIMER_MIN_INTERVAL; - if ((unsigned int)(tick + nextmin) < tick) //Tick will loop, rearrange the heap on the next iteration. + if (UINT_MAX - nextmin < tick) //Tick will loop, rearrange the heap on the next iteration. fix_heap_flag = 1; return nextmin; } -unsigned long get_uptime (void) +unsigned long get_uptime(void) { - return (unsigned long) difftime (time(NULL), start_time); + return (unsigned long)difftime(time(NULL), start_time); } void timer_init(void) @@ -420,17 +449,16 @@ void timer_init(void) void timer_final(void) { - struct timer_func_list* tfl = tfl_root, *tfl2; + struct timer_func_list *tfl; + struct timer_func_list *next; - while (tfl) { - tfl2 = tfl->next; // copy next pointer + for( tfl=tfl_root; tfl != NULL; tfl = next ) + next = tfl->next; // copy next pointer aFree(tfl->name); // free structures aFree(tfl); - tfl = tfl2; // use copied pointer for next cycle } - + if (timer_data) aFree(timer_data); if (timer_heap) aFree(timer_heap); if (free_timer_list) aFree(free_timer_list); } - diff --git a/src/common/timer.h b/src/common/timer.h index 9acc7c640..7184beec5 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -12,17 +12,19 @@ #define BASE_TICK 5 -#define TIMER_ONCE_AUTODEL 1 -#define TIMER_INTERVAL 2 -#define TIMER_REMOVE_HEAP 16 +#define TIMER_ONCE_AUTODEL 0x1 +#define TIMER_INTERVAL 0x2 +#define TIMER_REMOVE_HEAP 0x10 #define DIFF_TICK(a,b) ((int)((a)-(b))) // Struct declaration +typedef int (*TimerFunc)(int,unsigned int,int,int); + struct TimerData { unsigned int tick; - int (*func)(int,unsigned int,int,int); + TimerFunc func; int id; int data; int type; @@ -32,16 +34,12 @@ struct TimerData { // Function prototype declaration -#ifdef __WIN32 -void gettimeofday(struct timeval *t, void *dummy); -#endif - unsigned int gettick_nocache(void); unsigned int gettick(void); -int add_timer(unsigned int,int (*)(int,unsigned int,int,int),int,int); -int add_timer_interval(unsigned int,int (*)(int,unsigned int,int,int),int,int,int); -int delete_timer(int,int (*)(int,unsigned int,int,int)); +int add_timer(unsigned int,TimerFunc f,int,int); +int add_timer_interval(unsigned int,TimerFunc f,int,int,int); +int delete_timer(int,TimerFunc f); int addtick_timer(int tid,unsigned int tick); int settick_timer(int tid,unsigned int tick); @@ -49,8 +47,8 @@ struct TimerData *get_timer(int tid); int do_timer(unsigned int tick); -int add_timer_func_list(int (*)(int,unsigned int,int,int),char*); -char* search_timer_func_list(int (*)(int,unsigned int,int,int)); +int add_timer_func_list(TimerFunc func, char* name); +char* search_timer_func_list(TimerFunc f); unsigned long get_uptime(void); diff --git a/src/map/clif.c b/src/map/clif.c index 96123bfaa..56ea93a6a 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8450,10 +8450,10 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) // If player is dead, and is spawned (such as @refresh) send death packet. [Valaris] if(pc_isdead(sd)) clif_clearchar_area(&sd->bl,1); - // Uncomment if you want to make player face in the same direction he was facing right before warping. [Skotlex] // else // clif_changed_dir(&sd->bl, SELF); + // Trigger skill effects if you appear standing on them if(!battle_config.pc_invincible_time) skill_unit_move(&sd->bl,gettick(),1); @@ -8472,7 +8472,8 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) { WFIFOW(fd,0)=0x7f; WFIFOL(fd,2)=gettick(); WFIFOSET(fd,packet_len(0x7f)); - flush_fifo(fd,0); // send immediatly so the client gets accurate "pings" + // removed until the socket problems are fixed. [FlavioJS] + //flush_fifo(fd,0); // send immediatly so the client gets accurate "pings" return; } -- cgit v1.2.3-70-g09d2 From 38daeba66b5d2a9f6fc4eda795b6c9b8c77a7b54 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Wed, 20 Dec 2006 07:17:18 +0000 Subject: - Changed the script source from unsigned char* to const char*. - Updated plugins Makefile. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9532 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 + npc/sample/localized_npc.txt | 302 +++++++++++++-------------- src/common/cbasetypes.h | 6 + src/map/map.h | 6 +- src/map/npc.c | 8 +- src/map/script.c | 485 +++++++++++++++++++++---------------------- src/map/script.h | 4 +- src/plugins/Makefile | 103 ++++----- 8 files changed, 455 insertions(+), 462 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index bffce6bba..2efa61cbf 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,9 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2006/12/20 + * Changed the script source from unsigned char* to const char*. + * Updated plugins Makefile. [FlavioJS] 2006/12/19 * Reverted the mob ThinkTime update, that field is again aDelay as it apparently should be. [Skotlex] diff --git a/npc/sample/localized_npc.txt b/npc/sample/localized_npc.txt index ab6964a07..aa7c5fb5a 100644 --- a/npc/sample/localized_npc.txt +++ b/npc/sample/localized_npc.txt @@ -1,151 +1,151 @@ -//===== eAthena Script ======================================= -//= Sample localized NPC -//===== By: ================================================== -//= eAthena Dev Team -//===== Current Version: ===================================== -//= v1.0 -//===== Compatible With: ===================================== -//= eAthena with setd, getd and npc variables '.' -//===== Description: ========================================= -//= Example of a localized NPC. -//= -//= There are many ways to do it, this is just one option. -//= The player has a global account variable ##_langid_ that -//= identifies the it's language. -//= -//= The default language should always have langid 0. -//= When a message isn't found for the player's langid -//= (strlen = 0), the message from langid 0 is used instead. -//= -//= Each message is identified by a string that must only -//= contain valid variable name characters. -//= -//= void setlang(int langid) -//= - sets the player's language -//= int getlang(void) -//= - returns the player's language -//= void setmes2(string name,int langid,string text) -//= - sets the localized text for name -//= string getmes2(string name,int langid) -//= - returns the localized text of name -//= void mes2(string name) -//= - displays the localized text of name -//= -//===== Additional Comments: ================================= -//= To use this globally, just put the functions in Global_Functions.txt -//============================================================ - -////////////////////////////////////////////////////////////// -/// Sets the language of the player account. -/// @param langid Languange identifier (0 for default) -function script setlang { - set ##_langid_, getarg(0); - return; -} - -////////////////////////////////////////////////////////////// -/// Returns the language identifier of the player -function script getlang { - return ##_langid_; -} - -////////////////////////////////////////////////////////////// -/// Sets a localized text entry. -/// Does not need a RID attached. -/// @param name Message identifier -/// @param langid Language identifier (0 for default) -/// @param text Text message -function script setmes2 { - set $@mes2_name$, getarg(0); - set $@mes2_langid, getarg(1); - set $@mes2_text$, getarg(2); - set $@mes2_var$, "$@__"+ $@mes2_name$ +"_"+ $@mes2_langid +"$"; - - //debugmes "setmes2 \""+ $@mes2_var$ +"\", \""+ $@mes2_text$ +"\";"; - - // set the localized text - setd $@mes2_var$, $@mes2_text$; - return; -} - -////////////////////////////////////////////////////////////// -/// Sets a localized text entry. -/// Does not need a RID attached. -/// @param name Message identifier -/// @param langid Language identifier (0 for default) -/// @return Text message -function script getmes2 { - set $@mes2_name$, getarg(0); - set $@mes2_langid, getarg(1); - set $@mes2_var$, "$@__"+ $@mes2_name$ +"_"+ $@mes2_langid +"$"; - set $@mes2_text$, getd($@mes2_var$); - - //debugmes "getmes2(\""+ $@mes2_var$ +"\")=\""+ $@mes2_text$ +"\""; - - return $@mes2_text$; -} - -////////////////////////////////////////////////////////////// -/// mes for localized text. -/// index should be a unique string, made up only of characters -/// that are valis as a variable name -/// @param index Message identifier -function script mes2 { - set .@mes2_index$, getarg(0); - - if( getstrlen(.@mes2_index$) == 0 ) - return; // invalid index - - // print localized text - set .@mes2_text$, callfunc("getmes2",.@mes2_index$,##_langid_); - if( getstrlen(.@mes2_text$) == 0 ) - { - if( ##_langid_ != 0 ) - {// revert to default language - set .@mes2_text$, callfunc("getmes2",.@mes2_index$,0); - if( getstrlen(.@mes2_text$) != 0 ) - mes .@mes2_text$; // default text - } - } else - mes .@mes2_text$; // localized text - return; -} - -////////////////////////////////////////////////////////////// -/// Sample localized NPC -prontera.gat,155,183,4 script LocalizedNPC 705,{ - // Get text for specific languages - set .@menu1$, callfunc("getmes2","LNPC_lang",0); - set .@menu2$, callfunc("getmes2","LNPC_lang",1); - do { - // get text that fallbacks to language 0 - callfunc "mes2", "LNPC_name"; - // localized mes - callfunc "mes2", "LNPC_lang"; - callfunc "mes2", "LNPC_text"; - next; - - switch(select(.@menu1$,.@menu2$,"Cancel")) - { - case 1: - case 2: - // Set player language - callfunc "setlang",@menu-1; - break; - } - } while( @menu != 3 ); - close; - end; - -OnInterIfInitOnce: - // Load the localized text. - // This can be anywhere, as long as it's executed before the coresponding getmes2/mes2 calls - // 0 - English (default) - // 1 - Portuguese - callfunc "setmes2", "LNPC_name", 0, "[LocalizedNPC]"; - callfunc "setmes2", "LNPC_lang", 0, "EN"; - callfunc "setmes2", "LNPC_lang", 1, "PT"; - callfunc "setmes2", "LNPC_text", 0, "Something in english"; - callfunc "setmes2", "LNPC_text", 1, "Algo em portugu黌"; - end; -} +//===== eAthena Script ======================================= +//= Sample localized NPC +//===== By: ================================================== +//= eAthena Dev Team +//===== Current Version: ===================================== +//= v1.0 +//===== Compatible With: ===================================== +//= eAthena with setd, getd +//===== Description: ========================================= +//= Example of a localized NPC. +//= +//= There are many ways to do it, this is just one option. +//= The player has a global account variable ##_langid_ that +//= identifies the it's language. +//= +//= The default language should always have langid 0. +//= When a message isn't found for the player's langid +//= (strlen = 0), the message from langid 0 is used instead. +//= +//= Each message is identified by a string that must only +//= contain valid variable name characters. +//= +//= void setlang(int langid) +//= - sets the player's language +//= int getlang(void) +//= - returns the player's language +//= void setmes2(string name,int langid,string text) +//= - sets the localized text for name +//= string getmes2(string name,int langid) +//= - returns the localized text of name +//= void mes2(string name) +//= - displays the localized text of name +//= +//===== Additional Comments: ================================= +//= To use this globally, just put the functions in Global_Functions.txt +//============================================================ + +////////////////////////////////////////////////////////////// +/// Sets the language of the player account. +/// @param langid Languange identifier (0 for default) +function script setlang { + set ##_langid_, getarg(0); + return; +} + +////////////////////////////////////////////////////////////// +/// Returns the language identifier of the player +function script getlang { + return ##_langid_; +} + +////////////////////////////////////////////////////////////// +/// Sets a localized text entry. +/// Does not need a RID attached. +/// @param name Message identifier +/// @param langid Language identifier (0 for default) +/// @param text Text message +function script setmes2 { + set $@mes2_name$, getarg(0); + set $@mes2_langid, getarg(1); + set $@mes2_text$, getarg(2); + set $@mes2_var$, "$@__"+ $@mes2_name$ +"_"+ $@mes2_langid +"$"; + + //debugmes "setmes2 \""+ $@mes2_var$ +"\", \""+ $@mes2_text$ +"\";"; + + // set the localized text + setd $@mes2_var$, $@mes2_text$; + return; +} + +////////////////////////////////////////////////////////////// +/// Sets a localized text entry. +/// Does not need a RID attached. +/// @param name Message identifier +/// @param langid Language identifier (0 for default) +/// @return Text message +function script getmes2 { + set $@mes2_name$, getarg(0); + set $@mes2_langid, getarg(1); + set $@mes2_var$, "$@__"+ $@mes2_name$ +"_"+ $@mes2_langid +"$"; + set $@mes2_text$, getd($@mes2_var$); + + //debugmes "getmes2(\""+ $@mes2_var$ +"\")=\""+ $@mes2_text$ +"\""; + + return $@mes2_text$; +} + +////////////////////////////////////////////////////////////// +/// mes for localized text. +/// index should be a unique string, made up only of characters +/// that are valis as a variable name +/// @param index Message identifier +function script mes2 { + set @mes2_index$, getarg(0); + + if( getstrlen(@mes2_index$) == 0 ) + return; // invalid index + + // print localized text + set @mes2_text$, callfunc("getmes2",@mes2_index$,##_langid_); + if( getstrlen(@mes2_text$) == 0 ) + { + if( ##_langid_ != 0 ) + {// revert to default language + set @mes2_text$, callfunc("getmes2",@mes2_index$,0); + if( getstrlen(@mes2_text$) != 0 ) + mes @mes2_text$; // default text + } + } else + mes @mes2_text$; // localized text + return; +} + +////////////////////////////////////////////////////////////// +/// Sample localized NPC +prontera.gat,155,183,4 script LocalizedNPC 705,{ + // Get text for specific languages + set @menu1$, callfunc("getmes2","LNPC_lang",0); + set @menu2$, callfunc("getmes2","LNPC_lang",1); + do { + // get text that fallbacks to language 0 + callfunc "mes2", "LNPC_name"; + // localized mes + callfunc "mes2", "LNPC_lang"; + callfunc "mes2", "LNPC_text"; + next; + + switch(select(@menu1$,@menu2$,"Cancel")) + { + case 1: + case 2: + // Set player language + callfunc "setlang",@menu-1; + break; + } + } while( @menu != 3 ); + close; + end; + +OnInterIfInitOnce: + // Load the localized text. + // This can be anywhere, as long as it's executed before the coresponding getmes2/mes2 calls + // 0 - English (default) + // 1 - Portuguese + callfunc "setmes2", "LNPC_name", 0, "[LocalizedNPC]"; + callfunc "setmes2", "LNPC_lang", 0, "EN"; + callfunc "setmes2", "LNPC_lang", 1, "PT"; + callfunc "setmes2", "LNPC_text", 0, "Something in english"; + callfunc "setmes2", "LNPC_text", 1, "Algo em portugu黌"; + end; +} diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index ad2b7c4ed..3ef6dfd2f 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -286,4 +286,10 @@ typedef char bool; #endif #endif /* ! defined(Assert) */ +////////////////////////////////////////////////////////////////////////// +// Has to be unsigned to avoid problems in some systems +#define TOLOWER(c) ((char)tolower((unsigned char)(c))) +#define ISSPACE(c) ((char)isspace((unsigned char)(c))) +#define ISALPHA(c) ((char)isalpha((unsigned char)(c))) + #endif /* _CBASETYPES_H_ */ diff --git a/src/map/map.h b/src/map/map.h index c7234dc29..f9e59cbff 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -176,7 +176,7 @@ enum { //This stackable implementation does not means a BL can be more than one type at a time, but it's //meant to make it easier to check for multiple types at a time on invocations such as // map_foreach* calls [Skotlex] -enum { +enum bl_type { BL_NUL = 0x000, BL_PC = 0x001, BL_MOB = 0x002, @@ -192,7 +192,7 @@ enum { #define BL_CHAR (BL_PC|BL_MOB|BL_HOM) #define BL_ALL 0xfff -enum { WARP, SHOP, SCRIPT, MONS }; +enum bl_subtype { WARP, SHOP, SCRIPT, MONS }; enum { RC_FORMLESS=0, @@ -1073,7 +1073,7 @@ struct map_data { int water_height; int npc_num; int users; - struct { + struct map_flag { unsigned alias : 1; unsigned nomemo : 1; unsigned noteleport : 1; diff --git a/src/map/npc.c b/src/map/npc.c index 7f7e7e669..447d04d7a 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1361,7 +1361,7 @@ int npc_selllist(struct map_session_data *sd,int n,unsigned short *item_list) return 0; } -int npc_remove_map (struct npc_data *nd) +int npc_remove_map(struct npc_data *nd) { int m,i; nullpo_retr(1, nd); @@ -1431,11 +1431,11 @@ void npc_unload_duplicates (struct npc_data *nd) map_foreachiddb(npc_unload_dup_sub,nd->bl.id); } -int npc_unload (struct npc_data *nd) +int npc_unload(struct npc_data *nd) { nullpo_ret(nd); - npc_remove_map (nd); + npc_remove_map(nd); map_deliddb(&nd->bl); if (nd->chat_id) { @@ -2943,7 +2943,7 @@ int do_final_npc(void) if ((bl = map_id2bl(i))){ if (bl->type == BL_NPC) npc_unload((struct npc_data *)bl); - else if (bl->type&(BL_MOB|BL_PET)) + else if (bl->type&(BL_MOB|BL_PET))//## why BL_PET? [FlavioJS] unit_free(bl, 0); } } diff --git a/src/map/script.c b/src/map/script.c index 3edcbaf92..74e122786 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -18,6 +18,7 @@ #include #include +#include "../common/cbasetypes.h" #include "../common/socket.h" #include "../common/timer.h" #include "../common/malloc.h" @@ -64,6 +65,7 @@ static int script_pos,script_size; #define GETVALUE(buf,i) ((int)MakeDWord(MakeWord((buf)[i],(buf)[i+1]),MakeWord((buf)[i+2],0))) #define SETVALUE(buf,i,n) ((buf)[i]=GetByte(n,0),(buf)[i+1]=GetByte(n,1),(buf)[i+2]=GetByte(n,2)) +#define GETSTRING(off) (str_buf+(off)) static char *str_buf; static int str_pos,str_size; static struct str_data_struct { @@ -94,9 +96,9 @@ static char pos[11][100] = {"Head","Body","Left hand","Right hand","Robe","Shoes struct Script_Config script_config; static int parse_cmd; -static jmp_buf error_jump; -static char* error_msg; -static char* error_pos; +static jmp_buf error_jump; +static char* error_msg; +static const char* error_pos; // for advanced scripting support ( nested if, switch, while, for, do-while, function, etc ) // [Eoe / jA 1080, 1081, 1094, 1164] @@ -111,10 +113,10 @@ static struct { int curly_count; // 右カッコの数 int index; // スクリプト内で使用した構文の数 } syntax; -unsigned char* parse_curly_close(unsigned char *p); -unsigned char* parse_syntax_close(unsigned char *p); -unsigned char* parse_syntax_close_sub(unsigned char *p,int *flag); -unsigned char* parse_syntax(unsigned char *p); +const char* parse_curly_close(const char* p); +const char* parse_syntax_close(const char* p); +const char* parse_syntax_close_sub(const char* p,int* flag); +const char* parse_syntax(const char* p); static int parse_syntax_for_flag = 0; extern int current_equip_item_index; //for New CARS Scripts. It contains Inventory Index of the EQUIP_SCRIPT caller item. [Lupus] @@ -148,13 +150,13 @@ static struct linkdb_node *sleep_db; * ローカルプロトタイプ宣言 (必要な物のみ) *------------------------------------------ */ -unsigned char* parse_subexpr(unsigned char *,int); +const char* parse_subexpr(const char* p,int limit); void push_val(struct script_stack *stack,int type,int val); int run_func(struct script_state *st); int mapreg_setreg(int num,int val); int mapreg_setregstr(int num,const char *str); -static void disp_error_message(const char *mes,unsigned char *pos); +static void disp_error_message(const char *mes,const char *pos); enum { C_NOP,C_POS,C_INT,C_PARAM,C_FUNC,C_STR,C_CONSTSTR,C_ARG, @@ -237,7 +239,7 @@ static void report_src(struct script_state *st) { } } -static void check_event(struct script_state *st, unsigned char *event){ +static void check_event(struct script_state *st, const char *event){ if(event != NULL && event[0] != '\0' && !stristr(event,"::On")){ ShowError("NPC event parameter deprecated! Please use 'NPCNAME::OnEVENT' instead of '%s'.\n",event); report_src(st); @@ -263,12 +265,12 @@ static int calc_hash(const unsigned char *p) *------------------------------------------ */ // 既存のであれば番号、無ければ-1 -static int search_str(const unsigned char *p) +static int search_str(const char *p) { int i; i=str_hash[calc_hash(p)]; while(i){ - if(strcmp(str_buf+str_data[i].str,(char *) p)==0){ + if(strcmp(str_buf+str_data[i].str,p)==0){ return i; } i=str_data[i].next; @@ -281,15 +283,16 @@ static int search_str(const unsigned char *p) *------------------------------------------ */ // 既存のであれば番号、無ければ登録して新規番号 -int add_str(const unsigned char *p) +int add_str(const char* p) { int i; - char *lowcase; + int len; + char* lowcase; - lowcase=aStrdup((char *) p); + lowcase=aStrdup(p); for(i=0;lowcase[i];i++) - lowcase[i]=tolower(lowcase[i]); - if((i=search_str((unsigned char *) lowcase))>=0){ + lowcase[i]=TOLOWER(lowcase[i]); + if((i=search_str(lowcase))>=0){ aFree(lowcase); return i; } @@ -301,7 +304,7 @@ int add_str(const unsigned char *p) } else { i=str_hash[i]; for(;;){ - if(strcmp(str_buf+str_data[i].str,(char *) p)==0){ + if(strcmp(str_buf+str_data[i].str,p)==0){ return i; } if(str_data[i].next==0) @@ -312,22 +315,23 @@ int add_str(const unsigned char *p) } if(str_num>=str_data_size){ str_data_size+=128; - str_data=aRealloc(str_data,sizeof(str_data[0])*str_data_size); + RECREATE(str_data,struct str_data_struct,str_data_size); malloc_tsetdword(str_data + (str_data_size - 128), '\0', 128); } - while(str_pos+(int)strlen((char *) p)+1>=str_size){ + len=(int)strlen(p); + while(str_pos+len+1>=str_size){ str_size+=256; - str_buf=(char *)aRealloc(str_buf,str_size); + RECREATE(str_buf,char,str_size); malloc_tsetdword(str_buf + (str_size - 256), '\0', 256); } - strcpy(str_buf+str_pos, (char *) p); + memcpy(str_buf+str_pos,p,len+1); str_data[str_num].type=C_NOP; str_data[str_num].str=str_pos; str_data[str_num].next=0; str_data[str_num].func=NULL; str_data[str_num].backpatch=-1; str_data[str_num].label=-1; - str_pos+=(int)strlen( (char *) p)+1; + str_pos+=len+1; return str_num++; } @@ -351,7 +355,7 @@ static void check_script_buf(int size) *------------------------------------------ */ -#define add_scriptb(a) if( script_pos+1>=script_size ) check_script_buf(1); script_buf[script_pos++]=(a); +#define add_scriptb(a) if( script_pos+1>=script_size ) check_script_buf(1); script_buf[script_pos++]=(uint8)(a); #if 0 static void add_scriptb(int a) @@ -432,7 +436,7 @@ static void add_scriptl(int l) * ラベルを解決する *------------------------------------------ */ -void set_label(int l,int pos, unsigned char *script_pos) +void set_label(int l,int pos, const char* script_pos) { int i,next; @@ -459,19 +463,23 @@ void set_label(int l,int pos, unsigned char *script_pos) * スペース/コメント読み飛ばし *------------------------------------------ */ -static unsigned char *skip_space(unsigned char *p) +static const char *skip_space(const char *p) { - while(1){ - while(isspace(*p)) - p++; - if(p[0]=='/' && p[1]=='/'){ + for(;;){ + while(ISSPACE(*p)) + ++p; + if( *p=='/' && p[1]=='/' ){ while(*p && *p!='\n') + ++p; + } else if( *p=='/' && p[1]=='*' ){ + p+=2; + if(*p) ++p; + while( *p && (p[-1]!='*' || *p!='/') ) p++; - } else if(p[0]=='/' && p[1]=='*'){ - p++; - while(*p && (p[-1]!='*' || p[0]!='/')) - p++; - if(*p) p++; + if(*p) + ++p; + else + disp_error_message("reached end of streams while matching \"*/\"",p); } else break; } @@ -482,7 +490,7 @@ static unsigned char *skip_space(unsigned char *p) * 1単語スキップ *------------------------------------------ */ -static unsigned char *skip_word(unsigned char *p) +static const char *skip_word(const char *p) { // prefix if(*p=='.') p++; @@ -503,11 +511,34 @@ static unsigned char *skip_word(unsigned char *p) return p; } +/// Adds a word to str_data +int add_word(const char *p) +{ + char *word; + int len; + int i; + + // Check for a word + len = skip_word(p)-p; + if( len == 0 ) + disp_error_message("expected a word",p); + + // Copy the word + CREATE(word,char,len+1); + memcpy(word,p,len); + word[len]=0; + + // add the word + i=add_str(word); + aFree(word); + return i; +} + /*========================================== * エラーメッセージ出力 *------------------------------------------ */ -static void disp_error_message(const char *mes,unsigned char *pos) +static void disp_error_message(const char *mes,const char *pos) { error_msg = aStrdup(mes); error_pos = pos; @@ -518,7 +549,7 @@ static void disp_error_message(const char *mes,unsigned char *pos) * 項の解析 *------------------------------------------ */ -unsigned char* parse_simpleexpr(unsigned char *p) +const char* parse_simpleexpr(const char *p) { int i; p=skip_space(p); @@ -527,73 +558,55 @@ unsigned char* parse_simpleexpr(unsigned char *p) if(battle_config.etc_log) ShowDebug("parse_simpleexpr %s\n",p); #endif - if(*p==';' || *p==','){ + if(*p==';' || *p==',') disp_error_message("unexpected expr end",p); - exit(1); - } if(*p=='('){ p=parse_subexpr(p+1,-1); p=skip_space(p); - if((*p++)!=')'){ + if((*p++)!=')') disp_error_message("unmatch ')'",p); - exit(1); - } } else if(isdigit(*p) || ((*p=='-' || *p=='+') && isdigit(p[1]))){ char *np; - i=strtoul((char *) p,&np,0); + i=strtoul(p,&np,0); add_scripti(i); - p=(unsigned char *) np; + p=np; } else if(*p=='"'){ add_scriptc(C_STR); p++; while(*p && *p!='"'){ if(p[-1]<=0x7e && *p=='\\') p++; - else if(*p=='\n'){ + else if(*p=='\n') disp_error_message("unexpected newline @ string",p); - exit(1); - } add_scriptb(*p++); } - if(!*p){ + if(!*p) disp_error_message("unexpected eof @ string",p); - exit(1); - } add_scriptb(0); p++; //'"' } else { - int c,l; - char *p2; + int l; // label , register , function etc - if(skip_word(p)==p){ + if(skip_word(p)==p) disp_error_message("unexpected character",p); - exit(1); - } - - p2=(char *) skip_word(p); - c=*p2; *p2=0; // 名前をadd_strする - l=add_str(p); + l=add_word(p); parse_cmd=l; // warn_*_mismatch_paramnumのために必要 + p=skip_word(p); - *p2=c; - p=(unsigned char *) p2; - - if(str_data[l].type!=C_FUNC && c=='['){ + if(str_data[l].type!=C_FUNC && *p=='['){ // array(name[i] => getelementofarray(name,i) ) - add_scriptl(search_str((unsigned char *) "getelementofarray")); + add_scriptl(search_str("getelementofarray")); add_scriptc(C_ARG); add_scriptl(l); p=parse_subexpr(p+1,-1); p=skip_space(p); - if((*p++)!=']'){ + if((*p++)!=']') disp_error_message("unmatch ']'",p); - exit(1); - } add_scriptc(C_FUNC); } else if(str_data[l].type == C_USERFUNC || str_data[l].type == C_USERFUNC_POS) { - add_scriptl(search_str((unsigned char*)"callsub")); + add_scriptl(search_str("callsub")); add_scriptc(C_ARG); add_scriptl(l); }else @@ -612,10 +625,10 @@ unsigned char* parse_simpleexpr(unsigned char *p) * 式の解析 *------------------------------------------ */ -unsigned char* parse_subexpr(unsigned char *p,int limit) +const char* parse_subexpr(const char* p,int limit) { int op,opl,len; - char *tmpp; + const char* tmpp; #ifdef DEBUG_FUNCIN if(battle_config.etc_log) @@ -624,14 +637,14 @@ unsigned char* parse_subexpr(unsigned char *p,int limit) p=skip_space(p); if(*p=='-'){ - tmpp=(char *) skip_space((unsigned char *) (p+1)); + tmpp=skip_space(p+1); if(*tmpp==';' || *tmpp==','){ add_scriptl(LABEL_NEXTLINE); p++; return p; } } - tmpp=(char *) p; + tmpp=p; if((op=C_NEG,*p=='-') || (op=C_LNOT,*p=='!') || (op=C_NOT,*p=='~')){ p=parse_subexpr(p+1,8); add_scriptc(op); @@ -668,20 +681,16 @@ unsigned char* parse_subexpr(unsigned char *p,int limit) add_scriptc(C_ARG); } else if(str_data[parse_cmd].type == C_USERFUNC || str_data[parse_cmd].type == C_USERFUNC_POS) { // ユーザー定義関数呼び出し - parse_cmd = search_str((unsigned char*)"callsub"); + parse_cmd = search_str("callsub"); i++; - } else { - disp_error_message( - "expect command, missing function name or calling undeclared function",(unsigned char *) tmpp - ); - exit(0); - } + } else + disp_error_message("expect command, missing function name or calling undeclared function",tmpp); func=parse_cmd; - if( *p == '(' && *(plist[i]=(char *)skip_space(p+1)) == ')' ){ - p=(char *)plist[i]+1; // empty argument list + if( *p == '(' && *(plist[i]=skip_space(p+1)) == ')' ){ + p=plist[i]+1; // empty argument list } else while(*p && *p!=')' && i<128) { - plist[i]=(char *) p; + plist[i]=p; p=parse_subexpr(p,-1); p=skip_space(p); if(*p==',') p++; @@ -691,7 +700,7 @@ unsigned char* parse_subexpr(unsigned char *p,int limit) p=skip_space(p); i++; }; - plist[i]=(char *) p; + plist[i]=p; if(*(p++)!=')'){ disp_error_message("func request '(' ')'",p); exit(1); @@ -700,10 +709,11 @@ unsigned char* parse_subexpr(unsigned char *p,int limit) if( str_data[func].type==C_FUNC && script_config.warn_func_mismatch_paramnum){ const char *arg = buildin_func[str_data[func].val].arg; int j = 0; - for (; arg[j]; j++) if (arg[j] == '*') break; - if (!(i <= 1 && j == 0) && ((arg[j] == 0 && i != j) || (arg[j] == '*' && i < j))) { - disp_error_message("illegal number of parameters",(unsigned char *) (plist[(i=2 || sscanf(line,"%[A-Za-z0-9_] %[-0-9xXA-Fa-f] %d",name,val,&type)>=2){ for(i=0;name[i];i++) - name[i]=tolower(name[i]); - n=add_str((const unsigned char *) name); + name[i]=TOLOWER(name[i]); + n=add_str(name); if(type==0) str_data[n].type=C_INT; else @@ -1527,7 +1529,7 @@ static void read_constdb(void) const char* script_print_line( const char *p, const char *mark, int line ); -void script_error(char *src,const char *file,int start_line, const char *error_msg, const char *error_pos) { +void script_error(const char *src,const char *file,int start_line, const char *error_msg, const char *error_pos) { // エラーが発生した行を求める int j; int line = start_line; @@ -1580,9 +1582,9 @@ const char* script_print_line( const char *p, const char *mark, int line ) { *------------------------------------------ */ -struct script_code* parse_script(unsigned char *src,const char *file,int line) +struct script_code* parse_script(const char *src,const char *file,int line) { - unsigned char *p,*tmpp; + const char *p,*tmpp; int i; struct script_code *code; static int first=1; @@ -1594,7 +1596,7 @@ struct script_code* parse_script(unsigned char *src,const char *file,int line) } first=0; - script_buf=(unsigned char *)aCalloc(SCRIPT_BLOCK_SIZE,sizeof(unsigned char)); + CREATE(script_buf,unsigned char,SCRIPT_BLOCK_SIZE); script_pos=0; script_size=SCRIPT_BLOCK_SIZE; str_data[LABEL_NEXTLINE].type=C_NOP; @@ -1631,7 +1633,6 @@ struct script_code* parse_script(unsigned char *src,const char *file,int line) p=skip_space(p); if(*p!='{'){ disp_error_message("not found '{'",p); - exit(1); } p++; p = skip_space(p); @@ -1649,26 +1650,9 @@ struct script_code* parse_script(unsigned char *src,const char *file,int line) // labelだけ特殊処理 tmpp=skip_space(skip_word(p)); if(*tmpp==':' && !(!strncmp(p,"default:",8) && p + 7 == tmpp)){ - int l,c; - - c=*skip_word(p); - *skip_word(p)=0; - if(*p == 0) { - *skip_word(p)=c; - disp_error_message("label length 0 ",p); - exit(1); - } - l=add_str(p); - /* FIXME: How much does it breaks to not restore skipword(p)=c when an error occurs here? - if(str_data[l].label!=-1){ - *skip_word(p)=c; - disp_error_message("dup label ",p); - exit(1); - } - */ - set_label(l,script_pos,p); - strdb_put(scriptlabel_db, p, (void*)script_pos); - *skip_word(p)=c; + i=add_word(p); + set_label(i,script_pos,p); + strdb_put(scriptlabel_db, GETSTRING(str_data[i].str), (void*)script_pos); p=tmpp+1; continue; } @@ -1687,7 +1671,7 @@ struct script_code* parse_script(unsigned char *src,const char *file,int line) add_scriptc(C_NOP); script_size = script_pos; - script_buf=(unsigned char *)aRealloc(script_buf,script_pos); + RECREATE(script_buf,unsigned char,script_pos); // 未解決のラベルを解決 for(i=LABEL_START;iscript_buf = script_buf; code->script_size = script_size; code->script_vars = NULL; @@ -1923,7 +1907,7 @@ static int set_reg(struct script_state*st,struct map_session_data *sd,int num,ch int set_var(struct map_session_data *sd, char *name, void *val) { - return set_reg(NULL, sd, add_str((unsigned char *) name), name, val, NULL); + return set_reg(NULL, sd, add_str(name), name, val, NULL); } /*========================================== @@ -2003,7 +1987,7 @@ void push_val2(struct script_stack *stack,int type,int val,struct linkdb_node** * スタックへ文字列をプッシュ *------------------------------------------ */ -void push_str(struct script_stack *stack,int type,unsigned char *str) +void push_str(struct script_stack *stack,int type,char *str) { if(stack->sp>=stack->sp_max){ stack->sp_max += 64; @@ -2014,9 +1998,9 @@ void push_str(struct script_stack *stack,int type,unsigned char *str) } // if(battle_config.etc_log) // printf("push (%d,%x)-> %d\n",type,str,stack->sp); - stack->stack_data[stack->sp].type=type; - stack->stack_data[stack->sp].u.str=(char *) str; - stack->stack_data[stack->sp].ref = NULL; + stack->stack_data[stack->sp].type =type; + stack->stack_data[stack->sp].u.str=str; + stack->stack_data[stack->sp].ref =NULL; stack->sp++; } @@ -2028,10 +2012,10 @@ void push_copy(struct script_stack *stack,int pos) { switch(stack->stack_data[pos].type){ case C_CONSTSTR: - push_str(stack,C_CONSTSTR,(unsigned char *) stack->stack_data[pos].u.str); + push_str(stack,C_CONSTSTR,stack->stack_data[pos].u.str); break; case C_STR: - push_str(stack,C_STR,(unsigned char *) aStrdup(stack->stack_data[pos].u.str)); + push_str(stack,C_STR,aStrdup(stack->stack_data[pos].u.str)); break; default: push_val2( @@ -2891,14 +2875,14 @@ static int script_load_mapreg(void) } p=(char *)aMallocA((strlen(buf2) + 1)*sizeof(char)); strcpy(p,buf2); - s= add_str((unsigned char *) buf1); + s= add_str(buf1); idb_put(mapregstr_db,(i<<24)|s,p); }else{ if( sscanf(line+n,"%d",&v)!=1 ){ ShowError("%s: %s broken data !\n",mapreg_txt,buf1); continue; } - s= add_str((unsigned char *) buf1); + s= add_str(buf1); idb_put(mapreg_db,(i<<24)|s,(void*)v); } } @@ -2932,10 +2916,10 @@ static int script_load_mapreg(void) i = atoi(sql_row[1]); p=(char *)aMallocA((strlen(sql_row[2]) + 1)*sizeof(char)); strcpy(p,sql_row[2]); - s= add_str((unsigned char *) buf1); + s= add_str(buf1); idb_put(mapregstr_db,(i<<24)|s,p); }else{ - s= add_str((unsigned char *) buf1); + s= add_str(buf1); v= atoi(sql_row[2]); i = atoi(sql_row[1]); idb_put(mapreg_db,(i<<24)|s,(void *)v); @@ -2945,7 +2929,7 @@ static int script_load_mapreg(void) ShowInfo("Freeing results...\n"); mysql_free_result(sql_res); mapreg_dirty=0; - perfomance = ((unsigned int)time(NULL) - perfomance); + perfomance = (time(NULL) - perfomance); ShowInfo("SQL Mapreg Loading Completed Under %d Seconds.\n",perfomance); return 0; #endif /* TXT_ONLY */ @@ -3178,7 +3162,8 @@ int script_config_read(char *cfgName) } -static int do_final_userfunc_sub (DBKey key,void *data,va_list ap){ +static int do_final_userfunc_sub (DBKey key,void *data,va_list ap) +{ struct script_code *code = (struct script_code *)data; if(code){ script_free_vars( &code->script_vars ); @@ -3967,7 +3952,7 @@ int buildin_callfunc(struct script_state *st) struct script_code *scr, *oldscr; char *str=conv_str(st,& (st->stack->stack_data[st->start+2])); - if( (scr=strdb_get(userfunc_db,(unsigned char*)str)) ){ + if( (scr=strdb_get(userfunc_db,str)) ){ int i,j; struct linkdb_node **oldval = st->stack->var_function; for(i=st->start+3,j=0;iend;i++,j++) @@ -4191,7 +4176,7 @@ int buildin_menu(struct script_state *st) st->state=END; return 1; } - pc_setreg(sd,add_str((unsigned char *) "@menu"),sd->npc_menu); + pc_setreg(sd,add_str("@menu"),sd->npc_menu); st->pos=conv_num(st,& (st->stack->stack_data[st->start+sd->npc_menu*2+1])); st->state=GOTO; } @@ -4651,7 +4636,7 @@ int buildin_input(struct script_state *st) set_reg(st,sd,num,name,(void*)sd->npc_amount,st->stack->stack_data[st->start+2].ref); } else { // ragemu互換のため - //pc_setreg(sd,add_str((unsigned char *) "l14"),sd->npc_amount); + //pc_setreg(sd,add_str("l14"),sd->npc_amount); } return 0; } @@ -5694,9 +5679,9 @@ int buildin_getpartyname(struct script_state *st) party_id=conv_num(st,& (st->stack->stack_data[st->start+2])); name=buildin_getpartyname_sub(party_id); if(name != NULL) - push_str(st->stack,C_STR,(unsigned char *)name); + push_str(st->stack,C_STR,name); else - push_str(st->stack,C_CONSTSTR, (unsigned char *) "null"); + push_str(st->stack,C_CONSTSTR,"null"); return 0; } @@ -5719,19 +5704,19 @@ int buildin_getpartymember(struct script_state *st) if(p->party.member[i].account_id){ switch (type) { case 2: - mapreg_setreg(add_str((unsigned char *) "$@partymemberaid")+(j<<24),p->party.member[i].account_id); + mapreg_setreg(add_str("$@partymemberaid")+(j<<24),p->party.member[i].account_id); break; case 1: - mapreg_setreg(add_str((unsigned char *) "$@partymembercid")+(j<<24),p->party.member[i].char_id); + mapreg_setreg(add_str("$@partymembercid")+(j<<24),p->party.member[i].char_id); break; default: - mapreg_setregstr(add_str((unsigned char *) "$@partymembername$")+(j<<24),p->party.member[i].name); + mapreg_setregstr(add_str("$@partymembername$")+(j<<24),p->party.member[i].name); } j++; } } } - mapreg_setreg(add_str((unsigned char *) "$@partymembercount"),j); + mapreg_setreg(add_str("$@partymembercount"),j); return 0; } @@ -5759,7 +5744,7 @@ int buildin_getpartyleader(struct script_state *st) if (type) push_val(st->stack,C_INT,-1); else - push_str(st->stack,C_CONSTSTR, (unsigned char *) "null"); + push_str(st->stack,C_CONSTSTR,"null"); return 0; } @@ -5780,7 +5765,7 @@ int buildin_getpartyleader(struct script_state *st) push_val(st->stack,C_INT,p->party.member[i].lv); break; default: - push_str(st->stack,C_STR,(unsigned char *)p->party.member[i].name); + push_str(st->stack,C_STR,p->party.member[i].name); break; } return 0; @@ -5810,9 +5795,9 @@ int buildin_getguildname(struct script_state *st) int guild_id=conv_num(st,& (st->stack->stack_data[st->start+2])); name=buildin_getguildname_sub(guild_id); if(name != NULL) - push_str(st->stack,C_STR,(unsigned char *) name); + push_str(st->stack,C_STR,name); else - push_str(st->stack,C_CONSTSTR,(unsigned char *) "null"); + push_str(st->stack,C_CONSTSTR,"null"); return 0; } @@ -5841,9 +5826,9 @@ int buildin_getguildmaster(struct script_state *st) int guild_id=conv_num(st,& (st->stack->stack_data[st->start+2])); master=buildin_getguildmaster_sub(guild_id); if(master!=0) - push_str(st->stack,C_STR,(unsigned char *) master); + push_str(st->stack,C_STR,master); else - push_str(st->stack,C_CONSTSTR,(unsigned char *) "null"); + push_str(st->stack,C_CONSTSTR,"null"); return 0; } @@ -5877,31 +5862,31 @@ int buildin_strcharinfo(struct script_state *st) sd=script_rid2sd(st); if (!sd) { //Avoid crashing.... - push_str(st->stack,C_CONSTSTR,(unsigned char *) ""); + push_str(st->stack,C_CONSTSTR,""); return 0; } num=conv_num(st,& (st->stack->stack_data[st->start+2])); switch(num){ case 0: - push_str(st->stack,C_CONSTSTR,(unsigned char *) sd->status.name); + push_str(st->stack,C_CONSTSTR,sd->status.name); break; case 1: buf=buildin_getpartyname_sub(sd->status.party_id); if(buf!=0) - push_str(st->stack,C_STR,(unsigned char *) buf); + push_str(st->stack,C_STR,buf); else - push_str(st->stack,C_CONSTSTR,(unsigned char *) ""); + push_str(st->stack,C_CONSTSTR,""); break; case 2: buf=buildin_getguildname_sub(sd->status.guild_id); if(buf != NULL) - push_str(st->stack,C_STR,(unsigned char *) buf); + push_str(st->stack,C_STR,buf); else - push_str(st->stack,C_CONSTSTR,(unsigned char *) ""); + push_str(st->stack,C_CONSTSTR,""); break; default: ShowWarning("buildin_strcharinfo: unknown parameter."); - push_str(st->stack,C_CONSTSTR,(unsigned char *) ""); + push_str(st->stack,C_CONSTSTR,""); break; } @@ -5964,7 +5949,7 @@ int buildin_getequipname(struct script_state *st) }else{ sprintf(buf,"%s-[%s]",pos[num-1],pos[10]); } - push_str(st->stack,C_STR,(unsigned char *) buf); + push_str(st->stack,C_STR,buf); return 0; } @@ -6187,7 +6172,7 @@ int buildin_successrefitem(struct script_state *st) clif_misceffect(&sd->bl,3); if(sd->status.inventory[i].refine == MAX_REFINE && sd->status.inventory[i].card[0] == CARD0_FORGE && - sd->status.char_id == MakeDWord(sd->status.inventory[i].card[2],sd->status.inventory[i].card[3]) + sd->status.char_id == (int)MakeDWord(sd->status.inventory[i].card[2],sd->status.inventory[i].card[3]) ){ // Fame point system [DracoRPG] switch (sd->inventory_data[i]->wlv){ case 1: @@ -6773,7 +6758,7 @@ int buildin_gettimestr(struct script_state *st) strftime(tmpstr,maxlen,fmtstr,localtime(&now)); tmpstr[maxlen]='\0'; - push_str(st->stack,C_STR,(unsigned char *) tmpstr); + push_str(st->stack,C_STR,tmpstr); return 0; } @@ -6986,11 +6971,9 @@ int buildin_killmonster_sub(struct block_list *bl,va_list ap) if(!allflag){ if(strcmp(event,md->npc_event)==0) status_kill(bl); - return 0; }else{ if(!md->spawn) status_kill(bl); - return 0; } return 0; } @@ -8143,13 +8126,13 @@ int buildin_getwaitingroomstate(struct script_state *st) case 33: val=(cd->users >= cd->trigger); break; case 4: - push_str(st->stack,C_CONSTSTR,(unsigned char *) cd->title); + push_str(st->stack,C_CONSTSTR,cd->title); return 0; case 5: - push_str(st->stack,C_CONSTSTR,(unsigned char *) cd->pass); + push_str(st->stack,C_CONSTSTR,cd->pass); return 0; case 16: - push_str(st->stack,C_CONSTSTR,(unsigned char *) cd->npc_event); + push_str(st->stack,C_CONSTSTR,cd->npc_event); return 0; } push_val(st->stack,C_INT,val); @@ -8183,7 +8166,7 @@ int buildin_warpwaitingpc(struct script_state *st) sd=cd->usersd[0]; if (!sd) continue; //Broken npc chat room? - mapreg_setreg(add_str((unsigned char *) "$@warpwaitingpc")+(i<<24),sd->bl.id); + mapreg_setreg(add_str("$@warpwaitingpc")+(i<<24),sd->bl.id); if(strcmp(str,"Random")==0) pc_randomwarp(sd,3); @@ -8196,7 +8179,7 @@ int buildin_warpwaitingpc(struct script_state *st) }else pc_setpos(sd,mapindex_name2id(str),x,y,0); } - mapreg_setreg(add_str((unsigned char *) "$@warpwaitingpcnum"),n); + mapreg_setreg(add_str("$@warpwaitingpcnum"),n); return 0; } /*========================================== @@ -8617,7 +8600,7 @@ int buildin_pvpoff(struct script_state *st) if((pl_sd=pl_allsd[i]) && m == pl_sd->bl.m) { clif_pvpset(pl_sd,0,0,2); - if(pl_sd->pvp_timer != -1) { + if(pl_sd->pvp_timer != UINT_MAX) { delete_timer(pl_sd->pvp_timer,pc_calc_pvprank_timer); pl_sd->pvp_timer = -1; } @@ -8761,8 +8744,8 @@ int buildin_agitcheck(struct script_state *st) if (agit_flag==0) push_val(st->stack,C_INT,0); } else { sd=script_rid2sd(st); - if (agit_flag==1) pc_setreg(sd,add_str((unsigned char *) "@agit_flag"),1); - if (agit_flag==0) pc_setreg(sd,add_str((unsigned char *) "@agit_flag"),0); + if (agit_flag==1) pc_setreg(sd,add_str("@agit_flag"),1); + if (agit_flag==0) pc_setreg(sd,add_str("@agit_flag"),0); } return 0; } @@ -8780,7 +8763,7 @@ int buildin_flagemblem(struct script_state *st) int buildin_getcastlename(struct script_state *st) { char *mapname=conv_str(st,& (st->stack->stack_data[st->start+2])); - struct guild_castle *gc; + struct guild_castle *gc=NULL; int i; for(i=0;istack,C_CONSTSTR,(unsigned char *) gc->castle_name); + push_str(st->stack,C_CONSTSTR,gc->castle_name); else - push_str(st->stack,C_CONSTSTR,(unsigned char *) ""); + push_str(st->stack,C_CONSTSTR,""); return 0; } @@ -9379,10 +9362,10 @@ int buildin_strmobinfo(struct script_state *st) switch (num) { case 1: - push_str(st->stack,C_CONSTSTR,(unsigned char *) mob_db(class_)->name); + push_str(st->stack,C_CONSTSTR,mob_db(class_)->name); break; case 2: - push_str(st->stack,C_CONSTSTR,(unsigned char *) mob_db(class_)->jname); + push_str(st->stack,C_CONSTSTR,mob_db(class_)->jname); break; case 3: push_val(st->stack,C_INT,mob_db(class_)->lv); @@ -9476,13 +9459,13 @@ int buildin_getitemname(struct script_state *st) i_data = itemdb_exists(item_id); if (i_data == NULL) { - push_str(st->stack,C_CONSTSTR,(unsigned char *) "null"); + push_str(st->stack,C_CONSTSTR,"null"); return 0; } item_name=(char *)aMallocA(ITEM_NAME_LENGTH*sizeof(char)); memcpy(item_name, i_data->jname, ITEM_NAME_LENGTH); - push_str(st->stack,C_STR,(unsigned char *) item_name); + push_str(st->stack,C_STR,item_name); return 0; } /*========================================== @@ -9664,12 +9647,12 @@ int buildin_getinventorylist(struct script_state *st) if(!sd) return 0; for(i=0;istatus.inventory[i].nameid > 0 && sd->status.inventory[i].amount > 0){ - pc_setreg(sd,add_str((unsigned char *) "@inventorylist_id")+(j<<24),sd->status.inventory[i].nameid); - pc_setreg(sd,add_str((unsigned char *) "@inventorylist_amount")+(j<<24),sd->status.inventory[i].amount); - pc_setreg(sd,add_str((unsigned char *) "@inventorylist_equip")+(j<<24),sd->status.inventory[i].equip); - pc_setreg(sd,add_str((unsigned char *) "@inventorylist_refine")+(j<<24),sd->status.inventory[i].refine); - pc_setreg(sd,add_str((unsigned char *) "@inventorylist_identify")+(j<<24),sd->status.inventory[i].identify); - pc_setreg(sd,add_str((unsigned char *) "@inventorylist_attribute")+(j<<24),sd->status.inventory[i].attribute); + pc_setreg(sd,add_str("@inventorylist_id")+(j<<24),sd->status.inventory[i].nameid); + pc_setreg(sd,add_str("@inventorylist_amount")+(j<<24),sd->status.inventory[i].amount); + pc_setreg(sd,add_str("@inventorylist_equip")+(j<<24),sd->status.inventory[i].equip); + pc_setreg(sd,add_str("@inventorylist_refine")+(j<<24),sd->status.inventory[i].refine); + pc_setreg(sd,add_str("@inventorylist_identify")+(j<<24),sd->status.inventory[i].identify); + pc_setreg(sd,add_str("@inventorylist_attribute")+(j<<24),sd->status.inventory[i].attribute); for (k = 0; k < MAX_SLOTS; k++) { sprintf(card_var, "@inventorylist_card%d",k+1); @@ -9678,7 +9661,7 @@ int buildin_getinventorylist(struct script_state *st) j++; } } - pc_setreg(sd,add_str((unsigned char *) "@inventorylist_count"),j); + pc_setreg(sd,add_str("@inventorylist_count"),j); return 0; } @@ -9689,13 +9672,13 @@ int buildin_getskilllist(struct script_state *st) if(!sd) return 0; for(i=0;istatus.skill[i].id > 0 && sd->status.skill[i].lv > 0){ - pc_setreg(sd,add_str((unsigned char *) "@skilllist_id")+(j<<24),sd->status.skill[i].id); - pc_setreg(sd,add_str((unsigned char *)"@skilllist_lv")+(j<<24),sd->status.skill[i].lv); - pc_setreg(sd,add_str((unsigned char *)"@skilllist_flag")+(j<<24),sd->status.skill[i].flag); + pc_setreg(sd,add_str("@skilllist_id")+(j<<24),sd->status.skill[i].id); + pc_setreg(sd,add_str("@skilllist_lv")+(j<<24),sd->status.skill[i].lv); + pc_setreg(sd,add_str("@skilllist_flag")+(j<<24),sd->status.skill[i].flag); j++; } } - pc_setreg(sd,add_str((unsigned char *) "@skilllist_count"),j); + pc_setreg(sd,add_str("@skilllist_count"),j); return 0; } @@ -10262,9 +10245,9 @@ int buildin_getpetinfo(struct script_state *st) break; case 2: if(pd->pet.name) - push_str(st->stack,C_CONSTSTR,(unsigned char *) pd->pet.name); + push_str(st->stack,C_CONSTSTR,pd->pet.name); else - push_str(st->stack,C_CONSTSTR, (unsigned char *) "null"); + push_str(st->stack,C_CONSTSTR,"null"); break; case 3: push_val(st->stack,C_INT,pd->pet.intimate); @@ -10368,7 +10351,7 @@ int buildin_select(struct script_state *st) if((int)strlen(st->stack->stack_data[i].u.str) < 1) sd->npc_menu++; //Empty selection which wasn't displayed on the client. } - pc_setreg(sd,add_str((unsigned char *) "@menu"),sd->npc_menu); + pc_setreg(sd,add_str("@menu"),sd->npc_menu); sd->state.menu_or_input=0; push_val(st->stack,C_INT,sd->npc_menu); } @@ -10413,7 +10396,7 @@ int buildin_prompt(struct script_state *st) sd->npc_menu++; //Empty selection which wasn't displayed on the client. } } - pc_setreg(sd,add_str((unsigned char *) "@menu"),sd->npc_menu); + pc_setreg(sd,add_str("@menu"),sd->npc_menu); sd->state.menu_or_input=0; push_val(st->stack,C_INT,sd->npc_menu); } @@ -10678,7 +10661,7 @@ int buildin_getsavepoint(struct script_state *st) mapname=(char *) aMallocA((MAP_NAME_LENGTH+1)*sizeof(char)); memcpy(mapname, mapindex_id2name(sd->status.save_point.map), MAP_NAME_LENGTH); mapname[MAP_NAME_LENGTH]='\0'; - push_str(st->stack,C_STR,(unsigned char *) mapname); + push_str(st->stack,C_STR,mapname); break; case 1: push_val(st->stack,C_INT,x); @@ -11382,7 +11365,7 @@ int buildin_checkcell(struct script_state *st){ // [zBuffer] List of dynamic var commands ---> void setd_sub(struct script_state *st, struct map_session_data *sd, char *varname, int elem, void *value, struct linkdb_node **ref) { - set_reg(st, sd, add_str((unsigned char *) varname)+(elem<<24), varname, value, ref); + set_reg(st, sd, add_str(varname)+(elem<<24), varname, value, ref); return; } @@ -11495,7 +11478,7 @@ int buildin_escape_sql(struct script_state *st) { t_query = aMallocA((strlen(query)*2+1)*sizeof(char)); jstrescapecpy(t_query,query); - push_str(st->stack,C_STR,(unsigned char *)t_query); + push_str(st->stack,C_STR,t_query); return 0; } @@ -11511,7 +11494,7 @@ int buildin_getd (struct script_state *st) elem = 0; /*dat.type=C_NAME; - dat.u.num=add_str((unsigned char *) varname)+(elem<<24); + dat.u.num=add_str(varname)+(elem<<24); get_val(st,&dat); if(dat.type == C_INT) @@ -11525,7 +11508,7 @@ int buildin_getd (struct script_state *st) // Push the 'pointer' so it's more flexible [Lance] push_val(st->stack,C_NAME, - (elem<<24) | add_str((unsigned char *) varname)); + (elem<<24) | add_str(varname)); return 0; } @@ -11747,7 +11730,7 @@ int buildin_setitemscript(struct script_state *st) if (i_data && script!=NULL && script[0]=='{') { if(i_data->script!=NULL) script_free_code(i_data->script); - i_data->script = parse_script((unsigned char *) script, "script_setitemscript", 0); + i_data->script = parse_script(script, "script_setitemscript", 0); push_val(st->stack,C_INT,1); } else push_val(st->stack,C_INT,0); @@ -11800,7 +11783,7 @@ int buildin_getmonsterinfo(struct script_state *st) mob = mob_db(mob_id); switch ( conv_num(st,& (st->stack->stack_data[st->start+3])) ) { case 0: //Name - push_str(st->stack,C_CONSTSTR, (unsigned char *) mob->jname); + push_str(st->stack,C_CONSTSTR,mob->jname); break; case 1: //Lvl push_val(st->stack,C_INT, mob->lv); diff --git a/src/map/script.h b/src/map/script.h index 60fc3e990..274bc9022 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -31,7 +31,7 @@ extern struct Script_Config { struct script_data { int type; - union { + union script_data_val { int num; char *str; } u; @@ -61,7 +61,7 @@ struct script_state { } sleep; }; -struct script_code* parse_script(unsigned char *,const char*,int); +struct script_code* parse_script(const char* src,const char* file,int line); void run_script_sub(struct script_code *rootscript,int pos,int rid,int oid, char* file, int lineno); void run_script(struct script_code*,int,int,int); diff --git a/src/plugins/Makefile b/src/plugins/Makefile index 599d0f1e3..183905a46 100644 --- a/src/plugins/Makefile +++ b/src/plugins/Makefile @@ -1,51 +1,52 @@ - -OBJECTS = sample.dll sig.dll pid.dll gui.dll upnp.dll httpd.dll - -ifdef CYGWIN - PLUGINEXT = dll -else - PLUGINEXT = so -endif - -PLUGINS = $(OBJECTS:%.dll=%.$(PLUGINEXT)) -COMMON_H = ../common/plugin.h - -txt sql all: $(PLUGINS) - -%.$(PLUGINEXT): %.c - $(CC) $(CFLAGS) -shared -o ../../plugins/$@ $< - @touch $@ - -httpd.$(PLUGINEXT): httpd.c - $(CC) $(CFLAGS) -shared -o ../../plugins/$@ $< \ - ../common/obj/minimalloc.o ../common/obj/db.o ../common/obj/showmsg.o \ - ../common/obj/utils.o ../common/obj/ers.o - @touch $@ - -sig.$(PLUGINEXT): sig.c - $(CC) $(CFLAGS) -shared -o ../../plugins/$@ $< \ - ../common/obj/showmsg.o - @touch $@ - -gui.$(PLUGINEXT): ../../plugins/gui.conf -httpd.$(PLUGINEXT): ../../plugins/httpd.conf -upnp.$(PLUGINEXT): ../../plugins/upnp.conf - -../../plugins/%.conf: %.txt - cp -r $< $@ - -../../plugins/gui.conf: gui.txt -../../plugins/httpd.conf: httpd.txt -../../plugins/upnp.conf: upnp.txt - -depend: - makedepend -fGNUmakefile -o.$(PLUGINEXT) -Y. -Y../common *.c -clean: - rm -rf $(PLUGINS) - -# DO NOT DELETE - -sample.$(PLUGINEXT): sample.c $(COMMON_H) -sig.$(PLUGINEXT): sig.c $(COMMON_H) -pid.$(PLUGINEXT): pid.c $(COMMON_H) -gui.$(PLUGINEXT): gui.c $(COMMON_H) + +OBJECTS = sample.dll sig.dll pid.dll gui.dll upnp.dll httpd.dll + +ifdef CYGWIN + PLUGINEXT = dll +else + PLUGINEXT = so +endif + +PLUGINS = $(OBJECTS:%.dll=%.$(PLUGINEXT)) +COMMON_H = ../common/plugin.h + +txt sql all: $(PLUGINS) + +%.$(PLUGINEXT): %.c + $(CC) $(CFLAGS) -shared -o ../../plugins/$@ $< + @touch $@ + +httpd.$(PLUGINEXT): httpd.c + $(CC) $(CFLAGS) -shared -o ../../plugins/$@ $< \ + ../common/obj/minimalloc.o ../common/obj/db.o ../common/obj/showmsg.o \ + ../common/obj/utils.o ../common/obj/ers.o + @touch $@ + +sig.$(PLUGINEXT): sig.c + $(CC) $(CFLAGS) -shared -o ../../plugins/$@ $< \ + ../common/obj/showmsg.o ../common/obj/utils.o \ + ../common/obj/minimalloc.o + @touch $@ + +gui.$(PLUGINEXT): ../../plugins/gui.conf +httpd.$(PLUGINEXT): ../../plugins/httpd.conf +upnp.$(PLUGINEXT): ../../plugins/upnp.conf + +../../plugins/%.conf: %.txt + cp -r $< $@ + +../../plugins/gui.conf: gui.txt +../../plugins/httpd.conf: httpd.txt +../../plugins/upnp.conf: upnp.txt + +depend: + makedepend -fGNUmakefile -o.$(PLUGINEXT) -Y. -Y../common *.c +clean: + rm -rf $(PLUGINS) + +# DO NOT DELETE + +sample.$(PLUGINEXT): sample.c $(COMMON_H) +sig.$(PLUGINEXT): sig.c $(COMMON_H) +pid.$(PLUGINEXT): pid.c $(COMMON_H) +gui.$(PLUGINEXT): gui.c $(COMMON_H) -- cgit v1.2.3-70-g09d2 From 9855d5724bd4bc11b2ee2e155ce827c3acb66618 Mon Sep 17 00:00:00 2001 From: skotlex Date: Wed, 20 Dec 2006 16:43:46 +0000 Subject: - Fixed ISSPACE and ISALPHA casting their returned value to a char. These are "bool" functions, and as such return an non-zero int as result, casting them to char just... really messes things up when the returned value is out of the CHAR_MAX/CHAR_MIN range! git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9538 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 +++ src/common/cbasetypes.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 60791db70..85a4676df 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2006/12/20 + * Fixed ISSPACE and ISALPHA casting their returned value to a char, which + can really mess up the scripting engine when the returned value is true, + yet casted to false. * Moved the strip unequip code to before deleting the timer, this fixes trying to "re-strip" someone causing the skill to fail and on top of that terminate their current strip effect. diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 3ef6dfd2f..3b5c69fbe 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -289,7 +289,7 @@ typedef char bool; ////////////////////////////////////////////////////////////////////////// // Has to be unsigned to avoid problems in some systems #define TOLOWER(c) ((char)tolower((unsigned char)(c))) -#define ISSPACE(c) ((char)isspace((unsigned char)(c))) -#define ISALPHA(c) ((char)isalpha((unsigned char)(c))) +#define ISSPACE(c) (isspace((unsigned char)(c))) +#define ISALPHA(c) (isalpha((unsigned char)(c))) #endif /* _CBASETYPES_H_ */ -- cgit v1.2.3-70-g09d2 From d3a2bbe60ca0a543713bc0bdd280be7c9c9c2951 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Thu, 21 Dec 2006 01:16:30 +0000 Subject: - Moved md5calc to common - Answered Skotlex's question and fixed "warning: comparison is always false due to limited range of data type" by restricting script words to ASCII characters only. - Applied "svn:eol-style native" to makefiles and project files git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9544 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 4 + Makefile | 498 ++++++++++----------- eAthena-7.1.sln | 122 ++--- eAthena-8.sln | 92 ++-- src/char/Makefile | 62 +-- src/char_sql/Makefile | 54 +-- src/common/Makefile | 121 ++--- src/common/cbasetypes.h | 1 + src/common/md5calc.c | 236 ++++++++++ src/common/md5calc.h | 7 + src/ladmin/Makefile | 37 +- src/ladmin/ladmin.c | 2 +- src/ladmin/md5calc.c | 239 ---------- src/ladmin/md5calc.h | 10 - src/login/Makefile | 51 +-- src/login/login.c | 2 +- src/login/md5calc.c | 236 ---------- src/login/md5calc.h | 7 - src/login_sql/Makefile | 45 +- src/login_sql/login.c | 2 +- src/login_sql/make.sh | 6 - src/login_sql/md5calc.c | 239 ---------- src/login_sql/md5calc.h | 10 - src/map/Makefile | 212 ++++----- src/map/npc.c | 2 +- src/map/script.c | 39 +- src/plugins/Makefile | 2 +- src/tool/Makefile | 20 +- src/txt-converter/Makefile | 48 +- src/webserver/Makefile | 40 +- src/zlib/Makefile | 42 +- vcproj-7.1/char-server_sql.vcproj | 618 +++++++++++++------------- vcproj-7.1/char-server_txt.vcproj | 602 ++++++++++++------------- vcproj-7.1/login-server_sql.vcproj | 526 +++++++++++----------- vcproj-7.1/login-server_txt.vcproj | 530 +++++++++++----------- vcproj-7.1/map-server_sql.vcproj | 884 ++++++++++++++++++------------------ vcproj-7.1/map-server_txt.vcproj | 886 ++++++++++++++++++------------------- vcproj-8/char-server_sql.vcproj | 612 ++++++++++++------------- vcproj-8/char-server_txt.vcproj | 608 ++++++++++++------------- vcproj-8/login-server_sql.vcproj | 562 +++++++++++------------ vcproj-8/login-server_txt.vcproj | 568 ++++++++++++------------ vcproj-8/map-server_sql.vcproj | 788 ++++++++++++++++----------------- vcproj-8/map-server_txt.vcproj | 792 ++++++++++++++++----------------- 43 files changed, 4983 insertions(+), 5481 deletions(-) create mode 100644 src/common/md5calc.c create mode 100644 src/common/md5calc.h delete mode 100644 src/ladmin/md5calc.c delete mode 100644 src/ladmin/md5calc.h delete mode 100644 src/login/md5calc.c delete mode 100644 src/login/md5calc.h delete mode 100644 src/login_sql/make.sh delete mode 100644 src/login_sql/md5calc.c delete mode 100644 src/login_sql/md5calc.h (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 85a4676df..770341066 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,10 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2006/12/21 + * Fixed "warning: comparison is always false due to limited range of data type" + by restricting script words to ASCII characters only. + * Moved md5calc to common. [FlavioJS] 2006/12/20 * Fixed ISSPACE and ISALPHA casting their returned value to a char, which can really mess up the scripting engine when the returned value is true, diff --git a/Makefile b/Makefile index 2135a0f67..f1f292cea 100644 --- a/Makefile +++ b/Makefile @@ -1,249 +1,249 @@ - -CACHED = $(shell ls | grep Makefile.cache) -ifeq ($(findstring Makefile.cache,$(CACHED)), Makefile.cache) -MKDEF = $(shell cat Makefile.cache) -else - -CC = gcc -pipe -# CC = g++ --pipe - -MAKE = make -# MAKE = gmake - -OPT = -g -OPT += -O2 -# OPT += -O3 -# OPT += -mmmx -# OPT += -msse -# OPT += -msse2 -# OPT += -msse3 -# OPT += -rdynamic -OPT += -ffast-math -# OPT += -fbounds-checking -# OPT += -fstack-protector -# OPT += -fomit-frame-pointer -OPT += -Wall -Wno-sign-compare -# Uncomment this one if you are using GCC 4.X -# OPT += -Wno-unused-parameter -Wno-pointer-sign -# Makes map-wide script variables be saved to SQL instead of TXT files. -# OPT += -DMAPREGSQL -# Turbo is an alternate socket access implementation which should be faster. -# DO NOT ENABLE YET as it isn't quite ready for general usage. -# OPT += -DTURBO -# Enable the perl regular expression support for scripts -# OPT += -DPCRE_SUPPORT -# OPT += -DGCOLLECT -# OPT += -DMEMWATCH -# OPT += -DDMALLOC -DDMALLOC_FUNC_CHECK -# OPT += -DBCHECK - -# LIBS += -lgc -# LIBS += -ldmalloc -# LIBS += -L/usr/local/lib -lpcre - -PLATFORM = $(shell uname) - -ifeq ($(findstring Linux,$(PLATFORM)), Linux) - LIBS += -ldl -endif - -ifeq ($(findstring SunOS,$(PLATFORM)), SunOS) - LIBS += -lsocket -lnsl -ldl - MAKE = gmake -endif - -ifeq ($(findstring FreeBSD,$(PLATFORM)), FreeBSD) - MAKE = gmake - OS_TYPE = -D__FREEBSD__ -endif - -ifeq ($(findstring NetBSD,$(PLATFORM)), NetBSD) - MAKE = gmake - OS_TYPE = -D__NETBSD__ -endif - -ifeq ($(findstring CYGWIN,$(PLATFORM)), CYGWIN) - OPT += -DFD_SETSIZE=4096 - ifeq ($(findstring mingw,$(shell gcc --version)), mingw) - IS_MINGW = 1 - OS_TYPE = -DMINGW - LIBS += -L../.. -lwsock32 - else - OS_TYPE = -DCYGWIN - endif -endif - -CFLAGS = $(OPT) -I../common $(OS_TYPE) - -ifdef SQLFLAG - ifdef IS_MINGW - CFLAGS += -I../mysql - LIBS += -lmysql - else - MYSQLFLAG_CONFIG = $(shell which mysql_config) - ifeq ($(findstring /,$(MYSQLFLAG_CONFIG)), /) - MYSQLFLAG_VERSION = $(shell $(MYSQLFLAG_CONFIG) --version | sed s:\\..*::) - ifeq ($(findstring 5,$(MYSQLFLAG_VERSION)), 5) - MYSQLFLAG_CONFIG_ARGUMENT = --include - else - MYSQLFLAG_CONFIG_ARGUMENT = --cflags - endif - CFLAGS += $(shell $(MYSQLFLAG_CONFIG) $(MYSQLFLAG_CONFIG_ARGUMENT)) - LIBS += $(shell $(MYSQLFLAG_CONFIG) --libs) - else - CFLAGS += -I/usr/local/include/mysql - LIBS += -L/usr/local/lib/mysql -lmysqlclient - endif - endif -endif - -ifneq ($(findstring -lz,$(LIBS)), -lz) - LIBS += -lz -endif -ifneq ($(findstring -lm,$(LIBS)), -lm) - LIBS += -lm -endif - -MKDEF = CC="$(CC)" CFLAGS="$(CFLAGS)" LIB_S="$(LIBS)" - -endif - -.PHONY: txt sql common login login_sql char char_sql map map_sql ladmin converters \ - addons plugins tools webserver clean zlib depend - -txt : Makefile.cache conf common login char map ladmin - -ifdef SQLFLAG -sql: Makefile.cache conf common login_sql char_sql map_sql -else -sql: - $(MAKE) SQLFLAG=1 $@ -endif - -conf: - cp -r conf-tmpl conf - rm -rf conf/.svn conf/*/.svn - cp -r save-tmpl save - rm -rf save/.svn - -common: src/common/GNUmakefile - $(MAKE) -C src/$@ $(MKDEF) - -login: src/login/GNUmakefile common - $(MAKE) -C src/$@ $(MKDEF) txt - -char: src/char/GNUmakefile common - $(MAKE) -C src/$@ $(MKDEF) txt - -map: src/map/GNUmakefile common - $(MAKE) -C src/$@ $(MKDEF) txt - -login_sql: src/login_sql/GNUmakefile common - $(MAKE) -C src/$@ $(MKDEF) sql - -char_sql: src/char_sql/GNUmakefile common - $(MAKE) -C src/$@ $(MKDEF) sql - -map_sql: src/map/GNUmakefile common - $(MAKE) -C src/map $(MKDEF) sql - -ladmin: src/ladmin/GNUmakefile common - $(MAKE) -C src/$@ $(MKDEF) - -plugins addons: src/plugins/GNUmakefile common - $(MAKE) -C src/plugins $(MKDEF) - -webserver: - $(MAKE) -C src/$@ $(MKDEF) - -tools: - $(MAKE) -C src/tool $(MKDEF) - -ifdef SQLFLAG -converters: src/txt-converter/GNUmakefile common - $(MAKE) -C src/txt-converter $(MKDEF) -else -converters: - $(MAKE) SQLFLAG=1 $@ -endif - -zlib: - $(MAKE) -C src/$@ $(MKDEF) - -clean: src/common/GNUmakefile src/login/GNUmakefile src/login_sql/GNUmakefile \ - src/char/GNUmakefile src/char_sql/GNUmakefile src/map/GNUmakefile \ - src/ladmin/GNUmakefile src/plugins/GNUmakefile src/txt-converter/GNUmakefile - rm -f Makefile.cache - $(MAKE) -C src/common $@ - $(MAKE) -C src/login $@ - $(MAKE) -C src/login_sql $@ - $(MAKE) -C src/char $@ - $(MAKE) -C src/char_sql $@ - $(MAKE) -C src/map $@ - $(MAKE) -C src/ladmin $@ - $(MAKE) -C src/plugins $@ - $(MAKE) -C src/zlib $@ - $(MAKE) -C src/txt-converter $@ - -depend: src/common/GNUmakefile src/login/GNUmakefile src/login_sql/GNUmakefile \ - src/char/GNUmakefile src/char_sql/GNUmakefile src/map/GNUmakefile \ - src/ladmin/GNUmakefile src/plugins/GNUmakefile src/txt-converter/GNUmakefile - cd src/common; makedepend -fGNUmakefile -pobj/ -Y. *.c; cd ../..; - cd src/login; makedepend -DTXT_ONLY -fGNUmakefile -Y. -Y../common *.c; cd ../..; - cd src/login_sql; makedepend -fGNUmakefile -Y. -Y../common *.c; cd ../..; - cd src/char; makedepend -DTXT_ONLY -fGNUmakefile -Y. -Y../common *.c; cd ../..; - cd src/char_sql; makedepend -fGNUmakefile -Y. -Y../common *.c; cd ../..; - cd src/map; makedepend -DTXT_ONLY -fGNUmakefile -ptxtobj/ -Y. -Y../common *.c; cd ../..; - cd src/map; makedepend -fGNUmakefile -a -psqlobj/ -Y. -Y../common *.c; cd ../..; - cd src/ladmin; makedepend -fGNUmakefile -Y. -Y../common *.c; cd ../..; - cd src/txt-converter; makedepend -DTXT_SQL_CONVERT -fGNUmakefile -Y. -Y../common *.c; cd ../..; - $(MAKE) -C src/plugins $@ - -Makefile.cache: - printf "$(subst ",\",$(MKDEF))" > Makefile.cache - -src/%/GNUmakefile: src/%/Makefile - sed -e 's/$$>/$$^/' $< > $@ - -src/common/GNUmakefile: src/common/Makefile -src/login/GNUmakefile: src/login/Makefile -src/login_sql/GNUmakefile: src/login_sql/Makefile -src/char/GNUmakefile: src/char/Makefile -src/char_sql/GNUmakefile: src/char_sql/Makefile -src/map/GNUmakefile: src/map/Makefile -src/plugins/GNUmakefile: src/plugins/Makefile -src/ladmin/GNUmakefile: src/ladmin/Makefile -src/txt-converter/GNUmakefile: src/txt-converter/Makefile - -install: conf/%.conf conf/%.txt - $(shell mkdir -p /opt/eathena/bin/) - $(shell mkdir -p /opt/eathena/etc/eathena/) - $(shell mkdir -p /opt/eathena/var/log/eathena/) - $(shell mv save /opt/eathena/etc/eathena/save) - $(shell mv db /opt/eathena/etc/eathena/db) - $(shell mv conf /opt/eathena/etc/eathena/conf) - $(shell mv npc /opt/eathena/etc/eathena/npc) - $(shell mv log/* /opt/eathena/var/log/eathena/) - $(shell cp *-server* /opt/eathena/bin/) - $(shell cp ladmin /opt/eathena/bin/) - $(shell ln -s /opt/eathena/etc/eathena/save/ /opt/eathena/bin/) - $(shell ln -s /opt/eathena/etc/eathena/db/ /opt/eathena/bin/) - $(shell ln -s /opt/eathena/etc/eathena/conf/ /opt/eathena/bin/) - $(shell ln -s /opt/eathena/etc/eathena/npc/ /opt/eathena/bin/) - $(shell ln -s /opt/eathena/var/log/eathena/ /opt/eathena/bin/log) - -bin-clean: - $(shell rm /opt/eathena/bin/login-server*) - $(shell rm /opt/eathena/bin/char-server*) - $(shell rm /opt/eathena/bin/map-server*) - $(shell rm /opt/eathena/bin/ladmin) - -uninstall: - bin-clean - $(shell rm /opt/eathena/bin/save) - $(shell rm /opt/eathena/bin/db) - $(shell rm /opt/eathena/bin/conf) - $(shell rm /opt/eathena/bin/npc) - $(shell rm /opt/eathena/bin/log) - $(shell rm -rf /opt/eathena/etc/eathena) - $(shell rm -rf /opt/eathena/var/log/eathena) + +CACHED = $(shell ls | grep Makefile.cache) +ifeq ($(findstring Makefile.cache,$(CACHED)), Makefile.cache) +MKDEF = $(shell cat Makefile.cache) +else + +CC = gcc -pipe +# CC = g++ --pipe + +MAKE = make +# MAKE = gmake + +OPT = -g +OPT += -O2 +# OPT += -O3 +# OPT += -mmmx +# OPT += -msse +# OPT += -msse2 +# OPT += -msse3 +# OPT += -rdynamic +OPT += -ffast-math +# OPT += -fbounds-checking +# OPT += -fstack-protector +# OPT += -fomit-frame-pointer +OPT += -Wall -Wno-sign-compare +# Uncomment this one if you are using GCC 4.X +# OPT += -Wno-unused-parameter -Wno-pointer-sign +# Makes map-wide script variables be saved to SQL instead of TXT files. +# OPT += -DMAPREGSQL +# Turbo is an alternate socket access implementation which should be faster. +# DO NOT ENABLE YET as it isn't quite ready for general usage. +# OPT += -DTURBO +# Enable the perl regular expression support for scripts +# OPT += -DPCRE_SUPPORT +# OPT += -DGCOLLECT +# OPT += -DMEMWATCH +# OPT += -DDMALLOC -DDMALLOC_FUNC_CHECK +# OPT += -DBCHECK + +# LIBS += -lgc +# LIBS += -ldmalloc +# LIBS += -L/usr/local/lib -lpcre + +PLATFORM = $(shell uname) + +ifeq ($(findstring Linux,$(PLATFORM)), Linux) + LIBS += -ldl +endif + +ifeq ($(findstring SunOS,$(PLATFORM)), SunOS) + LIBS += -lsocket -lnsl -ldl + MAKE = gmake +endif + +ifeq ($(findstring FreeBSD,$(PLATFORM)), FreeBSD) + MAKE = gmake + OS_TYPE = -D__FREEBSD__ +endif + +ifeq ($(findstring NetBSD,$(PLATFORM)), NetBSD) + MAKE = gmake + OS_TYPE = -D__NETBSD__ +endif + +ifeq ($(findstring CYGWIN,$(PLATFORM)), CYGWIN) + OPT += -DFD_SETSIZE=4096 + ifeq ($(findstring mingw,$(shell gcc --version)), mingw) + IS_MINGW = 1 + OS_TYPE = -DMINGW + LIBS += -L../.. -lwsock32 + else + OS_TYPE = -DCYGWIN + endif +endif + +CFLAGS = $(OPT) -I../common $(OS_TYPE) + +ifdef SQLFLAG + ifdef IS_MINGW + CFLAGS += -I../mysql + LIBS += -lmysql + else + MYSQLFLAG_CONFIG = $(shell which mysql_config) + ifeq ($(findstring /,$(MYSQLFLAG_CONFIG)), /) + MYSQLFLAG_VERSION = $(shell $(MYSQLFLAG_CONFIG) --version | sed s:\\..*::) + ifeq ($(findstring 5,$(MYSQLFLAG_VERSION)), 5) + MYSQLFLAG_CONFIG_ARGUMENT = --include + else + MYSQLFLAG_CONFIG_ARGUMENT = --cflags + endif + CFLAGS += $(shell $(MYSQLFLAG_CONFIG) $(MYSQLFLAG_CONFIG_ARGUMENT)) + LIBS += $(shell $(MYSQLFLAG_CONFIG) --libs) + else + CFLAGS += -I/usr/local/include/mysql + LIBS += -L/usr/local/lib/mysql -lmysqlclient + endif + endif +endif + +ifneq ($(findstring -lz,$(LIBS)), -lz) + LIBS += -lz +endif +ifneq ($(findstring -lm,$(LIBS)), -lm) + LIBS += -lm +endif + +MKDEF = CC="$(CC)" CFLAGS="$(CFLAGS)" LIB_S="$(LIBS)" + +endif + +.PHONY: txt sql common login login_sql char char_sql map map_sql ladmin converters \ + addons plugins tools webserver clean zlib depend + +txt : Makefile.cache conf common login char map ladmin + +ifdef SQLFLAG +sql: Makefile.cache conf common login_sql char_sql map_sql +else +sql: + $(MAKE) SQLFLAG=1 $@ +endif + +conf: + cp -r conf-tmpl conf + rm -rf conf/.svn conf/*/.svn + cp -r save-tmpl save + rm -rf save/.svn + +common: src/common/GNUmakefile + $(MAKE) -C src/$@ $(MKDEF) + +login: src/login/GNUmakefile common + $(MAKE) -C src/$@ $(MKDEF) txt + +char: src/char/GNUmakefile common + $(MAKE) -C src/$@ $(MKDEF) txt + +map: src/map/GNUmakefile common + $(MAKE) -C src/$@ $(MKDEF) txt + +login_sql: src/login_sql/GNUmakefile common + $(MAKE) -C src/$@ $(MKDEF) sql + +char_sql: src/char_sql/GNUmakefile common + $(MAKE) -C src/$@ $(MKDEF) sql + +map_sql: src/map/GNUmakefile common + $(MAKE) -C src/map $(MKDEF) sql + +ladmin: src/ladmin/GNUmakefile common + $(MAKE) -C src/$@ $(MKDEF) + +plugins addons: src/plugins/GNUmakefile common + $(MAKE) -C src/plugins $(MKDEF) + +webserver: + $(MAKE) -C src/$@ $(MKDEF) + +tools: + $(MAKE) -C src/tool $(MKDEF) + +ifdef SQLFLAG +converters: src/txt-converter/GNUmakefile common + $(MAKE) -C src/txt-converter $(MKDEF) +else +converters: + $(MAKE) SQLFLAG=1 $@ +endif + +zlib: + $(MAKE) -C src/$@ $(MKDEF) + +clean: src/common/GNUmakefile src/login/GNUmakefile src/login_sql/GNUmakefile \ + src/char/GNUmakefile src/char_sql/GNUmakefile src/map/GNUmakefile \ + src/ladmin/GNUmakefile src/plugins/GNUmakefile src/txt-converter/GNUmakefile + rm -f Makefile.cache + $(MAKE) -C src/common $@ + $(MAKE) -C src/login $@ + $(MAKE) -C src/login_sql $@ + $(MAKE) -C src/char $@ + $(MAKE) -C src/char_sql $@ + $(MAKE) -C src/map $@ + $(MAKE) -C src/ladmin $@ + $(MAKE) -C src/plugins $@ + $(MAKE) -C src/zlib $@ + $(MAKE) -C src/txt-converter $@ + +depend: src/common/GNUmakefile src/login/GNUmakefile src/login_sql/GNUmakefile \ + src/char/GNUmakefile src/char_sql/GNUmakefile src/map/GNUmakefile \ + src/ladmin/GNUmakefile src/plugins/GNUmakefile src/txt-converter/GNUmakefile + cd src/common; makedepend -fGNUmakefile -pobj/ -Y. *.c; cd ../..; + cd src/login; makedepend -DTXT_ONLY -fGNUmakefile -Y. -Y../common *.c; cd ../..; + cd src/login_sql; makedepend -fGNUmakefile -Y. -Y../common *.c; cd ../..; + cd src/char; makedepend -DTXT_ONLY -fGNUmakefile -Y. -Y../common *.c; cd ../..; + cd src/char_sql; makedepend -fGNUmakefile -Y. -Y../common *.c; cd ../..; + cd src/map; makedepend -DTXT_ONLY -fGNUmakefile -ptxtobj/ -Y. -Y../common *.c; cd ../..; + cd src/map; makedepend -fGNUmakefile -a -psqlobj/ -Y. -Y../common *.c; cd ../..; + cd src/ladmin; makedepend -fGNUmakefile -Y. -Y../common *.c; cd ../..; + cd src/txt-converter; makedepend -DTXT_SQL_CONVERT -fGNUmakefile -Y. -Y../common *.c; cd ../..; + $(MAKE) -C src/plugins $@ + +Makefile.cache: + printf "$(subst ",\",$(MKDEF))" > Makefile.cache + +src/%/GNUmakefile: src/%/Makefile + sed -e 's/$$>/$$^/' $< > $@ + +src/common/GNUmakefile: src/common/Makefile +src/login/GNUmakefile: src/login/Makefile +src/login_sql/GNUmakefile: src/login_sql/Makefile +src/char/GNUmakefile: src/char/Makefile +src/char_sql/GNUmakefile: src/char_sql/Makefile +src/map/GNUmakefile: src/map/Makefile +src/plugins/GNUmakefile: src/plugins/Makefile +src/ladmin/GNUmakefile: src/ladmin/Makefile +src/txt-converter/GNUmakefile: src/txt-converter/Makefile + +install: conf/%.conf conf/%.txt + $(shell mkdir -p /opt/eathena/bin/) + $(shell mkdir -p /opt/eathena/etc/eathena/) + $(shell mkdir -p /opt/eathena/var/log/eathena/) + $(shell mv save /opt/eathena/etc/eathena/save) + $(shell mv db /opt/eathena/etc/eathena/db) + $(shell mv conf /opt/eathena/etc/eathena/conf) + $(shell mv npc /opt/eathena/etc/eathena/npc) + $(shell mv log/* /opt/eathena/var/log/eathena/) + $(shell cp *-server* /opt/eathena/bin/) + $(shell cp ladmin /opt/eathena/bin/) + $(shell ln -s /opt/eathena/etc/eathena/save/ /opt/eathena/bin/) + $(shell ln -s /opt/eathena/etc/eathena/db/ /opt/eathena/bin/) + $(shell ln -s /opt/eathena/etc/eathena/conf/ /opt/eathena/bin/) + $(shell ln -s /opt/eathena/etc/eathena/npc/ /opt/eathena/bin/) + $(shell ln -s /opt/eathena/var/log/eathena/ /opt/eathena/bin/log) + +bin-clean: + $(shell rm /opt/eathena/bin/login-server*) + $(shell rm /opt/eathena/bin/char-server*) + $(shell rm /opt/eathena/bin/map-server*) + $(shell rm /opt/eathena/bin/ladmin) + +uninstall: + bin-clean + $(shell rm /opt/eathena/bin/save) + $(shell rm /opt/eathena/bin/db) + $(shell rm /opt/eathena/bin/conf) + $(shell rm /opt/eathena/bin/npc) + $(shell rm /opt/eathena/bin/log) + $(shell rm -rf /opt/eathena/etc/eathena) + $(shell rm -rf /opt/eathena/var/log/eathena) diff --git a/eAthena-7.1.sln b/eAthena-7.1.sln index fa7d3b325..afd72f03f 100644 --- a/eAthena-7.1.sln +++ b/eAthena-7.1.sln @@ -1,61 +1,61 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_txt", "vcproj-7.1\char-server_txt.vcproj", "{D356871D-58E1-450B-967A-E3E9646175AF}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_sql", "vcproj-7.1\char-server_sql.vcproj", "{D356871D-58E1-450B-967A-E4E9646175AF}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_sql", "vcproj-7.1\login-server_sql.vcproj", "{D356871D-58E1-450B-967A-E5E9646175AF}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_sql", "vcproj-7.1\map-server_sql.vcproj", "{D356871D-58E1-450B-967A-E6E9646175AF}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_txt", "vcproj-7.1\login-server_txt.vcproj", "{D356871D-58E1-450B-967A-E2E9646175AF}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_txt", "vcproj-7.1\map-server_txt.vcproj", "{D356871D-58E1-450B-967A-E1E9646175AF}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Debug.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Debug.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Release.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Release.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Debug.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Debug.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Release.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Release.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Debug.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Debug.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Release.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Release.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_txt", "vcproj-7.1\char-server_txt.vcproj", "{D356871D-58E1-450B-967A-E3E9646175AF}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_sql", "vcproj-7.1\char-server_sql.vcproj", "{D356871D-58E1-450B-967A-E4E9646175AF}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_sql", "vcproj-7.1\login-server_sql.vcproj", "{D356871D-58E1-450B-967A-E5E9646175AF}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_sql", "vcproj-7.1\map-server_sql.vcproj", "{D356871D-58E1-450B-967A-E6E9646175AF}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_txt", "vcproj-7.1\login-server_txt.vcproj", "{D356871D-58E1-450B-967A-E2E9646175AF}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_txt", "vcproj-7.1\map-server_txt.vcproj", "{D356871D-58E1-450B-967A-E1E9646175AF}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {D356871D-58E1-450B-967A-E3E9646175AF}.Debug.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E3E9646175AF}.Debug.Build.0 = Debug|Win32 + {D356871D-58E1-450B-967A-E3E9646175AF}.Release.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-E3E9646175AF}.Release.Build.0 = Release|Win32 + {D356871D-58E1-450B-967A-E4E9646175AF}.Debug.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E4E9646175AF}.Debug.Build.0 = Debug|Win32 + {D356871D-58E1-450B-967A-E4E9646175AF}.Release.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-E4E9646175AF}.Release.Build.0 = Release|Win32 + {D356871D-58E1-450B-967A-E5E9646175AF}.Debug.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E5E9646175AF}.Debug.Build.0 = Debug|Win32 + {D356871D-58E1-450B-967A-E5E9646175AF}.Release.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-E5E9646175AF}.Release.Build.0 = Release|Win32 + {D356871D-58E1-450B-967A-E6E9646175AF}.Debug.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E6E9646175AF}.Debug.Build.0 = Debug|Win32 + {D356871D-58E1-450B-967A-E6E9646175AF}.Release.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-E6E9646175AF}.Release.Build.0 = Release|Win32 + {D356871D-58E1-450B-967A-E2E9646175AF}.Debug.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E2E9646175AF}.Debug.Build.0 = Debug|Win32 + {D356871D-58E1-450B-967A-E2E9646175AF}.Release.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-E2E9646175AF}.Release.Build.0 = Release|Win32 + {D356871D-58E1-450B-967A-E1E9646175AF}.Debug.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E1E9646175AF}.Debug.Build.0 = Debug|Win32 + {D356871D-58E1-450B-967A-E1E9646175AF}.Release.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-E1E9646175AF}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/eAthena-8.sln b/eAthena-8.sln index 7a0834d4d..f1799933e 100644 --- a/eAthena-8.sln +++ b/eAthena-8.sln @@ -1,46 +1,46 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_txt", "vcproj-8\map-server_txt.vcproj", "{D356871D-58E1-450B-967A-E1E9646175AF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_txt", "vcproj-8\login-server_txt.vcproj", "{D356871D-58E1-450B-967A-E2E9646175AF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_txt", "vcproj-8\char-server_txt.vcproj", "{D356871D-58E1-450B-967A-E3E9646175AF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_sql", "vcproj-8\char-server_sql.vcproj", "{D356871D-58E1-450B-967A-E4E9646175AF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_sql", "vcproj-8\login-server_sql.vcproj", "{D356871D-58E1-450B-967A-E5E9646175AF}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_sql", "vcproj-8\map-server_sql.vcproj", "{D356871D-58E1-450B-967A-E6E9646175AF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E1E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E2E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E3E9646175AF}.Release|Win32.Build.0 = Release|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E4E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E5E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 - {D356871D-58E1-450B-967A-E6E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_txt", "vcproj-8\map-server_txt.vcproj", "{D356871D-58E1-450B-967A-E1E9646175AF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_txt", "vcproj-8\login-server_txt.vcproj", "{D356871D-58E1-450B-967A-E2E9646175AF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_txt", "vcproj-8\char-server_txt.vcproj", "{D356871D-58E1-450B-967A-E3E9646175AF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_sql", "vcproj-8\char-server_sql.vcproj", "{D356871D-58E1-450B-967A-E4E9646175AF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_sql", "vcproj-8\login-server_sql.vcproj", "{D356871D-58E1-450B-967A-E5E9646175AF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_sql", "vcproj-8\map-server_sql.vcproj", "{D356871D-58E1-450B-967A-E6E9646175AF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D356871D-58E1-450B-967A-E1E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E1E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 + {D356871D-58E1-450B-967A-E1E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-E1E9646175AF}.Release|Win32.Build.0 = Release|Win32 + {D356871D-58E1-450B-967A-E2E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E2E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 + {D356871D-58E1-450B-967A-E2E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-E2E9646175AF}.Release|Win32.Build.0 = Release|Win32 + {D356871D-58E1-450B-967A-E3E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E3E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 + {D356871D-58E1-450B-967A-E3E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-E3E9646175AF}.Release|Win32.Build.0 = Release|Win32 + {D356871D-58E1-450B-967A-E4E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E4E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 + {D356871D-58E1-450B-967A-E4E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-E5E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E5E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 + {D356871D-58E1-450B-967A-E5E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 + {D356871D-58E1-450B-967A-E6E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32 + {D356871D-58E1-450B-967A-E6E9646175AF}.Debug|Win32.Build.0 = Debug|Win32 + {D356871D-58E1-450B-967A-E6E9646175AF}.Release|Win32.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/char/Makefile b/src/char/Makefile index 13dd1675b..6282926f6 100644 --- a/src/char/Makefile +++ b/src/char/Makefile @@ -1,31 +1,31 @@ -all txt: char-server - -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ - ../common/obj/strlib.o ../common/obj/graph.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o ../zlib/unz.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ - ../common/graph.h ../common/grfio.h ../common/mapindex.h - -%.o: %.c - $(COMPILE.c) -DTXT_ONLY $(OUTPUT_OPTION) $< - -char-server: char.o inter.o int_party.o int_guild.o int_status.o int_storage.o int_pet.o int_homun.o $(COMMON_OBJ) - $(CC) -o ../../$@ $> $(LIB_S) - -clean: - rm -f *.o ../../char-server - -# DO NOT DELETE - -char.o: char.c char.h inter.h int_pet.h $(COMMON_H) ../common/version.h -inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h char.h $(COMMON_H) -int_party.o: int_party.c int_party.h inter.h char.h $(COMMON_H) -int_guild.o: int_guild.c int_guild.h int_storage.h inter.h char.h $(COMMON_H) -int_storage.o: int_storage.c int_storage.h int_guild.h inter.h char.h $(COMMON_H) -int_status.o: int_status.c int_status.h char.h $(COMMON_H) -int_pet.o: int_pet.c int_pet.h inter.h char.h $(COMMON_H) -int_homun.o: int_homun.c int_homun.h inter.h char.h $(COMMON_H) +all txt: char-server + +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ + ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ + ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ + ../common/obj/strlib.o ../common/obj/graph.o ../common/obj/grfio.o \ + ../common/obj/mapindex.o ../common/obj/ers.o ../zlib/unz.o +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ + ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ + ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ + ../common/graph.h ../common/grfio.h ../common/mapindex.h + +%.o: %.c + $(COMPILE.c) -DTXT_ONLY $(OUTPUT_OPTION) $< + +char-server: char.o inter.o int_party.o int_guild.o int_status.o int_storage.o int_pet.o int_homun.o $(COMMON_OBJ) + $(CC) -o ../../$@ $> $(LIB_S) + +clean: + rm -f *.o ../../char-server + +# DO NOT DELETE + +char.o: char.c char.h inter.h int_pet.h $(COMMON_H) ../common/version.h +inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h char.h $(COMMON_H) +int_party.o: int_party.c int_party.h inter.h char.h $(COMMON_H) +int_guild.o: int_guild.c int_guild.h int_storage.h inter.h char.h $(COMMON_H) +int_storage.o: int_storage.c int_storage.h int_guild.h inter.h char.h $(COMMON_H) +int_status.o: int_status.c int_status.h char.h $(COMMON_H) +int_pet.o: int_pet.c int_pet.h inter.h char.h $(COMMON_H) +int_homun.o: int_homun.c int_homun.h inter.h char.h $(COMMON_H) diff --git a/src/char_sql/Makefile b/src/char_sql/Makefile index 544ba82c0..651cec002 100644 --- a/src/char_sql/Makefile +++ b/src/char_sql/Makefile @@ -1,28 +1,28 @@ -all sql: char-server_sql - -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ - ../common/obj/strlib.o ../common/obj/graph.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o ../zlib/unz.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ - ../common/graph.h ../common/grfio.h ../common/mapindex.h - -char-server_sql: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o int_homun.o itemdb.o $(COMMON_OBJ) - $(CC) -o ../../$@ $^ $(LIB_S) - -clean: - rm -f *.o ../../char-server_sql - -# DO NOT DELETE - -char.o: char.c char.h ../common/strlib.h itemdb.h ../common/showmsg.h -inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h ../common/mmo.h char.h ../common/socket.h ../common/showmsg.h -int_party.o: int_party.c int_party.h inter.h ../common/mmo.h char.h ../common/socket.h ../common/timer.h ../common/db.h ../common/showmsg.h -int_guild.o: int_guild.c int_guild.h inter.h ../common/mmo.h char.h ../common/socket.h ../common/db.h ../common/showmsg.h -int_storage.o: int_storage.c int_storage.h char.h itemdb.h ../common/showmsg.h -int_pet.o: int_pet.c int_pet.h inter.h char.h ../common/mmo.h ../common/socket.h ../common/db.h ../common/showmsg.h -int_homun.o: int_homun.c int_homun.h inter.h char.h ../common/mmo.h ../common/socket.h ../common/db.h ../common/showmsg.h +all sql: char-server_sql + +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ + ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ + ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ + ../common/obj/strlib.o ../common/obj/graph.o ../common/obj/grfio.o \ + ../common/obj/mapindex.o ../common/obj/ers.o ../zlib/unz.o +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ + ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ + ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ + ../common/graph.h ../common/grfio.h ../common/mapindex.h + +char-server_sql: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o int_homun.o itemdb.o $(COMMON_OBJ) + $(CC) -o ../../$@ $^ $(LIB_S) + +clean: + rm -f *.o ../../char-server_sql + +# DO NOT DELETE + +char.o: char.c char.h ../common/strlib.h itemdb.h ../common/showmsg.h +inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h ../common/mmo.h char.h ../common/socket.h ../common/showmsg.h +int_party.o: int_party.c int_party.h inter.h ../common/mmo.h char.h ../common/socket.h ../common/timer.h ../common/db.h ../common/showmsg.h +int_guild.o: int_guild.c int_guild.h inter.h ../common/mmo.h char.h ../common/socket.h ../common/db.h ../common/showmsg.h +int_storage.o: int_storage.c int_storage.h char.h itemdb.h ../common/showmsg.h +int_pet.o: int_pet.c int_pet.h inter.h char.h ../common/mmo.h ../common/socket.h ../common/db.h ../common/showmsg.h +int_homun.o: int_homun.c int_homun.h inter.h char.h ../common/mmo.h ../common/socket.h ../common/db.h ../common/showmsg.h itemdb.o: itemdb.c itemdb.h ../common/db.h ../common/mmo.h ../common/showmsg.h \ No newline at end of file diff --git a/src/common/Makefile b/src/common/Makefile index e601baae4..7c8f8065d 100644 --- a/src/common/Makefile +++ b/src/common/Makefile @@ -1,60 +1,61 @@ -txt sql all: obj common - -obj: - mkdir obj - -common: obj/core.o obj/socket.o obj/timer.o obj/db.o obj/plugins.o obj/lock.o \ - obj/nullpo.o obj/malloc.o obj/showmsg.o obj/strlib.o obj/utils.o \ - obj/graph.o obj/grfio.o obj/minicore.o obj/minisocket.o obj/minimalloc.o \ - obj/mapindex.o obj/unz.o obj/ers.o - - -obj/%.o: %.c - $(COMPILE.c) $(OUTPUT_OPTION) $< - -obj/mini%.o: %.c - $(COMPILE.c) -DMINICORE $(OUTPUT_OPTION) $< - -obj/unz.o: - $(MAKE) -C ../zlib - @touch $@ - - -clean: - rm -rf *.o obj - -HAVESVN = $(shell which svnversion) - -ifeq ($(findstring /,$(HAVESVN)), /) -svnversion.h: - @printf "#define SVNVERSION " > svnversion.h - @svnversion . >> svnversion.h - @printf "\n" >> svnversion.h -else -svnversion.h: - @printf "\n" > svnversion.h -endif - -obj/minicore.o: core.c core.h -obj/minisocket.o: socket.c socket.h -obj/minimalloc.o: malloc.c malloc.h - -# DO NOT DELETE - -obj/core.o: core.c core.h showmsg.h svnversion.h -obj/socket.o: socket.c socket.h mmo.h showmsg.h plugins.h -obj/timer.o: timer.c timer.h showmsg.h -obj/ers.o: ers.c ers.h cbasetypes.h -obj/db.o: db.c db.h showmsg.h ers.h -obj/lock.o: lock.c lock.h showmsg.h -obj/grfio.o: grfio.c grfio.h -obj/graph.o: graph.c graph.h -obj/nullpo.o: nullpo.c nullpo.h showmsg.h -obj/malloc.o: malloc.c malloc.h showmsg.h -obj/plugins.o: plugins.c plugins.h plugin.h -obj/showmsg.o: showmsg.c showmsg.h -obj/strlib.o: strlib.c strlib.h utils.h -obj/mapindex.o: mapindex.c mapindex.h -obj/utils.o: utils.c utils.h malloc.h showmsg.h mmo.h -mmo.h: cbasetypes.h - @touch mmo.h +txt sql all: obj common + +obj: + mkdir obj + +common: obj/core.o obj/socket.o obj/timer.o obj/db.o obj/plugins.o obj/lock.o \ + obj/nullpo.o obj/malloc.o obj/showmsg.o obj/strlib.o obj/utils.o \ + obj/graph.o obj/grfio.o obj/minicore.o obj/minisocket.o obj/minimalloc.o \ + obj/mapindex.o obj/unz.o obj/ers.o obj/md5calc.o + + +obj/%.o: %.c + $(COMPILE.c) $(OUTPUT_OPTION) $< + +obj/mini%.o: %.c + $(COMPILE.c) -DMINICORE $(OUTPUT_OPTION) $< + +obj/unz.o: + $(MAKE) -C ../zlib + @touch $@ + + +clean: + rm -rf *.o obj GNUmakefile + +HAVESVN = $(shell which svnversion) + +ifeq ($(findstring /,$(HAVESVN)), /) +svnversion.h: + @printf "#define SVNVERSION " > svnversion.h + @svnversion . >> svnversion.h + @printf "\n" >> svnversion.h +else +svnversion.h: + @printf "\n" > svnversion.h +endif + +obj/minicore.o: core.c core.h +obj/minisocket.o: socket.c socket.h +obj/minimalloc.o: malloc.c malloc.h + +# DO NOT DELETE + +obj/core.o: core.c core.h showmsg.h svnversion.h +obj/socket.o: socket.c socket.h mmo.h showmsg.h plugins.h +obj/timer.o: timer.c timer.h showmsg.h +obj/ers.o: ers.c ers.h cbasetypes.h +obj/db.o: db.c db.h showmsg.h ers.h +obj/lock.o: lock.c lock.h showmsg.h +obj/grfio.o: grfio.c grfio.h +obj/graph.o: graph.c graph.h +obj/nullpo.o: nullpo.c nullpo.h showmsg.h +obj/malloc.o: malloc.c malloc.h showmsg.h +obj/plugins.o: plugins.c plugins.h plugin.h +obj/showmsg.o: showmsg.c showmsg.h +obj/strlib.o: strlib.c strlib.h utils.h +obj/mapindex.o: mapindex.c mapindex.h +obj/utils.o: utils.c utils.h malloc.h showmsg.h mmo.h +obj/md5calc.o: md5calc.c md5calc.h +mmo.h: cbasetypes.h + @touch mmo.h diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 3b5c69fbe..c61424191 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -291,5 +291,6 @@ typedef char bool; #define TOLOWER(c) ((char)tolower((unsigned char)(c))) #define ISSPACE(c) (isspace((unsigned char)(c))) #define ISALPHA(c) (isalpha((unsigned char)(c))) +#define ISALNUM(c) (isalnum((unsigned char)(c))) #endif /* _CBASETYPES_H_ */ diff --git a/src/common/md5calc.c b/src/common/md5calc.c new file mode 100644 index 000000000..fd8ffd5d3 --- /dev/null +++ b/src/common/md5calc.c @@ -0,0 +1,236 @@ +/*********************************************************** + * md5 calculation algorithm + * + * The source code referred to the following URL. + * http://www.geocities.co.jp/SiliconValley-Oakland/8878/lab17/lab17.html + * + ***********************************************************/ + +#include "md5calc.h" +#include +#include + +#ifndef UINT_MAX +#define UINT_MAX 4294967295U +#endif + +// Global variable +static unsigned int *pX; + +// String Table +static const unsigned int T[] = { + 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, //0 + 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, //4 + 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, //8 + 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, //12 + 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, //16 + 0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8, //20 + 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, //24 + 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, //28 + 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, //32 + 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, //36 + 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05, //40 + 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, //44 + 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, //48 + 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, //52 + 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, //56 + 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 //60 +}; + +// ROTATE_LEFT The left is made to rotate x [ n-bit ]. This is diverted as it is from RFC. +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) + +// The function used for other calculation +static unsigned int F(unsigned int X, unsigned int Y, unsigned int Z) +{ + return (X & Y) | (~X & Z); +} +static unsigned int G(unsigned int X, unsigned int Y, unsigned int Z) +{ + return (X & Z) | (Y & ~Z); +} +static unsigned int H(unsigned int X, unsigned int Y, unsigned int Z) +{ + return X ^ Y ^ Z; +} +static unsigned int I(unsigned int X, unsigned int Y, unsigned int Z) +{ + return Y ^ (X | ~Z); +} + +static unsigned int Round(unsigned int a, unsigned int b, unsigned int FGHI, + unsigned int k, unsigned int s, unsigned int i) +{ + return b + ROTATE_LEFT(a + FGHI + pX[k] + T[i], s); +} + +static void Round1(unsigned int *a, unsigned int b, unsigned int c, + unsigned int d,unsigned int k, unsigned int s, unsigned int i) +{ + *a = Round(*a, b, F(b,c,d), k, s, i); +} +static void Round2(unsigned int *a, unsigned int b, unsigned int c, + unsigned int d,unsigned int k, unsigned int s, unsigned int i) +{ + *a = Round(*a, b, G(b,c,d), k, s, i); +} +static void Round3(unsigned int *a, unsigned int b, unsigned int c, + unsigned int d,unsigned int k, unsigned int s, unsigned int i) +{ + *a = Round(*a, b, H(b,c,d), k, s, i); +} +static void Round4(unsigned int *a, unsigned int b, unsigned int c, + unsigned int d,unsigned int k, unsigned int s, unsigned int i) +{ + *a = Round(*a, b, I(b,c,d), k, s, i); +} + +static void MD5_Round_Calculate(const unsigned char *block, + unsigned int *A2, unsigned int *B2, unsigned int *C2, unsigned int *D2) +{ + //create X It is since it is required. + unsigned int X[16]; //512bit 64byte + int j,k; + + //Save A as AA, B as BB, C as CC, and and D as DD (saving of A, B, C, and D) + unsigned int A=*A2, B=*B2, C=*C2, D=*D2; + unsigned int AA = A,BB = B,CC = C,DD = D; + + //It is a large region variable reluctantly because of calculation of a round. . . for Round1...4 + pX = X; + + //Copy block(padding_message) i into X + for (j=0,k=0; j<64; j+=4,k++) + X[k] = ( (unsigned int )block[j] ) // 8byte*4 -> 32byte conversion + | ( ((unsigned int )block[j+1]) << 8 ) // A function called Decode as used in the field of RFC + | ( ((unsigned int )block[j+2]) << 16 ) + | ( ((unsigned int )block[j+3]) << 24 ); + + + //Round 1 + Round1(&A,B,C,D, 0, 7, 0); Round1(&D,A,B,C, 1, 12, 1); Round1(&C,D,A,B, 2, 17, 2); Round1(&B,C,D,A, 3, 22, 3); + Round1(&A,B,C,D, 4, 7, 4); Round1(&D,A,B,C, 5, 12, 5); Round1(&C,D,A,B, 6, 17, 6); Round1(&B,C,D,A, 7, 22, 7); + Round1(&A,B,C,D, 8, 7, 8); Round1(&D,A,B,C, 9, 12, 9); Round1(&C,D,A,B, 10, 17, 10); Round1(&B,C,D,A, 11, 22, 11); + Round1(&A,B,C,D, 12, 7, 12); Round1(&D,A,B,C, 13, 12, 13); Round1(&C,D,A,B, 14, 17, 14); Round1(&B,C,D,A, 15, 22, 15); + + //Round 2 + Round2(&A,B,C,D, 1, 5, 16); Round2(&D,A,B,C, 6, 9, 17); Round2(&C,D,A,B, 11, 14, 18); Round2(&B,C,D,A, 0, 20, 19); + Round2(&A,B,C,D, 5, 5, 20); Round2(&D,A,B,C, 10, 9, 21); Round2(&C,D,A,B, 15, 14, 22); Round2(&B,C,D,A, 4, 20, 23); + Round2(&A,B,C,D, 9, 5, 24); Round2(&D,A,B,C, 14, 9, 25); Round2(&C,D,A,B, 3, 14, 26); Round2(&B,C,D,A, 8, 20, 27); + Round2(&A,B,C,D, 13, 5, 28); Round2(&D,A,B,C, 2, 9, 29); Round2(&C,D,A,B, 7, 14, 30); Round2(&B,C,D,A, 12, 20, 31); + + //Round 3 + Round3(&A,B,C,D, 5, 4, 32); Round3(&D,A,B,C, 8, 11, 33); Round3(&C,D,A,B, 11, 16, 34); Round3(&B,C,D,A, 14, 23, 35); + Round3(&A,B,C,D, 1, 4, 36); Round3(&D,A,B,C, 4, 11, 37); Round3(&C,D,A,B, 7, 16, 38); Round3(&B,C,D,A, 10, 23, 39); + Round3(&A,B,C,D, 13, 4, 40); Round3(&D,A,B,C, 0, 11, 41); Round3(&C,D,A,B, 3, 16, 42); Round3(&B,C,D,A, 6, 23, 43); + Round3(&A,B,C,D, 9, 4, 44); Round3(&D,A,B,C, 12, 11, 45); Round3(&C,D,A,B, 15, 16, 46); Round3(&B,C,D,A, 2, 23, 47); + + //Round 4 + Round4(&A,B,C,D, 0, 6, 48); Round4(&D,A,B,C, 7, 10, 49); Round4(&C,D,A,B, 14, 15, 50); Round4(&B,C,D,A, 5, 21, 51); + Round4(&A,B,C,D, 12, 6, 52); Round4(&D,A,B,C, 3, 10, 53); Round4(&C,D,A,B, 10, 15, 54); Round4(&B,C,D,A, 1, 21, 55); + Round4(&A,B,C,D, 8, 6, 56); Round4(&D,A,B,C, 15, 10, 57); Round4(&C,D,A,B, 6, 15, 58); Round4(&B,C,D,A, 13, 21, 59); + Round4(&A,B,C,D, 4, 6, 60); Round4(&D,A,B,C, 11, 10, 61); Round4(&C,D,A,B, 2, 15, 62); Round4(&B,C,D,A, 9, 21, 63); + + // Then perform the following additions. (let's add) + *A2 = A + AA; + *B2 = B + BB; + *C2 = C + CC; + *D2 = D + DD; + + //The clearance of confidential information + memset(pX, 0, sizeof(X)); +} + +//------------------------------------------------------------------- +// The function for the exteriors + +/** output is the coded binary in the character sequence which wants to code string. */ +void MD5_String2binary(const char * string, char * output) +{ +//var + /*8bit*/ + unsigned char padding_message[64]; //Extended message 512bit 64byte + unsigned char *pstring; //The position of string in the present scanning notes is held. + +// unsigned char digest[16]; + /*32bit*/ + unsigned int string_byte_len, //The byte chief of string is held. + string_bit_len, //The bit length of string is held. + copy_len, //The number of bytes which is used by 1-3 and which remained + msg_digest[4]; //Message digest 128bit 4byte + unsigned int *A = &msg_digest[0], //The message digest in accordance with RFC (reference) + *B = &msg_digest[1], + *C = &msg_digest[2], + *D = &msg_digest[3]; + int i; + +//prog + //Step 3.Initialize MD Buffer (although it is the initialization; step 3 of A, B, C, and D -- unavoidable -- a head) + *A = 0x67452301; + *B = 0xefcdab89; + *C = 0x98badcfe; + *D = 0x10325476; + + //Step 1.Append Padding Bits (extension of a mark bit) + //1-1 + string_byte_len = strlen(string); //The byte chief of a character sequence is acquired. + pstring = (unsigned char *)string; //The position of the present character sequence is set. + + //1-2 Repeat calculation until length becomes less than 64 bytes. + for (i=string_byte_len; 64<=i; i-=64,pstring+=64) + MD5_Round_Calculate(pstring, A,B,C,D); + + //1-3 + copy_len = string_byte_len % 64; //The number of bytes which remained is computed. + strncpy((char *)padding_message, (char *)pstring, copy_len); //A message is copied to an extended bit sequence. + memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length. + padding_message[copy_len] |= 0x80; //The next of a message is 1. + + //1-4 + //If 56 bytes or more (less than 64 bytes) of remainder becomes, it will calculate by extending to 64 bytes. + if (56 <= copy_len) { + MD5_Round_Calculate(padding_message, A,B,C,D); + memset(padding_message, 0, 56); //56 bytes is newly fill uped with 0. + } + + + //Step 2.Append Length (the information on length is added) + string_bit_len = string_byte_len * 8; //From the byte chief to bit length (32 bytes of low rank) + memcpy(&padding_message[56], &string_bit_len, 4); //32 bytes of low rank is set. + + //When bit length cannot be expressed in 32 bytes of low rank, it is a beam raising to a higher rank. + if (UINT_MAX / 8 < string_byte_len) { + unsigned int high = (string_byte_len - UINT_MAX / 8) * 8; + memcpy(&padding_message[60], &high, 4); + } else + memset(&padding_message[60], 0, 4); //In this case, it is good for a higher rank at 0. + + //Step 4.Process Message in 16-Word Blocks (calculation of MD5) + MD5_Round_Calculate(padding_message, A,B,C,D); + + + //Step 5.Output (output) + memcpy(output,msg_digest,16); +// memcpy (digest, msg_digest, and 16); //8 byte*4 < - 32byte conversion A function called Encode as used in the field of RFC +/* sprintf(output, + "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + digest[ 0], digest[ 1], digest[ 2], digest[ 3], + digest[ 4], digest[ 5], digest[ 6], digest[ 7], + digest[ 8], digest[ 9], digest[10], digest[11], + digest[12], digest[13], digest[14], digest[15]);*/ +} + +/** output is the coded character sequence in the character sequence which wants to code string. */ +void MD5_String(const char * string, char * output) +{ + unsigned char digest[16]; + + MD5_String2binary(string,(char*)digest); + sprintf(output, + "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + digest[ 0], digest[ 1], digest[ 2], digest[ 3], + digest[ 4], digest[ 5], digest[ 6], digest[ 7], + digest[ 8], digest[ 9], digest[10], digest[11], + digest[12], digest[13], digest[14], digest[15]); +} + diff --git a/src/common/md5calc.h b/src/common/md5calc.h new file mode 100644 index 000000000..9bc554f69 --- /dev/null +++ b/src/common/md5calc.h @@ -0,0 +1,7 @@ +#ifndef _MD5CALC_H_ +#define _MD5CALC_H_ + +void MD5_String(const char * string, char * output); +void MD5_String2binary(const char * string, char * output); + +#endif diff --git a/src/ladmin/Makefile b/src/ladmin/Makefile index e383902c2..c5818404b 100644 --- a/src/ladmin/Makefile +++ b/src/ladmin/Makefile @@ -1,19 +1,18 @@ -all txt sql: ladmin - -COMMON_OBJ = ../common/obj/minicore.o ../common/obj/minisocket.o ../common/obj/timer.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o \ - ../common/obj/utils.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h \ - ../common/utils.h - -ladmin: ladmin.o md5calc.o $(COMMON_OBJ) - $(CC) -o ../../$@ ladmin.o md5calc.o $(COMMON_OBJ) $(LIB_S) - -clean: - rm -f *.o ../../ladmin - -# DO NOT DELETE - -ladmin.o: ladmin.c ladmin.h md5calc.h $(COMMON_H) -md5calc.o: md5calc.c md5calc.h +all txt sql: ladmin + +COMMON_OBJ = ../common/obj/minicore.o ../common/obj/minisocket.o ../common/obj/timer.o \ + ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o \ + ../common/obj/utils.o ../common/obj/md5calc.o +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ + ../common/version.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h \ + ../common/utils.h ../common/md5calc.h + +ladmin: ladmin.o $(COMMON_OBJ) + $(CC) -o ../../$@ ladmin.o $(COMMON_OBJ) $(LIB_S) + +clean: + rm -f *.o ../../ladmin GNUmakefile + +# DO NOT DELETE + +ladmin.o: ladmin.c ladmin.h $(COMMON_H) diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c index 848c6f3de..29f2ce404 100644 --- a/src/ladmin/ladmin.c +++ b/src/ladmin/ladmin.c @@ -47,7 +47,7 @@ void Gettimeofday(struct timeval *timenow) #include "../common/mmo.h" #ifdef PASSWORDENC -#include "md5calc.h" +#include "../common/md5calc.h" #endif //-------------------------------INSTRUCTIONS------------------------------ diff --git a/src/ladmin/md5calc.c b/src/ladmin/md5calc.c deleted file mode 100644 index b50071ee3..000000000 --- a/src/ladmin/md5calc.c +++ /dev/null @@ -1,239 +0,0 @@ -// (c) eAthena Dev Team - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -/*********************************************************** - * md5 calculation algorithm - * - * The source code referred to the following URL. - * http://www.geocities.co.jp/SiliconValley-Oakland/8878/lab17/lab17.html - * - ***********************************************************/ - -#include "md5calc.h" -#include -#include - -#ifndef UINT_MAX -#define UINT_MAX 4294967295U -#endif - -// Global variable -static unsigned int *pX; - -// Stirng Table -static const unsigned int T[] = { - 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, //0 - 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, //4 - 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, //8 - 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, //12 - 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, //16 - 0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8, //20 - 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, //24 - 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, //28 - 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, //32 - 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, //36 - 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05, //40 - 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, //44 - 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, //48 - 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, //52 - 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, //56 - 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 //60 -}; - -// ROTATE_LEFT The left is made to rotate x [ n-bit ]. This is diverted as it is from RFC. -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -// The function used for other calculation -static unsigned int F(unsigned int X, unsigned int Y, unsigned int Z) -{ - return (X & Y) | (~X & Z); -} -static unsigned int G(unsigned int X, unsigned int Y, unsigned int Z) -{ - return (X & Z) | (Y & ~Z); -} -static unsigned int H(unsigned int X, unsigned int Y, unsigned int Z) -{ - return X ^ Y ^ Z; -} -static unsigned int I(unsigned int X, unsigned int Y, unsigned int Z) -{ - return Y ^ (X | ~Z); -} - -static unsigned int Round(unsigned int a, unsigned int b, unsigned int FGHI, - unsigned int k, unsigned int s, unsigned int i) -{ - return b + ROTATE_LEFT(a + FGHI + pX[k] + T[i], s); -} - -static void Round1(unsigned int *a, unsigned int b, unsigned int c, - unsigned int d,unsigned int k, unsigned int s, unsigned int i) -{ - *a = Round(*a, b, F(b,c,d), k, s, i); -} -static void Round2(unsigned int *a, unsigned int b, unsigned int c, - unsigned int d,unsigned int k, unsigned int s, unsigned int i) -{ - *a = Round(*a, b, G(b,c,d), k, s, i); -} -static void Round3(unsigned int *a, unsigned int b, unsigned int c, - unsigned int d,unsigned int k, unsigned int s, unsigned int i) -{ - *a = Round(*a, b, H(b,c,d), k, s, i); -} -static void Round4(unsigned int *a, unsigned int b, unsigned int c, - unsigned int d,unsigned int k, unsigned int s, unsigned int i) -{ - *a = Round(*a, b, I(b,c,d), k, s, i); -} - -static void MD5_Round_Calculate(const unsigned char *block, - unsigned int *A2, unsigned int *B2, unsigned int *C2, unsigned int *D2) -{ - //create X It is since it is required. - unsigned int X[16]; //512bit 64byte - int j,k; - - //Save A as AA, B as BB, C as CC, and and D as DD (saving of A, B, C, and D) - unsigned int A=*A2, B=*B2, C=*C2, D=*D2; - unsigned int AA = A,BB = B,CC = C,DD = D; - - //It is a large region variable reluctantly because of calculation of a round. . . for Round1...4 - pX = X; - - //Copy block(padding_message) i into X - for (j=0,k=0; j<64; j+=4,k++) - X[k] = ( (unsigned int )block[j] ) // 8byte*4 -> 32byte conversion - | ( ((unsigned int )block[j+1]) << 8 ) // A function called Decode as used in the field of RFC - | ( ((unsigned int )block[j+2]) << 16 ) - | ( ((unsigned int )block[j+3]) << 24 ); - - - //Round 1 - Round1(&A,B,C,D, 0, 7, 0); Round1(&D,A,B,C, 1, 12, 1); Round1(&C,D,A,B, 2, 17, 2); Round1(&B,C,D,A, 3, 22, 3); - Round1(&A,B,C,D, 4, 7, 4); Round1(&D,A,B,C, 5, 12, 5); Round1(&C,D,A,B, 6, 17, 6); Round1(&B,C,D,A, 7, 22, 7); - Round1(&A,B,C,D, 8, 7, 8); Round1(&D,A,B,C, 9, 12, 9); Round1(&C,D,A,B, 10, 17, 10); Round1(&B,C,D,A, 11, 22, 11); - Round1(&A,B,C,D, 12, 7, 12); Round1(&D,A,B,C, 13, 12, 13); Round1(&C,D,A,B, 14, 17, 14); Round1(&B,C,D,A, 15, 22, 15); - - //Round 2 - Round2(&A,B,C,D, 1, 5, 16); Round2(&D,A,B,C, 6, 9, 17); Round2(&C,D,A,B, 11, 14, 18); Round2(&B,C,D,A, 0, 20, 19); - Round2(&A,B,C,D, 5, 5, 20); Round2(&D,A,B,C, 10, 9, 21); Round2(&C,D,A,B, 15, 14, 22); Round2(&B,C,D,A, 4, 20, 23); - Round2(&A,B,C,D, 9, 5, 24); Round2(&D,A,B,C, 14, 9, 25); Round2(&C,D,A,B, 3, 14, 26); Round2(&B,C,D,A, 8, 20, 27); - Round2(&A,B,C,D, 13, 5, 28); Round2(&D,A,B,C, 2, 9, 29); Round2(&C,D,A,B, 7, 14, 30); Round2(&B,C,D,A, 12, 20, 31); - - //Round 3 - Round3(&A,B,C,D, 5, 4, 32); Round3(&D,A,B,C, 8, 11, 33); Round3(&C,D,A,B, 11, 16, 34); Round3(&B,C,D,A, 14, 23, 35); - Round3(&A,B,C,D, 1, 4, 36); Round3(&D,A,B,C, 4, 11, 37); Round3(&C,D,A,B, 7, 16, 38); Round3(&B,C,D,A, 10, 23, 39); - Round3(&A,B,C,D, 13, 4, 40); Round3(&D,A,B,C, 0, 11, 41); Round3(&C,D,A,B, 3, 16, 42); Round3(&B,C,D,A, 6, 23, 43); - Round3(&A,B,C,D, 9, 4, 44); Round3(&D,A,B,C, 12, 11, 45); Round3(&C,D,A,B, 15, 16, 46); Round3(&B,C,D,A, 2, 23, 47); - - //Round 4 - Round4(&A,B,C,D, 0, 6, 48); Round4(&D,A,B,C, 7, 10, 49); Round4(&C,D,A,B, 14, 15, 50); Round4(&B,C,D,A, 5, 21, 51); - Round4(&A,B,C,D, 12, 6, 52); Round4(&D,A,B,C, 3, 10, 53); Round4(&C,D,A,B, 10, 15, 54); Round4(&B,C,D,A, 1, 21, 55); - Round4(&A,B,C,D, 8, 6, 56); Round4(&D,A,B,C, 15, 10, 57); Round4(&C,D,A,B, 6, 15, 58); Round4(&B,C,D,A, 13, 21, 59); - Round4(&A,B,C,D, 4, 6, 60); Round4(&D,A,B,C, 11, 10, 61); Round4(&C,D,A,B, 2, 15, 62); Round4(&B,C,D,A, 9, 21, 63); - - // Then perform the following additions. (let's add) - *A2 = A + AA; - *B2 = B + BB; - *C2 = C + CC; - *D2 = D + DD; - - //The clearance of confidential information - memset(pX, 0, sizeof(X)); -} - -//------------------------------------------------------------------- -// The function for the exteriors - -/** output is the coded binary in the character sequence which wants to code string. */ -void MD5_String2binary(const char * string, char * output) -{ -//var - /*8bit*/ - unsigned char padding_message[64]; //Extended message 512bit 64byte - unsigned char *pstring; //The position of string in the present scanning notes is held. - -// unsigned char digest[16]; - /*32bit*/ - unsigned int string_byte_len, //The byte chief of string is held. - string_bit_len, //The bit length of string is held. - copy_len, //The number of bytes which is used by 1-3 and which remained - msg_digest[4]; //Message digest 128bit 4byte - unsigned int *A = &msg_digest[0], //The message digest in accordance with RFC (reference) - *B = &msg_digest[1], - *C = &msg_digest[2], - *D = &msg_digest[3]; - int i; - -//prog - //Step 3.Initialize MD Buffer (although it is the initialization; step 3 of A, B, C, and D -- unavoidable -- a head) - *A = 0x67452301; - *B = 0xefcdab89; - *C = 0x98badcfe; - *D = 0x10325476; - - //Step 1.Append Padding Bits (extension of a mark bit) - //1-1 - string_byte_len = strlen(string); //The byte chief of a character sequence is acquired. - pstring = (unsigned char *)string; //The position of the present character sequence is set. - - //1-2 Repeat calculation until length becomes less than 64 bytes. - for (i=string_byte_len; 64<=i; i-=64,pstring+=64) - MD5_Round_Calculate(pstring, A,B,C,D); - - //1-3 - copy_len = string_byte_len % 64; //The number of bytes which remained is computed. - strncpy((char *)padding_message, (char *)pstring, copy_len); //A message is copied to an extended bit sequence. - memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length. - padding_message[copy_len] |= 0x80; //The next of a message is 1. - - //1-4 - //If 56 bytes or more (less than 64 bytes) of remainder becomes, it will calculate by extending to 64 bytes. - if (56 <= copy_len) { - MD5_Round_Calculate(padding_message, A,B,C,D); - memset(padding_message, 0, 56); //56 bytes is newly fill uped with 0. - } - - - //Step 2.Append Length (the information on length is added) - string_bit_len = string_byte_len * 8; //From the byte chief to bit length (32 bytes of low rank) - memcpy(&padding_message[56], &string_bit_len, 4); //32 bytes of low rank is set. - - //When bit length cannot be expressed in 32 bytes of low rank, it is a beam raising to a higher rank. - if (UINT_MAX / 8 < string_byte_len) { - unsigned int high = (string_byte_len - UINT_MAX / 8) * 8; - memcpy(&padding_message[60], &high, 4); - } else - memset(&padding_message[60], 0, 4); //In this case, it is good for a higher rank at 0. - - //Step 4.Process Message in 16-Word Blocks (calculation of MD5) - MD5_Round_Calculate(padding_message, A,B,C,D); - - - //Step 5.Output (output) - memcpy(output,msg_digest,16); -// memcpy (digest, msg_digest, and 16); //8 byte*4 < - 32byte conversion A function called Encode as used in the field of RFC -/* sprintf(output, - "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - digest[ 0], digest[ 1], digest[ 2], digest[ 3], - digest[ 4], digest[ 5], digest[ 6], digest[ 7], - digest[ 8], digest[ 9], digest[10], digest[11], - digest[12], digest[13], digest[14], digest[15]);*/ -} - -/** output is the coded character sequence in the character sequence which wants to code string. */ -void MD5_String(const char * string, char * output) -{ - unsigned char digest[16]; - - MD5_String2binary(string,(char*)digest); - sprintf(output, - "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - digest[ 0], digest[ 1], digest[ 2], digest[ 3], - digest[ 4], digest[ 5], digest[ 6], digest[ 7], - digest[ 8], digest[ 9], digest[10], digest[11], - digest[12], digest[13], digest[14], digest[15]); -} - diff --git a/src/ladmin/md5calc.h b/src/ladmin/md5calc.h deleted file mode 100644 index ad46af760..000000000 --- a/src/ladmin/md5calc.h +++ /dev/null @@ -1,10 +0,0 @@ -// (c) eAthena Dev Team - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _MD5CALC_H_ -#define _MD5CALC_H_ - -void MD5_String(const char * string, char * output); -void MD5_String2binary(const char * string, char * output); - -#endif diff --git a/src/login/Makefile b/src/login/Makefile index 549d1f170..7c7d74c46 100644 --- a/src/login/Makefile +++ b/src/login/Makefile @@ -1,25 +1,26 @@ -all txt: login-server - -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ - ../common/obj/strlib.o ../common/obj/graph.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o ../zlib/unz.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ - ../common/graph.h ../common/grfio.h ../common/mapindex.h - -%.o: %.c - $(COMPILE.c) -DTXT_ONLY $(OUTPUT_OPTION) $< - -login-server: login.o md5calc.o $(COMMON_OBJ) - $(CC) -o ../../$@ login.o md5calc.o $(COMMON_OBJ) $(LIB_S) - -clean: - rm -f *.o ../../login-server - -# DO NOT DELETE - -login.o: login.c login.h md5calc.h $(COMMON_H) -md5calc.o: md5calc.c md5calc.h +all txt: login-server + +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ + ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ + ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ + ../common/obj/strlib.o ../common/obj/graph.o ../common/obj/grfio.o \ + ../common/obj/mapindex.o ../common/obj/ers.o ../common/obj/md5calc.h \ + ../zlib/unz.o +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ + ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ + ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ + ../common/graph.h ../common/grfio.h ../common/mapindex.h \ + ../common/md5calc.h + +%.o: %.c + $(COMPILE.c) -DTXT_ONLY $(OUTPUT_OPTION) $< + +login-server: login.o $(COMMON_OBJ) + $(CC) -o ../../$@ login.o $(COMMON_OBJ) $(LIB_S) + +clean: + rm -f *.o ../../login-server GNUmakefile + +# DO NOT DELETE + +login.o: login.c login.h $(COMMON_H) diff --git a/src/login/login.c b/src/login/login.c index e30b44f3e..3c38c738c 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -35,7 +35,7 @@ #include "login.h" #ifdef PASSWORDENC -#include "md5calc.h" +#include "../common/md5calc.h" #endif int account_id_count = START_ACCOUNT_NUM; diff --git a/src/login/md5calc.c b/src/login/md5calc.c deleted file mode 100644 index fd8ffd5d3..000000000 --- a/src/login/md5calc.c +++ /dev/null @@ -1,236 +0,0 @@ -/*********************************************************** - * md5 calculation algorithm - * - * The source code referred to the following URL. - * http://www.geocities.co.jp/SiliconValley-Oakland/8878/lab17/lab17.html - * - ***********************************************************/ - -#include "md5calc.h" -#include -#include - -#ifndef UINT_MAX -#define UINT_MAX 4294967295U -#endif - -// Global variable -static unsigned int *pX; - -// String Table -static const unsigned int T[] = { - 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, //0 - 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, //4 - 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, //8 - 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, //12 - 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, //16 - 0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8, //20 - 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, //24 - 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, //28 - 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, //32 - 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, //36 - 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05, //40 - 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, //44 - 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, //48 - 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, //52 - 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, //56 - 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 //60 -}; - -// ROTATE_LEFT The left is made to rotate x [ n-bit ]. This is diverted as it is from RFC. -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -// The function used for other calculation -static unsigned int F(unsigned int X, unsigned int Y, unsigned int Z) -{ - return (X & Y) | (~X & Z); -} -static unsigned int G(unsigned int X, unsigned int Y, unsigned int Z) -{ - return (X & Z) | (Y & ~Z); -} -static unsigned int H(unsigned int X, unsigned int Y, unsigned int Z) -{ - return X ^ Y ^ Z; -} -static unsigned int I(unsigned int X, unsigned int Y, unsigned int Z) -{ - return Y ^ (X | ~Z); -} - -static unsigned int Round(unsigned int a, unsigned int b, unsigned int FGHI, - unsigned int k, unsigned int s, unsigned int i) -{ - return b + ROTATE_LEFT(a + FGHI + pX[k] + T[i], s); -} - -static void Round1(unsigned int *a, unsigned int b, unsigned int c, - unsigned int d,unsigned int k, unsigned int s, unsigned int i) -{ - *a = Round(*a, b, F(b,c,d), k, s, i); -} -static void Round2(unsigned int *a, unsigned int b, unsigned int c, - unsigned int d,unsigned int k, unsigned int s, unsigned int i) -{ - *a = Round(*a, b, G(b,c,d), k, s, i); -} -static void Round3(unsigned int *a, unsigned int b, unsigned int c, - unsigned int d,unsigned int k, unsigned int s, unsigned int i) -{ - *a = Round(*a, b, H(b,c,d), k, s, i); -} -static void Round4(unsigned int *a, unsigned int b, unsigned int c, - unsigned int d,unsigned int k, unsigned int s, unsigned int i) -{ - *a = Round(*a, b, I(b,c,d), k, s, i); -} - -static void MD5_Round_Calculate(const unsigned char *block, - unsigned int *A2, unsigned int *B2, unsigned int *C2, unsigned int *D2) -{ - //create X It is since it is required. - unsigned int X[16]; //512bit 64byte - int j,k; - - //Save A as AA, B as BB, C as CC, and and D as DD (saving of A, B, C, and D) - unsigned int A=*A2, B=*B2, C=*C2, D=*D2; - unsigned int AA = A,BB = B,CC = C,DD = D; - - //It is a large region variable reluctantly because of calculation of a round. . . for Round1...4 - pX = X; - - //Copy block(padding_message) i into X - for (j=0,k=0; j<64; j+=4,k++) - X[k] = ( (unsigned int )block[j] ) // 8byte*4 -> 32byte conversion - | ( ((unsigned int )block[j+1]) << 8 ) // A function called Decode as used in the field of RFC - | ( ((unsigned int )block[j+2]) << 16 ) - | ( ((unsigned int )block[j+3]) << 24 ); - - - //Round 1 - Round1(&A,B,C,D, 0, 7, 0); Round1(&D,A,B,C, 1, 12, 1); Round1(&C,D,A,B, 2, 17, 2); Round1(&B,C,D,A, 3, 22, 3); - Round1(&A,B,C,D, 4, 7, 4); Round1(&D,A,B,C, 5, 12, 5); Round1(&C,D,A,B, 6, 17, 6); Round1(&B,C,D,A, 7, 22, 7); - Round1(&A,B,C,D, 8, 7, 8); Round1(&D,A,B,C, 9, 12, 9); Round1(&C,D,A,B, 10, 17, 10); Round1(&B,C,D,A, 11, 22, 11); - Round1(&A,B,C,D, 12, 7, 12); Round1(&D,A,B,C, 13, 12, 13); Round1(&C,D,A,B, 14, 17, 14); Round1(&B,C,D,A, 15, 22, 15); - - //Round 2 - Round2(&A,B,C,D, 1, 5, 16); Round2(&D,A,B,C, 6, 9, 17); Round2(&C,D,A,B, 11, 14, 18); Round2(&B,C,D,A, 0, 20, 19); - Round2(&A,B,C,D, 5, 5, 20); Round2(&D,A,B,C, 10, 9, 21); Round2(&C,D,A,B, 15, 14, 22); Round2(&B,C,D,A, 4, 20, 23); - Round2(&A,B,C,D, 9, 5, 24); Round2(&D,A,B,C, 14, 9, 25); Round2(&C,D,A,B, 3, 14, 26); Round2(&B,C,D,A, 8, 20, 27); - Round2(&A,B,C,D, 13, 5, 28); Round2(&D,A,B,C, 2, 9, 29); Round2(&C,D,A,B, 7, 14, 30); Round2(&B,C,D,A, 12, 20, 31); - - //Round 3 - Round3(&A,B,C,D, 5, 4, 32); Round3(&D,A,B,C, 8, 11, 33); Round3(&C,D,A,B, 11, 16, 34); Round3(&B,C,D,A, 14, 23, 35); - Round3(&A,B,C,D, 1, 4, 36); Round3(&D,A,B,C, 4, 11, 37); Round3(&C,D,A,B, 7, 16, 38); Round3(&B,C,D,A, 10, 23, 39); - Round3(&A,B,C,D, 13, 4, 40); Round3(&D,A,B,C, 0, 11, 41); Round3(&C,D,A,B, 3, 16, 42); Round3(&B,C,D,A, 6, 23, 43); - Round3(&A,B,C,D, 9, 4, 44); Round3(&D,A,B,C, 12, 11, 45); Round3(&C,D,A,B, 15, 16, 46); Round3(&B,C,D,A, 2, 23, 47); - - //Round 4 - Round4(&A,B,C,D, 0, 6, 48); Round4(&D,A,B,C, 7, 10, 49); Round4(&C,D,A,B, 14, 15, 50); Round4(&B,C,D,A, 5, 21, 51); - Round4(&A,B,C,D, 12, 6, 52); Round4(&D,A,B,C, 3, 10, 53); Round4(&C,D,A,B, 10, 15, 54); Round4(&B,C,D,A, 1, 21, 55); - Round4(&A,B,C,D, 8, 6, 56); Round4(&D,A,B,C, 15, 10, 57); Round4(&C,D,A,B, 6, 15, 58); Round4(&B,C,D,A, 13, 21, 59); - Round4(&A,B,C,D, 4, 6, 60); Round4(&D,A,B,C, 11, 10, 61); Round4(&C,D,A,B, 2, 15, 62); Round4(&B,C,D,A, 9, 21, 63); - - // Then perform the following additions. (let's add) - *A2 = A + AA; - *B2 = B + BB; - *C2 = C + CC; - *D2 = D + DD; - - //The clearance of confidential information - memset(pX, 0, sizeof(X)); -} - -//------------------------------------------------------------------- -// The function for the exteriors - -/** output is the coded binary in the character sequence which wants to code string. */ -void MD5_String2binary(const char * string, char * output) -{ -//var - /*8bit*/ - unsigned char padding_message[64]; //Extended message 512bit 64byte - unsigned char *pstring; //The position of string in the present scanning notes is held. - -// unsigned char digest[16]; - /*32bit*/ - unsigned int string_byte_len, //The byte chief of string is held. - string_bit_len, //The bit length of string is held. - copy_len, //The number of bytes which is used by 1-3 and which remained - msg_digest[4]; //Message digest 128bit 4byte - unsigned int *A = &msg_digest[0], //The message digest in accordance with RFC (reference) - *B = &msg_digest[1], - *C = &msg_digest[2], - *D = &msg_digest[3]; - int i; - -//prog - //Step 3.Initialize MD Buffer (although it is the initialization; step 3 of A, B, C, and D -- unavoidable -- a head) - *A = 0x67452301; - *B = 0xefcdab89; - *C = 0x98badcfe; - *D = 0x10325476; - - //Step 1.Append Padding Bits (extension of a mark bit) - //1-1 - string_byte_len = strlen(string); //The byte chief of a character sequence is acquired. - pstring = (unsigned char *)string; //The position of the present character sequence is set. - - //1-2 Repeat calculation until length becomes less than 64 bytes. - for (i=string_byte_len; 64<=i; i-=64,pstring+=64) - MD5_Round_Calculate(pstring, A,B,C,D); - - //1-3 - copy_len = string_byte_len % 64; //The number of bytes which remained is computed. - strncpy((char *)padding_message, (char *)pstring, copy_len); //A message is copied to an extended bit sequence. - memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length. - padding_message[copy_len] |= 0x80; //The next of a message is 1. - - //1-4 - //If 56 bytes or more (less than 64 bytes) of remainder becomes, it will calculate by extending to 64 bytes. - if (56 <= copy_len) { - MD5_Round_Calculate(padding_message, A,B,C,D); - memset(padding_message, 0, 56); //56 bytes is newly fill uped with 0. - } - - - //Step 2.Append Length (the information on length is added) - string_bit_len = string_byte_len * 8; //From the byte chief to bit length (32 bytes of low rank) - memcpy(&padding_message[56], &string_bit_len, 4); //32 bytes of low rank is set. - - //When bit length cannot be expressed in 32 bytes of low rank, it is a beam raising to a higher rank. - if (UINT_MAX / 8 < string_byte_len) { - unsigned int high = (string_byte_len - UINT_MAX / 8) * 8; - memcpy(&padding_message[60], &high, 4); - } else - memset(&padding_message[60], 0, 4); //In this case, it is good for a higher rank at 0. - - //Step 4.Process Message in 16-Word Blocks (calculation of MD5) - MD5_Round_Calculate(padding_message, A,B,C,D); - - - //Step 5.Output (output) - memcpy(output,msg_digest,16); -// memcpy (digest, msg_digest, and 16); //8 byte*4 < - 32byte conversion A function called Encode as used in the field of RFC -/* sprintf(output, - "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - digest[ 0], digest[ 1], digest[ 2], digest[ 3], - digest[ 4], digest[ 5], digest[ 6], digest[ 7], - digest[ 8], digest[ 9], digest[10], digest[11], - digest[12], digest[13], digest[14], digest[15]);*/ -} - -/** output is the coded character sequence in the character sequence which wants to code string. */ -void MD5_String(const char * string, char * output) -{ - unsigned char digest[16]; - - MD5_String2binary(string,(char*)digest); - sprintf(output, - "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - digest[ 0], digest[ 1], digest[ 2], digest[ 3], - digest[ 4], digest[ 5], digest[ 6], digest[ 7], - digest[ 8], digest[ 9], digest[10], digest[11], - digest[12], digest[13], digest[14], digest[15]); -} - diff --git a/src/login/md5calc.h b/src/login/md5calc.h deleted file mode 100644 index 9bc554f69..000000000 --- a/src/login/md5calc.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _MD5CALC_H_ -#define _MD5CALC_H_ - -void MD5_String(const char * string, char * output); -void MD5_String2binary(const char * string, char * output); - -#endif diff --git a/src/login_sql/Makefile b/src/login_sql/Makefile index 2a54f680b..249934065 100644 --- a/src/login_sql/Makefile +++ b/src/login_sql/Makefile @@ -1,22 +1,23 @@ -all sql: login-server_sql - -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ - ../common/obj/strlib.o ../common/obj/graph.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o ../zlib/unz.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ - ../common/graph.h ../common/grfio.h ../common/mapindex.h - -login-server_sql: login.o md5calc.o $(COMMON_OBJ) - $(CC) -o ../../$@ $^ $(LIB_S) - -clean: - rm -f *.o ../../login-server_sql - -# DO NOT DELETE - -login.o: login.c login.h md5calc.h $(COMMON_H) -md5calc.o: md5calc.c md5calc.h +all sql: login-server_sql + +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ + ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ + ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ + ../common/obj/strlib.o ../common/obj/graph.o ../common/obj/grfio.o \ + ../common/obj/mapindex.o ../common/obj/ers.o ../common/md5calc.o \ + ../zlib/unz.o +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ + ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ + ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ + ../common/graph.h ../common/grfio.h ../common/mapindex.h \ + ../common/md5calc.h + +login-server_sql: login.o $(COMMON_OBJ) + $(CC) -o ../../$@ $^ $(LIB_S) + +clean: + rm -f *.o ../../login-server_sql GNUmakefile + +# DO NOT DELETE + +login.o: login.c login.h $(COMMON_H) diff --git a/src/login_sql/login.c b/src/login_sql/login.c index c37329694..c6e159e27 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -41,7 +41,7 @@ #include "login.h" #ifdef PASSWORDENC -#include "md5calc.h" +#include "../common/md5calc.h" #endif #define J_MAX_MALLOC_SIZE 65535 diff --git a/src/login_sql/make.sh b/src/login_sql/make.sh deleted file mode 100644 index 3e43cd11f..000000000 --- a/src/login_sql/make.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - rsqlt=`rm -rf *.o` - gcc -c login.c -I/usr/local/include/mysql/ - gcc -c md5calc.c -I/usr/local/include/mysql/ - gcc -c strlib.c - gcc -o login-server login.o strlib.o md5calc.o ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o -L/usr/local/lib/mysql/ -lmysqlclient -lz diff --git a/src/login_sql/md5calc.c b/src/login_sql/md5calc.c deleted file mode 100644 index 09c59dd60..000000000 --- a/src/login_sql/md5calc.c +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -/*********************************************************** - * md5 calculation algorithm - * - * The source code referred to the following URL. - * http://www.geocities.co.jp/SiliconValley-Oakland/8878/lab17/lab17.html - * - ***********************************************************/ - -#include "md5calc.h" -#include -#include - -#ifndef UINT_MAX -#define UINT_MAX 4294967295U -#endif - -// Global variable -static unsigned int *pX; - -// Stirng Table -static const unsigned int T[] = { - 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, //0 - 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, //4 - 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, //8 - 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, //12 - 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, //16 - 0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8, //20 - 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, //24 - 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, //28 - 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, //32 - 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, //36 - 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05, //40 - 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, //44 - 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, //48 - 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, //52 - 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, //56 - 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 //60 -}; - -// ROTATE_LEFT The left is made to rotate x [ n-bit ]. This is diverted as it is from RFC. -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -// The function used for other calculation -static unsigned int F(unsigned int X, unsigned int Y, unsigned int Z) -{ - return (X & Y) | (~X & Z); -} -static unsigned int G(unsigned int X, unsigned int Y, unsigned int Z) -{ - return (X & Z) | (Y & ~Z); -} -static unsigned int H(unsigned int X, unsigned int Y, unsigned int Z) -{ - return X ^ Y ^ Z; -} -static unsigned int I(unsigned int X, unsigned int Y, unsigned int Z) -{ - return Y ^ (X | ~Z); -} - -static unsigned int Round(unsigned int a, unsigned int b, unsigned int FGHI, - unsigned int k, unsigned int s, unsigned int i) -{ - return b + ROTATE_LEFT(a + FGHI + pX[k] + T[i], s); -} - -static void Round1(unsigned int *a, unsigned int b, unsigned int c, - unsigned int d,unsigned int k, unsigned int s, unsigned int i) -{ - *a = Round(*a, b, F(b,c,d), k, s, i); -} -static void Round2(unsigned int *a, unsigned int b, unsigned int c, - unsigned int d,unsigned int k, unsigned int s, unsigned int i) -{ - *a = Round(*a, b, G(b,c,d), k, s, i); -} -static void Round3(unsigned int *a, unsigned int b, unsigned int c, - unsigned int d,unsigned int k, unsigned int s, unsigned int i) -{ - *a = Round(*a, b, H(b,c,d), k, s, i); -} -static void Round4(unsigned int *a, unsigned int b, unsigned int c, - unsigned int d,unsigned int k, unsigned int s, unsigned int i) -{ - *a = Round(*a, b, I(b,c,d), k, s, i); -} - -static void MD5_Round_Calculate(const unsigned char *block, - unsigned int *A2, unsigned int *B2, unsigned int *C2, unsigned int *D2) -{ - //create X It is since it is required. - unsigned int X[16]; //512bit 64byte - int j,k; - - //Save A as AA, B as BB, C as CC, and and D as DD (saving of A, B, C, and D) - unsigned int A=*A2, B=*B2, C=*C2, D=*D2; - unsigned int AA = A,BB = B,CC = C,DD = D; - - //It is a large region variable reluctantly because of calculation of a round. . . for Round1...4 - pX = X; - - //Copy block(padding_message) i into X - for (j=0,k=0; j<64; j+=4,k++) - X[k] = ( (unsigned int )block[j] ) // 8byte*4 -> 32byte conversion - | ( ((unsigned int )block[j+1]) << 8 ) // A function called Decode as used in the field of RFC - | ( ((unsigned int )block[j+2]) << 16 ) - | ( ((unsigned int )block[j+3]) << 24 ); - - - //Round 1 - Round1(&A,B,C,D, 0, 7, 0); Round1(&D,A,B,C, 1, 12, 1); Round1(&C,D,A,B, 2, 17, 2); Round1(&B,C,D,A, 3, 22, 3); - Round1(&A,B,C,D, 4, 7, 4); Round1(&D,A,B,C, 5, 12, 5); Round1(&C,D,A,B, 6, 17, 6); Round1(&B,C,D,A, 7, 22, 7); - Round1(&A,B,C,D, 8, 7, 8); Round1(&D,A,B,C, 9, 12, 9); Round1(&C,D,A,B, 10, 17, 10); Round1(&B,C,D,A, 11, 22, 11); - Round1(&A,B,C,D, 12, 7, 12); Round1(&D,A,B,C, 13, 12, 13); Round1(&C,D,A,B, 14, 17, 14); Round1(&B,C,D,A, 15, 22, 15); - - //Round 2 - Round2(&A,B,C,D, 1, 5, 16); Round2(&D,A,B,C, 6, 9, 17); Round2(&C,D,A,B, 11, 14, 18); Round2(&B,C,D,A, 0, 20, 19); - Round2(&A,B,C,D, 5, 5, 20); Round2(&D,A,B,C, 10, 9, 21); Round2(&C,D,A,B, 15, 14, 22); Round2(&B,C,D,A, 4, 20, 23); - Round2(&A,B,C,D, 9, 5, 24); Round2(&D,A,B,C, 14, 9, 25); Round2(&C,D,A,B, 3, 14, 26); Round2(&B,C,D,A, 8, 20, 27); - Round2(&A,B,C,D, 13, 5, 28); Round2(&D,A,B,C, 2, 9, 29); Round2(&C,D,A,B, 7, 14, 30); Round2(&B,C,D,A, 12, 20, 31); - - //Round 3 - Round3(&A,B,C,D, 5, 4, 32); Round3(&D,A,B,C, 8, 11, 33); Round3(&C,D,A,B, 11, 16, 34); Round3(&B,C,D,A, 14, 23, 35); - Round3(&A,B,C,D, 1, 4, 36); Round3(&D,A,B,C, 4, 11, 37); Round3(&C,D,A,B, 7, 16, 38); Round3(&B,C,D,A, 10, 23, 39); - Round3(&A,B,C,D, 13, 4, 40); Round3(&D,A,B,C, 0, 11, 41); Round3(&C,D,A,B, 3, 16, 42); Round3(&B,C,D,A, 6, 23, 43); - Round3(&A,B,C,D, 9, 4, 44); Round3(&D,A,B,C, 12, 11, 45); Round3(&C,D,A,B, 15, 16, 46); Round3(&B,C,D,A, 2, 23, 47); - - //Round 4 - Round4(&A,B,C,D, 0, 6, 48); Round4(&D,A,B,C, 7, 10, 49); Round4(&C,D,A,B, 14, 15, 50); Round4(&B,C,D,A, 5, 21, 51); - Round4(&A,B,C,D, 12, 6, 52); Round4(&D,A,B,C, 3, 10, 53); Round4(&C,D,A,B, 10, 15, 54); Round4(&B,C,D,A, 1, 21, 55); - Round4(&A,B,C,D, 8, 6, 56); Round4(&D,A,B,C, 15, 10, 57); Round4(&C,D,A,B, 6, 15, 58); Round4(&B,C,D,A, 13, 21, 59); - Round4(&A,B,C,D, 4, 6, 60); Round4(&D,A,B,C, 11, 10, 61); Round4(&C,D,A,B, 2, 15, 62); Round4(&B,C,D,A, 9, 21, 63); - - // Then perform the following additions. (let's add) - *A2 = A + AA; - *B2 = B + BB; - *C2 = C + CC; - *D2 = D + DD; - - //The clearance of confidential information - memset(pX, 0, sizeof(X)); -} - -//------------------------------------------------------------------- -// The function for the exteriors - -/** output is the coded binary in the character sequence which wants to code string. */ -void MD5_String2binary(const char * string, char * output) -{ -//var - /*8bit*/ - unsigned char padding_message[64]; //Extended message 512bit 64byte - unsigned char *pstring; //The position of string in the present scanning notes is held. - -// unsigned char digest[16]; - /*32bit*/ - unsigned int string_byte_len, //The byte chief of string is held. - string_bit_len, //The bit length of string is held. - copy_len, //The number of bytes which is used by 1-3 and which remained - msg_digest[4]; //Message digest 128bit 4byte - unsigned int *A = &msg_digest[0], //The message digest in accordance with RFC (reference) - *B = &msg_digest[1], - *C = &msg_digest[2], - *D = &msg_digest[3]; - int i; - -//prog - //Step 3.Initialize MD Buffer (although it is the initialization; step 3 of A, B, C, and D -- unavoidable -- a head) - *A = 0x67452301; - *B = 0xefcdab89; - *C = 0x98badcfe; - *D = 0x10325476; - - //Step 1.Append Padding Bits (extension of a mark bit) - //1-1 - string_byte_len = strlen(string); //The byte chief of a character sequence is acquired. - pstring = (unsigned char *)string; //The position of the present character sequence is set. - - //1-2 Repeat calculation until length becomes less than 64 bytes. - for (i=string_byte_len; 64<=i; i-=64,pstring+=64) - MD5_Round_Calculate(pstring, A,B,C,D); - - //1-3 - copy_len = string_byte_len % 64; //The number of bytes which remained is computed. - strncpy((char *)padding_message, (char *)pstring, copy_len); //A message is copied to an extended bit sequence. - memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length. - padding_message[copy_len] |= 0x80; //The next of a message is 1. - - //1-4 - //If 56 bytes or more (less than 64 bytes) of remainder becomes, it will calculate by extending to 64 bytes. - if (56 <= copy_len) { - MD5_Round_Calculate(padding_message, A,B,C,D); - memset(padding_message, 0, 56); //56 bytes is newly fill uped with 0. - } - - - //Step 2.Append Length (the information on length is added) - string_bit_len = string_byte_len * 8; //From the byte chief to bit length (32 bytes of low rank) - memcpy(&padding_message[56], &string_bit_len, 4); //32 bytes of low rank is set. - - //When bit length cannot be expressed in 32 bytes of low rank, it is a beam raising to a higher rank. - if (UINT_MAX / 8 < string_byte_len) { - unsigned int high = (string_byte_len - UINT_MAX / 8) * 8; - memcpy(&padding_message[60], &high, 4); - } else - memset(&padding_message[60], 0, 4); //In this case, it is good for a higher rank at 0. - - //Step 4.Process Message in 16-Word Blocks (calculation of MD5) - MD5_Round_Calculate(padding_message, A,B,C,D); - - - //Step 5.Output (output) - memcpy(output,msg_digest,16); -// memcpy (digest, msg_digest, and 16); //8 byte*4 < - 32byte conversion A function called Encode as used in the field of RFC -/* sprintf(output, - "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - digest[ 0], digest[ 1], digest[ 2], digest[ 3], - digest[ 4], digest[ 5], digest[ 6], digest[ 7], - digest[ 8], digest[ 9], digest[10], digest[11], - digest[12], digest[13], digest[14], digest[15]);*/ -} - -/** output is the coded character sequence in the character sequence which wants to code string. */ -void MD5_String(const char * string, char * output) -{ - unsigned char digest[16]; - - MD5_String2binary(string,(char*)digest); - sprintf(output, - "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - digest[ 0], digest[ 1], digest[ 2], digest[ 3], - digest[ 4], digest[ 5], digest[ 6], digest[ 7], - digest[ 8], digest[ 9], digest[10], digest[11], - digest[12], digest[13], digest[14], digest[15]); -} - diff --git a/src/login_sql/md5calc.h b/src/login_sql/md5calc.h deleted file mode 100644 index 505959c6a..000000000 --- a/src/login_sql/md5calc.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _MD5CALC_H_ -#define _MD5CALC_H_ - -void MD5_String(const char * string, char * output); -void MD5_String2binary(const char * string, char * output); - -#endif diff --git a/src/map/Makefile b/src/map/Makefile index 72bac5471..2345c7dd3 100644 --- a/src/map/Makefile +++ b/src/map/Makefile @@ -1,106 +1,106 @@ -all txt: txtobj map-server - -sql: sqlobj map-server_sql - -txtobj: - mkdir txtobj - -sqlobj: - mkdir sqlobj - -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/nullpo.o ../common/obj/malloc.o ../common/obj/showmsg.o \ - ../common/obj/utils.o ../common/obj/strlib.o ../common/obj/grfio.o \ - ../common/obj/graph.o ../common/obj/mapindex.o ../common/obj/ers.o \ - ../zlib/unz.o - -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/db.h \ - ../common/plugins.h ../common/lock.h ../common/nullpo.h ../common/malloc.h \ - ../common/showmsg.h ../common/utils.h ../common/strlib.h ../common/grfio.h \ - ../common/graph.h ../common/mapindex.h - -OBJECTS = obj/map.o obj/chrif.o obj/clif.o obj/pc.o obj/status.o obj/npc.o \ - obj/npc_chat.o obj/chat.o obj/path.o obj/itemdb.o obj/mob.o obj/script.o \ - obj/storage.o obj/skill.o obj/atcommand.o obj/charcommand.o obj/battle.o \ - obj/intif.o obj/trade.o obj/party.o obj/vending.o obj/guild.o obj/pet.o \ - obj/log.o obj/mail.o obj/charsave.o obj/date.o obj/irc.o obj/unit.o \ - obj/mercenary.o \ - $(COMMON_OBJ) - -map-server: $(OBJECTS:obj/%=txtobj/%) - $(CC) -o ../../$@ $> $(LIBS) $(LIB_S) - -map-server_sql: $(OBJECTS:obj/%=sqlobj/%) - $(CC) -o ../../$@ $> $(LIB_S) - -txtobj/%.o: %.c - $(COMPILE.c) -DTXT_ONLY $(OUTPUT_OPTION) $< - -sqlobj/%.o: %.c - $(COMPILE.c) $(OUTPUT_OPTION) $< - -clean: - rm -rf *.o ../../map-server ../../map-server_sql sqlobj txtobj - -# DO NOT DELETE - -txtobj/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h irc.h $(COMMON_H) -txtobj/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h $(COMMON_H) -txtobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h irc.h $(COMMON_H) -txtobj/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h $(COMMON_H) -txtobj/status.o: status.c pc.h map.h clif.h status.h mob.h itemdb.h battle.h skill.h script.h pet.h guild.h $(COMMON_H) -txtobj/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) -txtobj/npc_chat.o: npc_chat.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) -txtobj/chat.o: chat.c map.h clif.h pc.h chat.h $(COMMON_H) -txtobj/path.o: path.c map.h battle.h $(COMMON_H) -txtobj/itemdb.o: itemdb.c map.h battle.h itemdb.h $(COMMON_H) -txtobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h date.h irc.h $(COMMON_H) -txtobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h irc.h $(COMMON_H) -txtobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h $(COMMON_H) -txtobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h date.h $(COMMON_H) -txtobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) -txtobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h $(COMMON_H) -txtobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h $(COMMON_H) -txtobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h $(COMMON_H) -txtobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h $(COMMON_H) -txtobj/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h irc.h $(COMMON_H) -txtobj/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h $(COMMON_H) -txtobj/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h $(COMMON_H) -txtobj/log.o: log.c log.h map.h $(COMMON_H) -txtobj/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) -txtobj/date.o: date.c date.h $(COMMON_H) -txtobj/irc.o: irc.c irc.h map.h pc.h $(COMMON_H) -txtobj/unit.o: unit.c unit.h $(COMMON_H) -txtobj/mercenary.o: mercenary.c mercenary.h $(COMMON_H) - -sqlobj/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h log.h irc.h $(COMMON_H) -sqlobj/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h $(COMMON_H) -sqlobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h $(COMMON_H) -sqlobj/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h log.h $(COMMON_H) -sqlobj/status.o: status.c pc.h map.h clif.h status.h mob.h itemdb.h battle.h skill.h script.h pet.h guild.h $(COMMON_H) -sqlobj/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) -sqlobj/npc_chat.o: npc_chat.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) -sqlobj/chat.o: chat.c map.h clif.h pc.h chat.h $(COMMON_H) -sqlobj/path.o: path.c map.h battle.h $(COMMON_H) -sqlobj/itemdb.o: itemdb.c map.h battle.h itemdb.h $(COMMON_H) -sqlobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h log.h date.h irc.h $(COMMON_H) -sqlobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h irc.h $(COMMON_H) -sqlobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h $(COMMON_H) -sqlobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h log.h date.h $(COMMON_H) -sqlobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) -sqlobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h $(COMMON_H) -sqlobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h $(COMMON_H) -sqlobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h log.h $(COMMON_H) -sqlobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h $(COMMON_H) -sqlobj/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h log.h irc.h $(COMMON_H) -sqlobj/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h irc.h $(COMMON_H) -sqlobj/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h $(COMMON_H) -sqlobj/mail.o: mail.c mail.h $(COMMON_H) -sqlobj/log.o: log.c log.h map.h $(COMMON_H) -sqlobj/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) -sqlobj/charsave.o: charsave.c charsave.h $(COMMON_H) -sqlobj/date.o: date.c date.h $(COMMON_H) -sqlobj/irc.o: irc.c irc.h map.h pc.h $(COMMON_H) -sqlobj/unit.o: unit.c unit.h $(COMMON_H) -sqlobj/mercenary.o: mercenary.c mercenary.h $(COMMON_H) +all txt: txtobj map-server + +sql: sqlobj map-server_sql + +txtobj: + mkdir txtobj + +sqlobj: + mkdir sqlobj + +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ + ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ + ../common/obj/nullpo.o ../common/obj/malloc.o ../common/obj/showmsg.o \ + ../common/obj/utils.o ../common/obj/strlib.o ../common/obj/grfio.o \ + ../common/obj/graph.o ../common/obj/mapindex.o ../common/obj/ers.o \ + ../zlib/unz.o + +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/db.h \ + ../common/plugins.h ../common/lock.h ../common/nullpo.h ../common/malloc.h \ + ../common/showmsg.h ../common/utils.h ../common/strlib.h ../common/grfio.h \ + ../common/graph.h ../common/mapindex.h + +OBJECTS = obj/map.o obj/chrif.o obj/clif.o obj/pc.o obj/status.o obj/npc.o \ + obj/npc_chat.o obj/chat.o obj/path.o obj/itemdb.o obj/mob.o obj/script.o \ + obj/storage.o obj/skill.o obj/atcommand.o obj/charcommand.o obj/battle.o \ + obj/intif.o obj/trade.o obj/party.o obj/vending.o obj/guild.o obj/pet.o \ + obj/log.o obj/mail.o obj/charsave.o obj/date.o obj/irc.o obj/unit.o \ + obj/mercenary.o \ + $(COMMON_OBJ) + +map-server: $(OBJECTS:obj/%=txtobj/%) + $(CC) -o ../../$@ $> $(LIBS) $(LIB_S) + +map-server_sql: $(OBJECTS:obj/%=sqlobj/%) + $(CC) -o ../../$@ $> $(LIB_S) + +txtobj/%.o: %.c + $(COMPILE.c) -DTXT_ONLY $(OUTPUT_OPTION) $< + +sqlobj/%.o: %.c + $(COMPILE.c) $(OUTPUT_OPTION) $< + +clean: + rm -rf *.o ../../map-server ../../map-server_sql sqlobj txtobj + +# DO NOT DELETE + +txtobj/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h irc.h $(COMMON_H) +txtobj/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h $(COMMON_H) +txtobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h irc.h $(COMMON_H) +txtobj/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h $(COMMON_H) +txtobj/status.o: status.c pc.h map.h clif.h status.h mob.h itemdb.h battle.h skill.h script.h pet.h guild.h $(COMMON_H) +txtobj/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) +txtobj/npc_chat.o: npc_chat.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) +txtobj/chat.o: chat.c map.h clif.h pc.h chat.h $(COMMON_H) +txtobj/path.o: path.c map.h battle.h $(COMMON_H) +txtobj/itemdb.o: itemdb.c map.h battle.h itemdb.h $(COMMON_H) +txtobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h date.h irc.h $(COMMON_H) +txtobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h irc.h $(COMMON_H) +txtobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h $(COMMON_H) +txtobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h date.h $(COMMON_H) +txtobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) +txtobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h $(COMMON_H) +txtobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h $(COMMON_H) +txtobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h $(COMMON_H) +txtobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h $(COMMON_H) +txtobj/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h irc.h $(COMMON_H) +txtobj/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h $(COMMON_H) +txtobj/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h $(COMMON_H) +txtobj/log.o: log.c log.h map.h $(COMMON_H) +txtobj/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) +txtobj/date.o: date.c date.h $(COMMON_H) +txtobj/irc.o: irc.c irc.h map.h pc.h $(COMMON_H) +txtobj/unit.o: unit.c unit.h $(COMMON_H) +txtobj/mercenary.o: mercenary.c mercenary.h $(COMMON_H) + +sqlobj/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h log.h irc.h $(COMMON_H) +sqlobj/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h $(COMMON_H) +sqlobj/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h $(COMMON_H) +sqlobj/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h log.h $(COMMON_H) +sqlobj/status.o: status.c pc.h map.h clif.h status.h mob.h itemdb.h battle.h skill.h script.h pet.h guild.h $(COMMON_H) +sqlobj/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) +sqlobj/npc_chat.o: npc_chat.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) +sqlobj/chat.o: chat.c map.h clif.h pc.h chat.h $(COMMON_H) +sqlobj/path.o: path.c map.h battle.h $(COMMON_H) +sqlobj/itemdb.o: itemdb.c map.h battle.h itemdb.h $(COMMON_H) +sqlobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h log.h date.h irc.h $(COMMON_H) +sqlobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h irc.h $(COMMON_H) +sqlobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h $(COMMON_H) +sqlobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h log.h date.h $(COMMON_H) +sqlobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) +sqlobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h $(COMMON_H) +sqlobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h $(COMMON_H) +sqlobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h log.h $(COMMON_H) +sqlobj/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h $(COMMON_H) +sqlobj/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h log.h irc.h $(COMMON_H) +sqlobj/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h irc.h $(COMMON_H) +sqlobj/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h $(COMMON_H) +sqlobj/mail.o: mail.c mail.h $(COMMON_H) +sqlobj/log.o: log.c log.h map.h $(COMMON_H) +sqlobj/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) +sqlobj/charsave.o: charsave.c charsave.h $(COMMON_H) +sqlobj/date.o: date.c date.h $(COMMON_H) +sqlobj/irc.o: irc.c irc.h map.h pc.h $(COMMON_H) +sqlobj/unit.o: unit.c unit.h $(COMMON_H) +sqlobj/mercenary.o: mercenary.c mercenary.h $(COMMON_H) diff --git a/src/map/npc.c b/src/map/npc.c index 8e2a0d009..95cb4b177 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2943,7 +2943,7 @@ int do_final_npc(void) if ((bl = map_id2bl(i))){ if (bl->type == BL_NPC) npc_unload((struct npc_data *)bl); - else if (bl->type&(BL_MOB|BL_PET))//## why BL_PET? [FlavioJS] //## Because this is invoked after saving/wiping all players, which would include all pets. This bit of code will take care of any pets without a master that are still lingering in the map. [Skotlex] + else if (bl->type&(BL_MOB|BL_PET))//# why BL_PET? [FlavioJS] //# Because this is invoked after saving/wiping all players, which would include all pets. This bit of code will take care of any pets without a master that are still lingering in the map. [Skotlex] unit_free(bl, 0); } } diff --git a/src/map/script.c b/src/map/script.c index f94b0163a..e13edd1c4 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -499,12 +499,11 @@ static const char *skip_word(const char *p) if(*p=='#') p++; // account変数用 if(*p=='#') p++; // ワールドaccount変数用 - while(isalnum(*p)||*p=='_'|| *p>=0x81) { //#FIXME: Changing from unsigned char to signed char makes p never be able to go above 0x81, but what IS 0x81 for? - if(*p>=0x81 && p[1]){ - p+=2; - } else - p++; - } + //# Changing from unsigned char to signed char makes p never be able to go above 0x81, but what IS 0x81 for? [Skotlex] + //# It's for multibyte encodings like Shift-JIS. Unfortunately this can be problematic for singlebyte encodings. + // Using (*p)>>7 would yield the appropriate result but it's better to restrict words to ASCII characters only. [FlavioJS] + while( ISALNUM(*p) || *p == '_' ) + p++; // postfix if(*p=='$') p++; // 文字列変数 @@ -989,7 +988,7 @@ const char* parse_syntax(const char* p) { } break; case 'c': - if(!strncmp(p,"case",4) && !isalpha(*(p + 4))) { + if(!strncmp(p,"case",4) && !ISALPHA(p[4])) { // case の処理 if(syntax.curly_count <= 0 || syntax.curly[syntax.curly_count - 1].type != TYPE_SWITCH) { disp_error_message("parse_syntax: unexpected 'case' ",p); @@ -1044,7 +1043,7 @@ const char* parse_syntax(const char* p) { syntax.curly[pos].count++; } return p + 1; - } else if(!strncmp(p,"continue",8) && !isalpha(*(p + 8))) { + } else if(!strncmp(p,"continue",8) && !ISALPHA(p[8])) { // continue の処理 char label[256]; int pos = syntax.curly_count - 1; @@ -1077,7 +1076,7 @@ const char* parse_syntax(const char* p) { } break; case 'd': - if(!strncmp(p,"default",7) && !isalpha(p[7])) { + if(!strncmp(p,"default",7) && !ISALPHA(p[7])) { // switch - default の処理 if(syntax.curly_count <= 0 || syntax.curly[syntax.curly_count - 1].type != TYPE_SWITCH) { disp_error_message("parse_syntax: unexpected 'default'",p); @@ -1117,7 +1116,7 @@ const char* parse_syntax(const char* p) { p = skip_word(p); return p + 1; } - } else if(!strncmp(p,"do",2) && !isalpha(*(p + 2))) { + } else if(!strncmp(p,"do",2) && !ISALPHA(p[2])) { int l; char label[256]; p=skip_word(p); @@ -1136,7 +1135,7 @@ const char* parse_syntax(const char* p) { } break; case 'f': - if(!strncmp(p,"for",3) && !isalpha(*(p + 3))) { + if(!strncmp(p,"for",3) && !ISALPHA(p[3])) { int l; char label[256]; int pos = syntax.curly_count; @@ -1215,7 +1214,7 @@ const char* parse_syntax(const char* p) { l=add_str(label); set_label(l,script_pos,p); return p; - } else if(!strncmp(p,"function",8) && !isalpha(*(p + 8))) { + } else if(!strncmp(p,"function",8) && !ISALPHA(p[8])) { const char *func_name; // function p=skip_word(p); @@ -1257,7 +1256,7 @@ const char* parse_syntax(const char* p) { } break; case 'i': - if(!strncmp(p,"if",2) && !isalpha(*(p + 2))) { + if(!strncmp(p,"if",2) && !ISALPHA(p[2])) { // if() の処理 char label[256]; p=skip_word(p); @@ -1279,7 +1278,7 @@ const char* parse_syntax(const char* p) { } break; case 's': - if(!strncmp(p,"switch",6) && !isalpha(*(p + 6))) { + if(!strncmp(p,"switch",6) && !ISALPHA(p[6])) { // switch() の処理 char label[256]; syntax.curly[syntax.curly_count].type = TYPE_SWITCH; @@ -1303,7 +1302,7 @@ const char* parse_syntax(const char* p) { } break; case 'w': - if(!strncmp(p,"while",5) && !isalpha(*(p + 5))) { + if(!strncmp(p,"while",5) && !ISALPHA(p[5])) { int l; char label[256]; p=skip_word(p); @@ -1371,11 +1370,11 @@ const char* parse_syntax_close_sub(const char* p,int* flag) { syntax.curly[pos].count++; p = skip_space(p); - if(!syntax.curly[pos].flag && !strncmp(p,"else",4) && !isalpha(*(p + 4))) { + if(!syntax.curly[pos].flag && !strncmp(p,"else",4) && !ISALPHA(p[4])) { // else or else - if p = skip_word(p); p = skip_space(p); - if(!strncmp(p,"if",2) && !isalpha(*(p + 2))) { + if(!strncmp(p,"if",2) && !ISALPHA(p[2])) { // else - if p=skip_word(p); p=skip_space(p); @@ -11326,7 +11325,7 @@ int buildin_charisalpha(struct script_state *st) { char *str=conv_str(st,& (st->stack->stack_data[st->start+2])); int pos=conv_num(st,& (st->stack->stack_data[st->start+3])); - int val = ( str && pos>0 && (unsigned int)pos0 && (unsigned int)posstack,C_INT,val); return 0; @@ -11366,9 +11365,9 @@ int buildin_compare(struct script_state *st) { message = conv_str(st,& (st->stack->stack_data[st->start+2])); cmpstring = conv_str(st,& (st->stack->stack_data[st->start+3])); for (j = 0; message[j]; j++) - message[j] = tolower(message[j]); + message[j] = TOLOWER(message[j]); for (j = 0; cmpstring[j]; j++) - cmpstring[j] = tolower(cmpstring[j]); + cmpstring[j] = TOLOWER(cmpstring[j]); push_val(st->stack,C_INT,(strstr(message,cmpstring) != NULL)); return 0; } diff --git a/src/plugins/Makefile b/src/plugins/Makefile index 183905a46..7d100e591 100644 --- a/src/plugins/Makefile +++ b/src/plugins/Makefile @@ -42,7 +42,7 @@ upnp.$(PLUGINEXT): ../../plugins/upnp.conf depend: makedepend -fGNUmakefile -o.$(PLUGINEXT) -Y. -Y../common *.c clean: - rm -rf $(PLUGINS) + rm -rf $(PLUGINS) GNUmakefile # DO NOT DELETE diff --git a/src/tool/Makefile b/src/tool/Makefile index d8614c300..12f62e373 100644 --- a/src/tool/Makefile +++ b/src/tool/Makefile @@ -1,10 +1,10 @@ -all: adduser convert - -adduser: - $(CC) -o ../../tools/$@ adduser.c - -convert: - $(CC) -o ../../tools/$@ convert.c - -clean: - rm -rf ../../tools/adduser ../../tools/convert +all: adduser convert + +adduser: + $(CC) -o ../../tools/$@ adduser.c + +convert: + $(CC) -o ../../tools/$@ convert.c + +clean: + rm -rf ../../tools/adduser ../../tools/convert diff --git a/src/txt-converter/Makefile b/src/txt-converter/Makefile index 2e40e838d..aa559e915 100644 --- a/src/txt-converter/Makefile +++ b/src/txt-converter/Makefile @@ -1,24 +1,24 @@ -all sql: char-converter login-converter - -char-converter: char-converter.o ../common/obj/minicore.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o \ - ../common/obj/mapindex.o ../common/obj/ers.o ../common/obj/utils.o \ - ../char/char.o ../char/int_pet.o ../char/int_storage.o ../char/inter.o \ - ../char/int_party.o ../char/int_guild.o \ - ../char_sql/char.o ../char_sql/int_pet.o ../char_sql/int_storage.o \ - ../char_sql/inter.o ../char_sql/int_party.o ../char_sql/int_guild.o - $(CC) -o ../../tools/$@ $^ $(LIB_S) - -login-converter: login-converter.o ../common/obj/minicore.o ../common/obj/db.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/ers.o ../common/obj/utils.o - $(CC) -o ../../tools/$@ $^ $(LIB_S) - -clean: - rm -f *.o ../../tools/login-converter ../../tools/char-converter - -# DO NOT DELETE - -%.o: %.c - $(COMPILE.c) -DTXT_SQL_CONVERT $(OUTPUT_OPTION) $< - -char-converter.o: char-converter.c -login-converter.o: login-converter.c +all sql: char-converter login-converter + +char-converter: char-converter.o ../common/obj/minicore.o \ + ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o \ + ../common/obj/mapindex.o ../common/obj/ers.o ../common/obj/utils.o \ + ../char/char.o ../char/int_pet.o ../char/int_storage.o ../char/inter.o \ + ../char/int_party.o ../char/int_guild.o \ + ../char_sql/char.o ../char_sql/int_pet.o ../char_sql/int_storage.o \ + ../char_sql/inter.o ../char_sql/int_party.o ../char_sql/int_guild.o + $(CC) -o ../../tools/$@ $^ $(LIB_S) + +login-converter: login-converter.o ../common/obj/minicore.o ../common/obj/db.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/ers.o ../common/obj/utils.o + $(CC) -o ../../tools/$@ $^ $(LIB_S) + +clean: + rm -f *.o ../../tools/login-converter ../../tools/char-converter + +# DO NOT DELETE + +%.o: %.c + $(COMPILE.c) -DTXT_SQL_CONVERT $(OUTPUT_OPTION) $< + +char-converter.o: char-converter.c +login-converter.o: login-converter.c diff --git a/src/webserver/Makefile b/src/webserver/Makefile index 149f5a900..077b39980 100644 --- a/src/webserver/Makefile +++ b/src/webserver/Makefile @@ -1,20 +1,20 @@ -all: - #Generate framework... - $(CC) -c parse.c - $(CC) -c generate.c - $(CC) -c htmlstyle.c - $(CC) -c logs.c - - #Generate "pages"... - cd pages && $(CC) -c about.c && cd .. - cd pages && $(CC) -c sample.c && cd .. - cd pages && $(CC) -c notdone.c && cd .. - - #Building the server... - $(CC) -o webserver main.c parse.o generate.o htmlstyle.o \ - logs.o pages/about.o pages/sample.o pages/notdone.o - -clean: - rm -f *.o - rm -f pages/*.o - rm -f webserver +all: + #Generate framework... + $(CC) -c parse.c + $(CC) -c generate.c + $(CC) -c htmlstyle.c + $(CC) -c logs.c + + #Generate "pages"... + cd pages && $(CC) -c about.c && cd .. + cd pages && $(CC) -c sample.c && cd .. + cd pages && $(CC) -c notdone.c && cd .. + + #Building the server... + $(CC) -o webserver main.c parse.o generate.o htmlstyle.o \ + logs.o pages/about.o pages/sample.o pages/notdone.o + +clean: + rm -f *.o + rm -f pages/*.o + rm -f webserver diff --git a/src/zlib/Makefile b/src/zlib/Makefile index 21bd6cf37..7ba1cb382 100644 --- a/src/zlib/Makefile +++ b/src/zlib/Makefile @@ -1,21 +1,21 @@ - -OBJS = unzip.o ioapi.o - -ifeq ($(findstring MINGW,$(CFLAGS)), MINGW) - OBJS += iowin32.o -endif - -.c.o: - $(CC) -c $(CFLAGS) $*.c - -all: unz.o - -unz.o: $(OBJS) - ar rcs $@ $(OBJS) - -clean: - rm -f *.o - -# DO NOT DELETE -ioapi.o: ioapi.h -unzip.o: unzip.h ioapi.h crypt.h + +OBJS = unzip.o ioapi.o + +ifeq ($(findstring MINGW,$(CFLAGS)), MINGW) + OBJS += iowin32.o +endif + +.c.o: + $(CC) -c $(CFLAGS) $*.c + +all: unz.o + +unz.o: $(OBJS) + ar rcs $@ $(OBJS) + +clean: + rm -f *.o + +# DO NOT DELETE +ioapi.o: ioapi.h +unzip.o: unzip.h ioapi.h crypt.h diff --git a/vcproj-7.1/char-server_sql.vcproj b/vcproj-7.1/char-server_sql.vcproj index fc6acfcc5..1725511c3 100644 --- a/vcproj-7.1/char-server_sql.vcproj +++ b/vcproj-7.1/char-server_sql.vcproj @@ -1,309 +1,309 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcproj-7.1/char-server_txt.vcproj b/vcproj-7.1/char-server_txt.vcproj index 1d623cf05..a4b639a13 100644 --- a/vcproj-7.1/char-server_txt.vcproj +++ b/vcproj-7.1/char-server_txt.vcproj @@ -1,301 +1,301 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcproj-7.1/login-server_sql.vcproj b/vcproj-7.1/login-server_sql.vcproj index c9a0c2eb2..7cec00189 100644 --- a/vcproj-7.1/login-server_sql.vcproj +++ b/vcproj-7.1/login-server_sql.vcproj @@ -1,263 +1,263 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcproj-7.1/login-server_txt.vcproj b/vcproj-7.1/login-server_txt.vcproj index 8a10a99cf..035b9d474 100644 --- a/vcproj-7.1/login-server_txt.vcproj +++ b/vcproj-7.1/login-server_txt.vcproj @@ -1,265 +1,265 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcproj-7.1/map-server_sql.vcproj b/vcproj-7.1/map-server_sql.vcproj index ba6888a18..abd160a2b 100644 --- a/vcproj-7.1/map-server_sql.vcproj +++ b/vcproj-7.1/map-server_sql.vcproj @@ -1,442 +1,442 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcproj-7.1/map-server_txt.vcproj b/vcproj-7.1/map-server_txt.vcproj index 076502746..ce3face56 100644 --- a/vcproj-7.1/map-server_txt.vcproj +++ b/vcproj-7.1/map-server_txt.vcproj @@ -1,443 +1,443 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcproj-8/char-server_sql.vcproj b/vcproj-8/char-server_sql.vcproj index 0bfd5d2d2..a42fa47b8 100644 --- a/vcproj-8/char-server_sql.vcproj +++ b/vcproj-8/char-server_sql.vcproj @@ -1,306 +1,306 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcproj-8/char-server_txt.vcproj b/vcproj-8/char-server_txt.vcproj index 66bcfd8ea..f9ea2adca 100644 --- a/vcproj-8/char-server_txt.vcproj +++ b/vcproj-8/char-server_txt.vcproj @@ -1,304 +1,304 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcproj-8/login-server_sql.vcproj b/vcproj-8/login-server_sql.vcproj index c764c256d..cf0df29f7 100644 --- a/vcproj-8/login-server_sql.vcproj +++ b/vcproj-8/login-server_sql.vcproj @@ -1,281 +1,281 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcproj-8/login-server_txt.vcproj b/vcproj-8/login-server_txt.vcproj index e87e629fa..d4a089706 100644 --- a/vcproj-8/login-server_txt.vcproj +++ b/vcproj-8/login-server_txt.vcproj @@ -1,284 +1,284 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcproj-8/map-server_sql.vcproj b/vcproj-8/map-server_sql.vcproj index d02257a23..f5257e45f 100644 --- a/vcproj-8/map-server_sql.vcproj +++ b/vcproj-8/map-server_sql.vcproj @@ -1,394 +1,394 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcproj-8/map-server_txt.vcproj b/vcproj-8/map-server_txt.vcproj index 947759cb0..2d6402f7e 100644 --- a/vcproj-8/map-server_txt.vcproj +++ b/vcproj-8/map-server_txt.vcproj @@ -1,396 +1,396 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-70-g09d2 From 34f200c644ba8598448e20f4aa69a504e55d3c8f Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Fri, 22 Dec 2006 05:27:03 +0000 Subject: - Change strncpy to memcpy when parsing switches in the script engine since it's guaranteed to be a word of that size (skip_word). - Made scriptlabel_db duplicate the key. When str_buf is reallocated, the keys in scriptlabel_db could become invalid, causing a crash in npc_convertlabel_db. ( removed the readded >=0x81 equivalent ) - Now npc_convertlabel_db clears scriptlabel_db after using it. - parse_script has an extra parameter options. At the moment it only indicates if scriptlabel_db should be used or not. - Fixed "UINT_MAX undeclared" on systems that don't declare it in limits.h git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9557 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 11 +++++++ src/common/cbasetypes.h | 4 +++ src/common/db.h | 2 +- src/common/timer.c | 6 ++-- src/map/itemdb.c | 10 +++---- src/map/npc.c | 26 ++++++++--------- src/map/pet.c | 2 +- src/map/script.c | 77 +++++++++++++++++++++++++------------------------ src/map/script.h | 6 +++- 9 files changed, 83 insertions(+), 61 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 8f54fe8c1..6a4ea4e7d 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,17 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2006/12/22 + * Change strncpy to memcpy when parsing switches in the script engine + since it's guaranteed to be a word of that size (skip_word). + * Made scriptlabel_db duplicate the key. When str_buf is reallocated, the + keys in scriptlabel_db could become invalid, causing a crash in + npc_convertlabel_db. + * Now npc_convertlabel_db clears scriptlabel_db after using it. + * parse_script has an extra parameter options. At the moment it only + indicates if scriptlabel_db should be used or not. + * Fixed "UINT_MAX undeclared" on systems that don't declare it in limits.h + [FlavioJS] 2006/12/21 * Applied Rayce's suggestions and fixes to the script engine (http://www.eathena.ws/board/index.php?showtopic=129185) diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index c61424191..3a3bde818 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -126,6 +126,10 @@ typedef unsigned int uint32; #define SINT16_MAX ((sint16)0x7FFF) #define SINT32_MAX ((sint32)0x7FFFFFFF) +// ILP64 isn't supported, so always 32 bits? +#ifndef UINT_MAX +#define UINT_MAX 0xFFFFFFFF +#endif ////////////////////////////////////////////////////////////////////////// // Integers with guaranteed _minimum_ size. diff --git a/src/common/db.h b/src/common/db.h index aa165acd7..a79c88822 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -130,7 +130,7 @@ typedef enum { * @see #db_default_release(DBType,DBOptions) * @see #db_alloc(const char *,int,DBType,DBOptions,unsigned short) */ -typedef enum { +typedef enum db_opt { DB_OPT_BASE = 0, DB_OPT_DUP_KEY = 1, DB_OPT_RELEASE_KEY = 2, diff --git a/src/common/timer.c b/src/common/timer.c index cf71f2ffc..63a06acc2 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -18,9 +18,11 @@ #include #include #include + +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" #include "timer.h" -#include "malloc.h" -#include "showmsg.h" // タイマー間隔の最小値。モンスターの大量召還時、多数のクライアント接続時に // サーバーが反応しなくなる場合は、TIMER_MIN_INTERVAL を増やしてください。 diff --git a/src/map/itemdb.c b/src/map/itemdb.c index b6626fa41..68a61724f 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1146,11 +1146,11 @@ static int itemdb_readdb(void) np = strchr(np+1,'}'); //Jump close brackets until the next field is found. if (!np || !np[1]) { //Couldn't find the end of the script field. - id->script = parse_script((unsigned char *) str[19],filename[i],lines); + id->script = parse_script(str[19],filename[i],lines,0); continue; } np[1] = '\0'; //Set end of script - id->script = parse_script((unsigned char *) str[19],filename[i],lines); + id->script = parse_script(str[19],filename[i],lines,0); np+=2; //Skip to next field if(!np || (p=strchr(np,'{'))==NULL) @@ -1163,18 +1163,18 @@ static int itemdb_readdb(void) np = strchr(np+1,'}'); //Jump close brackets until the next field is found. if (!np || !np[1]) { //Couldn't find the end of the script field. - id->equip_script = parse_script((unsigned char *) str[20],filename[i],lines); + id->equip_script = parse_script(str[20],filename[i],lines,0); continue; } np[1] = '\0'; //Set end of script - id->equip_script = parse_script((unsigned char *) str[20],filename[i],lines); + id->equip_script = parse_script(str[20],filename[i],lines,0); np+=2; //Skip comma, to next field if(!np || (p=strchr(np,'{'))==NULL) continue; //Unequip script, last column. - id->unequip_script = parse_script((unsigned char *) p,filename[i],lines); + id->unequip_script = parse_script(p,filename[i],lines,0); } fclose(fp); if (ln > 0) { diff --git a/src/map/npc.c b/src/map/npc.c index 95cb4b177..4118b79ea 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1725,13 +1725,13 @@ static int npc_parse_shop (char *w1, char *w2, char *w3, char *w4) */ int npc_convertlabel_db (DBKey key, void *data, va_list ap) { - unsigned char *lname = key.str; + const char *lname = (const char*)key.str; int pos = (int)data; struct npc_data *nd; struct npc_label_list *lst; int num; - char *p; - char c; + const char *p; + int len; nullpo_retr(0, ap); nullpo_retr(0, nd = va_arg(ap,struct npc_data *)); @@ -1746,18 +1746,17 @@ int npc_convertlabel_db (DBKey key, void *data, va_list ap) // In case of labels not terminated with ':', for user defined function support p = lname; - while(isalnum(*(unsigned char*)p) || *p == '_') { p++; } - c = *p; - *p='\0'; + while( ISALNUM(*p) || *p == '_' ) + p++; + len = p-lname; // here we check if the label fit into the buffer - if (strlen(lname) > 23) { + if (len > 23) { ShowError("npc_parse_script: label name longer than 23 chars! '%s'\n (%s)", lname, current_file); exit(1); } - memcpy(lst[num].name, lname, strlen(lname)+1); //including EOS - - *p = c; + memcpy(lst[num].name, lname, len); + lst[num].name[len]=0; lst[num].pos = pos; nd->u.scr.label_list = lst; nd->u.scr.label_list_num = num+1; @@ -1868,7 +1867,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line unsigned char line[1024]; int i; struct npc_data *nd, *dnd; - struct dbt *label_db; + DB label_db; char *p; struct npc_label_list *label_dup = NULL; int label_dupnum = 0; @@ -1920,7 +1919,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line script = NULL; } else { // printf("Ok line %d\n",*lines); - script = parse_script((unsigned char *) srcbuf, file, startline); + script = parse_script(srcbuf, file, startline, SCRIPT_USE_LABEL_DB); } if (script == NULL) { // script parse error? @@ -2039,6 +2038,7 @@ static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line // ラベルデータのコンバート label_db = script_get_label_db(); label_db->foreach(label_db, npc_convertlabel_db, nd); + label_db->clear(label_db,NULL); // not needed anymore, so clear the db // もう使わないのでバッファ解放 aFree(srcbuf); @@ -2156,7 +2156,7 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *fir ShowError("Missing right curly at file %s, line %d\n",file, *lines); script = NULL; } else { - script = parse_script(srcbuf, file, startline); + script = parse_script(srcbuf, file, startline,0); } if (script == NULL) { // script parse error? diff --git a/src/map/pet.c b/src/map/pet.c index 035514bd1..50433aab3 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -1351,7 +1351,7 @@ int read_petdb() pet_db[j].script = NULL; if((np=strchr(p,'{'))==NULL) continue; - pet_db[j].script = parse_script((unsigned char *) np, filename[i], lines); + pet_db[j].script = parse_script(np, filename[i], lines, 0); j++; } if (j >= MAX_PET_DB) diff --git a/src/map/script.c b/src/map/script.c index 5f4de13e4..8357c094d 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -88,6 +88,7 @@ char mapreg_txt[256]="save/mapreg.txt"; static struct dbt *scriptlabel_db=NULL; static struct dbt *userfunc_db=NULL; +static int parse_options=0; struct dbt* script_get_label_db(){ return scriptlabel_db; } struct dbt* script_get_userfunc_db(){ return userfunc_db; } @@ -158,7 +159,7 @@ int mapreg_setreg(int num,int val); int mapreg_setregstr(int num,const char *str); static void disp_error_message(const char *mes,const char *pos); -enum { +enum c_op { C_NOP,C_POS,C_INT,C_PARAM,C_FUNC,C_STR,C_CONSTSTR,C_ARG, C_NAME,C_EOL, C_RETINFO, C_USERFUNC, C_USERFUNC_POS, // user defined functions @@ -502,12 +503,8 @@ static const char *skip_word(const char *p) //# Changing from unsigned char to signed char makes p never be able to go above 0x81, but what IS 0x81 for? [Skotlex] //# It's for multibyte encodings like Shift-JIS. Unfortunately this can be problematic for singlebyte encodings. // Using (*p)>>7 would yield the appropriate result but it's better to restrict words to ASCII characters only. [FlavioJS] - while( ISALNUM(*p) || *p == '_' || (*p)>>7 ) - { - if( (*p)>>7 ) // readded the >=0x81 equivalent until I figure out where the script engine is 'being naughty' O.o [FlavioJS] - ++p; + while( ISALNUM(*p) || *p == '_' ) ++p; - } // postfix if(*p=='$') p++; // 文字列変数 @@ -1020,12 +1017,12 @@ const char* parse_syntax(const char* p) { p = skip_space(p); p2 = p; p = skip_word(p); - len = p-p2; + len = p-p2; // length of word at p2 p = skip_space(p); if(*p != ':') disp_error_message("parse_syntax: expect ':'",p); memcpy(label,"if(",3); - strncpy(label+3,p2,len); + memcpy(label+3,p2,len); sprintf(label+3+len," != $@__SW%x_VAL) goto __SW%x_%x;", syntax.curly[pos].index,syntax.curly[pos].index,syntax.curly[pos].count+1); syntax.curly[syntax.curly_count++].type = TYPE_NULL; @@ -1254,7 +1251,8 @@ const char* parse_syntax(const char* p) { if(str_data[l].type == C_NOP) str_data[l].type = C_USERFUNC; set_label(l,script_pos,p); - strdb_put(scriptlabel_db, GETSTRING(str_data[l].str), (void*)script_pos); + if( parse_options&SCRIPT_USE_LABEL_DB ) + strdb_put(scriptlabel_db, GETSTRING(str_data[l].str), (void*)script_pos); return skip_space(p); } } @@ -1562,7 +1560,22 @@ static void read_constdb(void) *------------------------------------------ */ -const char* script_print_line( const char *p, const char *mark, int line ); +const char* script_print_line( const char *p, const char *mark, int line ) { + int i; + if( p == NULL || !p[0] ) return NULL; + if( line < 0 ) + printf("*% 5d : ", -line); + else + printf(" % 5d : ", line); + for(i=0;p[i] && p[i] != '\n';i++){ + if(p + i != mark) + printf("%c",p[i]); + else + printf("\'%c\'",p[i]); + } + printf("\n"); + return p+i+(p[i] == '\n' ? 1 : 0); +} void script_error(const char *src,const char *file,int start_line, const char *error_msg, const char *error_pos) { // エラーが発生した行を求める @@ -1595,29 +1608,12 @@ void script_error(const char *src,const char *file,int start_line, const char *e } } -const char* script_print_line( const char *p, const char *mark, int line ) { - int i; - if( p == NULL || !p[0] ) return NULL; - if( line < 0 ) - printf("*% 5d : ", -line); - else - printf(" % 5d : ", line); - for(i=0;p[i] && p[i] != '\n';i++){ - if(p + i != mark) - printf("%c",p[i]); - else - printf("\'%c\'",p[i]); - } - printf("\n"); - return p+i+(p[i] == '\n' ? 1 : 0); -} - /*========================================== * スクリプトの解析 *------------------------------------------ */ -struct script_code* parse_script(const char *src,const char *file,int line) +struct script_code* parse_script(const char *src,const char *file,int line,int options) { const char *p,*tmpp; int i; @@ -1648,8 +1644,11 @@ struct script_code* parse_script(const char *src,const char *file,int line) } } - //Labels must be reparsed for the script.... - scriptlabel_db->clear(scriptlabel_db, NULL); + // who called parse_script is responsible for clearing the database after using it, but just in case... lets clear it here + if( options&SCRIPT_USE_LABEL_DB ) + scriptlabel_db->clear(scriptlabel_db, NULL); + parse_options = options; + if( setjmp( error_jump ) != 0 ) { //Restore program state when script has problems. [from jA] script_error(src,file,line,error_msg,error_pos); @@ -1688,7 +1687,8 @@ struct script_code* parse_script(const char *src,const char *file,int line) if(*tmpp==':' && !(!strncmp(p,"default:",8) && p + 7 == tmpp)){ i=add_word(p); set_label(i,script_pos,p); - strdb_put(scriptlabel_db, GETSTRING(str_data[i].str), (void*)script_pos); + if( parse_options&SCRIPT_USE_LABEL_DB ) + strdb_put(scriptlabel_db, GETSTRING(str_data[i].str), (void*)script_pos); p=tmpp+1; continue; } @@ -1955,8 +1955,9 @@ char* conv_str(struct script_state *st,struct script_data *data) get_val(st,data); if(data->type==C_INT){ char *buf; - buf=(char *)aMallocA(ITEM_NAME_LENGTH*sizeof(char)); + CREATE(buf,char,ITEM_NAME_LENGTH); snprintf(buf,ITEM_NAME_LENGTH, "%d",data->u.num); + buf[ITEM_NAME_LENGTH-1]=0; data->type=C_STR; data->u.str=buf; } else if(data->type==C_POS) { @@ -3273,7 +3274,7 @@ int do_init_script() mapreg_db= db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_BASE,sizeof(int)); mapregstr_db=db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_RELEASE_DATA,sizeof(int)); userfunc_db=db_alloc(__FILE__,__LINE__,DB_STRING,DB_OPT_RELEASE_BOTH,50); - scriptlabel_db=db_alloc(__FILE__,__LINE__,DB_STRING,DB_OPT_ALLOW_NULL_DATA,50); + scriptlabel_db=db_alloc(__FILE__,__LINE__,DB_STRING,DB_OPT_DUP_KEY|DB_OPT_ALLOW_NULL_DATA,50); script_load_mapreg(); @@ -3978,9 +3979,9 @@ struct script_function buildin_func[] = { int buildin_mes(struct script_state *st) { struct map_session_data *sd = script_rid2sd(st); - conv_str(st,& (st->stack->stack_data[st->start+2])); + char *mes = conv_str(st, &(st->stack->stack_data[st->start+2])); if (sd) - clif_scriptmes(sd,st->oid,st->stack->stack_data[st->start+2].u.str); + clif_scriptmes(sd, st->oid, mes); return 0; } @@ -11306,9 +11307,9 @@ int buildin_setbattleflag(struct script_state *st){ value = conv_str(st,& (st->stack->stack_data[st->start+3])); if (battle_set_value(flag, value) == 0) - ShowWarning("buildin_setbattleflag: unknown battle_config flag '%s'",flag); + ShowWarning("buildin_setbattleflag: unknown battle_config flag '%s'\n",flag); else - ShowInfo("buildin_setbattleflag: battle_config flag '%s' is now set to '%s'.",flag,value); + ShowInfo("buildin_setbattleflag: battle_config flag '%s' is now set to '%s'.\n",flag,value); return 0; } @@ -11800,7 +11801,7 @@ int buildin_setitemscript(struct script_state *st) if (i_data && script!=NULL && script[0]=='{') { if(i_data->script!=NULL) script_free_code(i_data->script); - i_data->script = parse_script(script, "script_setitemscript", 0); + i_data->script = parse_script(script, "script_setitemscript", 0, 0); push_val(st->stack,C_INT,1); } else push_val(st->stack,C_INT,0); diff --git a/src/map/script.h b/src/map/script.h index bc142c125..7ab7e1876 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -61,7 +61,11 @@ struct script_state { } sleep; }; -struct script_code* parse_script(const char* src,const char* file,int line); +enum script_parse_options { + SCRIPT_USE_LABEL_DB = 0x1 +}; + +struct script_code* parse_script(const char* src,const char* file,int line,int options); void run_script_sub(struct script_code *rootscript,int pos,int rid,int oid, char* file, int lineno); void run_script(struct script_code*,int,int,int); -- cgit v1.2.3-70-g09d2 From d28762e63974a9dbe1e642829df185cdd40abde5 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Sat, 23 Dec 2006 03:24:32 +0000 Subject: - Moved "#include " to cbasetypes.h to ensure it's included before checking if UINT_MAX has been defined. - Minor changes in pc_readdb related to max_level being unsigned. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9561 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 5 +++++ src/char/char.c | 2 +- src/char/int_guild.c | 2 +- src/char/int_party.c | 2 +- src/char_sql/char.c | 5 +++-- src/char_sql/int_guild.c | 4 ++-- src/char_sql/int_party.c | 6 ++++-- src/common/cbasetypes.h | 11 ++++++----- src/common/timer.c | 1 - src/map/atcommand.c | 2 +- src/map/battle.c | 4 ++-- src/map/charcommand.c | 2 +- src/map/charsave.c | 2 +- src/map/chrif.c | 2 +- src/map/clif.c | 3 +-- src/map/guild.c | 2 +- src/map/mercenary.c | 2 +- src/map/mob.c | 2 +- src/map/npc.c | 2 +- src/map/party.c | 2 +- src/map/pc.c | 33 ++++++++++++++++----------------- src/map/script.c | 3 +-- src/map/skill.c | 2 +- src/map/status.c | 12 ++++++------ 24 files changed, 59 insertions(+), 54 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 775b833e8..726c974dd 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,11 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2006/12/23 + * Moved "#include " to cbasetypes.h to ensure it's included + before checking if UINT_MAX has been defined. + * Minor changes in pc_readdb related to max_level being unsigned. + [FlavioJS] 2006/12/22 * Simplified function agitcheck so it isn't crash prone. Now it takes no arguments, and will return whether WoE is on or not. diff --git a/src/char/char.c b/src/char/char.c index a95a1cfda..b6dc3bdba 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -18,8 +18,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/strlib.h" #include "../common/core.h" #include "../common/socket.h" diff --git a/src/char/int_guild.c b/src/char/int_guild.c index e6c4105c8..bc17f2ff1 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -4,8 +4,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/socket.h" #include "../common/db.h" diff --git a/src/char/int_party.c b/src/char/int_party.c index be8c6a04c..ed4424d5e 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -4,8 +4,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/socket.h" #include "../common/db.h" diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 0333798d1..3ff9adb05 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -21,17 +21,18 @@ #include #include #include -#include -#include "char.h" +#include "../common/cbasetypes.h" #include "../common/utils.h" #include "../common/strlib.h" #include "../common/showmsg.h" + #include "itemdb.h" #include "inter.h" #include "db.h" #include "malloc.h" #include "int_guild.h" +#include "char.h" #ifndef TXT_SQL_CONVERT static struct dbt *char_db_; diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index 9132f9ec2..8ef59b62b 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -7,9 +7,8 @@ #include #include #include -#include -#include "char.h" +#include "../common/cbasetypes.h" #include "../common/strlib.h" #include "../common/showmsg.h" // #include "int_storage.h" @@ -19,6 +18,7 @@ #include "socket.h" #include "db.h" #include "malloc.h" +#include "char.h" #define GS_MEMBER_UNMODIFIED 0x00 #define GS_MEMBER_MODIFIED 0x01 diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c index e39c826d4..025c14e31 100644 --- a/src/char_sql/int_party.c +++ b/src/char_sql/int_party.c @@ -7,13 +7,15 @@ #include #include #include -#include -#include "char.h" + +#include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/strlib.h" #include "../common/socket.h" #include "../common/showmsg.h" +#include "char.h" + #ifndef TXT_SQL_CONVERT struct party_data { struct party party; diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 3a3bde818..76f494851 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -59,6 +59,12 @@ // only Silicon Graphics/Cray goes ILP64 so don't care (and don't support) ////////////////////////////////////////////////////////////////////////// +#include +// ILP64 isn't supported, so always 32 bits? +#ifndef UINT_MAX +#define UINT_MAX 0xffffffff +#endif + ////////////////////////////////////////////////////////////////////////// // Integers with guaranteed _exact_ size. ////////////////////////////////////////////////////////////////////////// @@ -126,11 +132,6 @@ typedef unsigned int uint32; #define SINT16_MAX ((sint16)0x7FFF) #define SINT32_MAX ((sint32)0x7FFFFFFF) -// ILP64 isn't supported, so always 32 bits? -#ifndef UINT_MAX -#define UINT_MAX 0xFFFFFFFF -#endif - ////////////////////////////////////////////////////////////////////////// // Integers with guaranteed _minimum_ size. // These could be larger than you expect, diff --git a/src/common/timer.c b/src/common/timer.c index 63a06acc2..3b4fb1db4 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -13,7 +13,6 @@ #include #endif -#include #include #include #include diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 2ee492e53..a6c92a593 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -6,8 +6,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/mmo.h" #include "../common/timer.h" #include "../common/nullpo.h" diff --git a/src/map/battle.c b/src/map/battle.c index b80861df7..7ff6299e6 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -5,9 +5,8 @@ #include #include #include -#include -#include "battle.h" +#include "../common/cbasetypes.h" #include "../common/timer.h" #include "../common/nullpo.h" #include "../common/malloc.h" @@ -24,6 +23,7 @@ #include "pet.h" #include "guild.h" #include "party.h" +#include "battle.h" int attr_fix_table[4][ELE_MAX][ELE_MAX]; diff --git a/src/map/charcommand.c b/src/map/charcommand.c index de8668828..7d54fc5a6 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -6,8 +6,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/socket.h" #include "../common/timer.h" #include "../common/nullpo.h" diff --git a/src/map/charsave.c b/src/map/charsave.c index abcd7d152..13724cffd 100644 --- a/src/map/charsave.c +++ b/src/map/charsave.c @@ -4,8 +4,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/core.h" #include "../common/socket.h" #include "../common/timer.h" diff --git a/src/map/chrif.c b/src/map/chrif.c index 1e8183641..cbce3b6c8 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -6,8 +6,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/malloc.h" #include "../common/socket.h" #include "../common/timer.h" diff --git a/src/map/clif.c b/src/map/clif.c index 56ea93a6a..803484f8c 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9,9 +9,9 @@ #include #include #include -#include #include +#include "../common/cbasetypes.h" #include "../common/socket.h" #include "../common/timer.h" #include "../common/malloc.h" @@ -43,7 +43,6 @@ #include "pet.h" #include "mercenary.h" //[orn] #include "log.h" - #include "irc.h" struct Clif_Config { diff --git a/src/map/guild.c b/src/map/guild.c index 60643eede..fc9defdbc 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -4,8 +4,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/timer.h" #include "../common/nullpo.h" #include "../common/malloc.h" diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 0ae731fd3..99ca1017e 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -3,8 +3,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/socket.h" #include "../common/timer.h" #include "../common/nullpo.h" diff --git a/src/map/mob.c b/src/map/mob.c index 7405fc7ec..935e80384 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -6,8 +6,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/timer.h" #include "../common/db.h" #include "../common/nullpo.h" diff --git a/src/map/npc.c b/src/map/npc.c index 4118b79ea..9ce3160f6 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -7,8 +7,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/timer.h" #include "../common/nullpo.h" #include "../common/malloc.h" diff --git a/src/map/party.c b/src/map/party.c index aabd336ff..87bd3ad62 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -4,8 +4,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/timer.h" #include "../common/socket.h" #include "../common/nullpo.h" diff --git a/src/map/pc.c b/src/map/pc.c index 9aefa3f08..2a8f8487c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6,8 +6,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/socket.h" // [Valaris] #include "../common/timer.h" #include "../common/nullpo.h" @@ -7279,7 +7279,7 @@ int pc_readdb(void) while(fgets(line, sizeof(line)-1, fp)){ int jobs[MAX_PC_CLASS], job_count, job; int type; - unsigned int max; + unsigned int ui,maxlv; char *split[4]; if(line[0]=='/' && line[1]=='/') continue; @@ -7299,28 +7299,27 @@ int pc_readdb(void) ShowError("pc_readdb: Invalid type %d (must be 0 for base levels, 1 for job levels).\n", type); continue; } - max = atoi(split[0]); - if (max > MAX_LEVEL) { - ShowWarning("pc_readdb: Specified max level %d for job %d is beyond server's limit (%d).\n ", max, job, MAX_LEVEL); - max = MAX_LEVEL; + maxlv = atoi(split[0]); + if (maxlv > MAX_LEVEL) { + ShowWarning("pc_readdb: Specified max level %u for job %d is beyond server's limit (%u).\n ", maxlv, job, MAX_LEVEL); + maxlv = MAX_LEVEL; } //We send one less and then one more because the last entry in the exp array should hold 0. - max_level[job][type] = pc_split_atoui(split[3], exp_table[job][type],',',max-1)+1; + max_level[job][type] = pc_split_atoui(split[3], exp_table[job][type],',',maxlv-1)+1; //Reverse check in case the array has a bunch of trailing zeros... [Skotlex] //The reasoning behind the -2 is this... if the max level is 5, then the array //should look like this: //0: x, 1: x, 2: x: 3: x 4: 0 <- last valid value is at 3. - while ((i = max_level[job][type]-2) >= 0 && exp_table[job][type][i] <= 0) + while ((ui = max_level[job][type]) >= 2 && exp_table[job][type][ui-2] <= 0) max_level[job][type]--; - if (max_level[job][type] < max) { - ShowWarning("pc_readdb: Specified max %d for job %d, but that job's exp table only goes up to level %d.\n", max, job, max_level[job][type]); + if (max_level[job][type] < maxlv) { + ShowWarning("pc_readdb: Specified max %u for job %d, but that job's exp table only goes up to level %u.\n", maxlv, job, max_level[job][type]); ShowInfo("Filling the missing values with the last exp entry.\n"); //Fill the requested values with the last entry. - i = max_level[job][type]-2; - if (i < 0) i = 0; - for (; i < max-2; i++) - exp_table[job][type][i] = exp_table[job][type][i-1]; - max_level[job][type] = max; + ui = (max_level[job][type] <= 2? 0: max_level[job][type]-2); + for (; ui+2 < maxlv; ui++) + exp_table[job][type][ui] = exp_table[job][type][ui-1]; + max_level[job][type] = maxlv; } // ShowDebug("%s - Class %d: %d\n", type?"Job":"Base", job, max_level[job][type]); for (i = 1; i < job_count; i++) { @@ -7330,8 +7329,8 @@ int pc_readdb(void) continue; } memcpy(exp_table[job][type], exp_table[jobs[0]][type], sizeof(exp_table[0][0])); - max_level[job][type] = max; -// ShowDebug("%s - Class %d: %d\n", type?"Job":"Base", job, max_level[job][type]); + max_level[job][type] = maxlv; +// ShowDebug("%s - Class %d: %u\n", type?"Job":"Base", job, max_level[job][type]); } } fclose(fp); diff --git a/src/map/script.c b/src/map/script.c index 919c22917..48ac823d8 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -10,7 +10,6 @@ #include #include #include -#include #ifndef _WIN32 #include @@ -2991,7 +2990,7 @@ static int script_load_mapreg(void) ShowInfo("Freeing results...\n"); mysql_free_result(sql_res); mapreg_dirty=0; - perfomance = (time(NULL) - perfomance); + perfomance = (((unsigned int)time(NULL)) - perfomance); ShowInfo("SQL Mapreg Loading Completed Under %d Seconds.\n",perfomance); return 0; #endif /* TXT_ONLY */ diff --git a/src/map/skill.c b/src/map/skill.c index 33e02296a..9695a1f76 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -5,8 +5,8 @@ #include #include #include -#include +#include "../common/cbasetypes.h" #include "../common/timer.h" #include "../common/nullpo.h" #include "../common/malloc.h" diff --git a/src/map/status.c b/src/map/status.c index dfd5279d3..c287321b8 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -7,7 +7,12 @@ #include #include #include -#include + +#include "../common/cbasetypes.h" +#include "../common/timer.h" +#include "../common/nullpo.h" +#include "../common/showmsg.h" +#include "../common/malloc.h" #include "pc.h" #include "map.h" @@ -25,11 +30,6 @@ #include "unit.h" #include "mercenary.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" - //For specifying where in the SkillStatusChangeTableArray the "out of bounds" skills get stored. [Skotlex] #define SC_HM_BASE 800 #define SC_GD_BASE 900 -- cgit v1.2.3-70-g09d2 From 120b6a38af546987948505832c1d8d6fb3c853af Mon Sep 17 00:00:00 2001 From: ultramage Date: Wed, 21 Feb 2007 15:09:20 +0000 Subject: Applied a consistent look to all header files (copyright, ifdefs) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9891 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 1 + src/char/char.h | 3 ++- src/char/int_guild.h | 3 ++- src/char/int_homun.h | 2 +- src/char/int_party.h | 3 ++- src/char/int_pet.h | 3 ++- src/char/int_status.h | 7 ++++--- src/char/int_storage.h | 3 ++- src/char/inter.h | 3 ++- src/char_sql/char.h | 8 +++++--- src/char_sql/int_homun.c | 4 ++-- src/char_sql/int_homun.h | 10 +++++----- src/char_sql/int_party.h | 3 ++- src/char_sql/int_pet.h | 3 ++- src/char_sql/int_storage.h | 3 ++- src/char_sql/inter.h | 3 ++- src/char_sql/itemdb.h | 3 ++- src/common/cbasetypes.h | 1 + src/common/core.h | 2 +- src/common/db.h | 2 +- src/common/grfio.h | 3 ++- src/common/lock.h | 3 +-- src/common/malloc.h | 3 ++- src/common/mapindex.c | 3 +++ src/common/mapindex.h | 10 +++++++--- src/common/md5calc.h | 2 +- src/common/mmo.h | 2 +- src/common/nullpo.h | 2 +- src/common/plugin.h | 2 +- src/common/plugins.h | 2 +- src/common/showmsg.h | 2 +- src/common/socket.h | 2 +- src/common/strlib.h | 7 ++++--- src/common/timer.h | 2 +- src/common/utils.h | 6 +++--- src/common/version.h | 2 +- src/ladmin/ladmin.c | 2 +- src/ladmin/ladmin.h | 4 ++-- src/login/login.h | 3 ++- src/login_sql/login.h | 6 +++--- src/map/atcommand.h | 3 +-- src/map/battle.h | 2 +- src/map/charcommand.h | 2 +- src/map/charsave.h | 2 +- src/map/chat.h | 2 +- src/map/chrif.h | 2 +- src/map/clif.h | 4 +--- src/map/date.h | 3 ++- src/map/guild.h | 2 +- src/map/intif.h | 2 +- src/map/irc.c | 6 ++---- src/map/irc.h | 8 ++++++++ src/map/itemdb.h | 2 +- src/map/log.h | 2 +- src/map/mail.h | 6 ++++-- src/map/map.h | 2 +- src/map/mercenary.c | 3 +++ src/map/mercenary.h | 10 ++++++++-- src/map/mob.h | 2 +- src/map/npc.h | 3 +-- src/map/party.h | 2 +- src/map/pc.h | 3 ++- src/map/pet.h | 3 +-- src/map/script.h | 3 +-- src/map/skill.h | 2 +- src/map/status.h | 2 +- src/map/storage.h | 2 +- src/map/trade.h | 2 +- src/map/unit.c | 4 ++-- src/map/unit.h | 5 +++-- src/map/vending.h | 2 +- 71 files changed, 138 insertions(+), 98 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 89ef39a7c..1c6cfb32f 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/02/21 + * Applied a consistent look to all header files (copyright, ifdefs) * Minor stuff (typos, socket.c, junk in login reply packet) [ultramage] 2007/02/19 * Fixed @cartlist info message typo [Lupus] diff --git a/src/char/char.h b/src/char/char.h index e70fe7e4f..947d12d3f 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -55,4 +55,5 @@ extern char char_txt[]; int char_config_read(const char *cfgName); int mmo_char_fromstr(char *str, struct mmo_charstatus *p, struct global_reg *reg, int *reg_num); int parse_friend_txt(struct mmo_charstatus *p); -#endif + +#endif /* _CHAR_H_ */ diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 616384b94..6b0e9f7b5 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -19,4 +19,5 @@ extern char castle_txt[1024]; //For the TXT->SQL converter int inter_guild_fromstr(char *str, struct guild *g); int inter_guildcastle_fromstr(char *str, struct guild_castle *gc); -#endif + +#endif /* _INT_GUILD_H_ */ diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 5987d23f8..d56ab97a9 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -13,4 +13,4 @@ int inter_homun_parse_frommap(int fd); extern char homun_txt[1024]; -#endif +#endif /* _INT_HOMUN_H_ */ diff --git a/src/char/int_party.h b/src/char/int_party.h index 8f4ff5d18..453699617 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -16,4 +16,5 @@ extern char party_txt[1024]; //For the TXT->SQL converter int inter_party_fromstr(char *str, struct party *p); -#endif + +#endif /* _INT_PARTY_H_ */ diff --git a/src/char/int_pet.h b/src/char/int_pet.h index 2c72628bb..43f354798 100644 --- a/src/char/int_pet.h +++ b/src/char/int_pet.h @@ -15,4 +15,5 @@ extern char pet_txt[1024]; //Exported for use in the TXT-SQL converter. int inter_pet_fromstr(char *str,struct s_pet *p); -#endif + +#endif /* _INT_PET_H_ */ diff --git a/src/char/int_status.h b/src/char/int_status.h index bc93b1024..3ddf08299 100644 --- a/src/char/int_status.h +++ b/src/char/int_status.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef __INT_STATUS__ -#define __INT_STATUS__ +#ifndef _INT_STATUS_H_ +#define _INT_STATUS_H_ #include "char.h" @@ -21,4 +21,5 @@ void inter_status_save(void); void status_init(void); void status_final(void); #endif -#endif + +#endif /* _INT_STATUS_H_ */ diff --git a/src/char/int_storage.h b/src/char/int_storage.h index 7007646f9..976d77034 100644 --- a/src/char/int_storage.h +++ b/src/char/int_storage.h @@ -19,4 +19,5 @@ extern char guild_storage_txt[1024]; //Exported for use in the TXT-SQL converter. int storage_fromstr(char *str,struct storage *p); int guild_storage_fromstr(char *str,struct guild_storage *p); -#endif + +#endif /* _INT_STORAGE_H_ */ diff --git a/src/char/inter.h b/src/char/inter.h index 1789848c5..5a6a0edde 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -25,4 +25,5 @@ extern char main_chat_nick[16]; //For TXT->SQL conversion extern char accreg_txt[]; int inter_accreg_fromstr(const char *str, struct accreg *reg); -#endif + +#endif /* _INTER_H_ */ diff --git a/src/char_sql/char.h b/src/char_sql/char.h index 4a95fd0f8..41ce45ea6 100644 --- a/src/char_sql/char.h +++ b/src/char_sql/char.h @@ -1,7 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CHARSQL_H_ -#define _CHARSQL_H_ + +#ifndef _CHAR_SQL_H_ +#define _CHAR_SQL_H_ #include "../common/core.h" #include "../common/socket.h" @@ -106,4 +107,5 @@ extern int debug_mysql_query(char *file, int line, void *mysql, const char *q); //Exported for use in the TXT-SQL converter. int mmo_char_tosql(int char_id, struct mmo_charstatus *p); void sql_config_read(const char *cfgName); -#endif + +#endif /* _CHAR_SQL_H_ */ diff --git a/src/char_sql/int_homun.c b/src/char_sql/int_homun.c index 22edad8d0..2260ddf20 100644 --- a/src/char_sql/int_homun.c +++ b/src/char_sql/int_homun.c @@ -1,5 +1,5 @@ -// Homunculus saving by Albator and Orn for eAthena. -// GNU/GPL rulez ! +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder #include #include diff --git a/src/char_sql/int_homun.h b/src/char_sql/int_homun.h index 2b9af8ebc..fa49c659f 100644 --- a/src/char_sql/int_homun.h +++ b/src/char_sql/int_homun.h @@ -1,8 +1,8 @@ -// Homunculus saving by Albator and Orn for eAthena. -// GNU/GPL rulez ! +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder -#ifndef _INT_HOMUN_H_ -#define _INT_HOMUN_H_ +#ifndef _INT_HOMUN_SQL_H_ +#define _INT_HOMUN_SQL_H_ int inter_homunculus_sql_init(void); void inter_homunculus_sql_final(void); @@ -12,4 +12,4 @@ int mapif_delete_homunculus(int fd); int inter_delete_homunculus(int hom_id); int inter_homunculus_parse_frommap(int fd); -#endif +#endif /* _INT_HOMUN_SQL_H_ */ diff --git a/src/char_sql/int_party.h b/src/char_sql/int_party.h index 1e54b8b47..c244ab59e 100644 --- a/src/char_sql/int_party.h +++ b/src/char_sql/int_party.h @@ -26,4 +26,5 @@ int inter_party_CharOnline(int char_id, int party_id); int inter_party_CharOffline(int char_id, int party_id); //Required for the TXT->SQL converter int inter_party_tosql(struct party *p, int flag, int index); -#endif + +#endif /* _INT_PARTY_SQL_H_ */ diff --git a/src/char_sql/int_pet.h b/src/char_sql/int_pet.h index 1b03c9768..5c1955857 100644 --- a/src/char_sql/int_pet.h +++ b/src/char_sql/int_pet.h @@ -15,4 +15,5 @@ int inter_pet_sql_init(void); //Exported for use in the TXT-SQL converter. int inter_pet_tosql(int pet_id, struct s_pet *p); -#endif + +#endif /* _INT_PET_SQL_H_ */ diff --git a/src/char_sql/int_storage.h b/src/char_sql/int_storage.h index 3cba41e64..dd71ef9ed 100644 --- a/src/char_sql/int_storage.h +++ b/src/char_sql/int_storage.h @@ -14,4 +14,5 @@ int inter_storage_parse_frommap(int fd); //Exported for use in the TXT-SQL converter. int storage_tosql(int account_id,struct storage *p); int guild_storage_tosql(int guild_id, struct guild_storage *p); -#endif + +#endif /* _INT_STORAGE_SQL_H_ */ diff --git a/src/char_sql/inter.h b/src/char_sql/inter.h index ecfde71c0..c1567cfe6 100644 --- a/src/char_sql/inter.h +++ b/src/char_sql/inter.h @@ -53,4 +53,5 @@ extern char login_db_server_db[32]; extern char main_chat_nick[16]; int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type); -#endif + +#endif /* _INTER_SQL_H_ */ diff --git a/src/char_sql/itemdb.h b/src/char_sql/itemdb.h index 53b1d3e02..4fbd59f96 100644 --- a/src/char_sql/itemdb.h +++ b/src/char_sql/itemdb.h @@ -3,6 +3,7 @@ #ifndef _ITEMDB_H_ #define _ITEMDB_H_ + #include "mmo.h" //FIXME: Maybe it would be better to move this enum to mmo.h, @@ -40,4 +41,4 @@ int itemdb_isequip2(struct item_data *); void do_final_itemdb(void); int do_init_itemdb(void); -#endif +#endif /* _ITEMDB_H_ */ diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 76f494851..1eea1c465 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -1,5 +1,6 @@ #ifndef _CBASETYPES_H_ #define _CBASETYPES_H_ + /* +--------+-----------+--------+---------+ * | ILP32 | LP64 | ILP64 | (LL)P64 | * +------------+--------+-----------+--------+---------+ diff --git a/src/common/core.h b/src/common/core.h index 06ce86448..5e396cc7a 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -20,4 +20,4 @@ extern void set_server_type(void); extern void set_termfunc(void (*termfunc)(void)); extern void do_final(void); -#endif // _CORE_H_ +#endif /* _CORE_H_ */ diff --git a/src/common/db.h b/src/common/db.h index a79c88822..0c19b5fc2 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -702,4 +702,4 @@ void* linkdb_search ( struct linkdb_node** head, void *key); void* linkdb_erase ( struct linkdb_node** head, void *key); void linkdb_final ( struct linkdb_node** head ); -#endif +#endif /* _DB_H_ */ diff --git a/src/common/grfio.h b/src/common/grfio.h index 572258b04..0d6268b0d 100644 --- a/src/common/grfio.h +++ b/src/common/grfio.h @@ -19,4 +19,5 @@ int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* int encode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen); int deflate_file (const char *source, const char *filename); -#endif // _GRFIO_H_ +#endif /* _GRFIO_H_ */ + diff --git a/src/common/lock.h b/src/common/lock.h index e90fbf745..537305ccf 100644 --- a/src/common/lock.h +++ b/src/common/lock.h @@ -9,5 +9,4 @@ FILE* lock_fopen(const char* filename,int *info); int lock_fclose(FILE *fp,const char* filename,int *info); -#endif - +#endif /* _LOCK_H_ */ diff --git a/src/common/malloc.h b/src/common/malloc.h index 1af9cba62..5411d670d 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -3,6 +3,7 @@ #ifndef _MALLOC_H_ #define _MALLOC_H_ + // Q: What are the 'a'-variant allocation functions? // A: They allocate memory from the stack, which is automatically // freed when the invoking function returns. @@ -157,4 +158,4 @@ unsigned int malloc_usage (void); void malloc_init (void); void malloc_final (void); -#endif +#endif /* _MALLOC_H_ */ diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 070326463..be6580ae5 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -1,3 +1,6 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + #include #include #include diff --git a/src/common/mapindex.h b/src/common/mapindex.h index 7a0286adf..68989031d 100644 --- a/src/common/mapindex.h +++ b/src/common/mapindex.h @@ -1,5 +1,9 @@ -#ifndef _MAX_INDEX_H -#define _MAX_INDEX_H +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef _MAPINDEX_H_ +#define _MAPINDEX_H_ + //File in charge of assigning a numberic ID to each map in existance for space saving when passing map info between servers. extern char mapindex_cfgfile[80]; @@ -38,4 +42,4 @@ const char* mapindex_id2name(unsigned short); void mapindex_init(void); void mapindex_final(void); -#endif +#endif /* _MAPINDEX_H_ */ diff --git a/src/common/md5calc.h b/src/common/md5calc.h index 9bc554f69..fc1c274f2 100644 --- a/src/common/md5calc.h +++ b/src/common/md5calc.h @@ -4,4 +4,4 @@ void MD5_String(const char * string, char * output); void MD5_String2binary(const char * string, char * output); -#endif +#endif /* _MD5CALC_H_ */ diff --git a/src/common/mmo.h b/src/common/mmo.h index 48a8266e7..f946b46cb 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -511,4 +511,4 @@ enum { #endif #endif -#endif // _MMO_H_ +#endif /* _MMO_H_ */ diff --git a/src/common/nullpo.h b/src/common/nullpo.h index d5ccb8f95..71525dd00 100644 --- a/src/common/nullpo.h +++ b/src/common/nullpo.h @@ -234,4 +234,4 @@ void nullpo_info_f(const char *file, int line, const char *func, __attribute__((format(printf,4,5))); -#endif +#endif /* _NULLPO_H_ */ diff --git a/src/common/plugin.h b/src/common/plugin.h index f30a15e5e..3ddbaae98 100644 --- a/src/common/plugin.h +++ b/src/common/plugin.h @@ -80,4 +80,4 @@ typedef void Plugin_Event_Func(void); #define PLUGIN_EVENTS_TABLE struct _Plugin_Event_Table plugin_event_table[] void** plugin_call_table; -#endif // _PLUGIN_H_ +#endif /* _PLUGIN_H_ */ diff --git a/src/common/plugins.h b/src/common/plugins.h index 9cb4b94b4..70dd6b326 100644 --- a/src/common/plugins.h +++ b/src/common/plugins.h @@ -63,4 +63,4 @@ void plugin_unload(Plugin* plugin); void plugins_init(void); void plugins_final(void); -#endif // _PLUGINS_H_ +#endif /* _PLUGINS_H_ */ diff --git a/src/common/showmsg.h b/src/common/showmsg.h index cf9c16d23..31933f17a 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -93,4 +93,4 @@ extern int ShowDebug(const char *, ...); extern int ShowError(const char *, ...); extern int ShowFatalError(const char *, ...); -#endif +#endif /* _SHOWMSG_H_ */ diff --git a/src/common/socket.h b/src/common/socket.h index 1c4a1bd8c..0c96edb20 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -141,4 +141,4 @@ int socket_getips(uint32* ips, int max); extern uint32 addr_[16]; // ip addresses of local host (host byte order) extern int naddr_; // # of ip addresses -#endif // _SOCKET_H_ +#endif /* _SOCKET_H_ */ diff --git a/src/common/strlib.h b/src/common/strlib.h index f242b5cc4..8303c182f 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -1,8 +1,9 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _J_STR_LIB_H_ -#define _J_STR_LIB_H_ +#ifndef _STRLIB_H_ +#define _STRLIB_H_ + #define J_MAX_MALLOC_SIZE 65535 // String function library. // code by Jioh L. Jung (ziozzang@4wish.net) @@ -26,4 +27,4 @@ const char *stristr(const char *haystack, const char *needle); size_t strnlen (const char* string, size_t maxlen); #endif -#endif +#endif /* _STRLIB_H_ */ diff --git a/src/common/timer.h b/src/common/timer.h index 4b683d966..23cb6beaa 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -59,4 +59,4 @@ unsigned long get_uptime(void); void timer_init(void); void timer_final(void); -#endif // _TIMER_H_ +#endif /* _TIMER_H_ */ diff --git a/src/common/utils.h b/src/common/utils.h index efd477c9b..3e74374bc 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef COMMON_UTILS_H -#define COMMON_UTILS_H +#ifndef _UTILS_H_ +#define _UTILS_H_ #include @@ -41,4 +41,4 @@ extern unsigned short GetWord(unsigned long val, size_t num); extern unsigned short MakeWord(unsigned char byte0, unsigned char byte1); extern unsigned long MakeDWord(unsigned short word0, unsigned short word1); -#endif +#endif /* _UTILS_H_ */ diff --git a/src/common/version.h b/src/common/version.h index 2560c1019..71a93dcd9 100644 --- a/src/common/version.h +++ b/src/common/version.h @@ -27,4 +27,4 @@ // C言語の仕様上、最初に0を付けると8進数になるので間違えないで下さい。 #define ATHENA_MOD_VERSION 1249 // mod version (patch No.) -#endif +#endif /* _VERSION_H_ */ diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c index 343967d46..107d98d09 100644 --- a/src/ladmin/ladmin.c +++ b/src/ladmin/ladmin.c @@ -1,4 +1,4 @@ -// (c) eAthena Dev Team - Licensed under GNU GPL +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder /////////////////////////////////////////////////////////////////////////// diff --git a/src/ladmin/ladmin.h b/src/ladmin/ladmin.h index 64a67146e..b335984c7 100644 --- a/src/ladmin/ladmin.h +++ b/src/ladmin/ladmin.h @@ -1,4 +1,4 @@ -// (c) eAthena Dev Team - Licensed under GNU GPL +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder #ifndef _LADMIN_H_ @@ -10,4 +10,4 @@ // It is made into 2 at the time of passwordencrypt2. // When it is made 3, it corresponds to both. -#endif +#endif /* _LADMIN_H_ */ diff --git a/src/login/login.h b/src/login/login.h index 38901ff33..441f2bac1 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -39,4 +39,5 @@ struct mmo_char_server { extern struct mmo_char_server server[MAX_SERVERS]; extern int server_fd[MAX_SERVERS]; -#endif + +#endif /* _LOGIN_H_ */ diff --git a/src/login_sql/login.h b/src/login_sql/login.h index f3b604664..882a284e9 100644 --- a/src/login_sql/login.h +++ b/src/login_sql/login.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _LOGIN_H_ -#define _LOGIN_H_ +#ifndef _LOGIN_SQL_H_ +#define _LOGIN_SQL_H_ #define MAX_SERVERS 30 @@ -51,4 +51,4 @@ struct mmo_char_server { }; -#endif +#endif /* _LOGIN_SQL_H_ */ diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 84b4fa0ed..644237245 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -325,5 +325,4 @@ extern char atcommand_symbol; #define MAX_MSG 1000 extern char* msg_table[MAX_MSG]; -#endif - +#endif /* _ATCOMMAND_H_ */ diff --git a/src/map/battle.h b/src/map/battle.h index 12e217218..c04fcfbfb 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -444,4 +444,4 @@ extern void battle_set_defaults(void); extern int battle_set_value(char *, char *); int battle_get_value(char *); -#endif +#endif /* _BATTLE_H_ */ diff --git a/src/map/charcommand.h b/src/map/charcommand.h index 5982ffe30..979594251 100644 --- a/src/map/charcommand.h +++ b/src/map/charcommand.h @@ -70,5 +70,5 @@ int get_charcommand_level(const CharCommandType type); int charcommand_config_read(const char *cfgName); extern char charcommand_symbol; -#endif +#endif /* _CHARCOMMAND_H_ */ diff --git a/src/map/charsave.h b/src/map/charsave.h index 5743c1c65..5734ebf58 100644 --- a/src/map/charsave.h +++ b/src/map/charsave.h @@ -18,4 +18,4 @@ void charsave_save_scdata(int account_id, int char_id, struct status_change* sc_data, int max_sc); #endif -#endif +#endif /* _CHARSAVE_H_ */ diff --git a/src/map/chat.h b/src/map/chat.h index 702fd7dad..bfb1a0a80 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -19,4 +19,4 @@ int chat_enableevent(struct chat_data *cd); int chat_disableevent(struct chat_data *cd); int chat_npckickall(struct chat_data *cd); -#endif +#endif /* _CHAT_H_ */ diff --git a/src/map/chrif.h b/src/map/chrif.h index 302b31f56..a94591cd4 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -55,4 +55,4 @@ int do_init_chrif(void); int chrif_flush_fifo(void); -#endif +#endif /* _CHRIF_H_ */ diff --git a/src/map/clif.h b/src/map/clif.h index 5ce426f96..ca3ae2278 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -362,6 +362,4 @@ int clif_hom_food(struct map_session_data *sd,int foodid,int fail); //[orn] void clif_send_homdata(struct map_session_data *sd, int type, int param); //[orn] int clif_hwalkok(struct homun_data *hd); //[orn] -#endif - - +#endif /* _CLIF_H_ */ diff --git a/src/map/date.h b/src/map/date.h index 2b8ffe991..cc19d88d1 100644 --- a/src/map/date.h +++ b/src/map/date.h @@ -3,7 +3,6 @@ #ifndef _DATE_H_ #define _DATE_H_ -#endif int date_get_year(void); int date_get_month(void); @@ -15,3 +14,5 @@ int date_get_sec(void); int is_day_of_sun(void); int is_day_of_moon(void); int is_day_of_star(void); + +#endif /* _DATE_H_ */ diff --git a/src/map/guild.h b/src/map/guild.h index 6171c72f2..e569c0d15 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -91,4 +91,4 @@ int guild_agit_break(struct mob_data *md); void do_final_guild(void); -#endif +#endif /* _GUILD_H_ */ diff --git a/src/map/intif.h b/src/map/intif.h index 56f2f4783..b1d82940c 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -70,4 +70,4 @@ int intif_homunculus_requestdelete(int homun_id); int CheckForCharServer(void); -#endif +#endif /* _INTIF_H_ */ diff --git a/src/map/irc.c b/src/map/irc.c index 55eafdcd9..2300dd3ac 100644 --- a/src/map/irc.c +++ b/src/map/irc.c @@ -1,5 +1,5 @@ -#ifndef _IRC_H_ -#define _IRC_H_ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder #include #include @@ -545,5 +545,3 @@ int irc_read_conf(char *file) { return 1; } - -#endif //_IRC_H_ diff --git a/src/map/irc.h b/src/map/irc.h index 2297f013b..163ac0793 100644 --- a/src/map/irc.h +++ b/src/map/irc.h @@ -1,3 +1,9 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef _IRC_H_ +#define _IRC_H_ + #include "map.h" // IRC .conf file [Zido] @@ -53,3 +59,5 @@ int set_access(char *nick,int level); // [Zido] int get_access(char *nick); // [Zido] int irc_rmnames(void); // [Zido] int irc_read_conf(char *file); // [Zido] + +#endif /* _IRC_H_ */ diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 0b9e2a466..fb3d25964 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -142,4 +142,4 @@ void itemdb_reload(void); void do_final_itemdb(void); int do_init_itemdb(void); -#endif +#endif /* _ITEMDB_H_ */ diff --git a/src/map/log.h b/src/map/log.h index 872506ac5..9f82f61a2 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -53,4 +53,4 @@ extern struct Log_Config { char log_branch_db[32], log_pick_db[32], log_zeny_db[32], log_mvpdrop_db[32], log_gm_db[32], log_npc_db[32], log_chat_db[32]; } log_config; -#endif +#endif /* _LOG_H_ */ diff --git a/src/map/mail.h b/src/map/mail.h index d6f865f78..fca124ae4 100644 --- a/src/map/mail.h +++ b/src/map/mail.h @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -// Mail System for eAthena -// Created by Valaris +#ifndef _MAIL_H_ +#define _MAIL_H_ int mail_check(struct map_session_data *sd, int type); int mail_read(struct map_session_data *sd, int message_id); @@ -10,3 +10,5 @@ int mail_delete(struct map_session_data *sd, int message_id); int mail_send(struct map_session_data *sd, char *name, char *message, int flag); int do_init_mail(void); + +#endif /* _MAIL_H_ */ diff --git a/src/map/map.h b/src/map/map.h index a8e24d7fe..69cd1383b 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -1503,4 +1503,4 @@ typedef struct homun_data TBL_HOM; extern int lowest_gm_level; extern char main_chat_nick[16]; -#endif +#endif /* _MAP_H_ */ diff --git a/src/map/mercenary.c b/src/map/mercenary.c index f7799e500..a11373032 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -1,3 +1,6 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + #include #include #include diff --git a/src/map/mercenary.h b/src/map/mercenary.h index e5e194967..6103acc00 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -1,5 +1,9 @@ -// Homunculus and future Mercenary system code go here [Celest] -// implemented by [orn] +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef _MERCENARY_H_ +#define _MERCENARY_H_ + struct homunculus_db { int class_ ; char name[NAME_LENGTH]; @@ -81,3 +85,5 @@ int merc_skill_tree_get_max(int id, int b_class); void merc_hom_init_timers(struct homun_data * hd); void merc_skill_reload(void); void merc_reload(void); + +#endif /* _MERCENARY_H_ */ diff --git a/src/map/mob.h b/src/map/mob.h index f13cce8da..09dfb5a2a 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -203,4 +203,4 @@ int mob_clone_delete(int class_); void mob_reload(void); -#endif +#endif /* _MOB_H_ */ diff --git a/src/map/npc.h b/src/map/npc.h index ea28964f5..86bce296c 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -88,5 +88,4 @@ extern char *current_file; struct npc_data *fake_nd; -#endif - +#endif /* _NPC_H_ */ diff --git a/src/map/party.h b/src/map/party.h index 0b7c9a858..4c87dd501 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -47,4 +47,4 @@ int party_sub_count(struct block_list *bl, va_list ap); int party_foreachsamemap(int (*func)(struct block_list *,va_list),struct map_session_data *sd,int type,...); -#endif +#endif /* _PARTY_H_ */ diff --git a/src/map/pc.h b/src/map/pc.h index f95a27085..dc6be203d 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -315,4 +315,5 @@ int duel_checktime(struct map_session_data* sd); int pc_read_motd(void); // [Valaris] int pc_disguise(struct map_session_data *sd, int class_); -#endif + +#endif /* _PC_H_ */ diff --git a/src/map/pet.h b/src/map/pet.h index 3bb6d0906..821874359 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -65,5 +65,4 @@ int read_petdb(void); int do_init_pet(void); int do_final_pet(void); -#endif - +#endif /* _PET_H_ */ diff --git a/src/map/script.h b/src/map/script.h index 09b4a797b..bad0374dd 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -90,5 +90,4 @@ int script_reload(void); extern char mapreg_txt[]; -#endif - +#endif /* _SCRIPT_H_ */ diff --git a/src/map/skill.h b/src/map/skill.h index ddb9042a0..cab8039c0 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -956,4 +956,4 @@ enum { UNT_GROUNDDRIFT_FIRE, }; -#endif +#endif /* _SKILL_H_ */ diff --git a/src/map/status.h b/src/map/status.h index ce8fbd827..3c8d37e69 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -657,4 +657,4 @@ int status_check_visibility(struct block_list *src, struct block_list *target); int status_readdb(void); int do_init_status(void); -#endif +#endif /* _STATUS_H_ */ diff --git a/src/map/storage.h b/src/map/storage.h index 2140a2ec5..a9f109319 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -42,4 +42,4 @@ int storage_comp_item(const void *_i1, const void *_i2); void sortage_sortitem(struct storage* stor); void sortage_gsortitem(struct guild_storage* gstor); -#endif +#endif /* _STORAGE_H_ */ diff --git a/src/map/trade.h b/src/map/trade.h index bcd609271..cbcf34f2a 100644 --- a/src/map/trade.h +++ b/src/map/trade.h @@ -12,4 +12,4 @@ void trade_tradeok(struct map_session_data *sd); void trade_tradecancel(struct map_session_data *sd); void trade_tradecommit(struct map_session_data *sd); -#endif // _TRADE_H_ +#endif /* _TRADE_H_ */ diff --git a/src/map/unit.c b/src/map/unit.c index 80e0137cf..79dcd3a80 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1,6 +1,6 @@ -// Copyright (c) jAthena Dev Teams - Licensed under GNU GPL +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -// Merged originally from jA by Skotlex + #include #include #include diff --git a/src/map/unit.h b/src/map/unit.h index 9b53f90bf..32fc3cce7 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -1,6 +1,6 @@ -// Copyright (c) jAthena Dev Teams - Licensed under GNU GPL +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -// Merged originally from jA by Skotlex + #ifndef _UNIT_H_ #define _UNIT_H_ @@ -69,4 +69,5 @@ int do_final_unit(void); extern const int dirx[8]; extern const int diry[8]; + #endif /* _UNIT_H_ */ diff --git a/src/map/vending.h b/src/map/vending.h index f4014a894..d9db08b6d 100644 --- a/src/map/vending.h +++ b/src/map/vending.h @@ -11,4 +11,4 @@ void vending_openvending(struct map_session_data *sd,int len,char *message,int f void vending_vendinglistreq(struct map_session_data *sd,int id); void vending_purchasereq(struct map_session_data *sd,int len,int id,unsigned char *p); -#endif // _VENDING_H_ +#endif /* _VENDING_H_ */ -- cgit v1.2.3-70-g09d2 From 26789cc24022cf600543860c4a15dbe79aa0e1f8 Mon Sep 17 00:00:00 2001 From: skotlex Date: Sun, 11 Mar 2007 16:11:20 +0000 Subject: - cbasetypes now assumes that Mingwin does defines ssize_t - Modified the guild master change ack packet to return the aid/cid of the new guild master instead of the index where it was, the previous method could cause problems in situations where the order of guild members would not match exactly between char/map servers. - Updated the Soul Linker's Rogue Spirit Stealth's speed bonus to +60%, according to forum infor from ragnagate. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9985 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 7 +++++++ src/char/int_guild.c | 9 +++++---- src/char_sql/int_guild.c | 9 +++++---- src/common/cbasetypes.h | 3 ++- src/map/guild.c | 18 +++++++++++++----- src/map/guild.h | 2 +- src/map/intif.c | 4 ++-- src/map/status.c | 2 +- 8 files changed, 36 insertions(+), 18 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 7eeef7f10..5a6a646ad 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,13 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2007/03/12 + * Modified the guild master change ack packet to return the aid/cid of the + new guild master instead of the index where it was, the previous method + could cause problems in situations where the order of guild members would + not match exactly between char/map servers. + * Updated the Soul Linker's Rogue Spirit Stealth's speed bonus to +60%, + according to forum infor from ragnagate. [Skotlex] 2007/03/09 * Mapcache can run on system with any endianness. The generated file contains data in little endian. diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 6886287e2..84c5839d1 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -877,13 +877,14 @@ int mapif_guild_emblem(struct guild *g) { return 0; } -int mapif_guild_master_changed(struct guild *g, int position) +int mapif_guild_master_changed(struct guild *g, int aid, int cid) { unsigned char buf[12]; WBUFW(buf,0)=0x3843; WBUFL(buf,2)=g->guild_id; - WBUFL(buf,6)=position; - mapif_sendall(buf,10); + WBUFL(buf,6)=aid; + WBUFL(buf,10)=cid; + mapif_sendall(buf,14); return 0; } @@ -1517,7 +1518,7 @@ int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int le g->master[len] = '\0'; ShowInfo("int_guild: Guildmaster Changed to %s (Guild %d - %s)\n",name, guild_id, g->name); - return mapif_guild_master_changed(g, pos); + return mapif_guild_master_changed(g, g->member[0].account_id, g->member[0].char_id); } // map server からの通信 diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index 8232608c1..4ad3ea070 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -1199,13 +1199,14 @@ int mapif_guild_emblem(struct guild *g) return 0; } -int mapif_guild_master_changed(struct guild *g, int position) +int mapif_guild_master_changed(struct guild *g, int aid, int cid) { unsigned char buf[10]; WBUFW(buf,0)=0x3843; WBUFL(buf,2)=g->guild_id; - WBUFL(buf,6)=position; - mapif_sendall(buf,10); + WBUFL(buf,6)=aid; + WBUFL(buf,10)=cid; + mapif_sendall(buf,14); return 0; } @@ -2043,7 +2044,7 @@ int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int le ShowInfo("int_guild: Guildmaster Changed to %s (Guild %d - %s)\n",g->master, guild_id, g->name); g->save_flag |= (GS_BASIC|GS_MEMBER); //Save main data and member data. - return mapif_guild_master_changed(g, pos); + return mapif_guild_master_changed(g, g->member[0].account_id, g->member[0].char_id); } // ギルドチェック要求 diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 1eea1c465..eca0d056c 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -153,7 +153,8 @@ typedef unsigned long int ppuint32; // integer with exact processor width (and best speed) // size_t already defined in stdio.h ////////////////////////////// -#ifdef WIN32 // does not have a signed size_t +// +#if defined(WIN32) && !defined(MINGW) // does not have a signed size_t ////////////////////////////// #if defined(_WIN64) // naive 64bit windows platform typedef __int64 ssize_t; diff --git a/src/map/guild.c b/src/map/guild.c index 89778809f..c53343703 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -1603,16 +1603,24 @@ int guild_gm_change(int guild_id, struct map_session_data *sd) } //Notification from Char server that a guild's master has changed. [Skotlex] -int guild_gm_changed(int guild_id, int pos) +int guild_gm_changed(int guild_id, int account_id, int char_id) { struct guild *g; struct guild_member gm; - + int pos; + g=guild_search(guild_id); - - if (!g || pos < 0 || pos > g->max_member) + + if (!g) return 0; - + + for(pos=0; posmax_member && !( + g->member[pos].account_id==account_id && + g->member[pos].char_id==char_id); + pos++); + + if (pos == 0 || pos == g->max_member) return 0; + memcpy(&gm, &g->member[pos], sizeof (struct guild_member)); memcpy(&g->member[pos], &g->member[0], sizeof(struct guild_member)); memcpy(&g->member[0], &gm, sizeof(struct guild_member)); diff --git a/src/map/guild.h b/src/map/guild.h index e569c0d15..d5b501e3a 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -76,7 +76,7 @@ int guild_skillupack(int guild_id,int skill_num,int account_id); int guild_break(struct map_session_data *sd,char *name); int guild_broken(int guild_id,int flag); int guild_gm_change(int guild_id, struct map_session_data *sd); -int guild_gm_changed(int guild_id, int pos); +int guild_gm_changed(int guild_id, int account_id, int char_id); int guild_addcastleinfoevent(int castle_id,int index,const char *name); int guild_castledataload(int castle_id,int index); diff --git a/src/map/intif.c b/src/map/intif.c index 1f7a0657e..8c087ea83 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -31,7 +31,7 @@ static const int packet_len_table[]={ -1, 7, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810 39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820 10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830 - 9, 9,-1,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3840 + 9, 9,-1,14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3840 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1366,7 +1366,7 @@ int intif_parse_GuildCastleAllDataLoad(int fd) int intif_parse_GuildMasterChanged(int fd) { RFIFOHEAD(fd); - return guild_gm_changed(RFIFOL(fd,2),RFIFOL(fd,6)); + return guild_gm_changed(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10)); } // pet diff --git a/src/map/status.c b/src/map/status.c index 660241cd3..1aed80716 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -5174,7 +5174,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val val2 = tick>0?tick:10000; //Interval at which SP is drained. val3 = 65+val1*5; //Speed adjustment. if (sc->data[SC_SPIRIT].timer != -1 && sc->data[SC_SPIRIT].val2 == SL_ROGUE) - val3 += 10; //TODO: Figure out real bonus. Temp value +10% + val3 += 60; val4 = 10+val1*2; //SP cost. if (map_flag_gvg(bl->m)) val4 *= 5; break; -- cgit v1.2.3-70-g09d2 From cc0055f1af5eea3a9253cf3e0e0582f19ea8b512 Mon Sep 17 00:00:00 2001 From: toms Date: Tue, 20 Mar 2007 14:24:41 +0000 Subject: Modified swap #define to avoid 'value computed is not used' warning git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10036 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/cbasetypes.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/common/cbasetypes.h') diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index eca0d056c..1a1cd22a9 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -230,7 +230,9 @@ typedef char bool; // hmm only ints? //#define swap(a,b) { int temp=a; a=b; b=temp;} // if using macros then something that is type independent -#define swap(a,b) ((a == b) || ((a ^= b), (b ^= a), (a ^= b))) +//#define swap(a,b) ((a == b) || ((a ^= b), (b ^= a), (a ^= b))) +// Avoid "value computed is not used" warning and generates the same assembly code +#define swap(a,b) if (a != b) ((a ^= b), (b ^= a), (a ^= b)) #ifndef max #define max(a,b) (((a) > (b)) ? (a) : (b)) -- cgit v1.2.3-70-g09d2 From 2d33d82794559b83131b83528279ce898716c112 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Fri, 30 Mar 2007 06:16:08 +0000 Subject: * Added all the missing defines for ctype.h functions and converted all the direct uses to the defines. Ref: http://www.eathena.ws/board/index.php?showtopic=145235 git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10091 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 +++ src/common/cbasetypes.h | 19 ++++++++++++++--- src/common/core.c | 2 +- src/common/showmsg.c | 4 ++-- src/common/strlib.c | 4 ++-- src/map/atcommand.c | 56 ++++++++++++++++++++++++------------------------- src/map/charcommand.c | 6 +++--- src/map/irc.c | 4 ++-- src/map/npc.c | 3 --- src/map/script.c | 14 ++++++------- 10 files changed, 64 insertions(+), 51 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 273315354..2c2df8c03 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,9 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2007/03/31 + * Added all the missing defines for ctype.h functions and converted all + the direct uses to the defines. [FlavioJS] 2007/03/30 * Added "do_abort" function to the core. It is invoked when the server has received a Segmentation Fault or Floating Point Exception signal. Currently diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 1a1cd22a9..b513b7fa3 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -297,9 +297,22 @@ typedef char bool; ////////////////////////////////////////////////////////////////////////// // Has to be unsigned to avoid problems in some systems -#define TOLOWER(c) ((char)tolower((unsigned char)(c))) -#define ISSPACE(c) (isspace((unsigned char)(c))) -#define ISALPHA(c) (isalpha((unsigned char)(c))) +// Problems arise when these functions expect an argument in the range [0,256[ and are feed a signed char. +// NOTE: needs to be included when using these defines #define ISALNUM(c) (isalnum((unsigned char)(c))) +#define ISALPHA(c) (isalpha((unsigned char)(c))) +#define ISCNTRL(c) (iscntrl((unsigned char)(c))) +#define ISDIGIT(c) (isdigit((unsigned char)(c))) +#define ISGRAPH(c) (isgraph((unsigned char)(c))) +#define ISLOWER(c) (islower((unsigned char)(c))) +#define ISPRINT(c) (isprint((unsigned char)(c))) +#define ISPUNCT(c) (ispunct((unsigned char)(c))) +#define ISSPACE(c) (isspace((unsigned char)(c))) +#define ISUPPER(c) (isupper((unsigned char)(c))) +#define ISXDIGIT(c) (isxdigit((unsigned char)(c))) +#define TOASCII(c) (toascii((unsigned char)(c))) +#define TOLOWER(c) (tolower((unsigned char)(c))) +#define TOUPPER(c) (toupper((unsigned char)(c))) + #endif /* _CBASETYPES_H_ */ diff --git a/src/common/core.c b/src/common/core.c index 60d25546a..8c57f98ea 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -152,7 +152,7 @@ const char* get_svn_revision(void) // Check the version if (fgets(line,sizeof(line),fp)) { - if(!isdigit(line[0])) + if(!ISDIGIT(line[0])) { // XML File format while (fgets(line,sizeof(line),fp)) diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 9323efa3f..dd8cfb07a 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -242,7 +242,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) q=q+2; while(1) { - if( isdigit((int)((unsigned char)*q)) ) + if( ISDIGIT(*q) ) { // add number to number array, only accept 2digits, shift out the rest // so // \033[123456789m will become \033[89m numbers[numpoint] = (numbers[numpoint]<<4) | (*q-'0'); @@ -565,7 +565,7 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr) q=q+2; while(1) { - if( isdigit((int)((unsigned char)*q)) ) + if( ISDIGIT(*q) ) { ++q; // and next character diff --git a/src/common/strlib.c b/src/common/strlib.c index ee37cb9ae..dd10d655e 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -150,7 +150,7 @@ const char *stristr(const char *haystack, const char *needle) } for ( ; *haystack; ++haystack ) { - if ( toupper(*haystack) == toupper(*needle) ) + if ( TOUPPER(*haystack) == TOUPPER(*needle) ) { /* * Matched starting char -- loop through remaining chars. @@ -158,7 +158,7 @@ const char *stristr(const char *haystack, const char *needle) const char *h, *n; for ( h = haystack, n = needle; *h && *n; ++h, ++n ) { - if ( toupper(*h) != toupper(*n) ) + if ( TOUPPER(*h) != TOUPPER(*n) ) { break; } diff --git a/src/map/atcommand.c b/src/map/atcommand.c index e47deeb25..1b12d336c 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -798,12 +798,12 @@ AtCommandType is_atcommand_sub(const int fd, struct map_session_data* sd, const memset(command, '\0', sizeof(command)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - while (*p && !isspace(*p)) + while (*p && !ISSPACE(*p)) p++; if (p - str >= sizeof(command)) // too long return AtCommand_Unknown; strncpy(command, str, p - str); - while (isspace(*p)) + while (ISSPACE(*p)) p++; if (type == AtCommand_Unknown || info.proc == NULL) { @@ -842,7 +842,7 @@ AtCommandType is_atcommand(const int fd, struct map_session_data* sd, const char return AtCommand_None; str += strlen(sd->status.name); - while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) { + while (*str && (ISSPACE(*str) || (s_flag == 0 && *str == ':'))) { if (*str == ':') s_flag = 1; str++; @@ -1107,8 +1107,8 @@ int atcommand_send(const int fd, struct map_session_data* sd, const char* comman #define SKIP_VALUE(p) \ {\ - while(*(p) && !isspace(*(p))) ++(p); /* non-space */\ - while(*(p) && isspace(*(p))) ++(p); /* space */\ + while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\ + while(*(p) && ISSPACE(*(p))) ++(p); /* space */\ } //define SKIP_VALUE @@ -1148,30 +1148,30 @@ int atcommand_send(const int fd, struct map_session_data* sd, const char* comman // parse packet contents SKIP_VALUE(message); while(*message != 0 && off < len){ - if(isdigit(*message) || *message == '-' || *message == '+') + if(ISDIGIT(*message) || *message == '-' || *message == '+') {// default (byte) GET_VALUE(message,num); WFIFOB(fd,off)=TOB(num); ++off; - } else if(toupper(*message) == 'B') + } else if(TOUPPER(*message) == 'B') {// byte ++message; GET_VALUE(message,num); WFIFOB(fd,off)=TOB(num); ++off; - } else if(toupper(*message) == 'W') + } else if(TOUPPER(*message) == 'W') {// word (2 bytes) ++message; GET_VALUE(message,num); WFIFOW(fd,off)=TOW(num); off+=2; - } else if(toupper(*message) == 'L') + } else if(TOUPPER(*message) == 'L') {// long word (4 bytes) ++message; GET_VALUE(message,num); WFIFOL(fd,off)=TOL(num); off+=4; - } else if(toupper(*message) == 'S') + } else if(TOUPPER(*message) == 'S') {// string - escapes are valid // get string length - num <= 0 means not fixed length (default) ++message; @@ -1181,7 +1181,7 @@ int atcommand_send(const int fd, struct map_session_data* sd, const char* comman GET_VALUE(message,num); while(*message != '"') {// find start of string - if(*message == 0 || isspace(*message)){ + if(*message == 0 || ISSPACE(*message)){ PARSE_ERROR("Not a string:",message); return -1; } @@ -1211,16 +1211,16 @@ int atcommand_send(const int fd, struct map_session_data* sd, const char* comman { ++message; CHECK_EOS(message); - if(!isxdigit(*message)){ + if(!ISXDIGIT(*message)){ PARSE_ERROR("Not a hexadecimal digit:",message); return -1; } - num=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10); - if(isxdigit(*message)){ + num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10); + if(ISXDIGIT(*message)){ ++message; CHECK_EOS(message); num<<=8; - num+=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10); + num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10); } WFIFOB(fd,off)=TOB(num); ++message; @@ -1239,12 +1239,12 @@ int atcommand_send(const int fd, struct map_session_data* sd, const char* comman num=*message-'0'; // 1st octal digit ++message; CHECK_EOS(message); - if(isdigit(*message) && *message < '8'){ + if(ISDIGIT(*message) && *message < '8'){ num<<=3; num+=*message-'0'; // 2nd octal digit ++message; CHECK_EOS(message); - if(isdigit(*message) && *message < '8'){ + if(ISDIGIT(*message) && *message < '8'){ num<<=3; num+=*message-'0'; // 3rd octal digit ++message; @@ -1492,7 +1492,7 @@ int atcommand_who3(const int fd, struct map_session_data* sd, const char* comman if (sscanf(message, "%99[^\n]", match_text) < 1) strcpy(match_text, ""); for (j = 0; match_text[j]; j++) - match_text[j] = tolower(match_text[j]); + match_text[j] = TOLOWER(match_text[j]); count = 0; GM_level = pc_isGM(sd); @@ -1503,7 +1503,7 @@ int atcommand_who3(const int fd, struct map_session_data* sd, const char* comman if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level memcpy(player_name, pl_sd->status.name, NAME_LENGTH); for (j = 0; player_name[j]; j++) - player_name[j] = tolower(player_name[j]); + player_name[j] = TOLOWER(player_name[j]); if (strstr(player_name, match_text) != NULL) { // search with no case sensitive if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) { @@ -1565,7 +1565,7 @@ int atcommand_who2(const int fd, struct map_session_data* sd, const char* comman if (sscanf(message, "%99[^\n]", match_text) < 1) strcpy(match_text, ""); for (j = 0; match_text[j]; j++) - match_text[j] = tolower(match_text[j]); + match_text[j] = TOLOWER(match_text[j]); count = 0; GM_level = pc_isGM(sd); @@ -1576,7 +1576,7 @@ int atcommand_who2(const int fd, struct map_session_data* sd, const char* comman if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level memcpy(player_name, pl_sd->status.name, NAME_LENGTH); for (j = 0; player_name[j]; j++) - player_name[j] = tolower(player_name[j]); + player_name[j] = TOLOWER(player_name[j]); if (strstr(player_name, match_text) != NULL) { // search with no case sensitive //Players Name //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name); @@ -1636,7 +1636,7 @@ int atcommand_who(const int fd, struct map_session_data* sd, const char* command if (sscanf(message, "%99[^\n]", match_text) < 1) strcpy(match_text, ""); for (j = 0; match_text[j]; j++) - match_text[j] = tolower(match_text[j]); + match_text[j] = TOLOWER(match_text[j]); count = 0; GM_level = pc_isGM(sd); @@ -1647,7 +1647,7 @@ int atcommand_who(const int fd, struct map_session_data* sd, const char* command if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level memcpy(player_name, pl_sd->status.name, NAME_LENGTH); for (j = 0; player_name[j]; j++) - player_name[j] = tolower(player_name[j]); + player_name[j] = TOLOWER(player_name[j]); if (strstr(player_name, match_text) != NULL) { // search with no case sensitive g = guild_search(pl_sd->status.guild_id); p = party_search(pl_sd->status.party_id); @@ -1901,7 +1901,7 @@ int atcommand_whogm(const int fd, struct map_session_data* sd, const char* comma if (sscanf(message, "%99[^\n]", match_text) < 1) strcpy(match_text, ""); for (j = 0; match_text[j]; j++) - match_text[j] = tolower(match_text[j]); + match_text[j] = TOLOWER(match_text[j]); count = 0; GM_level = pc_isGM(sd); @@ -1913,7 +1913,7 @@ int atcommand_whogm(const int fd, struct map_session_data* sd, const char* comma if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level memcpy(player_name, pl_sd->status.name, NAME_LENGTH); for (j = 0; player_name[j]; j++) - player_name[j] = tolower(player_name[j]); + player_name[j] = TOLOWER(player_name[j]); if (strstr(player_name, match_text) != NULL) { // search with no case sensitive sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); clif_displaymessage(fd, atcmd_output); @@ -1968,7 +1968,7 @@ int atcommand_whozeny(const int fd, struct map_session_data* sd, const char* com if (sscanf(message, "%99[^\n]", match_text) < 1) strcpy(match_text, ""); for (j = 0; match_text[j]; j++) - match_text[j] = tolower(match_text[j]); + match_text[j] = TOLOWER(match_text[j]); count = 0; pl_allsd = map_getallusers(&users); @@ -1983,7 +1983,7 @@ int atcommand_whozeny(const int fd, struct map_session_data* sd, const char* com if ((pl_sd = pl_allsd[i])) { memcpy(player_name, pl_sd->status.name, NAME_LENGTH); for (j = 0; player_name[j]; j++) - player_name[j] = tolower(player_name[j]); + player_name[j] = TOLOWER(player_name[j]); if (strstr(player_name, match_text) != NULL) { // search with no case sensitive zeny[count]=pl_sd->status.zeny; counted[i]=0; @@ -3248,7 +3248,7 @@ int atcommand_go(const int fd, struct map_session_data* sd, const char* command, // get possible name of the city map_name[MAP_NAME_LENGTH-1] = '\0'; for (i = 0; map_name[i]; i++) - map_name[i] = tolower(map_name[i]); + map_name[i] = TOLOWER(map_name[i]); // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too) if (strncmp(map_name, "prontera", 3) == 0) { // 3 first characters town = 0; diff --git a/src/map/charcommand.c b/src/map/charcommand.c index 696abd7c7..f241148c3 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -145,12 +145,12 @@ is_charcommand_sub(const int fd, struct map_session_data* sd, const char* str, i memset(command, '\0', sizeof(command)); memset(output, '\0', sizeof(output)); - while (*p && !isspace(*p)) + while (*p && !ISSPACE(*p)) p++; if (p - str >= sizeof(command)) // too long return CharCommand_Unknown; strncpy(command, str, p - str); - while (isspace(*p)) + while (ISSPACE(*p)) p++; if (type == CharCommand_Unknown || info.proc == NULL) { @@ -188,7 +188,7 @@ is_charcommand(const int fd, struct map_session_data* sd, const char* message) { return CharCommand_None; str += strlen(sd->status.name); - while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) { + while (*str && (ISSPACE(*str) || (s_flag == 0 && *str == ':'))) { if (*str == ':') s_flag = 1; str++; diff --git a/src/map/irc.c b/src/map/irc.c index 7228da81a..8760efc11 100644 --- a/src/map/irc.c +++ b/src/map/irc.c @@ -99,7 +99,7 @@ void irc_announce_shop(struct map_session_data *sd, int flag) strcpy(mapname, map[sd->bl.m].name); maplen = strcspn(mapname,"."); mapname[maplen] = '\0'; - mapname[0]=toupper(mapname[0]); + mapname[0]=TOUPPER(mapname[0]); sprintf(send_string,"PRIVMSG %s :%s has opened a shop, %s, at <%d,%d> in %s.",irc_trade_channel,sd->status.name,sd->message,sd->bl.x,sd->bl.y,mapname); } else @@ -123,7 +123,7 @@ void irc_announce_mvp(struct map_session_data *sd, struct mob_data *md) strcpy(mapname, map[md->bl.m].name); maplen = strcspn(mapname,"."); mapname[maplen] = '\0'; - mapname[0]=toupper(mapname[0]); + mapname[0]=TOUPPER(mapname[0]); sprintf(send_string,"PRIVMSG %s :%s the %s has MVP'd %s in %s.",irc_channel,sd->status.name,job_name(sd->status.class_),md->name, mapname); irc_send(send_string); diff --git a/src/map/npc.c b/src/map/npc.c index edeb6d8d4..0a6277894 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -32,9 +32,6 @@ #include "unit.h" #ifdef _WIN32 -#undef isspace -#define isspace(x) (x == ' ' || x == '\t') -#endif struct npc_src_list { struct npc_src_list * next; diff --git a/src/map/script.c b/src/map/script.c index 55a0eb23e..513d3be6f 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -353,18 +353,18 @@ static unsigned int calc_hash2(const unsigned char *p) #if defined(SCRIPT_HASH_DJB2) unsigned int h = 5381; while( *p ) // hash*33 + c - h = ( h << 5 ) + h + ((unsigned char)tolower(*p++)); + h = ( h << 5 ) + h + ((unsigned char)TOLOWER(*p++)); return h; #elif defined(SCRIPT_HASH_SDBM) unsigned int h = 0; while( *p ) - h = ( h << 6 ) + ( h << 16 ) - h + ((unsigned char)tolower(*p++)); + h = ( h << 6 ) + ( h << 16 ) - h + ((unsigned char)TOLOWER(*p++)); return h; #elif defined(SCRIPT_HASH_ELF) unsigned int h = 0; unsigned int g; while( *p ){ // UNIX ELF hash - h = ( h << 4 ) + ((unsigned char)tolower(*p++)); + h = ( h << 4 ) + ((unsigned char)TOLOWER(*p++)); if ( g = h & 0xF0000000 ) h ^= g >> 24; h &= ~g; @@ -374,7 +374,7 @@ static unsigned int calc_hash2(const unsigned char *p) unsigned int h = 0; unsigned int g; while( *p ){ - h = ( h << 4 ) + ((unsigned char)tolower(*p++)); + h = ( h << 4 ) + ((unsigned char)TOLOWER(*p++)); if ( (g=h&0xF0000000) ) { h ^= g>>24; h ^= g; @@ -385,7 +385,7 @@ static unsigned int calc_hash2(const unsigned char *p) unsigned int h = 0; while( *p ){ h = ( h << 1 ) + ( h >> 3 ) + ( h >> 5 ) + ( h >> 8 ); - h+=(unsigned char)tolower(*p++); + h+=(unsigned char)TOLOWER(*p++); } return h; #endif @@ -783,7 +783,7 @@ const char* parse_simpleexpr(const char *p) if( *p != ')' ) disp_error_message("parse_simpleexpr: unmatch ')'",p); ++p; - } else if(isdigit(*p) || ((*p=='-' || *p=='+') && isdigit(p[1]))){ + } else if(ISDIGIT(*p) || ((*p=='-' || *p=='+') && ISDIGIT(p[1]))){ char *np; i=strtoul(p,&np,0); add_scripti(i); @@ -1123,7 +1123,7 @@ const char* parse_syntax(const char* p) v = str_data[v].val; p = skip_word(p); } else { //Numeric value - if((*p == '-' || *p == '+') && isdigit(p[1])) // pre-skip because '-' can not skip_word + if((*p == '-' || *p == '+') && ISDIGIT(p[1])) // pre-skip because '-' can not skip_word p++; p = skip_word(p); if(np != p) -- cgit v1.2.3-70-g09d2 From cb2452c0149e4a4d1f9fa08bf1aafd146f3ca2de Mon Sep 17 00:00:00 2001 From: ultramage Date: Sat, 7 Apr 2007 21:15:34 +0000 Subject: - Fixed the platform-specific stricmp compilation problem - Fixed inverted vending tax equation (venders getting only 2% zeny instead of 98%), and made it more precise git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10182 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 2 ++ src/common/cbasetypes.h | 6 ++++++ src/common/mmo.h | 19 ------------------- src/map/clif.c | 6 +++--- src/map/vending.c | 2 +- src/tool/mapcache.c | 6 +++--- 6 files changed, 15 insertions(+), 26 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 329a56020..e080546c1 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -5,6 +5,8 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/04/08 + * Fixed the platform-specific stricmp compilation problem + * Fixed inverted vending tax equation (!) and made it more precise * Moved e_mail_check() and config_switch() to strlib.h * Synchronized the login servers a bit 2007/04/07 diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index b513b7fa3..6db351b67 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -198,8 +198,14 @@ typedef unsigned long long uint64; #if defined(_MSC_VER) || defined(__BORLANDC__) #define strcasecmp stricmp #define strncasecmp strnicmp +#define strncmpi strnicmp #define snprintf _snprintf #define vsnprintf _vsnprintf +#else +#define strcmpi strcasecmp +#define stricmp strcasecmp +#define strncmpi strncasecmp +#define strnicmp strncasecmp #endif // keyword replacement in windows diff --git a/src/common/mmo.h b/src/common/mmo.h index 75b741697..bd5a067d9 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -489,23 +489,4 @@ enum { JOB_SOUL_LINKER, }; -#ifndef __WIN32 - #ifndef strcmpi - #define strcmpi strcasecmp - #endif - #ifndef stricmp - #define stricmp strcasecmp - #endif - #ifndef strncmpi - #define strncmpi strncasecmp - #endif - #ifndef strnicmp - #define strnicmp strncasecmp - #endif -#else - #ifndef strncmpi - #define strncmpi strnicmp - #endif -#endif - #endif /* _MMO_H_ */ diff --git a/src/map/clif.c b/src/map/clif.c index 36ae1d658..92361d4e9 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5593,9 +5593,9 @@ int clif_openvending(struct map_session_data *sd,int id,struct vending *vending) nullpo_retr(0, sd); fd=sd->fd; - WFIFOHEAD(fd, 8+sd->vend_num*22); + WFIFOHEAD(fd, 8+sd->vend_num*22); buf = WFIFOP(fd,0); - for(i=0,n=0;ivend_num;i++){ + for(i = 0, n = 0; i < sd->vend_num; i++) { if (sd->vend_num > 2+pc_checkskill(sd,MC_VENDING)) return 0; WBUFL(buf,8+n*22)=vending[i].value; WBUFW(buf,12+n*22)=(index=vending[i].index)+2; @@ -5615,7 +5615,7 @@ int clif_openvending(struct map_session_data *sd,int id,struct vending *vending) clif_addcards(WBUFP(buf, 22+n*22), &sd->status.cart[index]); n++; } - if(n > 0){ + if(n > 0) { WBUFW(buf,0)=0x136; WBUFW(buf,2)=8+n*22; WBUFL(buf,4)=id; diff --git a/src/map/vending.c b/src/map/vending.c index 44f1a0f11..23a7d9ce8 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -159,7 +159,7 @@ void vending_purchasereq(struct map_session_data *sd,int len,int id,unsigned cha pc_payzeny(sd, (int)z); if (battle_config.vending_tax) - z = z*battle_config.vending_tax/10000; + z = z*(1 - battle_config.vending_tax/10000); pc_getzeny(vsd, (int)z); for(i = 0; 8 + 4 * i < len; i++) { diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index a1b537a56..d8f37d2b9 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -218,9 +218,9 @@ char *remove_extension(char *mapname) if (ptr) { //Check and remove extension. while (ptr[1] && (ptr2 = strchr(ptr+1, '.'))) ptr = ptr2; //Skip to the last dot. - if(strcmp(ptr,".gat") == 0 || - strcmp(ptr,".afm") == 0 || - strcmp(ptr,".af2") == 0) + if(stricmp(ptr,".gat") == 0 || + stricmp(ptr,".afm") == 0 || + stricmp(ptr,".af2") == 0) *ptr = '\0'; //Remove extension. } return mapname; -- cgit v1.2.3-70-g09d2 From 80de35a12f4da3003c7e4c8f63bbc72b075baa0f Mon Sep 17 00:00:00 2001 From: skotlex Date: Sun, 8 Apr 2007 14:51:36 +0000 Subject: - Made the return code \n for Apple systems (it was \r before), this still needs fixing, since it should be /r only for pre OSX systems. - status_change_start will no longer abort if the duration is less than 0 if the status is Ankle Snare (since this stat has it's own minimum) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10185 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/cbasetypes.h | 2 ++ src/map/status.c | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 6db351b67..9eef2d6e5 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -276,8 +276,10 @@ typedef char bool; #if defined(WIN32) || defined(CYGWIN) #define RETCODE "\r\n" // CR/LF : Windows systems +/*FIXME: Mac OSX also uses \n, only pre-OSX uses \r #elif defined(__APPLE__) #define RETCODE "\r" // CR : Macintosh systems +*/ #else #define RETCODE "\n" // LF : Unix systems #endif diff --git a/src/map/status.c b/src/map/status.c index a4fbef589..efba2b497 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -4464,7 +4464,6 @@ int status_get_sc_def(struct block_list *bl, int type) else if (sc->data[SC_SIEGFRIED].timer != -1) sc_def += 100*sc->data[SC_SIEGFRIED].val3; //Status resistance. } - return sc_def>10000?10000:sc_def; } @@ -4519,7 +4518,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val if (def && tick && !(flag&2)) { tick -= tick*def/10000; - if (tick <= 0) + if (tick <= 0 && type != SC_ANKLE) //Ankle Snare has it's opwn minimum return 0; } -- cgit v1.2.3-70-g09d2 From cc716ca00420c23bdb02831f8fc205d4588e1f75 Mon Sep 17 00:00:00 2001 From: ultramage Date: Mon, 9 Apr 2007 00:46:55 +0000 Subject: * Played around with MinGW a bit today... - adjusted code so that it handles mingw-specific compatibility problems - adjusted the makefile, mingw is not a subset of cygwin * As an experiment Corrected many /W4 warnings on the txt login server git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10192 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 5 + Makefile | 20 +-- src/char/Makefile | 2 +- src/char_sql/Makefile | 2 +- src/char_sql/int_homun.c | 2 +- src/common/cbasetypes.h | 6 +- src/common/core.c | 1 - src/common/grfio.c | 1 - src/common/showmsg.c | 7 +- src/common/socket.c | 4 +- src/common/strlib.c | 3 +- src/common/strlib.h | 2 +- src/login/login.c | 290 ++++++++++++++++++++------------------- src/login/login.h | 18 +-- src/login_sql/login.c | 12 +- src/map/Makefile | 2 +- src/map/atcommand.c | 1 - src/map/charcommand.c | 1 - src/map/clif.c | 1 - src/map/irc.c | 1 - src/map/map.h | 14 +- src/map/mercenary.c | 1 - src/map/npc.c | 1 - src/map/npc_chat.c | 1 - src/map/pc.c | 1 - src/map/script.c | 1 - src/map/status.c | 1 - src/tool/grfio.c | 1 - src/txt-converter/Makefile | 2 +- src/zlib/iowin32.c | 1 - vcproj-8/login-server_txt.vcproj | 1 + vcproj-8/map-server_txt.vcproj | 1 + 32 files changed, 205 insertions(+), 202 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 7798849fe..fe3d9ca7c 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,11 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2007/04/10 + * As an experiment Corrected many /W4 warnings on the txt login server + * Played around with MinGW a bit today... [ultramage] + - adjusted code so that it handles mingw-specific compatibility problems + - adjusted the makefile, mingw is not a subset of cygwin 2007/04/09 * Now when saving a character, only the cart/peco/falcon 'option' states are saved, the rest should be handled by the status change load/save diff --git a/Makefile b/Makefile index 6731c3807..70cb51326 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ OPT += -ffast-math # OPT += -fbounds-checking # OPT += -fstack-protector # OPT += -fomit-frame-pointer -OPT += -Wall -Wno-sign-compare +OPT += -Wall -Wno-sign-compare -Wno-unused-parameter ifeq ($(GCC_VERSION), 4) OPT += -Wno-unused-parameter -Wno-pointer-sign endif @@ -71,15 +71,19 @@ endif ifeq ($(findstring CYGWIN,$(PLATFORM)), CYGWIN) OPT += -DFD_SETSIZE=4096 - ifeq ($(findstring mingw,$(shell gcc --version)), mingw) - IS_MINGW = 1 - OS_TYPE = -DMINGW - LIBS += -L../.. -lwsock32 - else - OS_TYPE = -DCYGWIN - endif + OS_TYPE = -DCYGWIN endif +ifeq ($(findstring mingw,$(shell gcc --version)), mingw) + IS_MINGW = 1 + OS_TYPE = -DMINGW + OPT += -DFD_SETSIZE=4096 +# CFLAGS += -I../zlib +# LIBS += -L../../lib + LIBS += -lws2_32 +endif + + ifeq ($(findstring x86_64,$(ARCH)), x86_64) OPT += -m32 endif diff --git a/src/char/Makefile b/src/char/Makefile index 2f6f77ffd..51766ab53 100644 --- a/src/char/Makefile +++ b/src/char/Makefile @@ -17,7 +17,7 @@ char-server: char.o inter.o int_party.o int_guild.o int_status.o int_storage.o i $(CC) -o ../../$@ $> $(LIB_S) clean: - rm -f *.o ../../char-server + rm -f *.o ../../char-server GNUmakefile # DO NOT DELETE diff --git a/src/char_sql/Makefile b/src/char_sql/Makefile index 4d6772838..1b8a742f0 100644 --- a/src/char_sql/Makefile +++ b/src/char_sql/Makefile @@ -14,7 +14,7 @@ char-server_sql: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o $(CC) -o ../../$@ $^ $(LIB_S) clean: - rm -f *.o ../../char-server_sql + rm -f *.o ../../char-server_sql GNUmakefile # DO NOT DELETE diff --git a/src/char_sql/int_homun.c b/src/char_sql/int_homun.c index 2260ddf20..049530607 100644 --- a/src/char_sql/int_homun.c +++ b/src/char_sql/int_homun.c @@ -145,7 +145,7 @@ int mapif_load_homunculus(int fd){ RFIFOHEAD(fd); memset(homun_pt, 0, sizeof(struct s_homunculus)); - sprintf(tmp_sql,"SELECT `homun_id`,`char_id`,`class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `homunculus` WHERE `homun_id`='%u'", RFIFOL(fd,6)); + sprintf(tmp_sql,"SELECT `homun_id`,`char_id`,`class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `homunculus` WHERE `homun_id`='%lu'", RFIFOL(fd,6)); if(mysql_query(&mysql_handle, tmp_sql) ) { ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql); diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 9eef2d6e5..e8af6bc9c 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -29,6 +29,10 @@ #define WIN32 #endif +#if defined(__MINGW32__) && !defined(MINGW) +#define MINGW +#endif + // __APPLE__ is the only predefined macro on MacOS X #if defined(__APPLE__) #define __DARWIN__ @@ -306,7 +310,7 @@ typedef char bool; ////////////////////////////////////////////////////////////////////////// // Has to be unsigned to avoid problems in some systems // Problems arise when these functions expect an argument in the range [0,256[ and are feed a signed char. -// NOTE: needs to be included when using these defines +#include #define ISALNUM(c) (isalnum((unsigned char)(c))) #define ISALPHA(c) (isalpha((unsigned char)(c))) #define ISCNTRL(c) (iscntrl((unsigned char)(c))) diff --git a/src/common/core.c b/src/common/core.c index 17aaa7b3c..a0a6b4f16 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -8,7 +8,6 @@ #endif #include #include -#include #include "core.h" #include "../common/mmo.h" diff --git a/src/common/grfio.c b/src/common/grfio.c index a2d7f7f5a..b15b37018 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include "grfio.h" diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 58c26ac8a..c61530204 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -27,7 +27,6 @@ #endif #else #include - #include #ifdef DEBUGLOGMAP #define DEBUGLOGPATH "log/map-server.log" @@ -400,8 +399,8 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) // \033[#;#f - Horizontal & Vertical Position // The first # specifies the line number, the second # specifies the column. // The default for both is 1 - info.dwCursorPosition.X = (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F-1):0; - info.dwCursorPosition.Y = (numpoint && numbers[numpoint-1])?(numbers[numpoint-1]>>4)*10+(numbers[numpoint-1]&0x0F-1):0; + info.dwCursorPosition.X = (numbers[numpoint])?(numbers[numpoint]>>4)*10+((numbers[numpoint]&0x0F)-1):0; + info.dwCursorPosition.Y = (numpoint && numbers[numpoint-1])?(numbers[numpoint-1]>>4)*10+((numbers[numpoint-1]&0x0F)-1):0; if( info.dwCursorPosition.X >= info.dwSize.X ) info.dwCursorPosition.Y = info.dwSize.X-1; if( info.dwCursorPosition.Y >= info.dwSize.Y ) info.dwCursorPosition.Y = info.dwSize.Y-1; @@ -480,7 +479,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) else if( *q == 'G' ) { // \033[#G - Cursor Horizontal Absolute (CHA) // Moves the cursor to indicated column in current row. - info.dwCursorPosition.X = (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F-1):0; + info.dwCursorPosition.X = (numbers[numpoint])?(numbers[numpoint]>>4)*10+((numbers[numpoint]&0x0F)-1):0; if( info.dwCursorPosition.X >= info.dwSize.X ) info.dwCursorPosition.X = info.dwSize.X-1; diff --git a/src/common/socket.c b/src/common/socket.c index 6d89b26e6..34c707827 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -81,7 +81,7 @@ int create_session(int fd, RecvFunc func_recv, SendFunc func_send, ParseFunc fun #ifndef MINICORE int ip_rules = 1; - static int connect_check(unsigned int ip); + static int connect_check(uint32 ip); #endif @@ -111,7 +111,7 @@ void set_nonblocking(int fd, int yes) // FIONBIO Use with a nonzero argp parameter to enable the nonblocking mode of socket s. // The argp parameter is zero if nonblocking is to be disabled. - if (ioctlsocket(fd, FIONBIO, &yes) != 0) + if (ioctlsocket(fd, FIONBIO, (unsigned long*)&yes) != 0) ShowError("Couldn't set the socket to non-blocking mode (code %d)!\n", s_errno); } diff --git a/src/common/strlib.c b/src/common/strlib.c index 0ad0575f7..bd49e7b61 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -4,7 +4,6 @@ #include #include #include -#include #include "strlib.h" #include "../common/cbasetypes.h" @@ -198,7 +197,7 @@ char* _strtok_r(char *s1, const char *s2, char **lasts) } #endif -#if !defined(WIN32) || (defined(_MSC_VER) && _MSC_VER < 1400) +#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) /* Find the length of STRING, but scan at most MAXLEN characters. If no '\0' terminator is found in that many characters, return MAXLEN. */ size_t strnlen (const char* string, size_t maxlen) diff --git a/src/common/strlib.h b/src/common/strlib.h index baaf244d7..bf26c2172 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -18,7 +18,7 @@ const char *stristr(const char *haystack, const char *needle); char* _strtok_r(char* s1, const char* s2, char** lasts); #endif -#if !defined(WIN32) || (defined(_MSC_VER) && _MSC_VER < 1400) +#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) size_t strnlen (const char* string, size_t maxlen); #endif diff --git a/src/login/login.c b/src/login/login.c index c7ff64446..bb4866970 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -36,11 +36,10 @@ #include "../common/md5calc.h" #include "login.h" -int account_id_count = START_ACCOUNT_NUM; -int server_num; -int new_account_flag = 0; +uint32 account_id_count = START_ACCOUNT_NUM; +bool new_account_flag = true; uint32 login_ip = INADDR_ANY; -int login_port = 6900; +uint16 login_port = 6900; // Advanced subnet check [LuzZza] struct _subnet { @@ -71,6 +70,8 @@ int display_parse_login = 0; // 0: no, 1: yes int display_parse_admin = 0; // 0: no, 1: yes int display_parse_fromchar = 0; // 0: no, 1: yes (without packet 0x2714), 2: all packets +// array of char server entries +#define MAX_SERVERS 30 struct mmo_char_server server[MAX_SERVERS]; int server_fd[MAX_SERVERS]; @@ -109,30 +110,33 @@ static int ip_sync_interval = 0; struct login_session_data { - unsigned int md5keylen; + uint16 md5keylen; char md5key[20]; }; #define AUTH_FIFO_SIZE 256 -struct { - int account_id, login_id1, login_id2; +struct auth_fifo { + uint32 account_id; + uint32 login_id1, login_id2; uint32 ip; - char sex; + uint8 sex; bool delflag; -} auth_fifo[AUTH_FIFO_SIZE]; +}; +struct auth_fifo auth_fifo[AUTH_FIFO_SIZE]; int auth_fifo_pos = 0; struct online_login_data { - int account_id; + uint32 account_id; int waiting_disconnect; - short char_server; + int char_server; }; struct auth_dat { - int account_id, sex; - char userid[24], pass[33], lastlogin[24]; // 33 for 32 + NULL terminated + uint32 account_id; + uint8 sex; // 0, 1, 2 + char userid[24], pass[32+1], lastlogin[24]; int logincount; - int state; // packet 0x006a value + 1 (0: compte OK) + uint32 state; // packet 0x006a value + 1 (0: compte OK) char email[40]; // e-mail (by default: a@a.com) char error_message[20]; // Message of error code #6 = Your are Prohibited to log in until %s (packet 0x006a) time_t ban_until_time; // # of seconds 1/1/1970 (timestamp): ban time limit of the account (0 = no ban) @@ -141,9 +145,10 @@ struct auth_dat { char memo[255]; // a memo field int account_reg2_num; struct global_reg account_reg2[ACCOUNT_REG2_NUM]; -} *auth_dat = NULL; +}; +struct auth_dat* auth_dat = NULL; -unsigned int auth_num = 0, auth_max = 0; +uint32 auth_num = 0, auth_max = 0; // define the number of times that some players must authentify them before to save account file. // it's just about normal authentification. If an account is created or modified, save is immediatly done. @@ -201,7 +206,8 @@ int login_log(char *fmt, ...) { return 0; } -static void* create_online_user(DBKey key, va_list args) { +static void* create_online_user(DBKey key, va_list args) +{ struct online_login_data *p; p = aCalloc(1, sizeof(struct online_login_data)); p->account_id = key.i; @@ -275,11 +281,12 @@ int isGM(int account_id) { //---------------------------------------------------------------------- // Adds a new GM using acc id and level //---------------------------------------------------------------------- -void addGM(int account_id, int level) { +void addGM(uint32 account_id, int level) +{ unsigned int i; int do_add = 0; for(i = 0; i < auth_num; i++) { - if (auth_dat[i].account_id==account_id) { + if (auth_dat[i].account_id == account_id) { do_add = 1; break; } @@ -325,7 +332,6 @@ int read_gm_account(void) { if(gm_account_db) aFree(gm_account_db); GM_num = 0; - if(GM_max < 0) GM_max = 256; gm_account_db = (struct gm_account*)aCalloc(GM_max, sizeof(struct gm_account)); // get last modify time/date @@ -393,12 +399,12 @@ int check_ipmask(uint32 ip, const unsigned char *str) // scan ip address - if (sscanf((const char*)str, "%u.%u.%u.%u/%n", &a0, &a1, &a2, &a3, &i) != 4 || i == 0) + if (sscanf((const char*)str, "%lu.%lu.%lu.%lu/%n", &a0, &a1, &a2, &a3, &i) != 4 || i == 0) return 0; p[0] = (uint8)a3; p[1] = (uint8)a2; p[2] = (uint8)a1; p[3] = (uint8)a0; // scan mask - if (sscanf((const char*)str+i, "%u.%u.%u.%u", &a0, &a1, &a2, &a3) == 4) { + if (sscanf((const char*)str+i, "%lu.%lu.%lu.%lu", &a0, &a1, &a2, &a3) == 4) { p2[0] = (uint8)a3; p2[1] = (uint8)a2; p2[2] = (uint8)a1; p2[3] = (uint8)a0; } else if (sscanf((const char*)(str+i), "%u", &m) == 1 && m >= 0 && m <= 32) { for(i = 32 - m; i < 32; i++) @@ -433,7 +439,7 @@ int check_ip(uint32 ip) // If we have an answer, there is no guarantee to have a 100% correct value. // And, the waiting time (to check) can be long (over 1 minute to a timeout). That can block the software. // So, DNS notation isn't authorised for ip checking. - sprintf(buf, "%d.%d.%d.%d.", CONVIP(ip)); + sprintf(buf, "%lu.%lu.%lu.%lu.", CONVIP(ip)); for(i = 0; i < access_allownum; i++) { access_ip = access_allow + i * ACO_STRSIZE; @@ -481,7 +487,7 @@ int check_ladminip(uint32 ip) // If we have an answer, there is no guarantee to have a 100% correct value. // And, the waiting time (to check) can be long (over 1 minute to a timeout). That can block the software. // So, DNS notation isn't authorised for ip checking. - sprintf(buf, "%d.%d.%d.%d.", CONVIP(ip)); + sprintf(buf, "%lu.%lu.%lu.%lu.", CONVIP(ip)); for(i = 0; i < access_ladmin_allownum; i++) { access_ip = access_ladmin_allow + i * ACO_STRSIZE; @@ -534,7 +540,7 @@ int mmo_auth_tostr(char *str, struct auth_dat *p) { int i; char *str_p = str; - str_p += sprintf(str_p, "%d\t%s\t%s\t%s\t%c\t%d\t%d\t%s\t%s\t%ld\t%s\t%s\t%ld\t", + str_p += sprintf(str_p, "%lu\t%s\t%s\t%s\t%c\t%d\t%lu\t%s\t%s\t%ld\t%s\t%s\t%ld\t", p->account_id, p->userid, p->pass, p->lastlogin, p->sex == 2 ? 'S' : p->sex == 1 ? 'M' : 'F', p->logincount, p->state, p->email, p->error_message, @@ -550,10 +556,13 @@ int mmo_auth_tostr(char *str, struct auth_dat *p) { //--------------------------------- // Reading of the accounts database //--------------------------------- -int mmo_auth_init(void) { +int mmo_auth_init(void) +{ FILE *fp; - int account_id, logincount, state, n, i; - unsigned int j; + uint32 account_id; + uint32 state; + int logincount, n; + uint32 i, j; char line[2048], *p, userid[2048], pass[2048], lastlogin[2048], sex, email[2048], error_message[2048], last_ip[2048], memo[2048]; long ban_until_time; long connect_until_time; @@ -589,11 +598,11 @@ int mmo_auth_init(void) { memset(memo, 0, sizeof(memo)); // database version reading (v2) - if (((i = sscanf(line, "%d\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%d\t" + if (((i = sscanf(line, "%lu\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%lu\t" "%[^\t]\t%[^\t]\t%ld\t%[^\t]\t%[^\t]\t%ld%n", &account_id, userid, pass, lastlogin, &sex, &logincount, &state, email, error_message, &connect_until_time, last_ip, memo, &ban_until_time, &n)) == 13 && line[n] == '\t') || - ((i = sscanf(line, "%d\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%d\t" + ((i = sscanf(line, "%lu\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%lu\t" "%[^\t]\t%[^\t]\t%ld\t%[^\t]\t%[^\t]%n", &account_id, userid, pass, lastlogin, &sex, &logincount, &state, email, error_message, &connect_until_time, last_ip, memo, &n)) == 12 && line[n] == '\t')) { @@ -609,7 +618,7 @@ int mmo_auth_init(void) { continue; } userid[23] = '\0'; - remove_control_chars((unsigned char *)userid); + remove_control_chars(userid); for(j = 0; j < auth_num; j++) { if (auth_dat[j].account_id == account_id) { ShowError(CL_RED"mmmo_auth_init: an account has an identical id to another.\n"); @@ -642,11 +651,11 @@ int mmo_auth_init(void) { strncpy(auth_dat[auth_num].userid, userid, 24); pass[23] = '\0'; - remove_control_chars((unsigned char *)pass); + remove_control_chars(pass); strncpy(auth_dat[auth_num].pass, pass, 24); lastlogin[23] = '\0'; - remove_control_chars((unsigned char *)lastlogin); + remove_control_chars(lastlogin); strncpy(auth_dat[auth_num].lastlogin, lastlogin, 24); auth_dat[auth_num].sex = (sex == 'S' || sex == 's') ? 2 : (sex == 'M' || sex == 'm'); @@ -667,12 +676,12 @@ int mmo_auth_init(void) { ShowNotice("Account %s (%d): invalid e-mail (replaced par a@a.com).\n", auth_dat[auth_num].userid, auth_dat[auth_num].account_id); strncpy(auth_dat[auth_num].email, "a@a.com", 40); } else { - remove_control_chars((unsigned char *)email); + remove_control_chars(email); strncpy(auth_dat[auth_num].email, email, 40); } error_message[19] = '\0'; - remove_control_chars((unsigned char *)error_message); + remove_control_chars(error_message); if (error_message[0] == '\0' || state != 7) { // 7, because state is packet 0x006a value + 1 strncpy(auth_dat[auth_num].error_message, "-", 20); } else { @@ -687,11 +696,11 @@ int mmo_auth_init(void) { auth_dat[auth_num].connect_until_time = (time_t)connect_until_time; last_ip[15] = '\0'; - remove_control_chars((unsigned char *)last_ip); + remove_control_chars(last_ip); strncpy(auth_dat[auth_num].last_ip, last_ip, 16); memo[254] = '\0'; - remove_control_chars((unsigned char *)memo); + remove_control_chars(memo); strncpy(auth_dat[auth_num].memo, memo, 255); for(j = 0; j < ACCOUNT_REG2_NUM; j++) { @@ -706,7 +715,7 @@ int mmo_auth_init(void) { break; } str[31] = '\0'; - remove_control_chars((unsigned char *)str); + remove_control_chars(str); strncpy(auth_dat[auth_num].account_reg2[j].str, str, 32); strncpy(auth_dat[auth_num].account_reg2[j].value,v,256); } @@ -722,7 +731,7 @@ int mmo_auth_init(void) { account_id_count = account_id + 1; // Old athena database version reading (v1) - } else if ((i = sscanf(line, "%d\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%d\t%n", + } else if ((i = sscanf(line, "%lu\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%lu\t%n", &account_id, userid, pass, lastlogin, &sex, &logincount, &state, &n)) >= 5) { if (account_id > END_ACCOUNT_NUM) { ShowError(CL_RED"mmmo_auth_init: an account has an id higher than %d\n", END_ACCOUNT_NUM); @@ -733,7 +742,7 @@ int mmo_auth_init(void) { continue; } userid[23] = '\0'; - remove_control_chars((unsigned char *)userid); + remove_control_chars(userid); for(j = 0; j < auth_num; j++) { if (auth_dat[j].account_id == account_id) { ShowError(CL_RED"mmo_auth_init: an account has an identical id to another.\n"); @@ -766,11 +775,11 @@ int mmo_auth_init(void) { strncpy(auth_dat[auth_num].userid, userid, 24); pass[23] = '\0'; - remove_control_chars((unsigned char *)pass); + remove_control_chars(pass); strncpy(auth_dat[auth_num].pass, pass, 24); lastlogin[23] = '\0'; - remove_control_chars((unsigned char *)lastlogin); + remove_control_chars(lastlogin); strncpy(auth_dat[auth_num].lastlogin, lastlogin, 24); auth_dat[auth_num].sex = (sex == 'S' || sex == 's') ? 2 : (sex == 'M' || sex == 'm'); @@ -813,7 +822,7 @@ int mmo_auth_init(void) { break; } str[31] = '\0'; - remove_control_chars((unsigned char *)str); + remove_control_chars(str); strncpy(auth_dat[auth_num].account_reg2[j].str, str, 32); strncpy(auth_dat[auth_num].account_reg2[j].value,v,256); } @@ -829,8 +838,8 @@ int mmo_auth_init(void) { account_id_count = account_id + 1; } else { - i = 0; - if (sscanf(line, "%d\t%%newid%%\n%n", &account_id, &i) == 1 && + int i = 0; + if (sscanf(line, "%lu\t%%newid%%\n%n", &account_id, &i) == 1 && i > 0 && account_id > account_id_count) account_id_count = account_id; } @@ -846,7 +855,7 @@ int mmo_auth_init(void) { sprintf(line, "1 account read in %s,", account_filename); } else { ShowStatus("mmo_auth_init: %d accounts read in %s,\n", auth_num, account_filename); - sprintf(line, "%d accounts read in %s,", auth_num, account_filename); + sprintf(line, "%lu accounts read in %s,", auth_num, account_filename); } if (GM_count == 0) { ShowStatus(" of which is no GM account, and "); @@ -882,9 +891,7 @@ void mmo_auth_sync(void) { FILE *fp; unsigned int i, j, k; int lock; - int account_id; - //int id[auth_num]; - //int *id = (int *)aCalloc(auth_num, sizeof(int)); + uint32 account_id; CREATE_BUFFER(id, int, auth_num); char line[65536]; @@ -923,13 +930,13 @@ void mmo_auth_sync(void) { fprintf(fp, "// ban time : 0: no ban, : banned until the date: date calculated by addition of 1/1/1970 + value (number of seconds since the 1/1/1970)\n"); for(i = 0; i < auth_num; i++) { k = id[i]; // use of sorted index - if (auth_dat[k].account_id < 0) + if (auth_dat[k].account_id == (uint32)-1) continue; mmo_auth_tostr(line, &auth_dat[k]); fprintf(fp, "%s" RETCODE, line); } - fprintf(fp, "%d\t%%newid%%\n", account_id_count); + fprintf(fp, "%lu\t%%newid%%\n", account_id_count); lock_fclose(fp, account_filename, &lock); @@ -992,8 +999,8 @@ int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len) void send_GM_accounts(void) { unsigned int i; - unsigned char buf[32767]; - int len; + uint8 buf[32767]; + uint16 len; len = 4; WBUFW(buf,0) = 0x2732; @@ -1001,7 +1008,7 @@ void send_GM_accounts(void) // send only existing accounts. We can not create a GM account when server is online. if (gm_account_db[i].level > 0) { WBUFL(buf,len) = gm_account_db[i].account_id; - WBUFB(buf,len+4) = (unsigned char)gm_account_db[i].level; + WBUFB(buf,len+4) = (uint8)gm_account_db[i].level; len += 5; if (len >= 32000) { ShowWarning("send_GM_accounts: Too many accounts! Only %d out of %d were sent.\n", i, GM_num); @@ -1374,7 +1381,7 @@ static int online_db_setoffline(DBKey key, void* data, va_list ap) //-------------------------------- int parse_fromchar(int fd) { - unsigned int i; + uint32 i; int j, id; uint32 ipl = session[fd]->client_addr; char ip[16]; @@ -1419,10 +1426,10 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 19) return 0; { - int account_id; - account_id = RFIFOL(fd,2); // speed up - for(i = 0; i < AUTH_FIFO_SIZE; i++) { - if (auth_fifo[i].account_id == account_id && + uint32 account_id = RFIFOL(fd,2); + for(i = 0; i < AUTH_FIFO_SIZE; i++) + { + if (auth_fifo[i].account_id == RFIFOL(fd,2) && auth_fifo[i].login_id1 == RFIFOL(fd,6) && auth_fifo[i].login_id2 == RFIFOL(fd,10) && // relate to the versions higher than 18 auth_fifo[i].sex == RFIFOB(fd,14) && @@ -1456,7 +1463,7 @@ int parse_fromchar(int fd) if (i == AUTH_FIFO_SIZE) { login_log("Char-server '%s': authentification of the account %d REFUSED (ip: %s)." RETCODE, server[id].name, account_id, ip); - WFIFOHEAD(fd,51); + WFIFOHEAD(fd,51); WFIFOW(fd,0) = 0x2713; WFIFOL(fd,2) = account_id; WFIFOB(fd,6) = 1; @@ -1486,9 +1493,9 @@ int parse_fromchar(int fd) return 0; { char email[40]; - int acc = RFIFOL(fd,2); + uint32 acc = RFIFOL(fd,2); memcpy(email, RFIFOP(fd,6), 40); email[39] = '\0'; - remove_control_chars((unsigned char *)email); + remove_control_chars(email); if (e_mail_check(email) == 0) login_log("Char-server '%s': Attempt to create an e-mail on an account with a default e-mail REFUSED - e-mail is invalid (account: %d, ip: %s)" RETCODE, server[id].name, acc, ip); else { @@ -1591,13 +1598,13 @@ int parse_fromchar(int fd) return 0; { char actual_email[40], new_email[40]; - int acc = RFIFOL(fd,2); + uint32 acc = RFIFOL(fd,2); memcpy(actual_email, RFIFOP(fd,6), 40); actual_email[39] = '\0'; - remove_control_chars((unsigned char *)actual_email); + remove_control_chars(actual_email); memcpy(new_email, RFIFOP(fd,46), 40); new_email[39] = '\0'; - remove_control_chars((unsigned char *)new_email); + remove_control_chars(new_email); if (e_mail_check(actual_email) == 0) login_log("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)" RETCODE, server[id].name, acc, ip); @@ -1634,7 +1641,7 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 10) return 0; { - int acc, statut; + uint32 acc, statut; acc = RFIFOL(fd,2); statut = RFIFOL(fd,6); for(i = 0; i < auth_num && auth_dat[i].account_id != acc; i++); @@ -1673,7 +1680,7 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 18) return 0; { - int acc = RFIFOL(fd,2); + uint32 acc = RFIFOL(fd,2); for(i = 0; i < auth_num; i++) { if (auth_dat[i].account_id == acc) { time_t timestamp; @@ -1737,8 +1744,8 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 6) return 0; { - int sex; - int acc = RFIFOL(fd,2); + uint8 sex; + uint32 acc = RFIFOL(fd,2); for(i = 0; i < auth_num; i++) { if (auth_dat[i].account_id == acc) { if (auth_dat[i].sex == 2) @@ -1751,7 +1758,7 @@ int parse_fromchar(int fd) else sex = 0; login_log("Char-server '%s': Sex change (account: %d, new sex %c, ip: %s)." RETCODE, - server[id].name, acc, (sex == 2) ? 'S' : (sex ? 'M' : 'F'), ip); + server[id].name, acc, (sex == 2) ? 'S' : (sex == 1 ? 'M' : 'F'), ip); for(j = 0; j < AUTH_FIFO_SIZE; j++) if (auth_fifo[j].account_id == acc) auth_fifo[j].login_id1++; // to avoid reconnection error when come back from map-server (char-server will ask again the authentification) @@ -1778,7 +1785,7 @@ int parse_fromchar(int fd) return 0; { int p; - int acc = RFIFOL(fd,4); + uint32 acc = RFIFOL(fd,4); for(i = 0; i < auth_num; i++) { if (auth_dat[i].account_id == acc) { //unsigned char buf[rfifow(fd,2)+1]; @@ -1788,14 +1795,14 @@ int parse_fromchar(int fd) login_log("char-server '%s': receiving (from the char-server) of account_reg2 (account: %d, ip: %s)." RETCODE, server[id].name, acc, ip); for(j=0,p=13;jforeach(online_db,online_db_setoffline,id); //Set all chars from this char-server offline first users = RFIFOW(fd,4); for (i = 0; i < users; i++) { @@ -1884,8 +1890,8 @@ int parse_fromchar(int fd) if (RFIFOREST(fd) < 10) return 0; { - int account_id = RFIFOL(fd, 2); - int char_id = RFIFOL(fd, 6); + uint32 account_id = RFIFOL(fd, 2); + uint32 char_id = RFIFOL(fd, 6); int p; RFIFOSKIP(fd,10); WFIFOW(fd,0) = 0x2729; @@ -1899,13 +1905,13 @@ int parse_fromchar(int fd) WFIFOSET(fd,WFIFOW(fd,2)); break; } - for(p = 13,j=0;j 0x1f) tmpstr[i % 16] = RFIFOB(fd,i); @@ -2025,7 +2031,8 @@ int parse_admin(int fd) if (RFIFOREST(fd) < 10) return 0; { - int st, ed, len; + int st, ed; + uint16 len; CREATE_BUFFER(id, int, auth_num); st = RFIFOL(fd,2); ed = RFIFOL(fd,6); @@ -2099,8 +2106,8 @@ int parse_admin(int fd) login_log("'ladmin': Attempt to create an account, but there is no more available id number (account: %s, pass: %s, sex: %c, ip: %s)" RETCODE, ma.userid, ma.passwd, ma.sex, ip); } else { - remove_control_chars((unsigned char *)ma.userid); - remove_control_chars((unsigned char *)ma.passwd); + remove_control_chars(ma.userid); + remove_control_chars(ma.passwd); for(i = 0; i < auth_num; i++) { if (strncmp(auth_dat[i].userid, ma.userid, 24) == 0) { login_log("'ladmin': Attempt to create an already existing account (account: %s, pass: %s, received pass: %s, ip: %s)" RETCODE, @@ -2113,7 +2120,7 @@ int parse_admin(int fd) char email[40]; memcpy(email, RFIFOP(fd,51), 40); email[39] = '\0'; - remove_control_chars((unsigned char *)email); + remove_control_chars(email); new_id = mmo_auth_new(&ma, ma.sex, email); login_log("'ladmin': Account creation (account: %s (id: %d), pass: %s, sex: %c, email: %s, ip: %s)" RETCODE, ma.userid, new_id, ma.passwd, ma.sex, auth_dat[i].email, ip); @@ -2133,7 +2140,7 @@ int parse_admin(int fd) WFIFOL(fd,2) = 0xFFFFFFFF; account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); i = search_account_index(account_name); if (i != -1) { // Char-server is notified of deletion (for characters deletion). @@ -2151,7 +2158,7 @@ int parse_admin(int fd) login_log("%s" RETCODE, buf); // delete account memset(auth_dat[i].userid, '\0', sizeof(auth_dat[i].userid)); - auth_dat[i].account_id = -1; + auth_dat[i].account_id = (uint32)-1; mmo_auth_sync(); } else { memcpy(WFIFOP(fd,6), account_name, 24); @@ -2169,13 +2176,13 @@ int parse_admin(int fd) WFIFOL(fd,2) = 0xFFFFFFFF; /// WTF??? an unsigned being set to a -1 account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); i = search_account_index(account_name); if (i != -1) { memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); memcpy(auth_dat[i].pass, RFIFOP(fd,26), 24); auth_dat[i].pass[23] = '\0'; - remove_control_chars((unsigned char *)auth_dat[i].pass); + remove_control_chars(auth_dat[i].pass); WFIFOL(fd,2) = auth_dat[i].account_id; login_log("'ladmin': Modification of a password (account: %s, new password: %s, ip: %s)" RETCODE, auth_dat[i].userid, auth_dat[i].pass, ip); @@ -2194,16 +2201,16 @@ int parse_admin(int fd) return 0; { char error_message[20]; - int statut; + uint32 statut; WFIFOW(fd,0) = 0x7937; WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); statut = RFIFOL(fd,26); memcpy(error_message, RFIFOP(fd,30), 20); error_message[19] = '\0'; - remove_control_chars((unsigned char *)error_message); + remove_control_chars(error_message); if (statut != 7 || error_message[0] == '\0') { // 7: // 6 = Your are Prohibited to log in until %s strcpy(error_message, "-"); } @@ -2248,8 +2255,9 @@ int parse_admin(int fd) break; case 0x7938: // Request for servers list and # of online players + { + uint8 server_num = 0; login_log("'ladmin': Sending of servers list (ip: %s)" RETCODE, ip); - server_num = 0; for(i = 0; i < MAX_SERVERS; i++) { if (server_fd[i] >= 0) { WFIFOL(fd,4+server_num*32) = htonl(server[i].ip); @@ -2266,6 +2274,7 @@ int parse_admin(int fd) WFIFOSET(fd,4+32*server_num); RFIFOSKIP(fd,2); break; + } case 0x793a: // Request to password check if (RFIFOREST(fd) < 50) @@ -2274,14 +2283,14 @@ int parse_admin(int fd) WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); i = search_account_index(account_name); if (i != -1) { char pass[25]; memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); memcpy(pass, RFIFOP(fd,26), 24); pass[24] = '\0'; - remove_control_chars((unsigned char *)pass); + remove_control_chars(pass); if (strcmp(auth_dat[i].pass, pass) == 0) { WFIFOL(fd,2) = auth_dat[i].account_id; login_log("'ladmin': Check of password OK (account: %s, password: %s, ip: %s)" RETCODE, @@ -2306,7 +2315,7 @@ int parse_admin(int fd) WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); memcpy(WFIFOP(fd,6), account_name, 24); { char sex; @@ -2358,7 +2367,7 @@ int parse_admin(int fd) WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); memcpy(WFIFOP(fd,6), account_name, 24); { char new_gm_level; @@ -2448,7 +2457,7 @@ int parse_admin(int fd) WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); memcpy(WFIFOP(fd,6), account_name, 24); { char email[40]; @@ -2457,7 +2466,7 @@ int parse_admin(int fd) login_log("'ladmin': Attempt to give an invalid e-mail (account: %s, ip: %s)" RETCODE, account_name, ip); } else { - remove_control_chars((unsigned char *)email); + remove_control_chars(email); i = search_account_index(account_name); if (i != -1) { memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); @@ -2483,7 +2492,7 @@ int parse_admin(int fd) WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); i = search_account_index(account_name); if (i != -1) { int size_of_memo = sizeof(auth_dat[i].memo); @@ -2497,7 +2506,7 @@ int parse_admin(int fd) memcpy(auth_dat[i].memo, RFIFOP(fd,28), RFIFOW(fd,26)); } auth_dat[i].memo[size_of_memo - 1] = '\0'; - remove_control_chars((unsigned char *)auth_dat[i].memo); + remove_control_chars(auth_dat[i].memo); WFIFOL(fd,2) = auth_dat[i].account_id; login_log("'ladmin': Modification of a memo field (account: %s, new memo: %s, ip: %s)" RETCODE, auth_dat[i].userid, auth_dat[i].memo, ip); @@ -2518,7 +2527,7 @@ int parse_admin(int fd) WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); i = search_account_index(account_name); if (i != -1) { memcpy(WFIFOP(fd,6), auth_dat[i].userid, 24); @@ -2567,7 +2576,7 @@ int parse_admin(int fd) WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); timestamp = (time_t)RFIFOL(fd,26); strftime(tmpstr, 24, date_format, localtime(×tamp)); i = search_account_index(account_name); @@ -2599,7 +2608,7 @@ int parse_admin(int fd) WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); timestamp = (time_t)RFIFOL(fd,26); if (timestamp <= time(NULL)) timestamp = 0; @@ -2647,7 +2656,7 @@ int parse_admin(int fd) WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); i = search_account_index(account_name); if (i != -1) { WFIFOL(fd,2) = auth_dat[i].account_id; @@ -2725,7 +2734,7 @@ int parse_admin(int fd) memset(message, '\0', sizeof(message)); memcpy(message, RFIFOP(fd,8), RFIFOL(fd,4)); message[sizeof(message)-1] = '\0'; - remove_control_chars((unsigned char *)message); + remove_control_chars(message); if (RFIFOW(fd,2) == 0) login_log("'ladmin': Receiving a message for broadcast (message (in yellow): %s, ip: %s)" RETCODE, message, ip); @@ -2754,7 +2763,7 @@ int parse_admin(int fd) WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); i = search_account_index(account_name); if (i != -1) { WFIFOL(fd,2) = auth_dat[i].account_id; @@ -2808,7 +2817,7 @@ int parse_admin(int fd) WFIFOL(fd,2) = 0xFFFFFFFF; // WTF??? account_name = (char*)RFIFOP(fd,2); account_name[23] = '\0'; - remove_control_chars((unsigned char *)account_name); + remove_control_chars(account_name); i = search_account_index(account_name); if (i != -1) { WFIFOL(fd,2) = auth_dat[i].account_id; @@ -2823,7 +2832,7 @@ int parse_admin(int fd) memcpy(WFIFOP(fd,100), auth_dat[i].email, 40); WFIFOL(fd,140) = (unsigned long)auth_dat[i].connect_until_time; WFIFOL(fd,144) = (unsigned long)auth_dat[i].ban_until_time; - WFIFOW(fd,148) = strlen(auth_dat[i].memo); + WFIFOW(fd,148) = (uint16)strlen(auth_dat[i].memo); if (auth_dat[i].memo[0]) { memcpy(WFIFOP(fd,150), auth_dat[i].memo, strlen(auth_dat[i].memo)); } @@ -2861,7 +2870,7 @@ int parse_admin(int fd) memcpy(WFIFOP(fd,100), auth_dat[i].email, 40); WFIFOL(fd,140) = (unsigned long)auth_dat[i].connect_until_time; WFIFOL(fd,144) = (unsigned long)auth_dat[i].ban_until_time; - WFIFOW(fd,148) = strlen(auth_dat[i].memo); + WFIFOW(fd,148) = (uint16)strlen(auth_dat[i].memo); if (auth_dat[i].memo[0]) { memcpy(WFIFOP(fd,150), auth_dat[i].memo, strlen(auth_dat[i].memo)); } @@ -3038,12 +3047,12 @@ int parse_login(int fd) if (!account.version) account.version = 1; //Force some version... memcpy(account.userid,RFIFOP(fd, 6),NAME_LENGTH); account.userid[23] = '\0'; - remove_control_chars((unsigned char *)account.userid); + remove_control_chars(account.userid); if (RFIFOW(fd,0) != 0x01dd) { login_log("Request for connection (non encryption mode) of %s (ip: %s)." RETCODE, account.userid, ip); memcpy(account.passwd, RFIFOP(fd,30), NAME_LENGTH); account.passwd[23] = '\0'; - remove_control_chars((unsigned char *)account.passwd); + remove_control_chars(account.passwd); } else { login_log("Request for connection (encryption mode) of %s (ip: %s)." RETCODE, account.userid, ip); // If remove control characters from received password encrypted by md5, @@ -3068,12 +3077,7 @@ int parse_login(int fd) WFIFOB(fd,2) = 1; // 01 = Server closed WFIFOSET(fd,3); } else { - if (gm_level) - ShowStatus("Connection of the GM (level:%d) account '%s' accepted.\n", gm_level, account.userid); - else - ShowStatus("Connection of the account '%s' accepted.\n", account.userid); - - server_num = 0; + uint8 server_num = 0; WFIFOHEAD(fd,47+32*MAX_SERVERS); for(i = 0; i < MAX_SERVERS; i++) { if (server_fd[i] >= 0) { @@ -3089,6 +3093,11 @@ int parse_login(int fd) } } if (server_num > 0) { // if at least 1 char-server + if (gm_level) + ShowStatus("Connection of the GM (level:%d) account '%s' accepted.\n", gm_level, account.userid); + else + ShowStatus("Connection of the account '%s' accepted.\n", account.userid); + WFIFOW(fd,0) = 0x69; WFIFOW(fd,2) = 47+32*server_num; WFIFOL(fd,4) = account.login_id1; @@ -3108,6 +3117,7 @@ int parse_login(int fd) auth_fifo[auth_fifo_pos].ip = session[fd]->client_addr; auth_fifo_pos++; } else { // if no char-server, don't send void list of servers, just disconnect the player with proper message + ShowStatus("Connection refused: there is no char-server online (account: %s, ip: %s).", account.userid, ip); login_log("Connection refused: there is no char-server online (account: %s, ip: %s)." RETCODE, account.userid, ip); WFIFOW(fd,0) = 0x81; @@ -3119,14 +3129,14 @@ int parse_login(int fd) WFIFOHEAD(fd,23); memset(WFIFOP(fd,0), '\0', 23); WFIFOW(fd,0) = 0x6a; - WFIFOB(fd,2) = result; + WFIFOB(fd,2) = (uint8)result; if (result == 6) { // 6 = Your are Prohibited to log in until %s char tmpstr[20]; time_t ban_until_time; i = search_account_index(account.userid); ban_until_time = (i) ? auth_dat[i].ban_until_time : 0; strftime(tmpstr, 20, date_format, localtime(&ban_until_time)); tmpstr[19] = '\0'; - strncpy(WFIFOP(fd,3), tmpstr, 20); // ban timestamp goes here + strncpy((char*)WFIFOP(fd,3), tmpstr, 20); // ban timestamp goes here } WFIFOSET(fd,23); } @@ -3151,9 +3161,9 @@ int parse_login(int fd) login_log("'ladmin': Sending request of the coding key (ip: %s)" RETCODE, ip); // Creation of the coding key memset(ld->md5key, '\0', sizeof(ld->md5key)); - ld->md5keylen = rand() % 4 + 12; + ld->md5keylen = (uint16)(12 + rand() % 4); for(i = 0; i < ld->md5keylen; i++) - ld->md5key[i] = rand() % 255 + 1; + ld->md5key[i] = (char)(1 + rand() % 255); RFIFOSKIP(fd,2); WFIFOHEAD(fd,4 + ld->md5keylen); @@ -3168,16 +3178,16 @@ int parse_login(int fd) if (RFIFOREST(fd) < 86) return 0; { - int len; + uint16 len; char* server_name; uint32 server_ip; uint16 server_port; WFIFOHEAD(fd,3); - memcpy(account.userid,RFIFOP(fd,2),NAME_LENGTH); account.userid[23] = '\0'; remove_control_chars((unsigned char *)account.userid); - memcpy(account.passwd, RFIFOP(fd,26), NAME_LENGTH); account.passwd[23] = '\0'; remove_control_chars((unsigned char *)account.passwd); + memcpy(account.userid,RFIFOP(fd,2),NAME_LENGTH); account.userid[23] = '\0'; remove_control_chars(account.userid); + memcpy(account.passwd, RFIFOP(fd,26), NAME_LENGTH); account.passwd[23] = '\0'; remove_control_chars(account.passwd); account.passwdenc = 0; - server_name = (char*)RFIFOP(fd,60); server_name[20] = '\0'; remove_control_chars((unsigned char *)server_name); + server_name = (char*)RFIFOP(fd,60); server_name[20] = '\0'; remove_control_chars(server_name); server_ip = ntohl(RFIFOL(fd, 54)); server_port = ntohs(RFIFOW(fd, 58)); login_log("Connection request of the char-server '%s' @ %d.%d.%d.%d:%d (ip: %s)" RETCODE, @@ -3274,7 +3284,7 @@ int parse_login(int fd) char password[25]; memcpy(password, RFIFOP(fd,4), 24); password[24] = '\0'; - remove_control_chars((unsigned char *)password); + remove_control_chars(password); // If remote administration is enabled and password sent by client matches password read from login server configuration file if ((admin_state == 1) && (strcmp(password, admin_pass) == 0)) { login_log("'ladmin'-login: Connection in administration mode accepted (non encrypted password: %s, ip: %s)" RETCODE, password, ip); @@ -3441,10 +3451,10 @@ int login_lan_config_read(const char *lancfgName) continue; } - remove_control_chars((unsigned char *)w1); - remove_control_chars((unsigned char *)w2); - remove_control_chars((unsigned char *)w3); - remove_control_chars((unsigned char *)w4); + remove_control_chars(w1); + remove_control_chars(w2); + remove_control_chars(w3); + remove_control_chars(w4); if(strcmpi(w1, "subnet") == 0) { @@ -3490,8 +3500,8 @@ int login_config_read(const char* cfgName) if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) < 2) continue; - remove_control_chars((unsigned char *)w1); - remove_control_chars((unsigned char *)w2); + remove_control_chars(w1); + remove_control_chars(w2); if(strcmpi(w1,"timestamp_format") == 0) { strncpy(timestamp_format, w2, 20); @@ -3544,7 +3554,7 @@ int login_config_read(const char* cfgName) if (login_ip) ShowStatus("Login server binding IP address : %s -> %s\n", w2, ip2str(login_ip, ip_str)); } else if (strcmpi(w1, "login_port") == 0) { - login_port = atoi(w2); + login_port = (uint16) atoi(w2); } else if (strcmpi(w1, "account_filename") == 0) { memset(account_filename, 0, sizeof(account_filename)); strncpy(account_filename, w2, sizeof(account_filename)); @@ -3635,7 +3645,7 @@ int login_config_read(const char* cfgName) } } else if(!strcmpi(w1, "new_account")) - new_account_flag = config_switch(w2); + new_account_flag = (bool)config_switch(w2); else if(!strcmpi(w1, "check_client_version")) check_client_version = config_switch(w2); else if(!strcmpi(w1, "client_version_to_connect")) @@ -3704,7 +3714,7 @@ void display_conf_warnings(void) { new_account_flag = 0; } - if (login_port < 1024 || login_port > 65535) { + if (login_port < 1024) { ShowWarning("Invalid value for login_port parameter -> setting to 6900 (default).\n"); login_port = 6900; } diff --git a/src/login/login.h b/src/login/login.h index 7845d3126..f5a7856b3 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -4,8 +4,6 @@ #ifndef _LOGIN_H_ #define _LOGIN_H_ -#define MAX_SERVERS 30 - #define LOGIN_CONF_NAME "conf/login_athena.conf" #define LAN_CONF_NAME "conf/subnet_athena.conf" #define PASSWORDENC 3 // A definition is given when making an encryption password correspond. @@ -13,31 +11,29 @@ // It is made into 2 at the time of passwordencrypt2. // When it is made 3, it corresponds to both. -extern int login_port; +extern uint16 login_port; + struct mmo_account { int version; char userid[NAME_LENGTH]; char passwd[NAME_LENGTH]; int passwdenc; - long account_id; + uint32 account_id; long login_id1; long login_id2; long char_id; char lastlogin[24]; - int sex; + char sex; }; struct mmo_char_server { char name[20]; uint32 ip; uint16 port; - int users; - int maintenance; - int new_; + uint16 users; // user count on this server + uint16 maintenance; // in maintenance mode? + uint16 new_; // allows creating new chars? }; -extern struct mmo_char_server server[MAX_SERVERS]; -extern int server_fd[MAX_SERVERS]; - #endif /* _LOGIN_H_ */ diff --git a/src/login_sql/login.c b/src/login_sql/login.c index 90a1b0981..5929c6da0 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -775,7 +775,7 @@ int parse_fromchar(int fd) case 0x2709: // request from map-server via char-server to reload GM accounts if (login_config.log_login) { - sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`log`) VALUES (NOW(), '%u', '%s', 'GM reload request')", loginlog_db, ipl, server[id].name); + sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`log`) VALUES (NOW(), '%lu', '%s', 'GM reload request')", loginlog_db, ipl, server[id].name); if (mysql_query(&mysql_handle, tmpsql)) { ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmpsql); @@ -1301,7 +1301,7 @@ int login_ip_ban_check(uint32 ip) if (login_config.log_login) { - sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', 'unknown','-3', 'ip banned')", loginlog_db, ip); + sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%lu', 'unknown','-3', 'ip banned')", loginlog_db, ip); // query if(mysql_query(&mysql_handle, tmpsql)) { ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); @@ -1409,7 +1409,7 @@ int parse_login(int fd) } else { WFIFOHEAD(fd,47+32*MAX_SERVERS); if (login_config.log_login) { - sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s','100', 'login ok')", loginlog_db, ipl, t_uid); + sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%lu', '%s','100', 'login ok')", loginlog_db, ipl, t_uid); //query if(mysql_query(&mysql_handle, tmpsql)) { ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); @@ -1493,7 +1493,7 @@ int parse_login(int fd) default : error = "Unknown Error."; break; } - sprintf(tmpsql, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s', '%d','login failed : %s')", loginlog_db, ipl, t_uid, result, error); + sprintf(tmpsql, "INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%lu', '%s', '%d','login failed : %s')", loginlog_db, ipl, t_uid, result, error); //query if(mysql_query(&mysql_handle, tmpsql)) { @@ -1503,7 +1503,7 @@ int parse_login(int fd) } if ((result == 1) && login_config.dynamic_pass_failure_ban && login_config.log_login) { // failed password - sprintf(tmpsql,"SELECT count(*) FROM `%s` WHERE `ip` = '%u' AND `rcode` = '1' AND `time` > NOW() - INTERVAL %d MINUTE", + sprintf(tmpsql,"SELECT count(*) FROM `%s` WHERE `ip` = '%lu' AND `rcode` = '1' AND `time` > NOW() - INTERVAL %d MINUTE", loginlog_db, ipl, login_config.dynamic_pass_failure_ban_interval); //how many times filed account? in one ip. if(mysql_query(&mysql_handle, tmpsql)) { ShowSQL("DB error - %s\n",mysql_error(&mysql_handle)); @@ -1599,7 +1599,7 @@ int parse_login(int fd) { char t_login[50]; jstrescapecpy(t_login,account.userid); - sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%u', '%s@%s','100', 'charserver - %s@%d.%d.%d.%d:%d')", + sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%lu', '%s@%s','100', 'charserver - %s@%lu.%lu.%lu.%lu:%d')", loginlog_db, ipl, t_login, t_uid, t_uid, CONVIP(server_ip), server_port); //query diff --git a/src/map/Makefile b/src/map/Makefile index 10af86c8f..2a25528eb 100644 --- a/src/map/Makefile +++ b/src/map/Makefile @@ -40,7 +40,7 @@ sqlobj/%.o: %.c $(COMPILE.c) $(OUTPUT_OPTION) $< clean: - rm -rf *.o ../../map-server ../../map-server_sql sqlobj txtobj + rm -rf *.o ../../map-server ../../map-server_sql sqlobj txtobj GNUmakefile # DO NOT DELETE diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 6acd8334f..77b1edf0c 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include "../common/cbasetypes.h" diff --git a/src/map/charcommand.c b/src/map/charcommand.c index 415f216d5..209116bc4 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include "../common/cbasetypes.h" diff --git a/src/map/clif.c b/src/map/clif.c index 92361d4e9..a4ba467ed 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5,7 +5,6 @@ #define DUMP_ALL_PACKETS 0 #include -#include #include #include #include diff --git a/src/map/irc.c b/src/map/irc.c index 863631394..b024137e0 100644 --- a/src/map/irc.c +++ b/src/map/irc.c @@ -1,7 +1,6 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include #include #include #include diff --git a/src/map/map.h b/src/map/map.h index 468f7a7d6..bf748df3b 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -828,8 +828,8 @@ struct npc_data { short n; short class_; short speed; - unsigned char name[NAME_LENGTH]; - unsigned char exname[NAME_LENGTH]; + char name[NAME_LENGTH]; + char exname[NAME_LENGTH]; int chat_id; unsigned int next_walktime; @@ -1243,8 +1243,8 @@ enum { struct chat_data { struct block_list bl; - unsigned char pass[8+1]; /* password */ - unsigned char title[60+1]; /* room title */ + char pass[8+1]; /* password */ + char title[60+1]; /* room title */ unsigned char limit; /* join limit */ unsigned char trigger; unsigned char users; /* current users */ @@ -1405,10 +1405,8 @@ extern char *map_server_dns; #ifndef TXT_ONLY -// MySQL -#ifdef __WIN32 -#include -#include +#ifdef _WIN32 +#include // SOCKET #endif #include diff --git a/src/map/mercenary.c b/src/map/mercenary.c index c21a8721d..899764ec8 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include "../common/cbasetypes.h" diff --git a/src/map/npc.c b/src/map/npc.c index faee6fc10..941eec4c8 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -3,7 +3,6 @@ #include #include -#include #include #include #include diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 6288714bc..f5a7762d6 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -4,7 +4,6 @@ #ifdef PCRE_SUPPORT #include -#include #include #include #include diff --git a/src/map/pc.c b/src/map/pc.c index 22bccbb00..eca06237d 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include "../common/cbasetypes.h" diff --git a/src/map/script.c b/src/map/script.c index c305bf6ec..afa7146b0 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #ifndef WIN32 #include diff --git a/src/map/status.c b/src/map/status.c index efba2b497..c2445bde2 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2,7 +2,6 @@ // For more information, see LICENCE in the main folder #include -#include #include #include #include diff --git a/src/tool/grfio.c b/src/tool/grfio.c index 72034d92f..b02563ce7 100644 --- a/src/tool/grfio.c +++ b/src/tool/grfio.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "grfio.h" diff --git a/src/txt-converter/Makefile b/src/txt-converter/Makefile index aa559e915..419029e19 100644 --- a/src/txt-converter/Makefile +++ b/src/txt-converter/Makefile @@ -13,7 +13,7 @@ login-converter: login-converter.o ../common/obj/minicore.o ../common/obj/db.o . $(CC) -o ../../tools/$@ $^ $(LIB_S) clean: - rm -f *.o ../../tools/login-converter ../../tools/char-converter + rm -f *.o ../../tools/login-converter ../../tools/char-converter GNUmakefile # DO NOT DELETE diff --git a/src/zlib/iowin32.c b/src/zlib/iowin32.c index a9b5f7839..e54cb13b7 100644 --- a/src/zlib/iowin32.c +++ b/src/zlib/iowin32.c @@ -67,7 +67,6 @@ voidpf ZCALLBACK win32_open_file_func (opaque, filename, mode) const char* filename; int mode; { - const char* mode_fopen = NULL; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; HANDLE hFile = 0; voidpf ret=NULL; diff --git a/vcproj-8/login-server_txt.vcproj b/vcproj-8/login-server_txt.vcproj index b28731e69..d68404933 100644 --- a/vcproj-8/login-server_txt.vcproj +++ b/vcproj-8/login-server_txt.vcproj @@ -39,6 +39,7 @@ /> Date: Mon, 9 Apr 2007 13:03:34 +0000 Subject: * Changed db key from 'unsigned char*' to 'const char*'. * Defined out the dump function in util.h/c. Notes: saw some suspicious code in npc.c so kept the 'const char*' propagation to a minimum for now git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10193 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 2 ++ src/common/cbasetypes.h | 3 +- src/common/db.c | 70 +++++++++++++++++--------------------------- src/common/db.h | 25 +++++----------- src/common/ers.c | 2 +- src/common/ers.h | 2 +- src/common/malloc.h | 2 ++ src/common/utils.c | 77 ++++++++++++++++++++++++++----------------------- src/common/utils.h | 6 +++- src/map/npc.c | 28 +++++++++--------- 10 files changed, 102 insertions(+), 115 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index fe3d9ca7c..c3cb7f7f6 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/04/10 + * Changed db key from 'unsigned char*' to 'const char*'. + * Defined out the dump function in util.h/c. [FlavioJS] * As an experiment Corrected many /W4 warnings on the txt login server * Played around with MinGW a bit today... [ultramage] - adjusted code so that it handles mingw-specific compatibility problems diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index e8af6bc9c..67c5a45db 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -157,7 +157,8 @@ typedef unsigned long int ppuint32; // integer with exact processor width (and best speed) // size_t already defined in stdio.h ////////////////////////////// -// +#include // size_t + #if defined(WIN32) && !defined(MINGW) // does not have a signed size_t ////////////////////////////// #if defined(_WIN64) // naive 64bit windows platform diff --git a/src/common/db.c b/src/common/db.c index f25afb5c3..98d7ae032 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -75,10 +75,6 @@ #include "../common/showmsg.h" #include "../common/ers.h" -//TODO: get rid of this -#define LOWER(c) (((c)>='A' && (c) <= 'Z') ? ((c)+('a'-'A')) : (c)) -#define UPPER(c) (((c)>='a' && (c) <= 'z') ? ((c)+('A'-'a')) : (c)) - /*****************************************************************************\ * (1) Private typedefs, enums, structures, defines and global variables of * * the database system. * @@ -642,7 +638,7 @@ static void db_dup_key_free(DB_impl db, DBKey key) switch (db->type) { case DB_STRING: case DB_ISTRING: - aFree(key.str); + aFree((char*)key.str); return; default: @@ -962,7 +958,7 @@ static unsigned int db_uint_hash(DBKey key, unsigned short maxlen) */ static unsigned int db_string_hash(DBKey key, unsigned short maxlen) { - unsigned char *k = key.str; + const char *k = key.str; unsigned int hash = 0; unsigned short i; @@ -972,8 +968,9 @@ static unsigned int db_string_hash(DBKey key, unsigned short maxlen) if (maxlen == 0) maxlen = UINT16_MAX; - for (i = 0; *k; i++) { - hash = (hash*33 + *k++)^(hash>>24); + for (i = 0; *k; ++i) { + hash = (hash*33 + ((unsigned char)*k))^(hash>>24); + k++; if (i == maxlen) break; } @@ -992,7 +989,7 @@ static unsigned int db_string_hash(DBKey key, unsigned short maxlen) */ static unsigned int db_istring_hash(DBKey key, unsigned short maxlen) { - unsigned char *k = key.str; + const char *k = key.str; unsigned int hash = 0; unsigned short i; @@ -1003,7 +1000,7 @@ static unsigned int db_istring_hash(DBKey key, unsigned short maxlen) maxlen = UINT16_MAX; for (i = 0; *k; i++) { - hash = (hash*33 + LOWER(*k))^(hash>>24); + hash = (hash*33 + ((unsigned char)TOLOWER(*k)))^(hash>>24); k++; if (i == maxlen) break; @@ -1044,7 +1041,7 @@ static void db_release_key(DBKey key, void *data, DBRelease which) #ifdef DB_ENABLE_STATS COUNT(db_release_key); #endif /* DB_ENABLE_STATS */ - if (which&DB_RELEASE_KEY) aFree(key.str); // needs to be a pointer + if (which&DB_RELEASE_KEY) aFree((char*)key.str); // needs to be a pointer } /** @@ -1083,7 +1080,7 @@ static void db_release_both(DBKey key, void *data, DBRelease which) #ifdef DB_ENABLE_STATS COUNT(db_release_both); #endif /* DB_ENABLE_STATS */ - if (which&DB_RELEASE_KEY) aFree(key.str); // needs to be a pointer + if (which&DB_RELEASE_KEY) aFree((char*)key.str); // needs to be a pointer if (which&DB_RELEASE_DATA) aFree(data); } @@ -1893,19 +1890,18 @@ static DBOptions db_obj_options(DB self) } /*****************************************************************************\ - * (5) Section with public functions. * - * db_fix_options - Apply database type restrictions to the options. * - * db_default_cmp - Get the default comparator for a type of database. * - * db_default_hash - Get the default hasher for a type of database. * - * db_default_release - Get the default releaser for a type of database * - * with the specified options. * - * db_custom_release - Get a releaser that behaves a certains way. * - * db_alloc - Allocate a new database. * - * db_i2key - Manual cast from 'int' to 'DBKey'. * - * db_ui2key - Manual cast from 'unsigned int' to 'DBKey'. * - * db_str2key - Manual cast from 'unsigned char *' to 'DBKey'. * - * db_init - Initialize the database system. * - * db_final - Finalize the database system. * + * (5) Section with public functions. + * db_fix_options - Apply database type restrictions to the options. + * db_default_cmp - Get the default comparator for a type of database. + * db_default_hash - Get the default hasher for a type of database. + * db_default_release - Get the default releaser for a type of database with the specified options. + * db_custom_release - Get a releaser that behaves a certains way. + * db_alloc - Allocate a new database. + * db_i2key - Manual cast from 'int' to 'DBKey'. + * db_ui2key - Manual cast from 'unsigned int' to 'DBKey'. + * db_str2key - Manual cast from 'unsigned char *' to 'DBKey'. + * db_init - Initializes the database system. + * db_final - Finalizes the database system. \*****************************************************************************/ /** @@ -2137,8 +2133,6 @@ DB db_alloc(const char *file, int line, DBType type, DBOptions options, unsigned * @return The key as a DBKey union * @public * @see #DB_MANUAL_CAST_TO_UNION - * @see #db_ui2key(unsigned int) - * @see #db_str2key(unsigned char *) */ DBKey db_i2key(int key) { @@ -2157,10 +2151,7 @@ DBKey db_i2key(int key) * @param key Key to be casted * @return The key as a DBKey union * @public - * @see common\db.h#DB_MANUAL_CAST_TO_UNION - * @see #db_i2key(int) - * @see #db_str2key(unsigned char *) - * @see common\db.h#db_ui2key(unsigned int) + * @see #DB_MANUAL_CAST_TO_UNION */ DBKey db_ui2key(unsigned int key) { @@ -2174,17 +2165,14 @@ DBKey db_ui2key(unsigned int key) } /** - * Manual cast from 'unsigned char *' to the union DBKey. + * Manual cast from 'const char *' to the union DBKey. * Created for compilers that don't support casting to unions. * @param key Key to be casted * @return The key as a DBKey union * @public - * @see common\db.h#DB_MANUAL_CAST_TO_UNION - * @see #db_i2key(int) - * @see #db_ui2key(unsigned int) - * @see common\db.h#db_str2key(unsigned char *) + * @see #DB_MANUAL_CAST_TO_UNION */ -DBKey db_str2key(unsigned char *key) +DBKey db_str2key(const char *key) { DBKey ret; @@ -2197,10 +2185,9 @@ DBKey db_str2key(unsigned char *key) #endif /* DB_MANUAL_CAST_TO_UNION */ /** - * Initialize the database system. + * Initializes the database system. * @public * @see #db_final(void) - * @see common\db.h#db_init(void) */ void db_init(void) { @@ -2210,12 +2197,9 @@ void db_init(void) } /** - * Finalize the database system. - * Frees the memory used by the block reusage system. + * Finalizes the database system. * @public - * @see common\db.h#DB_FINAL_NODE_CHECK * @see #db_init(void) - * @see common\db.h#db_final(void) */ void db_final(void) { diff --git a/src/common/db.h b/src/common/db.h index 0c19b5fc2..992469f66 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -78,7 +78,7 @@ * @see #DBReleaser * @see #db_custom_release(DBRelease) */ -typedef enum { +typedef enum DBRelease { DB_RELEASE_NOTHING = 0, DB_RELEASE_KEY = 1, DB_RELEASE_DATA = 2, @@ -102,7 +102,7 @@ typedef enum { * @see #db_default_release(DBType,DBOptions) * @see #db_alloc(const char *,int,DBType,DBOptions,unsigned short) */ -typedef enum { +typedef enum DBType { DB_INT, DB_UINT, DB_STRING, @@ -154,7 +154,7 @@ typedef enum db_opt { typedef union dbkey { int i; unsigned int ui; - unsigned char *str;//## TODO change to 'const char *' + const char *str; } DBKey; /** @@ -272,7 +272,7 @@ struct dbt { * @protected * @see #db_get(DB,DBKey) */ - void *(*get)(struct dbt *dbi, DBKey key); + void *(*get)(DB self, DBKey key); /** * Just calls {@link DB#vgetall(DB,void **,unsigned int,DBMatch,va_list)}. @@ -498,8 +498,8 @@ struct dbt { #else /* not DB_MANUAL_CAST_TO_UNION */ # define i2key(k) ((DBKey)(int)(k)) # define ui2key(k) ((DBKey)(unsigned int)(k)) -# define str2key(k) ((DBKey)(unsigned char *)(k)) -#endif /* DB_MANUAL_CAST_TO_UNION / not DB_MANUAL_CAST_TO_UNION */ +# define str2key(k) ((DBKey)(const char *)(k)) +#endif /* not DB_MANUAL_CAST_TO_UNION */ #define db_get(db,k) (db)->get((db),(k)) #define idb_get(db,k) (db)->get((db),i2key(k)) @@ -638,9 +638,6 @@ DB db_alloc(const char *file, int line, DBType type, DBOptions options, unsigned * @return The key as a DBKey union * @public * @see #DB_MANUAL_CAST_TO_UNION - * @see #db_ui2key(unsigned int) - * @see #db_str2key(unsigned char *) - * @see common\db.c#db_i2key(int) */ DBKey db_i2key(int key); @@ -651,9 +648,6 @@ DBKey db_i2key(int key); * @return The key as a DBKey union * @public * @see #DB_MANUAL_CAST_TO_UNION - * @see #db_i2key(int) - * @see #db_str2key(unsigned char *) - * @see common\db.c#db_ui2key(unsigned int) */ DBKey db_ui2key(unsigned int key); @@ -664,18 +658,14 @@ DBKey db_ui2key(unsigned int key); * @return The key as a DBKey union * @public * @see #DB_MANUAL_CAST_TO_UNION - * @see #db_i2key(int) - * @see #db_ui2key(unsigned int) - * @see common\db.c#db_str2key(unsigned char *) */ -DBKey db_str2key(unsigned char *key); +DBKey db_str2key(const char *key); #endif /* DB_MANUAL_CAST_TO_UNION */ /** * Initialize the database system. * @public * @see #db_final(void) - * @see common\db.c#db_init(void) */ void db_init(void); @@ -684,7 +674,6 @@ void db_init(void); * Frees the memory used by the block reusage system. * @public * @see #db_init(void) - * @see common\db.c#db_final(void) */ void db_final(void); diff --git a/src/common/ers.c b/src/common/ers.c index 485bab7d9..109378d5f 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -349,7 +349,7 @@ static void ers_obj_destroy(ERS self) * @see #ers_root * @see #ers_num */ -ERS ers_new(size_t size) +ERS ers_new(uint32 size) { ERS_impl obj; uint32 i; diff --git a/src/common/ers.h b/src/common/ers.h index e07ec7137..51b12d8a2 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -142,7 +142,7 @@ typedef struct eri { * @param The requested size of the entry in bytes * @return Interface of the object */ -ERS ers_new(size_t size); +ERS ers_new(uint32 size); /** * Print a report about the current state of the Entry Reusage System. diff --git a/src/common/malloc.h b/src/common/malloc.h index 5411d670d..43eff40f1 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -4,6 +4,8 @@ #ifndef _MALLOC_H_ #define _MALLOC_H_ +#include "../common/cbasetypes.h" + // Q: What are the 'a'-variant allocation functions? // A: They allocate memory from the stack, which is automatically // freed when the invoking function returns. diff --git a/src/common/utils.c b/src/common/utils.c index 2f5cf8705..d6a017c95 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -1,6 +1,12 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#include "../common/cbasetypes.h" +#include "../common/mmo.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "utils.h" + #include #include #include @@ -14,42 +20,41 @@ #include #endif -#include "utils.h" -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/cbasetypes.h" - -void dump(unsigned char* buffer, int num) +#ifdef UTIL_DUMP +void dump(const unsigned char* buffer, int num) { - int icnt, jcnt; - - printf(" Hex ASCII\n"); - printf(" ----------------------------------------------- ----------------"); - - for (icnt = 0; icnt < num; icnt += 16) { - printf("\n%p ", &buffer[icnt]); - for (jcnt = icnt; jcnt < icnt + 16; ++jcnt) { - if (jcnt < num) { - printf("%02hX ", buffer[jcnt]); - } else - printf(" "); - } - - printf(" | "); - - for (jcnt = icnt; jcnt < icnt + 16; ++jcnt) { - if (jcnt < num) { - if (buffer[jcnt] > 31 && buffer[jcnt] < 127) - printf("%c", buffer[jcnt]); - else - printf("."); - } else - printf(" "); - } - } - printf("\n"); + int icnt, jcnt; + + printf(" Hex ASCII\n"); + printf(" ----------------------------------------------- ----------------"); + + for (icnt = 0; icnt < num; icnt += 16) + { + printf("\n%p ", &buffer[icnt]); + for (jcnt = icnt; jcnt < icnt + 16; ++jcnt) + { + if (jcnt < num) + printf("%02hX ", buffer[jcnt]); + else + printf(" "); + } + + printf(" | "); + + for (jcnt = icnt; jcnt < icnt + 16; ++jcnt) + { + if (jcnt < num) { + if (buffer[jcnt] > 31 && buffer[jcnt] < 127) + printf("%c", buffer[jcnt]); + else + printf("."); + } else + printf(" "); + } + } + printf("\n"); } +#endif // Allocate a StringBuf [MouseJstr] struct StringBuf * StringBuf_Malloc() @@ -141,7 +146,7 @@ char * StringBuf_Value(struct StringBuf *sbuf) #ifdef WIN32 -char* checkpath(char *path, const char *srcpath) +static char* checkpath(char *path, const char *srcpath) { // just make sure the char*path is not const char *p=path; if(NULL!=path && NULL!=srcpath) @@ -202,7 +207,7 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) #define MAX_DIR_PATH 2048 -char* checkpath(char *path, const char*srcpath) +static char* checkpath(char *path, const char*srcpath) { // just make sure the char*path is not const char *p=path; if(NULL!=path && NULL!=srcpath) diff --git a/src/common/utils.h b/src/common/utils.h index 3fd0aeacc..3ee419c6f 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -6,7 +6,11 @@ #include -void dump(unsigned char *buffer, int num); +// Function that dumps the hex of the first num bytes of the buffer to the screen +//#define UTIL_DUMP +#ifdef UTIL_DUMP +void dump(const unsigned char* buffer, int num); +#endif struct StringBuf { char *buf_; diff --git a/src/map/npc.c b/src/map/npc.c index 941eec4c8..bf10e6230 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1,12 +1,6 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include -#include -#include - #include "../common/cbasetypes.h" #include "../common/timer.h" #include "../common/nullpo.h" @@ -17,7 +11,6 @@ #include "../common/db.h" #include "map.h" #include "log.h" -#include "npc.h" #include "clif.h" #include "intif.h" #include "pc.h" @@ -29,11 +22,18 @@ #include "battle.h" #include "skill.h" #include "unit.h" +#include "npc.h" + +#include +#include +#include +#include +#include + struct npc_src_list { struct npc_src_list * next; -// struct npc_src_list * prev; //[Shinomori] char name[4]; }; @@ -67,7 +67,7 @@ static struct { //Holds pointers to the commonly executed scripts for speedup. [Skotlex] struct npc_data *nd; struct event_data *event[UCHAR_MAX]; - unsigned char *event_name[UCHAR_MAX]; + const char *event_name[UCHAR_MAX]; unsigned char event_count; } script_event[NPCE_MAX]; @@ -320,7 +320,7 @@ int npc_event_sub(struct map_session_data *, struct event_data *, const unsigned */ int npc_event_doall_sub(DBKey key,void *data,va_list ap) { - unsigned char*p = key.str; + const char*p = key.str; struct event_data *ev; int *c; int rid; @@ -362,7 +362,7 @@ int npc_event_doall_id(const unsigned char *name, int rid) int npc_event_do_sub(DBKey key,void *data,va_list ap) { - unsigned char *p = key.str; + const char *p = key.str; struct event_data *ev; int *c; const unsigned char *name; @@ -511,7 +511,7 @@ int npc_cleareventtimer(struct npc_data *nd) int npc_do_ontimer_sub(DBKey key,void *data,va_list ap) { - unsigned char *p = key.str; + const char *p = key.str; struct event_data *ev = (struct event_data *)data; int *c = va_arg(ap,int *); // struct map_session_data *sd=va_arg(ap,struct map_session_data *); @@ -2900,10 +2900,10 @@ int npc_script_event(TBL_PC* sd, int type) { static int npc_read_event_script_sub(DBKey key,void *data,va_list ap) { - unsigned char *p = key.str; + const char *p = key.str; unsigned char *name = va_arg(ap,unsigned char *); struct event_data **event_buf = va_arg(ap,struct event_data**); - unsigned char **event_name = va_arg(ap,unsigned char **); + const char **event_name = va_arg(ap,const char **); unsigned char *count = va_arg(ap,char *);; if (*count >= UCHAR_MAX) return 0; -- cgit v1.2.3-70-g09d2 From 9f47d257ba5bb985bc6753b0f20b90da18664cd1 Mon Sep 17 00:00:00 2001 From: ultramage Date: Mon, 16 Apr 2007 20:44:44 +0000 Subject: * Finally fixed mingw problems, managed to build both TXT and SQL * Fixed the uint32 platform problem (Microsoft failed so I removed it :) * Removed the cbasetypes.h dependency from the mapcache generator * Removed some random compilation warnings git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10270 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 4 ++++ src/char/char.c | 16 ++++++++-------- src/char_sql/char.c | 12 ++++++------ src/common/cbasetypes.h | 21 +-------------------- src/common/db.c | 6 +++--- src/common/nullpo.h | 5 +++-- src/common/showmsg.c | 4 ++-- src/common/strlib.h | 2 +- src/ladmin/ladmin.c | 4 ++-- src/login/login.c | 32 ++++++++++++++------------------ src/login_sql/login.c | 18 +++++++++--------- src/tool/mapcache.c | 7 +++---- 12 files changed, 56 insertions(+), 75 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index a0d8a9f9d..6b0dcd0e4 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,10 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/04/17 + * Finally fixed mingw problems, managed to build both TXT and SQL + * Fixed the uint32 platform problem (Microsoft failed so I removed it :) + * Removed the cbasetypes.h dependency from the mapcache generator + * Removed some random compilation warnings [ultramage] * Small bugfixes and enhancements to the map cache generator [DracoRPG] 2007/04/15 * Fixed 'randomtarget' picking dead characters. diff --git a/src/char/char.c b/src/char/char.c index 0d888f399..5b9b5d87b 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1127,7 +1127,7 @@ int make_new_char(int fd, unsigned char *dat) { return -1; } - if (remove_control_chars((unsigned char *)name)) { + if (remove_control_chars(name)) { char_log("Make new char error (control char received in the name): (connection #%d, account: %d)." RETCODE, fd, sd->account_id); return -1; @@ -2182,7 +2182,7 @@ int parse_tologin(int fd) { memset(message, '\0', sizeof(message)); memcpy(message, RFIFOP(fd,8), RFIFOL(fd,4)); message[sizeof(message)-1] = '\0'; - remove_control_chars((unsigned char *)message); + remove_control_chars(message); // remove all first spaces p = message; while(p[0] == ' ') @@ -3970,10 +3970,10 @@ int char_lan_config_read(const char *lancfgName) { continue; } - remove_control_chars((unsigned char *)w1); - remove_control_chars((unsigned char *)w2); - remove_control_chars((unsigned char *)w3); - remove_control_chars((unsigned char *)w4); + remove_control_chars(w1); + remove_control_chars(w2); + remove_control_chars(w3); + remove_control_chars(w4); if(strcmpi(w1, "subnet") == 0) { @@ -4015,8 +4015,8 @@ int char_config_read(const char *cfgName) { if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2) continue; - remove_control_chars((unsigned char *)w1); - remove_control_chars((unsigned char *)w2); + remove_control_chars(w1); + remove_control_chars(w2); if(strcmpi(w1,"timestamp_format") == 0) { strncpy(timestamp_format, w2, 20); } else if(strcmpi(w1,"console_silent")==0){ diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 41ce64de7..80743dac9 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -3795,10 +3795,10 @@ int char_lan_config_read(const char *lancfgName) { continue; } - remove_control_chars((unsigned char *)w1); - remove_control_chars((unsigned char *)w2); - remove_control_chars((unsigned char *)w3); - remove_control_chars((unsigned char *)w4); + remove_control_chars(w1); + remove_control_chars(w2); + remove_control_chars(w3); + remove_control_chars(w4); if(strcmpi(w1, "subnet") == 0) { @@ -3940,8 +3940,8 @@ int char_config_read(const char *cfgName) { if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2) continue; - remove_control_chars((unsigned char *)w1); - remove_control_chars((unsigned char *)w2); + remove_control_chars(w1); + remove_control_chars(w2); if(strcmpi(w1,"timestamp_format") == 0) { strncpy(timestamp_format, w2, 20); } else if(strcmpi(w1,"console_silent")==0){ diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 67c5a45db..c066c1ebd 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -53,7 +53,7 @@ #endif // disable attributed stuff on non-GNU -#ifndef __GNUC__ +#if !defined(__GNUC__) && !defined(MINGW) # define __attribute__(x) #endif @@ -74,26 +74,10 @@ // Integers with guaranteed _exact_ size. ////////////////////////////////////////////////////////////////////////// -////////////////////////////// -#ifdef WIN32 -////////////////////////////// #define SIZEOF_LONG 4 #define SIZEOF_INT 4 #define HAVE_INT_8_16_32 -typedef __int8 int8; -typedef __int16 int16; -typedef __int32 int32; -typedef signed __int8 sint8; -typedef signed __int16 sint16; -typedef signed __int32 sint32; - -typedef unsigned __int8 uint8; -typedef unsigned __int16 uint16; -typedef unsigned __int32 uint32; -////////////////////////////// -#else // GNU -////////////////////////////// typedef char int8; typedef short int16; typedef int int32; @@ -105,9 +89,6 @@ typedef signed int sint32; typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; -////////////////////////////// -#endif -////////////////////////////// #undef UINT8_MIN #undef UINT16_MIN diff --git a/src/common/db.c b/src/common/db.c index 98d7ae032..7d1eb3903 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -600,7 +600,7 @@ static int db_is_key_null(DBType type, DBKey key) */ static DBKey db_dup_key(DB_impl db, DBKey key) { - unsigned char *str; + char *str; #ifdef DB_ENABLE_STATS COUNT(db_dup_key); @@ -609,12 +609,12 @@ static DBKey db_dup_key(DB_impl db, DBKey key) case DB_STRING: case DB_ISTRING: if (db->maxlen) { - CREATE(str, unsigned char, db->maxlen +1); + CREATE(str, char, db->maxlen +1); memcpy(str, key.str, db->maxlen); str[db->maxlen] = '\0'; key.str = str; } else { - key.str = (unsigned char *)aStrdup((const char *)key.str); + key.str = (char *)aStrdup(key.str); } return key; diff --git a/src/common/nullpo.h b/src/common/nullpo.h index 71525dd00..0238d2b6d 100644 --- a/src/common/nullpo.h +++ b/src/common/nullpo.h @@ -19,8 +19,9 @@ #endif #endif -#ifdef _WIN32 -#define __attribute__(x) /* nothing */ + +#if !defined(__GNUC__) && !defined(MINGW) +# define __attribute__(x) /* nothing */ #endif diff --git a/src/common/showmsg.c b/src/common/showmsg.c index c61530204..f56c66525 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -349,7 +349,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) // \033[2J - Clears the screen and moves the cursor to the home position (line 1, column 1). uint8 num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F); int cnt; - uint32 tmp; + DWORD tmp; COORD origin = {0,0}; if(num==1) { // chars from start up to and including cursor @@ -377,7 +377,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) uint8 num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F); COORD origin = {0,info.dwCursorPosition.Y}; SHORT cnt; - uint32 tmp; + DWORD tmp; if(num==1) { cnt = info.dwCursorPosition.X + 1; diff --git a/src/common/strlib.h b/src/common/strlib.h index db54d2969..5abd07e90 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -8,7 +8,7 @@ char* jstrescape (char* pt); char* jstrescapecpy (char* pt, const char* spt); int jmemescapecpy (char* pt, const char* spt, int size); -int remove_control_chars(char *); +int remove_control_chars(char* str); char* trim(char* str); char* normalize_name(char* str,const char* delims); const char *stristr(const char *haystack, const char *needle); diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c index 66bada1c3..e4a358745 100644 --- a/src/ladmin/ladmin.c +++ b/src/ladmin/ladmin.c @@ -4245,8 +4245,8 @@ int ladmin_config_read(const char *cfgName) { line[sizeof(line)-1] = '\0'; if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) { - remove_control_chars((unsigned char *) w1); - remove_control_chars((unsigned char *) w2); + remove_control_chars(w1); + remove_control_chars(w2); if(strcmpi(w1,"login_ip")==0){ struct hostent *h = gethostbyname (w2); diff --git a/src/login/login.c b/src/login/login.c index 65e3d666e..e948264b2 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -399,14 +399,14 @@ int check_ipmask(uint32 ip, const unsigned char *str) // scan ip address - if (sscanf((const char*)str, "%lu.%lu.%lu.%lu/%n", &a0, &a1, &a2, &a3, &i) != 4 || i == 0) + if (sscanf((const char*)str, "%u.%u.%u.%u/%n", &a0, &a1, &a2, &a3, &i) != 4 || i == 0) return 0; p[0] = (uint8)a3; p[1] = (uint8)a2; p[2] = (uint8)a1; p[3] = (uint8)a0; // scan mask - if (sscanf((const char*)str+i, "%lu.%lu.%lu.%lu", &a0, &a1, &a2, &a3) == 4) { + if (sscanf((const char*)str+i, "%u.%u.%u.%u", &a0, &a1, &a2, &a3) == 4) { p2[0] = (uint8)a3; p2[1] = (uint8)a2; p2[2] = (uint8)a1; p2[3] = (uint8)a0; - } else if (sscanf((const char*)(str+i), "%u", &m) == 1 && m >= 0 && m <= 32) { + } else if (sscanf((const char*)(str+i), "%u", &m) == 1 && m <= 32) { for(i = 32 - m; i < 32; i++) mask |= (1 << i); } else { @@ -439,7 +439,7 @@ int check_ip(uint32 ip) // If we have an answer, there is no guarantee to have a 100% correct value. // And, the waiting time (to check) can be long (over 1 minute to a timeout). That can block the software. // So, DNS notation isn't authorised for ip checking. - sprintf(buf, "%lu.%lu.%lu.%lu.", CONVIP(ip)); + sprintf(buf, "%u.%u.%u.%u.", CONVIP(ip)); for(i = 0; i < access_allownum; i++) { access_ip = access_allow + i * ACO_STRSIZE; @@ -487,7 +487,7 @@ int check_ladminip(uint32 ip) // If we have an answer, there is no guarantee to have a 100% correct value. // And, the waiting time (to check) can be long (over 1 minute to a timeout). That can block the software. // So, DNS notation isn't authorised for ip checking. - sprintf(buf, "%lu.%lu.%lu.%lu.", CONVIP(ip)); + sprintf(buf, "%u.%u.%u.%u.", CONVIP(ip)); for(i = 0; i < access_ladmin_allownum; i++) { access_ip = access_ladmin_allow + i * ACO_STRSIZE; @@ -540,7 +540,7 @@ int mmo_auth_tostr(char *str, struct auth_dat *p) { int i; char *str_p = str; - str_p += sprintf(str_p, "%lu\t%s\t%s\t%s\t%c\t%d\t%lu\t%s\t%s\t%ld\t%s\t%s\t%ld\t", + str_p += sprintf(str_p, "%u\t%s\t%s\t%s\t%c\t%d\t%u\t%s\t%s\t%ld\t%s\t%s\t%ld\t", p->account_id, p->userid, p->pass, p->lastlogin, p->sex == 2 ? 'S' : p->sex == 1 ? 'M' : 'F', p->logincount, p->state, p->email, p->error_message, @@ -598,11 +598,11 @@ int mmo_auth_init(void) memset(memo, 0, sizeof(memo)); // database version reading (v2) - if (((i = sscanf(line, "%lu\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%lu\t" + if (((i = sscanf(line, "%u\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%u\t" "%[^\t]\t%[^\t]\t%ld\t%[^\t]\t%[^\t]\t%ld%n", &account_id, userid, pass, lastlogin, &sex, &logincount, &state, email, error_message, &connect_until_time, last_ip, memo, &ban_until_time, &n)) == 13 && line[n] == '\t') || - ((i = sscanf(line, "%lu\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%lu\t" + ((i = sscanf(line, "%u\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%u\t" "%[^\t]\t%[^\t]\t%ld\t%[^\t]\t%[^\t]%n", &account_id, userid, pass, lastlogin, &sex, &logincount, &state, email, error_message, &connect_until_time, last_ip, memo, &n)) == 12 && line[n] == '\t')) { @@ -667,8 +667,6 @@ int mmo_auth_init(void) if (state > 255) auth_dat[auth_num].state = 100; - else if (state < 0) - auth_dat[auth_num].state = 0; else auth_dat[auth_num].state = state; @@ -731,7 +729,7 @@ int mmo_auth_init(void) account_id_count = account_id + 1; // Old athena database version reading (v1) - } else if ((i = sscanf(line, "%lu\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%lu\t%n", + } else if ((i = sscanf(line, "%u\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%u\t%n", &account_id, userid, pass, lastlogin, &sex, &logincount, &state, &n)) >= 5) { if (account_id > END_ACCOUNT_NUM) { ShowError(CL_RED"mmmo_auth_init: an account has an id higher than %d\n", END_ACCOUNT_NUM); @@ -795,8 +793,6 @@ int mmo_auth_init(void) if (i >= 7) { if (state > 255) auth_dat[auth_num].state = 100; - else if (state < 0) - auth_dat[auth_num].state = 0; else auth_dat[auth_num].state = state; } else @@ -839,7 +835,7 @@ int mmo_auth_init(void) } else { int i = 0; - if (sscanf(line, "%lu\t%%newid%%\n%n", &account_id, &i) == 1 && + if (sscanf(line, "%u\t%%newid%%\n%n", &account_id, &i) == 1 && i > 0 && account_id > account_id_count) account_id_count = account_id; } @@ -855,7 +851,7 @@ int mmo_auth_init(void) sprintf(line, "1 account read in %s,", account_filename); } else { ShowStatus("mmo_auth_init: %d accounts read in %s,\n", auth_num, account_filename); - sprintf(line, "%lu accounts read in %s,", auth_num, account_filename); + sprintf(line, "%u accounts read in %s,", auth_num, account_filename); } if (GM_count == 0) { ShowStatus(" of which is no GM account, and "); @@ -936,7 +932,7 @@ void mmo_auth_sync(void) { mmo_auth_tostr(line, &auth_dat[k]); fprintf(fp, "%s" RETCODE, line); } - fprintf(fp, "%lu\t%%newid%%\n", account_id_count); + fprintf(fp, "%u\t%%newid%%\n", account_id_count); lock_fclose(fp, account_filename, &lock); @@ -1946,7 +1942,7 @@ int parse_fromchar(int fd) memset(tmpstr, '\0', sizeof(tmpstr)); for(i = 0; i < RFIFOREST(fd); i++) { if ((i & 15) == 0) - fprintf(logfp, "%04lX ",i); + fprintf(logfp, "%04X ",i); fprintf(logfp, "%02x ", RFIFOB(fd,i)); if (RFIFOB(fd,i) > 0x1f) tmpstr[i % 16] = RFIFOB(fd,i); @@ -2008,7 +2004,7 @@ int parse_admin(int fd) switch(RFIFOW(fd,0)) { case 0x7530: // Request of the server version login_log("'ladmin': Sending of the server version (ip: %s)" RETCODE, ip); - WFIFOHEAD(fd,10); + WFIFOHEAD(fd,10); WFIFOW(fd,0) = 0x7531; WFIFOB(fd,2) = ATHENA_MAJOR_VERSION; WFIFOB(fd,3) = ATHENA_MINOR_VERSION; diff --git a/src/login_sql/login.c b/src/login_sql/login.c index 5929c6da0..ca98740c4 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -41,7 +41,7 @@ struct Login_Config { uint32 login_ip; // the address to bind to - unsigned short login_port; // the port to bind to + uint16 login_port; // the port to bind to bool log_login; // whether to log login server actions or not char date_format[32]; // date format used in messages bool console; // console input system enabled? @@ -1758,10 +1758,10 @@ int login_lan_config_read(const char *lancfgName) continue; } - remove_control_chars((unsigned char *)w1); - remove_control_chars((unsigned char *)w2); - remove_control_chars((unsigned char *)w3); - remove_control_chars((unsigned char *)w4); + remove_control_chars(w1); + remove_control_chars(w2); + remove_control_chars(w3); + remove_control_chars(w4); if(strcmpi(w1, "subnet") == 0) { @@ -1817,8 +1817,8 @@ int login_config_read(const char* cfgName) if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) < 2) continue; - remove_control_chars((unsigned char *)w1); - remove_control_chars((unsigned char *)w2); + remove_control_chars(w1); + remove_control_chars(w2); if(!strcmpi(w1,"timestamp_format")) { strncpy(timestamp_format, w2, 20); @@ -1834,7 +1834,7 @@ int login_config_read(const char* cfgName) if (login_config.login_ip) ShowStatus("Login server binding IP address : %s -> %s\n", w2, ip2str(login_config.login_ip, ip_str)); } else if(!strcmpi(w1,"login_port")) { - login_config.login_port = (unsigned short)atoi(w2); + login_config.login_port = (uint16)atoi(w2); ShowStatus("set login_port : %s\n",w2); } else if (!strcmpi(w1, "log_login")) @@ -2048,7 +2048,7 @@ int do_init(int argc, char** argv) new_reg_tick = gettick(); - ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", login_config.login_port); + ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %u).\n\n", login_config.login_port); return 0; } diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 4103e6916..3aa77fd80 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -9,7 +9,6 @@ #include #endif -#include "../common/cbasetypes.h" #include "grfio.h" #define MAP_NAME_LENGTH 12 @@ -219,9 +218,9 @@ char *remove_extension(char *mapname) if (ptr) { //Check and remove extension. while (ptr[1] && (ptr2 = strchr(ptr+1, '.'))) ptr = ptr2; //Skip to the last dot. - if(stricmp(ptr,".gat") == 0 || - stricmp(ptr,".afm") == 0 || - stricmp(ptr,".af2") == 0) + if(strcmp(ptr,".gat") == 0 || + strcmp(ptr,".afm") == 0 || + strcmp(ptr,".af2") == 0) *ptr = '\0'; //Remove extension. } return mapname; -- cgit v1.2.3-70-g09d2 From 95acae21f2c3d1f76109f6d9c5a8121f1474a923 Mon Sep 17 00:00:00 2001 From: ultramage Date: Fri, 20 Apr 2007 21:57:33 +0000 Subject: - Added ntows() to properly handle that client port number deficiency - Adjusted the packet_db array for a more consistent look - Reorganized some entries in packet_db.txt - Fixed a small scripts_custom.conf typo git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10296 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 ++ db/Changelog.txt | 2 ++ db/packet_db.txt | 87 ++++++++++++++++++++----------------------------- npc/Changelog.txt | 2 ++ npc/scripts_custom.conf | 2 +- src/char/char.c | 4 +-- src/char_sql/char.c | 4 +-- src/common/cbasetypes.h | 2 +- src/common/socket.c | 7 ++++ src/common/socket.h | 1 + src/login/login.c | 4 +-- src/login_sql/login.c | 4 +-- src/map/clif.c | 24 +++++++------- src/map/clif.h | 4 +-- 14 files changed, 75 insertions(+), 75 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index e214ecb83..ac588aa68 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,9 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2007/04/21 + * Added ntows() to properly handle that client port number deficiency + * Adjusted the packet_db array for a more consistent look [ultramage] 2007/04/20 * Cleaned up the doc folder. Removed outdated, untranslated, useless files and began normalizing a bit other ones~ [DracoRPG] diff --git a/db/Changelog.txt b/db/Changelog.txt index 395019900..15e9a9804 100644 --- a/db/Changelog.txt +++ b/db/Changelog.txt @@ -19,6 +19,8 @@ ----- ======================== +04/21 + * Reorganized some entries in packet_db.txt [ultramage] 04/20 * Fixed Aegis onspawn bug [Playtester] * Minor summoning behavior fixes [Playtester] diff --git a/db/packet_db.txt b/db/packet_db.txt index bfca0c8e8..ff634078f 100644 --- a/db/packet_db.txt +++ b/db/packet_db.txt @@ -1,14 +1,15 @@ // The packet database allows you to add support for new clients, // because packets change every release. // Note: Every packet version needs a wanttoconnection specification, since -// that is the packet used to identify a client's version, if multiple versions -// have the same connection packet, the higher version will be used (unless -// the lower one is specified as the default) +// that is the packet used to identify a client's version. +// If multiple versions have the same connection packet, the higher version +// will be used (unless the lower one is specified as the default) // Main packet version of the DB to use (default = max available version) -// Client detection is faster when all clients use the specified here version. +// Client detection is faster when all clients use this version. packet_db_ver: default + packet_ver: 5 0x0064,55 0x0065,17 @@ -751,19 +752,19 @@ packet_ver: 18 //2006-04-03aSakexe by blackhole89 packet_ver: 19 +0x0072,26,useskilltoid,11:18:22 +0x007e,120,useskilltoposinfo,5:15:29:38:40 +0x0085,12,changedir,7:11 +0x008c,12,getcharnamerequest,8 +0x0094,23,movetokafra,5:19 0x009b,37,wanttoconnection,9:21:28:32:36 +0x009f,24,useitem,9:20 0x00a2,11,solvecharname,7 -0x008c,12,getcharnamerequest,8 0x00a7,15,walktoxy,12 -0x0116,17,dropitem,8:15 0x00f5,13,takeitem,9 -0x009f,24,useitem,9:20 -0x0072,26,useskilltoid,11:18:22 -0x0113,40,useskilltopos,5:15:29:38 -0x0085,12,changedir,7:11 -0x007e,120,useskilltoposinfo,5:15:29:38:40 -0x0094,23,movetokafra,5:19 0x00f7,26,movefromkafra,11:22 +0x0113,40,useskilltopos,5:15:29:38 +0x0116,17,dropitem,8:15 0x0190,18,actionrequest,7:17 //2006-06-07aSakexe @@ -822,9 +823,8 @@ packet_ver: 19 //2006-10-23aSakexe 0x006d,110 -//2007-01-08aSakexe (http://www.eathena.ws/board/index.php?s=&showtopic=141398&view=findpost&p=779954) +//2007-01-08aSakexe packet_ver: 20 -0x006d,110 0x0072,30,useskilltoid,10:14:26 0x007e,120,useskilltoposinfo,10:19:23:38:40 0x0085,14,changedir,10:13 @@ -843,7 +843,26 @@ packet_ver: 20 0x0190,10,actionrequest,4:9 0x0193,2,closekafra,0 -//Unknown-Sakexe (http://www.eathena.ws/board/index.php?s=&showtopic=141398&view=findpost&p=780882) +//2007-02-12aSakexe +packet_ver: 21 +0x006d,110 +0x0072,25,useskilltoid,6:10:21 +0x007e,102,useskilltoposinfo,5:9:12:20:22 +0x0085,11,changedir,7:10 +0x0089,8,ticksend,4 +0x008c,11,getcharnamerequest,7 +0x0094,14,movetokafra,7:10 +0x009b,26,wanttoconnection,4:9:17:18:25 +0x009f,14,useitem,4:10 +0x00a2,15,solvecharname,11 +0x00a7,8,walktoxy,5 +0x00f3,-1,globalmessage,2:4 +0x00f5,8,takeitem,4 +0x00f7,22,movefromkafra,14:18 +0x0113,22,useskilltopos,5:9:12:20 +0x0116,10,dropitem,5:8 +0x0190,19,actionrequest,5:18 +0x0193,2,closekafra,0 0x028b,-1 0x028c,46 0x028d,34 @@ -865,45 +884,11 @@ packet_ver: 20 0x029d,-1 0x029e,11 0x029f,3 -0x02a0,0 -0x02a1,0 -0x02a2,0 -0x02a3,0 -0x02a4,0 -0x02a5,8 -0x02a6,0 -0x02a7,0 -0x02a8,0 -0x02a9,0 -0x02aa,4 -0x02ab,36 -0x02ac,6 - -//2007-02-12aSakexe (http://www.eathena.ws/board/index.php?s=&showtopic=141398&view=findpost&p=779954) -packet_ver: 21 -0x006d,110 -0x0072,25,useskilltoid,6:10:21 -0x007e,102,useskilltoposinfo,5:9:12:20:22 -0x0085,11,changedir,7:10 -0x0089,8,ticksend,4 -0x008c,11,getcharnamerequest,7 -0x0094,14,movetokafra,7:10 -0x009b,26,wanttoconnection,4:9:17:18:25 -0x009f,14,useitem,4:10 -0x00a2,15,solvecharname,11 -0x00a7,8,walktoxy,5 -0x00f3,-1,globalmessage,2:4 -0x00f5,8,takeitem,4 -0x00f7,22,movefromkafra,14:18 -0x0113,22,useskilltopos,5:9:12:20 -0x0116,10,dropitem,5:8 -0x0190,19,actionrequest,5:18 -0x0193,2,closekafra,0 -0x029b,72 +0x02a2,8 0x02a5,8 0x02aa,4 0x02ab,36 0x02ac,6 // Add new packets here -packet_ver: 22 +//packet_ver: 22 \ No newline at end of file diff --git a/npc/Changelog.txt b/npc/Changelog.txt index 5ef6f1c2f..2e836427d 100644 --- a/npc/Changelog.txt +++ b/npc/Changelog.txt @@ -1,5 +1,7 @@ Date Added ====== +2007/04/21 + * Fixed a small scripts_custom.conf typo [ultramage] 2007/04/15 * Updated Kiel Hyre quest thanks to L0ne_W0lf [Playtester] * Lowered the amount of Dimiks spawning in Juperos F1 [Playtester] diff --git a/npc/scripts_custom.conf b/npc/scripts_custom.conf index f7e609f06..76dbd10f3 100644 --- a/npc/scripts_custom.conf +++ b/npc/scripts_custom.conf @@ -128,7 +128,7 @@ npc: npc/custom/adoption.txt // -- A quest for Jewel Case for 99 Level Players of any 2nd Class //npc: npc/custom/quests/lvl99_quest.txt // Disable shops in the Prontera streets and open a special market place. -//npc/custom/market.txt +//npc: npc/custom/market.txt // Quest for: Bird Nest,Lion Mask,Skeleton Manteau,Fashion Hip Sack,Sales Banner //npc: npc/custom/quests/may_hats.txt // Random change of Drop/Exp rates 1x ~ 1.5x every 6 hours on your server diff --git a/src/char/char.c b/src/char/char.c index 5b9b5d87b..66601f644 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -3499,8 +3499,8 @@ int parse_char(int fd) // Advanced subnet check [LuzZza] subnet_map_ip = lan_subnetcheck(ipl); - WFIFOL(fd,22) = (subnet_map_ip) ? htonl(subnet_map_ip) : htonl(server[i].ip); - WFIFOW(fd,26) = server[i].port; // /!\ must be sent in intel host byte order /!\ (client bug) + WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : server[i].ip); + WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!] WFIFOSET(fd,28); ShowInfo("Character selection '%s' (account: %d, slot: %d).\n", diff --git a/src/char_sql/char.c b/src/char_sql/char.c index d9fcea839..dcec47c42 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -3349,8 +3349,8 @@ int parse_char(int fd) // Advanced subnet check [LuzZza] subnet_map_ip = lan_subnetcheck(ipl); - WFIFOL(fd,22) = (subnet_map_ip) ? htonl(subnet_map_ip) : htonl(server[i].ip); - WFIFOW(fd,26) = server[i].port; // /!\ must be sent in intel host byte order /!\ (client bug) + WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : server[i].ip); + WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!] WFIFOSET(fd,28); } if (auth_fifo_pos >= AUTH_FIFO_SIZE) diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index c066c1ebd..ae6430a62 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -291,7 +291,7 @@ typedef char bool; ////////////////////////////////////////////////////////////////////////// // Has to be unsigned to avoid problems in some systems -// Problems arise when these functions expect an argument in the range [0,256[ and are feed a signed char. +// Problems arise when these functions expect an argument in the range [0,256[ and are fed a signed char. #include #define ISALNUM(c) (isalnum((unsigned char)(c))) #define ISALPHA(c) (isalpha((unsigned char)(c))) diff --git a/src/common/socket.c b/src/common/socket.c index f8bdcdc7a..f406a0eea 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -1117,3 +1117,10 @@ uint32 str2ip(const char* ip_str) { return ntohl(inet_addr(ip_str)); } + +// Reorders bytes from network to little endian (Windows). +// Neccessary for sending port numbers to the RO client until Gravity notices that they forgot ntohs() calls. +uint16 ntows(uint16 neshort) +{ + return ((neshort & 0xFF) << 8) | ((neshort & 0xFF00) >> 8); +} diff --git a/src/common/socket.h b/src/common/socket.h index 41acbeabd..801da8807 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -130,6 +130,7 @@ uint32 host2ip(const char* hostname); const char* ip2str(uint32 ip, char ip_str[16]); uint32 str2ip(const char* ip_str); #define CONVIP(ip) (ip>>24)&0xFF,(ip>>16)&0xFF,(ip>>8)&0xFF,(ip>>0)&0xFF +uint16 ntows(uint16 netshort); int socket_getips(uint32* ips, int max); diff --git a/src/login/login.c b/src/login/login.c index e948264b2..e18396b23 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -3079,8 +3079,8 @@ int parse_login(int fd) if (server_fd[i] >= 0) { // Advanced subnet check [LuzZza] uint32 subnet_char_ip = lan_subnetcheck(ipl); - WFIFOL(fd,47+server_num*32) = (subnet_char_ip) ? htonl(subnet_char_ip) : htonl(server[i].ip); - WFIFOW(fd,47+server_num*32+4) = server[i].port; // /!\ must be sent in intel host byte order /!\ (client bug) + WFIFOL(fd,47+server_num*32) = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip); + WFIFOW(fd,47+server_num*32+4) = ntows(htons(server[i].port)); // [!] LE byte order here [!] memcpy(WFIFOP(fd,47+server_num*32+6), server[i].name, 20); WFIFOW(fd,47+server_num*32+26) = server[i].users; WFIFOW(fd,47+server_num*32+28) = server[i].maintenance; diff --git a/src/login_sql/login.c b/src/login_sql/login.c index af0621d80..74e32f740 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -1426,8 +1426,8 @@ int parse_login(int fd) if (server_fd[i] >= 0) { // Advanced subnet check [LuzZza] uint32 subnet_char_ip = lan_subnetcheck(ipl); - WFIFOL(fd,47+server_num*32) = (subnet_char_ip) ? htonl(subnet_char_ip) : htonl(server[i].ip); - WFIFOW(fd,47+server_num*32+4) = server[i].port; // /!\ must be sent in intel host byte order /!\ (client bug) + WFIFOL(fd,47+server_num*32) = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip); + WFIFOW(fd,47+server_num*32+4) = ntows(htons(server[i].port)); // [!] LE byte order here [!] memcpy(WFIFOP(fd,47+server_num*32+6), server[i].name, 20); WFIFOW(fd,47+server_num*32+26) = server[i].users; WFIFOW(fd,47+server_num*32+28) = server[i].maintenance; diff --git a/src/map/clif.c b/src/map/clif.c index 62ea6169c..4e4a701c5 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -50,7 +50,7 @@ struct Clif_Config { int connect_cmd[MAX_PACKET_VER + 1]; //Store the connect command for all versions. [Skotlex] } clif_config; -struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB]; +struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB + 1]; //Converts item type in case of pet eggs. #define itemtype(a) (a == 7)?4:a @@ -1684,7 +1684,7 @@ int clif_changemapserver(struct map_session_data* sd, const char* mapname, int x WFIFOW(fd,18) = x; WFIFOW(fd,20) = y; WFIFOL(fd,22) = htonl(ip); - WFIFOW(fd,26) = port; // /!\ must be sent in intel host byte order /!\ (client bug) + WFIFOW(fd,26) = ntows(htons(port)); // [!] LE byte order here [!] WFIFOSET(fd, packet_len(0x92)); return 0; @@ -11903,7 +11903,7 @@ int clif_parse(int fd) } // ゲーム用以外パケットか、認証を終える前に0072以外が来たら、切断する - if (cmd >= MAX_PACKET_DB || packet_db[packet_ver][cmd].len == 0) { // if packet is not inside these values: session is incorrect?? or auth packet is unknown + if (cmd > MAX_PACKET_DB || packet_db[packet_ver][cmd].len == 0) { // if packet is not inside these values: session is incorrect?? or auth packet is unknown ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x, %d bytes received), disconnecting session #%d.\n", cmd, RFIFOREST(fd), fd); session[fd]->eof = 1; return 0; @@ -12259,10 +12259,13 @@ static int packetdb_readdb(void) clif_config.packet_db_ver = MAX_PACKET_VER; packet_ver = MAX_PACKET_VER; // read into packet_db's version by default - while(fgets(line,1020,fp)){ + while( fgets(line,sizeof(line),fp) ) + { + ln++; if(line[0]=='/' && line[1]=='/') continue; - if (sscanf(line,"%[^:]: %[^\r\n]",w1,w2) == 2) { + if (sscanf(line,"%256[^:]: %256[^\r\n]",w1,w2) == 2) + { if(strcmpi(w1,"packet_ver")==0) { int prev_ver = packet_ver; skip_ver = 0; @@ -12319,7 +12322,8 @@ static int packetdb_readdb(void) continue; // Skipping current packet version memset(str,0,sizeof(str)); - for(j=0,p=line;j<4 && p;j++){ + for(j=0,p=line;j<4 && p; ++j) + { str[j]=p; p=strchr(p,','); if(p) *p++=0; @@ -12329,7 +12333,7 @@ static int packetdb_readdb(void) cmd=strtol(str[0],(char **)NULL,0); if(max_cmd < cmd) max_cmd = cmd; - if(cmd<=0 || cmd>=MAX_PACKET_DB) + if(cmd <= 0 || cmd > MAX_PACKET_DB) continue; if(str[1]==NULL){ ShowError("packet_db: packet len error\n"); @@ -12349,7 +12353,7 @@ static int packetdb_readdb(void) { if (packet_db[packet_ver][cmd].func != clif_parse_func[j].func) { //If we are updating a function, we need to zero up the previous one. [Skotlex] - for(i=0;i 2 /* && packet_db[cmd].pos[0] == 0 */) -// printf("packet_db ver %d: %d 0x%x %d %s %p\n",packet_ver,ln,cmd,packet_db[packet_ver][cmd].len,str[2],packet_db[packet_ver][cmd].func); } fclose(fp); if(max_cmd > MAX_PACKET_DB) diff --git a/src/map/clif.h b/src/map/clif.h index 947f63a9d..13506be11 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -8,7 +8,7 @@ // packet DB #define MAX_PACKET_DB 0x300 -#define MAX_PACKET_VER 25 +#define MAX_PACKET_VER 21 struct packet_db { short len; @@ -48,7 +48,7 @@ enum { // packet_db[SERVER] is reserved for server use #define SERVER 0 #define packet_len(x) packet_db[SERVER][x].len -extern struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB]; +extern struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB + 1]; int clif_setip(const char* ip); void clif_setbindip(const char* ip); -- cgit v1.2.3-70-g09d2 From be72ecd0560eb5dcdcc15805491e48e2d63f4e0e Mon Sep 17 00:00:00 2001 From: ultramage Date: Sat, 21 Apr 2007 17:08:08 +0000 Subject: - Removed the +25% mdef, -50% def effect from Freeze status - Changed autocast skills, they now only work with normal attacks - Fixed a few spots where the attack_type flag was getting truncated - Hopefully fixed the cygwin + size_t problem (using stddef.h as source) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10298 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 5 +++++ db/Changelog.txt | 1 + db/const.txt | 2 ++ db/item_db.txt | 4 ++-- src/common/cbasetypes.h | 4 +--- src/common/strlib.h | 3 ++- src/map/battle.c | 9 ++++----- src/map/party.h | 1 - src/map/pc.c | 8 ++++---- src/map/skill.c | 23 ++++++++++++----------- src/map/status.c | 4 ---- 11 files changed, 33 insertions(+), 31 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index ac588aa68..0fc5c4ab2 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,11 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/04/21 + * Removed the +25% mdef, -50% def effect from Freeze status + * Changed autocast skills, they now only work with normal attacks! + Ref: http://www.eathena.ws/board/index.php?showtopic=138159 + * Fixed a few spots where attack_type was getting truncated + * Hopefully fixed the cygwin + size_t problem (using stddef.h as source) * Added ntows() to properly handle that client port number deficiency * Adjusted the packet_db array for a more consistent look [ultramage] 2007/04/20 diff --git a/db/Changelog.txt b/db/Changelog.txt index 15e9a9804..9e8225520 100644 --- a/db/Changelog.txt +++ b/db/Changelog.txt @@ -20,6 +20,7 @@ ======================== 04/21 + * Added entries to const.txt, updated the new autocast cards * Reorganized some entries in packet_db.txt [ultramage] 04/20 * Fixed Aegis onspawn bug [Playtester] diff --git a/db/const.txt b/db/const.txt index 7a7ad1d22..b439e75d5 100644 --- a/db/const.txt +++ b/db/const.txt @@ -446,6 +446,8 @@ BF_MAGIC 0x0002 BF_MISC 0x0004 BF_SHORT 0x0010 BF_LONG 0x0040 +BF_SKILL 0x0100 +BF_NORMAL 0x0200 IG_BlueBox 1 IG_VioletBox 2 diff --git a/db/item_db.txt b/db/item_db.txt index e1a24dced..57585c217 100644 --- a/db/item_db.txt +++ b/db/item_db.txt @@ -1549,8 +1549,8 @@ 4360,Eremes_Card,Eremes Guile Card,6,,10,10,,,,,,,,2,,,,,{ bonus2 bCriticalAddRace,RC_DemiHuman,10; },{},{} 4361,Whitesmith_Card,Whitesmith Card,6,,10,10,,,,,,,,2,,,,,{ bonus bBreakWeaponRate,1000; bonus bBreakArmorRate,700; },{},{} 4362,Harword_Card,Howard Alt-Eisen Card,6,,10,10,,,,,,,,2,,,,,{ bonus bAspdRate,-5; bonus bHit,30; },{},{} -4363,High_Priest_Card,High Priest Card,6,,10,10,,,,,,,,16,,,,,{ bonus5 bAutoSpellWhenHit,361,1,10,BF_WEAPON|BF_MAGIC|BF_LONG|BF_SHORT,0; },{},{} -4364,Magaleta_Card,Margaretha Solin Card,6,,10,10,,,,,,,,769,,,,,{ bonus bInt,1; bonus5 bAutoSpellWhenHit,76,5,150,BF_MAGIC|BF_LONG|BF_SHORT,1; },{},{} +4363,High_Priest_Card,High Priest Card,6,,10,10,,,,,,,,16,,,,,{ bonus5 bAutoSpellWhenHit,361,1,10,BF_WEAPON|BF_MAGIC|BF_SHORT|BF_LONG|BF_SKILL|BF_NORMAL,0; },{},{} +4364,Magaleta_Card,Margaretha Solin Card,6,,10,10,,,,,,,,769,,,,,{ bonus bInt,1; bonus5 bAutoSpellWhenHit,76,5,150,BF_MAGIC|BF_LONG|BF_SHORT|BF_SKILL|BF_NORMAL,1; },{},{} 4365,High_Wizard_Card,High Wizard Card,6,,10,10,,,,,,,,769,,,,,{ bonus bIgnoreMDefRace,RC_NonBoss; bonus bCastrate,100; bonus bSPrecovRate,-100; },{},{ heal 0,-2000; } 4366,Katrinn_Card,Kathryne Keyron Card,6,,10,10,,,,,,,,769,,,,,{ bonus bCastrate,getrefine()*-1; if(getrefine()>=9) { bonus bMatkRate,2; } },{},{} 4367,Sniper_Card,Sniper Card,6,,10,10,,,,,,,,2,,,,,{ bonus bNoRegen,1; bonus2 bHpDrainRate,50,20; },{},{} diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index ae6430a62..00296588e 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -136,9 +136,8 @@ typedef unsigned long int ppuint32; ////////////////////////////////////////////////////////////////////////// // integer with exact processor width (and best speed) -// size_t already defined in stdio.h ////////////////////////////// -#include // size_t +#include // size_t #if defined(WIN32) && !defined(MINGW) // does not have a signed size_t ////////////////////////////// @@ -308,5 +307,4 @@ typedef char bool; #define TOLOWER(c) (tolower((unsigned char)(c))) #define TOUPPER(c) (toupper((unsigned char)(c))) - #endif /* _CBASETYPES_H_ */ diff --git a/src/common/strlib.h b/src/common/strlib.h index 5abd07e90..a3753b918 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -4,6 +4,8 @@ #ifndef _STRLIB_H_ #define _STRLIB_H_ +#include // size_t + char* jstrescape (char* pt); char* jstrescapecpy (char* pt, const char* spt); int jmemescapecpy (char* pt, const char* spt, int size); @@ -26,5 +28,4 @@ size_t strnlen (const char* string, size_t maxlen); int e_mail_check(char* email); int config_switch(const char* str); - #endif /* _STRLIB_H_ */ diff --git a/src/map/battle.c b/src/map/battle.c index f1679024e..358eb5746 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -149,7 +149,7 @@ struct delay_damage { unsigned short skill_lv; unsigned short skill_id; unsigned short dmg_lv; - unsigned char attack_type; + unsigned short attack_type; }; int battle_delay_damage_sub (int tid, unsigned int tick, int id, int data) @@ -163,7 +163,7 @@ int battle_delay_damage_sub (int tid, unsigned int tick, int id, int data) if ((dat->dmg_lv == ATK_DEF || dat->damage > 0) && dat->attack_type) { if (!status_isdead(target)) - skill_additional_effect(dat->src,target,dat->skill_id,dat->skill_lv,dat->attack_type, tick); + skill_additional_effect(dat->src,target,dat->skill_id,dat->skill_lv,dat->attack_type,tick); skill_counter_additional_effect(dat->src,target,dat->skill_id,dat->skill_lv,dat->attack_type,tick); } @@ -2785,8 +2785,7 @@ void battle_drain(TBL_PC *sd, struct block_list *tbl, int rdamage, int ldamage, * 通??U撃??まとめ *------------------------------------------ */ -int battle_weapon_attack( struct block_list *src,struct block_list *target, - unsigned int tick,int flag) +int battle_weapon_attack(struct block_list* src, struct block_list* target, unsigned int tick, int flag) { struct map_session_data *sd = NULL, *tsd = NULL; struct status_data *sstatus, *tstatus; @@ -2929,7 +2928,7 @@ int battle_weapon_attack( struct block_list *src,struct block_list *target, map_freeblock_lock(); - battle_delay_damage(tick+wd.amotion, src, target, BF_WEAPON, 0, 0, damage, wd.dmg_lv, wd.dmotion); + battle_delay_damage(tick+wd.amotion, src, target, wd.flag, 0, 0, damage, wd.dmg_lv, wd.dmotion); if (sc && sc->data[SC_AUTOSPELL].timer != -1 && rand()%100 < sc->data[SC_AUTOSPELL].val4) { int sp = 0; diff --git a/src/map/party.h b/src/map/party.h index 4c87dd501..f8ceb67f8 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -46,5 +46,4 @@ int party_send_dot_remove(struct map_session_data *sd); int party_sub_count(struct block_list *bl, va_list ap); int party_foreachsamemap(int (*func)(struct block_list *,va_list),struct map_session_data *sd,int type,...); - #endif /* _PARTY_H_ */ diff --git a/src/map/pc.c b/src/map/pc.c index cff5069d5..06161cffe 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2329,11 +2329,11 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) break; case SP_AUTOSPELL: if(sd->state.lr_flag != 2) - pc_bonus_autospell(sd->autospell, MAX_PC_BONUS, type2, type3, val, BF_WEAPON|BF_SHORT|BF_LONG, current_equip_card_id); + pc_bonus_autospell(sd->autospell, MAX_PC_BONUS, type2, type3, val, BF_WEAPON|BF_SHORT|BF_LONG|BF_NORMAL, current_equip_card_id); break; case SP_AUTOSPELL_WHENHIT: if(sd->state.lr_flag != 2) - pc_bonus_autospell(sd->autospell2, MAX_PC_BONUS, type2, type3, val, BF_WEAPON|BF_SHORT|BF_LONG, current_equip_card_id); + pc_bonus_autospell(sd->autospell2, MAX_PC_BONUS, type2, type3, val, BF_WEAPON|BF_SHORT|BF_LONG|BF_NORMAL, current_equip_card_id); break; case SP_HP_LOSS_RATE: if(sd->state.lr_flag != 2) { @@ -2422,12 +2422,12 @@ int pc_bonus4(struct map_session_data *sd,int type,int type2,int type3,int type4 switch(type){ case SP_AUTOSPELL: if(sd->state.lr_flag != 2) - pc_bonus_autospell(sd->autospell, MAX_PC_BONUS, (val&1?type2:-type2), (val&2?-type3:type3), type4, BF_WEAPON|BF_SHORT|BF_LONG, current_equip_card_id); + pc_bonus_autospell(sd->autospell, MAX_PC_BONUS, (val&1?type2:-type2), (val&2?-type3:type3), type4, BF_WEAPON|BF_SHORT|BF_LONG|BF_NORMAL, current_equip_card_id); break; case SP_AUTOSPELL_WHENHIT: if(sd->state.lr_flag != 2) - pc_bonus_autospell(sd->autospell2, MAX_PC_BONUS, (val&1?type2:-type2), (val&2?-type3:type3), type4, BF_WEAPON|BF_SHORT|BF_LONG, current_equip_card_id); + pc_bonus_autospell(sd->autospell2, MAX_PC_BONUS, (val&1?type2:-type2), (val&2?-type3:type3), type4, BF_WEAPON|BF_SHORT|BF_LONG|BF_NORMAL, current_equip_card_id); break; default: if(battle_config.error_log) diff --git a/src/map/skill.c b/src/map/skill.c index 34c07dd51..1279aa822 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1349,7 +1349,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int break; case TK_TURNKICK: case MO_BALKYOUNG: //Note: attack_type is passed as BF_WEAPON for the actual target, BF_MISC for the splash-affected mobs. - if(attack_type == BF_MISC) //70% base stun chance... + if(attack_type&BF_MISC) //70% base stun chance... sc_start(bl,SC_STUN,70,skilllv,skill_get_time2(skillid,skilllv)); break; case GS_BULLSEYE: //0.1% coma rate. @@ -1410,18 +1410,18 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int src = sd?&sd->bl:src; } - //Reports say that autospell effects get triggered on skills and pretty much everything including splash attacks. [Skotlex] - //But Gravity Patched this silently, and it now seems to trigger only on - //weapon attacks. + // Autospell when attacking if(sd && !status_isdead(bl) && src != bl && sd->autospell[0].id) { struct block_list *tbl; struct unit_data *ud; int i, skilllv; + for (i = 0; i < MAX_PC_BONUS && sd->autospell[i].id; i++) { - if(!(sd->autospell[i].flag&attack_type&BF_RANGEMASK && - sd->autospell[i].flag&attack_type&BF_WEAPONMASK)) - continue; //Attack type or range type did not match. + if(!(sd->autospell[i].flag&attack_type&BF_WEAPONMASK && + sd->autospell[i].flag&attack_type&BF_RANGEMASK && + sd->autospell[i].flag&attack_type&BF_SKILLMASK)) + continue; // one or more trigger conditions were not fulfilled skill = (sd->autospell[i].id > 0) ? sd->autospell[i].id : -sd->autospell[i].id; @@ -1583,7 +1583,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * } } - //Trigger counter-spells to retaliate against damage causing skills. [Skotlex] + // Trigger counter-spells to retaliate against damage causing skills. if(dstsd && !status_isdead(bl) && src != bl && dstsd->autospell2[0].id && !(skillid && skill_get_nk(skillid)&NK_NO_DAMAGE)) { @@ -1593,9 +1593,10 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * for (i = 0; i < MAX_PC_BONUS && dstsd->autospell2[i].id; i++) { - if(!(dstsd->autospell2[i].flag&attack_type&BF_RANGEMASK && - dstsd->autospell2[i].flag&attack_type&BF_WEAPONMASK)) - continue; //Attack type or range type did not match. + if(!(dstsd->autospell2[i].flag&attack_type&BF_WEAPONMASK && + dstsd->autospell2[i].flag&attack_type&BF_RANGEMASK && + dstsd->autospell2[i].flag&attack_type&BF_SKILLMASK)) + continue; // one or more trigger conditions were not fulfilled skillid = (dstsd->autospell2[i].id > 0) ? dstsd->autospell2[i].id : -dstsd->autospell2[i].id; skilllv = dstsd->autospell2[i].lv?dstsd->autospell2[i].lv:1; diff --git a/src/map/status.c b/src/map/status.c index 564d10d08..24d347b72 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -3539,8 +3539,6 @@ static signed char status_calc_def(struct block_list *bl, struct status_change * def += sc->data[SC_DEFENCE].val2 ; if(sc->data[SC_INCDEFRATE].timer!=-1) def += def * sc->data[SC_INCDEFRATE].val1/100; - if(sc->data[SC_FREEZE].timer!=-1) - def >>=1; if(sc->data[SC_STONE].timer!=-1 && sc->opt1 == OPT1_STONE) def >>=1; if(sc->data[SC_SIGNUMCRUCIS].timer!=-1) @@ -3606,8 +3604,6 @@ static signed char status_calc_mdef(struct block_list *bl, struct status_change return 90; if(sc->data[SC_SKA].timer != -1) // [marquis007] return 90; - if(sc->data[SC_FREEZE].timer!=-1) - mdef += 25*mdef/100; if(sc->data[SC_STONE].timer!=-1 && sc->opt1 == OPT1_STONE) mdef += 25*mdef/100; if(sc->data[SC_ENDURE].timer!=-1 && sc->data[SC_ENDURE].val4 == 0) -- cgit v1.2.3-70-g09d2 From 28eedb41600c4c6617cd38905b3e55c879180754 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Sat, 5 May 2007 14:50:07 +0000 Subject: * Removed the dependency on winsock.h for definitions, it's all winsock2.h now. * Minor documentation/re-coding in chat.c. * More work on ticket #41. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10471 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 + src/char_sql/inter.h | 9 +- src/common/cbasetypes.h | 4 + src/common/lock.c | 8 +- src/common/plugin.h | 4 +- src/common/plugins.h | 5 + src/common/showmsg.c | 9 +- src/common/socket.c | 25 +-- src/common/socket.h | 9 +- src/common/timer.c | 17 +- src/common/timer.h | 11 +- src/login_sql/login.c | 3 + src/map/chat.c | 156 ++++++++-------- src/map/map.h | 16 +- src/map/script.c | 467 +++++++++++++++++++++++++++++------------------- 15 files changed, 439 insertions(+), 307 deletions(-) (limited to 'src/common/cbasetypes.h') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 3efea78cd..c60aa2a20 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/05/06 + * Removed the dependency on winsock.h for definitions, it's all winsock2.h now. + * Minor documentation/re-coding in chat.c. + * More work on ticket #41. [FLavioJS] * Fixed Red Pouch overriding nobranch mapflag [Playtester] * Attempt to fix Kyrie Eleison not castable on enemy players [Playtester] - please test, I can't double client to test it in pvp diff --git a/src/char_sql/inter.h b/src/char_sql/inter.h index c1567cfe6..98b0fc49d 100644 --- a/src/char_sql/inter.h +++ b/src/char_sql/inter.h @@ -4,6 +4,10 @@ #ifndef _INTER_SQL_H_ #define _INTER_SQL_H_ +#ifndef _CBASETYPES_H_ +#include "../common/cbasetypes.h" +#endif + int inter_init_sql(const char *file); void inter_final(void); int inter_parse_frommap(int fd); @@ -21,9 +25,8 @@ int inter_log(char *fmt,...); extern unsigned int party_share_level; extern char inter_log_filename[1024]; -#ifdef __WIN32 -//Windows.h need to be included before mysql.h -#include +#ifdef WIN32 +#include #endif //add include for DBMS(mysql) #include diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 00296588e..468c0c8d0 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -307,4 +307,8 @@ typedef char bool; #define TOLOWER(c) (tolower((unsigned char)(c))) #define TOUPPER(c) (toupper((unsigned char)(c))) +////////////////////////////////////////////////////////////////////////// +// length of a static array +#define ARRAYLENGTH(A) ( sizeof(A)/sizeof((A)[0]) ) + #endif /* _CBASETYPES_H_ */ diff --git a/src/common/lock.c b/src/common/lock.c index a08b46756..e4ec36302 100644 --- a/src/common/lock.c +++ b/src/common/lock.c @@ -1,6 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#include "../common/cbasetypes.h" +#include "../common/showmsg.h" +#include "lock.h" + #include #include #include @@ -11,10 +15,8 @@ #define F_OK 0x0 #define R_OK 0x4 #endif -#include "lock.h" -#include "showmsg.h" -#ifndef _WIN32 +#ifndef WIN32 #define exists(filename) (!access(filename, F_OK)) #else // could be speed up maybe? diff --git a/src/common/plugin.h b/src/common/plugin.h index 3ddbaae98..8aef934d0 100644 --- a/src/common/plugin.h +++ b/src/common/plugin.h @@ -4,7 +4,9 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ -#include "cbasetypes.h" +#ifndef _CBASETYPES_H_ +#include "../common/cbasetypes.h" +#endif ////// Plugin functions /////////////// diff --git a/src/common/plugins.h b/src/common/plugins.h index 70dd6b326..b4235e72d 100644 --- a/src/common/plugins.h +++ b/src/common/plugins.h @@ -4,12 +4,17 @@ #ifndef _PLUGINS_H_ #define _PLUGINS_H_ +#ifndef _CBASETYPES_H_ +#include "../common/cbasetypes.h" +#endif + #include "../common/plugin.h" ////// Dynamic Link Library functions /////////////// #ifdef WIN32 + #define WIN32_LEAN_AND_MEAN #include #define DLL_OPEN(x) LoadLibrary(x) #define DLL_SYM(x,y,z) (FARPROC)(x) = GetProcAddress(y,z) diff --git a/src/common/showmsg.c b/src/common/showmsg.c index f56c66525..34338da4b 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -1,16 +1,17 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#include "../common/cbasetypes.h" +#include "../common/utils.h" +#include "showmsg.h" + #include #include #include #include #include // atexit -#include "cbasetypes.h" -#include "showmsg.h" -#include "utils.h" -#ifdef _WIN32 +#ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include diff --git a/src/common/socket.c b/src/common/socket.c index 73b0fb06b..efc51b99d 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -1,14 +1,22 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#include "../common/cbasetypes.h" +#include "../common/mmo.h" +#include "../common/timer.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "../common/strlib.h" +#include "socket.h" + #include #include #include #include -#ifdef __WIN32 - #define WIN32_LEAN_AND_MEAN - #include +#ifdef WIN32 + //#define WIN32_LEAN_AND_MEAN + //#include #include #include #else @@ -29,7 +37,7 @@ #endif // portability layer -#ifdef _WIN32 +#ifdef WIN32 typedef int socklen_t; #define s_errno WSAGetLastError() @@ -52,13 +60,6 @@ #define S_ECONNABORTED ECONNABORTED #endif -#include "../common/socket.h" -#include "../common/mmo.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" - fd_set readfds; int fd_max; time_t last_tick; @@ -561,7 +562,7 @@ int do_sendrecv(int next) fd_max = ret; } -#ifdef _WIN32 +#ifdef WIN32 // on windows, enumerating all members of the fd_set is way faster if we access the internals for(i=0;i<(int)rfd.fd_count;i++) { diff --git a/src/common/socket.h b/src/common/socket.h index 64190d6e7..3d860e166 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -4,10 +4,12 @@ #ifndef _SOCKET_H_ #define _SOCKET_H_ +#ifndef _CBASETYPES_H_ +#include "../common/cbasetypes.h" +#endif + #ifdef WIN32 - #define WIN32_LEAN_AND_MEAN - #include - #include + #include typedef long in_addr_t; #else #include @@ -15,7 +17,6 @@ #include #endif -#include "../common/cbasetypes.h" #include diff --git a/src/common/timer.c b/src/common/timer.c index 6c228839c..09be7d949 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -3,11 +3,17 @@ #include -#ifdef __WIN32 -#define __USE_W32_SOCKETS +#include "../common/cbasetypes.h" +#include "../common/malloc.h" +#include "../common/showmsg.h" +#include "timer.h" + +#ifdef WIN32 +//#define __USE_W32_SOCKETS // Well, this won't last another 30++ years (where conversion will truncate). //#define _USE_32BIT_TIME_T // use 32 bit time variables on 64bit windows -#include +//#include +#include #else #include #include @@ -18,11 +24,6 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "timer.h" - // タイマー間隔の最小値。モンスターの大量召還時、多数のクライアント接続時に // サーバーが反応しなくなる場合は、TIMER_MIN_INTERVAL を増やしてください。 diff --git a/src/common/timer.h b/src/common/timer.h index 23cb6beaa..24534de2a 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -4,10 +4,15 @@ #ifndef _TIMER_H_ #define _TIMER_H_ -#ifdef __WIN32 +#ifndef _CBASETYPES_H_ +#include "../common/cbasetypes.h" +#endif + +#ifdef WIN32 /* We need winsock lib to have timeval struct - windows is weirdo */ -#define __USE_W32_SOCKETS -#include +//#define __USE_W32_SOCKETS +//#include +#include #endif #define BASE_TICK 5 diff --git a/src/login_sql/login.c b/src/login_sql/login.c index bff047492..4b3c4c4a2 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -22,6 +22,9 @@ #include "login.h" //add include for DBMS(mysql) +#ifdef WIN32 +#include +#endif #include struct Login_Config { diff --git a/src/map/chat.c b/src/map/chat.c index 28ddbe8c4..e66ed7dc3 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -1,18 +1,19 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include - +#include "../common/cbasetypes.h" #include "../common/nullpo.h" #include "../common/malloc.h" #include "battle.h" -#include "chat.h" #include "map.h" #include "clif.h" #include "pc.h" #include "npc.h" #include "atcommand.h" +#include "chat.h" + +#include +#include int chat_triggerevent(struct chat_data *cd); @@ -107,57 +108,58 @@ int chat_joinchat(struct map_session_data* sd, int chatid, char* pass) return 0; } -/*========================================== - * チャットルームから抜ける - *------------------------------------------ - */ -int chat_leavechat(struct map_session_data *sd) +/// Removes the user from the chat room. +int chat_leavechat(struct map_session_data* sd) { - struct chat_data *cd; - int i,leavechar; + struct chat_data* cd; + int i; + int leavechar; nullpo_retr(1, sd); - cd=(struct chat_data*)map_id2bl(sd->chatID); - if(cd==NULL) { - sd->chatID = 0; + cd = (struct chat_data*)map_id2bl(sd->chatID); + if( cd == NULL ) + { + pc_setchatid(sd, 0); return 1; } - for(i = 0,leavechar=-1;i < cd->users;i++){ + for( i = 0, leavechar = -1; i < cd->users; i++ ) + { if(cd->usersd[i] == sd){ leavechar=i; break; } } - if(leavechar<0) - { //Not found in the chatroom? - sd->chatID = 0; + if( leavechar < 0 ) + {// Not found in the chatroom? + pc_setchatid(sd, 0); return -1; } - if(leavechar==0 && cd->users>1 && (*cd->owner)->type==BL_PC){ - // 所有者だった&他に人が居る&PCのチャット - clif_changechatowner(cd,cd->usersd[1]); - clif_clearchat(cd,0); + if( leavechar == 0 && cd->users > 1 && (*cd->owner)->type == BL_PC ) + {// Change ownership to the next user + clif_changechatowner(cd, cd->usersd[1]); + clif_clearchat(cd, 0); } // 抜けるPCにも送るのでusersを減らす前に実行 - clif_leavechat(cd,sd); + clif_leavechat(cd, sd); cd->users--; - pc_setchatid(sd,0); + pc_setchatid(sd, 0); - if(cd->users == 0 && (*cd->owner)->type==BL_PC){ - //Delete empty chatroom - clif_clearchat(cd,0); + if( cd->users == 0 && (*cd->owner)->type==BL_PC ) + {// Delete empty chatroom + clif_clearchat(cd, 0); map_delobject(cd->bl.id); return 1; } - for(i=leavechar;i < cd->users;i++) - cd->usersd[i] = cd->usersd[i+1]; + for( i = leavechar; i < cd->users; i++ ) + cd->usersd[i] = cd->usersd[i + 1]; - if(leavechar==0 && (*cd->owner)->type==BL_PC){ + if( leavechar == 0 && (*cd->owner)->type==BL_PC ) + { //Adjust Chat location after owner has been changed. map_delblock( &cd->bl ); cd->bl.x=cd->usersd[0]->bl.x; @@ -272,11 +274,8 @@ int chat_kickchat(struct map_session_data *sd,char *kickusername) return -1; } -/*========================================== - * npcチャットルーム作成 - *------------------------------------------ - */ -int chat_createnpcchat(struct npc_data *nd,int limit,int pub,int trigger,const char* title,int titlelen,const char *ev) +/// Creates a chat room for the npc. +int chat_createnpcchat(struct npc_data* nd,int limit,int pub,int trigger,const char* title,int titlelen,const char *ev) { struct chat_data *cd; @@ -285,45 +284,40 @@ int chat_createnpcchat(struct npc_data *nd,int limit,int pub,int trigger,const c cd = (struct chat_data *) aMalloc(sizeof(struct chat_data)); cd->limit = cd->trigger = limit; - if(trigger>0) + if( trigger > 0 ) cd->trigger = trigger; cd->pub = pub; cd->users = 0; - memcpy(cd->pass,"",1); - if(titlelen>=sizeof(cd->title)-1) titlelen=sizeof(cd->title)-1; - memcpy(cd->title,title,titlelen); - cd->title[titlelen]=0; - - cd->bl.m = nd->bl.m; - cd->bl.x = nd->bl.x; - cd->bl.y = nd->bl.y; + cd->pass[0] = '\0'; + if( titlelen > sizeof(cd->title) - 1 ) + titlelen = sizeof(cd->title) - 1; + memcpy(cd->title, title, titlelen); + cd->title[titlelen] = '\0'; + + cd->bl.m = nd->bl.m; + cd->bl.x = nd->bl.x; + cd->bl.y = nd->bl.y; cd->bl.type = BL_CHAT; - cd->bl.prev= cd->bl.next = NULL; - cd->owner_ = (struct block_list *)nd; - cd->owner = &cd->owner_; - if (strlen(ev) > 49) - { //npc_event is a char[50] [Skotlex] - memcpy(cd->npc_event,ev,49); - cd->npc_event[49] = '\0'; - } else - memcpy(cd->npc_event,ev,strlen(ev)+1); //Include the \0 - + cd->bl.prev = cd->bl.next = NULL; + cd->owner_ = (struct block_list *)nd; + cd->owner = &cd->owner_; + strncpy(cd->npc_event, ev, ARRAYLENGTH(cd->npc_event)); + cd->npc_event[ARRAYLENGTH(cd->npc_event)-1] = '\0'; cd->bl.id = map_addobject(&cd->bl); - if(cd->bl.id==0){ + if( cd->bl.id == 0) + { aFree(cd); return 0; } - nd->chat_id=cd->bl.id; + nd->chat_id = cd->bl.id; - clif_dispchat(cd,0); + clif_dispchat(cd, 0); return 0; } -/*========================================== - * npcチャットルーム削除 - *------------------------------------------ - */ -int chat_deletenpcchat(struct npc_data *nd) + +/// Removes the chatroom from the npc. +int chat_deletenpcchat(struct npc_data* nd) { struct chat_data *cd; @@ -331,9 +325,9 @@ int chat_deletenpcchat(struct npc_data *nd) nullpo_retr(0, cd=(struct chat_data*)map_id2bl(nd->chat_id)); chat_npckickall(cd); - clif_clearchat(cd,0); + clif_clearchat(cd, 0); map_delobject(cd->bl.id); // freeまでしてくれる - nd->chat_id=0; + nd->chat_id = 0; return 0; } @@ -346,44 +340,38 @@ int chat_triggerevent(struct chat_data *cd) { nullpo_retr(0, cd); - if(cd->users>=cd->trigger && cd->npc_event[0]) + if( cd->users >= cd->trigger && cd->npc_event[0] ) npc_event_do(cd->npc_event); return 0; } -/*========================================== - * イベントの有効化 - *------------------------------------------ - */ -int chat_enableevent(struct chat_data *cd) +/// Enables the event of the chat room. +/// At most, 127 users are needed to trigger the event. +int chat_enableevent(struct chat_data* cd) { nullpo_retr(0, cd); - cd->trigger&=0x7f; + cd->trigger &= 0x7f; chat_triggerevent(cd); return 0; } -/*========================================== - * イベントの無効化 - *------------------------------------------ - */ -int chat_disableevent(struct chat_data *cd) + +/// Disables the event of the chat room +int chat_disableevent(struct chat_data* cd) { nullpo_retr(0, cd); - cd->trigger|=0x80; + cd->trigger |= 0x80; return 0; } -/*========================================== - * チャットルームから全員蹴り出す - *------------------------------------------ - */ -int chat_npckickall(struct chat_data *cd) + +/// Kicks all the users for the chat room. +int chat_npckickall(struct chat_data* cd) { nullpo_retr(0, cd); - while(cd->users>0){ + while( cd->users > 0 ) chat_leavechat(cd->usersd[cd->users-1]); - } + return 0; } diff --git a/src/map/map.h b/src/map/map.h index 6178b364d..fc7affdf3 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -4,7 +4,9 @@ #ifndef _MAP_H_ #define _MAP_H_ -#include +#ifndef _CBASETYPES_H_ +#include "../common/cbasetypes.h" +#endif #include "../common/mmo.h" #include "../common/mapindex.h" #include "../common/db.h" @@ -12,6 +14,8 @@ #include "itemdb.h" // MAX_ITEMGROUP #include "status.h" // SC_MAX +#include + //Uncomment to enable the Cell Stack Limit mod. //It's only config is the battle_config cell_stack_limit. //Only chars affected are those defined in BL_CHAR (mobs and players currently) @@ -387,8 +391,10 @@ struct status_change_entry { struct status_change { struct status_change_entry data[SC_MAX]; short count; - unsigned short opt1,opt2; - unsigned int opt3, option; //Note that older packet versions use short here. + unsigned short opt1;// body state + unsigned short opt2;// health state + unsigned int opt3; + unsigned int option;// effect state }; struct vending { @@ -1394,8 +1400,8 @@ extern char *map_server_dns; #ifndef TXT_ONLY -#ifdef _WIN32 -#include // SOCKET +#ifdef WIN32 +#include #endif #include diff --git a/src/map/script.c b/src/map/script.c index 1538e8d10..fe102b923 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -4026,12 +4026,12 @@ struct script_function buildin_func[] = { BUILDIN_DEF(skillpointcount,""), BUILDIN_DEF(changebase,"i"), BUILDIN_DEF(changesex,""), - BUILDIN_DEF(waitingroom,"si*"), - BUILDIN_DEF(delwaitingroom,"*"), - BUILDIN_DEF2(waitingroomkickall,"kickwaitingroomall","*"), - BUILDIN_DEF(enablewaitingroomevent,"*"), - BUILDIN_DEF(disablewaitingroomevent,"*"), - BUILDIN_DEF(getwaitingroomstate,"i*"), + BUILDIN_DEF(waitingroom,"si??"), + BUILDIN_DEF(delwaitingroom,"?"), + BUILDIN_DEF2(waitingroomkickall,"kickwaitingroomall","?"), + BUILDIN_DEF(enablewaitingroomevent,"?"), + BUILDIN_DEF(disablewaitingroomevent,"?"), + BUILDIN_DEF(getwaitingroomstate,"i?"), BUILDIN_DEF(warpwaitingpc,"sii?"), BUILDIN_DEF(attachrid,"i"), BUILDIN_DEF(detachrid,""), @@ -6797,11 +6797,12 @@ BUILDIN_FUNC(statusup2) } /// See 'doc/item_bonus.txt' -/// bonus , -/// bonus2 ,, -/// bonus3 ,,, -/// bonus4 ,,,, -/// bonus5 ,,,,, +/// +/// bonus ,; +/// bonus2 ,,; +/// bonus3 ,,,; +/// bonus4 ,,,,; +/// bonus5 ,,,,,; BUILDIN_FUNC(bonus) { int type; @@ -6856,8 +6857,13 @@ BUILDIN_FUNC(bonus) } /// Changes the level of a player skill. -/// skill ,{,} -/// @see pc_skill() for flag +/// defaults to 1 +/// =0 : set the level of the skill +/// =1 : set the temporary level of the skill +/// =2 : add to the level of the skill +/// +/// skill ,, +/// skill , BUILDIN_FUNC(skill) { int id; @@ -6879,8 +6885,12 @@ BUILDIN_FUNC(skill) } /// Changes the level of a player skill. -/// addtoskill ,{,} -/// @see pc_skill() for flag +/// like skill, but defaults to 2 +/// +/// addtoskill ,, +/// addtoskill , +/// +/// @see skill BUILDIN_FUNC(addtoskill) { int id; @@ -6901,8 +6911,9 @@ BUILDIN_FUNC(addtoskill) return 0; } -/// Increases the level of the guild skill. -/// guildskill , +/// Increases the level of a guild skill. +/// +/// guildskill ,; BUILDIN_FUNC(guildskill) { int id; @@ -6923,6 +6934,7 @@ BUILDIN_FUNC(guildskill) } /// Returns the level of the player skill. +/// /// getskilllv() -> BUILDIN_FUNC(getskilllv) { @@ -6940,6 +6952,7 @@ BUILDIN_FUNC(getskilllv) } /// Returns the level of the guild skill. +/// /// getgdskilllv(,) -> BUILDIN_FUNC(getgdskilllv) { @@ -6959,7 +6972,10 @@ BUILDIN_FUNC(getgdskilllv) } /// Returns the 'basic_skill_check' setting. -/// basicskillcheck() -> +/// This config determines if the server check the skill level of NV_BASIC +/// before alowing the basic actions. +/// +/// basicskillcheck() -> BUILDIN_FUNC(basicskillcheck) { script_pushint(st, battle_config.basic_skill_check); @@ -6967,6 +6983,7 @@ BUILDIN_FUNC(basicskillcheck) } /// Returns the GM level of the player. +/// /// getgmlevel() -> BUILDIN_FUNC(getgmlevel) { @@ -6982,6 +6999,7 @@ BUILDIN_FUNC(getgmlevel) } /// Terminates the execution of this script instance. +/// /// end BUILDIN_FUNC(end) { @@ -6989,7 +7007,8 @@ BUILDIN_FUNC(end) return 0; } -/// Checks if the player has that option. +/// Checks if the player has that effect state (option). +/// /// checkoption(