Merge pull request #234 from XLabsProject/develop

Release v1.1.0
This commit is contained in:
Maurice Heumann 2021-07-11 15:50:38 +02:00 committed by GitHub
commit d40536c636
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 237 additions and 258 deletions

View File

@ -6,74 +6,39 @@ on:
- "*"
pull_request:
branches:
- master
types: [closed, opened, synchronize, reopened]
- "*"
types: [opened, synchronize, reopened]
jobs:
modify:
runs-on: ubuntu-latest
name: Apply Git modifications if any are necessary
steps:
- name: Check out files
uses: actions/checkout@v2
with:
submodules: false
lfs: false
# Set up committer info and GPG key
- name: Import GPG key
if: github.event.pull_request.merged
id: import_gpg
uses: XLabsProject/ghaction-import-gpg@25d9d6ab99eb355c169c33c2306a72df85d9f516
with:
git-commit-gpgsign: true
git-committer-email: "${{ secrets.XLABS_CI_EMAIL }}"
git-committer-name: "${{ secrets.XLABS_CI_NAME }}"
git-push-gpgsign: false
git-tag-gpgsign: true
git-user-signingkey: true
gpg-private-key: ${{ secrets.XLABS_CI_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.XLABS_CI_GPG_PASSWORD }}
- name: Extract version from changelog
if: github.event.pull_request.merged
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_depth: 10
path: ./CHANGELOG.md
- name: Create annotated tag
if: github.event.pull_request.merged
run: |
git tag -a -m "${{ steps.changelog_reader.outputs.changes }}" \
"${{ steps.changelog_reader.outputs.version }}" \
"${{ github.event.pull_request.merge_commit_sha }}"
git push origin --tags
build:
name: Build binaries
runs-on: windows-latest
needs:
- modify
strategy:
matrix:
configuration:
- Debug
- Release
steps:
- name: Wait for previous workflows
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: softprops/turnstyle@v1
with:
poll-interval-seconds: 10
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check out files
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0
# NOTE - if LFS ever starts getting used during builds, switch this to true!
# NOTE - If LFS ever starts getting used during builds, switch this to true!
lfs: false
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
- name: Generate project files
#run: tools/premake5 vs2019 --ci-build
run: tools/premake5 vs2019
- name: Set up problem matching
@ -87,130 +52,46 @@ jobs:
with:
name: ${{matrix.configuration}} binaries
path: |
build/bin/x64/${{matrix.configuration}}/*
build/bin/x64/${{matrix.configuration}}/s1x.exe
build/bin/x64/${{matrix.configuration}}/s1x.pdb
- name: Upload ${{matrix.configuration}} debug symbols
uses: actions/upload-artifact@v2
with:
name: ${{matrix.configuration}} debug symbols
path: |
build/bin/**/*.pdb
release:
name: Create new GitHub Release
deploy:
name: Deploy artifacts
needs: build
runs-on: ubuntu-latest
if: github.event.pull_request.merged
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop')
steps:
- name: Check out files
uses: actions/checkout@v2
with:
submodules: false
lfs: false
- name: Setup main environment
if: github.ref == 'refs/heads/master'
run: echo "XLABS_MASTER_PATH=${{ secrets.XLABS_MASTER_SSH_PATH }}" >> $GITHUB_ENV
- name: Setup develop environment
if: github.ref == 'refs/heads/develop'
run: echo "XLABS_MASTER_PATH=${{ secrets.XLABS_MASTER_SSH_PATH_DEV }}" >> $GITHUB_ENV
- name: Download Release binaries
uses: actions/download-artifact@v2
with:
name: Release binaries
# Set up committer info and GPG key
- name: Import GPG key
id: import_gpg
uses: XLabsProject/ghaction-import-gpg@25d9d6ab99eb355c169c33c2306a72df85d9f516
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
git-commit-gpgsign: true
git-committer-email: "${{ secrets.XLABS_CI_EMAIL }}"
git-committer-name: "${{ secrets.XLABS_CI_NAME }}"
git-push-gpgsign: false
git-tag-gpgsign: true
git-user-signingkey: true
gpg-private-key: ${{ secrets.XLABS_CI_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.XLABS_CI_GPG_PASSWORD }}
key: ${{ secrets.XLABS_MASTER_SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
- name: Extract version from changelog
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
- name: Add known hosts
run: ssh-keyscan -H ${{ secrets.XLABS_MASTER_SSH_ADDRESS }} >> ~/.ssh/known_hosts
- name: Wait for previous workflows
uses: softprops/turnstyle@v1
with:
validation_depth: 2
path: ./CHANGELOG.md
- uses: papeloto/action-zip@v1
with:
recursive: false
files: s1x.exe
dest: s1x-${{ steps.changelog_reader.outputs.version }}.zip
- name: Sign ZIP file
run: gpg --output "s1x-${{ steps.changelog_reader.outputs.version }}.zip.sig" --detach-sig "s1x-${{ steps.changelog_reader.outputs.version }}.zip"
- name: Create Release
id: create_release
uses: actions/create-release@v1
poll-interval-seconds: 10
env:
GITHUB_TOKEN: ${{ secrets.XLABS_CI_GITHUB_TOKEN }}
with:
tag_name: ${{ steps.changelog_reader.outputs.version }}
release_name: ${{ steps.changelog_reader.outputs.version }}
body: ${{ steps.changelog_reader.outputs.changes }}
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release ZIP
id: upload-release-zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.XLABS_CI_GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/s1x-${{ steps.changelog_reader.outputs.version }}.zip
asset_name: s1x-${{ steps.changelog_reader.outputs.version }}.zip
asset_content_type: application/zip
- name: Upload s1x binary
run: rsync -avz s1x.exe ${{ secrets.XLABS_MASTER_SSH_USER }}@${{ secrets.XLABS_MASTER_SSH_ADDRESS }}:${{ env.XLABS_MASTER_PATH }}/s1x/
- name: Upload Release ZIP signature
id: upload-release-zip-signature
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.XLABS_CI_GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/s1x-${{ steps.changelog_reader.outputs.version }}.zip.sig
asset_name: s1x-${{ steps.changelog_reader.outputs.version }}.zip.sig
asset_content_type: text/plain
- name: Remove extra files
run: git clean -ffdx && git reset --hard
- name: Create Pull Request to merge master back into develop
uses: peter-evans/create-pull-request@v3
env:
GITHUB_TOKEN: ${{ secrets.XLABS_CI_GITHUB_TOKEN }}
with:
delete-branch: false
author: "${{ secrets.XLABS_CI_NAME }} <${{ secrets.XLABS_CI_EMAIL }}>"
committer: "${{ secrets.XLABS_CI_NAME }} <${{ secrets.XLABS_CI_EMAIL }}>"
branch: release/${{ steps.changelog_reader.outputs.version }}
base: develop
body: |
This Pull Request contains all changes done for the release of ${{ steps.changelog_reader.outputs.version }}, ready to be merged back into `master`.
This release should be merged in due time to make sure that changes done to files such as the changelog as part of the release are also contained on the `develop` branch.
title: Merge ${{ steps.changelog_reader.outputs.version }} into develop
notify:
name: Notify Discord
runs-on: ubuntu-latest
if: |
github.repository_owner == 'XLabsProject' && (
(
github.event.pull_request.merged
) || (
github.event.push.ref == 'refs/heads/master' ||
github.event.push.ref == 'refs/heads/develop'
)
)
steps:
- name: Post CI status notification to Discord
uses: sarisia/actions-status-discord@v1.7.1
if: always()
with:
webhook: ${{ secrets.DISCORD_CI_BOT_WEBHOOK }}
title: "Build"
- name: Publish changes
run: ssh ${{ secrets.XLABS_MASTER_SSH_USER }}@${{ secrets.XLABS_MASTER_SSH_ADDRESS }} ${{ secrets.XLABS_MASTER_SSH_CHANGE_PUBLISH_COMMAND }}

View File

@ -35,48 +35,13 @@ jobs:
gpg-private-key: ${{ secrets.XLABS_CI_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.XLABS_CI_GPG_PASSWORD }}
- name: Rename Unreleased section in changelog to ${{ steps.normalize_version.outputs.version }}
uses: thomaseizinger/keep-a-changelog-new-release@1.1.0
with:
version: ${{ steps.normalize_version.outputs.version }}
- name: Commit changelog
id: make-commit
run: |
git checkout -b "release/${{ steps.normalize_version.outputs.version }}"
git add CHANGELOG.md
git commit -S -m "Prepare release ${{ steps.normalize_version.outputs.version }}"
git push -u origin "release/${{ steps.normalize_version.outputs.version }}"
echo "::set-output name=commit::$(git rev-parse HEAD)"
- name: Extract changelog for Pull Request
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_depth: 10
version: ${{ steps.normalize_version.outputs.version }}
path: ./CHANGELOG.md
- name: Create Pull Request
uses: repo-sync/pull-request@v2
with:
github_token: ${{ secrets.XLABS_CI_GITHUB_TOKEN }}
source_branch: "release/${{ steps.normalize_version.outputs.version }}"
source_branch: "develop"
destination_branch: "master"
pr_body: |
This Pull Request is for the release of S1x ${{ steps.normalize_version.outputs.version }} and was [automatically created by a workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) triggered by @${{ github.actor }}.
Commit [`${{ steps.make-commit.outputs.commit }}`](https://github.com/${{ github.repository }}/commit/${{ steps.make-commit.outputs.commit }}) includes an update to the changelog to list the new version with its changes.
# What happens when this PR gets merged?
After merging this PR, another workflow will create a new tag `${{ steps.normalize_version.outputs.version }}` on the `master` branch and the version will officially be ${{ steps.changelog_reader.outputs.status }} via an actual GitHub release. A final build will be triggered and all binaries and assets will be attached to the GitHub release.
# Changelog for ${{ steps.normalize_version.outputs.version }}
These changes will be included in the release:
${{ steps.changelog_reader.outputs.changes }}
pr_title: Release ${{ steps.changelog_reader.outputs.version }}
This Pull Request is for the release of X Labs Launcher ${{ steps.normalize_version.outputs.version }} and was [automatically created by a workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) triggered by @${{ github.actor }}.
pr_title: Release ${{ steps.normalize_version.outputs.version }}
pr_label: release

80
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,80 @@
name: Release
on:
pull_request:
branches:
- "master"
types: [closed]
jobs:
merge:
runs-on: ubuntu-latest
name: Merge Release
steps:
- name: Check out files
uses: actions/checkout@v2
with:
submodules: false
lfs: false
# Set up committer info and GPG key
- name: Import GPG key
if: github.event.pull_request.merged
id: import_gpg
uses: XLabsProject/ghaction-import-gpg@25d9d6ab99eb355c169c33c2306a72df85d9f516
with:
git-commit-gpgsign: true
git-committer-email: "${{ secrets.XLABS_CI_EMAIL }}"
git-committer-name: "${{ secrets.XLABS_CI_NAME }}"
git-push-gpgsign: false
git-tag-gpgsign: true
git-user-signingkey: true
gpg-private-key: ${{ secrets.XLABS_CI_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.XLABS_CI_GPG_PASSWORD }}
- name: Extract version from pull request
if: github.event.pull_request.merged
id: extract_version
run: |
title="${{ github.event.pull_request.title }}"
version="${title#Release }"
echo "::set-output name=version::$version"
- name: Create annotated tag
if: github.event.pull_request.merged
run: |
git tag -a -m "${{ github.event.pull_request.title }}" \
"${{ steps.extract_version.outputs.version }}" \
"${{ github.event.pull_request.merge_commit_sha }}"
git push origin --tags
- name: Create Pull Request
uses: repo-sync/pull-request@v2
with:
github_token: ${{ secrets.XLABS_CI_GITHUB_TOKEN }}
source_branch: "master"
destination_branch: "develop"
pr_body: |
This Pull Request merges the release of X Labs Launcher ${{ steps.extract_version.outputs.version }} and was [automatically created by a workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) triggered by @${{ github.actor }}.
pr_title: Merge release ${{ steps.extract_version.outputs.version }}
pr_label: release
notify:
name: Notify Discord
runs-on: ubuntu-latest
if: |
github.repository_owner == 'XLabsProject' && (
(
github.event.pull_request.merged
) || (
github.event.push.ref == 'refs/heads/master' ||
github.event.push.ref == 'refs/heads/develop'
)
)
steps:
- name: Post CI status notification to Discord
uses: sarisia/actions-status-discord@v1.7.1
if: always()
with:
webhook: ${{ secrets.DISCORD_CI_BOT_WEBHOOK }}
title: "Build"

2
.gitmodules vendored
View File

@ -10,7 +10,7 @@
[submodule "deps/protobuf"]
path = deps/protobuf
url = https://github.com/google/protobuf.git
branch = 3.15.x
branch = 3.17.x
[submodule "deps/minhook"]
path = deps/minhook
url = https://github.com/TsudaKageyu/minhook.git

2
deps/GSL vendored

@ -1 +1 @@
Subproject commit c1cbb41b428f15e53454682a45f03ea31f1da0a7
Subproject commit 8a4b9ed0bf643726ce625678a17b1fc40d90870c

2
deps/asmjit vendored

@ -1 +1 @@
Subproject commit 8ee4c76ee3bf4c33478347caefc5d4f7f0e97992
Subproject commit d02235b83434943b52a6d7c57118205c5082de08

2
deps/libtomcrypt vendored

@ -1 +1 @@
Subproject commit 165c795b65e3281040be2edc41be38cf3536d8cd
Subproject commit 673f5ce29015a9bba3c96792920a10601b5b0718

2
deps/lua vendored

@ -1 +1 @@
Subproject commit 681297187ec45268e872b26753c441586c12bdd8
Subproject commit dbdc74dc5502c2e05e1c1e2ac894943f418c8431

2
deps/minhook vendored

@ -1 +1 @@
Subproject commit 423d1e45af2ed2719a5c31e990e935ef301ed9c3
Subproject commit 6ffd0190232c670fa08e01dd4f2907ee5785a335

2
deps/protobuf vendored

@ -1 +1 @@
Subproject commit 436bd7880e458532901c58f4d9d1ea23fa7edd52
Subproject commit 70db61a91bae270dca5db2f9837deea11118b148

2
deps/rapidjson vendored

@ -1 +1 @@
Subproject commit 17aa824c928ea111e9b12a61e06d98335ce98f15
Subproject commit 48fbd8cd202ca54031fe799db2ad44ffa8e77c13

2
deps/sol2 vendored

@ -1 +1 @@
Subproject commit 430b55a49609daacea6fd3ee2c9d137db4db9c83
Subproject commit bb5f60e138191bb5838ffbd9d458701ff3b05552

2
deps/stb vendored

@ -1 +1 @@
Subproject commit c9064e317699d2e495f36ba4f9ac037e88ee371a
Subproject commit 8e51be04dc7dcee462e1f09e410faceab52cc6d2

2
deps/zlib vendored

@ -1 +1 @@
Subproject commit 53ce2713117ef2a8ed682d77b944df991c499252
Subproject commit c3f3043f7aa80750245f8166a338c4877020b589

View File

@ -12,6 +12,7 @@
#include <utils/cryptography.hpp>
#include "game/game.hpp"
#include "steam/steam.hpp"
namespace auth
{
@ -218,6 +219,11 @@ namespace auth
utils::hook::jump(0x1404421F6, get_direct_connect_stub(), true);
utils::hook::call(0x140208C54, send_connect_data_stub);
}
command::add("guid", []()
{
printf("Your guid: %llX\n", steam::SteamUser()->GetSteamID().bits);
});
}
};
}

