- added the ability to remove cell markers

This commit is contained in:
Mark Vejvoda 2012-06-13 16:19:44 +00:00
parent 943dcef9fe
commit 81cc68305c
12 changed files with 375 additions and 12 deletions

View File

@ -115,10 +115,13 @@ Game::Game() : ProgramState(NULL) {
saveGamePopupMenuIndex = -1;
loadGamePopupMenuIndex = -1;
markCellPopupMenuIndex = -1;
unmarkCellPopupMenuIndex = -1;
keyboardSetupPopupMenuIndex = -1;
isMarkCellEnabled = false;
markCellTexture = NULL;
isUnMarkCellEnabled = false;
unmarkCellTexture = NULL;
masterserverMode = false;
currentUIState=NULL;
@ -167,10 +170,13 @@ void Game::resetMembers() {
saveGamePopupMenuIndex = -1;
loadGamePopupMenuIndex = -1;
markCellPopupMenuIndex = -1;
unmarkCellPopupMenuIndex = -1;
keyboardSetupPopupMenuIndex = -1;
isMarkCellEnabled = false;
markCellTexture = NULL;
isUnMarkCellEnabled = false;
unmarkCellTexture = NULL;
currentUIState = NULL;
@ -741,6 +747,8 @@ void Game::load(int loadTypes) {
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
const string markCellTextureFilename = data_path + "data/core/misc_textures/mark_cell.png";
markCellTexture = Renderer::findFactionLogoTexture(markCellTextureFilename);
const string unmarkCellTextureFilename = data_path + "data/core/misc_textures/unmark_cell.png";
unmarkCellTexture = Renderer::findFactionLogoTexture(unmarkCellTextureFilename);
string scenarioDir = "";
if(gameSettings.getScenarioDir() != "") {
@ -1153,6 +1161,8 @@ void Game::setupPopupMenus(bool checkClientAdminOverrideOnly) {
menuItems.push_back(lang.get("MarkCell"));
markCellPopupMenuIndex = menuItems.size()-1;
menuItems.push_back(lang.get("UnMarkCell"));
unmarkCellPopupMenuIndex = menuItems.size()-1;
if(allowAdminMenuItems == true){
menuItems.push_back(lang.get("PauseResumeGame"));
@ -1383,6 +1393,7 @@ void Game::update() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
updateNetworkMarkedCells();
updateNetworkUnMarkedCells();
//check for quiting status
if(NetworkManager::getInstance().getGameNetworkInterface() != NULL &&
@ -1578,6 +1589,33 @@ void Game::updateNetworkMarkedCells() {
}
}
void Game::updateNetworkUnMarkedCells() {
try {
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
if(gameNetworkInterface != NULL &&
gameNetworkInterface->getUnMarkedCellList(false).empty() == false) {
Lang &lang= Lang::getInstance();
std::vector<UnMarkedCell> chatList = gameNetworkInterface->getUnMarkedCellList(true);
for(int idx = 0; idx < chatList.size(); idx++) {
UnMarkedCell mc = chatList[idx];
mc.setFaction((const Faction *)world.getFaction(mc.getFactionIndex()));
Map *map= world.getMap();
Vec2i surfaceCellPos = map->toSurfCoords(mc.getTargetPos());
mapMarkedCellList.erase(surfaceCellPos);
}
}
}
catch(const std::exception &ex) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
throw megaglest_runtime_error(szBuf);
}
}
void Game::ReplaceDisconnectedNetworkPlayersWithAI(bool isNetworkGame, NetworkRole role) {
if(role == nrServer && isNetworkGame == true &&
difftime(time(NULL),lastNetworkPlayerConnectionCheck) >= NETWORK_PLAYER_CONNECTION_CHECK_SECONDS) {
@ -1916,6 +1954,7 @@ void Game::mouseDownLeft(int x, int y) {
NetworkManager &networkManager= NetworkManager::getInstance();
bool messageBoxClick= false;
bool originalIsMarkCellEnabled = isMarkCellEnabled;
bool originalIsUnMarkCellEnabled = isUnMarkCellEnabled;
if(popupMenu.mouseClick(x, y)) {
std::pair<int,string> result = popupMenu.mouseClickedMenuItem(x, y);
@ -2015,6 +2054,9 @@ void Game::mouseDownLeft(int x, int y) {
else if(result.first == markCellPopupMenuIndex) {
isMarkCellEnabled = true;
}
else if(result.first == unmarkCellPopupMenuIndex) {
isUnMarkCellEnabled = true;
}
}
else if(popupMenuSwitchTeams.mouseClick(x, y)) {
//popupMenuSwitchTeams
@ -2115,6 +2157,30 @@ void Game::mouseDownLeft(int x, int y) {
isMarkCellEnabled = false;
Renderer &renderer= Renderer::getInstance();
//renderer.updateMarkedCellScreenPosQuadCache(surfaceCellPos);
renderer.forceQuadCacheUpdate();
}
if(originalIsUnMarkCellEnabled == true && isUnMarkCellEnabled == true) {
Vec2i surfaceCellPos = map->toSurfCoords(Vec2i(xCell,yCell));
SurfaceCell *sc = map->getSurfaceCell(surfaceCellPos);
Vec3f vertex = sc->getVertex();
Vec2i targetPos(vertex.x,vertex.z);
//MarkedCell mc(targetPos,world.getThisFaction(),"placeholder for note");
//mapMarkedCellList[surfaceCellPos] = mc;
if(mapMarkedCellList.find(surfaceCellPos) != mapMarkedCellList.end()) {
MarkedCell mc = mapMarkedCellList[surfaceCellPos];
if(mc.getFaction() == world.getThisFaction()) {
mapMarkedCellList.erase(surfaceCellPos);
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
gameNetworkInterface->sendUnMarkCellMessage(mc.getTargetPos(),mc.getFaction()->getIndex());
}
}
//printf("#1 ADDED in marked list pos [%s] markedCells.size() = %lu\n",surfaceCellPos.getString().c_str(),mapMarkedCellList.size());
isUnMarkCellEnabled = false;
Renderer &renderer= Renderer::getInstance();
//renderer.updateMarkedCellScreenPosQuadCache(surfaceCellPos);
renderer.forceQuadCacheUpdate();
@ -2156,6 +2222,32 @@ void Game::mouseDownLeft(int x, int y) {
//renderer.updateMarkedCellScreenPosQuadCache(surfaceCellPos);
renderer.forceQuadCacheUpdate();
}
if(originalIsUnMarkCellEnabled == true && isUnMarkCellEnabled == true) {
Vec2i targetPos;
Vec2i screenPos(x,y);
Renderer &renderer= Renderer::getInstance();
renderer.computePosition(screenPos, targetPos);
Vec2i surfaceCellPos = map->toSurfCoords(targetPos);
//MarkedCell mc(targetPos,world.getThisFaction(),"placeholder for note");
//mapMarkedCellList[surfaceCellPos] = mc;
if(mapMarkedCellList.find(surfaceCellPos) != mapMarkedCellList.end()) {
MarkedCell mc = mapMarkedCellList[surfaceCellPos];
if(mc.getFaction() == world.getThisFaction()) {
mapMarkedCellList.erase(surfaceCellPos);
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
gameNetworkInterface->sendUnMarkCellMessage(mc.getTargetPos(),mc.getFaction()->getIndex());
}
}
//printf("#1 ADDED in marked list pos [%s] markedCells.size() = %lu\n",surfaceCellPos.getString().c_str(),mapMarkedCellList.size());
isUnMarkCellEnabled = false;
//Renderer &renderer= Renderer::getInstance();
//renderer.updateMarkedCellScreenPosQuadCache(surfaceCellPos);
renderer.forceQuadCacheUpdate();
}
}
}

View File

@ -149,12 +149,15 @@ private:
int saveGamePopupMenuIndex;
int loadGamePopupMenuIndex;
int markCellPopupMenuIndex;
int unmarkCellPopupMenuIndex;
int keyboardSetupPopupMenuIndex;
//GLuint statelist3dMenu;
ProgramState *currentUIState;
bool isMarkCellEnabled;
Texture2D *markCellTexture;
bool isUnMarkCellEnabled;
Texture2D *unmarkCellTexture;
std::map<Vec2i, MarkedCell> mapMarkedCellList;
bool masterserverMode;
@ -179,6 +182,9 @@ public:
bool isMarkCellMode() const { return isMarkCellEnabled; }
const Texture2D * getMarkCellTexture() const { return markCellTexture; }
bool isUnMarkCellMode() const { return isUnMarkCellEnabled; }
const Texture2D * getUnMarkCellTexture() const { return unmarkCellTexture; }
std::map<Vec2i, MarkedCell> getMapMarkedCellList() const { return mapMarkedCellList; }
bool isMasterserverMode() const { return masterserverMode; }
@ -306,6 +312,7 @@ private:
void renderVideoPlayer();
void updateNetworkMarkedCells();
void updateNetworkUnMarkedCells();
};
}}//end namespace

View File

@ -1611,6 +1611,10 @@ void Renderer::renderMouse2d(int x, int y, int anim, float fade) {
const Texture2D *texture= game->getMarkCellTexture();
renderTextureQuad(x-18,y-50,32,32,texture,0.8f);
}
if(game->isUnMarkCellMode() == true) {
const Texture2D *texture= game->getUnMarkCellTexture();
renderTextureQuad(x-18,y-50,32,32,texture,0.8f);
}
}
float color1 = 0.0, color2 = 0.0;

View File

@ -484,6 +484,18 @@ void ClientInterface::updateLobby() {
}
}
break;
case nmtUnMarkCell:
{
NetworkMessageUnMarkCell networkMessageMarkCell;
if(receiveMessage(&networkMessageMarkCell)) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got nmtMarkCell\n",__FILE__,__FUNCTION__);
UnMarkedCell msg(networkMessageMarkCell.getTarget(),
networkMessageMarkCell.getFactionIndex());
this->addUnMarkedCell(msg);
}
}
break;
case nmtLaunch:
case nmtBroadCastSetup:
@ -698,6 +710,19 @@ void ClientInterface::updateFrame(int *checkFrame) {
this->addMarkedCell(msg);
}
}
break;
case nmtUnMarkCell:
{
NetworkMessageUnMarkCell networkMessageMarkCell;
if(receiveMessage(&networkMessageMarkCell)) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got nmtMarkCell\n",__FILE__,__FUNCTION__);
UnMarkedCell msg(networkMessageMarkCell.getTarget(),
networkMessageMarkCell.getFactionIndex());
this->addUnMarkedCell(msg);
}
}
break;
case nmtLaunch:
@ -1200,6 +1225,14 @@ void ClientInterface::sendMarkCellMessage(Vec2i targetPos, int factionIndex, str
sendMessage(&networkMessageMarkCell);
}
void ClientInterface::sendUnMarkCellMessage(Vec2i targetPos, int factionIndex) {
string humanPlayerName = getHumanPlayerName();
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] humanPlayerName = [%s] playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,humanPlayerName.c_str(),playerIndex);
NetworkMessageUnMarkCell networkMessageMarkCell(targetPos,factionIndex);
sendMessage(&networkMessageMarkCell);
}
void ClientInterface::sendPingMessage(int32 pingFrequency, int64 pingTime) {
NetworkMessagePing networkMessagePing(pingFrequency,pingTime);
sendMessage(&networkMessagePing);
@ -1401,6 +1434,18 @@ bool ClientInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
}
break;
case nmtUnMarkCell:
{
discard = true;
NetworkMessageUnMarkCell networkMessageMarkCell;
receiveMessage(&networkMessageMarkCell);
UnMarkedCell msg(networkMessageMarkCell.getTarget(),
networkMessageMarkCell.getFactionIndex());
this->addUnMarkedCell(msg);
}
break;
case nmtSynchNetworkGameData:
{
discard = true;

View File

@ -87,6 +87,7 @@ public:
virtual void quitGame(bool userManuallyQuit);
virtual void sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note);
virtual void sendUnMarkCellMessage(Vec2i targetPos, int factionIndex);
//misc
virtual string getNetworkStatus() ;

