From 65b6861e84d29a8226680312ca4639bd15373bed Mon Sep 17 00:00:00 2001 From: lighta Date: Wed, 18 Nov 2015 06:34:14 -0500 Subject: [PATCH] Small cleanup And updata mapcache to use DBPATH instead rechecking RENEWAL macro, (code duplication) Make mapcache use cli.o to give some feedback on arguments given. --- src/char/char.c | 13 +++------- src/config/const.h | 26 +++++++++++++++++++ src/map/clif.c | 12 ++++----- src/map/pc.c | 18 ++++++------- src/map/pc.h | 2 -- src/map/script.c | 17 +++++-------- src/map/status.h | 10 -------- src/tool/CMakeLists.txt | 2 ++ src/tool/Makefile.in | 2 +- src/tool/mapcache.c | 41 +++++++++++++++--------------- vcproj-10/mapcache.vcxproj | 4 ++- vcproj-10/mapcache.vcxproj.filters | 8 +++++- vcproj-12/mapcache.vcxproj | 4 ++- vcproj-12/mapcache.vcxproj.filters | 8 +++++- vcproj-13/mapcache.vcxproj | 4 ++- vcproj-13/mapcache.vcxproj.filters | 8 +++++- vcproj-9/mapcache.vcproj | 10 +++++++- 17 files changed, 113 insertions(+), 76 deletions(-) diff --git a/src/char/char.c b/src/char/char.c index 238c41ad41..2acd87a1b2 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2634,15 +2634,10 @@ void char_set_defaults(){ charserv_config.log_inter = 1; // loggin inter or not [devil] charserv_config.char_check_db =1; -#ifdef RENEWAL - charserv_config.start_point.map = mapindex_name2id("iz_int"); - charserv_config.start_point.x = 97; - charserv_config.start_point.y = 90; -#else - charserv_config.start_point.map = mapindex_name2id("new_zone01"); //mapindex_name2id(MAP_DEFAULT); - charserv_config.start_point.x = 53; //MAP_DEFAULT_X - charserv_config.start_point.y = 111; //MAP_DEFAULT_Y -#endif + //see const.h to change those default + charserv_config.start_point.map = mapindex_name2id(MAP_DEFAULT_NAME); + charserv_config.start_point.x = MAP_DEFAULT_X; + charserv_config.start_point.y = MAP_DEFAULT_Y; charserv_config.console = 0; charserv_config.max_connect_user = -1; diff --git a/src/config/const.h b/src/config/const.h index 4e2a510715..d35eeb9c43 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -93,6 +93,32 @@ time = time * (1 - (float)min(val, 100) / 100); \ } #endif + + +/** + * Max Refine available to your server + * Changing this limit requires edits to refine_db.txt + **/ +#ifdef RENEWAL +# define MAX_REFINE 20 +#else +# define MAX_REFINE 10 +#endif + +/** + * Default coordinate for new char + * That map should be loaded by a mapserv + **/ +#ifdef RENEWAL + #define MAP_DEFAULT_NAME "iz_int" + #define MAP_DEFAULT_X 97 + #define MAP_DEFAULT_Y 90 +#else + #define MAP_DEFAULT_NAME "new_zone01" + #define MAP_DEFAULT_X 53 + #define MAP_DEFAULT_Y 111 +#endif + /** * End of File **/ diff --git a/src/map/clif.c b/src/map/clif.c index 0ce5274ed6..c6f8589cae 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -10100,10 +10100,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) if(!battle_config.pc_invincible_time) skill_unit_move(&sd->bl,gettick(),1); -#if PACKETVER >= 20090218 - pc_show_questinfo_reinit(sd); + pc_show_questinfo_reinit(sd); pc_show_questinfo(sd); -#endif } @@ -15800,17 +15798,17 @@ void clif_quest_update_status(struct map_session_data *sd, int quest_id, bool ac /// Notification about an NPC's quest state (ZC_QUEST_NOTIFY_EFFECT). -/// 0446 .L .W .W .W .W +/// 0446 .L .W .W .W .W /// effect: /// 0 = none /// 1 = exclamation mark icon /// 2 = question mark icon -/// type: +/// color: /// 0 = yellow /// 1 = orange /// 2 = green /// 3 = purple -void clif_quest_show_event(struct map_session_data *sd, struct block_list *bl, short state, short color) +void clif_quest_show_event(struct map_session_data *sd, struct block_list *bl, short effect, short color) { #if PACKETVER >= 20090218 int fd = sd->fd; @@ -15820,7 +15818,7 @@ void clif_quest_show_event(struct map_session_data *sd, struct block_list *bl, s WFIFOL(fd, 2) = bl->id; WFIFOW(fd, 6) = bl->x; WFIFOW(fd, 8) = bl->y; - WFIFOW(fd, 10) = state; + WFIFOW(fd, 10) = effect; WFIFOW(fd, 12) = color; WFIFOSET(fd, packet_len(0x446)); #endif diff --git a/src/map/pc.c b/src/map/pc.c index cc0757de70..3d96a55592 100755 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6261,9 +6261,7 @@ void pc_baselevelchanged(struct map_session_data *sd) { pc_unequipitem(sd, sd->equip_index[i], 3); } } -#if PACKETVER >= 20090218 - pc_show_questinfo(sd); -#endif + pc_show_questinfo(sd); } int pc_checkjoblevelup(struct map_session_data *sd) @@ -8258,9 +8256,7 @@ bool pc_jobchange(struct map_session_data *sd,int job, char upper) pc_checkallowskill(sd); pc_equiplookall(sd); -#if PACKETVER >= 20090218 - pc_show_questinfo(sd); -#endif + pc_show_questinfo(sd); //if you were previously famous, not anymore. if (fame_flag) { @@ -11707,7 +11703,7 @@ static void pc_show_questinfo_sub(struct map_session_data *sd, bool *qi_display, } } else { - // Check if need to be hid + // Check if need to be hide if ((*qi_display) != 0) { (*qi_display) = 0; #if PACKETVER >= 20120410 @@ -11719,12 +11715,12 @@ static void pc_show_questinfo_sub(struct map_session_data *sd, bool *qi_display, } } -#if PACKETVER >= 20090218 /** * Show available NPC Quest / Event Icon Check [Kisuka] * @param sd Player **/ void pc_show_questinfo(struct map_session_data *sd) { +#if PACKETVER >= 20090218 struct questinfo *qi = NULL; unsigned short i; uint8 j, state = 0, mystate = 0; @@ -11792,6 +11788,7 @@ void pc_show_questinfo(struct map_session_data *sd) { pc_show_questinfo_sub(sd, &sd->qi_display[i], qi, true); } } +#endif } /** @@ -11799,7 +11796,7 @@ void pc_show_questinfo(struct map_session_data *sd) { * @param sd Player **/ void pc_show_questinfo_reinit(struct map_session_data *sd) { - +#if PACKETVER >= 20090218 nullpo_retv(sd); if (sd->qi_display) { @@ -11813,8 +11810,9 @@ void pc_show_questinfo_reinit(struct map_session_data *sd) { if (!map[sd->bl.m].qi_count || !map[sd->bl.m].qi_data) return; CREATE(sd->qi_display, bool, (sd->qi_count = map[sd->bl.m].qi_count)); -} #endif +} + /*========================================== * pc Init/Terminate diff --git a/src/map/pc.h b/src/map/pc.h index ca04e5d9e0..33706d97f5 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1215,10 +1215,8 @@ int pc_autotrade_timer(int tid, unsigned int tick, int id, intptr_t data); void pc_validate_skill(struct map_session_data *sd); -#if PACKETVER >= 20090218 void pc_show_questinfo(struct map_session_data *sd); void pc_show_questinfo_reinit(struct map_session_data *sd); -#endif #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) int pc_level_penalty_mod(struct map_session_data *sd, int mob_level, uint32 mob_class, int type); diff --git a/src/map/script.c b/src/map/script.c index 03be6d842f..f85eaf7baf 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -18685,9 +18685,8 @@ BUILDIN_FUNC(setquest) quest_add(sd, quest_id); -#if PACKETVER >= 20120410 - pc_show_questinfo(sd); -#endif + //20120410 or 20090218 ? no reason that shouldn't work for 2009 + pc_show_questinfo(sd); return SCRIPT_CMD_SUCCESS; } @@ -18716,9 +18715,8 @@ BUILDIN_FUNC(completequest) return SCRIPT_CMD_FAILURE; quest_update_status(sd, script_getnum(st, 2), Q_COMPLETE); -#if PACKETVER >= 20120410 - pc_show_questinfo(sd); -#endif + //20120410 or 20090218 + pc_show_questinfo(sd); return SCRIPT_CMD_SUCCESS; } @@ -18733,9 +18731,8 @@ BUILDIN_FUNC(changequest) return SCRIPT_CMD_FAILURE; quest_change(sd, script_getnum(st, 2),script_getnum(st, 3)); -#if PACKETVER >= 20120410 - pc_show_questinfo(sd); -#endif + //20120410 or 20090218 + pc_show_questinfo(sd); return SCRIPT_CMD_SUCCESS; } @@ -21226,7 +21223,7 @@ BUILDIN_FUNC(setquestinfo_req) { return SCRIPT_CMD_FAILURE; } - if ((num+1)%2 != 0) { + if (num%2) { ShowError("buildin_setquestinfo_req: Odd number of parameters(%d) - pairs of requirements are expected.\n", num); return SCRIPT_CMD_FAILURE; } diff --git a/src/map/status.h b/src/map/status.h index 1717a0fb43..ddea528d82 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -11,16 +11,6 @@ struct homun_data; struct mercenary_data; struct status_change; -/** - * Max Refine available to your server - * Changing this limit requires edits to refine_db.txt - **/ -#ifdef RENEWAL -# define MAX_REFINE 20 -#else -# define MAX_REFINE 10 -#endif - /// Refine type enum refine_type { REFINE_TYPE_ARMOR = 0, diff --git a/src/tool/CMakeLists.txt b/src/tool/CMakeLists.txt index a54ffa0e22..0f51e2e8e5 100644 --- a/src/tool/CMakeLists.txt +++ b/src/tool/CMakeLists.txt @@ -14,12 +14,14 @@ set( COMMON_HEADERS "${COMMON_SOURCE_DIR}/des.h" "${COMMON_SOURCE_DIR}/grfio.h" "${COMMON_SOURCE_DIR}/utils.h" + "${COMMON_SOURCE_DIR}/cli.h" ) set( COMMON_SOURCES ${COMMON_MINI_SOURCES} "${COMMON_SOURCE_DIR}/des.c" "${COMMON_SOURCE_DIR}/grfio.c" "${COMMON_SOURCE_DIR}/utils.c" + "${COMMON_SOURCE_DIR}/cli.c" ) set( MAPCACHE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/mapcache.c" diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 8e37c1113e..465c21fb40 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -1,5 +1,5 @@ -COMMON_OBJ = minicore.o malloc.o showmsg.o strlib.o utils.o des.o grfio.o +COMMON_OBJ = minicore.o malloc.o showmsg.o strlib.o utils.o des.o grfio.o cli.o COMMON_DIR_OBJ = $(COMMON_OBJ:%=../common/obj/%) COMMON_H = $(shell ls ../common/*.h) COMMON_INCLUDE = -I../common/ diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 5e8a5d6486..a20184feff 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -9,14 +9,16 @@ #include #endif +#include "../config/core.h" + #include "../common/cbasetypes.h" #include "../common/grfio.h" #include "../common/malloc.h" #include "../common/mmo.h" #include "../common/showmsg.h" #include "../common/utils.h" +#include "../common/cli.h" -#include "../config/renewal.h" #define NO_WATER 1000000 @@ -175,24 +177,28 @@ char *remove_extension(char *mapname) } // Processes command-line arguments -void process_args(int argc, char *argv[]) +int process_args(int argc, char *argv[]) { int i; - for(i = 0; i < argc; i++) { + for(i = 1; i < argc; i++) { if(strcmp(argv[i], "-grf") == 0) { - if(++i < argc) - strcpy(grf_list_file, argv[i]); + if(opt_has_next_value(argv[i],i,argc)) strcpy(grf_list_file, argv[++i]); + else return 1; } else if(strcmp(argv[i], "-list") == 0) { - if(++i < argc) - strcpy(map_list_file, argv[i]); + if(opt_has_next_value(argv[i],i,argc)) strcpy(map_list_file, argv[++i]); + else return 1; } else if(strcmp(argv[i], "-cache") == 0) { - if(++i < argc) - strcpy(map_cache_file, argv[i]); - } else if(strcmp(argv[i], "-rebuild") == 0) + if(opt_has_next_value(argv[i],i,argc)) strcpy(map_cache_file, argv[++i]); + else return 1; + } else if(strcmp(argv[i], "-rebuild") == 0) { rebuild = 1; + } else { + ShowWarning("Invalid argument given '%s'.\n", argv[i]); + return 1; + } } - + return 0; } int do_init(int argc, char** argv) @@ -202,17 +208,12 @@ int do_init(int argc, char** argv) struct map_data map; char name[MAP_NAME_LENGTH_EXT]; - /* setup pre-defined, #define-dependant */ - sprintf(map_cache_file,"db/%s/map_cache.dat", -#ifdef RENEWAL - "re" -#else - "pre-re" -#endif - ); + /* setup pre-defined, #define-dependant, use -cache option to override this */ + sprintf(map_cache_file,"db/%smap_cache.dat",DBPATH); // Process the command-line arguments - process_args(argc, argv); + if(process_args(argc, argv)) + return 0; ShowStatus("Initializing grfio with %s\n", grf_list_file); grfio_init(grf_list_file); diff --git a/vcproj-10/mapcache.vcxproj b/vcproj-10/mapcache.vcxproj index f2f5fec954..03ca08dc7e 100644 --- a/vcproj-10/mapcache.vcxproj +++ b/vcproj-10/mapcache.vcxproj @@ -130,6 +130,7 @@ + @@ -143,7 +144,8 @@ - + + diff --git a/vcproj-10/mapcache.vcxproj.filters b/vcproj-10/mapcache.vcxproj.filters index 12f73abd8a..cf02777c39 100644 --- a/vcproj-10/mapcache.vcxproj.filters +++ b/vcproj-10/mapcache.vcxproj.filters @@ -22,6 +22,9 @@ common + + common + mapcache @@ -57,7 +60,10 @@ common - + + common + + config diff --git a/vcproj-12/mapcache.vcxproj b/vcproj-12/mapcache.vcxproj index 32f6a3418d..5216c80095 100644 --- a/vcproj-12/mapcache.vcxproj +++ b/vcproj-12/mapcache.vcxproj @@ -134,6 +134,7 @@ + @@ -147,7 +148,8 @@ - + + diff --git a/vcproj-12/mapcache.vcxproj.filters b/vcproj-12/mapcache.vcxproj.filters index 12f73abd8a..cf02777c39 100644 --- a/vcproj-12/mapcache.vcxproj.filters +++ b/vcproj-12/mapcache.vcxproj.filters @@ -22,6 +22,9 @@ common + + common + mapcache @@ -57,7 +60,10 @@ common - + + common + + config diff --git a/vcproj-13/mapcache.vcxproj b/vcproj-13/mapcache.vcxproj index a5e7b8639d..2e0ea5c90d 100644 --- a/vcproj-13/mapcache.vcxproj +++ b/vcproj-13/mapcache.vcxproj @@ -134,6 +134,7 @@ + @@ -147,7 +148,8 @@ - + + diff --git a/vcproj-13/mapcache.vcxproj.filters b/vcproj-13/mapcache.vcxproj.filters index 12f73abd8a..2dfaefba9d 100644 --- a/vcproj-13/mapcache.vcxproj.filters +++ b/vcproj-13/mapcache.vcxproj.filters @@ -22,6 +22,9 @@ common + + common + mapcache @@ -57,7 +60,10 @@ common - + + common + + config diff --git a/vcproj-9/mapcache.vcproj b/vcproj-9/mapcache.vcproj index 45d40a0040..433e7fa464 100644 --- a/vcproj-9/mapcache.vcproj +++ b/vcproj-9/mapcache.vcproj @@ -270,6 +270,14 @@ RelativePath="..\src\common\winapi.h" > + + + +