From 6bb922953da0f1c86ea98aa3776b486c17149a88 Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 8 Apr 2013 20:52:32 +0000 Subject: [PATCH] (svn r25168) [1.3] -Backport from trunk: - Fix: [NewGRF] Acceleration of NewGRF aircraft was too fast, while acceleration of default aircraft was way too slow (r25115) - Fix: Pass $LDFLAGS_BUILD to all endian_check compilations (r25108) - Change: [Win32] MSVC 2010 comes with stdint.h (r25128) - Change: Be slightly more lenient with trying to detect a subversion repository in case someone has a sparse tags checkout. In that case the .svn folder misses from the $ROOT_DIR because it is in the $ROOT_DIR/.. (i.e. tags) folder (r25107) --- Makefile.src.in | 2 +- config.lib | 6 ++++++ findversion.sh | 2 +- src/aircraft_cmd.cpp | 9 ++++++++- src/newgrf.cpp | 10 ++-------- src/saveload/afterload.cpp | 11 +++++++++++ src/saveload/saveload.cpp | 2 +- src/stdafx.h | 2 +- src/table/engines.h | 4 ++-- 9 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Makefile.src.in b/Makefile.src.in index df515e03a0..2f2d8f1ad1 100644 --- a/Makefile.src.in +++ b/Makefile.src.in @@ -276,7 +276,7 @@ endian_target.h: $(ENDIAN_CHECK) $(CONFIG_CACHE_ENDIAN) $(ENDIAN_CHECK): $(SRC_DIR)/endian_check.cpp $(E) '$(STAGE) Compiling and Linking $@' - $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $< -o $@ + $(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) $< -o $@ # Revision files diff --git a/config.lib b/config.lib index 3fbabe341c..47ccd0e5b9 100644 --- a/config.lib +++ b/config.lib @@ -1012,6 +1012,12 @@ check_params() { if [ -d "$ROOT_DIR/.svn" ] && [ -n "`svn help 2>/dev/null`" ]; then log 1 "checking revision... svn detection" + elif [ -d "$ROOT_DIR/../.svn" ] && [ -n "`svn help 2>/dev/null`" ] && [ -n "`LC_ALL=C svn info $ROOT_DIR/.. | grep '^URL:.*tags$'`" ]; then + # subversion changed its behaviour; now not all folders have a .svn folder, + # but only the root folder. Since making tags requires a (sparse) checkout + # of the tags folder, the folder of the tag does not have a .svn folder + # anymore and this fails to detect the subversion repository checkout. + log 1 "checking revision... svn detection (tag)" elif [ -d "$ROOT_DIR/.git" ] && [ -n "`git help 2>/dev/null`" ]; then log 1 "checking revision... git detection" elif [ -d "$ROOT_DIR/.hg" ] && [ -n "`hg help 2>/dev/null`" ]; then diff --git a/findversion.sh b/findversion.sh index 35568de0ca..c0d500a8fd 100755 --- a/findversion.sh +++ b/findversion.sh @@ -70,7 +70,7 @@ ROOT_DIR=`pwd` # Determine if we are using a modified version # Assume the dir is not modified MODIFIED="0" -if [ -d "$ROOT_DIR/.svn" ]; then +if [ -d "$ROOT_DIR/.svn" ] || [ -d "$ROOT_DIR/../.svn" ]; then # We are an svn checkout if [ -n "`svnversion | grep 'M'`" ]; then MODIFIED="2" diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 385eb9be15..deec94649d 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -598,7 +598,14 @@ enum AircraftSpeedLimits { */ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE, bool hard_limit = true) { - uint spd = v->acceleration * 16; + /** + * 'acceleration' has the unit 3/8 mph/tick. This function is called twice per tick. + * So the speed amount we need to accelerate is: + * acceleration * 3 / 16 mph = acceleration * 3 / 16 * 16 / 10 km-ish/h + * = acceleration * 3 / 10 * 256 * (km-ish/h / 256) + * ~ acceleration * 77 (km-ish/h / 256) + */ + uint spd = v->acceleration * 77; byte t; /* Adjust speed limits by plane speed factor to prevent taxiing diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 65c9096e56..e426100cf0 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -1618,15 +1618,9 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int avi->max_speed = (buf->ReadByte() * 128) / 10; break; - case 0x0D: { // Acceleration - uint acceleration = (buf->ReadByte() * 128) / 10; - if (acceleration > UINT8_MAX) { - grfmsg(1, "Acceleration property of aircraft %d is too big.", engine + i); - acceleration = UINT8_MAX; - } - avi->acceleration = acceleration; + case 0x0D: // Acceleration + avi->acceleration = buf->ReadByte(); break; - } case PROP_AIRCRAFT_RUNNING_COST_FACTOR: // 0x0E Running cost factor avi->running_cost = buf->ReadByte(); diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 15c44d392b..a3837942c8 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -2761,6 +2761,17 @@ bool AfterLoadGame() _settings_game.script.settings_profile = IsInsideMM(_old_diff_level, SP_BEGIN, SP_END) ? _old_diff_level : (uint)SP_MEDIUM; } + if (IsSavegameVersionBefore(182)) { + Aircraft *v; + /* Aircraft acceleration variable was bonkers */ + FOR_ALL_AIRCRAFT(v) { + if (v->subtype <= AIR_AIRCRAFT) { + const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type); + v->acceleration = avi->acceleration; + } + } + } + /* Road stops is 'only' updating some caches */ AfterLoadRoadStops(); AfterLoadLabelMaps(); diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index a21f6242a5..fa27fb31e1 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -243,7 +243,7 @@ * 177 24619 * 178 24789 * 179 24810 - * 180 24998 + * 180 24998 1.3.x */ extern const uint16 SAVEGAME_VERSION = 180; ///< Current savegame version of OpenTTD. diff --git a/src/stdafx.h b/src/stdafx.h index b3359b74d1..b91466403d 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -30,7 +30,7 @@ * We need INT64_MAX, which for most systems comes from stdint.h. However, MSVC * does not have stdint.h and apparently neither does MorphOS. * For OSX the inclusion is already done in osx_stdafx.h. */ -#if !defined(__APPLE__) && !defined(_MSC_VER) && !defined(__MORPHOS__) +#if !defined(__APPLE__) && (!defined(_MSC_VER) || _MSC_VER >= 1600) && !defined(__MORPHOS__) #if defined(SUNOS) /* SunOS/Solaris does not have stdint.h, but inttypes.h defines everything * stdint.h defines and we need. */ diff --git a/src/table/engines.h b/src/table/engines.h index 102d8d79ce..b79733c7ae 100644 --- a/src/table/engines.h +++ b/src/table/engines.h @@ -580,8 +580,8 @@ static const ShipVehicleInfo _orig_ship_vehicle_info[] = { * @param c running_Cost * @param d subtype (bit 0 - plane, bit 1 - large plane) * @param e sound effect - * @param f acceleration - * @param g max_speed (1 unit = 8 mph = 12.8 km-ish/h) + * @param f acceleration (1 unit = 3/8 mph/tick = 3/5 km-ish/h/tick) (stays the same in the variable) + * @param g max_speed (1 unit = 8 mph = 12.8 km-ish/h) (is converted to km-ish/h by the macro) * @param h mail_capacity (bags) * @param i passenger_capacity (persons) */