瀏覽代碼

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.
lighta 9 年之前
父節點
當前提交
65b6861e84

+ 4 - 9
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;

+ 26 - 0
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
  **/

+ 5 - 7
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 <npc id>.L <x>.W <y>.W <effect>.W <type>.W
+/// 0446 <npc id>.L <x>.W <y>.W <effect>.W <color>.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

+ 8 - 10
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

+ 0 - 2
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);

+ 7 - 10
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;
 	}

+ 0 - 10
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,

+ 2 - 0
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"

+ 1 - 1
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/

+ 21 - 20
src/tool/mapcache.c

@@ -9,14 +9,16 @@
 #include <unistd.h>
 #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);

+ 3 - 1
vcproj-10/mapcache.vcxproj

@@ -130,6 +130,7 @@
     <ClCompile Include="..\src\common\showmsg.c" />
     <ClCompile Include="..\src\common\strlib.c" />
     <ClCompile Include="..\src\common\utils.c" />
+    <ClCompile Include="..\src\common\cli.c" />
     <ClCompile Include="..\src\tool\mapcache.c" />
   </ItemGroup>
   <ItemGroup>
@@ -143,7 +144,8 @@
     <ClInclude Include="..\src\common\strlib.h" />
     <ClInclude Include="..\src\common\utils.h" />
     <ClInclude Include="..\src\common\winapi.h" />
-	<ClInclude Include="..\src\config\renewal.h" />
+    <ClInclude Include="..\src\common\cli.h" />
+    <ClInclude Include="..\src\config\core.h" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 7 - 1
vcproj-10/mapcache.vcxproj.filters

@@ -22,6 +22,9 @@
     <ClCompile Include="..\src\common\utils.c">
       <Filter>common</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\common\cli.c">
+      <Filter>common</Filter>
+    </ClCompile>
     <ClCompile Include="..\src\tool\mapcache.c">
       <Filter>mapcache</Filter>
     </ClCompile>
@@ -57,7 +60,10 @@
     <ClInclude Include="..\src\common\winapi.h">
       <Filter>common</Filter>
     </ClInclude>
-    <ClInclude Include="..\src\config\renewal.h">
+    <ClInclude Include="..\src\common\cli.h">
+      <Filter>common</Filter>
+    </ClInclude>
+    <ClInclude Include="..\src\config\core.h">
       <Filter>config</Filter>
     </ClInclude>
   </ItemGroup>

+ 3 - 1
vcproj-12/mapcache.vcxproj

@@ -134,6 +134,7 @@
     <ClCompile Include="..\src\common\showmsg.c" />
     <ClCompile Include="..\src\common\strlib.c" />
     <ClCompile Include="..\src\common\utils.c" />
+    <ClCompile Include="..\src\common\cli.c" />
     <ClCompile Include="..\src\tool\mapcache.c" />
   </ItemGroup>
   <ItemGroup>
@@ -147,7 +148,8 @@
     <ClInclude Include="..\src\common\strlib.h" />
     <ClInclude Include="..\src\common\utils.h" />
     <ClInclude Include="..\src\common\winapi.h" />
-    <ClInclude Include="..\src\config\renewal.h" />
+    <ClInclude Include="..\src\common\cli.h" />
+    <ClInclude Include="..\src\config\core.h" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 7 - 1
vcproj-12/mapcache.vcxproj.filters

@@ -22,6 +22,9 @@
     <ClCompile Include="..\src\common\utils.c">
       <Filter>common</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\common\cli.c">
+      <Filter>common</Filter>
+    </ClCompile>
     <ClCompile Include="..\src\tool\mapcache.c">
       <Filter>mapcache</Filter>
     </ClCompile>
@@ -57,7 +60,10 @@
     <ClInclude Include="..\src\common\winapi.h">
       <Filter>common</Filter>
     </ClInclude>
-    <ClInclude Include="..\src\config\renewal.h">
+    <ClInclude Include="..\src\common\cli.h">
+      <Filter>common</Filter>
+    </ClInclude>
+    <ClInclude Include="..\src\config\core.h">
       <Filter>config</Filter>
     </ClInclude>
   </ItemGroup>

+ 3 - 1
vcproj-13/mapcache.vcxproj

@@ -134,6 +134,7 @@
     <ClCompile Include="..\src\common\showmsg.c" />
     <ClCompile Include="..\src\common\strlib.c" />
     <ClCompile Include="..\src\common\utils.c" />
+    <ClCompile Include="..\src\common\cli.c" />
     <ClCompile Include="..\src\tool\mapcache.c" />
   </ItemGroup>
   <ItemGroup>
@@ -147,7 +148,8 @@
     <ClInclude Include="..\src\common\strlib.h" />
     <ClInclude Include="..\src\common\utils.h" />
     <ClInclude Include="..\src\common\winapi.h" />
-    <ClInclude Include="..\src\config\renewal.h" />
+    <ClInclude Include="..\src\common\cli.h" />
+    <ClInclude Include="..\src\config\core.h" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 7 - 1
vcproj-13/mapcache.vcxproj.filters

@@ -22,6 +22,9 @@
     <ClCompile Include="..\src\common\utils.c">
       <Filter>common</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\common\cli.c">
+      <Filter>common</Filter>
+    </ClCompile>
     <ClCompile Include="..\src\tool\mapcache.c">
       <Filter>mapcache</Filter>
     </ClCompile>
@@ -57,7 +60,10 @@
     <ClInclude Include="..\src\common\winapi.h">
       <Filter>common</Filter>
     </ClInclude>
-    <ClInclude Include="..\src\config\renewal.h">
+    <ClCompile Include="..\src\common\cli.h">
+      <Filter>common</Filter>
+    </ClCompile>
+    <ClInclude Include="..\src\config\core.h">
       <Filter>config</Filter>
     </ClInclude>
   </ItemGroup>

+ 9 - 1
vcproj-9/mapcache.vcproj

@@ -270,6 +270,14 @@
 				RelativePath="..\src\common\winapi.h"
 				>
 			</File>
+                        <File
+				RelativePath="..\src\common\cli.c"
+				>
+			</File>
+                        <File
+				RelativePath="..\src\common\cli.h"
+				>
+			</File>
 		</Filter>
 		<Filter
 			Name="mapcache"
@@ -279,7 +287,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\src\config\renewal.h"
+				RelativePath="..\src\config\core.h"
 				>
 			</File>
 		</Filter>