Skip to content

Commit

Permalink
Try to get the artifact stuff working!
Browse files Browse the repository at this point in the history
  • Loading branch information
netniV committed Feb 8, 2025
2 parents 79f005f + 202b078 commit 2e3395d
Show file tree
Hide file tree
Showing 41 changed files with 1,022 additions and 349 deletions.
42 changes: 23 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# Contributing

This project is entirely maintained in my own personal free time, and updated as and when that time
is available. Any help by submitting pull requests is greatly welcome and any donations or
sponsorships are greatly appreciated.

## Building

First clone and initialize the repository:

```bash
git clone https://github.com/tashcan/bob.git
git clone https://github.com/netniv/bob.git
cd bob
```

## Installing

Please note that when this project compiles, it will create a DLL called `stfc-community-patch.dll`. This
file must be either copied to the `C:\Games\Star Trek Fleet Command\Star Trek Fleet Command\default\game`
folder as `version.dll` or create a symbolic link to the file using an elevated (administrator) command
Please note that when this project compiles, it will create a DLL called `stfc-community-patch.dll`. This
file must be either copied to the `C:\Games\Star Trek Fleet Command\Star Trek Fleet Command\default\game`
folder as `version.dll` or create a symbolic link to the file using an elevated (administrator) command
prompt:

```console
Expand All @@ -33,18 +37,18 @@ You may see the following error, and this normally occurs if your SDK is below t
The <experimental/coroutine> and <experimental/resumable> headers are only supported with /await and implement pre-C++20 coroutine support. Use <coroutine> for standard C++20 coroutines
```

If you have Visual Studio 2022, make sure to have the Windows 11 SDK selected as a minimum, even if you
are running the Visual Studio IDE on Windows 10. The Windows 11 SDK will also create targets that work
If you have Visual Studio 2022, make sure to have the Windows 11 SDK selected as a minimum, even if you
are running the Visual Studio IDE on Windows 10. The Windows 11 SDK will also create targets that work
for Windows 10.

You can do this via the Visual Studio Installer. The Visual Studio Installer will show any other versions
of Visual Studio, so please make sure to use the `Modify` button on the correct one. You can launch the
Visual Studio Installer from within Visual Studio 2022 via the `Tools -> Get Tools and Features` menu
option, or through `Settings -> Apps -> Visual Studio -> Modify`.
You can do this via the Visual Studio Installer. The Visual Studio Installer will show any other versions
of Visual Studio, so please make sure to use the `Modify` button on the correct one. You can launch the
Visual Studio Installer from within Visual Studio 2022 via the `Tools -> Get Tools and Features` menu
option, or through `Settings -> Apps -> Visual Studio -> Modify`.

Once you are modifying the correct Visual Studio 2022 instance, select the `Individual Components` tab and
click into the Filter textbox. Enter the type `SDK` which should provided a minimal filtered list of SDK's
available. You should see Windows 11 SDK listed and has a tick. If not, please click the tick box and then
Once you are modifying the correct Visual Studio 2022 instance, select the `Individual Components` tab and
click into the Filter textbox. Enter the type `SDK` which should provided a minimal filtered list of SDK's
available. You should see Windows 11 SDK listed and has a tick. If not, please click the tick box and then
apply the changes to have the SDK downloaded and installed. This will take around 2-3GB of space.

#### Configure and building the project
Expand All @@ -59,22 +63,22 @@ xmake project -k vsxmake -m "debug,release"
You will now find a `bob.sln` file inside `vsxmake2022`(or similarly named). You can simply open that in `Visual Studio`
and Build the solution.

**IMPORTANT**: To reset the build, you can remove the `build/` folder and all items beneath it. Visual
**IMPORTANT**: To reset the build, you can remove the `build/` folder and all items beneath it. Visual
Studio will then rebuild the project.

**IMPORTANT**: To fully reset the project, also remove the `.vs/` folder.

### Visual Studio Code

If you want to use Visual Studio Code, you may still need to make sure the various SDK's and MSVC runtimes
If you want to use Visual Studio Code, you may still need to make sure the various SDK's and MSVC runtimes
are available.

Once they are installed, either standalone or via Visual Studio, you can open the `bob` folder inside
Visual Studio or by right clicking in a Windows Explorer via and selecting `Open with Visual Studio Code`.
When it first opens, it should ask you to install the XMake extension. Once the extensions are
Once they are installed, either standalone or via Visual Studio, you can open the `bob` folder inside
Visual Studio or by right clicking in a Windows Explorer via and selecting `Open with Visual Studio Code`.
When it first opens, it should ask you to install the XMake extension. Once the extensions are
installed, you can build the project by navigating to the XMake section in the Activity Bar and clicking `Build All` at the top.

