Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Passive Abilities #236

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion cuwo/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ def on_shoot_packet(self, packet):

def on_passive_packet(self, packet):
self.world.add_passive(packet)
# we need to remember who sent each passive so we don't send them back
self.server.received_passives[packet] = self
self.server.update_packet.passive_actions.append(packet)

def on_discover_packet(self, packet):
Expand Down Expand Up @@ -515,6 +517,7 @@ def __init__(self, loop, config):
# game-related
self.update_packet = packets.ServerUpdate()
self.update_packet.reset()
self.received_passives = dict()

self.connections = set()
self.players = MultikeyDict()
Expand Down Expand Up @@ -728,7 +731,17 @@ def send_update(self):
for chunk in self.updated_chunks:
chunk.on_update(update_packet)
if not update_packet.is_empty():
self.broadcast_packet(update_packet)
# passive_actions will be modified for each player, so we must keep a copy of the original
old_passives = update_packet.passive_actions
# send update to each player
for player in self.players.values():
# generate only passives actions which were not originally sent by this player
update_packet.passive_actions = [x for x in old_passives
if self.received_passives.get(x, None) != player]
data = packets.write_packet(update_packet)
player.send_data(data)

self.received_passives.clear()
update_packet.reset()

# reset drop times
Expand Down