# Patch notes

## 1.20.0 - 06/08/2022

Support for patch **1.6**

### Added

* `TweakDB.CreateRecord`, `TweakDB.CloneRecord`, and `TweakDB.DeleteRecord` now support `TweakDBID` as a parameter type

```lua
-- Get the sticky frag grenade record
sticky_grenade = TweakDB:GetRecord("Items.GrenadeFragSticky")

-- Create a clone of "Items.GrenadeFragSticky" with the name "Items.GrenadeFragStickyNew"
TweakDB:CloneRecord(sticky_grenade:GetID() + "New", sticky_grenade:GetID())

-- Get the new record
sticky_grenade_new = TweakDB:GetRecord("Items.GrenadeFragStickyNew")
-- or
sticky_grenade_new = TweakDB:GetRecord(sticky_grenade:GetID() + "New")

-- manipulate the new record as needed

-- delete record many different ways
TweakDB:DeleteRecord(sticky_grenade_new:GetID())
TweakDB:DeleteRecord(sticky_grenade:GetID() + "New")
TweakDB:DeleteRecord("Items.GrenadeFragStickyNew")
```

### Changes and fixes

* Updated `usedhashes.kark` to the new URL
* Moved to OpenResty Lua JIT

## 1.19.**5** - 05/04/2022

