forked from FAForever/fa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserSync.lua
More file actions
275 lines (225 loc) · 8.84 KB
/
UserSync.lua
File metadata and controls
275 lines (225 loc) · 8.84 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
-- Here's an opportunity for user side script to examine the Sync table for the new tick
local baseOnSync = OnSync
OnSync = function()
baseOnSync()
import('/lua/UserCamera.lua').ProcessCameraRequests(Sync.CameraRequests)
if Sync.FocusArmyChanged then
import('/lua/ui/game/avatars.lua').FocusArmyChanged()
import('/lua/ui/game/multifunction.lua').FocusArmyChanged()
import('/lua/ui/notify/notify.lua').focusArmyChanged()
end
if Sync.CampaignMode then
import('/lua/ui/campaign/campaignmanager.lua').campaignMode = Sync.CampaignMode
end
if Sync.PlayMFDMovie then
import('/lua/ui/game/missiontext.lua').PlayMFDMovie(Sync.PlayMFDMovie, Sync.VideoText)
end
if Sync.UserUnitEnhancements then
import('/lua/enhancementcommon.lua').SetEnhancementTable(Sync.UserUnitEnhancements)
end
if Sync.ObjectivesTable and next(Sync.ObjectivesTable) then
import('/lua/ui/game/objectives2.lua').AddObjectives(Sync.ObjectivesTable)
end
if Sync.ObjectivesUpdateTable and next(Sync.ObjectivesUpdateTable) then
import('/lua/ui/game/objectives2.lua').UpdateObjectivesTable(Sync.ObjectivesUpdateTable)
end
if Sync.ObjectiveTimer then
if Sync.ObjectiveTimer != false then
import('/lua/ui/game/timer.lua').SetTimer(Sync.ObjectiveTimer)
else
import('/lua/ui/game/timer.lua').ResetTimer()
end
end
--Play Voices
if not import('/lua/ui/game/missiontext.lua').IsHeadPlaying() then
for k, v in Sync.Voice do
PlayVoice(Sound{ Bank=v.Bank, Cue=v.Cue }, true)
end
end
if Sync.AddTransmissions then
import('/lua/ui/game/transmissionlog.lua').OnPostLoad(Sync.AddTransmissions)
end
if Sync.EnhanceRestrict then
import('/lua/enhancementcommon.lua').RestrictList(Sync.EnhanceRestrict)
end
if Sync.Restrictions then
import('/lua/game.lua').SetRestrictions(Sync.Restrictions)
end
if Sync.NISVideo then
import('/lua/ui/game/missiontext.lua').PlayNIS(Sync.NISVideo)
end
if Sync.EndGameMovie then
import('/lua/ui/game/missiontext.lua').PlayEndGameMovie(Sync.EndGameMovie)
end
if Sync.HelpPrompt then
import('/lua/ui/game/helptext.lua').AddHelpTextPrompt(Sync.HelpPrompt)
end
if Sync.MPTaunt then
local msg = {}
msg.tauntid = Sync.MPTaunt[1]
msg.taunthead = Sync.MPTaunt[2]
SessionSendChatMessage(msg)
end
if Sync.Ping then
import('/lua/ui/game/ping.lua').DisplayPing(Sync.Ping)
end
if Sync.MaxPingMarkers then
import('/lua/ui/game/ping.lua').MaxMarkers = Sync.MaxPingMarkers
end
if not table.empty(Sync.Score) then
import('/lua/ui/game/score.lua').currentScores = Sync.Score
if not Sync.FullScoreSync then
import('/lua/ui/game/scoreaccum.lua').UpdateScoreData(Sync.Score)
end
end
if Sync.FullScoreSync then
if not table.empty(Sync.ScoreAccum) then
import('/lua/ui/game/scoreaccum.lua').OnFullSync(Sync.ScoreAccum)
end
end
if not import("/lua/ui/dialogs/eschandler.lua").isExiting then
for _, gameResult in Sync.GameResult do
local armyIndex, result = unpack(gameResult)
LOG(string.format('Sending game result: %i %s', armyIndex, result))
GpgNetSend('GameResult', armyIndex, result)
import('/lua/ui/game/gameresult.lua').DoGameResult(armyIndex, result)
end
end
if Sync.StatsToSend then
local json = import('/lua/system/dkson.lua').json.encode({ stats = Sync.StatsToSend })
LOG('Sending stats: '..json)
GpgNetSend('JsonStats', json)
Sync.StatsToSend = nil
end
if Sync.PausedBy then
if not PreviousSync.PausedBy then
import('/lua/ui/game/gamemain.lua').OnPause(Sync.PausedBy, Sync.TimeoutsRemaining)
end
else
if PreviousSync.PausedBy then
import('/lua/ui/game/gamemain.lua').OnResume()
end
end
if Sync.Paused != PreviousSync.Paused then
import("/lua/ui/game/gamemain.lua").OnPause(Sync.Paused);
end
if Sync.PlayerQueries then
import('/lua/UserPlayerQuery.lua').ProcessQueries(Sync.PlayerQueries)
end
if Sync.QueryResults then
import('/lua/UserPlayerQuery.lua').ProcessQueryResults(Sync.QueryResults)
end
if Sync.OperationComplete then
if Sync.OperationComplete.success then
GpgNetSend('OperationComplete', Sync.OperationComplete.allPrimary, Sync.OperationComplete.allSecondary, GetGameTime())
end
import('/lua/ui/campaign/campaignmanager.lua').OperationVictory(Sync.OperationComplete)
end
if Sync.Cheaters then
# Ted, this is where you would hook in better cheater reporting.
local names = ''
local isare = LOC('<LOC cheating_fragment_0000>is')
local srcs = SessionGetCommandSourceNames()
for k,v in ipairs(Sync.Cheaters) do
if names != '' then
names = names .. ', '
isare = LOC('<LOC cheating_fragment_0001>are')
end
names = names .. (srcs[v] or '???')
end
local msg = names .. ' ' .. isare
if Sync.Cheaters.CheatsEnabled then
msg = msg .. LOC('<LOC cheating_fragment_0002> cheating!')
else
msg = msg .. LOC('<LOC cheating_fragment_0003> trying to cheat!')
end
print(msg)
end
if Sync.DiplomacyAction then
import('/lua/ui/game/diplomacy.lua').ActionHandler(Sync.DiplomacyAction)
end
if Sync.DiplomacyAnnouncement then
import('/lua/ui/game/diplomacy.lua').AnnouncementHandler(Sync.DiplomacyAnnouncement)
end
if Sync.LockInput then
import('/lua/ui/game/worldview.lua').LockInput()
end
if Sync.UnlockInput then
import('/lua/ui/game/worldview.lua').UnlockInput()
end
if Sync.NISMode then
import('/lua/ui/game/gamemain.lua').NISMode(Sync.NISMode)
end
if Sync.RequestPlayerFaction then
import('/lua/ui/game/factionselect.lua').RequestPlayerFaction()
end
if Sync.PrintText then
for _, textData in Sync.PrintText do
local data = textData
if type(Sync.PrintText) == 'string' then
data = {text = Sync.PrintText, size = 14, color = 'ffffffff', duration = 5, location = 'center'}
end
import('/lua/ui/game/textdisplay.lua').PrintToScreen(data)
end
end
if Sync.FloatingEntityText then
for _, textData in Sync.FloatingEntityText do
import('/lua/ui/game/unittext.lua').FloatingEntityText(textData)
end
end
if Sync.StartCountdown then
for _, textData in Sync.StartCountdown do
import('/lua/ui/game/unittext.lua').StartCountdown(textData)
end
end
if Sync.CancelCountdown then
for _, textData in Sync.CancelCountdown do
import('/lua/ui/game/unittext.lua').CancelCountdown(textData)
end
end
if Sync.AddPingGroups then
import('/lua/ui/game/objectives2.lua').AddPingGroups(Sync.AddPingGroups)
end
if Sync.RemovePingGroups then
import('/lua/ui/game/objectives2.lua').RemovePingGroups(Sync.RemovePingGroups)
end
if Sync.SetAlliedVictory != nil then
import('/lua/ui/game/diplomacy.lua').SetAlliedVictory(Sync.SetAlliedVictory)
end
if Sync.HighlightUIPanel then
import('/lua/ui/game/tutorial.lua').HighlightPanels(Sync.HighlightUIPanel)
end
if Sync.AddCameraMarkers then
import('/lua/ui/game/tutorial.lua').AddCameraMarkers(Sync.AddCameraMarkers)
end
if Sync.RemoveCameraMarkers then
import('/lua/ui/game/tutorial.lua').RemoveCameraMarkers(Sync.RemoveCameraMarkers)
end
if Sync.EndDemo then
import('/lua/ui/game/demo.lua').OnDemoEnd()
end
if Sync.CreateSimDialogue then
import('/lua/ui/game/simdialogue.lua').CreateSimDialogue(Sync.CreateSimDialogue)
end
if Sync.SetButtonDisabled then
import('/lua/ui/game/simdialogue.lua').SetButtonDisabled(Sync.SetButtonDisabled)
end
if Sync.UpdatePosition then
import('/lua/ui/game/simdialogue.lua').UpdatePosition(Sync.UpdatePosition)
end
if Sync.UpdateButtonText then
import('/lua/ui/game/simdialogue.lua').UpdateButtonText(Sync.UpdateButtonText)
end
if Sync.SetDialogueText then
import('/lua/ui/game/simdialogue.lua').SetDialogueText(Sync.SetDialogueText)
end
if Sync.DestroyDialogue then
import('/lua/ui/game/simdialogue.lua').DestroyDialogue(Sync.DestroyDialogue)
end
if Sync.IsSavedGame == true then
import('/lua/ui/game/gamemain.lua').IsSavedGame = true
end
if Sync.ChangeCameraZoom != nil then
import('/lua/ui/game/gamemain.lua').SimChangeCameraZoom(Sync.ChangeCameraZoom)
end
end