Merge pull request #157 from Pax1601/156-delete-lua-function-can-cause-player-desync-in-multiplayer

updated Olympus.delete to avoid player desync
This commit is contained in:
Pax1601 2023-03-28 14:27:28 +02:00 committed by GitHub
commit cae9b16d97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -341,8 +341,13 @@ function Olympus.delete(ID, lat, lng)
Olympus.debug("Olympus.delete " .. ID, 2)
local unit = Olympus.getUnitByID(ID)
if unit then
unit:destroy();
Olympus.debug("Olympus.delete completed successfully", 2)
if unit:getPlayerName() then
trigger.action.explosion(unit:getPoint() , 250 ) --consider replacing with forcibly deslotting the player, however this will work for now
Olympus.debug("Olympus.delete completed successfully", 2)
else
unit:destroy(); --works for AI units not players
Olympus.debug("Olympus.delete completed successfully", 2)
end
end
end