1
0
Fork 0

Compare commits

..

No commits in common. "cb8612ba79fc3da00bb8d41f817889942f98f270" and "6f35f3274f2a845307cbc5c5ef6c5bde952fdcb4" have entirely different histories.

17 changed files with 54 additions and 71 deletions

View File

@ -17,11 +17,6 @@ jobs:
# manylinux2014 is based on CentOS 7, but already has a lot of things # manylinux2014 is based on CentOS 7, but already has a lot of things
# installed and preconfigured. It makes it easier to build OpenTTD. # installed and preconfigured. It makes it easier to build OpenTTD.
image: quay.io/pypa/manylinux2014_x86_64 image: quay.io/pypa/manylinux2014_x86_64
volumes:
- /usr/local/share/vcpkg:/vcpkg
env:
ImageOS: ${{ env.ImageOS }}
ImageVersion: ${{ env.ImageVersion }}
steps: steps:
- name: Download source - name: Download source
@ -46,18 +41,13 @@ jobs:
- name: Enable Rust cache - name: Enable Rust cache
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
- name: Prepare cache key
id: key
run: |
echo "image=$ImageOS-$ImageVersion" >> $GITHUB_OUTPUT
- name: Enable vcpkg cache - name: Enable vcpkg cache
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: /vcpkg/installed path: /vcpkg/installed
key: ${{ steps.key.outputs.image }}-vcpkg-release-1 # Increase the number whenever dependencies are modified key: ubuntu-20.04-vcpkg-release-1 # Increase the number whenever dependencies are modified
restore-keys: | restore-keys: |
${{ steps.key.outputs.image }}-vcpkg-release ubuntu-20.04-vcpkg-release
- name: Install dependencies - name: Install dependencies
run: | run: |
@ -113,23 +103,40 @@ jobs:
# We use vcpkg for our dependencies, to get more up-to-date version. # We use vcpkg for our dependencies, to get more up-to-date version.
echo "::group::Install vcpkg and dependencies" echo "::group::Install vcpkg and dependencies"
# Make Python3 available for other packages. # We do a little dance to make sure we copy the cached install folder
/vcpkg/vcpkg install python3 # into our new clone.
ln -sf /vcpkg/installed/x64-linux/tools/python3/python3.[0-9][0-9] /usr/bin/python3 git clone --depth=1 https://github.com/microsoft/vcpkg /vcpkg-clone
if [ -e /vcpkg/installed ]; then
mv /vcpkg/installed /vcpkg-clone/
rm -rf /vcpkg
fi
mv /vcpkg-clone /vcpkg
/vcpkg/vcpkg install \ (
breakpad \ cd /vcpkg
curl[http2] \ ./bootstrap-vcpkg.sh -disableMetrics
fontconfig \
freetype \ # Once installed (and cached) a package will never be upgraded unless we do it ourselves.
harfbuzz \ ./vcpkg upgrade --no-dry-run
icu \
liblzma \ # Make Python3 available for other packages.
libpng \ ./vcpkg install python3
lzo \ ln -sf $(pwd)/installed/x64-linux/tools/python3/python3.[0-9][0-9] /usr/bin/python3
sdl2 \
zlib \ ./vcpkg install \
# EOF breakpad \
curl[http2] \
fontconfig \
freetype \
harfbuzz \
icu \
liblzma \
libpng \
lzo \
sdl2 \
zlib \
# EOF
)
echo "::endgroup::" echo "::endgroup::"
echo "::group::Install breakpad dependencies" echo "::group::Install breakpad dependencies"

View File

@ -12,7 +12,7 @@ jobs:
macos: macos:
name: MacOS name: MacOS
runs-on: macos-12 runs-on: macos-11
env: env:
MACOSX_DEPLOYMENT_TARGET: 10.13 MACOSX_DEPLOYMENT_TARGET: 10.13

View File

@ -277,7 +277,7 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
/* streams of pixels (a, r, g, b channels) /* streams of pixels (a, r, g, b channels)
* *
* stored in separated stream so data are always aligned on 4B boundary */ * stored in separated stream so data are always aligned on 4B boundary */
Colour *dst_px_orig[ZOOM_LVL_END]; Colour *dst_px_orig[ZOOM_LVL_COUNT];
/* interleaved stream of 'm' channel and 'n' channel /* interleaved stream of 'm' channel and 'n' channel
* 'n' is number of following pixels with the same alpha channel class * 'n' is number of following pixels with the same alpha channel class
@ -285,10 +285,10 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
* *
* it has to be stored in one stream so fewer registers are used - * it has to be stored in one stream so fewer registers are used -
* x86 has problems with register allocation even with this solution */ * x86 has problems with register allocation even with this solution */
uint16_t *dst_n_orig[ZOOM_LVL_END]; uint16_t *dst_n_orig[ZOOM_LVL_COUNT];
/* lengths of streams */ /* lengths of streams */
uint32_t lengths[ZOOM_LVL_END][2]; uint32_t lengths[ZOOM_LVL_COUNT][2];
ZoomLevel zoom_min; ZoomLevel zoom_min;
ZoomLevel zoom_max; ZoomLevel zoom_max;

