Follow up to be9babe

Exporting the random option ids back into the script engine, since they might be useful to some custom scripts.
This commit is contained in:
Lemongrass3110 2020-11-09 14:12:51 +01:00
parent 3d25f36e2a
commit c924b90b2b
2 changed files with 22 additions and 0 deletions

View File

@ -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;
/**

View File

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