Skip to content

Commit 91589b1

Browse files
More cleanup
1 parent 02a5632 commit 91589b1

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/Chunking.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,11 @@ static void sendAroundPacket(const EntityRef recipient, std::vector<std::vector<
9595
for (size_t i = 0; i < count; i++) {
9696
data[i] = slice[i];
9797
}
98-
recipient.sock->sendPacket(pktBuf, packetId, 4 + (count * sizeof(T)));
98+
recipient.sock->sendPacket(pktBuf, packetId, sizeof(int32_t) + (count * sizeof(T)));
9999
}
100100
}
101101

102-
template<class T>
103-
static void sendAroundDelPacket(const EntityRef recipient, std::vector<std::vector<T>>& slices, bool isTransportation, uint32_t packetId) {
102+
static void sendAroundDelPacket(const EntityRef recipient, std::vector<std::vector<int32_t>>& slices, bool isTransportation, uint32_t packetId) {
104103
assert(recipient.kind == EntityKind::PLAYER);
105104

106105
size_t maxCnt = MAX_IDS_PER_AROUND_DEL;
@@ -113,20 +112,22 @@ static void sendAroundDelPacket(const EntityRef recipient, std::vector<std::vect
113112
int count = slice.size();
114113
assert(count <= maxCnt);
115114

116-
T* data;
115+
size_t baseSize;
117116
if (isTransportation) {
118-
*((int32_t*)pktBuf) = 3; // eTT
119-
*((int32_t*)pktBuf + sizeof(int32_t)) = count;
120-
data = (T*)(pktBuf + sizeof(int32_t) + sizeof(int32_t));
117+
sP_FE2CL_AROUND_DEL_TRANSPORTATION* pkt = (sP_FE2CL_AROUND_DEL_TRANSPORTATION*)pktBuf;
118+
pkt->eTT = 3;
119+
pkt->iCnt = count;
120+
baseSize = sizeof(sP_FE2CL_AROUND_DEL_TRANSPORTATION);
121121
} else {
122122
*((int32_t*)pktBuf) = count;
123-
data = (T*)(pktBuf + sizeof(int32_t));
123+
baseSize = sizeof(int32_t);
124124
}
125+
int32_t* ids = (int32_t*)(pktBuf + baseSize);
125126

126127
for (size_t i = 0; i < count; i++) {
127-
data[i] = slice[i];
128+
ids[i] = slice[i];
128129
}
129-
recipient.sock->sendPacket(pktBuf, packetId, isTransportation ? 8 : 4 + (count * sizeof(T)));
130+
recipient.sock->sendPacket(pktBuf, packetId, baseSize + (count * sizeof(int32_t)));
130131
}
131132
}
132133

0 commit comments

Comments
 (0)