Removed debug logging. PlayerID in InputCommands from buttons is corrected.

This commit is contained in:
William Moberg
2016-03-07 17:35:01 +01:00
parent 962521fa59
commit 1516ed8e2d
3 changed files with 14 additions and 32 deletions
+2 -2
View File
@@ -40,7 +40,7 @@ bool ButtonSystem::OnMousePress(const Events::MousePress& e)
//You have clicked on a button entity, send pressed event.
if (m_World->HasComponent(m_PickData.Entity, "InputCmdButton")) {
Events::InputCommand eInputCmd;
eInputCmd.PlayerID = LocalPlayer.ID;
eInputCmd.PlayerID = -1;
eInputCmd.Player = LocalPlayer;
EntityWrapper button = EntityWrapper(m_World, m_PickData.Entity);
eInputCmd.Command = (std::string)button["InputCmdButton"]["Command"];
@@ -68,7 +68,7 @@ bool ButtonSystem::OnMouseRelease(const Events::MouseRelease& e)
if (m_World->HasComponent(m_PickData.Entity, "InputCmdButton")) {
Events::InputCommand eInputCmd;
eInputCmd.PlayerID = LocalPlayer.ID;
eInputCmd.PlayerID = -1;
eInputCmd.Player = LocalPlayer;
EntityWrapper button = EntityWrapper(m_World, m_PickData.Entity);
eInputCmd.Command = (std::string)button["InputCmdButton"]["Command"];
-7
View File
@@ -18,8 +18,6 @@ bool PlayerDeathSystem::OnPlayerDeath(Events::PlayerDeath& e)
return false;
}
LOG_DEBUG("------ Player #%i died.", e.Player.ID);
createDeathEffect(e.Player);
// Delete player
@@ -38,7 +36,6 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
auto playerModel = player.FirstChildByName("PlayerModel");
if (!playerModel.Valid() || !playerModel.HasComponent("Model") || !playerModel.HasComponent("Animation")) {
if (player == LocalPlayer) {
LOG_DEBUG("------ LocalPlayer's death effect could not be spawned, setting to spectator instead of death cam.");
setSpectatorCamera();
}
return;
@@ -58,7 +55,6 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
//camera (with lifetime) behind the player
if (player == LocalPlayer) {
LOG_DEBUG("------ LocalPlayer's death effect spawning, setting to death camera.");
m_LocalPlayerDeathEffect = deathEffectEW;
auto cam = deathEffectEW.FirstChildByName("Camera");
Events::SetCamera eSetCamera;
@@ -76,10 +72,7 @@ bool PlayerDeathSystem::OnEntityDeleted(Events::EntityDeleted& e)
// If the player hasn't spawned already, activate the spectator camera.
if (!LocalPlayer.Valid()) {
LOG_DEBUG("------ LocalPlayer's death effect removed, setting to spectator.");
setSpectatorCamera();
} else {
LOG_DEBUG("------ LocalPlayer's death effect removed, player is already spawned, not setting spectator.");
}
return true;
}
+12 -23
View File
@@ -59,16 +59,16 @@ void PlayerSpawnSystem::Update(double dt)
return;
}
int numHandledRequests = 0;
int playersStillPickingClass = 0;
int numSpawnedPlayers = 0;
int playersSpectating = 0;
const int numRequestsToHandle = (int)m_SpawnRequests.size();
for (auto it = m_SpawnRequests.begin(); it != m_SpawnRequests.end(); ++it) {
// TODO: -1 Signifies no class picked, enum here later?
// TODO: -1 Signifies no class picked, or they are a spectator, enum here later?
// It is valid if they didn't pick class yet
// but don't spawn anything, goto next spawnrequest.
if (it->Class == -1) {
++playersStillPickingClass;
break;
++playersSpectating;
continue;
}
for (auto& cPlayerSpawn : *playerSpawns) {
EntityWrapper spawner(m_World, cPlayerSpawn.EntityID);
@@ -80,13 +80,6 @@ void PlayerSpawnSystem::Update(double dt)
if (spawner.HasComponent("Team")) {
auto cSpawnerTeam = spawner["Team"];
if ((int)cSpawnerTeam["Team"] != it->Team) {
// It is valid if someone picks spectator
// but don't spawn anything, goto next spawnrequest.
if (it->Team == (int)cSpawnerTeam["Team"].Enum("Spectator")) {
++numHandledRequests;
it = m_SpawnRequests.erase(it);
break;
}
continue;
}
}
@@ -104,9 +97,7 @@ void PlayerSpawnSystem::Update(double dt)
e.Player = player;
e.Spawner = spawner;
m_EventBroker->Publish(e);
Events::LockMouse lock;
m_EventBroker->Publish(lock);
++numHandledRequests;
++numSpawnedPlayers;
it = m_SpawnRequests.erase(it);
break;
}
@@ -114,11 +105,11 @@ void PlayerSpawnSystem::Update(double dt)
break;
}
}
if (numHandledRequests != numRequestsToHandle - playersStillPickingClass) {
LOG_DEBUG("%i players were supposed to be spawned or set as spectator, but only %i was handled.", numRequestsToHandle, numHandledRequests);
if (numSpawnedPlayers != numRequestsToHandle - playersSpectating) {
LOG_DEBUG("%i players were supposed to be spawned, but only %i was successfully.", numRequestsToHandle - playersSpectating, numSpawnedPlayers);
} else {
std::string dbg = numHandledRequests != 0 ? std::to_string(numHandledRequests) + " players were spawned or set as spectator. " : "";
dbg += playersStillPickingClass != 0 ? std::to_string(playersStillPickingClass) + " players are still picking class and will be spawned later." : "";
std::string dbg = numSpawnedPlayers != 0 ? std::to_string(numSpawnedPlayers) + " players were spawned. " : "";
dbg += playersSpectating != 0 ? std::to_string(playersSpectating) + " players are spectating/picking class. " : "";
LOG_DEBUG(dbg.c_str());
}
}
@@ -162,10 +153,8 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e)
// If player is in queue to spawn, then change their team affiliation or class in the request.
if (e.Command == "PickTeam") {
iter->Team = (ComponentInfo::EnumType)e.Value;
LOG_DEBUG("old spawn request setting Team");
} else {
iter->Class = (ComponentInfo::EnumType)e.Value;
LOG_DEBUG("old spawn request setting Class");
}
} else if (m_PlayerEntities.count(e.PlayerID) == 0 || !m_PlayerEntities[e.PlayerID].Valid()) {
// If player is not in queue to spawn, then create a spawn request,
@@ -175,13 +164,11 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e)
if (e.Command == "PickTeam") {
req.Team = (ComponentInfo::EnumType)e.Value;
req.Class = -1; // TODO: -1 Signifies no class picked, enum here later?
LOG_DEBUG("new spawn request setting Team");
} else {
// Should never get here, since you should have picked a team before you ever get a chance to pick class.
LOG_WARNING("Sequence error: Should not be able to pick class before team");
req.Team = 1; // TODO: 1 Signifies spectator, should probably have real enum here later.
req.Class = (ComponentInfo::EnumType)e.Value;
LOG_DEBUG("new spawn request setting Class");
}
m_SpawnRequests.push_back(req);
} else {
@@ -217,6 +204,8 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
Events::SetCamera e;
e.CameraEntity = cameraEntity;
m_EventBroker->Publish(e);
Events::LockMouse lock;
m_EventBroker->Publish(lock);
}
// HACK: Set the player model color to team color