Browse Source

Play sound when receiving message, not just on sending ours

Ivan Savenko 2 years ago
parent
commit
48eb8ab54f
2 changed files with 9 additions and 11 deletions
  1. 1 5
      client/adventureMap/CInGameConsole.cpp
  2. 8 6
      server/CGameHandler.cpp

+ 1 - 5
client/adventureMap/CInGameConsole.cpp

@@ -104,6 +104,7 @@ void CInGameConsole::print(const std::string & txt)
 	}
 
 	GH.windows().totalRedraw(); // FIXME: ingame console has no parent widget set
+	CCS->soundh->playSound("CHAT");
 }
 
 void CInGameConsole::keyPressed (EShortcut key)
@@ -134,11 +135,6 @@ void CInGameConsole::keyPressed (EShortcut key)
 			{
 				bool anyTextExceptCaret = enteredText.size() > 1;
 				endEnteringText(anyTextExceptCaret);
-
-				if(anyTextExceptCaret)
-				{
-					CCS->soundh->playSound("CHAT");
-				}
 			}
 			break;
 		}

+ 8 - 6
server/CGameHandler.cpp

@@ -4980,12 +4980,6 @@ void CGameHandler::playerMessage(PlayerColor player, const std::string &message,
 {
 	bool cheated = false;
 	
-	if(!getPlayerSettings(player)->isControlledByAI())
-	{
-		PlayerMessageClient temp_message(player, message);
-		sendAndApply(&temp_message);
-	}
-
 	std::vector<std::string> words;
 	boost::split(words, message, boost::is_any_of(" "));
 	
@@ -5106,6 +5100,14 @@ void CGameHandler::playerMessage(PlayerColor player, const std::string &message,
 		if(!player.isSpectator())
 			checkVictoryLossConditionsForPlayer(player);//Player enter win code or got required art\creature
 	}
+	else
+	{
+		if(!getPlayerSettings(player)->isControlledByAI())
+		{
+			PlayerMessageClient temp_message(player, message);
+			sendAndApply(&temp_message);
+		}
+	}
 }
 
 bool CGameHandler::makeCustomAction(BattleAction & ba)