diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/HPMi.h | 2 | ||||
-rw-r--r-- | src/common/Makefile.in | 82 | ||||
-rw-r--r-- | src/common/console.c | 4 | ||||
-rw-r--r-- | src/common/console.h | 2 | ||||
-rw-r--r-- | src/common/mmo.h | 7 | ||||
-rw-r--r-- | src/common/strlib.c | 54 | ||||
-rw-r--r-- | src/common/strlib.h | 4 | ||||
-rw-r--r-- | src/common/thread.c | 14 |
8 files changed, 94 insertions, 75 deletions
diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 5e44b80c7..c8bce8ee8 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -91,7 +91,7 @@ HPExport struct HPMi_interface { bool (*addPacket) (unsigned short cmd, unsigned short length, void (*receive)(int fd), unsigned int point, unsigned int pluginID); } HPMi_s; #ifndef _HPM_H_ - HPExport struct HPMi_interface *HPMi; +HPExport struct HPMi_interface *HPMi; #endif #endif /* _HPMi_H_ */ diff --git a/src/common/Makefile.in b/src/common/Makefile.in index 313db8ccc..78f9cd0d1 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -1,31 +1,35 @@ -COMMON_OBJ = obj_all/core.o obj_all/socket.o obj_all/timer.o obj_all/db.o obj_all/HPM.o \ - obj_all/nullpo.o obj_all/malloc.o obj_all/showmsg.o obj_all/strlib.o obj_all/utils.o \ - obj_all/grfio.o obj_all/mapindex.o obj_all/ers.o obj_all/md5calc.o \ - obj_all/minicore.o obj_all/minisocket.o obj_all/minimalloc.o obj_all/random.o obj_all/des.o \ - obj_all/conf.o obj_all/thread.o obj_all/mutex.o obj_all/raconf.o obj_all/mempool.o obj_all/console.o \ - obj_all/miniconsole.o - -COMMON_H = $(shell ls ../common/*.h) +MT19937AR_D = ../../3rdparty/mt19937ar +MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o +MT19937AR_H = $(MT19937AR_D)/mt19937ar.h +MT19937AR_INCLUDE = -I$(MT19937AR_D) + +LIBCONFIG_D = ../../3rdparty/libconfig +LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \ + scanner.o strbuf.o) +LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \ + scanctx.h scanner.h strbuf.h wincompat.h) +LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D) + +COMMON_SHARED_OBJ = conf.o db.o des.o ers.o grfio.o HPM.o mapindex.o \ + md5calc.o mempool.o mutex.o nullpo.o raconf.o random.o \ + showmsg.o strlib.o thread.o timer.o utils.o +COMMON_OBJ = $(addprefix obj_all/, $(COMMON_SHARED_OBJ) \ + console.o core.o malloc.o socket.o) +COMMON_MINI_OBJ = $(addprefix obj_all/, $(COMMON_SHARED_OBJ) \ + miniconsole.o minicore.o minimalloc.o minisocket.o) +COMMON_H = atomic.h cbasetypes.h conf.h console.h core.h db.h des.h ers.h \ + evdp.h grfio.h HPM.h HPMi.h malloc.h mapindex.h md5calc.h \ + mempool.h mmo.h mutex.h netbuffer.h network.h nullpo.h raconf.h \ + random.h showmsg.h socket.h spinlock.h sql.h strlib.h thread.h \ + timer.h utils.h winapi.h COMMON_SQL_OBJ = obj_sql/sql.o COMMON_SQL_H = sql.h -MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o -MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h -MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar - -LIBCONFIG_OBJ = ../../3rdparty/libconfig/libconfig.o ../../3rdparty/libconfig/grammar.o \ - ../../3rdparty/libconfig/scanctx.o ../../3rdparty/libconfig/scanner.o ../../3rdparty/libconfig/strbuf.o -LIBCONFIG_H = ../../3rdparty/libconfig/libconfig.h ../../3rdparty/libconfig/grammar.h \ - ../../3rdparty/libconfig/parsectx.h ../../3rdparty/libconfig/scanctx.h ../../3rdparty/libconfig/scanner.h \ - ../../3rdparty/libconfig/strbuf.h ../../3rdparty/libconfig/wincompat.h -LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig - HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - ALL_DEPENDS=sql - SQL_DEPENDS=common common_sql + SQL_DEPENDS=common common_sql common_mini else SQL_DEPENDS=needs_mysql endif @@ -36,9 +40,9 @@ CC = @CC@ export CC ##################################################################### -.PHONY : all sql clean help +.PHONY: all sql common common_sql common_mini clean help -all: $(ALL_DEPENDS) +all: sql sql: $(SQL_DEPENDS) @@ -55,10 +59,15 @@ help: ##################################################################### +Makefile: Makefile.in + @$(MAKE) -C ../.. src/common/Makefile + needs_mysql: @echo "MySQL not found or disabled by the configure script" @exit 1 +# object directories + obj_all: @echo " MKDIR obj_all" @-mkdir obj_all @@ -67,35 +76,42 @@ obj_sql: @echo " MKDIR obj_sql" @-mkdir obj_sql -obj_all/common.a: $(COMMON_OBJ) +obj_all/common.a: $(COMMON_OBJ) Makefile @echo " AR $@" @@AR@ rcs obj_all/common.a $(COMMON_OBJ) -obj_sql/common_sql.a: $(COMMON_SQL_OBJ) +obj_all/common_mini.a: $(COMMON_MINI_OBJ) Makefile + @echo " AR $@" + @@AR@ rcs obj_all/common_mini.a $(COMMON_MINI_OBJ) + +obj_sql/common_sql.a: $(COMMON_SQL_OBJ) Makefile @echo " AR $@" @@AR@ rcs obj_sql/common_sql.a $(COMMON_SQL_OBJ) - -common: obj_all $(COMMON_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common.a +common: $(COMMON_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common.a Makefile + +common_mini: $(COMMON_MINI_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common_mini.a Makefile -common_sql: obj_sql $(COMMON_SQL_OBJ) obj_sql/common_sql.a +common_sql: $(COMMON_SQL_OBJ) obj_sql/common_sql.a Makefile -obj_all/%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) +obj_all/%.o: %.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_all @echo " CC $<" @$(CC) @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj_all/mini%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) +obj_all/mini%.o: %.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_all @echo " CC $<" @$(CC) @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj_sql/%.o: %.c $(COMMON_H) $(COMMON_SQL_H) $(LIBCONFIG_H) +obj_sql/%.o: %.c $(COMMON_H) $(COMMON_SQL_H) $(CONFIG_H) $(LIBCONFIG_H) | obj_sql @echo " CC $<" @$(CC) @CFLAGS@ $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files $(MT19937AR_OBJ): - @$(MAKE) -C ../../3rdparty/mt19937ar + @echo " MAKE $@" + @$(MAKE) -C $(MT19937AR_D) $(LIBCONFIG_OBJ): - @$(MAKE) -C ../../3rdparty/libconfig + @echo " MAKE $@" + @$(MAKE) -C $(LIBCONFIG_D) diff --git a/src/common/console.c b/src/common/console.c index 75b6eaea4..b25de84b3 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -386,8 +386,8 @@ void console_parse_init(void) { timer->add_interval(timer->gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ } -void console_setSQL(Sql *SQL) { - console->SQL = SQL; +void console_setSQL(Sql *SQL_handle) { + console->SQL = SQL_handle; } #endif /* CONSOLE_INPUT */ diff --git a/src/common/console.h b/src/common/console.h index 214a41175..cef898f17 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -64,7 +64,7 @@ struct console_interface { void (*load_defaults) (void); void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth); void (*addCommand) (char *name, CParseFunc func); - void (*setSQL) (Sql *SQL); + void (*setSQL) (Sql *SQL_handle); #endif }; diff --git a/src/common/mmo.h b/src/common/mmo.h index 17a01ff95..b51d0ec4a 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -575,6 +575,13 @@ struct fame_list { char name[NAME_LENGTH]; }; +enum fame_list_type { + RANKTYPE_BLACKSMITH = 0, + RANKTYPE_ALCHEMIST = 1, + RANKTYPE_TAEKWON = 2, + RANKTYPE_PK = 3, //Not supported yet +}; + enum { //Change Guild Infos GBI_EXP =1, // Guild Experience (EXP) GBI_GUILDLV, // Guild level diff --git a/src/common/strlib.c b/src/common/strlib.c index 686b2e47d..e45cb0789 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -444,9 +444,9 @@ bool bin2hex(char* output, unsigned char* input, size_t count) /// Parses a single field in a delim-separated string. /// The delimiter after the field is skipped. /// -/// @param sv Parse state +/// @param svstate Parse state /// @return 1 if a field was parsed, 0 if already done, -1 on error. -int sv_parse_next(struct s_svstate* sv) +int sv_parse_next(struct s_svstate* svstate) { enum { START_OF_FIELD, @@ -462,13 +462,13 @@ int sv_parse_next(struct s_svstate* sv) char delim; int i; - if( sv == NULL ) + if( svstate == NULL ) return -1;// error - str = sv->str; - len = sv->len; - opt = sv->opt; - delim = sv->delim; + str = svstate->str; + len = svstate->len; + opt = svstate->opt; + delim = svstate->delim; // check opt if( delim == '\n' && (opt&(SV_TERMINATE_CRLF|SV_TERMINATE_LF)) ) @@ -482,9 +482,9 @@ int sv_parse_next(struct s_svstate* sv) return -1;// error } - if( sv->done || str == NULL ) + if( svstate->done || str == NULL ) { - sv->done = true; + svstate->done = true; return 0;// nothing to parse } @@ -495,10 +495,10 @@ int sv_parse_next(struct s_svstate* sv) ((opt&SV_TERMINATE_CR) && str[i] == '\r') || \ ((opt&SV_TERMINATE_CRLF) && i+1 < len && str[i] == '\r' && str[i+1] == '\n') ) #define IS_C_ESCAPE() ( (opt&SV_ESCAPE_C) && str[i] == '\\' ) -#define SET_FIELD_START() sv->start = i -#define SET_FIELD_END() sv->end = i +#define SET_FIELD_START() svstate->start = i +#define SET_FIELD_END() svstate->end = i - i = sv->off; + i = svstate->off; state = START_OF_FIELD; while( state != END ) { @@ -578,14 +578,14 @@ int sv_parse_next(struct s_svstate* sv) else ++i;// CR or LF #endif - sv->done = true; + svstate->done = true; state = END; break; } } if( IS_END() ) - sv->done = true; - sv->off = i; + svstate->done = true; + svstate->off = i; #undef IS_END #undef IS_DELIM @@ -619,31 +619,31 @@ int sv_parse_next(struct s_svstate* sv) /// @param opt Options that determine the parsing behaviour /// @return Number of fields found in the string or -1 if an error occured int sv_parse(const char* str, int len, int startoff, char delim, int* out_pos, int npos, enum e_svopt opt) { - struct s_svstate sv; + struct s_svstate svstate; int count; // initialize if( out_pos == NULL ) npos = 0; for( count = 0; count < npos; ++count ) out_pos[count] = -1; - sv.str = str; - sv.len = len; - sv.off = startoff; - sv.opt = opt; - sv.delim = delim; - sv.done = false; + svstate.str = str; + svstate.len = len; + svstate.off = startoff; + svstate.opt = opt; + svstate.delim = delim; + svstate.done = false; // parse count = 0; if( npos > 0 ) out_pos[0] = startoff; - while( !sv.done ) { + while( !svstate.done ) { ++count; - if( sv_parse_next(&sv) <= 0 ) + if( sv_parse_next(&svstate) <= 0 ) return -1;// error - if( npos > count*2 ) out_pos[count*2] = sv.start; - if( npos > count*2+1 ) out_pos[count*2+1] = sv.end; + if( npos > count*2 ) out_pos[count*2] = svstate.start; + if( npos > count*2+1 ) out_pos[count*2+1] = svstate.end; } - if( npos > 1 ) out_pos[1] = sv.off; + if( npos > 1 ) out_pos[1] = svstate.off; return count; } diff --git a/src/common/strlib.h b/src/common/strlib.h index 9b1875d45..5ef455a0e 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -124,9 +124,9 @@ struct sv_interface { /// Parses a single field in a delim-separated string. /// The delimiter after the field is skipped. /// - /// @param sv Parse state + /// @param svstate Parse state /// @return 1 if a field was parsed, 0 if done, -1 on error. - int (*parse_next) (struct s_svstate* sv); + int (*parse_next) (struct s_svstate* svstate); /// Parses a delim-separated string. /// Starts parsing at startoff and fills the pos array with position pairs. diff --git a/src/common/thread.c b/src/common/thread.c index 315b310b2..4d110f2dd 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -96,15 +96,11 @@ void rathread_final(){ // gets called whenever a thread terminated .. -static void rat_thread_terminated( rAthread handle ){ - - int id_backup = handle->myID; - - // Simply set all members to 0 (except the id) - memset(handle, 0x00, sizeof(struct rAthread)); - - handle->myID = id_backup; // done ;) - +static void rat_thread_terminated(rAthread handle) { + // Preserve handle->myID and handle->hThread, set everything else to its default value + handle->param = NULL; + handle->proc = NULL; + handle->prio = RAT_PRIO_NORMAL; }//end: rat_thread_terminated() #ifdef WIN32 |