Skip to content

Commit

Permalink
don't reuse message if altering (#10621)
Browse files Browse the repository at this point in the history
Don't reuse message because of race condition
  • Loading branch information
Raycoms committed Jan 29, 2025
1 parent e8d7f7c commit e9d793a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,9 @@ public void sendColonyViewPackets()
}
players.addAll(newSubscribers);

final ColonyViewMessage message = new ColonyViewMessage(colony, colonyFriendlyByteBuf);
for (ServerPlayer player : players)
{
message.setIsNewSubscription(newSubscribers.contains(player));
Network.getNetwork().sendToPlayer(message, player);
Network.getNetwork().sendToPlayer(new ColonyViewMessage(colony, colonyFriendlyByteBuf, newSubscribers.contains(player)), player);
}
}
colony.getRequestManager().setDirty(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,11 @@ public ColonyViewMessage()
* @param colony Colony of the view to update.
* @param buf the bytebuffer.
*/
public ColonyViewMessage(@NotNull final Colony colony, final FriendlyByteBuf buf)
public ColonyViewMessage(@NotNull final Colony colony, final FriendlyByteBuf buf, boolean newSubscription)
{
this.colonyId = colony.getID();
this.dim = colony.getDimension();
this.colonyBuffer = new FriendlyByteBuf(buf.copy());
}

/**
* Set whether the message is a new subscription(full view)
*
* @param newSubscription
*/
public void setIsNewSubscription(boolean newSubscription)
{
isNewSubscription = newSubscription;
}

Expand Down

0 comments on commit e9d793a

Please sign in to comment.