Changeset - r10723:2143de457ff9
[Not reviewed]
master
0 1 0
truebrain - 16 years ago 2009-01-13 12:52:09
truebrain@openttd.org
(svn r15056) -Add [NoAI]: when starting a game, give a random value to the setting marked with AICONFIG_RANDOM (Yexo)
1 file changed with 12 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_config.cpp
Show inline comments
 
@@ -5,6 +5,7 @@
 
#include "../stdafx.h"
 
#include "../openttd.h"
 
#include "../settings_type.h"
 
#include "../core/random_func.hpp"
 
#include "ai.hpp"
 
#include "ai_config.hpp"
 
#include "ai_info.hpp"
 
@@ -20,6 +21,17 @@ void AIConfig::ChangeAI(const char *name
 
		free((void*)(*it).first);
 
	}
 
	this->settings.clear();
 

	
 
	if (_game_mode == GM_NORMAL && this->info != NULL) {
 
		/* If we're in an existing game and the AI is changed, set all settings
 
		 *  for the AI that have the random flag to a random value. */
 
		for (AIConfigItemList::const_iterator it = this->info->GetConfigList()->begin(); it != this->info->GetConfigList()->end(); it++) {
 
			if ((*it).flags & AICONFIG_RANDOM) {
 
				this->SetSetting((*it).name, InteractiveRandomRange((*it).max_value - (*it).min_value) + (*it).min_value);
 
			}
 
		}
 
	}
 

	
 
}
 

	
 
AIConfig::AIConfig(const AIConfig *config)
0 comments (0 inline, 0 general)