Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Senichev <[email protected]>
  • Loading branch information
artemsen committed Jan 14, 2024
1 parent 9044b9d commit ee2576a
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 8 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/mingw.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[binaries]
c = '/usr/bin/x86_64-w64-mingw32-gcc'
cpp = '/usr/bin/x86_64-w64-mingw32-g++'
objc = '/usr/bin/x86_64-w64-mingw32-gcc'
ar = '/usr/bin/x86_64-w64-mingw32-ar'
strip = '/usr/bin/x86_64-w64-mingw32-strip'
pkg-config = '/usr/bin/x86_64-w64-mingw32-pkg-config'
windres = '/usr/bin/x86_64-w64-mingw32-windres'

[properties]
root = '/usr/x86_64-w64-mingw32'
sys_root = '/usr/x86_64-w64-mingw32'

[host_machine]
system = 'windows'
subsystem = 'windows'
kernel = 'nt'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'
40 changes: 40 additions & 0 deletions .github/workflows/mingw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: MinGW
on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Install base environment
run: >
sudo apt install --no-install-recommends --yes
wget ca-certificates
make meson
g++-mingw-w64-x86-64 mingw-w64-tools
- name: Install SDL2-MinGW
run: |
mkdir -p /tmp/sdl
wget -qO- https://github.com/libsdl-org/SDL/releases/download/release-2.28.5/SDL2-devel-2.28.5-mingw.tar.gz | tar -xz --strip-components 1 -C /tmp/sdl
sudo make CROSS_PATH=/usr -C /tmp/sdl cross
mkdir -p /tmp/sdl_image
wget -qO- https://github.com/libsdl-org/SDL_image/releases/download/release-2.8.2/SDL2_image-devel-2.8.2-mingw.tar.gz | tar -xz --strip-components 1 -C /tmp/sdl_image
sudo make CROSS_PATH=/usr -C /tmp/sdl_image cross
- name: Check out source code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get version
run: echo "VERSION=$(git describe --tags --long --always | sed 's/^v//;s/-/./')" >> $GITHUB_OUTPUT
id: version

- name: Configure
run: meson -Dversion=${{steps.version.outputs.VERSION}} --buildtype release --cross-file .github/workflows/mingw.txt ./build
- name: Build
run: ninja -C ./build
- name: Install
run: DESTDIR=install ninja -C ./build install
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml → .github/workflows/native.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Native
on: [push, pull_request]

jobs:
Expand Down
2 changes: 2 additions & 0 deletions src/firework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "firework.hpp"

#include <cmath>

#include "mtrand.hpp"

Firework::Firework(const SDL_Rect& init)
Expand Down
2 changes: 1 addition & 1 deletion src/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void Layout::update(size_t width, size_t height)
level_height = height;

// size of header and footer
size_t header_h = std::min(64ul, static_cast<size_t>(window.h) / 10);
size_t header_h = static_cast<size_t>(std::min(64, window.h / 10));

// size of a single puzzle cell
const int max_wnd_w = window.w - padding * 2;
Expand Down
13 changes: 7 additions & 6 deletions src/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ void Level::generate()
std::fill(cells.begin(), cells.end(), Cell {});

// install sender (server)
sender.x = mtrand::get(1ul, width - 1);
sender.y = mtrand::get(1ul, height - 1);
sender.x = mtrand::get(static_cast<size_t>(1), width - 1);
sender.y = mtrand::get(static_cast<size_t>(1), height - 1);
get_cell(sender).object = Cell::Sender;

const size_t max_recievers = cells.size() / 5;
Expand Down Expand Up @@ -146,7 +146,8 @@ void Level::add_reciever()
}

// get random position
const size_t free_index = mtrand::get(0ul, free_cells.size());
const size_t free_index =
mtrand::get(static_cast<size_t>(0), free_cells.size());
const Position& reciever = free_cells[free_index];

// find path from receiver to sender
Expand Down Expand Up @@ -176,9 +177,9 @@ bool Level::find_path(const Position& from, std::set<Position>& vizited,
sides.push_back(Side::Top);
sides.push_back(Side::Bottom);
for (size_t i = 0; i < 4; ++i) {
const size_t index0 = mtrand::get(0ul, sides.size());
const size_t index1 = mtrand::get(0ul, sides.size());
std::iter_swap(sides.begin() + index0, sides.begin() + index1);
const size_t i0 = mtrand::get(static_cast<size_t>(0), sides.size());
const size_t i1 = mtrand::get(static_cast<size_t>(0), sides.size());
std::iter_swap(sides.begin() + i0, sides.begin() + i1);
}
} else {
// shortest path
Expand Down

0 comments on commit ee2576a

Please sign in to comment.