View File

@ -17,7 +17,7 @@ class Blitter_32bppOptimized : public Blitter_32bppSimple {
public: public:
/** Data stored about a (single) sprite. */ /** Data stored about a (single) sprite. */
struct SpriteData { struct SpriteData {
uint32_t offset[ZOOM_LVL_END][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information. uint32_t offset[ZOOM_LVL_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information.
byte data[]; ///< Data, all zoomlevels. byte data[]; ///< Data, all zoomlevels.
}; };

View File

@ -72,7 +72,7 @@ public:
}; };
struct SpriteData { struct SpriteData {
SpriteFlags flags; SpriteFlags flags;
SpriteInfo infos[ZOOM_LVL_END]; SpriteInfo infos[ZOOM_LVL_COUNT];
byte data[]; ///< Data, all zoomlevels. byte data[]; ///< Data, all zoomlevels.
}; };

View File

@ -18,7 +18,7 @@ class Blitter_8bppOptimized FINAL : public Blitter_8bppBase {
public: public:
/** Data stored about a (single) sprite. */ /** Data stored about a (single) sprite. */
struct SpriteData { struct SpriteData {
uint32_t offset[ZOOM_LVL_END]; ///< Offsets (from .data) to streams for different zoom levels. uint32_t offset[ZOOM_LVL_COUNT]; ///< Offsets (from .data) to streams for different zoom levels.
byte data[]; ///< Data, all zoomlevels. byte data[]; ///< Data, all zoomlevels.
}; };

View File

@ -282,9 +282,6 @@ enum CallbackID {
/** Called to determine the engine name to show. */ /** Called to determine the engine name to show. */
CBID_VEHICLE_NAME = 0x161, // 15 bit callback CBID_VEHICLE_NAME = 0x161, // 15 bit callback
/** Called to determine probability during build. */
CBID_VEHICLE_BUILD_PROBABILITY = 0x162, // 15 bit callback
}; };
/** /**

View File

@ -1192,20 +1192,6 @@ int GetEngineProperty(EngineID engine, PropertyID property, int orig_value, cons
return orig_value; return orig_value;
} }
/**
* Test for vehicle build probablity type.
* @param v Vehicle whose build probability to test.
* @param type Build probability type to test for.
* @returns True iff the probability result says so.
*/
bool TestVehicleBuildProbability(Vehicle *v, EngineID engine, BuildProbabilityType type)
{
uint16_t p = GetVehicleCallback(CBID_VEHICLE_BUILD_PROBABILITY, std::underlying_type<BuildProbabilityType>::type(type), 0, engine, v);
if (p == CALLBACK_FAILED) return false;
const uint16_t PROBABILITY_RANGE = 100;
return p + RandomRange(PROBABILITY_RANGE) >= PROBABILITY_RANGE;
}
static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, uint16_t base_random_bits, bool first) static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, uint16_t base_random_bits, bool first)
{ {

View File

@ -103,12 +103,6 @@ bool UsesWagonOverride(const Vehicle *v);
int GetVehicleProperty(const Vehicle *v, PropertyID property, int orig_value, bool is_signed = false); int GetVehicleProperty(const Vehicle *v, PropertyID property, int orig_value, bool is_signed = false);
int GetEngineProperty(EngineID engine, PropertyID property, int orig_value, const Vehicle *v = nullptr, bool is_signed = false); int GetEngineProperty(EngineID engine, PropertyID property, int orig_value, const Vehicle *v = nullptr, bool is_signed = false);
enum class BuildProbabilityType {
Reversed = 0,
};
bool TestVehicleBuildProbability(Vehicle *v, EngineID engine, BuildProbabilityType type);
enum VehicleTrigger { enum VehicleTrigger {
VEHICLE_TRIGGER_NEW_CARGO = 0x01, VEHICLE_TRIGGER_NEW_CARGO = 0x01,
/* Externally triggered only for the first vehicle in chain */ /* Externally triggered only for the first vehicle in chain */

View File

@ -195,7 +195,7 @@ static void StartSound(SoundID sound_id, float pan, uint volume)
static const byte _vol_factor_by_zoom[] = {255, 255, 255, 190, 134, 87}; static const byte _vol_factor_by_zoom[] = {255, 255, 255, 190, 134, 87};
static_assert(lengthof(_vol_factor_by_zoom) == ZOOM_LVL_END); static_assert(lengthof(_vol_factor_by_zoom) == ZOOM_LVL_COUNT);
static const byte _sound_base_vol[] = { static const byte _sound_base_vol[] = {
128, 90, 128, 128, 128, 128, 128, 128, 128, 90, 128, 128, 128, 128, 128, 128,
@ -258,7 +258,7 @@ static void SndPlayScreenCoordFx(SoundID sound, int left, int right, int top, in
StartSound( StartSound(
sound, sound,
panning, panning,
_vol_factor_by_zoom[vp->zoom] _vol_factor_by_zoom[vp->zoom - ZOOM_LVL_BEGIN]
); );
return; return;
} }

View File

@ -457,7 +457,7 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
Debug(sprite, 9, "Load sprite {}", id); Debug(sprite, 9, "Load sprite {}", id);
SpriteLoader::Sprite sprite[ZOOM_LVL_END]; SpriteLoader::Sprite sprite[ZOOM_LVL_COUNT];
uint8_t sprite_avail = 0; uint8_t sprite_avail = 0;
sprite[ZOOM_LVL_NORMAL].type = sprite_type; sprite[ZOOM_LVL_NORMAL].type = sprite_type;
@ -1051,4 +1051,4 @@ void GfxClearFontSpriteCache()
} }
} }
/* static */ ReusableBuffer<SpriteLoader::CommonPixel> SpriteLoader::Sprite::buffer[ZOOM_LVL_END]; /* static */ ReusableBuffer<SpriteLoader::CommonPixel> SpriteLoader::Sprite::buffer[ZOOM_LVL_COUNT];

View File

@ -62,7 +62,7 @@ public:
void AllocateData(ZoomLevel zoom, size_t size) { this->data = Sprite::buffer[zoom].ZeroAllocate(size); } void AllocateData(ZoomLevel zoom, size_t size) { this->data = Sprite::buffer[zoom].ZeroAllocate(size); }
private: private:
/** Allocated memory to pass sprite data around */ /** Allocated memory to pass sprite data around */
static ReusableBuffer<SpriteLoader::CommonPixel> buffer[ZOOM_LVL_END]; static ReusableBuffer<SpriteLoader::CommonPixel> buffer[ZOOM_LVL_COUNT];
}; };
/** /**

View File

@ -661,7 +661,6 @@ static CommandCost CmdBuildRailWagon(DoCommandFlag flags, TileIndex tile, const
v->group_id = DEFAULT_GROUP; v->group_id = DEFAULT_GROUP;
if (TestVehicleBuildProbability(v, v->engine_type, BuildProbabilityType::Reversed)) SetBit(v->flags, VRF_REVERSE_DIRECTION);
AddArticulatedParts(v); AddArticulatedParts(v);
v->UpdatePosition(); v->UpdatePosition();
@ -729,7 +728,6 @@ static void AddRearEngineToMultiheadedTrain(Train *v)
v->SetMultiheaded(); v->SetMultiheaded();
u->SetMultiheaded(); u->SetMultiheaded();
v->SetNext(u); v->SetNext(u);
if (TestVehicleBuildProbability(u, u->engine_type, BuildProbabilityType::Reversed)) SetBit(u->flags, VRF_REVERSE_DIRECTION);
u->UpdatePosition(); u->UpdatePosition();
/* Now we need to link the front and rear engines together */ /* Now we need to link the front and rear engines together */
@ -801,7 +799,6 @@ CommandCost CmdBuildRailVehicle(DoCommandFlag flags, TileIndex tile, const Engin
v->SetFrontEngine(); v->SetFrontEngine();
v->SetEngine(); v->SetEngine();
if (TestVehicleBuildProbability(v, v->engine_type, BuildProbabilityType::Reversed)) SetBit(v->flags, VRF_REVERSE_DIRECTION);
v->UpdatePosition(); v->UpdatePosition();
if (rvi->railveh_type == RAILVEH_MULTIHEAD) { if (rvi->railveh_type == RAILVEH_MULTIHEAD) {

View File

@ -1270,10 +1270,10 @@ void OpenGLBackend::ReleaseAnimBuffer(const Rect &update_rect)
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sizeof(OpenGLSprite)); Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sizeof(OpenGLSprite));
OpenGLSprite *gl_sprite = (OpenGLSprite *)dest_sprite->data; OpenGLSprite *gl_sprite = (OpenGLSprite *)dest_sprite->data;
new (gl_sprite) OpenGLSprite(sprite->width, sprite->height, sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_END, sprite->colours); new (gl_sprite) OpenGLSprite(sprite->width, sprite->height, sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_COUNT, sprite->colours);
/* Upload texture data. */ /* Upload texture data. */
for (int i = 0; i < (sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_END); i++) { for (int i = 0; i < (sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_COUNT); i++) {
gl_sprite->Update(sprite[i].width, sprite[i].height, i, sprite[i].data); gl_sprite->Update(sprite[i].width, sprite[i].height, i, sprite[i].data);
} }
@ -1323,7 +1323,7 @@ void OpenGLBackend::RenderOglSprite(OpenGLSprite *gl_sprite, PaletteID pal, int
Dimension dim = gl_sprite->GetSize(zoom); Dimension dim = gl_sprite->GetSize(zoom);
_glUseProgram(this->sprite_program); _glUseProgram(this->sprite_program);
_glUniform4f(this->sprite_sprite_loc, (float)x, (float)y, (float)dim.width, (float)dim.height); _glUniform4f(this->sprite_sprite_loc, (float)x, (float)y, (float)dim.width, (float)dim.height);
_glUniform1f(this->sprite_zoom_loc, (float)zoom); _glUniform1f(this->sprite_zoom_loc, (float)(zoom - ZOOM_LVL_BEGIN));
_glUniform2f(this->sprite_screen_loc, (float)_screen.width, (float)_screen.height); _glUniform2f(this->sprite_screen_loc, (float)_screen.width, (float)_screen.height);
_glUniform1i(this->sprite_rgb_loc, rgb ? 1 : 0); _glUniform1i(this->sprite_rgb_loc, rgb ? 1 : 0);
_glUniform1i(this->sprite_crash_loc, pal == PALETTE_CRASH ? 1 : 0); _glUniform1i(this->sprite_crash_loc, pal == PALETTE_CRASH ? 1 : 0);

View File

@ -108,7 +108,7 @@ public:
/* SpriteEncoder */ /* SpriteEncoder */
bool Is32BppSupported() override { return true; } bool Is32BppSupported() override { return true; }
uint GetSpriteAlignment() override { return 1u << (ZOOM_LVL_END - 1); } uint GetSpriteAlignment() override { return 1u << (ZOOM_LVL_COUNT - 1); }
Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override; Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
}; };

