@@ -43,6 +43,8 @@ local IssueAggressiveMove = IssueAggressiveMove
4343local IssueGuard = IssueGuard
4444local IssueFerry = IssueFerry
4545
46+ local GetCurrentCommandSourceArmy = SimUtils .GetCurrentCommandSourceArmy
47+
4648-- upvalue categories for performance
4749local CategoriesTransportation = categories .TRANSPORTATION
4850
@@ -64,7 +66,18 @@ function DoCallback(name, data, units)
6466
6567 local timeTaken = GetSystemTimeSecondsOnlyForProfileUse () - start
6668 if (timeTaken > 0.005 ) then
67- SPEW (string.format (" Time to process %s from %d: %f" , name , timeTaken , GetCurrentCommandSource () or - 2 ))
69+ local commandSourceNickname
70+ local commandSourceArmy = GetCurrentCommandSourceArmy ()
71+ if commandSourceArmy then
72+ commandSourceNickname = tostring (ArmyBrains [commandSourceArmy ].Nickname )
73+ else
74+ commandSourceNickname = string.format (" Observer (source %d)" , GetCurrentCommandSource ())
75+ end
76+ SPEW (string.format (" Time to process \" %s\" from %s: %f"
77+ , name
78+ , commandSourceNickname
79+ , timeTaken
80+ ))
6881 end
6982end
7083
640653 -- verify selection
641654 selection = SecureUnits (selection )
642655 if (not selection ) or TableEmpty (selection ) then
643- if (GetFocusArmy () == GetCurrentCommandSource ()) then
656+ if (GetFocusArmy () == GetCurrentCommandSourceArmy ()) then
644657 print (" Unable to interrupt path finding" )
645658 end
646659
650663 -- only apply this to engineers
651664 local engineers = EntityCategoryFilterDown (categories .ENGINEER + categories .COMMAND , selection )
652665 if table .empty (engineers ) then
653- if (GetFocusArmy () == GetCurrentCommandSource ()) then
666+ if (GetFocusArmy () == GetCurrentCommandSourceArmy ()) then
654667 print (" Unable to interrupt path finding" )
655668 end
656669
663676 local commandSourceGuard = CommandSourceGuards [commandSource ]
664677
665678 if commandSourceGuard and commandSourceGuard + 5 >= gameTick then
666- if (GetFocusArmy () == GetCurrentCommandSource ()) then
679+ if (GetFocusArmy () == GetCurrentCommandSourceArmy ()) then
667680 print (" Unable to interrupt path finding" )
668681 end
669682
686699 -- verify selection
687700 selection = SecureUnits (selection )
688701 if (not selection ) or TableEmpty (selection ) then
689- if (GetFocusArmy () == GetCurrentCommandSource ()) then
702+ if (GetFocusArmy () == GetCurrentCommandSourceArmy ()) then
690703 print (" Unable to discharge" )
691704 end
692705
705718 end
706719
707720 if table .empty (unitsWithShields ) then
708- if (GetFocusArmy () == GetCurrentCommandSource ()) then
721+ if (GetFocusArmy () == GetCurrentCommandSourceArmy ()) then
709722 print (" Unable to discharge" )
710723 end
711724
718731 local commandSourceGuard = CommandSourceGuards [commandSource ]
719732
720733 if commandSourceGuard and commandSourceGuard + 5 >= gameTick then
721- if (GetFocusArmy () == GetCurrentCommandSource ()) then
734+ if (GetFocusArmy () == GetCurrentCommandSourceArmy ()) then
722735 print (" Unable to discharge" )
723736 end
724737
837850 --- @param data UIShareableBrushStrokeCallbackMessage
838851 local SyncPainting = function (data )
839852 -- used to determine the color of the painting
840- data .ShareablePainting .PeerName = GetArmyBrain (GetCurrentCommandSource ()).Nickname
853+ data .ShareablePainting .PeerName = GetArmyBrain (GetCurrentCommandSourceArmy ()).Nickname
841854
842855 Sync .SharePaintingBrushStroke = Sync .SharePaintingBrushStroke or {}
843856 table.insert (Sync .SharePaintingBrushStroke , data )
846859 --- @param data UIShareableBrushStrokeCallbackMessage
847860 Callbacks .SharePaintingBrushStroke = function (data )
848861 local focusArmy = GetFocusArmy ()
849- local currentCommandSource = GetCurrentCommandSource ()
862+ local currentCommandSourceArmy = GetCurrentCommandSourceArmy ()
850863
851864 -- spectators are able to see all paintings. We take into account
852865 -- the original focus army because spectators can change focus army
856869 end
857870
858871 -- allies are able to see each others paintings
859- if IsAlly (focusArmy , currentCommandSource ) then
872+ if IsAlly (focusArmy , currentCommandSourceArmy ) then
860873 SyncPainting (data )
861874 return
862875 end
@@ -882,7 +895,6 @@ local function PassesAIAntiCheatCheck()
882895 return ScenarioInfo .GameHasAIs or PassesAntiCheatCheck ()
883896end
884897
885-
886898local SpawnedMeshes = {}
887899
888900local function SpawnUnitMesh (id , x , y , z , pitch , yaw , roll )
@@ -1417,8 +1429,14 @@ end
14171429--- @param data CallbackModeratorEventData
14181430Callbacks .ModeratorEvent = function (data )
14191431 -- show up in the game logs
1420- local brain = GetArmyBrain (GetCurrentCommandSource ())
1421- SPEW (string.format (" Moderator event for %s: %s" , tostring (brain .Nickname ), tostring (data .Message )))
1432+ local commandSourceNickname
1433+ local commandSourceArmy = GetCurrentCommandSourceArmy ()
1434+ if commandSourceArmy then
1435+ commandSourceNickname = tostring (GetArmyBrain (commandSourceArmy ).Nickname )
1436+ else
1437+ commandSourceNickname = string.format (" Observer (source %d)" , GetCurrentCommandSource ())
1438+ end
1439+ SPEW (string.format (" Moderator event for %s: %s" , commandSourceNickname , tostring (data .Message )))
14221440end
14231441
14241442-- #endregion
0 commit comments