**IMPORTANT**: To reset the build, you can remove the `build/` folder and all items beneath it. Visual
**IMPORTANT**: To reset the build, you can remove the `build/` folder and all items beneath it. Visual
Studio Code will then rebuild the project.

### Command Line
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<p align="center">
<img src="https://img.shields.io/badge/License-GPLv3-blue.svg" alt="License: GPLv3">
<img src="https://img.shields.io/github/sponsors/netniv" alt="Sponsorship">
</p>

<p align="center">
Expand All @@ -11,7 +12,7 @@
## Features

- Set system UI scale + adjustment factor
- Set viewer UI scale
- Set viewer UI scale
- Set system zoom
- default
- maximum
Expand Down Expand Up @@ -97,7 +98,7 @@ names:
- community_patch_settings.toml
- version.dll

The pre-compiled DLL can be downloaded from the official assets hosted on [GitHub Releases](https://github.com/tashcan/bob/releases)
The pre-compiled DLL can be downloaded from the official assets hosted on [GitHub Releases](https://github.com/netniv/bob/releases)

## Configuration

Expand Down Expand Up @@ -142,10 +143,10 @@ The most common problems getting the DLL to work are:

## Support

Tashcan has now retired all things STFC from [Ripper's Corner](https://discord.gg/gPuQ5sPYM9) but still swing by to say hello to the wonderful man.

For STFC Community Mod items, please visit the [STFC Community Mod](https://discord.gg/PrpHgs7Vjs) discord server.

Tashcan has now retired all things STFC from [Ripper's Corner](https://discord.gg/gPuQ5sPYM9) but still swing by to say hello to the wonderful man.

## Disclaimer

This is intended to give people insight and possiblity to add new things for QoL improvements.
Expand Down
3 changes: 0 additions & 3 deletions example_community_patch_settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ hotkeys_extended = true
use_scopely_hotkeys = false

[graphics]
# This is an option that can be enabled to try and keep a more 'useable' UI scale size when resizing the Game Window, defaults to false
adjust_scale_res = false

# Allow borderless full screen mode, set to false to disable
borderless_fullscreen_f11 = true

Expand Down
2 changes: 1 addition & 1 deletion macos-launcher/src/GitHubLib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

struct GitHubUpdater {
func latestPatchVersion() async -> Int {
let url = URL(string: "https://api.github.com/repos/tashcan/bob/releases/latest")!
let url = URL(string: "https://api.github.com/repos/netniv/bob/releases/latest")!
do {
let (data, _) = try await URLSession.shared.data(from: url)
let json = try JSONSerialization.jsonObject(with: data) as! [String: Any]
Expand Down
4 changes: 2 additions & 2 deletions mods/src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ void Config::Load()
this->ui_scale_viewer = get_config_or_default(config, parsed, "graphics", "ui_scale_viewer", 1.0f);
this->zoom = get_config_or_default(config, parsed, "graphics", "zoom", 2500.f);
this->free_resize = get_config_or_default(config, parsed, "graphics", "free_resize", true);
this->adjust_scale_res = get_config_or_default(config, parsed, "graphics", "adjust_scale_res", false);
this->keyboard_zoom_speed = get_config_or_default(config, parsed, "graphics", "keyboard_zoom_speed", 350.0f);

if (this->enable_experimental) {
Expand Down Expand Up @@ -564,6 +563,7 @@ void Config::Load()

parse_config_shortcut(config, parsed, "action_primary", GameFunction::ActionPrimary, "SPACE");
parse_config_shortcut(config, parsed, "action_secondary", GameFunction::ActionSecondary, "R");
parse_config_shortcut(config, parsed, "action_queue", GameFunction::ActionQueue, "V");
parse_config_shortcut(config, parsed, "action_view", GameFunction::ActionView, "V");
parse_config_shortcut(config, parsed, "action_recall", GameFunction::ActionRecall, "R");
parse_config_shortcut(config, parsed, "action_recall_cancel", GameFunction::ActionRecallCancel, "SPACE");
Expand Down Expand Up @@ -668,6 +668,6 @@ void Config::Load()
<< "Loaded beta version " << VERSION_MAJOR << "." << VERSION_MINOR << "." << VERSION_REVISION << " (Release)"
#endif

<< "\n\nPlease see https://github.com/tashcan/bob for latest configuration help, examples and future releases\n"
<< "\n\nPlease see https://github.com/netniv/bob for latest configuration help, examples and future releases\n"
<< "or visit the STFC Community Mod discord server at https://discord.gg/PrpHgs7Vjs\n\n";
}
22 changes: 22 additions & 0 deletions mods/src/errormsg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include <spdlog/spdlog.h>

class ErrorMsg
{
public:
static void MissingMethod(const char* classname, const char* methodname)
{
spdlog::error("Unable to find method '{}->{}'", classname, methodname);
}

static void MissingStaticMethod(const char* classname, const char* methodname)
{
spdlog::error("Unable to find method '{}::{}'", classname, methodname);
}

static void MissingHelper(const char* namespacename, const char* classname)
{
spdlog::error("Unable to find helper '{}.{}'", namespacename, classname);
}
};
4 changes: 4 additions & 0 deletions mods/src/il2cpp/il2cpp_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ class IL2CppClassHelper
return obj;
}

bool HasClass() {
return this->cls != nullptr;
}

template <typename T = void> T* GetMethod(const char* name, int arg_count = -1)
{
if (!this->cls) {
Expand Down
1 change: 1 addition & 0 deletions mods/src/patches/gamefunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ enum GameFunction {
UiViewerScaleDown,
ActionPrimary,
ActionSecondary,
ActionQueue,
ActionView,
ActionRecall,
ActionRecallCancel,
Expand Down
68 changes: 39 additions & 29 deletions mods/src/patches/parts/buff_fixes.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "config.h"
#include "errormsg.h"
#include "prime_types.h"

#include <il2cpp/il2cpp_helper.h>
Expand Down Expand Up @@ -101,37 +102,46 @@ bool FleetService_ResolveOfficerAbilityBuffs_Hook(auto original, int64_t _fleet)

void InstallBuffFixHooks()
{
auto screen_manager_helper =
auto buffhelper =
il2cpp_get_class_helper("Digit.Client.PrimeLib.Runtime", "Digit.PrimeServer.Services", "BuffService");
auto ptr = screen_manager_helper.GetMethod("IsBuffConditionMet");
if (!ptr) {
return;
}
SPUD_STATIC_DETOUR(ptr, BuffService_IsBuffConditionMet_Hook);
if (!buffhelper.HasClass()) {
ErrorMsg::MissingHelper("Services", "BuffService");
} else {
auto ptr = buffhelper.GetMethod("IsBuffConditionMet");
if (ptr == nullptr) {
ErrorMsg::MissingMethod("BuffServices", "IsBuffConditionMet");
} else {
SPUD_STATIC_DETOUR(ptr, BuffService_IsBuffConditionMet_Hook);
}

screen_manager_helper =
il2cpp_get_class_helper("Digit.Client.PrimeLib.Runtime", "Digit.PrimeServer.Services", "FleetService");
ptr = screen_manager_helper.GetMethod("ResolveOfficerAbilityBuffs");
if (!ptr) {
return;
ptr = buffhelper.GetMethodSpecial("ApplyBuffModifiersToCostVal", [](auto count, const Il2CppType **params) {
if (count != 2) {
return false;
}
auto p2 = params[1]->type;
if (p2 == IL2CPP_TYPE_VALUETYPE) {
return true;
}
return false;
});

if (ptr == nullptr) {
ErrorMsg::MissingMethod("BuffService", "ApplyBuffModifiersToCostVal");
} else {
SPUD_STATIC_DETOUR(ptr, BuffService_ApplyBuffModifiersToCostVal_1_Hook);
}
}
SPUD_STATIC_DETOUR(ptr, FleetService_ResolveOfficerAbilityBuffs_Hook);

screen_manager_helper =
il2cpp_get_class_helper("Digit.Client.PrimeLib.Runtime", "Digit.PrimeServer.Services", "BuffService");
ptr =
screen_manager_helper.GetMethodSpecial("ApplyBuffModifiersToCostVal", [](auto count, const Il2CppType **params) {
if (count != 2) {
return false;
}
auto p2 = params[1]->type;
if (p2 == IL2CPP_TYPE_VALUETYPE) {
return true;
}
return false;
});
if (!ptr) {
return;
auto fleethelper =
il2cpp_get_class_helper("Digit.Client.PrimeLib.Runtime", "Digit.PrimeServer.Services", "FleetService");
if (!fleethelper.HasClass()) {
ErrorMsg::MissingHelper("Services", "FleetService");
} else {
auto ptr = fleethelper.GetMethod("ResolveOfficerAbilityBuffs");
if (ptr == nullptr) {
ErrorMsg::MissingMethod("FleetService", "IsBuffConditionMet");
} else {
SPUD_STATIC_DETOUR(ptr, FleetService_ResolveOfficerAbilityBuffs_Hook);
}
}
SPUD_STATIC_DETOUR(ptr, BuffService_ApplyBuffModifiersToCostVal_1_Hook);
}
}
49 changes: 34 additions & 15 deletions mods/src/patches/parts/chat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "prime/GenericButtonContext.h"

#include "config.h"
#include "errormsg.h"

#include <spud/detour.h>

Expand Down Expand Up @@ -73,25 +74,43 @@ void InstallChatPatches()
{
static auto fullscreen_controller =
il2cpp_get_class_helper("Assembly-CSharp", "Digit.Prime.Chat", "FullScreenChatViewController");
auto ptr = fullscreen_controller.GetMethod("AboutToShow");
if (ptr) {
SPUD_STATIC_DETOUR(ptr, FullScreenChatViewController_AboutToShow);

if (!fullscreen_controller.HasClass()) {
ErrorMsg::MissingHelper("Chat", "FullScreenChatViewController");
} else {
auto ptr = fullscreen_controller.GetMethod("AboutToShow");
if (ptr == nullptr) {
ErrorMsg::MissingMethod("FullScreenChatViewController", "AboutToShow");
} else {
SPUD_STATIC_DETOUR(ptr, FullScreenChatViewController_AboutToShow);
}
}

static auto preview_controller =
il2cpp_get_class_helper("Assembly-CSharp", "Digit.Prime.Chat", "ChatPreviewController");
ptr = preview_controller.GetMethod("AboutToShow");
if (ptr) {
SPUD_STATIC_DETOUR(ptr, ChatPreviewController_AboutToShow);
}

ptr = preview_controller.GetMethod("OnPanel_Focused");
if (ptr) {
SPUD_STATIC_DETOUR(ptr, ChatPreviewController_OnPanel_Focused);
}
if (!preview_controller.HasClass()) {
ErrorMsg::MissingHelper("Chat", "ChatPreviewController");
} else {
auto ptr = preview_controller.GetMethod("AboutToShow");
if (ptr == nullptr) {
ErrorMsg::MissingMethod("ChatPreviewController", "AboutToShow");
} else {
SPUD_STATIC_DETOUR(ptr, ChatPreviewController_AboutToShow);
}

ptr = preview_controller.GetMethod("OnPanel_Focused");
if (ptr == nullptr) {
ErrorMsg::MissingMethod("ChatPreviewController", "OnPanel_Focused");
} else {
SPUD_STATIC_DETOUR(ptr, ChatPreviewController_OnPanel_Focused);
}

ptr = preview_controller.GetMethod("OnGlobalMessageReceived");
if (ptr) {
SPUD_STATIC_DETOUR(ptr, ChatPreviewController_OnGlobalMessageReceived);
ptr = preview_controller.GetMethod("OnGlobalMessageReceived");
if (ptr == nullptr) {
ErrorMsg::MissingMethod("ChatPreviewController", "OnGlobalMessageReceived");
} else {
SPUD_STATIC_DETOUR(ptr, ChatPreviewController_OnGlobalMessageReceived);
}
}
}
}
26 changes: 16 additions & 10 deletions mods/src/patches/parts/disable_banners.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "config.h"
#include "errormsg.h"

#include <il2cpp/il2cpp_helper.h>
#include <prime/Toast.h>
Expand Down Expand Up @@ -31,16 +32,21 @@ void ToastObserver_EnqueueOrCombineToast_Hook(auto original, ToastObserver *_thi
void InstallToastBannerHooks()
{
auto helper = il2cpp_get_class_helper("Assembly-CSharp", "Digit.Prime.HUD", "ToastObserver");
auto ptr = helper.GetMethod("EnqueueToast");
if (!ptr) {
return;
}
SPUD_STATIC_DETOUR(ptr, ToastObserver_EnqueueToast_Hook);
if (!helper.HasClass()) {
ErrorMsg::MissingHelper("HUD", "ToastObserver");
} else {
auto ptr = helper.GetMethod("EnqueueToast");
if (ptr == nullptr) {
ErrorMsg::MissingMethod("ToastObserver", "EnqueueTosat");
} else {
SPUD_STATIC_DETOUR(ptr, ToastObserver_EnqueueToast_Hook);
}

helper = il2cpp_get_class_helper("Assembly-CSharp", "Digit.Prime.HUD", "ToastObserver");
ptr = helper.GetMethod("EnqueueOrCombineToast");
if (!ptr) {
return;
ptr = helper.GetMethod("EnqueueOrCombineToast");
if (ptr == nullptr) {
ErrorMsg::MissingMethod("ToastObserver", "EnqueueOrCombineToast");
} else {
SPUD_STATIC_DETOUR(ptr, ToastObserver_EnqueueOrCombineToast_Hook);
}
}
SPUD_STATIC_DETOUR(ptr, ToastObserver_EnqueueOrCombineToast_Hook);
}
Loading

0 comments on commit 2e3395d

Please sign in to comment.