View File

@ -3,6 +3,11 @@
#include "scheduler.hpp"
#include "game/game.hpp"
#include "console.hpp"
#include "command.hpp"
#include "network.hpp"
#include "party.hpp"
#include <utils/string.hpp>
#include <discord_rpc.h>
@ -48,25 +53,24 @@ namespace discord
discord_presence.details = utils::string::va("%s on %s", gametype, map);
// get server host name
auto* const host_name = reinterpret_cast<char*>(0x141646CC4);
utils::string::strip(host_name, host_name, static_cast<int>(strlen(host_name)) + 1);
if (!strcmp(host_name, "key"))
// get number of clients in game
auto clients = reinterpret_cast<int*>(0x1414CC290);
int clientsNum = *clients;
discord_presence.partySize = clientsNum;
if (game::Dvar_FindVar("name") && !strcmp(host_name, game::Dvar_FindVar("name")->current.string)) // host_name == name, most likely private match
{
discord_presence.state = game::Dvar_FindVar("sv_hostname")->current.string;
discord_presence.state = "Private Match";
discord_presence.partyMax = game::Dvar_FindVar("sv_maxclients")->current.integer;
}
else
else
{
discord_presence.state = host_name;
}
dvar = game::Dvar_FindVar("sv_maxclients");
if (dvar)
{
auto clients = reinterpret_cast<int*>(0x1414CC290);
int clientsNum = *clients;
discord_presence.partySize = clientsNum;
discord_presence.partyMax = dvar->current.integer;
discord_presence.partyMax = party::server_client_count();
}
if (!discord_presence.startTimestamp)
@ -76,7 +80,7 @@ namespace discord
}
discord_presence.largeImageKey = game::Dvar_FindVar("ui_mapname")->current.string;
discord_presence.largeImageText = game::UI_GetGameTypeDisplayName(game::Dvar_FindVar("ui_mapname")->current.string);
discord_presence.largeImageText = game::UI_GetMapDisplayName(game::Dvar_FindVar("ui_mapname")->current.string);
}
Discord_UpdatePresence(&discord_presence);
@ -107,7 +111,7 @@ namespace discord
scheduler::once([]()
{
scheduler::once(update_discord, scheduler::pipeline::async);
scheduler::loop(update_discord, scheduler::pipeline::async, 20s);
scheduler::loop(update_discord, scheduler::pipeline::async, 15s);
}, scheduler::pipeline::main);
initialized_ = true;
@ -132,12 +136,14 @@ namespace discord
discord_presence.instance = 1;
console::info("Discord: Ready\n");
Discord_UpdatePresence(&discord_presence);
}
static void errored(const int error_code, const char* message)
{
printf("Discord: (%i) %s", error_code, message);
console::error("Discord: Error (%i): %s\n", error_code, message);
}
};
}

