-
Notifications
You must be signed in to change notification settings - Fork 645
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
Use PacketList directly when sending #6831
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logically seems fine, I'd just like it to be made as clear and obvious about what's going on at every step as possible
src/map/entities/charentity.cpp
Outdated
@@ -439,40 +439,34 @@ void CCharEntity::pushPacket(std::unique_ptr<CBasicPacket>&& packet) | |||
void CCharEntity::updateCharPacket(CCharEntity* PChar, ENTITYUPDATE type, uint8 updatemask) | |||
{ | |||
auto existing = PendingCharPackets.find(PChar->id); | |||
if (existing == PendingCharPackets.end()) | |||
if (existing == PendingCharPackets.end() || !existing->second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this logical block quite hard to reason about, can you break these up even if it ends up with nested conditions?
I think it would also help to rename existing to itr, and break out conditions like:
const bool hasPendingPacket = itr != PendingCharPackets.end();
and to not use the itr pair directly, but to use:
auto& pendingPacket = existing->second;
pendingPacket ->updateWith...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the logic here, hopefully more clear.
src/map/entities/charentity.h
Outdated
@@ -542,8 +541,7 @@ class CCharEntity : public CBattleEntity | |||
|
|||
CItemEquipment* getEquip(SLOTTYPE slot); | |||
|
|||
// TODO: Don't use raw ptrs for this, but don't duplicate whole packets with unique_ptr either. | |||
CBasicPacket* PendingPositionPacket = nullptr; | |||
std::deque<std::unique_ptr<CBasicPacket>> PacketList; // The list of packets to be sent to the character during the next network cycle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of making this public, can you keep it private and access it with: auto getPacketList() -> std::deque<std::unique_ptr<CBasicPacket>>&
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, made it const too.
src/map/map.cpp
Outdated
|
||
while (!packetList.empty() && *buffsize + packetList.front()->getSize() < MAX_BUFFER_SIZE && static_cast<size_t>(packets) < PacketCount) | ||
while (!PChar->PacketList.empty() && *buffsize + PChar->PacketList.front()->getSize() < MAX_BUFFER_SIZE && static_cast<size_t>(packets) < PacketCount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isPacketListEmpty
This seems to cause a very game breaking bug if items get out of sync between mog house and player inventory, gil etc. Would you take a look at the issue I posted and see what you think? |
Please stop commenting on closed PRs, it's very hard for us to track. Open new issues and link prs you want to talk about |
I affirm:
What does this pull request do?
Couple edge case fixes if a pending packet ends up being null. Mainly though this makes it so we use the PacketList directly when preparing packets to send instead of making a copy and using that. We currently make a copy of the packet list, process those copies, then delete the real packets. This apparently causes some sync issues (#6829) that should be fixed now.
I'm not sure why exactly this issue seems to be consistent, so this may require some further review, but this seems to fix it.
Steps to test these changes
Log in with 2 characters, go to the same zone, both characters can see each other.