diff --git a/Source/EntityInit.cpp b/Source/EntityInit.cpp index 0142d6468..3ce175a55 100644 --- a/Source/EntityInit.cpp +++ b/Source/EntityInit.cpp @@ -99,7 +99,7 @@ std::vector CGameMode::BuildActorEntryPacket(CGameActor* actor, std::uint1 std::string name = this->nameCard.Name(actor->render.accountId); if (actor->render.state == 1) { - packet.resize(sizeof(ActorMoveEntryPacket)); + packet.resize(sizeof(ActorMoveEntryPacket), 0); ActorMoveEntryPacket* entry = reinterpret_cast(packet.data()); entry->hp = actor->GetGaugeCurrent(); entry->maxHp = actor->GetGaugeMaximum(); @@ -113,24 +113,24 @@ std::vector CGameMode::BuildActorEntryPacket(CGameActor* actor, std::uint1 int cellX; int subX; - if (x > 0.0f) { + if (x <= 0.0f) { + cellX = 0; + subX = 0; + } else { const double position = x + 0.5; cellX = static_cast(position); subX = static_cast(static_cast(position - cellX) * 16.0f); - } else { - cellX = 0; - subX = 0; } int cellY; int subY; - if (y > 0.0f) { + if (y <= 0.0f) { + cellY = 0; + subY = 0; + } else { const double position = y + 0.5; cellY = static_cast(position); subY = static_cast(static_cast(position - cellY) * 16.0f); - } else { - cellY = 0; - subY = 0; } const int destinationX = actor->movementState[5]; @@ -143,7 +143,7 @@ std::vector CGameMode::BuildActorEntryPacket(CGameActor* actor, std::uint1 entry->moveData[5] = static_cast((subX << 4) | (subY & 0x0F)); entry->packetType = packetType; - entry->packetLength = static_cast(name.size() + packet.size()); + entry->packetLength = static_cast(packet.size() + name.size()); entry->objectType = actor->objectType; entry->accountId = actor->render.accountId; entry->speed = *reinterpret_cast(actor->destinationAndSpeed + 4); @@ -177,7 +177,7 @@ std::vector CGameMode::BuildActorEntryPacket(CGameActor* actor, std::uint1 entry->body = static_cast(pc->GetBodyCostume()); } } else { - packet.resize(sizeof(ActorStandEntryPacket)); + packet.resize(sizeof(ActorStandEntryPacket), 0); ActorStandEntryPacket* entry = reinterpret_cast(packet.data()); entry->hp = actor->GetGaugeCurrent(); entry->maxHp = actor->GetGaugeMaximum(); @@ -197,7 +197,7 @@ std::vector CGameMode::BuildActorEntryPacket(CGameActor* actor, std::uint1 } entry->packetType = packetType; - entry->packetLength = static_cast(name.size() + packet.size()); + entry->packetLength = static_cast(packet.size() + name.size()); entry->objectType = actor->objectType; entry->accountId = actor->render.accountId; entry->speed = *reinterpret_cast(actor->destinationAndSpeed + 4);