Skip to content

Commit 255a720

Browse files
committed
chore: tidy up
1 parent f1feec9 commit 255a720

38 files changed

Lines changed: 223 additions & 263 deletions

SSV2/includes/classes/Mutex.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
-- Class: Mutex
1212
--------------------------------------
1313
-- Simple mutual exclusivity.
14-
---@class Mutex
15-
---@field protected m_locked boolean
14+
---@class Mutex : Callable<Mutex>
15+
---@field private m_locked boolean
1616
---@overload fun(): Mutex
17-
local Mutex = Callable("Mutex")
17+
local Mutex = Callable("Mutex", { ctor = function(t) return t:new() end })
1818

1919
---@return Mutex
20-
function Mutex.new()
21-
return MakeInstance({ m_locked = false }, Mutex)
20+
function Mutex:new()
21+
return setmetatable({ m_locked = false }, self)
2222
end
2323

2424
---@return boolean

SSV2/includes/classes/Pair.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
-- Class: Pair
1212
--------------------------------------
1313
---@class Pair<K, V> : { first: K, second: V }
14-
local Pair = {}
15-
Pair.__index = Pair
14+
---@overload fun(k: K, v: V): Pair<K, V>
15+
local Pair = Callable("Pair", { ctor = function(t, ...) return t:new(...) end })
1616

1717

18-
local _mt = {}
19-
_mt.__index = function(self, k)
18+
local _mt <const> = {}
19+
_mt.__index = function(self, k)
2020
if (k == "first") then
2121
return self._raw[1]
2222
end
@@ -28,7 +28,7 @@ _mt.__index = function(self, k)
2828
return _mt[k]
2929
end
3030

31-
_mt.__newindex = function(self, k, v)
31+
_mt.__newindex = function(self, k, v)
3232
if (type(k) == "number") then -- table.insert won't work without this
3333
if (k == 1) then
3434
self._raw[1] = v
@@ -70,7 +70,7 @@ end
7070
---@param a K
7171
---@param b V
7272
---@return Pair<K, V>
73-
function Pair.new(a, b)
73+
function Pair:new(a, b)
7474
local obj = { _raw = { a, b } }
7575
return setmetatable(obj, _mt)
7676
end

SSV2/includes/classes/Range.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,27 @@
1212
--------------------------------------
1313
-- A simple `Range` utiliy.
1414
---@ignore -- manual docs
15-
---@class Range
15+
---@class Range : Callable<Range>
1616
---@field private m_min number
1717
---@field private m_max number
1818
---@field private m_step number
1919
---@overload fun(from: number, to: number, step?: number): Range
20-
local Range = Callable("Range")
20+
local Range = Callable("Range", { ctor = function(t, ...) return t:new(...) end })
2121

2222
---@param from number
2323
---@param to number
2424
---@param step? number
2525
---@return Range
26-
function Range.new(from, to, step)
26+
function Range:new(from, to, step)
2727
step = step or 1
2828
assert(type(from) == "number" and type(to) == "number", "Range requires numeric from/to")
2929
assert(step ~= 0, "Step cannot be 0")
3030

3131
return setmetatable({
32-
m_min = from,
33-
m_max = to,
32+
m_min = from,
33+
m_max = to,
3434
m_step = step,
35-
---@diagnostic disable-next-line
36-
}, Range)
35+
}, self)
3736
end
3837

3938
---@param value number

SSV2/includes/classes/Rect.lua

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
--------------------------------------
1111
-- Class: Rect
1212
--------------------------------------
13-
---@class Rect
14-
---@field min vec2
15-
---@field max vec2
13+
---@class Rect : Callable<Rect>
14+
---@field public min vec2
15+
---@field public max vec2
1616
---@overload fun(min: vec2, max: vec2) : Rect
17-
local Rect = Callable("Rect")
17+
local Rect = Callable("Rect", {
18+
ctor = function(t, ...)
19+
return t:new(...)
20+
end
21+
})
1822