View File

@ -71,10 +71,10 @@ namespace exception
bool is_recoverable()
{
return is_game_thread()
return is_initialized()
&& is_game_thread()
&& !is_exception_interval_too_short()
&& !too_many_exceptions_occured()
&& is_initialized();
&& !too_many_exceptions_occured();
}
void show_mouse_cursor()

View File

@ -59,9 +59,9 @@ namespace game_module
DWORD __stdcall get_module_file_name_a(HMODULE hmodule, const LPSTR filename, const DWORD size)
{
if (!hmodule || utils::nt::library(hmodule) == get_game_module())
if (!hmodule)
{
hmodule = get_host_module();
hmodule = get_game_module();
}
return file_name_a_hook.invoke<DWORD>(hmodule, filename, size);

View File

@ -3,7 +3,6 @@
#include "game/game.hpp"
#include "images.hpp"
#include "console.hpp"
#include "scheduler.hpp"
#include <utils/hook.hpp>
#include <utils/string.hpp>
@ -18,7 +17,7 @@ namespace images
utils::hook::detour load_texture_hook;
utils::hook::detour setup_texture_hook;
utils::concurrency::container<std::unordered_map<std::string, std::string>> overriden_textures;
static_assert(sizeof(game::GfxImage) == 104);
static_assert(offsetof(game::GfxImage, name) == (sizeof(game::GfxImage) - sizeof(void*)));
static_assert(offsetof(game::GfxImage, pixelData) == 56);
@ -37,7 +36,7 @@ namespace images
data = i->second;
}
});
if (data.empty() && !utils::io::read_file(utils::string::va("s1x/images/%s.png", image->name), &data))
{
return {};
@ -45,7 +44,7 @@ namespace images
return {std::move(data)};
}
std::optional<utils::image> load_raw_image_from_file(game::GfxImage* image)
{
const auto image_file = load_image(image);
@ -73,8 +72,8 @@ namespace images
data.SysMemSlicePitch = data.SysMemPitch * raw_image->get_height();
data.pSysMem = raw_image->get_buffer();
game::Image_Setup(image, raw_image->get_width(), raw_image->get_height(), image->depth, image->numElements, image->imageFormat,
DXGI_FORMAT_R8G8B8A8_UNORM, image->name, &data);
game::Image_Setup(image, raw_image->get_width(), raw_image->get_height(), image->depth, image->numElements,
image->imageFormat, DXGI_FORMAT_R8G8B8A8_UNORM, image->name, &data);
return true;
}
@ -92,7 +91,7 @@ namespace images
return;
}
}
catch(std::exception& e)
catch (std::exception& e)
{
console::error("Failed to load image %s: %s\n", image->name, e.what());
}
@ -102,7 +101,7 @@ namespace images
int setup_texture_stub(game::GfxImage* image, void* a2, void* a3)
{
if(image->resourceSize == -1)
if (image->resourceSize == -1)
{
return 0;
}

View File

@ -17,6 +17,9 @@ namespace lui
{
if (!game::environment::is_mp()) return;
// Don't show create cod account popup
utils::hook::set<uint32_t>(0x1400EAD12, 0);
#ifdef _DEBUG
// Enable development menus (causes issues in sp)
utils::hook::set<uint32_t>(SELECT_VALUE(0x1400B4ABC, 0x140109FAC), 1);

View File

@ -26,6 +26,7 @@ namespace party
} connect_state;
std::string sv_motd;
int sv_maxclients;
void perform_game_initialization()
{
@ -273,6 +274,11 @@ namespace party
}
}
int server_client_count()
{
return party::sv_maxclients;
}
class component final : public component_interface
{
public:
@ -595,6 +601,7 @@ namespace party
}
party::sv_motd = info.get("sv_motd");
party::sv_maxclients = std::stoi(info.get("sv_maxclients"));
connect_to_party(target, mapname, gametype);
});

