Wrote PumpPacketProximity, it works
This commit is contained in:
@@ -107,6 +107,7 @@ private:
|
|||||||
|
|
||||||
//utility methods
|
//utility methods
|
||||||
void PumpPacket(SerialPacket* const);
|
void PumpPacket(SerialPacket* const);
|
||||||
|
void PumpPacketProximity(SerialPacket* const argPacket, int roomIndex, Vector2 position, int distance);
|
||||||
void CopyCharacterToPacket(CharacterPacket* const packet, int characterIndex);
|
void CopyCharacterToPacket(CharacterPacket* const packet, int characterIndex);
|
||||||
|
|
||||||
//APIs and utilities
|
//APIs and utilities
|
||||||
|
|||||||
@@ -300,5 +300,5 @@ void ServerApplication::HandleCharacterSetMotion(CharacterPacket* const argPacke
|
|||||||
CharacterPacket newPacket;
|
CharacterPacket newPacket;
|
||||||
CopyCharacterToPacket(&newPacket, argPacket->characterIndex);
|
CopyCharacterToPacket(&newPacket, argPacket->characterIndex);
|
||||||
newPacket.type = SerialPacketType::CHARACTER_SET_MOTION;
|
newPacket.type = SerialPacketType::CHARACTER_SET_MOTION;
|
||||||
PumpPacket(&newPacket);
|
PumpPacketProximity(&newPacket, characterData->GetRoomIndex(), characterData->GetOrigin(), -1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,6 +175,22 @@ void ServerApplication::PumpPacket(SerialPacket* const argPacket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerApplication::PumpPacketProximity(SerialPacket* const argPacket, int roomIndex, Vector2 position, int distance) {
|
||||||
|
RoomData* room = roomMgr.Get(roomIndex);
|
||||||
|
|
||||||
|
if (!room) {
|
||||||
|
throw(std::runtime_error("Failed to pump to a non-existant room"));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& character : *room->GetCharacterList()) {
|
||||||
|
if (distance == -1 || (character->GetOrigin() - position).Length() <= distance) {
|
||||||
|
AccountData* account = accountMgr.Get(character->GetOwner());
|
||||||
|
ClientData* client = clientMgr.Get(account->GetClientIndex());
|
||||||
|
network.SendTo(client->GetAddress(), argPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ServerApplication::CopyCharacterToPacket(CharacterPacket* const packet, int characterIndex) {
|
void ServerApplication::CopyCharacterToPacket(CharacterPacket* const packet, int characterIndex) {
|
||||||
CharacterData* character = characterMgr.Get(characterIndex);
|
CharacterData* character = characterMgr.Get(characterIndex);
|
||||||
if (!character) {
|
if (!character) {
|
||||||
|
|||||||
Reference in New Issue
Block a user