Changeset - r11209:bd8cb881039a
[Not reviewed]
master
0 3 0
yexo - 15 years ago 2009-02-23 20:57:55
yexo@openttd.org
(svn r15562) -Change: Use GetName() to determine the unique AI name instead of GetInstanceName() to make branching of AIs easier.
3 files changed with 7 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_core.cpp
Show inline comments
 
@@ -37,7 +37,7 @@
 
		info = AI::ai_scanner->SelectRandomAI();
 
		assert(info != NULL);
 
		/* Load default data and store the name in the settings */
 
		AIConfig::GetConfig(company)->ChangeAI(info->GetInstanceName());
 
		AIConfig::GetConfig(company)->ChangeAI(info->GetName());
 
	}
 

	
 
	_current_company = company;
src/ai/ai_gui.cpp
Show inline comments
 
@@ -115,7 +115,7 @@ struct AIListWindow : public Window {
 
		} else {
 
			AIInfoList::const_iterator it = this->ai_info_list->begin();
 
			for (int i = 0; i < this->selected; i++) it++;
 
			AIConfig::GetConfig(slot)->ChangeAI((*it).second->GetInstanceName(), (*it).second->GetVersion());
 
			AIConfig::GetConfig(slot)->ChangeAI((*it).second->GetName(), (*it).second->GetVersion());
 
		}
 
		InvalidateWindow(WC_GAME_OPTIONS, 0);
 
	}
src/ai/ai_scanner.cpp
Show inline comments
 
@@ -307,12 +307,12 @@ void AIScanner::RegisterLibrary(AILibrar
 
void AIScanner::RegisterAI(AIInfo *info)
 
{
 
	char ai_name[1024];
 
	snprintf(ai_name, sizeof(ai_name), "%s.%d", info->GetInstanceName(), info->GetVersion());
 
	snprintf(ai_name, sizeof(ai_name), "%s.%d", info->GetName(), info->GetVersion());
 
	strtolower(ai_name);
 

	
 
	/* Check if GetShortName follows the rules */
 
	if (strlen(info->GetShortName()) != 4) {
 
		DEBUG(ai, 0, "The AI '%s' returned a string from GetShortName() which is not four characaters. Unable to load the AI.", info->GetInstanceName());
 
		DEBUG(ai, 0, "The AI '%s' returned a string from GetShortName() which is not four characaters. Unable to load the AI.", info->GetName());
 
		delete info;
 
		return;
 
	}
 
@@ -342,7 +342,7 @@ void AIScanner::RegisterAI(AIInfo *info)
 

	
 
	/* Add the AI to the 'unique' AI list, where only the highest version of the
 
	 *  AI is registered. */
 
	snprintf(ai_name, sizeof(ai_name), "%s", info->GetInstanceName());
 
	snprintf(ai_name, sizeof(ai_name), "%s", info->GetName());
 
	strtolower(ai_name);
 
	if (this->info_single_list.find(ai_name) == this->info_single_list.end()) {
 
		this->info_single_list[strdup(ai_name)] = info;
 
@@ -406,7 +406,7 @@ AIInfo *AIScanner::FindInfo(const char *
 
	AIInfoList::iterator it = this->info_list.begin();
 
	for (; it != this->info_list.end(); it++) {
 
		char ai_name_compare[1024];
 
		snprintf(ai_name_compare, sizeof(ai_name_compare), "%s", (*it).second->GetInstanceName());
 
		snprintf(ai_name_compare, sizeof(ai_name_compare), "%s", (*it).second->GetName());
 
		strtolower(ai_name_compare);
 

	
 
		if (strcasecmp(ai_name, ai_name_compare) == 0 && (*it).second->CanLoadFromVersion(versionParam)) {
 
@@ -424,7 +424,7 @@ char *AIScanner::GetAIConsoleList(char *
 
	AIInfoList::iterator it = this->info_list.begin();
 
	for (; it != this->info_list.end(); it++) {
 
		AIInfo *i = (*it).second;
 
		p += seprintf(p, last, "%10s (v%d): %s\n", i->GetInstanceName(), i->GetVersion(), i->GetDescription());
 
		p += seprintf(p, last, "%10s (v%d): %s\n", i->GetName(), i->GetVersion(), i->GetDescription());
 
	}
 
	p += seprintf(p, last, "\n");
 

	
0 comments (0 inline, 0 general)