View File

@ -8,6 +8,8 @@ namespace party
void connect(const game::netadr_s& target);
void start_map(const std::string& mapname);
int server_client_count();
int get_client_num_by_name(const std::string& name);
int get_client_count();

View File

@ -1,5 +1,6 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "game_module.hpp"
#include <utils/nt.hpp>
#include <utils/string.hpp>
@ -9,7 +10,7 @@ namespace redirect
{
void launch_complementary_game(const bool singleplayer, const std::string& mode = "")
{
const utils::nt::library self;
const auto self = game_module::get_host_module();
STARTUPINFOA startup_info;
PROCESS_INFORMATION process_info;

View File

@ -1,6 +1,7 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "game/game.hpp"
#include "game_module.hpp"
#include <utils/nt.hpp>
#include <utils/hook.hpp>
@ -78,7 +79,7 @@ namespace splash
{
WNDCLASSA wnd_class;
const utils::nt::library self;
const auto self = game_module::get_host_module();
wnd_class.style = CS_DROPSHADOW;
wnd_class.cbClsExtra = 0;

View File

@ -63,6 +63,15 @@ namespace system_check
return verify_hashes(mp_zone_hashes) && (game::environment::is_dedi() || verify_hashes(sp_zone_hashes));
}
void verify_binary_version()
{
const auto value = *reinterpret_cast<DWORD*>(0x140001337);
if (value != 0x24AFEB05 && value != 0x1D860F04)
{
throw std::runtime_error("Unsupported Call of Duty: Advanced Warfare version");
}
}
}
bool is_valid()
@ -76,6 +85,8 @@ namespace system_check
public:
void post_load() override
{
verify_binary_version();
if (!is_valid())
{
MessageBoxA(nullptr, "Your game files are outdated or unsupported.\n"

View File

@ -98,5 +98,5 @@ namespace updater
}
#if defined(CI) && !defined(DEBUG)
REGISTER_COMPONENT(updater::component)
//REGISTER_COMPONENT(updater::component)
#endif

View File

@ -18,7 +18,7 @@ namespace demonware
this->register_task(12, &bdStorage::get_user_file);
this->register_task(13, &bdStorage::unk13);
this->map_publisher_resource_variant("motd-.*\\.txt", motd::get_text);
this->map_publisher_resource_variant(".*\\motd-.*\\.txt", motd::get_text);
this->map_publisher_resource("ffotd-.*\\.ff", DW_FASTFILE);
this->map_publisher_resource("playlists(_.+)?\\.aggr", DW_PLAYLISTS);
this->map_publisher_resource("social_[Tt][Uu][0-9]+\\.cfg", DW_SOCIAL_CONFIG);

View File

@ -36,7 +36,13 @@ FARPROC loader::load_library(const std::string& filename) const
const auto target = utils::nt::library::load(filename);
if (!target)
{
throw std::runtime_error("Failed to map binary!");
throw std::runtime_error{"Failed to map binary!"};
}
const auto base = size_t(target.get_ptr());
if(base != 0x140000000)
{
throw std::runtime_error{utils::string::va("Binary was mapped at 0x%llX (instead of 0x%llX). Something is severely broken :(", base, 0x140000000)};
}
this->load_imports(target, target);
@ -188,7 +194,7 @@ void loader::load_tls(const utils::nt::library& target, const utils::nt::library
const auto tls_size = source_tls->EndAddressOfRawData - source_tls->StartAddressOfRawData;
const auto tls_index = *reinterpret_cast<DWORD*>(target_tls->AddressOfIndex);
*reinterpret_cast<DWORD*>(source_tls->AddressOfIndex) = tls_index;
utils::hook::set<DWORD>(source_tls->AddressOfIndex, tls_index);
DWORD old_protect;
VirtualProtect(PVOID(target_tls->StartAddressOfRawData),

View File

@ -122,15 +122,6 @@ void remove_crash_file()
utils::io::remove_file("__s1Exe");
}
void verify_aw_version()
{
const auto value = *reinterpret_cast<DWORD*>(0x140001337);
if (value != 0x24AFEB05 && value != 0x1D860F04)
{
throw std::runtime_error("Unsupported Call of Duty: Advanced Warfare version");
}
}
void enable_dpi_awareness()
{
const utils::nt::library user32{"user32.dll"};
@ -169,6 +160,25 @@ void limit_parallel_dll_loading()
RegCloseKey(key);
}
void apply_environment()
{
char* buffer{};
size_t size{};
if (_dupenv_s(&buffer, &size, "XLABS_AW_INSTALL") != 0 || buffer == nullptr)
{
throw std::runtime_error("Please use the X Labs launcher to run the game!");
}
const auto _ = gsl::finally([&]
{
free(buffer);
});
std::string dir{buffer, size};
SetCurrentDirectoryA(dir.data());
SetDllDirectoryA(dir.data());
}
int main()
{
FARPROC entry_point;
@ -193,6 +203,8 @@ int main()
try
{
apply_environment();
if (!component_loader::post_start()) return 0;
auto mode = detect_mode_from_arguments();
@ -211,8 +223,6 @@ int main()
throw std::runtime_error("Unable to load binary into memory");
}
verify_aw_version();
if (!component_loader::post_load()) return 0;
premature_shutdown = false;

View File

@ -19,10 +19,11 @@ namespace utils
return path;
}
std::string write_exitisting_temp_file(const std::string& file, const std::string& data)
std::string write_exitisting_temp_file(const std::string& file, const std::string& data,
const bool fatal_if_overwrite_fails)
{
const auto temp = get_temp_folder();
const auto file_path = temp + file;
auto file_path = temp + file;
std::string current_data;
if (!io::read_file(file_path, &current_data))
@ -35,7 +36,7 @@ namespace utils
return file_path;
}
if (current_data == data || io::write_file(file_path, data))
if (current_data == data || io::write_file(file_path, data) || !fatal_if_overwrite_fails)
{
return file_path;
}
@ -57,11 +58,11 @@ namespace utils
}
}
std::string binary_resource::get_extracted_file()
std::string binary_resource::get_extracted_file(const bool fatal_if_overwrite_fails)
{
if (this->path_.empty())
{
this->path_ = write_exitisting_temp_file(this->filename_, this->resource_);
this->path_ = write_exitisting_temp_file(this->filename_, this->resource_, fatal_if_overwrite_fails);
}
return this->path_;

View File

@ -9,7 +9,7 @@ namespace utils
public:
binary_resource(int id, std::string file);
std::string get_extracted_file();
std::string get_extracted_file(bool fatal_if_overwrite_fails = false);
const std::string& get_data() const;
private:

Binary file not shown.