View File

@ -590,6 +590,35 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
}
break;
case nmtUnMarkCell:
{
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got nmtUnMarkCell gotIntro = %d\n",__FILE__,__FUNCTION__,__LINE__,gotIntro);
if(gotIntro == true) {
NetworkMessageUnMarkCell networkMessageMarkCell;
if(receiveMessage(&networkMessageMarkCell)) {
UnMarkedCell msg(networkMessageMarkCell.getTarget(),
networkMessageMarkCell.getFactionIndex());
this->addUnMarkedCell(msg);
//gotTextMsg = true;
}
else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d]\nInvalid message type before intro handshake [%d]\nDisconnecting socket for slot: %d [%s].\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,networkMessageType,this->playerIndex,this->getIpAddress().c_str());
this->serverInterface->notifyBadClientConnectAttempt(this->getIpAddress());
close();
return;
}
}
else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d]\nInvalid message type before intro handshake [%d]\nDisconnecting socket for slot: %d [%s].\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,networkMessageType,this->playerIndex,this->getIpAddress().c_str());
this->serverInterface->notifyBadClientConnectAttempt(this->getIpAddress());
close();
return;
}
}
break;
//command list
case nmtCommandList: {

View File

@ -146,6 +146,25 @@ void NetworkInterface::clearMarkedCellList() {
}
}
std::vector<UnMarkedCell> NetworkInterface::getUnMarkedCellList(bool clearList) {
std::vector<UnMarkedCell> result;
if(unmarkedCellList.empty() == false) {
result = unmarkedCellList;
if(clearList == true) {
unmarkedCellList.clear();
}
}
return result;
}
void NetworkInterface::clearUnMarkedCellList() {
if(unmarkedCellList.empty() == false) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] unmarkedCellList.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,unmarkedCellList.size());
unmarkedCellList.clear();
}
}
std::string NetworkInterface::getIpAddress() {
std::string result = "";

View File

@ -115,6 +115,34 @@ public:
string getNote() const { return note; }
};
class UnMarkedCell {
protected:
Vec2i targetPos;
const Faction *faction;
int factionIndex;
public:
UnMarkedCell() {
faction = NULL;
factionIndex = -1;
}
UnMarkedCell(Vec2i targetPos,const Faction *faction) {
this->targetPos = targetPos;
this->faction = faction;
this->factionIndex = -1;
}
UnMarkedCell(Vec2i targetPos,int factionIndex) {
this->targetPos = targetPos;
this->faction = NULL;
this->factionIndex = factionIndex;
}
Vec2i getTargetPos() const { return targetPos; }
const Faction * getFaction() const { return faction; }
void setFaction(const Faction *faction) { this->faction = faction; }
int getFactionIndex() const { return factionIndex; }
};
typedef int (*DisplayMessageFunction)(const char *msg, bool exit);
class NetworkInterface {
@ -131,6 +159,7 @@ protected:
std::vector<ChatMsgInfo> chatTextList;
NetworkMessagePing lastPingInfo;
std::vector<MarkedCell> markedCellList;
std::vector<UnMarkedCell> unmarkedCellList;
static DisplayMessageFunction pCB_DisplayMessage;
void DisplayErrorMessage(string sErr, bool closeSocket=true);
@ -186,6 +215,10 @@ public:
void clearMarkedCellList();
void addMarkedCell(const MarkedCell &msg) { markedCellList.push_back(msg); }
std::vector<UnMarkedCell> getUnMarkedCellList(bool clearList);
void clearUnMarkedCellList();
void addUnMarkedCell(const UnMarkedCell &msg) { unmarkedCellList.push_back(msg); }
virtual bool getConnectHasHandshaked() const= 0;
NetworkMessagePing getLastPingInfo() const { return lastPingInfo; }
@ -239,6 +272,7 @@ public:
virtual void quitGame(bool userManuallyQuit)=0;
virtual void sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note) = 0;
virtual void sendUnMarkCellMessage(Vec2i targetPos, int factionIndex) = 0;
//misc
virtual string getNetworkStatus() = 0;

