mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Added GameInstance class
- available as global GAME - integrates LOCPLINT (CPlayerInterface) - integrates CGI->mh (CMapHandler) - integrates CSH (CServerHandler)
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "StdInc.h"
|
||||
|
||||
#include "GameChatHandler.h"
|
||||
#include "GameInstance.h"
|
||||
#include "CServerHandler.h"
|
||||
#include "CPlayerInterface.h"
|
||||
#include "PlayerLocalState.h"
|
||||
@@ -39,8 +40,8 @@ void GameChatHandler::resetMatchState()
|
||||
|
||||
void GameChatHandler::sendMessageGameplay(const std::string & messageText)
|
||||
{
|
||||
LOCPLINT->cb->sendMessage(messageText, LOCPLINT->localState->getCurrentArmy());
|
||||
CSH->getGlobalLobby().sendMatchChatMessage(messageText);
|
||||
GAME->interface()->cb->sendMessage(messageText, GAME->interface()->localState->getCurrentArmy());
|
||||
GAME->server().getGlobalLobby().sendMatchChatMessage(messageText);
|
||||
}
|
||||
|
||||
void GameChatHandler::sendMessageLobby(const std::string & senderName, const std::string & messageText)
|
||||
@@ -50,8 +51,8 @@ void GameChatHandler::sendMessageLobby(const std::string & senderName, const std
|
||||
txt.appendRawString(messageText);
|
||||
lcm.message = txt;
|
||||
lcm.playerName = senderName;
|
||||
CSH->sendLobbyPack(lcm);
|
||||
CSH->getGlobalLobby().sendMatchChatMessage(messageText);
|
||||
GAME->server().sendLobbyPack(lcm);
|
||||
GAME->server().getGlobalLobby().sendMatchChatMessage(messageText);
|
||||
}
|
||||
|
||||
void GameChatHandler::onNewLobbyMessageReceived(const std::string & senderName, const std::string & messageText)
|
||||
@@ -90,20 +91,20 @@ void GameChatHandler::onNewGameMessageReceived(PlayerColor sender, const std::st
|
||||
std::string playerName = "<UNKNOWN>";
|
||||
|
||||
if (sender.isValidPlayer())
|
||||
playerName = LOCPLINT->cb->getStartInfo()->playerInfos.at(sender).name;
|
||||
playerName = GAME->interface()->cb->getStartInfo()->playerInfos.at(sender).name;
|
||||
|
||||
if (sender.isSpectator())
|
||||
playerName = VLC->generaltexth->translate("vcmi.lobby.login.spectator");
|
||||
|
||||
chatHistory.push_back({playerName, messageText, timeFormatted});
|
||||
|
||||
LOCPLINT->cingconsole->addMessage(timeFormatted, playerName, messageText);
|
||||
GAME->interface()->cingconsole->addMessage(timeFormatted, playerName, messageText);
|
||||
}
|
||||
|
||||
void GameChatHandler::onNewSystemMessageReceived(const std::string & messageText)
|
||||
{
|
||||
chatHistory.push_back({"System", messageText, TextOperations::getCurrentFormattedTimeLocal()});
|
||||
|
||||
if(LOCPLINT && !settings["session"]["hideSystemMessages"].Bool())
|
||||
LOCPLINT->cingconsole->addMessage(TextOperations::getCurrentFormattedTimeLocal(), "System", messageText);
|
||||
if(GAME->interface() && !settings["session"]["hideSystemMessages"].Bool())
|
||||
GAME->interface()->cingconsole->addMessage(TextOperations::getCurrentFormattedTimeLocal(), "System", messageText);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user