Skip to content

Commit

Permalink
update to 1.0.3-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
x87 committed Oct 23, 2022
1 parent c3add22 commit 50b44b0
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 42 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
### 1.0.3-dev

- add support for the latest Trilogy patch 1.04.5

**SDK AND PLUGINS**

- new SDK methods `GetDirectoryPath`, `GetCLEOVersion`, `GetSymbolAddress`, `GetNumberOfActiveCSScripts`, `GetNumberOfActiveJSScripts`. SDK version is now 6.
- code that displays a CLEO version in the main menu was extracted into a separate plugin - `frontend.cleo`. Works with GTA III, VC, re3, reVC, and SA.

**BREAKING CHANGES**

- bumped minimum required versions of [command definitions](https://re.cleo.li/docs/en/definitions.html)

### 1.0.2 - September 9, 2022

- add JavaScript support in 64-bit versions of re3 and reVC (see [Feature Matrix](https://github.com/cleolibrary/CLEO-Redux/wiki/Feature-Support-Matrix/) for details)
Expand Down
Binary file modified SDK/cleo_redux.lib
Binary file not shown.
Binary file modified SDK/cleo_redux64.lib
Binary file not shown.
32 changes: 32 additions & 0 deletions SDK/cleo_redux_sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ enum class HostId
UNKNOWN = 255
};

enum class Directory
{
// /CLEO directory
CLEO = 0,
// /CLEO/.config
CONFIG = 1,
// /CLEO/CLEO_TEXT
TEXT = 2,
// /CLEO/CLEO_PLUGINS
PLUGINS = 3,
// Current working directory
CWD = 4,
// Host root directory
HOST = 5,
};

typedef void* Context;
typedef intptr_t isize;

Expand All @@ -52,6 +68,7 @@ extern "C" {
void ResolvePath(const char* src, char* dest);
// since v1
// Returns the absolute path to the CLEO directory
// deprecated: use GetDirectoryPath
void GetCLEOFolder(char* dest);
// since v1
// Returns the absolute path to the current working directory (normally the game directory)
Expand Down Expand Up @@ -116,5 +133,20 @@ extern "C" {
// since v5
// Registers a new callback invoked on a ShowTextBox function call. Providing a callback shadows built-in ShowTextBox implementation.
void OnShowTextBox(OnShowTextBoxCallback callback);
/// since v6
/// Returns the absolute path to the CLEO root directory or one of its sub-directories
void GetDirectoryPath(Directory dir, char* dest);
/// since v6
/// Returns CLEO Redux version as a string
void GetCLEOVersion(char* dest);
/// since v6
/// Returns a memory address for the given symbol, or 0 if not found
void* GetSymbolAddress(const char* symbol);
/// since v6
/// Returns number of active CS scripts
size_t GetNumberOfActiveCSScripts();
/// since v6
/// Returns number of active JS scripts
size_t GetNumberOfActiveJSScripts();
}

93 changes: 89 additions & 4 deletions SDK/cleo_redux_sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub const SDK_STRING_MAX_LEN: usize = 128;

#[allow(non_camel_case_types)]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub enum HandlerResult {
/// Proceed to the next command
CONTINUE = 0,
Expand All @@ -15,6 +16,7 @@ pub enum HandlerResult {

#[allow(non_camel_case_types)]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub enum HostId {
RE3 = 1,
REVC = 2,
Expand All @@ -30,6 +32,24 @@ pub enum HostId {
UNKNOWN = 255,
}

#[allow(non_camel_case_types)]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub enum Directory {
/// /CLEO directory
CLEO = 0,
/// /CLEO/.config
CONFIG = 1,
/// /CLEO/CLEO_TEXT
TEXT = 2,
/// /CLEO/CLEO_PLUGINS
PLUGINS = 3,
/// Current working directory
CWD = 4,
/// Host root directory
HOST = 5,
}

#[allow(non_camel_case_types)]
pub type c_char = i8;
#[allow(non_camel_case_types)]
Expand Down Expand Up @@ -65,6 +85,7 @@ extern "C" {
/// Returns the absolute path to the CLEO directory
///
/// since v1
/// deprecated: use GetDirectoryPath
fn GetCLEOFolder(dest: *mut c_char);
/// Returns the absolute path to the current working directory (normally the game directory)
///
Expand Down Expand Up @@ -150,6 +171,26 @@ extern "C" {
///
/// since v5
fn OnShowTextBox(cb: OnShowTextBoxCallback);
/// Returns the absolute path to the CLEO root directory or one of its sub-directories
///
/// since v6
fn GetDirectoryPath(dir: Directory, dest: *mut c_char);
/// Returns CLEO Redux version as a string
///
/// since v6
fn GetCLEOVersion(dest: *mut c_char);
/// Returns a memory address for the given symbol, or 0 if not found
///
/// since v6
fn GetSymbolAddress(symbol: *const c_char) -> usize;
/// Returns number of active CS scripts
///
/// since v6
fn GetNumberOfActiveCSScripts() -> usize;
/// Returns number of active JS scripts
///
/// since v6
fn GetNumberOfActiveJSScripts() -> usize;
}

macro_rules! sz {
Expand Down Expand Up @@ -225,10 +266,10 @@ pub fn set_int_param(ctx: Context, value: isize) {
/// Returns the absolute path to the CLEO directory
///
/// since v1
///
/// deprecated: use get_directory_path()
pub fn get_cleo_folder() -> std::path::PathBuf {
let mut buf = [0i8; 256];
unsafe { GetCLEOFolder(buf.as_mut_ptr()) };
std::path::Path::new(&to_rust_string(buf.as_ptr())).into()
get_directory_path(Directory::CLEO)
}

/// Returns the absolute path to the current working directory (normally the game directory)
Expand Down Expand Up @@ -380,4 +421,48 @@ pub fn on_show_text_box(cb: OnShowTextBoxCallback) {
unsafe {
OnShowTextBox(cb);
}
}
}

/// Returns the absolute path to the CLEO root directory or one of its sub-directories
///
/// since v6
#[allow(dead_code)]
pub fn get_directory_path(dir: Directory) -> std::path::PathBuf {
let mut buf = [0i8; 256];
unsafe { GetDirectoryPath(dir, buf.as_mut_ptr()) };
std::path::Path::new(&to_rust_string(buf.as_ptr())).into()
}

/// Returns CLEO Redux version as a string
///
/// since v6
#[allow(dead_code)]
pub fn get_cleo_version() -> String {
let mut buf = [0i8; 256];
unsafe { GetCLEOVersion(buf.as_mut_ptr()) };
to_rust_string(buf.as_ptr())
}

/// Returns a memory address for the given symbol, or 0 if not found
///
/// since v6
#[allow(dead_code)]
pub fn get_symbol_address(symbol: &str) -> usize {
unsafe { GetSymbolAddress(sz!(symbol)) }
}

/// Get number of active CS scripts
///
/// since v6
#[allow(dead_code)]
pub fn get_number_of_active_cs_scripts() -> usize {
unsafe { GetNumberOfActiveCSScripts() }
}

/// Get number of active JS scripts
///
/// since v6
#[allow(dead_code)]
pub fn get_number_of_active_js_scripts() -> usize {
unsafe { GetNumberOfActiveJSScripts() }
}
4 changes: 2 additions & 2 deletions docs/en/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CLEO Redux exposes some of the configurable settings in the file `CLEO\.config\c
- `AllowCs` - when set to `1` CLEO loads and executes `*.cs` files located in the [CLEO directory](./cleo-directory.md). Enabled by default.
- `AllowJs` - when set to `1` CLEO loads and executes `*.js` files located in the [CLEO directory](./cleo-directory.md). Enabled by default.
- `AllowFxt` - when set to `1` CLEO loads and [uses](./using-fxt.md) `*.fxt` files located in the CLEO\CLEO_TEXT directory. Enabled by default.
- `CheckUpdates` - when set to `1` CLEO check if there is a new update available for download during the game startup. Disabled by default.
- `CheckUpdates` - (deprecated in favor of [Frontend](./installation-plugins.md) plugin)
- `LogOpcodes` - when set to `1` CLEO [logs](./log.md) all executed opcodes in custom scripts.
- `DisplayMenuInfo` - when set to `1` CLEO displays some information in the main menu. Enabled by default.
- `PermissionLevel` - sets the [permission level](./permissions.md) for unsafe operations (see below). Default is `Lax`.
Expand All @@ -19,4 +19,4 @@ CLEO Redux exposes some of the configurable settings in the file `CLEO\.config\c

## Permissions

This section lists permission tokens and sets whether they are allowed or not in the [Strict mode](./permissions.md#strict).
This section lists permission tokens and sets whether they are allowed or not in the [Strict mode](./permissions.md#strict).
14 changes: 7 additions & 7 deletions docs/en/definitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ At start CLEO validates that a definition file is present and correct and if not

| Game | File | Minimum Required Version |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------ |
| GTA III, re3 | [gta3.json](https://github.com/sannybuilder/library/blob/master/gta3/gta3.json) | `0.237` |
| GTA VC, reVC | [vc.json](https://github.com/sannybuilder/library/blob/master/vc/vc.json) | `0.242` |
| GTA San Andreas (Classic) 1.0 | [sa.json](https://github.com/sannybuilder/library/blob/master/sa/sa.json) | `0.271` |
| GTA IV | [gta_iv.json](https://github.com/sannybuilder/library/blob/master/gta_iv/gta_iv.json) | `0.41` |
| GTA III: The Definitive Edition | [gta3_unreal.json](https://github.com/sannybuilder/library/blob/master/gta3_unreal/gta3_unreal.json) | `0.217` |
| Vice City: The Definitive Edition | [vc_unreal.json](https://github.com/sannybuilder/library/blob/master/vc_unreal/vc_unreal.json) | `0.223` |
| San Andreas: The Definitive Edition | [sa_unreal.json](https://github.com/sannybuilder/library/blob/master/sa_unreal/sa_unreal.json) | `0.235` |
| GTA III, re3 | [gta3.json](https://github.com/sannybuilder/library/blob/master/gta3/gta3.json) | `0.241` |
| GTA VC, reVC | [vc.json](https://github.com/sannybuilder/library/blob/master/vc/vc.json) | `0.248` |
| GTA San Andreas (Classic) 1.0 | [sa.json](https://github.com/sannybuilder/library/blob/master/sa/sa.json) | `0.286` |
| GTA IV | [gta_iv.json](https://github.com/sannybuilder/library/blob/master/gta_iv/gta_iv.json) | `0.43` |
| GTA III: The Definitive Edition | [gta3_unreal.json](https://github.com/sannybuilder/library/blob/master/gta3_unreal/gta3_unreal.json) | `0.220` |
| Vice City: The Definitive Edition | [vc_unreal.json](https://github.com/sannybuilder/library/blob/master/vc_unreal/vc_unreal.json) | `0.227` |
| San Andreas: The Definitive Edition | [sa_unreal.json](https://github.com/sannybuilder/library/blob/master/sa_unreal/sa_unreal.json) | `0.248` |
| Bully: Scholarship Edition | [bully.json](https://github.com/sannybuilder/library/blob/master/bully/bully.json) | `0.29` |
| Unknown (32-bit) | [unknown_x86.json](https://github.com/sannybuilder/library/blob/master/unknown_x86/unknown_x86.json) | `0.216` |
| Unknown (64-bit) | [unknown_x64.json](https://github.com/sannybuilder/library/blob/master/unknown_x64/unknown_x64.json) | `0.220` |
Expand Down
19 changes: 10 additions & 9 deletions docs/en/installation-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ Plugins are optional programs adding extra scripting commands with the help of [

## List of plugins

| Name | Description | Link |
| ------------------------------------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------- |
| [IniFiles](https://library.sannybuilder.com/#/unknown_x86/ini) | Reading from and writing to INI files | [src](https://github.com/cleolibrary/CLEO-Redux/tree/master/plugins/IniFiles) |
| [Dylib](https://library.sannybuilder.com/#/unknown_x86/dylib) | Loading DLL files and importing functions | [src](https://github.com/cleolibrary/CLEO-Redux/tree/master/plugins/Dylib) |
| [Input](https://library.sannybuilder.com/#/unknown_x86/input) | Checking for keyboard and mouse input, emulating key presses | [src](https://github.com/cleolibrary/CLEO-Redux/tree/master/plugins/Input) |
| [ImGuiRedux](https://library.sannybuilder.com/#/unknown_x86/imgui) | Dear ImGui bindings | [GitHub repo](https://github.com/user-grinch/ImGuiRedux) |
| [MemoryOperations](https://library.sannybuilder.com/#/unknown_x86/memops) | Low-level memory operations | [GitHub repo](https://github.com/cleolibrary/CLEO-REDUX-PLUGINS) |

Plugins are included in the CLEO Redux installer. You can opt out of some of them by unchecking the corresponding checkbox in the installer.
| Name | Description | Link |
| ------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| [IniFiles](https://library.sannybuilder.com/#/unknown_x86/ini) | Reading from and writing to INI files | [src](https://github.com/cleolibrary/CLEO-Redux/tree/master/plugins/IniFiles) |
| [Dylib](https://library.sannybuilder.com/#/unknown_x86/dylib) | Loading DLL files and importing functions | [src](https://github.com/cleolibrary/CLEO-Redux/tree/master/plugins/Dylib) |
| [Input](https://library.sannybuilder.com/#/unknown_x86/input) | Checking for keyboard and mouse input, emulating key presses | [src](https://github.com/cleolibrary/CLEO-Redux/tree/master/plugins/Input) |
| [ImGuiRedux](https://library.sannybuilder.com/#/unknown_x86/imgui) | Dear ImGui bindings | [GitHub repo](https://github.com/user-grinch/ImGuiRedux) |
| [MemoryOperations](https://library.sannybuilder.com/#/unknown_x86/memops) | Low-level memory operations | [GitHub repo](https://github.com/cleolibrary/CLEO-REDUX-PLUGINS) |
| Frontend | Checks the latest version on GitHub and display information in the main menu | |

Plugins are included in the CLEO Redux installer. You can opt out of some of them by unchecking the corresponding checkbox in the installer.
29 changes: 15 additions & 14 deletions docs/en/the-definitive-edition-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ Here you can find answers to the frequently asked questions about support for Th

### What versions are supported?

- GTA III: The Definitive Edition **1.0.0.14718** (Title Update 1.03), **1.0.0.15284** (Title Update 1.04)
- GTA Vice City: The Definitive Edition **1.0.0.14718** (Title Update 1.03), **1.0.0.15399** (Title Update 1.04)
- San Andreas: The Definitive Edition **1.0.0.14296**, **1.0.0.14388**, **1.0.0.14718** (Title Update 1.03), **1.0.0.15483** (Title Update 1.04)
- GTA III: The Definitive Edition **1.0.0.14718** (Title Update 1.03), **1.0.0.15284** (Title Update 1.04), **1.0.8.11827** (Title Update 1.04.5)
- GTA Vice City: The Definitive Edition **1.0.0.14718** (Title Update 1.03), **1.0.0.15399** (Title Update 1.04), **1.0.8.11827** (Title Update 1.04.5)
- San Andreas: The Definitive Edition **1.0.0.14296**, **1.0.0.14388**, **1.0.0.14718** (Title Update 1.03), **1.0.0.15483** (Title Update 1.04), **1.0.8.11827** (Title Update 1.04.5)

### Is there any difference from support of the classic games?

In short, yes. [See this page](https://github.com/cleolibrary/CLEO-Redux/wiki/Feature-Support-Matrix) for detail on what's supported and what's not.

### Can I use original opcodes?

Yes, you can. Refer to the Sanny Builder library https://library.sannybuilder.com/#/sa_unreal. Take a note that some opcodes have been changed from the classic games, so don't expect everything to work like it was in classic. If you run into an issue, find help in [our Discord](https://discord.gg/d5dZSfgBZr).

### How do I know what commands can I use in JavaScript?

After each game run, CLEO generates a d.ts file in the CLEO\.config directory. It's called gta3.d.ts, vc.d.ts or sa.d.ts depending on the game. This file lists all supported functions and methods that you can use in JavaScript code.
After each game run, CLEO generates a d.ts file in the CLEO\.config directory. It's called gta3.d.ts, vc.d.ts or sa.d.ts depending on the game. This file lists all supported functions and methods that you can use in JavaScript code.

To enable autocomplete in VS Code include the following line in your JS script:

Expand All @@ -38,16 +39,16 @@ Update the file name accordingly depending on which game your script is for.

Opcodes from CLEO Library (CLEO 4 or CLEO for GTA III and Vice City) are not supported. But CLEO Redux adds its own new opcodes for some operations.

- 0C00 [IS_KEY_PRESSED](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C00)
- 0C01 [INT_ADD](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C01)
- 0C02 [INT_SUB](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C02)
- 0C03 [INT_MUL](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C03)
- 0C04 [INT_DIV](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C04)
- 0C05 [TERMINATE_THIS_CUSTOM_SCRIPT](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C05)
- 0C06 [WRITE_MEMORY](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C06) (**UNSAFE** - requires `mem` permission)
- 0C07 [READ_MEMORY](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C07) (**UNSAFE** - requires `mem` permission)
- 0C08 [CALL_FUNCTION](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C08) (**UNSAFE** - requires `mem` permission)
- 0C09 [CALL_FUNCTION_RETURN](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C09) (**UNSAFE** - requires `mem` permission)
- 0C00 [IS_KEY_PRESSED](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C00)
- 0C01 [INT_ADD](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C01)
- 0C02 [INT_SUB](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C02)
- 0C03 [INT_MUL](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C03)
- 0C04 [INT_DIV](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C04)
- 0C05 [TERMINATE_THIS_CUSTOM_SCRIPT](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C05)
- 0C06 [WRITE_MEMORY](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C06) (**UNSAFE** - requires `mem` permission)
- 0C07 [READ_MEMORY](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C07) (**UNSAFE** - requires `mem` permission)
- 0C08 [CALL_FUNCTION](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C08) (**UNSAFE** - requires `mem` permission)
- 0C09 [CALL_FUNCTION_RETURN](https://library.sannybuilder.com/#/sa_unreal/CLEO/0C09) (**UNSAFE** - requires `mem` permission)

Note that Sanny Builder does not support these new opcodes out-of-the-box yet. To enable new opcodes in your CS scripts add the following lines on top of your script:

Expand Down
2 changes: 1 addition & 1 deletion docs/en/using-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SDK provides a way to create new script commands for any game that CLEO Redux su

## SDK Version

The current version is `5`. Changes to SDK advance this number by one.
The current version is `6`. Changes to SDK advance this number by one.


## Platforms Support
Expand Down
Loading

0 comments on commit 50b44b0

Please sign in to comment.