From 7faff38bfb9afc208b58fa0f04fb24773fceae21 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 15 Apr 2012 08:50:23 +0000 Subject: [PATCH] (svn r24116) [1.2] -Backport from trunk: - Fix: When starting GS or AI, always use the settings of the game, not the new-game settings [FS#5142] (r24108) - Fix: Provide translated comments in the desktop file without language name postfix (r24100) - Fix: Cloning orders of aircraft with limited range failed [FS#5131] (r24086) --- Makefile.bundle.in | 2 +- media/openttd.desktop.filter.awk | 13 +++++++++++++ media/openttd.desktop.translation.awk | 6 +++--- src/ai/ai_core.cpp | 4 ++-- src/ai/ai_instance.cpp | 2 +- src/game/game_core.cpp | 2 +- src/order_cmd.cpp | 13 +++++++------ 7 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 media/openttd.desktop.filter.awk diff --git a/Makefile.bundle.in b/Makefile.bundle.in index c49440ede1..756f208e6a 100644 --- a/Makefile.bundle.in +++ b/Makefile.bundle.in @@ -85,7 +85,7 @@ endif $(Q)cp "$(BIN_DIR)/scripts/"* "$(BUNDLE_DIR)/scripts/" ifdef MENU_DIR $(Q)cp "$(ROOT_DIR)/media/openttd.desktop" "$(BUNDLE_DIR)/media/" - $(Q)$(AWK) -f "$(ROOT_DIR)/media/openttd.desktop.translation.awk" "$(SRC_DIR)/lang/"*.txt | $(SORT) >> "$(BUNDLE_DIR)/media/openttd.desktop" + $(Q)$(AWK) -f "$(ROOT_DIR)/media/openttd.desktop.translation.awk" "$(SRC_DIR)/lang/"*.txt | $(SORT) | $(AWK) -f "$(ROOT_DIR)/media/openttd.desktop.filter.awk" >> "$(BUNDLE_DIR)/media/openttd.desktop" $(Q)sed s/=openttd/=$(BINARY_NAME)/g "$(BUNDLE_DIR)/media/openttd.desktop" > "$(ROOT_DIR)/media/openttd.desktop.install" endif ifeq ($(TTD), openttd.exe) diff --git a/media/openttd.desktop.filter.awk b/media/openttd.desktop.filter.awk new file mode 100644 index 0000000000..06cf1106da --- /dev/null +++ b/media/openttd.desktop.filter.awk @@ -0,0 +1,13 @@ +# $Id: openttd.desktop.translation.awk 19884 2010-05-22 19:59:37Z rubidium $ + +# This file is part of OpenTTD. +# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. +# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + +# +# Awk script to automatically remove duplicate Comment[i]= lines +# + +BEGIN { FS = "="; last = "" } +{ if (last != $1) { print $0 }; last = $1 } diff --git a/media/openttd.desktop.translation.awk b/media/openttd.desktop.translation.awk index 943cb498f5..ee8fdd9700 100644 --- a/media/openttd.desktop.translation.awk +++ b/media/openttd.desktop.translation.awk @@ -6,10 +6,10 @@ # See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . # -# Awk script to automatically generate a single comment line -# for a translated desktop shortcut. If it does not exist there +# Awk script to automatically generate a comment lines for +# a translated desktop shortcut. If it does not exist there # is no output. # /##isocode/ { lang = $2; next } -/STR_DESKTOP_SHORTCUT_COMMENT/ { sub("^[^:]*:", "", $0); print "Comment[" lang "]=" $0; next} +/STR_DESKTOP_SHORTCUT_COMMENT/ { sub("^[^:]*:", "", $0); print "Comment[" lang "]=" $0; sub("_.*", "", lang); print "Comment[" lang "]=" $0; next} diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp index ed2945cf3b..82e2c78096 100644 --- a/src/ai/ai_core.cpp +++ b/src/ai/ai_core.cpp @@ -39,7 +39,7 @@ /* Clients shouldn't start AIs */ if (_networking && !_network_server) return; - AIConfig *config = AIConfig::GetConfig(company); + AIConfig *config = AIConfig::GetConfig(company, AIConfig::SSS_FORCE_GAME); AIInfo *info = config->GetInfo(); if (info == NULL || (rerandomise_ai && config->IsRandom())) { info = AI::scanner_info->SelectRandomAI(); @@ -283,7 +283,7 @@ { /* Find the first company which doesn't exist yet */ for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { - if (!Company::IsValidID(c)) return AIConfig::GetConfig(c)->GetSetting("start_date"); + if (!Company::IsValidID(c)) return AIConfig::GetConfig(c, AIConfig::SSS_FORCE_GAME)->GetSetting("start_date"); } /* Currently no AI can be started, check again in a year. */ diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index 6c71fef768..b1eb25b5a6 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -222,7 +222,7 @@ void AIInstance::Died() ShowAIDebugWindow(_current_company); - const AIInfo *info = AIConfig::GetConfig(_current_company)->GetInfo(); + const AIInfo *info = AIConfig::GetConfig(_current_company, AIConfig::SSS_FORCE_GAME)->GetInfo(); if (info != NULL) { ShowErrorMessage(STR_ERROR_AI_PLEASE_REPORT_CRASH, INVALID_STRING_ID, WL_WARNING); diff --git a/src/game/game_core.cpp b/src/game/game_core.cpp index add5c7fd83..c1892097fc 100644 --- a/src/game/game_core.cpp +++ b/src/game/game_core.cpp @@ -72,7 +72,7 @@ /* Clients shouldn't start GameScripts */ if (_networking && !_network_server) return; - GameConfig *config = GameConfig::GetConfig(); + GameConfig *config = GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME); GameInfo *info = config->GetInfo(); if (info == NULL) return; diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 6846c7af5b..61ba4e1212 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -1402,13 +1402,14 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 /** * Check if an aircraft has enough range for an order list. - * @param v Aircraft to check. + * @param v_new Aircraft to check. + * @param v_order Vehicle currently holding the order list. * @param first First order in the source order list. * @return True if the aircraft has enough range for the orders, false otherwise. */ -bool CheckAircraftOrderDistance(const Aircraft *v, const Order *first) +static bool CheckAircraftOrderDistance(const Aircraft *v_new, const Vehicle *v_order, const Order *first) { - if (first == NULL || v->acache.cached_max_range == 0) return true; + if (first == NULL || v_new->acache.cached_max_range == 0) return true; /* Iterate over all orders to check the distance between all * 'goto' orders and their respective next order (of any type). */ @@ -1418,7 +1419,7 @@ bool CheckAircraftOrderDistance(const Aircraft *v, const Order *first) case OT_GOTO_DEPOT: case OT_GOTO_WAYPOINT: /* If we don't have a next order, we've reached the end and must check the first order instead. */ - if (GetOrderDistance(o, o->next != NULL ? o->next : first, v) > v->acache.cached_max_range_sqr) return false; + if (GetOrderDistance(o, o->next != NULL ? o->next : first, v_order) > v_new->acache.cached_max_range_sqr) return false; break; default: break; @@ -1478,7 +1479,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } /* Check for aircraft range limits. */ - if (dst->type == VEH_AIRCRAFT && !CheckAircraftOrderDistance(Aircraft::From(dst), src->GetFirstOrder())) { + if (dst->type == VEH_AIRCRAFT && !CheckAircraftOrderDistance(Aircraft::From(dst), src, src->GetFirstOrder())) { return_cmd_error(STR_ERROR_AIRCRAFT_NOT_ENOUGH_RANGE); } @@ -1525,7 +1526,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } /* Check for aircraft range limits. */ - if (dst->type == VEH_AIRCRAFT && !CheckAircraftOrderDistance(Aircraft::From(dst), src->GetFirstOrder())) { + if (dst->type == VEH_AIRCRAFT && !CheckAircraftOrderDistance(Aircraft::From(dst), src, src->GetFirstOrder())) { return_cmd_error(STR_ERROR_AIRCRAFT_NOT_ENOUGH_RANGE); }