forked from FAForever/fa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
162 lines (146 loc) · 3.85 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
-- this imports a path file that is written by Forged Alliance Forever right before it starts the game.
dofile(InitFileDir .. '\\..\\..\\fa_path.lua')
path = {}
blacklist = {
"00_BigMap.scd",
"00_BigMapLEM.scd",
"fa-ladder.scd",
"fa_ladder.scd",
"faladder.scd",
"powerlobby.scd",
"02_sorian_ai_pack.scd",
"03_lobbyenhancement.scd",
"randmap.scd",
"_Eject.scd",
"Eject.scd",
"gaz_ui",
"lobby.nxt",
"faforever.nxt"
}
whitelist =
{
"effects.nx2",
"env.nx2",
"loc.nx2",
"lua.nx2",
"meshes.nx2",
"mods.nx2",
"modules.nx2",
"projectiles.nx2",
"schook.nx2",
"textures.nx2",
"units.nx2",
"murderparty.nxt",
"labwars.nxt",
"units.scd",
"textures.scd",
"skins.scd",
"schook.scd",
"props.scd",
"projectiles.scd",
"objects.scd",
"moholua.scd",
"mohodata.scd",
"mods.scd",
"meshes.scd",
"lua.scd",
"loc_us.scd",
"loc_es.scd",
"loc_fr.scd",
"loc_it.scd",
"loc_de.scd",
"loc_ru.scd",
"env.scd",
"effects.scd",
"editor.scd",
"ambience.scd",
"advanced strategic icons.nxt",
"lobbymanager.scd",
"texturepack.nxt",
"sc_music.scd"
}
local function mount_dir(dir, mountpoint)
table.insert(path, { dir = dir, mountpoint = mountpoint } )
end
local function mount_contents(dir, mountpoint)
LOG('checking ' .. dir)
for _,entry in io.dir(dir .. '\\*') do
if entry != '.' and entry != '..' then
local mp = string.lower(entry)
local safe = true
for i, black in blacklist do
safe = safe and (string.find(mp, black, 1) == nil)
end
if safe then
mp = string.gsub(mp, '[.]scd$', '')
mp = string.gsub(mp, '[.]zip$', '')
mount_dir(dir .. '\\' .. entry, mountpoint .. '/' .. mp)
else
LOG('not safe ' .. entry)
end
end
end
end
local function mount_dir_with_whitelist(dir, glob, mountpoint)
sorted = {}
LOG('checking ' .. dir .. glob)
for _,entry in io.dir(dir .. glob) do
if entry != '.' and entry != '..' then
local mp = string.lower(entry)
local notsafe = true
for i, white in whitelist do
notsafe = notsafe and (string.find(mp, white, 1) == nil)
end
if notsafe then
LOG('not safe ' .. dir .. entry)
else
table.insert(sorted, dir .. entry)
end
end
end
table.sort(sorted)
table.foreach(sorted, function(k,v) mount_dir(v,'/') end)
end
local function mount_dir_with_blacklist(dir, glob, mountpoint)
sorted = {}
LOG('checking ' .. dir .. glob)
for _,entry in io.dir(dir .. glob) do
if entry != '.' and entry != '..' then
local mp = string.lower(entry)
local safe = true
for i, black in blacklist do
safe = safe and (string.find(mp, black, 1) == nil)
end
if safe then
table.insert(sorted, dir .. entry)
else
LOG('not safe ' .. dir .. entry)
end
end
end
table.sort(sorted)
table.foreach(sorted, function(k,v) mount_dir(v,'/') end)
end
-- these are the classic supcom directories. They don't work with accents or other foreign characters in usernames
mount_contents(SHGetFolderPath('PERSONAL') .. 'My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\mods', '/mods')
mount_contents(SHGetFolderPath('PERSONAL') .. 'My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\maps', '/maps')
-- these are the local FAF directories. The My Games ones are only there for people with usernames that don't work in the uppder ones.
mount_contents(InitFileDir .. '\\..\\user\\My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\mods', '/mods')
mount_contents(InitFileDir .. '\\..\\user\\My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\maps', '/maps')
-- InitFileDir = /repo/faf/
mount_dir(InitFileDir, '/')
-- these are using the newly generated path from the dofile() statement at the beginning of this script
mount_dir_with_whitelist(fa_path .. '\\gamedata\\', '*.scd', '/')
mount_dir(fa_path, '/')
hook = {
'/schook'
}
protocols = {
'http',
'https',
'mailto',
'ventrilo',
'teamspeak',
'daap',
'im',
}