Skip to content

Commit 9511f48

Browse files
authored
fix: Restore file functionality after Lua Sandboxing (#10)
* chore: bump server version - new os.createdir function requires latest server version (12966) - Start work on refactoring * chore: Update server print formatting * refactor: Update and move file io functions * refactor: Update dat151 tag names Compatibility update for Codewalker dev47 * chore: minor variable renaming * refactor: Update room labels * fix: Fix write success logic * docs: Update docs * chore: Add some identifying comments
1 parent 25bb522 commit 9511f48

23 files changed

+2114
-1777
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ Further build / development guidance can be viewed [here](./docs/development-gui
7676
- Closing the UI will cache your changes locally automatically, **no need to generate the files everytime you close it**
7777
- The resource should detect which room you are currently in and default to that room when you open the UI
7878
- *Note* - You can press and hold `right mouse button` with the UI open to be able to move around
79-
- Try your best to not leave the MLO while doing so as this can lead to unaccounted for issues during file saving / generation
79+
- Try your best to not leave the MLO while doing so as this can lead to undefined behavior during file saving / generation
8080
5. Press the `Generate Audio Occlusion Files` and wait for confirmation of generated XML file(s)
8181
6. Use [CodeWalker](https://github.com/dexyfex/CodeWalker) to convert the XML files to the proper GTAV format
82+
- *Note* - CodeWalker Compatibility
83+
- For mlotool v1.1.2 and earlier -> Use CodeWalker dev 46
84+
- For mlotool v1.2.0 and later -> Use CodeWalker dev 47 or higher
8285
7. Move the converted XML files to a FiveM map resource
8386
8. Restart your FiveM server and enjoy occluded audio goodness
8487

client/classes/room.lua

+28
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,47 @@ function Room.new(interiodId, nameHash, proxyHash, roomIndex)
1616
--#region Dat151 Fields
1717
room.occlRoomName = ('%s_%s'):format(nameHash, room.name)
1818
room.flags = '0xAAAAAAAA'
19+
20+
-- AmbientZone
1921
room.zone = ''
22+
23+
-- InteriorType
2024
room.unk02 = 0
25+
26+
-- ReverbSmall
2127
room.unk03 = 0.35
28+
29+
-- ReverbMedium
2230
room.reverb = 0
31+
32+
-- ReverbLarge
2333
room.echo = 0
34+
35+
-- RoomToneSound
2436
room.sound = 'null_sound'
37+
38+
-- RainType
2539
room.unk07 = 0
40+
41+
-- ExteriorAudibility
2642
room.unk08 = 0
43+
44+
-- RoomOcclusionDamping
2745
room.unk09 = 0
46+
47+
-- NonMarkedPortalOcclusion
2848
room.unk10 = 0.7
49+
50+
-- DistanceFromPortalForOcclusion
2951
room.unk11 = 0
52+
53+
-- DistanceFromPortalFadeDistance
3054
room.unk12 = 50
55+
56+
-- WeaponMetrics
3157
room.unk13 = ''
58+
59+
-- InteriorWallaSoundSet
3260
room.soundSet = 'hash_D4855127'
3361
--#endregion
3462

client/client.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ function GenerateMLOFiles(mloData, generateAO, generateDat151, debug)
2525
local mlo = UpdateMLOData(mloData)
2626

2727
if mlo then
28-
local saveFileName = mlo.saveName ~= '' and mlo.saveName or { mlo.nameHash, mlo.name }
28+
local saveDirName = mlo.saveName ~= '' and mlo.saveName or { mlo.nameHash, mlo.name }
2929
if generateAO then
3030
local paths, pathKeys = MLO.generatePaths(mlo)
3131
local aoFileName = tostring(mlo.uintProxyHash)
3232
local aoFileType = 'ymt.pso.xml'
3333
local ymtData = EncodeAudioOcclusion(mlo, paths, pathKeys)
34-
TriggerLatentServerEvent('ht_mlotool:outputResultFile', 100000, saveFileName, aoFileName, aoFileType, ymtData, debug)
34+
TriggerLatentServerEvent('ht_mlotool:outputResultFile', 100000, saveDirName, aoFileName, aoFileType, ymtData, debug)
3535
end
3636

3737
if generateDat151 then
@@ -48,7 +48,7 @@ function GenerateMLOFiles(mloData, generateAO, generateDat151, debug)
4848
local datFileName = ('%s_game'):format(mloName)
4949
local datFileType = 'dat151.rel.xml'
5050
local dat151Data = EncodeDat151(mlo)
51-
TriggerLatentServerEvent('ht_mlotool:outputResultFile', 100000, saveFileName, datFileName, datFileType, dat151Data, debug)
51+
TriggerLatentServerEvent('ht_mlotool:outputResultFile', 100000, saveDirName, datFileName, datFileType, dat151Data, debug)
5252
end
5353

5454
TriggerLatentServerEvent('ht_mlotool:saveMLOData', 100000, mlo)

client/encoders/dat151.lua

+21-20
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ function EncodeDat151(mlo)
33
{
44
tagName = 'Dat151',
55
content = {
6-
{ tagName = 'Version', attr = { value = '35636732' } },
6+
{ tagName = 'Version', attr = { value = '45897013' } },
77
{
88
tagName = 'Items',
99
content = {
1010
{
1111
tagName = 'Item',
12-
attr = { type = 'Interior', ntOffset = 0 },
12+
attr = { type = 'InteriorSettings', ntOffset = 0 },
1313
content = {
1414
{ tagName = 'Name', value = mlo.name },
1515
{ tagName = 'Flags', attr = { value = '0xAAAAA044' } },
16-
{ tagName = 'Walla', value = '0xD4855127' },
17-
{ tagName = 'Tunnel', value = '0x00000000' },
16+
{ tagName = 'InteriorWallaSoundSet', value = '0xD4855127' },
17+
{ tagName = 'InteriorReflections', value = '0x00000000' },
1818
{ tagName = 'Rooms', content = {} }
1919
}
2020
}
@@ -36,23 +36,24 @@ function EncodeDat151(mlo)
3636
tagName = 'Item',
3737
attr = { type = 'InteriorRoom', ntOffset = 0 },
3838
content = {
39+
-- * These are the names that Codewalker is expecting as of release dev47
3940
{ tagName = 'Name', value = occlRoomName },
40-
{ tagName = 'Flags0', attr = { value = room.flags } },
41-
{ tagName = 'MloRoom', value = string.lower(room.name) },
42-
{ tagName = 'Zone', value = (room.zone ~= '' and room.zone or nil) },
43-
{ tagName = 'Unk02', attr = { value = room.unk02 } },
44-
{ tagName = 'Unk03', attr = { value = room.unk03 } },
45-
{ tagName = 'Reverb', attr = { value = room.reverb } },
46-
{ tagName = 'Echo', attr = { value = room.echo } },
47-
{ tagName = 'Sound', value = room.sound },
48-
{ tagName = 'Unk07', attr = { value = room.unk07 } },
49-
{ tagName = 'Unk08', attr = { value = room.unk08 } },
50-
{ tagName = 'Unk09', attr = { value = room.unk09 } },
51-
{ tagName = 'Unk10', attr = { value = room.unk10 } },
52-
{ tagName = 'Unk11', attr = { value = room.unk11 } },
53-
{ tagName = 'Unk12', attr = { value = room.unk12 } },
54-
{ tagName = 'Unk13', value = (room.unk13 ~= '' and room.unk13 or nil) },
55-
{ tagName = 'SoundSet', value = room.soundSet }
41+
{ tagName = 'Flags', attr = { value = room.flags } },
42+
{ tagName = 'RoomName', value = string.lower(room.name) },
43+
{ tagName = 'AmbientZone', value = (room.zone ~= '' and room.zone or nil) },
44+
{ tagName = 'InteriorType', attr = { value = room.unk02 } },
45+
{ tagName = 'ReverbSmall', attr = { value = room.unk03 } },
46+
{ tagName = 'ReverbMedium', attr = { value = room.reverb } },
47+
{ tagName = 'ReverbLarge', attr = { value = room.echo } },
48+
{ tagName = 'RoomToneSound', value = room.sound },
49+
{ tagName = 'RainType', attr = { value = room.unk07 } },
50+
{ tagName = 'ExteriorAudibility', attr = { value = room.unk08 } },
51+
{ tagName = 'RoomOcclusionDamping', attr = { value = room.unk09 } },
52+
{ tagName = 'NonMarkedPortalOcclusion', attr = { value = room.unk10 } },
53+
{ tagName = 'DistanceFromPortalForOcclusion', attr = { value = room.unk11 } },
54+
{ tagName = 'DistanceFromPortalFadeDistance', attr = { value = room.unk12 } },
55+
{ tagName = 'WeaponMetrics', value = (room.unk13 ~= '' and room.unk13 or nil) },
56+
{ tagName = 'InteriorWallaSoundSet', value = room.soundSet }
5657
}
5758
}
5859

docs/codewalker-usage-guide.md

+9
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,12 @@ This is meant as a guide for the post-generation import steps that will take the
2525

2626
<img src="./images/codewalker/drag_n_drop_zone.png" width=500 />
2727
6. You can now use these files as described in steps 10 and 11 of the [Usage Guide](./usage-guide.md#usage-steps)
28+
29+
## Version Support
30+
The following is some simple guidance
31+
32+
### MLO Tool v1.2.0 and later
33+
- Use [CodeWalker dev 47 or later](https://discord.com/channels/329138547833700352/351357358460370944/1270905539777269762)
34+
35+
### MLO Tool v1.1.2 and ealier
36+
- Use [CodeWalker dev 46](https://discord.com/channels/329138547833700352/351357358460370944/1148210493958398073)

docs/images/rooms_tab.png

130 KB
Loading

docs/images/rooms_tab_marked.png

130 KB
Loading

fxmanifest.lua

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ client_scripts {
2222
'client/**/*.lua',
2323
}
2424

25-
server_script 'server/server.lua'
25+
server_scripts {
26+
'server/**/*.lua'
27+
}
2628

2729
ox_libs {
2830
'locale'
@@ -37,5 +39,6 @@ files {
3739
ui_page 'web/build/index.html'
3840

3941
dependencies {
42+
'/server:12966',
4043
'ox_lib'
4144
}

0 commit comments

Comments
 (0)