forked from FAForever/fa
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
Latest commit
201 lines (186 loc) · 6.46 KB
/
Copy pathinit.lua
File metadata and controls
201 lines (186 loc) · 6.46 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
-- 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.nx5",
"env.nx5",
"etc.nx5",
"loc.nx5",
"lua.nx5",
"meshes.nx5",
"mods.nx5",
"projectiles.nx5",
"schook.nx5",
"textures.nx5",
"units.nx5",
"props.nx5",
"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_v105.scd",
"texturepack.nxt",
"sc_music.scd"
}
localfunctionmount_dir(dir, mountpoint)
table.insert(path, { dir=dir, mountpoint=mountpoint })
end
localfunctionmount_contents(dir, mountpoint)
LOG('checking ' ..dir)
for_,entryinio.dir(dir..'\\*') do
ifentry!='.' andentry!='..' then
localmp=string.lower(entry)
localsafe=true
fori, blackinblacklistdo
safe=safeand (string.find(mp, black, 1) ==nil)
end
ifsafethen
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
localfunctionmount_dir_with_whitelist(dir, glob, mountpoint)
sorted= {}
LOG('checking ' ..dir..glob)
for_,entryinio.dir(dir..glob) do
ifentry!='.' andentry!='..' then
localmp=string.lower(entry)
localnotsafe=true
fori, whiteinwhitelistdo
notsafe=notsafeand (string.find(mp, white, 1) ==nil)
end
ifnotsafethen
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
localfunctionmount_dir_with_blacklist(dir, glob, mountpoint)
sorted= {}
LOG('checking ' ..dir..glob)
for_,entryinio.dir(dir..glob) do
ifentry!='.' andentry!='..' then
localmp=string.lower(entry)
localsafe=true
fori, blackinblacklistdo
safe=safeand (string.find(mp, black, 1) ==nil)
end
ifsafethen
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
-- Begin map mounting section
-- This section mounts movies and sounds from maps, essential for custom missions and scripted maps
localfunctionmount_map_dir(dir, glob, mountpoint)
LOG('mounting maps from: '..dir)
mount_contents(dir, mountpoint)
for_, mapinio.dir(dir..glob) do
for_, folderinio.dir(dir..'\\'..map..'\\**') do
iffolder=='movies' then
LOG('Found map movies in: '..map)
mount_dir(dir..map..'\\movies', '/movies')
elseiffolder=='sounds' then
LOG('Found map sounds in: '..map)
mount_dir(dir..map..'\\sounds', '/sounds')
end
end
end
end
mount_map_dir(SHGetFolderPath('PERSONAL') ..'My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\maps\\', '**', '/maps')
mount_map_dir(InitFileDir..'\\..\\user\\My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\maps\\', '**', '/maps')
-- Begin mod mounting section
-- This section mounts sounds from the mods directory to allow mods to add custom sounds to the game
functionmount_mod_sounds(MODFOLDER)
-- searching for mods inside the modfolder
for_,modinio.dir(MODFOLDER..'\\*.*') do
-- do we have a true directory ?
ifmod!='.' andmod!='..' then
-- searching for sounds inside mod folder
for_,folderinio.dir(MODFOLDER..'\\'..mod..'\\*.*') do
-- if we found a folder named sounds then mount it
iffolder=='sounds' then
LOG('Found mod sounds in: '..mod)
mount_dir(MODFOLDER..'\\'..mod..'\\sounds', '/sounds')
break
end
end
end
end
end
mount_mod_sounds(SHGetFolderPath('PERSONAL') ..'My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\mods')
mount_mod_sounds(InitFileDir..'\\..\\user\\My Games\\Gas Powered Games\\Supreme Commander Forged Alliance\\mods')
-- 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')
mount_dir_with_whitelist(InitFileDir..'\\..\\gamedata\\', '*.nxt', '/')
mount_dir_with_whitelist(InitFileDir..'\\..\\gamedata\\', '*.nx5', '/')
-- 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',
}