View File

@ -1477,7 +1477,7 @@ void ViewportSign::UpdatePosition(int center, int top, StringID str, StringID st
*/ */
void ViewportSign::MarkDirty(ZoomLevel maxzoom) const void ViewportSign::MarkDirty(ZoomLevel maxzoom) const
{ {
Rect zoomlevels[ZOOM_LVL_END]; Rect zoomlevels[ZOOM_LVL_COUNT];
for (ZoomLevel zoom = ZOOM_LVL_BEGIN; zoom != ZOOM_LVL_END; zoom++) { for (ZoomLevel zoom = ZOOM_LVL_BEGIN; zoom != ZOOM_LVL_END; zoom++) {
/* FIXME: This doesn't switch to width_small when appropriate. */ /* FIXME: This doesn't switch to width_small when appropriate. */

View File

@ -27,6 +27,8 @@ enum ZoomLevel : byte {
ZOOM_LVL_OUT_32X, ///< Zoomed 32 times out. ZOOM_LVL_OUT_32X, ///< Zoomed 32 times out.
ZOOM_LVL_END, ///< End for iteration. ZOOM_LVL_END, ///< End for iteration.
ZOOM_LVL_COUNT = ZOOM_LVL_END - ZOOM_LVL_BEGIN, ///< Number of zoom levels.
/* Here we define in which zoom viewports are */ /* Here we define in which zoom viewports are */
ZOOM_LVL_VIEWPORT = ZOOM_LVL_OUT_4X, ///< Default zoom level for viewports. ZOOM_LVL_VIEWPORT = ZOOM_LVL_OUT_4X, ///< Default zoom level for viewports.
ZOOM_LVL_NEWS = ZOOM_LVL_OUT_4X, ///< Default zoom level for the news messages. ZOOM_LVL_NEWS = ZOOM_LVL_OUT_4X, ///< Default zoom level for the news messages.