# HG changeset patch # User glx # Date 1180052708 0 # Node ID b71483f2330fd6b195a2f9a73f35057cdee83575 # Parent ee017328156330c526ab957d99251dd9736340de (svn r9915) [NoAI] -Sync with trunk -r9815:9914 diff -r ee0173281563 -r b71483f2330f bin/data/group.grf Binary file bin/data/group.grf has changed diff -r ee0173281563 -r b71483f2330f config.lib --- a/config.lib Fri May 11 15:13:08 2007 +0000 +++ b/config.lib Fri May 25 00:25:08 2007 +0000 @@ -313,10 +313,10 @@ echo " Available options are: --endian=[AUTO|LE|BE]" exit 1 fi - # OS only allows DETECT, UNIX, OSX, FREEBSD, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, WINCE, and PSP - if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|WINCE|PSP)$'`" ]; then + # OS only allows DETECT, UNIX, OSX, FREEBSD, OPENBSD, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, WINCE, and PSP + if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|OPENBSD|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|WINCE|PSP)$'`" ]; then echo "configure: error: invalid option --os=$os" - echo " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|WINCE|PSP]" + echo " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|OPENBSD|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|WINCE|PSP]" exit 1 fi # cpu_type can be either 32 or 64 @@ -731,7 +731,7 @@ CFLAGS="$CFLAGS -fno-strict-aliasing" fi - if [ "$os" != "CYGWIN" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ]; then + if [ "$os" != "CYGWIN" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ]; then LIBS="$LIBS -lpthread" LIBS="$LIBS -lrt" fi @@ -755,6 +755,10 @@ CFLAGS="$CFLAGS -Wno-strict-prototypes" fi + if [ "$os" = "OPENBSD" ]; then + LIBS="$LIBS -pthread" + fi + if [ "$os" = "OSX" ]; then LDFLAGS="$LDFLAGS -framework Cocoa" if [ "$enable_dedicated" = "0" ]; then @@ -767,7 +771,7 @@ fi # Most targets act like UNIX, just with some additions - if [ "$os" = "BEOS" ] || [ "$os" = "OSX" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ]; then + if [ "$os" = "BEOS" ] || [ "$os" = "OSX" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ]; then CFLAGS="$CFLAGS -DUNIX" fi # And others like Windows @@ -1267,13 +1271,14 @@ detect_os() { if [ "$os" = "DETECT" ]; then - # Detect UNIX, OSX, FREEBSD, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, WINCE, and PSP + # Detect UNIX, OSX, FREEBSD, OPENBSD, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, WINCE, and PSP # Try first via dumpmachine, then via uname os=`echo "$host" | tr '[A-Z]' '[a-z]' | $awk ' /linux/ { print "UNIX"; exit} /darwin/ { print "OSX"; exit} /freebsd/ { print "FREEBSD"; exit} + /openbsd/ { print "OPENBSD"; exit} /morphos/ { print "MORPHOS"; exit} /beos/ { print "BEOS"; exit} /sunos/ { print "SUNOS"; exit} @@ -1290,6 +1295,7 @@ /linux/ { print "UNIX"; exit} /darwin/ { print "OSX"; exit} /freebsd/ { print "FREEBSD"; exit} + /openbsd/ { print "OPENBSD"; exit} /morphos/ { print "MORPHOS"; exit} /beos/ { print "BEOS"; exit} /sunos/ { print "SUNOS"; exit} @@ -1301,8 +1307,8 @@ if [ -z "$os" ]; then log 1 "detecting OS... none detected" - log 1 "I couldn't detect your OS. Please use --with-os=OS to force one" - log 1 "Allowed values are: UNIX, OSX, FREEBSD, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, WINCE, and PSP" + log 1 "I couldn't detect your OS. Please use --os=OS to force one" + log 1 "Allowed values are: UNIX, OSX, FREEBSD, OPENBSD, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, WINCE, and PSP" exit 1 fi @@ -2010,8 +2016,8 @@ echo " --awk=AWK the awk to use in configure [awk]" echo " --lipo=LIPO the lipo to use (OSX ONLY) [HOST-lipo]" echo " --os=OS the OS we are compiling for [DETECT]" - echo " DETECT/UNIX/OSX/FREEBSD/MORPHOS/BEOS/" - echo " SUNOS/CYGWIN/MINGW/OS2/WINCE/PSP" + echo " DETECT/UNIX/OSX/FREEBSD/OPENBSD/MORPHOS/" + echo " BEOS/SUNOS/CYGWIN/MINGW/OS2/WINCE/PSP" echo " --endian=ENDIAN set the endian of the HOST (AUTO/LE/BE)" echo " --revision=rXXXX overwrite the revision detection." echo " Use with care!" diff -r ee0173281563 -r b71483f2330f docs/landscape.html --- a/docs/landscape.html Fri May 11 15:13:08 2007 +0000 +++ b/docs/landscape.html Fri May 25 00:25:08 2007 +0000 @@ -475,9 +475,9 @@   * @param window_type tells what kind of window the list is for. Use the VLW flags in vehicle_gui.h * @return the number of vehicles added to the list */ -uint GenerateVehicleSortList(const Vehicle ***sort_list, uint16 *length_of_array, byte type, PlayerID owner, uint32 index, uint16 window_type) +uint GenerateVehicleSortList(const Vehicle ***sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type) { const byte subtype = (type != VEH_AIRCRAFT) ? (byte)Train_Front : (byte)AIR_AIRCRAFT; uint n = 0; @@ -2048,6 +2069,19 @@ break; } + case VLW_GROUP_LIST: + FOR_ALL_VEHICLES(v) { + if (v->type == type && ( + (type == VEH_TRAIN && IsFrontEngine(v)) || + (type != VEH_TRAIN && v->subtype <= subtype) + ) && v->owner == owner && v->group_id == index) { + if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, GetNumVehicles() / 4); + + (*sort_list)[n++] = v; + } + } + break; + default: NOT_REACHED(); break; } @@ -2071,7 +2105,7 @@ * @param vlw_flag tells what kind of list requested the goto depot * @return 0 for success and CMD_ERROR if no vehicle is able to go to depot */ -int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id) +int32 SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id) { const Vehicle **sort_list = NULL; uint n, i; @@ -2381,7 +2415,7 @@ return _tile_type_procs[GetTileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y); } -UnitID GetFreeUnitNumber(byte type) +UnitID GetFreeUnitNumber(VehicleType type) { UnitID unit, max = 0; const Vehicle *u; @@ -2439,6 +2473,7 @@ if (p->livery[LS_DEFAULT].in_use && (_patches.liveries == 2 || (_patches.liveries == 1 && player == _local_player))) { /* Determine the livery scheme to use */ switch (GetEngine(engine_type)->type) { + default: NOT_REACHED(); case VEH_TRAIN: { const RailVehicleInfo *rvi = RailVehInfo(engine_type); @@ -2449,7 +2484,7 @@ { if (cargo_type == CT_INVALID) cargo_type = rvi->cargo_type; if (rvi->railveh_type == RAILVEH_WAGON) { - if (cargo_type == CT_PASSENGERS || cargo_type == CT_MAIL || cargo_type == CT_VALUABLES) { + if (!GetCargo(cargo_type)->is_freight) { if (parent_engine_type == INVALID_ENGINE) { scheme = LS_PASSENGER_WAGON_STEAM; } else { @@ -2663,6 +2698,8 @@ SLE_REF(Vehicle, next_shared, REF_VEHICLE), SLE_REF(Vehicle, prev_shared, REF_VEHICLE), + SLE_CONDVAR(Vehicle, group_id, SLE_UINT16, 60, SL_MAX_VERSION), + /* reserve extra space in savegame here. (currently 10 bytes) */ SLE_CONDNULL(10, 2, SL_MAX_VERSION), @@ -2848,6 +2885,7 @@ case VEH_SPECIAL: v = new (v) SpecialVehicle(); break; case VEH_DISASTER: v = new (v) DisasterVehicle(); break; case VEH_INVALID: v = new (v) InvalidVehicle(); break; + default: NOT_REACHED(); } /* Old savegames used 'last_station_visited = 0xFF' */ @@ -2860,6 +2898,9 @@ v->current_order.flags = (v->current_order.type & 0xF0) >> 4; v->current_order.type.m_val &= 0x0F; } + + /* Advanced vehicle lists got added */ + if (CheckSavegameVersion(60)) v->group_id = DEFAULT_GROUP; } /* Check for shared order-lists (we now use pointers for that) */ @@ -2933,15 +2974,8 @@ { switch (this->current_order.type) { case OT_LOADING: { - /* Not the first call for this tick */ - if (mode) return; - - /* We have not waited enough time till the next round of loading/unloading */ - if (--this->load_unload_time_rem) return; - - /* Load/unload the vehicle; when it actually did something - * we do not leave the station. */ - if (LoadUnloadVehicle(this)) return; + /* Not the first call for this tick, or still loading */ + if (mode || !HASBIT(this->vehicle_flags, VF_LOADING_FINISHED)) return; this->PlayLeaveStationSound(); diff -r ee0173281563 -r b71483f2330f src/vehicle.h --- a/src/vehicle.h Fri May 11 15:13:08 2007 +0000 +++ b/src/vehicle.h Fri May 25 00:25:08 2007 +0000 @@ -8,6 +8,7 @@ #include "oldpool.h" #include "order.h" #include "rail.h" +#include "road.h" /** The returned bits of VehicleEnterTile. */ enum VehicleEnterTileStatus { @@ -64,15 +65,18 @@ RVSB_ROAD_STOP_TRACKDIR_MASK = 0x09 ///< Only bits 0 and 3 are used to encode the trackdir for road stops }; -enum { +enum VehicleType { VEH_TRAIN, VEH_ROAD, VEH_SHIP, VEH_AIRCRAFT, VEH_SPECIAL, VEH_DISASTER, + VEH_END, VEH_INVALID = 0xFF, -} ; +}; +template <> struct EnumPropsT : MakeEnumPropsT {}; +typedef TinyEnumT VehicleTypeByte; enum VehStatus { VS_HIDDEN = 0x01, @@ -141,6 +145,9 @@ /* Link between the two ends of a multiheaded engine */ Vehicle *other_multiheaded_part; + + /* Cached wagon override spritegroup */ + const struct SpriteGroup *cached_override; }; enum { @@ -182,6 +189,9 @@ byte reverse_ctr; struct RoadStop *slot; byte slot_age; + + RoadType roadtype; + RoadTypes compatible_roadtypes; }; struct VehicleSpecial { @@ -200,7 +210,7 @@ struct Vehicle { - byte type; // type, ie roadven,train,ship,aircraft,special + VehicleTypeByte type; ///< Type of vehicle byte subtype; // subtype (Filled with values from EffectVehicles/TrainSubTypes/AircraftSubTypes) VehicleID index; // NOSAVE: Index in vehicle array @@ -304,6 +314,8 @@ TileIndex cargo_loaded_at_xy; ///< tile index where feeder cargo was loaded uint32 value; + GroupID group_id; ///< Index of group Pool array + union { VehicleRail rail; VehicleAir air; @@ -516,9 +528,7 @@ void ShowAircraftViewWindow(const Vehicle* v); -UnitID GetFreeUnitNumber(byte type); - -bool LoadUnloadVehicle(Vehicle *v); +UnitID GetFreeUnitNumber(VehicleType type); void TrainConsistChanged(Vehicle *v); void TrainPowerChanged(Vehicle *v); @@ -528,9 +538,9 @@ bool VehicleNeedsService(const Vehicle *v); -uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, byte type, PlayerID owner, uint32 index, uint16 window_type); -void BuildDepotVehicleList(byte type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count); -int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id); +uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type); +void BuildDepotVehicleList(VehicleType type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count); +int32 SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id); bool IsVehicleInDepot(const Vehicle *v); void VehicleEnterDepot(Vehicle *v); @@ -606,7 +616,7 @@ v = new (v) InvalidVehicle(); } -static inline bool IsPlayerBuildableVehicleType(byte type) +static inline bool IsPlayerBuildableVehicleType(VehicleType type) { switch (type) { case VEH_TRAIN: @@ -614,8 +624,9 @@ case VEH_SHIP: case VEH_AIRCRAFT: return true; + + default: return false; } - return false; } static inline bool IsPlayerBuildableVehicleType(const Vehicle *v) @@ -711,7 +722,7 @@ extern const uint32 _send_to_depot_proc_table[]; /* Functions to find the right command for certain vehicle type */ -static inline uint32 GetCmdBuildVeh(byte type) +static inline uint32 GetCmdBuildVeh(VehicleType type) { return _veh_build_proc_table[type]; } @@ -721,7 +732,7 @@ return GetCmdBuildVeh(v->type); } -static inline uint32 GetCmdSellVeh(byte type) +static inline uint32 GetCmdSellVeh(VehicleType type) { return _veh_sell_proc_table[type]; } @@ -731,7 +742,7 @@ return GetCmdSellVeh(v->type); } -static inline uint32 GetCmdRefitVeh(byte type) +static inline uint32 GetCmdRefitVeh(VehicleType type) { return _veh_refit_proc_table[type]; } @@ -741,7 +752,7 @@ return GetCmdRefitVeh(v->type); } -static inline uint32 GetCmdSendToDepot(byte type) +static inline uint32 GetCmdSendToDepot(VehicleType type) { return _send_to_depot_proc_table[type]; } diff -r ee0173281563 -r b71483f2330f src/vehicle_gui.cpp --- a/src/vehicle_gui.cpp Fri May 11 15:13:08 2007 +0000 +++ b/src/vehicle_gui.cpp Fri May 25 00:25:08 2007 +0000 @@ -31,6 +31,7 @@ #include "depot.h" #include "helpers.hpp" #include "cargotype.h" +#include "group.h" struct Sorting { Listing aircraft; @@ -41,15 +42,6 @@ static Sorting _sorting; -struct vehiclelist_d { - const Vehicle** sort_list; // List of vehicles (sorted) - Listing *_sorting; // pointer to the appropiate subcategory of _sorting - uint16 length_of_sort_list; // Keeps track of how many vehicle pointers sort list got space for - byte vehicle_type; // The vehicle type that is sorted - list_d l; // General list struct -}; -assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d)); - static bool _internal_sort_order; // descending/ascending typedef int CDECL VehicleSortListingTypeFunction(const void*, const void*); @@ -78,7 +70,7 @@ &VehicleValueSorter, }; -static const StringID _vehicle_sort_listing[] = { +const StringID _vehicle_sort_listing[] = { STR_SORT_BY_NUMBER, STR_SORT_BY_DROPDOWN_NAME, STR_SORT_BY_AGE, @@ -134,7 +126,7 @@ } } -static void BuildVehicleList(vehiclelist_d* vl, PlayerID owner, uint16 index, uint16 window_type) +void BuildVehicleList(vehiclelist_d *vl, PlayerID owner, uint16 index, uint16 window_type) { if (!(vl->l.flags & VL_REBUILD)) return; @@ -146,7 +138,7 @@ vl->l.flags |= VL_RESORT; } -static void SortVehicleList(vehiclelist_d *vl) +void SortVehicleList(vehiclelist_d *vl) { if (!(vl->l.flags & VL_RESORT)) return; @@ -377,6 +369,7 @@ int command = 0; switch (v->type) { + default: NOT_REACHED(); case VEH_TRAIN: command = CMD_REFIT_RAIL_VEHICLE | CMD_MSG(STR_RAIL_CAN_T_REFIT_VEHICLE); break; case VEH_ROAD: command = CMD_REFIT_ROAD_VEH | CMD_MSG(STR_REFIT_ROAD_VEHICLE_CAN_T); break; case VEH_SHIP: command = CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP); break; @@ -748,16 +741,6 @@ } } -/* - * Start of functions regarding vehicle list windows - */ - -enum { - PLY_WND_PRC__OFFSET_TOP_WIDGET = 26, - PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26, - PLY_WND_PRC__SIZE_OF_ROW_BIG = 36, -}; - enum VehicleListWindowWidgets { VLW_WIDGET_CLOSEBOX = 0, VLW_WIDGET_CAPTION, @@ -808,7 +791,7 @@ uint16 window_type = w->window_number & VLW_MASK; PlayerID player = (PlayerID)GB(w->window_number, 0, 8); - vl->vehicle_type = GB(w->window_number, 11, 5); + vl->vehicle_type = (VehicleType)GB(w->window_number, 11, 5); vl->length_of_sort_list = 0; vl->sort_list = NULL; w->caption_color = player; @@ -925,7 +908,7 @@ vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer } -static void DrawSmallOrderList(const Vehicle *v, int x, int y) +void DrawSmallOrderList(const Vehicle *v, int x, int y) { const Order *order; int sel, i = 0; @@ -1235,7 +1218,7 @@ PlayerVehWndProc }; -static void ShowVehicleListWindowLocal(PlayerID player, uint16 VLW_flag, byte vehicle_type, uint16 unique_number) +static void ShowVehicleListWindowLocal(PlayerID player, uint16 VLW_flag, VehicleType vehicle_type, uint16 unique_number) { Window *w; WindowNumber num; @@ -1272,9 +1255,13 @@ } } -void ShowVehicleListWindow(PlayerID player, byte vehicle_type) +void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type) { - ShowVehicleListWindowLocal(player, VLW_STANDARD, vehicle_type, 0); + if (player == _local_player && _patches.advanced_vehicle_list) { + ShowPlayerGroup(player, vehicle_type); + } else { + ShowVehicleListWindowLocal(player, VLW_STANDARD, vehicle_type, 0); + } } void ShowVehicleListWindow(const Vehicle *v) @@ -1283,12 +1270,12 @@ ShowVehicleListWindowLocal(v->owner, VLW_SHARED_ORDERS, v->type, v->orders->index); } -void ShowVehicleListWindow(PlayerID player, byte vehicle_type, StationID station) +void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station) { ShowVehicleListWindowLocal(player, VLW_STATION_LIST, vehicle_type, station); } -void ShowVehicleListWindow(PlayerID player, byte vehicle_type, TileIndex depot_tile) +void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, TileIndex depot_tile) { uint16 depot_airport_index; diff -r ee0173281563 -r b71483f2330f src/vehicle_gui.h --- a/src/vehicle_gui.h Fri May 11 15:13:08 2007 +0000 +++ b/src/vehicle_gui.h Fri May 25 00:25:08 2007 +0000 @@ -15,21 +15,35 @@ /* sorter stuff */ void RebuildVehicleLists(); void ResortVehicleLists(); +void SortVehicleList(vehiclelist_d *vl); +void BuildVehicleList(vehiclelist_d *vl, PlayerID owner, uint16 index, uint16 window_type); #define PERIODIC_RESORT_DAYS 10 +extern const StringID _vehicle_sort_listing[]; + +/* Start of functions regarding vehicle list windows */ +enum { + PLY_WND_PRC__OFFSET_TOP_WIDGET = 26, + PLY_WND_PRC__SIZE_OF_ROW_TINY = 13, + PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26, + PLY_WND_PRC__SIZE_OF_ROW_BIG = 36, + PLY_WND_PRC__SIZE_OF_ROW_BIG2 = 39, +}; + /* Vehicle List Window type flags */ enum { VLW_STANDARD = 0 << 8, VLW_SHARED_ORDERS = 1 << 8, VLW_STATION_LIST = 2 << 8, VLW_DEPOT_LIST = 3 << 8, + VLW_GROUP_LIST = 4 << 8, VLW_MASK = 0x700, }; static inline bool ValidVLWFlags(uint16 flags) { - return (flags == VLW_STANDARD || flags == VLW_SHARED_ORDERS || flags == VLW_STATION_LIST || flags == VLW_DEPOT_LIST); + return (flags == VLW_STANDARD || flags == VLW_SHARED_ORDERS || flags == VLW_STATION_LIST || flags == VLW_DEPOT_LIST || flags == VLW_GROUP_LIST); } void PlayerVehWndProc(Window *w, WindowEvent *e); @@ -41,7 +55,7 @@ void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection); void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection); -void ShowBuildVehicleWindow(TileIndex tile, byte type); +void ShowBuildVehicleWindow(TileIndex tile, VehicleType type); void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v); @@ -49,11 +63,13 @@ uint ShowRefitOptionsList(int x, int y, uint w, EngineID engine); void ShowVehicleListWindow(const Vehicle *v); -void ShowVehicleListWindow(PlayerID player, byte vehicle_type); -void ShowVehicleListWindow(PlayerID player, byte vehicle_type, StationID station); -void ShowVehicleListWindow(PlayerID player, byte vehicle_type, TileIndex depot_tile); +void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type); +void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station); +void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, TileIndex depot_tile); -void ShowReplaceVehicleWindow(byte vehicletype); +void ShowReplaceVehicleWindow(VehicleType vehicletype); +void DrawSmallOrderList(const Vehicle *v, int x, int y); +void ShowReplaceGroupVehicleWindow(GroupID group, VehicleType veh); static inline void DrawVehicleImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection) { @@ -66,7 +82,7 @@ } } -static inline uint GetVehicleListHeight(byte type) +static inline uint GetVehicleListHeight(VehicleType type) { return (type == VEH_TRAIN || type == VEH_ROAD) ? 14 : 24; } diff -r ee0173281563 -r b71483f2330f src/video/dedicated_v.cpp --- a/src/video/dedicated_v.cpp Fri May 11 15:13:08 2007 +0000 +++ b/src/video/dedicated_v.cpp Fri May 25 00:25:08 2007 +0000 @@ -112,7 +112,7 @@ #endif -static void *_dedicated_video_mem; +static Pixel *_dedicated_video_mem; extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm); extern void SwitchMode(int new_mode); @@ -122,7 +122,7 @@ { _screen.width = _screen.pitch = _cur_resolution[0]; _screen.height = _cur_resolution[1]; - _dedicated_video_mem = malloc(_cur_resolution[0]*_cur_resolution[1]); + _dedicated_video_mem = (Pixel *)malloc(_cur_resolution[0] * _cur_resolution[1] * sizeof(Pixel)); SetDebugString("net=6"); @@ -283,7 +283,7 @@ next_tick = cur_ticks + 30; GameLoop(); - _screen.dst_ptr = (Pixel*)_dedicated_video_mem; + _screen.dst_ptr = _dedicated_video_mem; UpdateWindows(); } CSleep(1); diff -r ee0173281563 -r b71483f2330f src/video/null_v.cpp --- a/src/video/null_v.cpp Fri May 11 15:13:08 2007 +0000 +++ b/src/video/null_v.cpp Fri May 25 00:25:08 2007 +0000 @@ -7,13 +7,13 @@ #include "../window.h" #include "null_v.h" -static void* _null_video_mem = NULL; +static Pixel *_null_video_mem = NULL; static const char* NullVideoStart(const char* const* parm) { _screen.width = _screen.pitch = _cur_resolution[0]; _screen.height = _cur_resolution[1]; - _null_video_mem = malloc(_cur_resolution[0] * _cur_resolution[1]); + _null_video_mem = (Pixel *)malloc(_cur_resolution[0] * _cur_resolution[1] * sizeof(Pixel)); return NULL; } @@ -27,7 +27,7 @@ for (i = 0; i < 1000; i++) { GameLoop(); - _screen.dst_ptr = (Pixel*)_null_video_mem; + _screen.dst_ptr = _null_video_mem; UpdateWindows(); } } diff -r ee0173281563 -r b71483f2330f src/video/sdl_v.cpp --- a/src/video/sdl_v.cpp Fri May 11 15:13:08 2007 +0000 +++ b/src/video/sdl_v.cpp Fri May 25 00:25:08 2007 +0000 @@ -195,7 +195,7 @@ _screen.width = newscreen->w; _screen.height = newscreen->h; - _screen.pitch = newscreen->pitch; + _screen.pitch = newscreen->pitch / sizeof(Pixel); _sdl_screen = newscreen; InitPalette(); diff -r ee0173281563 -r b71483f2330f src/video/win32_v.cpp --- a/src/video/win32_v.cpp Fri May 11 15:13:08 2007 +0000 +++ b/src/video/win32_v.cpp Fri May 25 00:25:08 2007 +0000 @@ -671,7 +671,7 @@ if (_wnd.double_size) { w = ALIGN(w, 4); - _wnd.alloced_bits = _wnd.buffer_bits = (Pixel*)malloc(w * h); + _wnd.alloced_bits = _wnd.buffer_bits = (Pixel *)malloc(w * h * sizeof(Pixel)); w *= 2; h *= 2; } diff -r ee0173281563 -r b71483f2330f src/viewport.cpp --- a/src/viewport.cpp Fri May 11 15:13:08 2007 +0000 +++ b/src/viewport.cpp Fri May 25 00:25:08 2007 +0000 @@ -26,6 +26,8 @@ #define VIEWPORT_DRAW_MEM (65536 * 2) +ZoomLevel _saved_scrollpos_zoom; + /* XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar) */ static ViewPort _viewports[25 - 2]; static uint32 _active_viewports; ///< bitmasked variable where each bit signifies if a viewport is in use or not @@ -143,7 +145,7 @@ } void AssignWindowViewport(Window *w, int x, int y, - int width, int height, uint32 follow_flags, byte zoom) + int width, int height, uint32 follow_flags, ZoomLevel zoom) { ViewPort *vp; Point pt; @@ -162,8 +164,8 @@ vp->zoom = zoom; - vp->virtual_width = width << zoom; - vp->virtual_height = height << zoom; + vp->virtual_width = ScaleByZoom(width, zoom); + vp->virtual_height = ScaleByZoom(height, zoom); if (follow_flags & 0x80000000) { const Vehicle *veh; @@ -267,10 +269,10 @@ vp->virtual_left = x; vp->virtual_top = y; - old_left >>= vp->zoom; - old_top >>= vp->zoom; - x >>= vp->zoom; - y >>= vp->zoom; + old_left = UnScaleByZoom(old_left, vp->zoom); + old_top = UnScaleByZoom(old_top, vp->zoom); + x = UnScaleByZoom(x, vp->zoom); + y = UnScaleByZoom(y, vp->zoom); old_left -= x; old_top -= y; @@ -331,8 +333,8 @@ return pt; } - x = ((x << vp->zoom) + vp->virtual_left) >> 2; - y = ((y << vp->zoom) + vp->virtual_top) >> 1; + x = (ScaleByZoom(x, vp->zoom) + vp->virtual_left) >> 2; + y = (ScaleByZoom(y, vp->zoom) + vp->virtual_top) >> 1; a = y-x; b = y+x; @@ -404,10 +406,10 @@ * @param widget_zoom_out widget index for window with zoom-out button */ void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out) { - SetWindowWidgetDisabledState(w, widget_zoom_in, vp->zoom == 0); + SetWindowWidgetDisabledState(w, widget_zoom_in, vp->zoom == ZOOM_LVL_MIN); InvalidateWidget(w, widget_zoom_in); - SetWindowWidgetDisabledState(w, widget_zoom_out, vp->zoom == 2); + SetWindowWidgetDisabledState(w, widget_zoom_out, vp->zoom == ZOOM_LVL_MAX); InvalidateWidget(w, widget_zoom_out); } @@ -669,7 +671,7 @@ z += TILE_HEIGHT; if (ti->tileh == SLOPE_STEEP_N) z += TILE_HEIGHT; } - DrawGroundSpriteAt(_cur_dpi->zoom != 2 ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti->x, ti->y, z); + DrawGroundSpriteAt(_cur_dpi->zoom <= ZOOM_LVL_DETAIL ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti->x, ti->y, z); } else if (_thd.drawstyle & HT_RAIL /*&& _thd.place_mode == VHM_RAIL*/) { /* autorail highlight piece under cursor */ uint type = _thd.drawstyle & 0xF; @@ -808,7 +810,7 @@ bottom = top + dpi->height; switch (dpi->zoom) { - case 0: + case ZOOM_LVL_NORMAL: FOR_ALL_TOWNS(t) { if (bottom > t->sign.top && top < t->sign.top + 12 && @@ -821,7 +823,7 @@ } break; - case 1: + case ZOOM_LVL_OUT_2X: right += 2; bottom += 2; @@ -837,21 +839,26 @@ } break; - default: NOT_REACHED(); - case 2: - right += 4; - bottom += 5; + case ZOOM_LVL_OUT_4X: + case ZOOM_LVL_OUT_8X: + right += ScaleByZoom(1, dpi->zoom); + bottom += ScaleByZoom(1, dpi->zoom) + 1; FOR_ALL_TOWNS(t) { if (bottom > t->sign.top && - top < t->sign.top + 24 && + top < t->sign.top + ScaleByZoom(12, dpi->zoom) && right > t->sign.left && - left < t->sign.left + t->sign.width_2*4) { + left < t->sign.left + ScaleByZoom(t->sign.width_2, dpi->zoom)) { AddStringToDraw(t->sign.left + 5, t->sign.top + 1, STR_TOWN_LABEL_TINY_BLACK, t->index, 0); AddStringToDraw(t->sign.left + 1, t->sign.top - 3, STR_TOWN_LABEL_TINY_WHITE, t->index, 0); } } break; + + case ZOOM_LVL_OUT_16X: + break; + + default: NOT_REACHED(); } } @@ -882,7 +889,7 @@ bottom = top + dpi->height; switch (dpi->zoom) { - case 0: + case ZOOM_LVL_NORMAL: FOR_ALL_STATIONS(st) { if (bottom > st->sign.top && top < st->sign.top + 12 && @@ -893,7 +900,7 @@ } break; - case 1: + case ZOOM_LVL_OUT_2X: right += 2; bottom += 2; FOR_ALL_STATIONS(st) { @@ -906,19 +913,25 @@ } break; - default: NOT_REACHED(); - case 2: - right += 4; - bottom += 5; + case ZOOM_LVL_OUT_4X: + case ZOOM_LVL_OUT_8X: + right += ScaleByZoom(1, dpi->zoom); + bottom += ScaleByZoom(1, dpi->zoom) + 1; + FOR_ALL_STATIONS(st) { if (bottom > st->sign.top && - top < st->sign.top + 24 && + top < st->sign.top + ScaleByZoom(12, dpi->zoom) && right > st->sign.left && - left < st->sign.left + st->sign.width_2*4) { + left < st->sign.left + ScaleByZoom(st->sign.width_2, dpi->zoom)) { AddStation(st, STR_STATION_SIGN_TINY, st->sign.width_2 | 0x8000); } } break; + + case ZOOM_LVL_OUT_16X: + break; + + default: NOT_REACHED(); } } @@ -949,7 +962,7 @@ bottom = top + dpi->height; switch (dpi->zoom) { - case 0: + case ZOOM_LVL_NORMAL: FOR_ALL_SIGNS(si) { if (bottom > si->sign.top && top < si->sign.top + 12 && @@ -960,7 +973,7 @@ } break; - case 1: + case ZOOM_LVL_OUT_2X: right += 2; bottom += 2; FOR_ALL_SIGNS(si) { @@ -973,19 +986,25 @@ } break; - default: NOT_REACHED(); - case 2: - right += 4; - bottom += 5; + case ZOOM_LVL_OUT_4X: + case ZOOM_LVL_OUT_8X: + right += ScaleByZoom(1, dpi->zoom); + bottom += ScaleByZoom(1, dpi->zoom) + 1; + FOR_ALL_SIGNS(si) { if (bottom > si->sign.top && - top < si->sign.top + 24 && + top < si->sign.top + ScaleByZoom(12, dpi->zoom) && right > si->sign.left && - left < si->sign.left + si->sign.width_2 * 4) { + left < si->sign.left + ScaleByZoom(si->sign.width_2, dpi->zoom)) { AddSign(si, STR_2002, si->sign.width_2 | 0x8000); } } break; + + case ZOOM_LVL_OUT_16X: + break; + + default: NOT_REACHED(); } } @@ -1016,7 +1035,7 @@ bottom = top + dpi->height; switch (dpi->zoom) { - case 0: + case ZOOM_LVL_NORMAL: FOR_ALL_WAYPOINTS(wp) { if (bottom > wp->sign.top && top < wp->sign.top + 12 && @@ -1027,7 +1046,7 @@ } break; - case 1: + case ZOOM_LVL_OUT_2X: right += 2; bottom += 2; FOR_ALL_WAYPOINTS(wp) { @@ -1040,19 +1059,25 @@ } break; - default: NOT_REACHED(); - case 2: - right += 4; - bottom += 5; + case ZOOM_LVL_OUT_4X: + case ZOOM_LVL_OUT_8X: + right += ScaleByZoom(1, dpi->zoom); + bottom += ScaleByZoom(1, dpi->zoom) + 1; + FOR_ALL_WAYPOINTS(wp) { if (bottom > wp->sign.top && - top < wp->sign.top + 24 && + top < wp->sign.top + ScaleByZoom(12, dpi->zoom) && right > wp->sign.left && - left < wp->sign.left + wp->sign.width_2*4) { + left < wp->sign.left + ScaleByZoom(wp->sign.width_2, dpi->zoom)) { AddWaypoint(wp, STR_WAYPOINT_VIEWPORT_TINY, wp->sign.width_2 | 0x8000); } } break; + + case ZOOM_LVL_OUT_16X: + break; + + default: NOT_REACHED(); } } @@ -1163,25 +1188,25 @@ static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDraw *ss) { DrawPixelInfo dp; - byte zoom; + ZoomLevel zoom; _cur_dpi = &dp; dp = *dpi; zoom = dp.zoom; - dp.zoom = 0; - - dp.left >>= zoom; - dp.top >>= zoom; - dp.width >>= zoom; - dp.height >>= zoom; + dp.zoom = ZOOM_LVL_NORMAL; + + dp.left = UnScaleByZoom(dp.left, zoom); + dp.top = UnScaleByZoom(dp.top, zoom); + dp.width = UnScaleByZoom(dp.width, zoom); + dp.height = UnScaleByZoom(dp.height, zoom); do { uint16 colour; if (ss->width != 0) { - int x = (ss->x >> zoom) - 1; - int y = (ss->y >> zoom) - 1; + int x = UnScaleByZoom(ss->x, zoom) - 1; + int y = UnScaleByZoom(ss->y, zoom) - 1; int bottom = y + 11; int w = ss->width; @@ -1214,7 +1239,7 @@ colour = 16; } DrawString( - ss->x >> zoom, (ss->y >> zoom) - (ss->width & 0x8000 ? 2 : 0), + UnScaleByZoom(ss->x, zoom), UnScaleByZoom(ss->y, zoom) - (ss->width & 0x8000 ? 2 : 0), ss->string, colour ); @@ -1239,7 +1264,7 @@ _cur_dpi = &vd.dpi; vd.dpi.zoom = vp->zoom; - mask = (-1) << vp->zoom; + mask = ScaleByZoom(-1, vp->zoom); vd.combine_sprites = 0; @@ -1249,8 +1274,8 @@ vd.dpi.top = top & mask; vd.dpi.pitch = old_dpi->pitch; - x = ((vd.dpi.left - (vp->virtual_left&mask)) >> vp->zoom) + vp->left; - y = ((vd.dpi.top - (vp->virtual_top&mask)) >> vp->zoom) + vp->top; + x = UnScaleByZoom(vd.dpi.left - (vp->virtual_left & mask), vp->zoom) + vp->left; + y = UnScaleByZoom(vd.dpi.top - (vp->virtual_top & mask), vp->zoom) + vp->top; vd.dpi.dst_ptr = old_dpi->dst_ptr + x - old_dpi->left + (y - old_dpi->top) * old_dpi->pitch; @@ -1293,7 +1318,7 @@ * If we do, the sprite memory will overflow. */ static void ViewportDrawChk(const ViewPort *vp, int left, int top, int right, int bottom) { - if (((bottom - top) * (right - left) << (2 * vp->zoom)) > 180000) { + if (ScaleByZoom(bottom - top, vp->zoom) * ScaleByZoom(right - left, vp->zoom) > 180000) { if ((bottom - top) > (right - left)) { int t = (top + bottom) >> 1; ViewportDrawChk(vp, left, top, right, t); @@ -1305,10 +1330,10 @@ } } else { ViewportDoDraw(vp, - ((left - vp->left) << vp->zoom) + vp->virtual_left, - ((top - vp->top) << vp->zoom) + vp->virtual_top, - ((right - vp->left) << vp->zoom) + vp->virtual_left, - ((bottom - vp->top) << vp->zoom) + vp->virtual_top + ScaleByZoom(left - vp->left, vp->zoom) + vp->virtual_left, + ScaleByZoom(top - vp->top, vp->zoom) + vp->virtual_top, + ScaleByZoom(right - vp->left, vp->zoom) + vp->virtual_left, + ScaleByZoom(bottom - vp->top, vp->zoom) + vp->virtual_top ); } } @@ -1396,10 +1421,10 @@ if (top >= vp->virtual_height) return; SetDirtyBlocks( - (left >> vp->zoom) + vp->left, - (top >> vp->zoom) + vp->top, - (right >> vp->zoom) + vp->left, - (bottom >> vp->zoom) + vp->top + UnScaleByZoom(left, vp->zoom) + vp->left, + UnScaleByZoom(top, vp->zoom) + vp->top, + UnScaleByZoom(right, vp->zoom) + vp->left, + UnScaleByZoom(bottom, vp->zoom) + vp->top ); } @@ -1490,7 +1515,7 @@ if (!HASBIT(_display_opt, DO_SHOW_TOWN_NAMES)) return false; switch (vp->zoom) { - case 0: + case ZOOM_LVL_NORMAL: x = x - vp->left + vp->virtual_left; y = y - vp->top + vp->virtual_top; FOR_ALL_TOWNS(t) { @@ -1504,7 +1529,7 @@ } break; - case 1: + case ZOOM_LVL_OUT_2X: x = (x - vp->left + 1) * 2 + vp->virtual_left; y = (y - vp->top + 1) * 2 + vp->virtual_top; FOR_ALL_TOWNS(t) { @@ -1518,19 +1543,26 @@ } break; - default: - x = (x - vp->left + 3) * 4 + vp->virtual_left; - y = (y - vp->top + 3) * 4 + vp->virtual_top; + case ZOOM_LVL_OUT_4X: + case ZOOM_LVL_OUT_8X: + x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left; + y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top; + FOR_ALL_TOWNS(t) { if (y >= t->sign.top && - y < t->sign.top + 24 && + y < t->sign.top + ScaleByZoom(12, vp->zoom) && x >= t->sign.left && - x < t->sign.left + t->sign.width_2 * 4) { + x < t->sign.left + ScaleByZoom(t->sign.width_2, vp->zoom)) { ShowTownViewWindow(t->index); return true; } } break; + + case ZOOM_LVL_OUT_16X: + break; + + default: NOT_REACHED(); } return false; @@ -1544,7 +1576,7 @@ if (!HASBIT(_display_opt, DO_SHOW_STATION_NAMES)) return false; switch (vp->zoom) { - case 0: + case ZOOM_LVL_NORMAL: x = x - vp->left + vp->virtual_left; y = y - vp->top + vp->virtual_top; FOR_ALL_STATIONS(st) { @@ -1558,7 +1590,7 @@ } break; - case 1: + case ZOOM_LVL_OUT_2X: x = (x - vp->left + 1) * 2 + vp->virtual_left; y = (y - vp->top + 1) * 2 + vp->virtual_top; FOR_ALL_STATIONS(st) { @@ -1572,19 +1604,26 @@ } break; - default: - x = (x - vp->left + 3) * 4 + vp->virtual_left; - y = (y - vp->top + 3) * 4 + vp->virtual_top; + case ZOOM_LVL_OUT_4X: + case ZOOM_LVL_OUT_8X: + x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left; + y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top; + FOR_ALL_STATIONS(st) { if (y >= st->sign.top && - y < st->sign.top + 24 && + y < st->sign.top + ScaleByZoom(12, vp->zoom) && x >= st->sign.left && - x < st->sign.left + st->sign.width_2 * 4) { + x < st->sign.left + ScaleByZoom(st->sign.width_2, vp->zoom)) { ShowStationViewWindow(st->index); return true; } } break; + + case ZOOM_LVL_OUT_16X: + break; + + default: NOT_REACHED(); } return false; @@ -1598,7 +1637,7 @@ if (!HASBIT(_display_opt, DO_SHOW_SIGNS) || _current_player == PLAYER_SPECTATOR) return false; switch (vp->zoom) { - case 0: + case ZOOM_LVL_NORMAL: x = x - vp->left + vp->virtual_left; y = y - vp->top + vp->virtual_top; FOR_ALL_SIGNS(si) { @@ -1612,7 +1651,7 @@ } break; - case 1: + case ZOOM_LVL_OUT_2X: x = (x - vp->left + 1) * 2 + vp->virtual_left; y = (y - vp->top + 1) * 2 + vp->virtual_top; FOR_ALL_SIGNS(si) { @@ -1626,19 +1665,26 @@ } break; - default: - x = (x - vp->left + 3) * 4 + vp->virtual_left; - y = (y - vp->top + 3) * 4 + vp->virtual_top; + case ZOOM_LVL_OUT_4X: + case ZOOM_LVL_OUT_8X: + x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left; + y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top; + FOR_ALL_SIGNS(si) { if (y >= si->sign.top && - y < si->sign.top + 24 && + y < si->sign.top + ScaleByZoom(12, vp->zoom) && x >= si->sign.left && - x < si->sign.left + si->sign.width_2 * 4) { + x < si->sign.left + ScaleByZoom(si->sign.width_2, vp->zoom)) { ShowRenameSignWindow(si); return true; } } break; + + case ZOOM_LVL_OUT_16X: + break; + + default: NOT_REACHED(); } return false; @@ -1652,7 +1698,7 @@ if (!HASBIT(_display_opt, DO_WAYPOINTS)) return false; switch (vp->zoom) { - case 0: + case ZOOM_LVL_NORMAL: x = x - vp->left + vp->virtual_left; y = y - vp->top + vp->virtual_top; FOR_ALL_WAYPOINTS(wp) { @@ -1666,7 +1712,7 @@ } break; - case 1: + case ZOOM_LVL_OUT_2X: x = (x - vp->left + 1) * 2 + vp->virtual_left; y = (y - vp->top + 1) * 2 + vp->virtual_top; FOR_ALL_WAYPOINTS(wp) { @@ -1680,19 +1726,26 @@ } break; - default: - x = (x - vp->left + 3) * 4 + vp->virtual_left; - y = (y - vp->top + 3) * 4 + vp->virtual_top; + case ZOOM_LVL_OUT_4X: + case ZOOM_LVL_OUT_8X: + x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left; + y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top; + FOR_ALL_WAYPOINTS(wp) { if (y >= wp->sign.top && - y < wp->sign.top + 24 && + y < wp->sign.top + ScaleByZoom(12, vp->zoom) && x >= wp->sign.left && - x < wp->sign.left + wp->sign.width_2 * 4) { + x < wp->sign.left + ScaleByZoom(wp->sign.width_2, vp->zoom)) { ShowRenameWaypointWindow(wp); return true; } } break; + + case ZOOM_LVL_OUT_16X: + break; + + default: NOT_REACHED(); } return false; @@ -1932,9 +1985,10 @@ } /** highlighting tiles while only going over them with the mouse */ -void VpStartPlaceSizing(TileIndex tile, int user) +void VpStartPlaceSizing(TileIndex tile, byte method, byte process) { - _thd.userdata = user; + _thd.select_method = method; + _thd.select_proc = process; _thd.selend.x = TileX(tile) * TILE_SIZE; _thd.selstart.x = TileX(tile) * TILE_SIZE; _thd.selend.y = TileY(tile) * TILE_SIZE; @@ -2392,7 +2446,8 @@ if (_special_mouse_mode != WSM_SIZING) return true; - e.we.place.userdata = _thd.userdata; + e.we.place.select_method = _thd.select_method; + e.we.place.select_proc = _thd.select_proc; /* stop drag mode if the window has been closed */ w = FindWindowById(_thd.window_class, _thd.window_number); @@ -2414,7 +2469,7 @@ _special_mouse_mode = WSM_NONE; if (_thd.next_drawstyle == HT_RECT) { _thd.place_mode = VHM_RECT; - } else if ((e.we.place.userdata & 0xF) == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik + } else if (e.we.place.select_method == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik _thd.place_mode = VHM_RECT; } else if (_thd.next_drawstyle & HT_LINE) { _thd.place_mode = VHM_RAIL; diff -r ee0173281563 -r b71483f2330f src/viewport.h --- a/src/viewport.h Fri May 11 15:13:08 2007 +0000 +++ b/src/viewport.h Fri May 25 00:25:08 2007 +0000 @@ -5,6 +5,8 @@ #ifndef VIEWPORT_H #define VIEWPORT_H +#include "zoom.hpp" + struct ViewPort { int left,top; // screen coordinates for the viewport int width, height; // screen width/height for the viewport @@ -12,7 +14,7 @@ int virtual_left, virtual_top; // virtual coordinates int virtual_width, virtual_height; // these are just width << zoom, height << zoom - byte zoom; + ZoomLevel zoom; }; void SetSelectionRed(bool); @@ -21,7 +23,7 @@ void InitViewports(); void DeleteWindowViewport(Window *w); void AssignWindowViewport(Window *w, int x, int y, - int width, int height, uint32 follow_flags, byte zoom); + int width, int height, uint32 follow_flags, ZoomLevel zoom); ViewPort *IsPtInWindowViewport(const Window *w, int x, int y); Point GetTileBelowCursor(); void UpdateViewportPosition(Window *w); @@ -60,7 +62,7 @@ void SetTileSelectSize(int w, int h); void SetTileSelectBigSize(int ox, int oy, int sx, int sy); -void VpStartPlaceSizing(TileIndex tile, int user); +void VpStartPlaceSizing(TileIndex tile, byte method, byte process); void VpSetPresizeRange(uint from, uint to); void VpSetPlaceSizingLimit(int limit); @@ -135,7 +137,9 @@ WindowClass window_class; WindowNumber window_number; - int userdata; + byte select_method; + byte select_proc; + TileIndex redsq; }; diff -r ee0173281563 -r b71483f2330f src/water_cmd.cpp --- a/src/water_cmd.cpp Fri May 11 15:13:08 2007 +0000 +++ b/src/water_cmd.cpp Fri May 25 00:25:08 2007 +0000 @@ -725,7 +725,7 @@ } } -static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode) +static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode, uint sub_mode) { static const byte coast_tracks[] = {0, 32, 4, 0, 16, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0}; diff -r ee0173281563 -r b71483f2330f src/win32.cpp --- a/src/win32.cpp Fri May 11 15:13:08 2007 +0000 +++ b/src/win32.cpp Fri May 25 00:25:08 2007 +0000 @@ -890,6 +890,9 @@ #endif /* UNICODE */ #if defined(UNICODE) + /* Check if a win9x user started the win32 version */ + if (HASBIT(GetVersion(), 31)) error("This version of OpenTTD doesn't run on windows 95/98/ME.\nPlease download the win9x binary and try again."); + /* For UNICODE we need to convert the commandline to char* _AND_ * save it because argv[] points into this buffer and thus needs to * be available between subsequent calls to FS2OTTD() */ diff -r ee0173281563 -r b71483f2330f src/window.cpp --- a/src/window.cpp Fri May 11 15:13:08 2007 +0000 +++ b/src/window.cpp Fri May 25 00:25:08 2007 +0000 @@ -271,7 +271,7 @@ dp->top = top - (*wz)->top; dp->pitch = _screen.pitch; dp->dst_ptr = _screen.dst_ptr + top * _screen.pitch + left; - dp->zoom = 0; + dp->zoom = ZOOM_LVL_NORMAL; CallWindowEventNP(*wz, WE_PAINT); } } @@ -1618,14 +1618,14 @@ /* here allows scrolling in both x and y axis */ #define scrollspeed 3 if (x - 15 < 0) { - WP(w, vp_d).scrollpos_x += (x - 15) * scrollspeed << vp->zoom; + WP(w, vp_d).scrollpos_x += ScaleByZoom((x - 15) * scrollspeed, vp->zoom); } else if (15 - (vp->width - x) > 0) { - WP(w, vp_d).scrollpos_x += (15 - (vp->width - x)) * scrollspeed << vp->zoom; + WP(w, vp_d).scrollpos_x += ScaleByZoom((15 - (vp->width - x)) * scrollspeed, vp->zoom); } if (y - 15 < 0) { - WP(w, vp_d).scrollpos_y += (y - 15) * scrollspeed << vp->zoom; + WP(w, vp_d).scrollpos_y += ScaleByZoom((y - 15) * scrollspeed, vp->zoom); } else if (15 - (vp->height - y) > 0) { - WP(w,vp_d).scrollpos_y += (15 - (vp->height - y)) * scrollspeed << vp->zoom; + WP(w,vp_d).scrollpos_y += ScaleByZoom((15 - (vp->height - y)) * scrollspeed, vp->zoom); } #undef scrollspeed } @@ -1970,8 +1970,8 @@ ViewPort *vp = w->viewport; vp->width = w->width = neww; vp->height = w->height = newh; - vp->virtual_width = neww << vp->zoom; - vp->virtual_height = newh << vp->zoom; + vp->virtual_width = ScaleByZoom(neww, vp->zoom); + vp->virtual_height = ScaleByZoom(newh, vp->zoom); continue; // don't modify top,left } diff -r ee0173281563 -r b71483f2330f src/window.h --- a/src/window.h Fri May 11 15:13:08 2007 +0000 +++ b/src/window.h Fri May 25 00:25:08 2007 +0000 @@ -9,7 +9,9 @@ #include "string.h" #include "order.h" #include "rail.h" +#include "road.h" #include "airport.h" +#include "vehicle.h" struct WindowEvent; @@ -133,7 +135,8 @@ Point pt; TileIndex tile; TileIndex starttile; - int userdata; + byte select_method; + byte select_proc; } place; struct { @@ -323,10 +326,11 @@ assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d)); struct buildvehicle_d { - byte vehicle_type; + VehicleType vehicle_type; union { RailTypeByte railtype; AirportFTAClass::Flags flags; + RoadTypes roadtypes; } filter; byte sel_index; ///< deprecated value, used for 'unified' ship and road bool descending_sort_order; @@ -347,12 +351,13 @@ bool update_left; bool update_right; bool init_lists; + GroupID sel_group; }; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d)); struct depot_d { VehicleID sel; - byte type; + VehicleType type; bool generate_list; uint16 engine_list_length; uint16 wagon_list_length; @@ -477,6 +482,28 @@ }; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d)); +struct vehiclelist_d { + const Vehicle** sort_list; // List of vehicles (sorted) + Listing *_sorting; // pointer to the appropiate subcategory of _sorting + uint16 length_of_sort_list; // Keeps track of how many vehicle pointers sort list got space for + VehicleType vehicle_type; // The vehicle type that is sorted + list_d l; // General list struct +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d)); + +struct grouplist_d { + const Group **sort_list; + list_d l; // General list struct +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(grouplist_d)); + +struct groupveh_d : vehiclelist_d { + GroupID group_sel; + VehicleID vehicle_sel; + + grouplist_d gl; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(groupveh_d)); /****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/ enum WindowWidgetBehaviours { diff -r ee0173281563 -r b71483f2330f src/yapf/follow_track.hpp --- a/src/yapf/follow_track.hpp Fri May 11 15:13:08 2007 +0000 +++ b/src/yapf/follow_track.hpp Fri May 25 00:25:08 2007 +0000 @@ -45,7 +45,7 @@ { m_old_tile = old_tile; m_old_td = old_td; - assert((GetTileTrackStatus(m_old_tile, TT()) & TrackdirToTrackdirBits(m_old_td)) != 0); + assert((GetTileTrackStatus(m_old_tile, TT(), m_veh->u.road.compatible_roadtypes) & TrackdirToTrackdirBits(m_old_td)) != 0); m_exitdir = TrackdirToExitdir(m_old_td); if (EnteredDepot()) return true; if (!CanExitOldTile()) return false; @@ -114,7 +114,7 @@ if (IsRailTT() && GetTileType(m_new_tile) == MP_RAILWAY && IsPlainRailTile(m_new_tile)) { m_new_td_bits = (TrackdirBits)(GetTrackBits(m_new_tile) * 0x101); } else { - uint32 ts = GetTileTrackStatus(m_new_tile, TT()); + uint32 ts = GetTileTrackStatus(m_new_tile, TT(), m_veh->u.road.compatible_roadtypes); m_new_td_bits = (TrackdirBits)(ts & TRACKDIR_BIT_MASK); } return (m_new_td_bits != TRACKDIR_BIT_NONE); diff -r ee0173281563 -r b71483f2330f src/yapf/yapf.hpp --- a/src/yapf/yapf.hpp Fri May 11 15:13:08 2007 +0000 +++ b/src/yapf/yapf.hpp Fri May 25 00:25:08 2007 +0000 @@ -7,6 +7,7 @@ #include "track_dir.hpp" +#include "../vehicle.h" #include "../depot.h" #include "../road_map.h" #include "../tunnel_map.h" @@ -14,7 +15,6 @@ #include "../bridge.h" #include "../station.h" #include "../station_map.h" -#include "../vehicle.h" #include "../date.h" #include "../functions.h" #include "../landscape.h" diff -r ee0173281563 -r b71483f2330f src/yapf/yapf_destrail.hpp --- a/src/yapf/yapf_destrail.hpp Fri May 11 15:13:08 2007 +0000 +++ b/src/yapf/yapf_destrail.hpp Fri May 25 00:25:08 2007 +0000 @@ -113,7 +113,7 @@ default: m_destTile = v->dest_tile; m_dest_station_id = INVALID_STATION; - m_destTrackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_RAIL) & TRACKDIR_BIT_MASK); + m_destTrackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_RAIL, 0) & TRACKDIR_BIT_MASK); break; } CYapfDestinationRailBase::SetDestination(v); diff -r ee0173281563 -r b71483f2330f src/yapf/yapf_road.cpp --- a/src/yapf/yapf_road.cpp Fri May 11 15:13:08 2007 +0000 +++ b/src/yapf/yapf_road.cpp Fri May 25 00:25:08 2007 +0000 @@ -268,14 +268,14 @@ // our source tile will be the next vehicle tile (should be the given one) TileIndex src_tile = tile; // get available trackdirs on the start tile - uint ts = GetTileTrackStatus(tile, TRANSPORT_ROAD); + uint ts = GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes); TrackdirBits src_trackdirs = (TrackdirBits)(ts & TRACKDIR_BIT_MASK); // select reachable trackdirs only src_trackdirs &= DiagdirReachesTrackdirs(enterdir); // get available trackdirs on the destination tile TileIndex dest_tile = v->dest_tile; - uint dest_ts = GetTileTrackStatus(dest_tile, TRANSPORT_ROAD); + uint dest_ts = GetTileTrackStatus(dest_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes); TrackdirBits dest_trackdirs = (TrackdirBits)(dest_ts & TRACKDIR_BIT_MASK); // set origin and destination nodes @@ -320,7 +320,7 @@ // set destination tile, trackdir // get available trackdirs on the destination tile - uint dest_ts = GetTileTrackStatus(dst_tile, TRANSPORT_ROAD); + uint dest_ts = GetTileTrackStatus(dst_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes); TrackdirBits dst_td_bits = (TrackdirBits)(dest_ts & TRACKDIR_BIT_MASK); Yapf().SetDestination(dst_tile, dst_td_bits); @@ -345,7 +345,7 @@ // set origin (tile, trackdir) TileIndex src_tile = v->tile; Trackdir src_td = GetVehicleTrackdir(v); - if ((GetTileTrackStatus(src_tile, TRANSPORT_ROAD) & TrackdirToTrackdirBits(src_td)) == 0) { + if ((GetTileTrackStatus(src_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes) & TrackdirToTrackdirBits(src_td)) == 0) { // sometimes the roadveh is not on the road (it resides on non-existing track) // how should we handle that situation? return false; @@ -438,7 +438,7 @@ { TileIndex tile = v->tile; Trackdir trackdir = GetVehicleTrackdir(v); - if ((GetTileTrackStatus(tile, TRANSPORT_ROAD) & TrackdirToTrackdirBits(trackdir)) == 0) + if ((GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes) & TrackdirToTrackdirBits(trackdir)) == 0) return NULL; // handle the case when our vehicle is already in the depot tile diff -r ee0173281563 -r b71483f2330f src/yapf/yapf_ship.cpp --- a/src/yapf/yapf_ship.cpp Fri May 11 15:13:08 2007 +0000 +++ b/src/yapf/yapf_ship.cpp Fri May 25 00:25:08 2007 +0000 @@ -53,7 +53,7 @@ // convert origin trackdir to TrackdirBits TrackdirBits trackdirs = TrackdirToTrackdirBits(trackdir); // get available trackdirs on the destination tile - TrackdirBits dest_trackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_WATER) & TRACKDIR_BIT_MASK); + TrackdirBits dest_trackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_WATER, 0) & TRACKDIR_BIT_MASK); // create pathfinder instance Tpf pf; diff -r ee0173281563 -r b71483f2330f src/zoom.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/zoom.hpp Fri May 25 00:25:08 2007 +0000 @@ -0,0 +1,50 @@ +/* $Id$ */ + +/** @file zoom.hpp */ + +#ifndef ZOOM_HPP +#define ZOOM_HPP + +enum ZoomLevel { + /* Our possible zoom-levels */ + ZOOM_LVL_NORMAL = 0, + ZOOM_LVL_OUT_2X, + ZOOM_LVL_OUT_4X, + ZOOM_LVL_OUT_8X, + ZOOM_LVL_OUT_16X, + ZOOM_LVL_END, + + /* Here we define in which zoom viewports are */ + ZOOM_LVL_VIEWPORT = ZOOM_LVL_NORMAL, + ZOOM_LVL_NEWS = ZOOM_LVL_NORMAL, + ZOOM_LVL_INDUSTRY = ZOOM_LVL_OUT_2X, + ZOOM_LVL_TOWN = ZOOM_LVL_OUT_2X, + ZOOM_LVL_AIRCRAFT = ZOOM_LVL_NORMAL, + ZOOM_LVL_SHIP = ZOOM_LVL_NORMAL, + ZOOM_LVL_TRAIN = ZOOM_LVL_NORMAL, + ZOOM_LVL_ROADVEH = ZOOM_LVL_NORMAL, + ZOOM_LVL_WORLD_SCREENSHOT = ZOOM_LVL_NORMAL, + + ZOOM_LVL_DETAIL = ZOOM_LVL_OUT_2X, //! All zoomlevels below or equal to this, will result in details on the screen, like road-work, ... + + ZOOM_LVL_MIN = ZOOM_LVL_NORMAL, + ZOOM_LVL_MAX = ZOOM_LVL_OUT_16X, +}; + +extern ZoomLevel _saved_scrollpos_zoom; + +static inline int ScaleByZoom(int value, ZoomLevel zoom) +{ + if (zoom == ZOOM_LVL_NORMAL) return value; + int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL; + return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : value >> izoom; +} + +static inline int UnScaleByZoom(int value, ZoomLevel zoom) +{ + if (zoom == ZOOM_LVL_NORMAL) return value; + int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL; + return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << izoom; +} + +#endif /* ZOOM_HPP */