mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-08 23:19:40 +00:00
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
This commit is contained in:
parent
e1057864d8
commit
889f2ab48c
@ -3764,7 +3764,7 @@ static void ParamSet(byte *buf, int len)
|
|||||||
case 0x9E: // Miscellaneous GRF features
|
case 0x9E: // Miscellaneous GRF features
|
||||||
_misc_grf_features = res;
|
_misc_grf_features = res;
|
||||||
/* Set train list engine width */
|
/* Set train list engine width */
|
||||||
_traininfo_vehicle_width = HASBIT(res, 3) ? 32 : 29;
|
_traininfo_vehicle_width = HasGrfMiscBit(GMB_TRAIN_WIDTH_32_PIXELS) ? 32 : 29;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -4811,3 +4811,8 @@ void LoadNewGRF(uint load_index, uint file_index)
|
|||||||
/* Call any functions that should be run after GRFs have been loaded. */
|
/* Call any functions that should be run after GRFs have been loaded. */
|
||||||
AfterLoadGRFs();
|
AfterLoadGRFs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HasGrfMiscBit(GrfMiscBit bit)
|
||||||
|
{
|
||||||
|
return HASBIT(_misc_grf_features, bit);
|
||||||
|
}
|
||||||
|
10
src/newgrf.h
10
src/newgrf.h
@ -23,6 +23,14 @@ enum GrfLoadingStage {
|
|||||||
|
|
||||||
DECLARE_POSTFIX_INCREMENT(GrfLoadingStage);
|
DECLARE_POSTFIX_INCREMENT(GrfLoadingStage);
|
||||||
|
|
||||||
|
enum GrfMiscBit {
|
||||||
|
GMB_DESERT_TREES_FIELDS = 0, // Unsupported.
|
||||||
|
GMB_DESERT_PAVED_ROADS = 1,
|
||||||
|
GMB_FIELD_BOUNDING_BOX = 2, // Unsupported.
|
||||||
|
GMB_TRAIN_WIDTH_32_PIXELS = 3,
|
||||||
|
GMB_AMBIENT_SOUND_CALLBACK = 4, // Unsupported.
|
||||||
|
GMB_CATENARY_ON_3RD_TRACK = 5, // Unsupported.
|
||||||
|
};
|
||||||
|
|
||||||
struct GRFLabel {
|
struct GRFLabel {
|
||||||
byte label;
|
byte label;
|
||||||
@ -85,4 +93,6 @@ void ReloadNewGRFData(); // in openttd.cpp
|
|||||||
|
|
||||||
void CDECL grfmsg(int severity, const char *str, ...);
|
void CDECL grfmsg(int severity, const char *str, ...);
|
||||||
|
|
||||||
|
bool HasGrfMiscBit(GrfMiscBit bit);
|
||||||
|
|
||||||
#endif /* NEWGRF_H */
|
#endif /* NEWGRF_H */
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "yapf/yapf.h"
|
#include "yapf/yapf.h"
|
||||||
#include "depot.h"
|
#include "depot.h"
|
||||||
|
#include "newgrf.h"
|
||||||
|
|
||||||
|
|
||||||
static uint CountRoadBits(RoadBits r)
|
static uint CountRoadBits(RoadBits r)
|
||||||
@ -661,6 +662,23 @@ const byte _road_sloped_sprites[14] = {
|
|||||||
0, 0
|
0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to draw unpaved roads regardless of the town zone.
|
||||||
|
* By default, OpenTTD always draws roads as unpaved if they are on a desert
|
||||||
|
* tile or above the snowline. Newgrf files, however, can set a bit that allows
|
||||||
|
* paved roads to be built on desert tiles as they would be on grassy tiles.
|
||||||
|
*
|
||||||
|
* @param tile The tile the road is on
|
||||||
|
* @param roadside What sort of road this is
|
||||||
|
* @return True if the road should be drawn unpaved regardless of the roadside.
|
||||||
|
*/
|
||||||
|
static bool AlwaysDrawUnpavedRoads(TileIndex tile, Roadside roadside)
|
||||||
|
{
|
||||||
|
return (IsOnSnow(tile) &&
|
||||||
|
!(_opt.landscape == LT_TROPIC && HasGrfMiscBit(GMB_DESERT_PAVED_ROADS) &&
|
||||||
|
roadside != ROADSIDE_BARREN && roadside != ROADSIDE_GRASS && roadside != ROADSIDE_GRASS_ROAD_WORKS));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw ground sprite and road pieces
|
* Draw ground sprite and road pieces
|
||||||
* @param ti TileInfo
|
* @param ti TileInfo
|
||||||
@ -687,7 +705,7 @@ static void DrawRoadBits(TileInfo* ti)
|
|||||||
|
|
||||||
roadside = GetRoadside(ti->tile);
|
roadside = GetRoadside(ti->tile);
|
||||||
|
|
||||||
if (IsOnSnow(ti->tile)) {
|
if (AlwaysDrawUnpavedRoads(ti->tile, roadside)) {
|
||||||
image += 19;
|
image += 19;
|
||||||
} else {
|
} else {
|
||||||
switch (roadside) {
|
switch (roadside) {
|
||||||
@ -729,6 +747,7 @@ static void DrawTile_Road(TileInfo *ti)
|
|||||||
case ROAD_TILE_CROSSING: {
|
case ROAD_TILE_CROSSING: {
|
||||||
SpriteID image;
|
SpriteID image;
|
||||||
SpriteID pal = PAL_NONE;
|
SpriteID pal = PAL_NONE;
|
||||||
|
Roadside roadside = GetRoadside(ti->tile);
|
||||||
|
|
||||||
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
|
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
|
||||||
|
|
||||||
@ -737,10 +756,10 @@ static void DrawTile_Road(TileInfo *ti)
|
|||||||
if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++;
|
if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++;
|
||||||
if (IsCrossingBarred(ti->tile)) image += 2;
|
if (IsCrossingBarred(ti->tile)) image += 2;
|
||||||
|
|
||||||
if (IsOnSnow(ti->tile)) {
|
if (AlwaysDrawUnpavedRoads(ti->tile, roadside)) {
|
||||||
image += 8;
|
image += 8;
|
||||||
} else {
|
} else {
|
||||||
switch (GetRoadside(ti->tile)) {
|
switch (roadside) {
|
||||||
case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; break;
|
case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; break;
|
||||||
case ROADSIDE_GRASS: break;
|
case ROADSIDE_GRASS: break;
|
||||||
default: image += 4; break; // Paved
|
default: image += 4; break; // Paved
|
||||||
|
Loading…
Reference in New Issue
Block a user