Prechádzať zdrojové kódy

Added feature configs for barter shops (#6549)

Thanks to JohnnyPlayy
Lemongrass3110 3 rokov pred
rodič
commit
6ec51e8bf3
4 zmenil súbory, kde vykonal 37 pridanie a 7 odobranie
  1. 8 0
      conf/battle/feature.conf
  2. 17 0
      src/map/battle.cpp
  3. 3 0
      src/map/battle.hpp
  4. 9 7
      src/map/npc.cpp

+ 8 - 0
conf/battle/feature.conf

@@ -111,3 +111,11 @@ feature.attendance: on
 // Private Airship System (Note 1)
 // Requires: 2018-03-21aRagexeRE or later
 feature.privateairship: on
+
+// Barter Shop System (Note 1)
+// Requires: 2018-07-04RagexeRE or later
+feature.barter: on
+
+// Barter Shop System (Note 1)
+// Requires: 2019-11-06RagexeRE or later
+feature.barter: on

+ 17 - 0
src/map/battle.cpp

@@ -10077,6 +10077,9 @@ static const struct _battle_data {
 	{ "keep_ap_on_logout",                  &battle_config.keep_ap_on_logout,               1,      0,      1,              },
 	{ "attack_machine_level_difference",    &battle_config.attack_machine_level_difference, 15,     0,      INT_MAX,        },
 
+	{ "feature.barter",                     &battle_config.feature_barter,                  1,      0,      1,              },
+	{ "feature.barter_extended",            &battle_config.feature_barter_extended,         1,      0,      1,              },
+
 #include "../custom/battle_config_init.inc"
 };
 
@@ -10260,6 +10263,20 @@ void battle_adjust_conf()
 	}
 #endif
 
+#if !( PACKETVER_MAIN_NUM >= 20181121 || PACKETVER_RE_NUM >= 20180704 || PACKETVER_ZERO_NUM >= 20181114 )
+	if( battle_config.feature_barter ){
+		ShowWarning("conf/battle/feature.conf barter shop system is enabled but it requires PACKETVER 2018-07-04 or newer, disabling...\n");
+		battle_config.feature_barter = 0;
+	}
+#endif
+
+#if !( PACKETVER_MAIN_NUM >= 20191120 || PACKETVER_RE_NUM >= 20191106 || PACKETVER_ZERO_NUM >= 20191127 )
+	if( battle_config.feature_barter_extended ){
+		ShowWarning("conf/battle/feature.conf extended barter shop system is enabled but it requires PACKETVER 2019-11-06 or newer, disabling...\n");
+		battle_config.feature_barter_extended = 0;
+	}
+#endif
+
 #ifndef CELL_NOSTACK
 	if (battle_config.custom_cell_stack_limit != 1)
 		ShowWarning("Battle setting 'custom_cell_stack_limit' takes no effect as this server was compiled without Cell Stack Limit support.\n");

+ 3 - 0
src/map/battle.hpp

@@ -708,6 +708,9 @@ struct Battle_Config
 	int keep_ap_on_logout;
 	int attack_machine_level_difference;
 
+	int feature_barter;
+	int feature_barter_extended;
+
 #include "../custom/battle_config_struct.inc"
 };
 

+ 9 - 7
src/map/npc.cpp

@@ -717,10 +717,12 @@ uint64 BarterDatabase::parseBodyNode( const YAML::Node& node ){
 
 void BarterDatabase::loadingFinished(){
 	for( const auto& pair : *this ){
-#if !( PACKETVER_MAIN_NUM >= 20181121 || PACKETVER_RE_NUM >= 20180704 || PACKETVER_ZERO_NUM >= 20181114 )
-		ShowError( "Barter system is not supported by your packet version.\n" );
-		return;
+		if( !battle_config.feature_barter && !battle_config.feature_barter_extended ){
+#ifndef BUILDBOT
+			ShowError( "Barter system is not enabled.\n" );
 #endif
+			return;
+		}
 
 		std::shared_ptr<s_npc_barter> barter = pair.second;
 
@@ -770,12 +772,12 @@ void BarterDatabase::loadingFinished(){
 			}
 		}
 
-#if !( PACKETVER_MAIN_NUM >= 20191120 || PACKETVER_RE_NUM >= 20191106 || PACKETVER_ZERO_NUM >= 20191127 )
-		if( nd->u.barter.extended ){
-			ShowError( "Barter %s uses extended mechanics but this is not supported by the current packet version.\n", nd->name );
+		if( nd->u.barter.extended && !battle_config.feature_barter_extended ){
+#ifndef BUILDBOT
+			ShowError( "Barter %s uses extended mechanics but this is not enabled.\n", nd->name );
+#endif
 			continue;
 		}
-#endif
 
 		if( nd->bl.m >= 0 ){
 			map_addnpc( nd->bl.m, nd );