Skip to content

Commit

Permalink
Sync - Block send custom to host
Browse files Browse the repository at this point in the history
  • Loading branch information
DrNewbie committed Nov 14, 2017
1 parent 055b89f commit 68c1baf
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 24 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,5 @@
function BaseNetworkSession:check_send_outfit(peer)
local FakeSyncFix = function(d1, d2, ...)
local FakeSyncFixOutfit = function(d1, d2, ...)
if tostring(d1) == 'sync_outfit' then
local _blackmarket_outfit = managers.blackmarket:unpack_outfit_from_string(d2)
local _grenade_id = tostring(_blackmarket_outfit.grenade)
Expand All @@ -11,7 +11,7 @@ function BaseNetworkSession:check_send_outfit(peer)
return d1, d2, ...
end
if managers.blackmarket:signature() then
local d1, d2 = FakeSyncFix("sync_outfit", managers.blackmarket:outfit_string())
local d1, d2 = FakeSyncFixOutfit("sync_outfit", managers.blackmarket:outfit_string())
if peer then
peer:send_queued_sync(d1, d2, self:local_peer():outfit_version(), managers.blackmarket:signature())
else
Expand All @@ -21,20 +21,6 @@ function BaseNetworkSession:check_send_outfit(peer)
end

function BaseNetworkSession:send_to_peers_synched(...)
local FakeSyncFix = function(d1, d2, ...)
if tostring(d1) == 'sync_grenades' then
if tweak_data.blackmarket.projectiles[d2].custom then
d2 = tweak_data.blackmarket.projectiles[d2].base_on or 'concussion'
end
end
if tostring(d1) == 'sync_unit_event_id_16' and d2 and d2.name and d2:name() then
local _d2 = tostring(d2:name():key())
if tweak_data.blackmarket.custom_projectiles[_d2] then
d2 = nil
end
end
return d1, d2, ...
end
for peer_id, peer in pairs(self._peers) do
peer:send_queued_sync(FakeSyncFix(...))
end
Expand Down
@@ -0,0 +1,7 @@
function ClientNetworkSession:send_to_host(...)
if self._server_peer then
self._server_peer:send(FakeSyncFix(...))
else
print("[ClientNetworkSession:send_to_host] no host")
end
end
38 changes: 30 additions & 8 deletions assets/mod_overrides/AddOnThrowablesSync/Hooks/networkpeer.lua
@@ -1,18 +1,40 @@
function NetworkPeer:send_queued_sync(...)
local FakeSyncFix = function(d1, d2, ...)
if tostring(d1) == 'sync_grenades' then
if tweak_data.blackmarket.projectiles[d2].custom then
d2 = tweak_data.blackmarket.projectiles[d2].base_on or 'concussion'
end
function FakeSyncFix(d1, d2, d3, d4, d5, ...)
local _d1 = tostring(d1)
if _d1 == 'sync_grenades' then
local projectile_tweak = tweak_data.blackmarket.projectiles[tostring(d2)]
if projectile_tweak and projectile_tweak.custom then
d2 = projectile_tweak.base_on or 'concussion'
end
if tostring(d1) == 'sync_unit_event_id_16' and d2 and d2.name and d2:name() then
elseif _d1 == 'sync_unit_event_id_16' and d2 and d2.name and d2:name() then
local _d2 = tostring(d2:name():key())
if tweak_data.blackmarket.custom_projectiles[_d2] then
d2 = nil
end
elseif _d1 == 'sync_throw_projectile' then
if d2 and d2.name and d2:name() then
local _d2 = tostring(d2:name():key())
if tweak_data.blackmarket.custom_projectiles[_d2] then
d2 = nil
end
end
return d1, d2, ...
if d5 then
local projectile_entry = tostring(tweak_data.blackmarket:get_projectile_name_from_index(d5))
local projectile_tweak = tweak_data.blackmarket.projectiles[projectile_entry]
if projectile_tweak and projectile_tweak.custom then
d5 = tweak_data.blackmarket:get_index_from_projectile_id(tweak_data.blackmarket.projectiles[projectile_entry].base_on or 'concussion')
end
end
elseif _d1 == 'request_throw_projectile' then
local projectile_entry = tostring(tweak_data.blackmarket:get_projectile_name_from_index(d2))
local projectile_tweak = tweak_data.blackmarket.projectiles[projectile_entry]
if projectile_tweak and projectile_tweak.custom then
d2 = tweak_data.blackmarket:get_index_from_projectile_id(tweak_data.blackmarket.projectiles[projectile_entry].base_on or 'concussion')
end
end
return d1, d2, d3, d4, d5, ...
end

function NetworkPeer:send_queued_sync(...)
if not self._ip_verified then
Application:error("[NetworkPeer:send_queued_sync] ip unverified:", ...)
return
Expand Down
1 change: 1 addition & 0 deletions assets/mod_overrides/AddOnThrowablesSync/main.xml
@@ -1,5 +1,6 @@
<mod name="AddOnThrowablesSync" global_key="AddOnThrowablesSync">
<Hooks directory="Hooks">
<hook file="clientnetworksession.lua" source_file="lib/network/base/clientnetworksession"/>
<hook file="blackmarketmanager.lua" source_file="lib/managers/blackmarketmanager"/>
<hook file="basenetworksession.lua" source_file="lib/network/base/basenetworksession"/>
<hook file="networkpeer.lua" source_file="lib/network/base/networkpeer"/>
Expand Down

0 comments on commit 68c1baf

Please sign in to comment.