diff --git a/config.lib b/config.lib old mode 100644 new mode 100755 diff --git a/findversion.sh b/findversion.sh index 1d7c52a471..f91186d033 100644 --- a/findversion.sh +++ b/findversion.sh @@ -6,7 +6,7 @@ if [ "$#" != "0" ]; then Usage: ./findversion.sh Finds the current revision and if the code is modified. -Output: \t\t +Output: \t\t\t REV a string describing what version of the code the current checkout is based on. The exact format of this string depends on the version @@ -40,6 +40,9 @@ MODIFIED A value of 1 means that the modified status is unknown, because this is not an svn/git/hg checkout for example. +CLEAN_REV + the same as REV but without branch name + By setting the AWK environment variable, a caller can determine which version of "awk" is used. If nothing is set, this script defaults to "awk". @@ -62,16 +65,21 @@ SRC_DIR=src MODIFIED="0" if [ -d "$ROOT_DIR/.svn" ]; then # We are an svn checkout - if svnversion "$SRC_DIR" | grep 'M' > /dev/null; then + if [ -n "`svnversion \"$SRC_DIR\" | grep 'M'`" ]; then MODIFIED="2" fi # Find the revision like: rXXXXM-branch BRANCH=`LC_ALL=C svn info "$SRC_DIR" | "$AWK" '/^URL:.*branches/ { split($2, a, "/"); for(i in a) if (a[i]=="branches") { print a[i+1]; break } }'` + TAG=`LC_ALL=C svn info "$SRC_DIR" | "$AWK" '/^URL:.*tags/ { split($2, a, "/"); for(i in a) if (a[i]=="tags") { print a[i+1]; break } }'` REV_NR=`LC_ALL=C svn info "$SRC_DIR" | "$AWK" '/^Last Changed Rev:/ { print $4 }'` - REV="r$REV_NR" + if [ -n "$TAG" ]; then + REV=$TAG + else + REV="r$REV_NR" + fi elif [ -d "$ROOT_DIR/.git" ]; then # We are a git checkout - if git diff-index HEAD "$SRC_DIR" | read dummy; then + if [ -n "`git diff-index HEAD \"$SRC_DIR\"`" ]; then MODIFIED="2" fi HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null | cut -c1-8` @@ -80,7 +88,7 @@ elif [ -d "$ROOT_DIR/.git" ]; then REV_NR=`LC_ALL=C git log --pretty=format:%s "$SRC_DIR" | grep "^(svn r[0-9]*)" | head -n 1 | sed "s/.*(svn r\([0-9]*\)).*/\1/"` elif [ -d "$ROOT_DIR/.hg" ]; then # We are a hg checkout - if hg status "$SRC_DIR" | grep -v '^?' | read dummy; then + if [ -n "`hg status \"$SRC_DIR\" | grep -v '^?'`" ]; then MODIFIED="2" fi HASH=`LC_ALL=C hg tip 2>/dev/null | head -n 1 | cut -d: -f3 | cut -c1-8` @@ -99,8 +107,10 @@ if [ "$MODIFIED" -eq "2" ]; then REV="${REV}M" fi +CLEAN_REV=${REV} + if [ -n "$BRANCH" ]; then REV="${REV}-$BRANCH" fi -echo "$REV $REV_NR $MODIFIED" +echo "$REV $REV_NR $MODIFIED $CLEAN_REV" diff --git a/os/debian/control.in b/os/debian/control similarity index 96% rename from os/debian/control.in rename to os/debian/control index 0c6a4a0534..c17953dd28 100644 --- a/os/debian/control.in +++ b/os/debian/control @@ -1,4 +1,4 @@ -Source: PACKAGE +Source: openttd Section: contrib/games Priority: optional Maintainer: Matthijs Kooijman @@ -9,7 +9,7 @@ Vcs-Browser: http://svn.debian.org/wsvn/collab-maint/deb-maint/openttd/trunk/ Vcs-Svn: svn://svn.debian.org/svn/collab-maint/deb-maint/openttd/trunk Homepage: http://www.openttd.org/ -Package: PACKAGE +Package: openttd Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Suggests: timidity, freepats diff --git a/os/debian/rules b/os/debian/rules index d6fa65dbf1..1ac6c90eff 100755 --- a/os/debian/rules +++ b/os/debian/rules @@ -6,22 +6,7 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -DEFAULT_PACKAGE := openttd -# Find the package name from the topmost changelog entry. -# Is this the best way to do this? -PACKAGE = $(shell cat debian/changelog | head -1 | cut -f1 -d' ') - -debian/control: - # Generate control file - sed 's/PACKAGE/$(PACKAGE)/' debian/control.in > debian/control - - # TODO: How to do this using makefile conditionals? - if [ "$(PACKAGE)" != "$(DEFAULT_PACKAGE)" ]; then \ - echo "Provides: $(DEFAULT_PACKAGE)" >> debian/control ; \ - echo "Conflicts: $(DEFAULT_PACKAGE)" >> debian/control ; \ - fi; - -configure: debian/control configure-stamp +configure: configure-stamp configure-stamp: dh_testdir # Add here commands to configure the package. @@ -29,20 +14,20 @@ configure-stamp: touch configure-stamp -build: debian/control configure build-stamp +build: configure build-stamp build-stamp: dh_testdir # Add here commands to compile the package. - ./configure --prefix-dir=/usr --binary-dir=games --data-dir=share/games/openttd --icon-dir=share/pixmaps --personal-dir=.openttd --install-dir=debian/$(PACKAGE) + ./configure --prefix-dir=/usr --binary-dir=games --data-dir=share/games/openttd --icon-dir=share/pixmaps --personal-dir=.openttd --install-dir=debian/openttd $(MAKE) #/usr/bin/docbook-to-man debian/openttd.sgml > openttd.1 touch build-stamp -clean: debian/control +clean: dh_testdir dh_testroot rm -f build-stamp configure-stamp @@ -54,10 +39,8 @@ clean: debian/control [ ! -f Makefile ] || $(MAKE) distclean dh_clean - # Clean up generated control file - -rm debian/control -install: debian/control build +install: build dh_testdir dh_testroot dh_clean -k @@ -71,7 +54,7 @@ binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. -binary-arch: debian/control build install +binary-arch: build install dh_testdir dh_testroot dh_installchangelogs changelog.txt diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 36ef9f4011..a858d162f3 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1692,21 +1692,23 @@ static void AircraftEventHandler_AtTerminal(Vehicle *v, const AirportFTAClass *a /* airport-road is free. We either have to go to another airport, or to the hangar * ---> start moving */ + bool go_to_hangar = false; switch (v->current_order.type) { case OT_GOTO_STATION: // ready to fly to another airport - /* airplane goto state takeoff, helicopter to helitakeoff */ - v->u.air.state = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : TAKEOFF; break; case OT_GOTO_DEPOT: // visit hangar for serivicing, sale, etc. - if (v->current_order.dest == v->u.air.targetairport) { - v->u.air.state = HANGAR; - } else { - v->u.air.state = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : TAKEOFF; - } + go_to_hangar = v->current_order.dest == v->u.air.targetairport; break; default: // orders have been deleted (no orders), goto depot and don't bother us v->current_order.Free(); - v->u.air.state = HANGAR; + go_to_hangar = GetStation(v->u.air.targetairport)->Airport()->nof_depots != 0; + } + + if (go_to_hangar) { + v->u.air.state = HANGAR; + } else { + /* airplane goto state takeoff, helicopter to helitakeoff */ + v->u.air.state = (v->subtype == AIR_HELICOPTER) ? HELITAKEOFF : TAKEOFF; } AirportMove(v, apc); } diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp index 4981aa31cd..2bf5dfc816 100644 --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -39,6 +39,7 @@ #include "vehicle_func.h" #include "vehicle_base.h" #include "sound_func.h" +#include "roadveh.h" #include "table/strings.h" #include "table/sprites.h" @@ -329,7 +330,7 @@ static void DisasterTick_Ufo(Vehicle *v) v->current_order.dest = 1; FOR_ALL_VEHICLES(u) { - if (u->type == VEH_ROAD && IsHumanPlayer(u->owner)) { + if (u->type == VEH_ROAD && IsRoadVehFront(u) && IsHumanPlayer(u->owner)) { v->dest_tile = u->index; v->age = 0; return; @@ -340,7 +341,7 @@ static void DisasterTick_Ufo(Vehicle *v) } else { /* Target a vehicle */ u = GetVehicle(v->dest_tile); - if (u->type != VEH_ROAD) { + if (u->type != VEH_ROAD || !IsRoadVehFront(u)) { DeleteDisasterVeh(v); return; } @@ -363,12 +364,16 @@ static void DisasterTick_Ufo(Vehicle *v) v->age++; if (u->u.road.crashed_ctr == 0) { u->u.road.crashed_ctr++; - u->vehstatus |= VS_CRASHED; AddNewsItem(STR_B001_ROAD_VEHICLE_DESTROYED, NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, 0), u->index, 0); + + for (Vehicle *w = u; w != NULL; w = w->Next()) { + w->vehstatus |= VS_CRASHED; + MarkSingleVehicleDirty(w); + } } } diff --git a/src/settings.cpp b/src/settings.cpp index 40e1f27ac2..bebdc1f11c 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1258,8 +1258,8 @@ static int32 ConvertLandscape(const char *value) static const SettingDesc _music_settings[] = { SDT_VAR(MusicFileSettings, playlist, SLE_UINT8, S, 0, 0, 0, 5, 1, STR_NULL, NULL), - SDT_VAR(MusicFileSettings, music_vol, SLE_UINT8, S, 0, 128, 0, 100, 1, STR_NULL, NULL), - SDT_VAR(MusicFileSettings, effect_vol, SLE_UINT8, S, 0, 128, 0, 100, 1, STR_NULL, NULL), + SDT_VAR(MusicFileSettings, music_vol, SLE_UINT8, S, 0, 127, 0, 127, 1, STR_NULL, NULL), + SDT_VAR(MusicFileSettings, effect_vol, SLE_UINT8, S, 0, 127, 0, 127, 1, STR_NULL, NULL), SDT_LIST(MusicFileSettings, custom_1, SLE_UINT8, S, 0, NULL, STR_NULL, NULL), SDT_LIST(MusicFileSettings, custom_2, SLE_UINT8, S, 0, NULL, STR_NULL, NULL), SDT_BOOL(MusicFileSettings, playing, S, 0, true, STR_NULL, NULL), diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index e6ff67c192..abc05c681a 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1323,7 +1323,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) bool type = HasBit(p2, 0); bool is_drive_through = HasBit(p2, 1); bool build_over_road = is_drive_through && IsNormalRoadTile(tile); - bool town_owned_road = build_over_road && IsTileOwner(tile, OWNER_TOWN); + bool town_owned_road = false; RoadTypes rts = (RoadTypes)GB(p2, 2, 3); if (!AreValidRoadTypes(rts) || !HasRoadTypesAvail(_current_player, rts)) return CMD_ERROR; @@ -1342,22 +1342,27 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost cost; + RoadTypes cur_rts = IsNormalRoadTile(tile) ? GetRoadTypes(tile) : ROADTYPES_NONE; + uint num_roadbits = 0; /* Not allowed to build over this road */ if (build_over_road) { - if (IsTileOwner(tile, OWNER_TOWN) && !_patches.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD); - - RoadTypes cur_rts = GetRoadTypes(tile); - /* there is a road, check if we can build road+tram stop over it */ if (HasBit(cur_rts, ROADTYPE_ROAD)) { Owner road_owner = GetRoadOwner(tile, ROADTYPE_ROAD); - if (road_owner != OWNER_TOWN && road_owner != OWNER_NONE && !CheckOwnership(road_owner)) return CMD_ERROR; + if (road_owner == OWNER_TOWN) { + town_owned_road = true; + if (!_patches.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD); + } else { + if (road_owner != OWNER_NONE && !CheckOwnership(road_owner)) return CMD_ERROR; + } + num_roadbits += CountBits(GetRoadBits(tile, ROADTYPE_ROAD)); } /* there is a tram, check if we can build road+tram stop over it */ if (HasBit(cur_rts, ROADTYPE_TRAM)) { Owner tram_owner = GetRoadOwner(tile, ROADTYPE_TRAM); if (tram_owner != OWNER_NONE && !CheckOwnership(tram_owner)) return CMD_ERROR; + num_roadbits += CountBits(GetRoadBits(tile, ROADTYPE_TRAM)); } /* Don't allow building the roadstop when vehicles are already driving on it */ @@ -1368,6 +1373,8 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) } cost = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL, !build_over_road); if (CmdFailed(cost)) return cost; + uint roadbits_to_build = CountBits(rts) * 2 - num_roadbits; + cost.AddCost(_price.build_road * roadbits_to_build); Station *st = NULL; diff --git a/src/strings.cpp b/src/strings.cpp index 32f2a297cf..00a0eb9098 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -846,11 +846,18 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c } case SCC_STATION_NAME: { // {STATION} - const Station* st = GetStation(GetInt32(&argv)); + StationID sid = GetInt32(&argv); - if (!st->IsValid()) { // station doesn't exist anymore + if (!IsValidStationID(sid)) { + /* The station doesn't exist anymore. The only place where we might + * be "drawing" an invalid station is in the case of cargo that is + * in transit. */ buff = GetStringWithArgs(buff, STR_UNKNOWN_DESTINATION, NULL, last); - } else if (st->name != NULL) { + break; + } + + const Station *st = GetStation(sid); + if (st->name != NULL) { buff = strecpy(buff, st->name, last); } else { int64 temp[3]; diff --git a/src/yapf/yapf_road.cpp b/src/yapf/yapf_road.cpp index eef92e5f7d..52f5612499 100644 --- a/src/yapf/yapf_road.cpp +++ b/src/yapf/yapf_road.cpp @@ -321,14 +321,15 @@ public: TrackdirBits dst_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(dst_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes)); Yapf().SetDestination(dst_tile, dst_td_bits); - // find the best path - Yapf().FindPath(v); - // if path not found - return distance = UINT_MAX uint dist = UINT_MAX; + + // find the best path + if (!Yapf().FindPath(v)) return dist; + Node *pNode = Yapf().GetBestNode(); if (pNode != NULL) { - // path was found or at least suggested + // path was found // get the path cost estimate dist = pNode->GetCostEstimate(); }