Support for patch **1.52.1** (made up name, they didn't bother to name it AGAIN)

## 1.19.4 - 22/03/2022

Support for patch **1.52**

## 1.19.3 - 02/03/2022

### Changes and fixes

* Fix crash on Windows 7.
* Fix LoadTexture overwriting the previously loaded texture.

## 1.19.2 - 28/02/2022

Support for patch **1.5 hotfix 2**

### Added

* `ImGui.LoadTexture(string path)` returns a texture loaded from an image on disk in the mods' directory.
* `ImGui.Image(texture)` displays a texture loaded with the `LoadTexture` function.

  Full Api is as follows, note that you may omit parameters after texture and default values will be used `(Texture texture, ImVec2 size, ImVec2 uv0, ImVec2 uv1, ImVec4 tintColor, borderColor)`

### Changes and fixes

* Added stb to load images.
* Fixed bad screen skip fix.

## 1.19.1 - 19/02/2022

Support for patch **1.5 v2**

### Changes and fixes

* Changed the archive hashes to use the wolvenkit KARK files for TweakDB editing
* red4ext updated to 1.3.1

## 1.19.0 - 16/02/2022

Support for patch **1.5**

### Changes and fixes

* red4ext updated to 1.3.0
* mimalloc updated to 2.0.3
* sqlite3 updated to 3.37.0+200

Special thanks to WopsS, psiberx and Sombra for their help with this patch!

## 1.19.0-rc2 - 16/02/2022

### Known issues

* exEntitySpawner does not work.
* No pedestrian patch is not tested.

### Changes and fixes

* Fix cursor not getting locked to the game.
* Fix skip start screen patch not working.

## 1.19.0-rc - 16/02/2022

Support for patch **1.5**

### Known issues

* exEntitySpawner does not work.
* No pedestrian patch is not tested.
* Feel free to tell us any other issue that may arise on github/discord.

### Changes and fixes

* mimalloc updated to 2.0.3
* sqlite3 updated to 3.37.0+200

## 1.18.3 - 10/02/2022

### Changes and fixes

* Improve the d3d12 hook to fix a crash when using ReShade < 5.

## 1.18.2 - 09/02/2022

### Changes and fixes

* Improve the d3d12 hook to avoid conflicts with other overlays.

## 1.18.1 - 15/12/2021

Contains: [634](https://github.com/yamashi/CyberEngineTweaks/pull/634) and [635](https://github.com/yamashi/CyberEngineTweaks/pull/635)

### Changes and fixes

* Fixed random crashes when overridden method has a script reference parameter.
* Fixed random crashes when working with game structs.
* Fixed random crashes for very frequently called overrides (such as `GameObject.OnGameAttached` and `GameObject.OnDetach` on game reload).
* Fixed random crashes for hotkeys and inputs (for example, binding the mouse wheel had a very high chance of causing crashes).
* Fixed potential issues when CET mods that modify TweakDB are used with TweakDBext mods at the same time.

### Added

* Added the ability to add new free flats to TweakDB.

## 1.18.0 - 4/12/2021

Contains: [623](https://github.com/yamashi/CyberEngineTweaks/pull/623), [625](https://github.com/yamashi/CyberEngineTweaks/pull/625), [628](https://github.com/yamashi/CyberEngineTweaks/pull/628) and [629](https://github.com/yamashi/CyberEngineTweaks/pull/629)

### Changes and fixes

* Fix bad allocation causing crashes when using some RTTI types
* When using `Override()` the handler receives the original function (or next in the override chain) as the last parameter

```lua
Override('PlayerPuppet', 'SetWarningMessage', function(_, message, wrappedMethod)
    wrappedMethod('[Overridden] ' .. message)
end)
```

* The wrapped function can be called multiple times

```lua
Override('PlayerPuppet', 'GetGunshotRange', function(_, originalRangeFunc)
    return originalRangeFunc() + originalRangeFunc()
end)
```

* If any of the overrides fail then the entire override chain also fails
* Observers can be called before and after the target function using `ObserveBefore()` and `ObserveAfter()`

```lua
ObserveBefore('PlayerPuppet', 'GetGunshotRange', function()
    print('PlayerPuppet::GetGunshotRange::Before')
end)
ObserveAfter('PlayerPuppet', 'GetGunshotRange', function()
    print('PlayerPuppet::GetGunshotRange::After')
end)
```

* `Observe()` is an alias for `ObserveBefore()`
* All observers are guaranteed to be called even if overrides and other observers fail
* It's possible to observe and override static class methods

```lua
Override('RPGManager', 'GetFloatItemQuality', function(value)
    print('RPGManager.GetFloatItemQuality(' .. value .. ')')
    return gamedataQuality.Legendary
end)
```

* Full name should be used when overriding a scripted static method

```lua
Observe('PlayerPuppet', 'IsSwimming;PlayerPuppet', function(player)
    print('PlayerPuppet.IsSwimming(player)')
end)
```

* Use weak handle for `self` in overrides. This should decrease the number of unreleased references and make CET less dependent on garbage collection.
* Reuse overridden functions on mods reload. This fixes a potential issue with the native function registry, which has a hard limit on the number of registered functions.
* Support out params in overrides.To properly handle out params in overrides:
* Accept all params in the handler
* Don't pass out params to the wrapped function
* Return all results from the handler

```lua
registerForEvent('onInit', function()
    Override('SpatialQueriesSystem', 'SyncRaycastByCollisionGroup', function(_, a1, a2, a3, a4, a5, a6, wrapped)
        -- Skip a4 here because it's an out param
        local success, result = wrapped(a1, a2, a3, a5, a6)
        print(success, GameDump(result))

        -- Return all results
        return success, result
    end)
end)

registerHotkey('SyncRaycastByCollisionGroup', 'SyncRaycastByCollisionGroup', function()
    local from, forward = Game.GetTargetingSystem():GetCrosshairData(GetPlayer())
    local to = Vector4.new(from.x + forward.x * 100, from.y + forward.y * 100, from.z + forward.z * 100, from.w)

    local success, result = Game.GetSpatialQueriesSystem():SyncRaycastByCollisionGroup(from, to, 'Static', false, false)
    print(success, GameDump(result))
end)
```

### Added

* Added support for mods deployed as a symlink for the mod directory
* Added Lua function to check if the mod archive is installed:

```lua
if not ModArchiveExists("my_mod.archive") then
    print("This mod requires my_mod.archive to be installed")
end
```

* Use `FromVariant(variant)` to extract the value
* Use `ToVariant(value)` to pack the value when the type is unambiguous

```lua
ToVariant(Vector4.new(1, 2, 3))
ToVariant(gamedataQuality.Epic)
ToVariant("Nam libero tempore")
ToVariant(16570246047455160070ULL)
ToVariant(true)
ToVariant(TweakDBID("Items.money"))
ToVariant(CName("deflect"))
ToVariant(LocKey(12345))
ToVariant(CRUID(1337))
```

* Use `ToVariant(value, type)` when the type is ambiguous or you wanna force the type

```lua
ToVariant(1, "Int32") -- Same numeric value can be a signed integer
ToVariant(1, "Uint32") -- or unsigned integer
ToVariant(1, "Float") -- or float
ToVariant(nil, "handle:PlayerPuppet") -- Null requires a concrete type
```

* The type of the array is resolved from the first element when possible

```lua
ToVariant({ "a", "b", "c" }) -- Auto resolved as "array:String"
ToVariant({ 1, 2, 3 }, "array:Uint32") -- Ambiguous type
```

* Added event for early TweakDB changes:

```lua
registerForEvent('onTweak', function()
	TweakDB:SetFlat('PreventionSystem.setup.totalEntitiesLimit', 20)
end)
```

## 1.17.0 - 2/10/2021

Contains: [617](https://github.com/yamashi/CyberEngineTweaks/pull/617), [618](https://github.com/yamashi/CyberEngineTweaks/pull/618), [619](https://github.com/yamashi/CyberEngineTweaks/pull/619) and [620](https://github.com/yamashi/CyberEngineTweaks/pull/620)

### Changes and fixes

* Fixed directx12 hooking not working when overlays were present.
* Fixed symlink deployment with Vortex.
* Drop second implementation of `Scripting::ToRED()` which was very outdated. This was limiting what overridden functions can return.
* Fix `gamedataTDBIDHelper` helper that behaves the same as `gamedataTweakDBInterface`.
* Sanitize type names to be a valid Lua identifier. This makes namespaced types added by redscript accessible in Lua.
* Force garbage collection for overridden functions of `inkGameController` and it's descendants.\
  In some cases, there seem to be issues with unreleased instances of `inkGameController` leading to crashes. This was introduced when we started to properly wrap the context in `Handle<>`.
* Changed the behavior of observers so that all observers will be called even if an override is defined.

```lua
Observe('PlayerPuppet', 'IsPlayer', function() print('Observer 1') end)
Override('PlayerPuppet', 'IsPlayer', function() print('Override 1') end)
Override('PlayerPuppet', 'IsPlayer', function() print('Override 2') end)
Observe('PlayerPuppet', 'IsPlayer', function() print('Observer 2') end)
```

Will output

```
Observer 1
Observer 2
Override 1
```

### Added

* Stricter check of the passed context when calling the RTTI function. Prevents unwanted crashes when invalid value passed as `self` / `this`. In particular, it prevents crashes when a dot is accidentally used instead of a colon.
* Support for `ISerializable` strong and weak references. This opens access to some new classes, but not all of them.
* Function to add new `CName`s to the pool

```lua
print(CName("CET").value) -- Empty string
CName.add("CET")
print(CName("CET").value) -- CET
```

* Workaround for parameterized struct constructor. Previously, fields of a reference type could be corrupted right after construction.
* Support of nulls for strong and weak references.

Assignment example:

```lua
-- Set reference to null
self.resetConfirmationToken = nil
```

Parameter example:

```lua
-- Omit optional task data
Game.GetDelaySystem():QueueTask(this, nil, "ResolveGameplayStateTask", gameScriptTaskExecutionStage.PostPhysics)
```

* `IsDefined` helper function as in redscript. Checks if reference is not null and valid. Can be used on game object's field and lua variable.
* &#x20;`EnumInt` helper function as in redscript.

```lua
print(EnumInt(GameplayTier.Tier2_StagedGameplay)) -- 2ULL
```

* &#x20;Support for `CRUID` type.&#x20;

```lua
local dialogLine = scnDialogLineData.new()
dialogLine.id = CRUID(12345)
```

* &#x20;Support for `gamedataLocKeyWrapper` type.

```lua
TweakDB:SetFlat("Items.Preset_Overture_Kerry.displayName", LocKey(40475))
```

## 1.16.4 - 14/09/2021

Support for patch **1.31**

Contains: [611](https://github.com/yamashi/CyberEngineTweaks/pull/611)

### Changes and fixes

* Updated to Imgui 1.84.2

## 1.16.3 - Don't remember when

Support for patch **1.30** second edition.

## 1.16.2 - 27/8/2021

Contains: [603](https://github.com/yamashi/CyberEngineTweaks/pull/603)

### Changes and fixes

* Fix disappearing footsteps (1.16.1 regression).
* Alternative syntax for `CName` and `TweakDBID` conversions without `.new()`

```lua
print(TweakDBID("Items.money"))
print(CName(0))
print(CName("DEBUG"))
```

* Direct access to global functions.

```lua
print(GetPlayer()) -- Equivalent to print(Game.GetPlayer())
```

* Throw Lua errors from RTTI calls as the Lua script will do.

```lua
registerForEvent('onInit', function()
    Observe('TimeSystem', 'SetTimeDilation', function(self, reason)
        if reason.value == 'consoleCommand' then
            Game.FloorF('XXX')
        end
    end)
end)
registerHotkey('TestError', 'TestError', function()
    Game.GetTimeSystem():SetTimeDilation('consoleCommand', 0.25, 1.0, 'Linear')
end)
```

Will print the full callstack in the log:

```
[error] ...x64\plugins\cyber_engine_tweaks\mods\test-error\init.lua:4: Function 'FloorF' parameter 1 must be Float.
stack traceback:
    [C]: in function 'FloorF'
    ...x64\plugins\cyber_engine_tweaks\mods\test-error\init.lua:4: in function <...x64\plugins\cyber_engine_tweaks\mods\test-error\init.lua:2>
    [C]: in function 'SetTimeDilation'
    ...x64\plugins\cyber_engine_tweaks\mods\test-error\init.lua:10: in function <...x64\plugins\cyber_engine_tweaks\mods\test-error\init.lua:9>
```

## 1.16.1 - 23/8/2021

### Changes and fixes

* Fix channel logs not printing the message.
* Added a new channel "DEBUG" that always prints even when game logs are disabled.
* Re-added TweakDB printing.
* Register global `PlayerPuppet.OnAction` handler as for pre patch 1.3.
* Override function by full name. Allows to observe/override all variants of overloaded function.

## 1.16.0 - 20/8/2021

Support for patch **1.30** - huge thanks to everyone who helped with this and all testers!&#x20;

Contains: [581](https://github.com/yamashi/CyberEngineTweaks/pull/581), [582](https://github.com/yamashi/CyberEngineTweaks/pull/582), [583](https://github.com/yamashi/CyberEngineTweaks/pull/583), [585 ](https://github.com/yamashi/CyberEngineTweaks/pull/585)and [589](https://github.com/yamashi/CyberEngineTweaks/pull/589)

### Changes and fixes

* Fix crash when calling functions that have optional parameters not defaulted.
* Fix crash when using RegisterInputListener from an observer.

## 1.15.0 - 8/8/2021

Contains: [568](https://github.com/yamashi/CyberEngineTweaks/pull/568), [572](https://github.com/yamashi/CyberEngineTweaks/pull/572), [573](https://github.com/yamashi/CyberEngineTweaks/pull/573), [574](https://github.com/yamashi/CyberEngineTweaks/pull/574), [575](https://github.com/yamashi/CyberEngineTweaks/pull/575), [577](https://github.com/yamashi/CyberEngineTweaks/pull/577), [578](https://github.com/yamashi/CyberEngineTweaks/pull/578) and [579](https://github.com/yamashi/CyberEngineTweaks/pull/579)

### Script API

* Whitelisted `collectgarbage` to let scripts force release game references.
* Added `exEntitySpawner` to spawn entities easily

```lua
spawnPosition = Game.GetPlayer():GetWorldTransform()

-- [Simple]
-- Spawn 'Character.Judy' just like prevention system
-- Optionally set appearance to 'judy_diving_suit'
judyEntityID = exEntitySpawner.SpawnRecord('Character.Judy', spawnPosition)
judyEntityID = exEntitySpawner.SpawnRecord('Character.Judy', spawnPosition, 'judy_diving_suit')

-- [Advanced]
-- Spawn base\quest\secondary_characters\judy.ent
-- Optionally set appearance to 'default'
-- Optionally set TweakDB record to 'Character.Judy' (VO/Name/Equipment/etc)
judyEntityID = exEntitySpawner.Spawn([[base\quest\secondary_characters\judy.ent]], spawnPosition)
judyEntityID = exEntitySpawner.Spawn([[base\quest\secondary_characters\judy.ent]], spawnPosition, 'default')
judyEntityID = exEntitySpawner.Spawn([[base\quest\secondary_characters\judy.ent]], spawnPosition, 'default', 'Character.Judy')

-- Some time later...
-- entities are not spawned instantly, FindEntityByID may return nil
judy = Game.FindEntityByID(judyEntityID)

exEntitySpawner.Despawn(judy)
```

### Changes and fixes

* Fixed a crash that would occur on machines without ASLR enabled by enabling LuaJIT's GC64 option.
* Fixed nested RTTI calls that would crash the game due to memory release of the previous call's memory.
* Fix the disable anti AA and async compute patches.
* Fix for TweakDB default values.
* Fix tooltips that contained C format characters and would crash the game.
* Improved update hook.
* `xmake install` will now install in the game's directory to make it easier for those installing from source.

## 1.14.0 - 17/06/2021

Contains: [551](https://github.com/yamashi/CyberEngineTweaks/pull/551), [552](https://github.com/yamashi/CyberEngineTweaks/pull/552), [553](https://github.com/yamashi/CyberEngineTweaks/pull/553), [557](https://github.com/yamashi/CyberEngineTweaks/pull/557), [558](https://github.com/yamashi/CyberEngineTweaks/pull/558), [559](https://github.com/yamashi/CyberEngineTweaks/pull/559)

### Script API

* All game classes are directly accessible by name. For example, `entEntityId`, `PlayerPuppet`.
* All game enums are directly accessible by name. For example, `gamedataStatType.BaseDamage`, `gameGameVersion.Current`.
* Classes can also be accessed by their aliases from redscript. For example, `WeaponObject` instead of `gameweaponObject`.
* Classes have the conventional `.new()` constructor. For example, `MappinData.new()`.
* A constructor can take an array of properties to create and initialize an object in a single statement. For example, `EntityID.new({ hash = 12345 })`.
* Static methods are accessible from classes using the dot. For example, `ScriptedPuppet.IsDefeated(npc)`.
* A static method can be called from an instance if the first parameter is of the same type. For example, `vec4:Length()` instead of `Vector4.Length(vec4)`.
* The overloaded function is resolved based on passed parameters when called by its short name. For example, `StatusEffectHelper.HasStatusEffect(target, gamedataStatusEffectType.Overheat)`.
* Partial `Variant` type support. `ToVariant()` and `FromVariant()` are only applicable to classes.
* `Observe()` and `Override()` now accept both native and scripted type names.
* Added `Game.GetSystemRequestsHandler()` as an alternative to `GetSingleton("inkMenuScenario"):GetSystemRequestsHandler()`.
* Added `TweakDB:SetFlats`

```lua
TweakDB:SetFlats('Character.Judy', {
  level = 99,
  tags = { 'Immortal' }
});
```

* Added `WorldFunctionalTests`

```lua
transform = Game.GetPlayer():GetWorldTransform()
entityID = WorldFunctionalTests.SpawnEntity('base\\quest\\secondary_characters\\judy.ent', transform, '')
entity = Game.FindEntityByID(entityID)
WorldFunctionalTests.DespawnEntity(entity)
```

* Added `Imgui.GetStyle()`
* Added support for `ResourceAsyncReference`. Allows editing of TweakDB props of that type by the mods.

### Changes and fixes

* Fixed disappearing footsteps issue.
  * The issue still can occur if the mods do not properly release the player reference.
* The `GetMod()` is only available after `onInit` as there is no guarantee that the required mod will be loaded before this event.
* Types and functions that rely on RTTI are only available after `onInit` event to prevent some unwanted crashes and unexpected behavior.
* Improved detection of whether the game is running. Prevents more crashes when exiting the game.
* Implemented optional parameters support. Prevents some unexpected crashes.
* Fixed `DumpType("Type")` returning empty result.
* Fixed crash when accessing properties of invalid `Enum`, eg. `Enum.new('', '').value`.
* Fixed crash when setting an incompatible value for an object property.
* Fixed crash when calling function with out parameters of `Enum`, `CName` or `TweakDBID` type.
* Fixed memory leaks when passing strong or weak references to the function.&#x20;
* Fixed memory leaks when invalid parameters passed to the function.
* Fixed memory leaks for function results and out parameters of certain types.
* Fixed memory leaks when creating new objects.
* Fixed memory leaks when setting object properties.
* Fixed memory leak for arrays with elements of certain types passed as an argument.
* Fixed a crash when passing an incompatible array as an argument. For example, an array of numbers instead of an array of handles.
* Fixed memory leak when passing an object instead of an array as an argument. This resulted in a silent crash without calling `ResetAllocator`.
* Fixed inconsistent `self` and random crashes in `Observe` and `Override`.
* Reverted `Override()` to the previous behavior so when the handler fails, the original game function is not called.&#x20;
* Added implicit conversion from Int64/UInt64 to other arithmetic types.
* Added type safety checks for Int64/UInt64.
* Added recursive freeing of arrays.
* Added logging for errors occurred in the module loaded with `require()`. Should make the transition to the new version less painful.

### Internals

* Global fallback table is used now for all mod environments. No need to whitelist what's defined there.
* Aliases like `Game['GetPlayer'] = Game['GetPlayer;GameInstance']` aren't needed in `autoexec.lua`. All global and class functions are automatically resolved by short name now.
* Added implicit class to strong reference conversion.
* Updated RED4ext to latest version.
  * This fixes the error when trying to use a `CName` that is `None`

### Added

* Patch for the Minimap flicker

## 1.13.0 - 28/04/2021

Support for patch **1.22**

**Fixed**

* Crash when using TweakDB:Update in an Observe/Override callback
* Direct3d12 command queue could be null sometimes
* Error logging from Observe/Override callbacks
* Redundant Lua environment passing
* 64bits numbers are now correctly interpreted as numbers by Lua

**Added**

* Strings can now be implicitly cast to a TweakDBID when the scripting framework expects a TweakDBID

## 1.12.2 - 14/04/2021

Support for patch **1.21**

**Fixed**

* Lua scripting errors with functions returning some values with out params
* GameOptions.Toggle() now works
* Fix falsy "Unknown error" when calling a global that returns `nil`
* Return out params from global function the same way as for instance methods
* EulerAngles::ToString returning swapped roll and yaw values
* SQLite3 database not closing on mod reload

**Added**

* Equality comparison to some types (Vector3, Enum, TweakDBID,...)
* Concatenation for TweakDBID

## 1.12.1 - 04/04/2021

**Fixed**

* Regressions with GameOptions
* Wrong version info returned back by GetVersion()
* Problems with Console widget history
* 3rd party licences missing
* ImGui.TreePop unavailable in Lua
* Multiple registerInput handlers unable to be invoked at same time
* Conversion of 64-bit integral values from object properties
* Scroll wheel failling to register properly

**Added**

* Modal popups for unsaved changes into Bindings and Settings widget
* Modal popup on first launch asking user explicitly to bind some hotkey for toggling Overlay
* Option to enable removing of dead binds (default is on)
* Option to enable ImGui assertions to make sure mods are not breaking something (default is off)
* Option to toggle ImGui Diagnostic window (default is off, this option is not preserved after restart!)

**Changed**

* Nicer formatting of headings inside Bindings widget (replace characters that are not alphanumeric by space and autocapitalize each word)
* Reworked Settings menu (options are now split into two categories - Patches and Dev)
* Reworked Bindings menu (separated hotkeys and inputs into two categories)
* onDraw is not called for mods while CET modal dialog is active (including first launch)
* First time launch (it should now be more streamlined)
* Decoupled config.json from bindings.json (overlay key is now located only inside bindings.json and is left out of config.json)
* Overlay key was moved to Bindings menu
* Updated TiltedCore to 0.2.2

## 1.12.0 - 29/03/2021

Added support for patch **1.2**.

**Fixed**

* **os.remove** and **os.rename** were not working properly.
* The debug menu patch would not show the menus.
* Fixed dofile, loadfile and loadstring.
* Lua environment would not be applied correctly to some callbacks.
* Lua to RED engine converter now works correctly with nil values and double.
* Security issue where scripts could override another script's functions, calling another script is now read only.

**Changed**

* Key bindings were improved.
  * Support for scroll wheel.
  * **registerInput** for single inputs. This handler is similar to registerHotkey, but function now takes one boolean argument denoting if input was pressed/released.
  * **IsBound** and **GetBind** added to check if action is bound and retrieve string representation of it.
* TweakDB experienced many changes:
  * All TweakDB functions can now be called with strings instead of TweakDBID. TweakDBID is still accepted.
  * TweakDB:SetFlat now updates records if it already exists (see SetFlatNoUpdate)
  * Performance improved.
* **Lua version changed to 5.1** this can break your mod if you were using post 5.1 language features such as bit operators. This change was done to fix environment issues, we also got a performance boost by switching to **LuaJIT** instead of the default Lua implementation.
* Updated Imgui to version 1.82.
* Updated spdlog to version 1.8.5.
* Updated sqlite3 to version 3.35.0.

**Added**

* Re-added the SMT patch for AMD CPUs that did not get a performance boost after CDPR's patch.
* Added Lua's bit32 library.
* TweakDB additions:
  * CloneRecord, CreateRecord and DeleteRecord.
  * GetRecords, obtain a list of records associated with a type.
  * SetFlatNoUpdate, faster way to set without checking if there is an old record to update. Requires call to TweakDB:Update afterwards to apply changes!
  * TweakDB editor in the UI.
  * Supports loading `archivehashes.txt`.
  * Can now search through record flats.

## 1.11.4 - 18/02/2021

**Fixed**

* Fix memory allocation errors due to missing argument.
* Fix Observe/Override sometimes affecting scripts when they shouldn't.

## 1.11.3 - 17/02/2021

* Fix crash when using multiple mods.

## 1.11.2 - 17/02/2021

**Fixed**

* Crash on game exit when a reference had not been garbage collected by the lua vm.
* Missing enum value CellPadding in Imgui Lua (Pull Request: [496](https://github.com/yamashi/CyberEngineTweaks/pull/496)).
* Crash when using Override/Observe on pure script functions.
* Crash when reloading mods using Override/Observe.
* Crash when a malformed lua file was loaded with "require".
* Lua execution error when a callback used a global variable because environments were not applied.
* Fix memory leaks when reloading mods using Observe/Override.

**Changed**

* Memory optimization for calls.
* Replaced the hacky thread safety used for the Lua VM with TiltedCore's Lockable\<T>.

## 1.11.1 - 15/02/2021

**Added**

* API changes to support Imgui 1.81 and added missing ColorButton overloads.
* **Override** has now 2 overloads to simplify usage, this will completely remove the original function or add one if it doesn't exist:
  * Override(typeName, fullFunctionName, shortFunctionName, function)
  * Override(typeName, functionName, function) - both **full** and **short names** are set to **functionName**
* **Observe** has now 2 overloads to simplify usage, this will not remove the original function but will add one if it doesn't exist:
  * Observe(typeName, fullFunctionName, shortFunctionName, function)
  * Observe(typeName, functionName, function) - both **full** and **short names** are set to **functionName**

**Changed**

* Upgrade Imgui 1.80 to [1.81](https://github.com/ocornut/imgui/releases/tag/v1.81).
* Fixed Override so that it can override at runtime after scripts have been loaded.
* Revert Lua caching of functions as the new override method will work regardless.

**Fixed**

* Fix game crash when a script used "require" on a malformed file.

## 1.11.0 - 13/02/2021

**Added**

* Override function to either listen to a function or to replace a game function. Despite its name it can also be used to extend a type by adding a new function.\
  Usage is as such:

```lua
Override("PlayerPuppet", "IsA", "IsA", true, function(self, className) print(className); return true end)
```

The first parameter is the class type, second the full name of the function, the third is the short name (usually they are the same), the fourth boolean is used to specify if this is a replacement of the function or not, if set to true it will replace entirely the original function, if set to false, your function will be called before the original function is called. The last parameter is your handler function, note that the parameters are passed according to the RED script definition.

**Removed**

* Telemetry, the experiment gave us the data we wanted, obviously a lot of people use the mod and we are very happy about that! We are sorry this caused so much drama, it wasn't the intention and quite frankly we still don't really understand why.

**Changed**

* Calling RED functions used to be cached, given that functions can be overridden at any time the cache has been removed, it's a bit slower but shouldn't be visible in the real world.

## 1.10.3 - 12/02/2021

* Using the up and down arrows in the console now retrieves the command history

## 1.10.2 - 07/02/2021

* Added Telemetry so we know how many people use CET (can be disabled in settings), note that we do not store any information we just count the number of players

## 1.10.1 - 06/02/2021

* Fix TweakDBID issues with large arrays
* Fix TweakDBID crash when using specific functions

## 1.10 - 05/02/2021

**Changed**

* Updated to game version 1.12
* Updated RED4ext.sdk to the latest

**Proper sandboxing (**[**#454**](https://github.com/yamashi/CyberEngineTweaks/pull/454)**):**

* Each mod is (right now) assigned sqlite3 database implicitly, accessible through `db` lua object (will be changed later to on-demand through info in metadata file)
* Introduced proper sandbox with LuaSandbox helper class
* Bytecode cannot be loaded now (native modules included)
* `require` cache is reset on `Reload all mods` now
* `require` does not support '.' instead of '/' now (only *breaking change*, functions the same otherwise)
* All pathing is now relative to mod (*breaking change*, includes all io functions, `dofile()` and such included)
* stripped ImGui, json, io and dofile and such from console sandbox (only needed things left for it in)
* Added `dir()` command for mods to list directory contents
* Errors that happen in Game, game class methods,... should now log into proper environment (to console when executed from console, to mod log when executed from mod)

**More ImGui stuff(**[**#452**](https://github.com/yamashi/CyberEngineTweaks/pull/452)**,** [**#453**](https://github.com/yamashi/CyberEngineTweaks/pull/453)**,** [**#457**](https://github.com/yamashi/CyberEngineTweaks/pull/457)**,** [**#460**](https://github.com/yamashi/CyberEngineTweaks/pull/460)**):**

* Enabled ImGui keyboard navigatio&#x6E;**.** (`ctrl + tab` to switch window, arrow keys to navigate)
* Removed the deprecated `power` argument in Drag and Slider widgets, replace it with the newer ImGuiSliderFlag *(breaking change)*
* Made the argument `open` optional in `ImGui.Begin()`, `ImGui.BeginModal()`, `ImGui.BeginTabItem()`, so the close button can be hidden when setting flags.
* Added [bindings ](https://github.com/yamashi/CyberEngineTweaks/tree/master/src/sol_imgui#tables)for the new tables widget in ImGui 1.8.0
* [Added ](https://github.com/yamashi/CyberEngineTweaks/tree/master/src/sol_imgui#inputs-utilities-mouse)selected mouse utilities back
* Added bindings for [ImDrawlist](https://github.com/yamashi/CyberEngineTweaks/pull/460/files#diff-9ac293ccdb6ed6087eb7d232047f6abe6a033d21359c213c209d48f322807d89R1696)

**TweakDB binding** ([#461](https://github.com/yamashi/CyberEngineTweaks/pull/461))

* TweakDB:GetFlat(...)
* TweakDB:SetFlat(...)
* TweakDB:GetRecord(...)
* TweakDB:Query(...)
* TweakDB:Update(...)

## 1.9.6 - 30/01/2021

**Changed**

* **Major** vulnerability in the game's save loader fixed

## 1.9.5 - 28/01/2021

**Changed**

* Updated to game version 1.11
* Updated RED4ext.sdk to the latest
* Updated to spdlog 1.8.2

## 1.9.4 - 26/01/2021

### Changed

* Replaced pattern search with much faster library

### Fixed

* Fix issue when resizing game window (eg. resolution change in Options)
* Fix issue causing game window to stop rendering and freeze on last frame
* Fix ImGui.CalcTextSize overloads (now, second parameter is removed from all, as it did not make sense for Lua anyway)
* Fix Windows 7 flatlining

## 1.9.2 - 23/01/2021

### Added

* Added `json`support to Lua

## 1.9.1 - 23/01/2021

### Added

* Added support for the latest patch 1.10
* UI with settings will now ask you for a console key on first launch, you can edit it later&#x20;
* Mods can now request hotkeys via `registerHotkey`, the user can pick what key they want to use in the menu
* You can now instantiate game objects with `NewObject('class name')`, do not expect this to work with every class without any issues
* SQLite3 support was added, you can use the entire API at the moment, we are going to remove all open functions in the near future and replace it with a open that can only open a single database linked to your mod
* Mods will now log to their own log files, you can also use `spdlog`to print in your log

### Fixed

* Scripting is now handling memory correctly, calling `Game.GetPlayer()` every frame is fine now
* Game doesn't crash when exiting anymore

### Removed

* `dofile` is now deprecated, use only mods please, it will be removed entirely in the next update


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.redmodding.org/cyber-engine-tweaks/patch-notes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
