فهرست منبع

Follow up to be9babe

Exporting the random option ids back into the script engine, since they might be useful to some custom scripts.
Lemongrass3110 4 سال پیش
والد
کامیت
c924b90b2b
2فایلهای تغییر یافته به همراه22 افزوده شده و 0 حذف شده
  1. 21 0
      src/map/itemdb.cpp
  2. 1 0
      src/map/itemdb.hpp

+ 21 - 0
src/map/itemdb.cpp

@@ -2333,6 +2333,27 @@ uint64 RandomOptionDatabase::parseBodyNode(const YAML::Node &node) {
 	return 1;
 }
 
+void RandomOptionDatabase::loadingFinished(){
+	const char* prefix = "RDMOPT_";
+
+	for( const auto& pair : *this ){
+		std::string name = prefix + pair.second->name;
+		int64 constant;
+
+		// Check if it has already been set
+		if( script_get_constant( name.c_str(), &constant ) ){
+			// It is already the same
+			if( constant == pair.first ){
+				continue;
+			}else{
+				// Export it to the script engine -> will issue a warning
+			}
+		}
+
+		script_set_constant( name.c_str(), pair.first, false, false );
+	}
+}
+
 RandomOptionDatabase random_option_db;
 
 /**

+ 1 - 0
src/map/itemdb.hpp

@@ -955,6 +955,7 @@ public:
 
 	const std::string getDefaultLocation();
 	uint64 parseBodyNode(const YAML::Node &node);
+	void loadingFinished();
 
 	// Additional
 	bool option_exists(std::string name);