mirror of
https://github.com/alterware/iw4-validator.git
synced 2025-04-19 08:32:53 +00:00
feat: print warning for invalid gametypes
This commit is contained in:
parent
a3fd324479
commit
2d69f181e2
17
.github/workflows/build.yml
vendored
17
.github/workflows/build.yml
vendored
@ -29,9 +29,12 @@ jobs:
|
|||||||
- debug
|
- debug
|
||||||
- release
|
- release
|
||||||
arch:
|
arch:
|
||||||
|
- x86
|
||||||
- x64
|
- x64
|
||||||
- arm64
|
- arm64
|
||||||
include:
|
include:
|
||||||
|
- arch: x86
|
||||||
|
platform: Win32
|
||||||
- arch: x64
|
- arch: x64
|
||||||
platform: x64
|
platform: x64
|
||||||
- arch: arm64
|
- arch: arm64
|
||||||
@ -79,6 +82,7 @@ jobs:
|
|||||||
- debug
|
- debug
|
||||||
- release
|
- release
|
||||||
arch:
|
arch:
|
||||||
|
- x86
|
||||||
- x64
|
- x64
|
||||||
- arm64
|
- arm64
|
||||||
steps:
|
steps:
|
||||||
@ -95,6 +99,13 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install crossbuild-essential-arm64 -y
|
sudo apt-get install crossbuild-essential-arm64 -y
|
||||||
|
|
||||||
|
- name: Install dependencies (x86)
|
||||||
|
if: matrix.arch == 'x86'
|
||||||
|
run: |
|
||||||
|
sudo dpkg --add-architecture i386
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get -y install gcc-multilib g++-multilib
|
||||||
|
|
||||||
- name: Install Premake5
|
- name: Install Premake5
|
||||||
uses: diamante0018/setup-premake@master
|
uses: diamante0018/setup-premake@master
|
||||||
with:
|
with:
|
||||||
@ -184,10 +195,10 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Setup Docker Buildx
|
- name: Setup Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3.2.0
|
uses: docker/setup-buildx-action@v3.3.0
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
uses: docker/login-action@v3.1.0
|
uses: docker/login-action@v3.2.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USER }}
|
username: ${{ secrets.DOCKERHUB_USER }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
@ -203,7 +214,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build and Push Docker Image
|
- name: Build and Push Docker Image
|
||||||
id: build-and-push
|
id: build-and-push
|
||||||
uses: docker/build-push-action@v5.1.0
|
uses: docker/build-push-action@v5.3.0
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
|
@ -216,9 +216,9 @@ namespace console
|
|||||||
lock _{};
|
lock _{};
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SetConsoleTitleA(title.data());
|
SetConsoleTitleA(title.c_str());
|
||||||
#else
|
#else
|
||||||
printf("\033]0;%s\007", title.data());
|
printf("\033]0;%s\007", title.c_str());
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <utils/string.hpp>
|
#include <utils/string.hpp>
|
||||||
|
|
||||||
|
#include "console.hpp"
|
||||||
#include "map_rotation.hpp"
|
#include "map_rotation.hpp"
|
||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
@ -10,6 +11,29 @@ namespace map_rotation
|
|||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
bool is_valid_game_type(const std::string& game_type)
|
||||||
|
{
|
||||||
|
static std::array<const char*, 14> game_types =
|
||||||
|
{
|
||||||
|
"arena",
|
||||||
|
"conf",
|
||||||
|
"ctf",
|
||||||
|
"dd",
|
||||||
|
"dm",
|
||||||
|
"dom",
|
||||||
|
"gtnw",
|
||||||
|
"gun",
|
||||||
|
"infect",
|
||||||
|
"koth",
|
||||||
|
"oneflag",
|
||||||
|
"sab",
|
||||||
|
"sd",
|
||||||
|
"war",
|
||||||
|
};
|
||||||
|
|
||||||
|
return std::ranges::find(game_types, game_type) != std::end(game_types);
|
||||||
|
}
|
||||||
|
|
||||||
bool is_valid_key(const std::string& key)
|
bool is_valid_key(const std::string& key)
|
||||||
{
|
{
|
||||||
static std::array<const char*, 3> keys =
|
static std::array<const char*, 3> keys =
|
||||||
@ -69,10 +93,15 @@ namespace map_rotation
|
|||||||
if (is_valid_key(key))
|
if (is_valid_key(key))
|
||||||
{
|
{
|
||||||
this->add_entry(key, value);
|
this->add_entry(key, value);
|
||||||
|
|
||||||
|
if (key == "gametype" && !is_valid_game_type(value))
|
||||||
|
{
|
||||||
|
console::warn("It appears you have an invalid game type in your map rotation (%s)", value.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw map_rotation_parse_error(utils::string::va("Invalid key '%s'", key.data()));
|
throw map_rotation_parse_error(utils::string::va("Invalid key '%s'", key.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace map_rotation
|
namespace map_rotation
|
||||||
{
|
{
|
||||||
#define DEFAULT_ERROR_MSG "Map Rotation Parse Error"
|
constexpr auto* DEFAULT_ERROR_MSG = "Map Rotation Parse Error";
|
||||||
|
|
||||||
class map_rotation_parse_error : public std::runtime_error
|
class map_rotation_parse_error : public std::runtime_error
|
||||||
{
|
{
|
||||||
|
10
src/main.cpp
10
src/main.cpp
@ -21,12 +21,12 @@ namespace
|
|||||||
std::string data;
|
std::string data;
|
||||||
if (!utils::io::read_file(filename, &data) || data.empty())
|
if (!utils::io::read_file(filename, &data) || data.empty())
|
||||||
{
|
{
|
||||||
throw std::runtime_error(utils::string::va("'%s' is empty", filename.data()));
|
throw std::runtime_error(utils::string::va("'%s' is empty", filename.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game::parse_client_effects(data.data()))
|
if (game::parse_client_effects(data.data()))
|
||||||
{
|
{
|
||||||
console::info("Successfully parsed '%s'\n", filename.data());
|
console::info("Successfully parsed '%s'\n", filename.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,9 +41,11 @@ namespace
|
|||||||
std::string data;
|
std::string data;
|
||||||
if (!utils::io::read_file(filename, &data) || data.empty())
|
if (!utils::io::read_file(filename, &data) || data.empty())
|
||||||
{
|
{
|
||||||
throw std::runtime_error(utils::string::va("'%s' is empty", filename.data()));
|
throw std::runtime_error(utils::string::va("'%s' is empty", filename.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console::info("Please ensure that the map rotation is in all lowercase\n");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
map_rotation::rotation_data rotation_data;
|
map_rotation::rotation_data rotation_data;
|
||||||
@ -53,7 +55,7 @@ namespace
|
|||||||
}
|
}
|
||||||
catch (const std::exception& ex)
|
catch (const std::exception& ex)
|
||||||
{
|
{
|
||||||
console::error(utils::string::va("%s. '%s' contains invalid data!\n", ex.what(), filename.data()));
|
console::error(utils::string::va("%s. '%s' contains invalid data!\n", ex.what(), filename.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,12 +7,12 @@ namespace utils
|
|||||||
{
|
{
|
||||||
bool remove_file(const std::string& file)
|
bool remove_file(const std::string& file)
|
||||||
{
|
{
|
||||||
return std::remove(file.data()) == 0;
|
return std::remove(file.c_str()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool move_file(const std::string& src, const std::string& target)
|
bool move_file(const std::string& src, const std::string& target)
|
||||||
{
|
{
|
||||||
return std::rename(src.data(), target.data()) == 0;
|
return std::rename(src.c_str(), target.c_str()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool file_exists(const std::string& file)
|
bool file_exists(const std::string& file)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user