diff options
author | frosch <frosch@openttd.org> | 2010-10-16 20:34:43 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-10-16 20:34:43 +0000 |
commit | 98250ad8da83fe6f842437bb614df28a1fe217c6 (patch) | |
tree | bfa52c0de54fa6c0a8c46d8b576555408ebcdc68 /src/ai | |
parent | 82d4ffacff3398b44b2b16466f1305d607f0f57f (diff) | |
download | openttd-98250ad8da83fe6f842437bb614df28a1fe217c6.tar.xz |
(svn r20951) -Codechange: Add SmallMap::Contains() and use it.
Diffstat (limited to 'src/ai')
-rw-r--r-- | src/ai/ai_gui.cpp | 2 | ||||
-rw-r--r-- | src/ai/ai_info.cpp | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 3cfee3f6a..bf03a4760 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -318,7 +318,7 @@ struct AISettingsWindow : public Window { SetDParam(idx++, current_value == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON); } else { DrawArrowButtons(buttons_left, y + 2, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > (*it).min_value, editable && current_value < (*it).max_value); - if (it->labels != NULL && it->labels->Find(current_value) != it->labels->End()) { + if (it->labels != NULL && it->labels->Contains(current_value)) { SetDParam(idx++, STR_JUST_RAW_STRING); SetDParamStr(idx++, it->labels->Find(current_value)->second); } else { diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp index ff5dca946..54725cd48 100644 --- a/src/ai/ai_info.cpp +++ b/src/ai/ai_info.cpp @@ -307,7 +307,8 @@ SQInteger AIInfo::AddLabels(HSQUIRRELVM vm) int key = atoi(key_string + 1); const char *label = SQ2OTTD(sq_label); - if (config->labels->Find(key) == config->labels->End()) config->labels->Insert(key, strdup(label)); + /* !Contains() prevents strdup from leaking. */ + if (!config->labels->Contains(key)) config->labels->Insert(key, strdup(label)); sq_pop(vm, 2); } |