Skip to content

Commit 8b20644

Browse files
authored
Merge pull request #74 from acidlabsdev/main
refactor(serializer): add mutation lock
2 parents 62d48eb + f2bf4b3 commit 8b20644

22 files changed

Lines changed: 637 additions & 252 deletions

CONTRIBUTING.md

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Commit Convention
1+
# Contributing
2+
3+
Thank you for considering contributing to this project! It's people like you that make the open source community a great place to learn, inspire, and create.
4+
5+
## Commit Convention
26

37
These are recommended, but not enforced yet. We follow slightly similar commit guidelines to [YimMenu](https://github.com/Mr-X-GTA/YimMenu/blob/master/CONTRIBUTING.md):
48

@@ -82,7 +86,7 @@ Use Lua's default global table `_G`:
8286
You are free to use any style you want, except in these cases:
8387

8488
| Scope | Naming | Example |
85-
| ----------- | ----------- | ---------- |
89+
| :---: | :---: | :---: |
8690
| Global Functions | PascalCase | `function DoSomething(...) end` |
8791
| Local Functions | any (consistent) | You are free to use any style as long as it stays consistent throughout the whole file |
8892
| Standard Lib Extensions | Use the lib's default style | `string.somefunc = function(...) end` |
@@ -220,6 +224,59 @@ Suppose you want to draw some text that gets automatically translated:
220224
}
221225
```
222226

227+
## Project Structure
228+
229+
The project is organized by responsibility rather than feature size. Folders define architectural boundaries and expected usage patterns.
230+
231+
```bash
232+
├─ includes/
233+
│ ├─ classes/ # Contains reverse-engineered game classes (mostly sourced from Yimura's archived classes repository) and a few Lua-defined classes.
234+
│ │
235+
│ ├─ data/ # A place where all raw data is stored.
236+
│ │ ├─ actions/ # Contains YimActions V3 data (animations, scenarios, synchronized scenes, and movement clipsets).
237+
│ │ └─ enums/ # Groups all game and custom enums in one place under one `Enums` global namespace.
238+
│ │
239+
│ ├─ features/ # Stores all script features.
240+
│ │ ├─ self/ # Player-specific features.
241+
│ │ ├─ vehicle/ # Vehicle-specific features.
242+
│ │ └─ world/ # World-specific features.
243+
│ │
244+
│ ├─ frontend/ # This is where UI tabs live.
245+
│ │
246+
│ ├─ lib/ # Contains project libraries and commands: API extensions, translations, Lua standard library extensions, global utilities, etc.
247+
│ │
248+
│ ├─ modules/ # Contains custom modules such as native wrappers, game entity abstractions, and higher-level gameplay utilities.
249+
│ │
250+
│ ├─ services/ # Contains runtime services (GUI, KeyManager, Serializer, CommandExecutor, etc.)
251+
│ │
252+
│ ├─ structs/ # Stores helper structs.
253+
│ │
254+
│ ├─ thirdparty/ # Thirdparty components and their license texts.
255+
│ │
256+
│ ├─ backend.lua # Central backend module providing lifecycle coordination, entity management, and API/script version checks.
257+
│ ├─ version.lua # This is purely for CI and should never be edited. It stores the latest script version.
258+
│ └─ init.lua # Initializes the whole project.
259+
260+
└─ samurais_scripts.lua # Main entry point that calls `init.lua`, handles late initialization for a few modules/services, and lazily populates a few data sets in a fiber.
261+
```
262+
263+
## Where Does My Code Go?
264+
265+
| Addition | Home | Notes |
266+
| :---: | :---: | :---: |
267+
| A gameplay feature | `includes/features/` | Features are behavior, not UI. |
268+
| A UI tab or layout code | `includes/frontend/` | UI only. No game logic. |
269+
| A reusable system with lifecycle | `includes/services/` | Must be explicitly initialized. |
270+
| A reverse-engineered game structure or a custom Lua class | `includes/classes/` | - |
271+
| A lightweight data container or object | `includes/structs/` | No lifecycle, no side effects. |
272+
| Raw static data (tables, lists, maps) | `includes/data/` | Never execute logic here. |
273+
| A native wrapper or abstraction | `includes/modules/` | Bridges Lua `<->` game engine. |
274+
| Utility or extension code | `includes/lib/` | Generic helpers and API/stdlib extensions. |
275+
| Initialization or bootstrapping | `init.lua` / `backend.lua` | Do not add features here. |
276+
| A third party module from somewhere/someone else | `includes/thirdparty` | Place in a subfolder accompanied with the module's license *(when applicable)*. |
277+
223278
## What To Avoid
224279

225280
- Manually editing any language file except `en-US.lua`. They are auto-generated so any changes you add will be overwritten by GitHub Actions.
281+
- Contributing licensed open source code from other developers without permission, credits, or original license *(when applicable)*.
282+
- Adding high-risk online options without clear and concise user warnings.

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
<!-- markdownlint-disable MD033 -->
2+
<!-- markdownlint-disable MD041 -->
3+
14
<div align="center">
25
<a href="https://github.com/YimMenu-Lua/Samurais-Scripts/releases/latest">
36
<img alt="Script Version" src="https://img.shields.io/badge/Script%20Version-v1.7.8-blue?style=for-the-badge">
@@ -69,14 +72,6 @@ This project was rewritten from scratch using [SmallBase](https://github.com/xes
6972
> Some parts of the API were refactored or extended but nothing has drastically changed.
7073
> All changes introduced in this project are documented in the source.
7174
72-
## Contact
73-
74-
<div>
75-
<a href="https://discord.gg/RHBUxJ5Qhp">
76-
<img height="96" width="192" src="https://substackcdn.com/image/fetch/$s_!nfCP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a41e45e-aac9-44e5-8b69-55a81058ecbf_875x280.png">
77-
</a>
78-
</div>
79-
8075
## FAQ
8176

8277
- **Q:** Does this support Enhanced?
@@ -100,10 +95,18 @@ This project was rewritten from scratch using [SmallBase](https://github.com/xes
10095

10196
| Name | Contribution |
10297
| :---: | :---: |
103-
| <a href="https://github.com/harmless05"><img height="40" width="40" src="https://avatars.githubusercontent.com/harmless05"><br/>Harmless</a> | Shift-Drift |
104-
| <a href="https://github.com/NiiV3AU"><img height="40" width="40" src="https://avatars.githubusercontent.com/NiiV3AU"><br/>NiiV3AU</a> | German translations |
105-
| <a href="https://github.com/gir489returns"><img height="40" width="40" src="https://avatars.githubusercontent.com/gir489returns"><br/>gir489returns</a> | [Casino Pacino](https://github.com/YimMenu-Lua/Casino-Pacino) |
106-
| <a href="https://github.com/tupoy-ya"><img height="40" width="40" src="https://avatars.githubusercontent.com/tupoy-ya"><br/>tupoy-ya</a> | Several contributions and shared knowledge |
107-
| <a href="https://github.com/szalikdev"><img height="40" width="40" src="https://avatars.githubusercontent.com/szalikdev"><br/>szalikdev</a> | Revived the project and joined the cause |
108-
| <a href="https://github.com/shinywasabi"><img height="40" width="40" src="https://avatars.githubusercontent.com/shinywasabi"><br/>ShinyWasabi</a> | Foundational community tooling frequently used as reference |
109-
| <a href="https://unknowncheats.me"><img height="40" width="40" src="https://avatars.githubusercontent.com/u/29552835"><br/>UnknownCheats</a> | A treasure trove of information |
98+
| <a href="https://github.com/harmless05"><img height="40" width="40" alt="harmless05" src="https://avatars.githubusercontent.com/harmless05"><br/>Harmless</a> | Shift-Drift |
99+
| <a href="https://github.com/NiiV3AU"><img height="40" width="40" alt="NiiV3AU" src="https://avatars.githubusercontent.com/NiiV3AU"><br/>NiiV3AU</a> | German translations |
100+
| <a href="https://github.com/gir489returns"><img height="40" width="40" alt="gir489returns" src="https://avatars.githubusercontent.com/gir489returns"><br/>gir489returns</a> | [Casino Pacino](https://github.com/YimMenu-Lua/Casino-Pacino) |
101+
| <a href="https://github.com/tupoy-ya"><img height="40" width="40" alt="tupoy-ya" src="https://avatars.githubusercontent.com/tupoy-ya"><br/>tupoy-ya</a> | Several contributions and shared knowledge |
102+
| <a href="https://github.com/szalikdev"><img height="40" width="40" alt="szalikdev" src="https://avatars.githubusercontent.com/szalikdev"><br/>szalikdev</a> | Revived the project and joined the cause |
103+
| <a href="https://github.com/shinywasabi"><img height="40" width="40" alt="arthur" src="https://avatars.githubusercontent.com/shinywasabi"><br/>ShinyWasabi</a> | Foundational community tooling frequently used as reference |
104+
| <a href="https://unknowncheats.me"><img height="40" width="40" alt="uc" src="https://avatars.githubusercontent.com/u/29552835"><br/>UnknownCheats</a> | A treasure trove of information |
105+
106+
## Contact
107+
108+
<div>
109+
<a href="https://discord.gg/RHBUxJ5Qhp">
110+
<img height="96" width="192" alt="Discord" src="https://substackcdn.com/image/fetch/$s_!nfCP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8a41e45e-aac9-44e5-8b69-55a81058ecbf_875x280.png">
111+
</a>
112+
</div>

SSV2/includes/classes/CVehicle.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local CWheel = require("includes.classes.CWheel")
33
local CCarHandlingData = require("includes.classes.CCarHandlingData")
44
local CBikeHandlingData = require("includes.classes.CBikeHandlingData")
55
local CFlyingHandlingData = require("includes.classes.CFlyingHandlingData")
6-
local phFragInst = require("includes.structs.phFragInst")
6+
local phFragInst = require("includes.classes.phFragInst")
77
local CVehicleDrawData = require("includes.classes.CVehicleDrawData")
88

99
---@class CAdvancedData : GenericClass
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
--------------------------------------
2-
-- phFragInst Struct
3-
--------------------------------------
41
---@class phFragInst
52
---@field private m_ptr pointer
63
---@field public m_cache_entry pointer

SSV2/includes/features/CasinoPacino.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---@diagnostic disable: lowercase-global
22

3-
local SGSL = require("includes.structs.SGSL")
3+
local SGSL = require("includes.services.SGSL")
44

55
---@enum eCasinoPrize
66
Enums.eCasinoPrize = {

SSV2/includes/features/YimResupplierV3.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local SGSL = require("includes.structs.SGSL")
1+
local SGSL = require("includes.services.SGSL")
22

33
---@class WarehouseStruct
44
---@field wasChecked boolean

SSV2/includes/features/vehicle/stancer.lua

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ end
3232
---@field public m_deltas table<eWheelSide, StanceObject>
3333
---@field public m_wheels table<eWheelSide, array<CWheel>>
3434
---@field public m_suspension_height { m_current: float, m_last_seen: float }
35-
---@field public m_is_model_saved boolean
3635
---@field public m_is_active boolean
3736
local Stancer = setmetatable({}, FeatureBase)
3837
Stancer.__index = Stancer
@@ -263,12 +262,8 @@ function Stancer:ForEach(array, fn)
263262
end
264263

265264
function Stancer:IsVehicleModelSaved()
266-
if (not self.m_entity or not self.m_entity:IsValid()) then
267-
return false
268-
end
269-
270265
if (not self.m_cached_model) then
271-
self.m_cached_model = self.m_entity:GetModelHash()
266+
return false
272267
end
273268

274269
return GVars.features.vehicle.stancer.saved_models[tostring(self.m_cached_model)] ~= nil
@@ -564,10 +559,6 @@ end
564559
function Stancer:Update()
565560
self.m_is_active = self.m_entity:IsCar()
566561

567-
-- I'm paranoid about unnecessarily calling natives on tick
568-
-- possible RAGE engine PTSD involved
569-
self.m_is_model_saved = self:IsVehicleModelSaved()
570-
571562
if (not self.m_is_active or not self.m_wheels or self.m_reloading) then
572563
return
573564
end

SSV2/includes/frontend/casino_ui.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local CasinoPacino = require("includes.features.CasinoPacino"):init()
2-
local SGSL = require("includes.structs.SGSL")
2+
local SGSL = require("includes.services.SGSL")
33

44
local function drawGamblingTab()
55
ImGui.SeparatorText(_T "CP_COOLDOWN_BYPASS")

SSV2/includes/frontend/settings/debug_ui.lua

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -521,50 +521,7 @@ local function DrawPatches()
521521
end
522522

523523
local function DrawMiscTests()
524-
ImGui.SeparatorText("Vehicle Flag Dump")
525-
526-
if (ImGui.Button("Handling Flags")) then
527-
script.run_in_fiber(function()
528-
local PV = Self:GetVehicle()
529-
if (not PV:IsValid()) then
530-
return
531-
end
532-
PV:Resolve():DumpHandlingFlags()
533-
end)
534-
end
535-
ImGui.SameLine()
536-
if (ImGui.Button("Model Flags")) then
537-
script.run_in_fiber(function()
538-
local PV = Self:GetVehicle()
539-
if (not PV:IsValid()) then
540-
return
541-
end
542-
PV:Resolve():DumpModelFlags()
543-
end)
544-
end
545-
ImGui.SameLine()
546-
if (ImGui.Button("Model Info Flags")) then
547-
script.run_in_fiber(function()
548-
local PV = Self:GetVehicle()
549-
if (not PV:IsValid()) then
550-
return
551-
end
552-
PV:Resolve():DumpModelInfoFlags()
553-
end)
554-
end
555-
556-
ImGui.SameLine()
557-
if (ImGui.Button("Advanced Flags")) then
558-
script.run_in_fiber(function()
559-
local PV = Self:GetVehicle()
560-
if (not PV:IsValid()) then
561-
return
562-
end
563-
PV:Resolve():DumpAdvancedFlags()
564-
end)
565-
end
566-
567-
if (ImGui.Button("")) then
524+
if (ImGui.Button("Test Toasts")) then
568525
for i = 1, 5 do
569526
local label = _F("Test %d", i)
570527
local level = math.random(0, 3)

SSV2/includes/frontend/settings/settings_ui.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ local settings_tab = GUI:RegisterNewTab(Enums.eTabID.TAB_SETTINGS, "GENERIC_GENE
4040
)) then
4141
for i, lang in ipairs(Translator.locales) do
4242
local is_selected = (i == GVars.backend.language_index)
43-
if ImGui.Selectable(_F("%s (%s)", lang.name, lang.iso), is_selected) then
43+
if (ImGui.Selectable(_F("%s (%s)", lang.name, lang.iso), is_selected)) then
4444
GVars.backend.language_index = i
4545
GVars.backend.language_name = lang.name
4646
GVars.backend.language_code = lang.iso

0 commit comments

Comments
 (0)