Pull request #136 Merge remote-tracking branch 'origin/master' into FixNetworkBugs
# Conflicts: # src/Engine/Network/Client.cpp
This commit is contained in:
@@ -107,7 +107,6 @@ private:
|
||||
void parseDoubleJump(Packet& packet);
|
||||
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
||||
void parseSnapshot(Packet& packet);
|
||||
void UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD);
|
||||
void identifyPacketLoss();
|
||||
void hasServerTimedOut();
|
||||
EntityID createPlayer();
|
||||
|
||||
@@ -367,9 +367,6 @@ void Client::parseSnapshot(Packet& packet)
|
||||
// Update entity
|
||||
if (m_World->HasComponent(localEntityID, componentType)) {
|
||||
// TODO Fix memory leak here
|
||||
if (localEntity.Name() == "CapturePointHUD") {
|
||||
UpdateLocalCapturePointHUD(localEntity);
|
||||
}
|
||||
SharedComponentWrapper newComponent = createSharedComponent(packet, localEntityID, componentInfo);
|
||||
bool shouldApply = true;
|
||||
// Apply potential filter function
|
||||
@@ -397,7 +394,11 @@ void Client::parseSnapshot(Packet& packet)
|
||||
if (serverParentID == EntityID_Invalid) {
|
||||
newLocalEntityID = m_World->CreateEntity(EntityID_Invalid);
|
||||
} else {
|
||||
if (serverClientMapsHasEntity(serverParentID)) {
|
||||
newLocalEntityID = m_World->CreateEntity(m_ServerIDToClientID.at(serverParentID));
|
||||
} else {
|
||||
newLocalEntityID = m_World->CreateEntity(EntityID_Invalid);
|
||||
}
|
||||
}
|
||||
m_World->SetName(newLocalEntityID, serverEntityName);
|
||||
insertIntoServerClientMaps(serverEntityID, newLocalEntityID);
|
||||
@@ -407,7 +408,7 @@ void Client::parseSnapshot(Packet& packet)
|
||||
}
|
||||
// Parent logic
|
||||
// This should be enough beacause we know that the entities arives in pre-order (there will always be a parent)
|
||||
if (serverParentID != EntityID_Invalid) {
|
||||
if (serverParentID != EntityID_Invalid && serverClientMapsHasEntity(serverParentID)) {
|
||||
EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID);
|
||||
if (m_World->GetParent(localEntityID) != m_ServerIDToClientID.at(serverParentID)) {
|
||||
m_World->SetParent(localEntityID, m_ServerIDToClientID.at(serverParentID));
|
||||
@@ -417,18 +418,6 @@ void Client::parseSnapshot(Packet& packet)
|
||||
parseSpawnEvents();
|
||||
}
|
||||
|
||||
|
||||
void Client::UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD)
|
||||
{
|
||||
//auto children = m_World->GetChildren(capturePointHUD.ID);
|
||||
//for (auto it = children.first; it != children.second; it++) {
|
||||
// it->first
|
||||
//}
|
||||
//
|
||||
//EntityWrapper& localHUD = m_LocalPlayer.FirstChildByName("HUD").FirstChildByName("CapturePointHUD");
|
||||
//m_World->GetComponentPools()
|
||||
}
|
||||
|
||||
void Client::disconnect()
|
||||
{
|
||||
m_IsConnected = false;
|
||||
|
||||
@@ -194,10 +194,7 @@ void Server::addPlayersToPacket(Packet & packet, EntityID entityID)
|
||||
// HACK: Only sync players for now, since the map turned out to be TOO LARGE to send in one snapshot and Simon's computer shits itself
|
||||
// HACK: Also checked CapturePointHUD for now. (this would get out of sync);
|
||||
EntityWrapper childEntity(m_World, childEntityID);
|
||||
if (!shouldSendToClient(childEntity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (shouldSendToClient(childEntity)) {
|
||||
// Write EntityID and parentsID and Entity name
|
||||
packet.WritePrimitive(childEntityID);
|
||||
packet.WritePrimitive(entityID);
|
||||
@@ -229,8 +226,9 @@ void Server::addPlayersToPacket(Packet & packet, EntityID entityID)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Go to to your children
|
||||
addChildrenToPacket(packet, childEntityID);
|
||||
addPlayersToPacket(packet, childEntityID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,8 +456,7 @@ bool Server::OnInputCommand(const Events::InputCommand & e)
|
||||
}
|
||||
isReadingData = !isReadingData;
|
||||
m_SaveDataTimer = std::clock();
|
||||
}
|
||||
else if (e.Command == "KickPlayer" && e.Value > 0) {
|
||||
} else if (e.Command == "KickPlayer" && e.Value > 0) {
|
||||
kick(0);
|
||||
}
|
||||
|
||||
@@ -604,8 +601,15 @@ void Server::parsePlayerTransform(Packet& packet)
|
||||
|
||||
bool Server::shouldSendToClient(EntityWrapper childEntity)
|
||||
{
|
||||
auto children = m_World->GetChildren(childEntity.ID);
|
||||
for (auto it = children.first; it != children.second; it++) {
|
||||
EntityWrapper child(m_World, it->second);
|
||||
if(child.HasComponent("CapturePoint")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid()
|
||||
|| childEntity.HasComponent("CapturePoint") || childEntity.FirstParentWithComponent("CapturePoint").Valid();
|
||||
|| childEntity.HasComponent("CapturePoint");
|
||||
}
|
||||
|
||||
PlayerID Server::GetPlayerIDFromEndpoint()
|
||||
|
||||
@@ -6,9 +6,11 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
|
||||
, PureSystem("CapturePoint")
|
||||
{
|
||||
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
|
||||
if (!IsClient) {
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +18,9 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
|
||||
//NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt
|
||||
void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt)
|
||||
{
|
||||
if (IsClient) {
|
||||
return;
|
||||
}
|
||||
if (m_WinnerWasFound) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user