View File

@ -1014,4 +1014,33 @@ void NetworkMessageMarkCell::send(Socket* socket) const{
NetworkMessage::send(socket, &data, sizeof(data));
}
// =====================================================
// class NetworkMessageUnMarkCell
// =====================================================
NetworkMessageUnMarkCell::NetworkMessageUnMarkCell(Vec2i target, int factionIndex) {
data.messageType = nmtUnMarkCell;
data.targetX = target.x;
data.targetY = target.y;
data.factionIndex = factionIndex;
}
NetworkMessageUnMarkCell * NetworkMessageUnMarkCell::getCopy() const {
NetworkMessageUnMarkCell *copy = new NetworkMessageUnMarkCell();
copy->data = this->data;
return copy;
}
bool NetworkMessageUnMarkCell::receive(Socket* socket){
bool result = NetworkMessage::receive(socket, &data, sizeof(data), true);
return result;
}
void NetworkMessageUnMarkCell::send(Socket* socket) const{
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] nmtUnMarkCell\n",__FILE__,__FUNCTION__,__LINE__);
assert(data.messageType == nmtUnMarkCell);
NetworkMessage::send(socket, &data, sizeof(data));
}
}}//end namespace

View File

@ -44,6 +44,7 @@ enum NetworkMessageType {
nmtPlayerIndexMessage,
nmtLoadingStatusMessage,
nmtMarkCell,
nmtUnMarkCell,
nmtCount
};
@ -731,7 +732,7 @@ public:
// =====================================================
// class NetworkMessageText
// class NetworkMessageMarkCell
//
// Mark a Cell message nmtMarkCell
// =====================================================
@ -768,6 +769,40 @@ public:
};
#pragma pack(pop)
// =====================================================
// class NetworkUnMessageMarkCell
//
// Mark a Cell message nmtUnMarkCell
// =====================================================
#pragma pack(push, 1)
class NetworkMessageUnMarkCell: public NetworkMessage {
private:
struct Data{
int8 messageType;
int16 targetX;
int16 targetY;
int8 factionIndex;
};
private:
Data data;
public:
NetworkMessageUnMarkCell(){}
NetworkMessageUnMarkCell(Vec2i target, int factionIndex);
Vec2i getTarget() const { return Vec2i(data.targetX,data.targetY); }
int getFactionIndex() const { return data.factionIndex; }
virtual bool receive(Socket* socket);
virtual void send(Socket* socket) const;
NetworkMessageUnMarkCell * getCopy() const;
};
#pragma pack(pop)
}}//end namespace
#endif

