This repository has been archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GlobalSettings MP bugfix and AutoRepairSetting (#6580)
* GlobalSettings MP bugfix and AutoRepairSetting - added AutoRepairSetting to enable automatic repair while driving - fixes GlobalSettings sync in MP * typo autodrive fix Co-authored-by: Peter Vaiko <[email protected]>
- Loading branch information
1 parent
feeaf35
commit 279d42c
Showing
27 changed files
with
232 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
GlobalSettingsEvent = {}; | ||
local GlobalSettingsEvent_mt = Class(GlobalSettingsEvent, Event); | ||
InitEventClass(GlobalSettingsEvent, "GlobalSettingsEvent"); | ||
function GlobalSettingsEvent:emptyNew() | ||
local self = Event:new(GlobalSettingsEvent_mt); | ||
self.className = "GlobalSettingsEvent"; | ||
return self; | ||
end | ||
|
||
function GlobalSettingsEvent:new(parentName, name, value) | ||
courseplay:debug(string.format("GlobalSettingsEvent:new %s, %s, %s)", tostring(parentName),tostring(name), tostring(value)), 5) | ||
self.parentName = parentName | ||
self.name = name | ||
self.value = value; | ||
return self; | ||
end | ||
|
||
function GlobalSettingsEvent:writeStream(streamId, connection) | ||
courseplay:debug("SettingsListEvent:writeStream()",5) | ||
courseplay:debug(('parentName:%s, name:%s, value:%s'):format(tostring(self.parentName), tostring(self.name), tostring(self.value)), 5); | ||
|
||
streamWriteString(streamId, self.parentName) | ||
streamWriteString(streamId, self.name) | ||
streamWriteInt32(streamId, self.value) | ||
end | ||
|
||
function GlobalSettingsEvent:readStream(streamId, connection) | ||
self.parentName = streamReadString(streamId) | ||
self.name = streamReadString(streamId) | ||
self.value = streamReadInt32(streamId) | ||
|
||
courseplay:debug("GlobalSettingsEvent:readStream()",5) | ||
courseplay:debug(('parentName:%s, name:%s, value:%s'):format(tostring(self.parentName), tostring(self.name), tostring(self.value)), 5); | ||
|
||
self:run(connection) | ||
end | ||
|
||
function GlobalSettingsEvent:run(connection) | ||
courseplay:debug("GlobalSettingsEvent:run()",5) | ||
courseplay:debug(('parentName:%s, name:%s, value:%s'):format(tostring(self.parentName), tostring(self.name), tostring(self.value)), 5); | ||
courseplay[self.parentName][self.name]:setFromNetwork(self.value) | ||
|
||
if not connection:getIsServer() then | ||
courseplay:debug("broadcast GlobalSettingsEvent",5) | ||
g_server:broadcastEvent(GlobalSettingsEvent:new(self.parentName, self.name, self.value), nil, connection); | ||
end; | ||
end | ||
|
||
function GlobalSettingsEvent.sendEvent(parentName, name, value) | ||
if g_server == nil then | ||
courseplay:debug("send GlobalSettingsEvent", 5) | ||
courseplay:debug(('parentName:%s, name:%s, value:%s'):format(tostring(parentName), tostring(name), tostring(value)), 5); | ||
g_client:getServerConnection():sendEvent(GlobalSettingsEvent:new(parentName, name, value)) | ||
else | ||
courseplay:debug("broadcast GlobalSettingsEvent", 5) | ||
courseplay:debug(('parentName:%s, name:%s, value:%s'):format(tostring(parentName), tostring(name), tostring(value)), 5); | ||
g_server:broadcastEvent(GlobalSettingsEvent:new(parentName, name, value)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.