1923
---@param min vec2
2024
---@param max vec2
2125
---@return Rect
22-
function Rect.new(min, max)
23-
---@diagnostic disable-next-line
24-
return setmetatable({ min = min, max = max }, Rect)
26+
function Rect:new(min, max)
27+
return setmetatable({ min = min, max = max }, self)
2528
end
2629

2730
---@return float

SSV2/includes/classes/Set.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515
---@field protected m_data_type string
1616
---@field new fun(...: T): Set<T>
1717
---@overload fun(...: T): Set<T>
18-
local Set = Callable("Set")
18+
local Set = Callable("Set", {
19+
ctor = function(t, ...)
20+
return t:new(...)
21+
end
22+
})
1923

20-
function Set.new(...)
21-
---@diagnostic disable-next-line: param-type-mismatch
22-
local instance = setmetatable({ m_data = {} }, Set)
24+
function Set:new(...)
25+
local instance = setmetatable({ m_data = {} }, self)
2326
local args = { ... }
2427

2528
if (#args > 0) then

SSV2/includes/data/bsv2_data.lua

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -280,34 +280,34 @@ return {
280280
},
281281

282282
DefaultHeliModels = {
283-
Pair.new("Annihilator", 837858166),
284-
Pair.new("Annihilator Stealth", 295054921),
285-
Pair.new("Maverick", 2634305738),
286-
Pair.new("Police Maverick", 353883353),
287-
Pair.new("Savage", 4212341271),
288-
Pair.new("SuperVolito", 710198397),
289-
Pair.new("SuperVolito Carbon", 2623428164),
290-
Pair.new("Swift Flying Bravo", 3955379698),
291-
Pair.new("Swift Deluxe", 1075432268),
292-
Pair.new("Valkyrie", 2694714877),
293-
Pair.new("Volatus", 2449479409),
283+
Pair("Annihilator", 837858166),
284+
Pair("Annihilator Stealth", 295054921),
285+
Pair("Maverick", 2634305738),
286+
Pair("Police Maverick", 353883353),
287+
Pair("Savage", 4212341271),
288+
Pair("SuperVolito", 710198397),
289+
Pair("SuperVolito Carbon", 2623428164),
290+
Pair("Swift Flying Bravo", 3955379698),
291+
Pair("Swift Deluxe", 1075432268),
292+
Pair("Valkyrie", 2694714877),
293+
Pair("Volatus", 2449479409),
294294
},
295295

296296
HeliPresetDestinations = {
297-
Pair.new("Sandy Shores Helipad", vec3:new(1770.17, 3239.85, 42.1217)),
298-
Pair.new("Paleto Bay Sheriff's Office", vec3:new(-475.02, 5988.46, 31.3367)),
299-
Pair.new("Fort Zancudo Helipad", vec3:new(-1859.4, 2795.65, 32.8066)),
300-
Pair.new("The Diamond Casino Helipad", vec3:new(967.052, 42.1343, 123.127)),
301-
Pair.new("Vinewood Police Station", vec3:new(579.992, 12.3636, 103.234)),
302-
Pair.new("Hawick Agency Helipad", vec3:new(393.284, -66.3109, 124.376)),
303-
Pair.new("Richard's Majestic Helipad", vec3:new(-913.493, -378.444, 137.906)),
304-
Pair.new("Rockford Hills Agency Helipad", vec3:new(-1007.68, -415.99, 80.1686)),
305-
Pair.new("Vespucci Canals Agency Helipad", vec3:new(-1010.76, -756.875, 81.7484)),
306-
Pair.new("Little Seoul Agency Helipad", vec3:new(-597.602, -716.92, 131.04)),
307-
Pair.new("Lombank Office Helipad", vec3:new(-1581.9, -569.51, 116.328)),
308-
Pair.new("Mazebank West Office Helipad", vec3:new(-1391.7, -477.587, 91.2508)),
309-
Pair.new("Mazebank Tower Helipad", vec3:new(-75.2834, -819.323, 326.175)),
310-
Pair.new("Arcadius Office Helipad", vec3:new(-144.582, -593.811, 211.775)),
297+
Pair("Sandy Shores Helipad", vec3:new(1770.17, 3239.85, 42.1217)),
298+
Pair("Paleto Bay Sheriff's Office", vec3:new(-475.02, 5988.46, 31.3367)),
299+
Pair("Fort Zancudo Helipad", vec3:new(-1859.4, 2795.65, 32.8066)),
300+
Pair("The Diamond Casino Helipad", vec3:new(967.052, 42.1343, 123.127)),
301+
Pair("Vinewood Police Station", vec3:new(579.992, 12.3636, 103.234)),
302+
Pair("Hawick Agency Helipad", vec3:new(393.284, -66.3109, 124.376)),
303+
Pair("Richard's Majestic Helipad", vec3:new(-913.493, -378.444, 137.906)),
304+
Pair("Rockford Hills Agency Helipad", vec3:new(-1007.68, -415.99, 80.1686)),
305+
Pair("Vespucci Canals Agency Helipad", vec3:new(-1010.76, -756.875, 81.7484)),
306+
Pair("Little Seoul Agency Helipad", vec3:new(-597.602, -716.92, 131.04)),
307+
Pair("Lombank Office Helipad", vec3:new(-1581.9, -569.51, 116.328)),
308+
Pair("Mazebank West Office Helipad", vec3:new(-1391.7, -477.587, 91.2508)),
309+
Pair("Mazebank Tower Helipad", vec3:new(-75.2834, -819.323, 326.175)),
310+
Pair("Arcadius Office Helipad", vec3:new(-144.582, -593.811, 211.775)),
311311
},
312312
DefaultJetModels = {
313313
{

SSV2/includes/data/theme_library.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
-- * Provide a copy of or a link to the original license (GPL-3.0 or later); see LICENSE.md or <https://www.gnu.org/licenses/>.
88

99

10+
---@diagnostic disable
1011
---@class ThemeLibrary
1112
local ThemeLibrary <const> = {
1213
---@type Theme

SSV2/includes/features/EnemiesFlee.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ function EnemiesFlee:OnClick()
2929
end
3030

3131
Notifier:ShowSuccess("Samurai's Scripts", _T("WRLD_FLEE_ALL_NOTIF"), false, 10.5)
32-
self.m_active = true
33-
---@type Set<handle>
34-
local task_set = Set.new()
35-
local trash = {}
36-
local timer = Timer.new(1e4)
32+
self.m_active = true
33+
local task_set = Set() ---@type Set<handle>
34+
local trash = {}
35+
local timer = Timer.new(1e4)
3736

3837
while (not timer:IsDone()) do
3938
for _, p in ipairs(entities.get_all_peds_as_handles()) do

SSV2/includes/features/self/laser_sights.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ local Set = require("includes.classes.Set")
1919
local LaserSights = setmetatable({}, FeatureBase)
2020
LaserSights.__index = LaserSights
2121

22-
LaserSights.WeaponExclusions = Set.new(
22+
LaserSights.WeaponExclusions = Set(
2323
0x34A67B97,
2424
0xBA536372,
2525
0x184140A1,

SSV2/includes/features/self/miscellaneous.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ local Pair = require("includes.classes.Pair")
2020
local SelfMisc = setmetatable({}, FeatureBase)
2121
SelfMisc.__index = SelfMisc
2222
SelfMisc.m_cell_input = {
23-
Pair.new(172, 1),
24-
Pair.new(173, 2),
25-
Pair.new(174, 3),
26-
Pair.new(175, 4),
27-
Pair.new(176, 5),
28-
Pair.new(177, 5),
29-
Pair.new(178, 5),
30-
Pair.new(179, 5),
31-
Pair.new(180, 1),
32-
Pair.new(181, 2),
23+
Pair(172, 1),
24+
Pair(173, 2),
25+
Pair(174, 3),
26+
Pair(175, 4),
27+
Pair(176, 5),
28+
Pair(177, 5),
29+
Pair(178, 5),
30+
Pair(179, 5),
31+
Pair(180, 1),
32+
Pair(181, 2),
3333
}
3434

3535
---@param ent LocalPlayer

0 commit comments

Comments
 (0)