View File

@ -1133,6 +1133,45 @@ void ServerInterface::dispatchPendingMarkCellMessages(std::vector <string> &erro
}
}
void ServerInterface::dispatchPendingUnMarkCellMessages(std::vector <string> &errorMsgList) {
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[i],CODE_AT_LINE_X(i));
ConnectionSlot* connectionSlot= slots[i];
if(connectionSlot != NULL &&
connectionSlot->getUnMarkedCellList(false).empty() == false) {
try {
std::vector<UnMarkedCell> chatText = connectionSlot->getUnMarkedCellList(true);
for(int chatIdx = 0;
exitServer == false && slots[i] != NULL &&
chatIdx < chatText.size(); chatIdx++) {
connectionSlot= slots[i];
if(connectionSlot != NULL) {
UnMarkedCell msg(chatText[chatIdx]);
this->addUnMarkedCell(msg);
NetworkMessageUnMarkCell networkMessageMarkCell(msg.getTargetPos(),msg.getFactionIndex());
broadcastMessage(&networkMessageMarkCell, connectionSlot->getPlayerIndex(),i);
//if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] after broadcast nmtText chatText [%s] chatTeamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatTeamIndex);
}
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] i = %d\n",__FILE__,__FUNCTION__,__LINE__,i);
// Its possible that the slot is disconnected here
// so check the original pointer again
if(slots[i] != NULL) {
slots[i]->clearUnMarkedCellList();
}
}
catch(const exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error detected [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
errorMsgList.push_back(ex.what());
}
}
}
}
void ServerInterface::update() {
Chrono chrono;
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start();
@ -1206,6 +1245,7 @@ void ServerInterface::update() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
dispatchPendingMarkCellMessages(errorMsgList);
dispatchPendingUnMarkCellMessages(errorMsgList);
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
}
@ -1386,17 +1426,6 @@ bool ServerInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
this->addMarkedCell(msg);
// string newChatText = msg.chatText.c_str();
// //string newChatSender = msg.chatSender.c_str();
// int newChatTeamIndex = msg.chatTeamIndex;
// int newChatPlayerIndex = msg.chatPlayerIndex;
// string newChatLanguage = msg.targetLanguage.c_str();
//
// if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 about to broadcast nmtText chatText [%s] chatTeamIndex = %d, newChatPlayerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatTeamIndex,newChatPlayerIndex);
//
// NetworkMessageText networkMessageText(newChatText.c_str(),newChatTeamIndex,newChatPlayerIndex,newChatLanguage);
// broadcastMessage(&networkMessageText, connectionSlot->getPlayerIndex());
NetworkMessageMarkCell networkMessageMarkCellBroadcast(
networkMessageMarkCell.getTarget(),
networkMessageMarkCell.getFactionIndex(),
@ -1408,6 +1437,27 @@ bool ServerInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
}
break;
case nmtUnMarkCell:
{
discard = true;
NetworkMessageUnMarkCell networkMessageMarkCell;
connectionSlot->receiveMessage(&networkMessageMarkCell);
UnMarkedCell msg(networkMessageMarkCell.getTarget(),
networkMessageMarkCell.getFactionIndex());
this->addUnMarkedCell(msg);
NetworkMessageUnMarkCell networkMessageMarkCellBroadcast(
networkMessageMarkCell.getTarget(),
networkMessageMarkCell.getFactionIndex());
broadcastMessage(&networkMessageMarkCellBroadcast, connectionSlot->getPlayerIndex());
//if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] after broadcast nmtMarkCell chatText [%s] chatTeamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatTeamIndex);
}
break;
case nmtSynchNetworkGameData:
{
discard = true;
@ -1763,6 +1813,20 @@ void ServerInterface::sendMarkCellMessage(Vec2i targetPos, int factionIndex, str
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
}
void ServerInterface::sendUnMarkCellMessage(Vec2i targetPos, int factionIndex) {
sendUnMarkCellMessage(targetPos, factionIndex, -1);
}
void ServerInterface::sendUnMarkCellMessage(Vec2i targetPos, int factionIndex, int lockedSlotIndex) {
//printf("Line: %d text [%s] echoLocal = %d\n",__LINE__,text.c_str(),echoLocal);
//assert(text.length() > 0);
//if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] text [%s] teamIndex = %d, echoLocal = %d, lockedSlotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,text.c_str(),teamIndex,echoLocal,lockedSlotIndex);
NetworkMessageUnMarkCell networkMessageMarkCell(targetPos,factionIndex);
broadcastMessage(&networkMessageMarkCell, -1, lockedSlotIndex);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
}
void ServerInterface::quitGame(bool userManuallyQuit) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
NetworkMessageQuit networkMessageQuit;

View File

@ -119,6 +119,9 @@ public:
virtual void sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note);
void sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note, int lockedSlotIndex);
virtual void sendUnMarkCellMessage(Vec2i targetPos, int factionIndex);
void sendUnMarkCellMessage(Vec2i targetPos, int factionIndex, int lockedSlotIndex);
virtual void quitGame(bool userManuallyQuit);
virtual string getNetworkStatus();
ServerSocket *getServerSocket()
@ -230,6 +233,7 @@ protected:
void executeNetworkCommandsFromClients();
void dispatchPendingChatMessages(std::vector <string> &errorMsgList);
void dispatchPendingMarkCellMessages(std::vector <string> &errorMsgList);
void dispatchPendingUnMarkCellMessages(std::vector <string> &errorMsgList);
void shutdownMasterserverPublishThread();
};