mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
4 Commits
6f35f3274f
...
cb8612ba79
Author | SHA1 | Date |
---|---|---|
|
cb8612ba79 | |
|
ddd609ce9b | |
|
e2c5eb3b65 | |
|
b1f98a79f8 |
|
@ -17,6 +17,11 @@ jobs:
|
|||
# manylinux2014 is based on CentOS 7, but already has a lot of things
|
||||
# installed and preconfigured. It makes it easier to build OpenTTD.
|
||||
image: quay.io/pypa/manylinux2014_x86_64
|
||||
volumes:
|
||||
- /usr/local/share/vcpkg:/vcpkg
|
||||
env:
|
||||
ImageOS: ${{ env.ImageOS }}
|
||||
ImageVersion: ${{ env.ImageVersion }}
|
||||
|
||||
steps:
|
||||
- name: Download source
|
||||
|
@ -41,13 +46,18 @@ jobs:
|
|||
- name: Enable Rust cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Prepare cache key
|
||||
id: key
|
||||
run: |
|
||||
echo "image=$ImageOS-$ImageVersion" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Enable vcpkg cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /vcpkg/installed
|
||||
key: ubuntu-20.04-vcpkg-release-1 # Increase the number whenever dependencies are modified
|
||||
key: ${{ steps.key.outputs.image }}-vcpkg-release-1 # Increase the number whenever dependencies are modified
|
||||
restore-keys: |
|
||||
ubuntu-20.04-vcpkg-release
|
||||
${{ steps.key.outputs.image }}-vcpkg-release
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
|
@ -103,40 +113,23 @@ jobs:
|
|||
# We use vcpkg for our dependencies, to get more up-to-date version.
|
||||
echo "::group::Install vcpkg and dependencies"
|
||||
|
||||
# We do a little dance to make sure we copy the cached install folder
|
||||
# into our new clone.
|
||||
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
|
||||
# Make Python3 available for other packages.
|
||||
/vcpkg/vcpkg install python3
|
||||
ln -sf /vcpkg/installed/x64-linux/tools/python3/python3.[0-9][0-9] /usr/bin/python3
|
||||
|
||||
(
|
||||
cd /vcpkg
|
||||
./bootstrap-vcpkg.sh -disableMetrics
|
||||
|
||||
# Once installed (and cached) a package will never be upgraded unless we do it ourselves.
|
||||
./vcpkg upgrade --no-dry-run
|
||||
|
||||
# Make Python3 available for other packages.
|
||||
./vcpkg install python3
|
||||
ln -sf $(pwd)/installed/x64-linux/tools/python3/python3.[0-9][0-9] /usr/bin/python3
|
||||
|
||||
./vcpkg install \
|
||||
breakpad \
|
||||
curl[http2] \
|
||||
fontconfig \
|
||||
freetype \
|
||||
harfbuzz \
|
||||
icu \
|
||||
liblzma \
|
||||
libpng \
|
||||
lzo \
|
||||
sdl2 \
|
||||
zlib \
|
||||
# EOF
|
||||
)
|
||||
/vcpkg/vcpkg install \
|
||||
breakpad \
|
||||
curl[http2] \
|
||||
fontconfig \
|
||||
freetype \
|
||||
harfbuzz \
|
||||
icu \
|
||||
liblzma \
|
||||
libpng \
|
||||
lzo \
|
||||
sdl2 \
|
||||
zlib \
|
||||
# EOF
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Install breakpad dependencies"
|
||||
|
|
|
@ -12,7 +12,7 @@ jobs:
|
|||
macos:
|
||||
name: MacOS
|
||||
|
||||
runs-on: macos-11
|
||||
runs-on: macos-12
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.13
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
|
|||
/* streams of pixels (a, r, g, b channels)
|
||||
*
|
||||
* stored in separated stream so data are always aligned on 4B boundary */
|
||||
Colour *dst_px_orig[ZOOM_LVL_COUNT];
|
||||
Colour *dst_px_orig[ZOOM_LVL_END];
|
||||
|
||||
/* interleaved stream of 'm' channel and 'n' channel
|
||||
* '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 -
|
||||
* x86 has problems with register allocation even with this solution */
|
||||
uint16_t *dst_n_orig[ZOOM_LVL_COUNT];
|
||||
uint16_t *dst_n_orig[ZOOM_LVL_END];
|
||||
|
||||
/* lengths of streams */
|
||||
uint32_t lengths[ZOOM_LVL_COUNT][2];
|
||||
uint32_t lengths[ZOOM_LVL_END][2];
|
||||
|
||||
ZoomLevel zoom_min;
|
||||
ZoomLevel zoom_max;
|
||||
|
|
|
@ -17,7 +17,7 @@ class Blitter_32bppOptimized : public Blitter_32bppSimple {
|
|||
public:
|
||||
/** Data stored about a (single) sprite. */
|
||||
struct SpriteData {
|
||||
uint32_t offset[ZOOM_LVL_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information.
|
||||
uint32_t offset[ZOOM_LVL_END][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information.
|
||||
byte data[]; ///< Data, all zoomlevels.
|
||||
};
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
};
|
||||
struct SpriteData {
|
||||
SpriteFlags flags;
|
||||
SpriteInfo infos[ZOOM_LVL_COUNT];
|
||||
SpriteInfo infos[ZOOM_LVL_END];
|
||||
byte data[]; ///< Data, all zoomlevels.
|
||||
};
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class Blitter_8bppOptimized FINAL : public Blitter_8bppBase {
|
|||
public:
|
||||
/** Data stored about a (single) sprite. */
|
||||
struct SpriteData {
|
||||
uint32_t offset[ZOOM_LVL_COUNT]; ///< Offsets (from .data) to streams for different zoom levels.
|
||||
uint32_t offset[ZOOM_LVL_END]; ///< Offsets (from .data) to streams for different zoom levels.
|
||||
byte data[]; ///< Data, all zoomlevels.
|
||||
};
|
||||
|
||||
|
|
|
@ -282,6 +282,9 @@ enum CallbackID {
|
|||
|
||||
/** Called to determine the engine name to show. */
|
||||
CBID_VEHICLE_NAME = 0x161, // 15 bit callback
|
||||
|
||||
/** Called to determine probability during build. */
|
||||
CBID_VEHICLE_BUILD_PROBABILITY = 0x162, // 15 bit callback
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1192,6 +1192,20 @@ int GetEngineProperty(EngineID engine, PropertyID property, int orig_value, cons
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -103,6 +103,12 @@ bool UsesWagonOverride(const Vehicle *v);
|
|||
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);
|
||||
|
||||
enum class BuildProbabilityType {
|
||||
Reversed = 0,
|
||||
};
|
||||
|
||||
bool TestVehicleBuildProbability(Vehicle *v, EngineID engine, BuildProbabilityType type);
|
||||
|
||||
enum VehicleTrigger {
|
||||
VEHICLE_TRIGGER_NEW_CARGO = 0x01,
|
||||
/* Externally triggered only for the first vehicle in chain */
|
||||
|
|
|
@ -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_assert(lengthof(_vol_factor_by_zoom) == ZOOM_LVL_COUNT);
|
||||
static_assert(lengthof(_vol_factor_by_zoom) == ZOOM_LVL_END);
|
||||
|
||||
static const byte _sound_base_vol[] = {
|
||||
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(
|
||||
sound,
|
||||
panning,
|
||||
_vol_factor_by_zoom[vp->zoom - ZOOM_LVL_BEGIN]
|
||||
_vol_factor_by_zoom[vp->zoom]
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -457,7 +457,7 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
|
|||
|
||||
Debug(sprite, 9, "Load sprite {}", id);
|
||||
|
||||
SpriteLoader::Sprite sprite[ZOOM_LVL_COUNT];
|
||||
SpriteLoader::Sprite sprite[ZOOM_LVL_END];
|
||||
uint8_t sprite_avail = 0;
|
||||
sprite[ZOOM_LVL_NORMAL].type = sprite_type;
|
||||
|
||||
|
@ -1051,4 +1051,4 @@ void GfxClearFontSpriteCache()
|
|||
}
|
||||
}
|
||||
|
||||
/* static */ ReusableBuffer<SpriteLoader::CommonPixel> SpriteLoader::Sprite::buffer[ZOOM_LVL_COUNT];
|
||||
/* static */ ReusableBuffer<SpriteLoader::CommonPixel> SpriteLoader::Sprite::buffer[ZOOM_LVL_END];
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
void AllocateData(ZoomLevel zoom, size_t size) { this->data = Sprite::buffer[zoom].ZeroAllocate(size); }
|
||||
private:
|
||||
/** Allocated memory to pass sprite data around */
|
||||
static ReusableBuffer<SpriteLoader::CommonPixel> buffer[ZOOM_LVL_COUNT];
|
||||
static ReusableBuffer<SpriteLoader::CommonPixel> buffer[ZOOM_LVL_END];
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -661,6 +661,7 @@ static CommandCost CmdBuildRailWagon(DoCommandFlag flags, TileIndex tile, const
|
|||
|
||||
v->group_id = DEFAULT_GROUP;
|
||||
|
||||
if (TestVehicleBuildProbability(v, v->engine_type, BuildProbabilityType::Reversed)) SetBit(v->flags, VRF_REVERSE_DIRECTION);
|
||||
AddArticulatedParts(v);
|
||||
|
||||
v->UpdatePosition();
|
||||
|
@ -728,6 +729,7 @@ static void AddRearEngineToMultiheadedTrain(Train *v)
|
|||
v->SetMultiheaded();
|
||||
u->SetMultiheaded();
|
||||
v->SetNext(u);
|
||||
if (TestVehicleBuildProbability(u, u->engine_type, BuildProbabilityType::Reversed)) SetBit(u->flags, VRF_REVERSE_DIRECTION);
|
||||
u->UpdatePosition();
|
||||
|
||||
/* Now we need to link the front and rear engines together */
|
||||
|
@ -799,6 +801,7 @@ CommandCost CmdBuildRailVehicle(DoCommandFlag flags, TileIndex tile, const Engin
|
|||
v->SetFrontEngine();
|
||||
v->SetEngine();
|
||||
|
||||
if (TestVehicleBuildProbability(v, v->engine_type, BuildProbabilityType::Reversed)) SetBit(v->flags, VRF_REVERSE_DIRECTION);
|
||||
v->UpdatePosition();
|
||||
|
||||
if (rvi->railveh_type == RAILVEH_MULTIHEAD) {
|
||||
|
|
|
@ -1270,10 +1270,10 @@ void OpenGLBackend::ReleaseAnimBuffer(const Rect &update_rect)
|
|||
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sizeof(OpenGLSprite));
|
||||
|
||||
OpenGLSprite *gl_sprite = (OpenGLSprite *)dest_sprite->data;
|
||||
new (gl_sprite) OpenGLSprite(sprite->width, sprite->height, sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_COUNT, sprite->colours);
|
||||
new (gl_sprite) OpenGLSprite(sprite->width, sprite->height, sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_END, sprite->colours);
|
||||
|
||||
/* Upload texture data. */
|
||||
for (int i = 0; i < (sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_COUNT); i++) {
|
||||
for (int i = 0; i < (sprite->type == SpriteType::Font ? 1 : ZOOM_LVL_END); i++) {
|
||||
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);
|
||||
_glUseProgram(this->sprite_program);
|
||||
_glUniform4f(this->sprite_sprite_loc, (float)x, (float)y, (float)dim.width, (float)dim.height);
|
||||
_glUniform1f(this->sprite_zoom_loc, (float)(zoom - ZOOM_LVL_BEGIN));
|
||||
_glUniform1f(this->sprite_zoom_loc, (float)zoom);
|
||||
_glUniform2f(this->sprite_screen_loc, (float)_screen.width, (float)_screen.height);
|
||||
_glUniform1i(this->sprite_rgb_loc, rgb ? 1 : 0);
|
||||
_glUniform1i(this->sprite_crash_loc, pal == PALETTE_CRASH ? 1 : 0);
|
||||
|
|
|
@ -108,7 +108,7 @@ public:
|
|||
/* SpriteEncoder */
|
||||
|
||||
bool Is32BppSupported() override { return true; }
|
||||
uint GetSpriteAlignment() override { return 1u << (ZOOM_LVL_COUNT - 1); }
|
||||
uint GetSpriteAlignment() override { return 1u << (ZOOM_LVL_END - 1); }
|
||||
Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -1477,7 +1477,7 @@ void ViewportSign::UpdatePosition(int center, int top, StringID str, StringID st
|
|||
*/
|
||||
void ViewportSign::MarkDirty(ZoomLevel maxzoom) const
|
||||
{
|
||||
Rect zoomlevels[ZOOM_LVL_COUNT];
|
||||
Rect zoomlevels[ZOOM_LVL_END];
|
||||
|
||||
for (ZoomLevel zoom = ZOOM_LVL_BEGIN; zoom != ZOOM_LVL_END; zoom++) {
|
||||
/* FIXME: This doesn't switch to width_small when appropriate. */
|
||||
|
|
|
@ -27,8 +27,6 @@ enum ZoomLevel : byte {
|
|||
ZOOM_LVL_OUT_32X, ///< Zoomed 32 times out.
|
||||
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 */
|
||||
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.
|
||||
|
|
Loading…
Reference in New Issue