- limit players to 5 cell markers max at any given time
This commit is contained in:
parent
64884e14d0
commit
9fc64f4878
|
@ -2240,7 +2240,17 @@ void Game::mouseDownLeft(int x, int y) {
|
|||
saveGame();
|
||||
}
|
||||
else if(result.first == markCellPopupMenuIndex) {
|
||||
isMarkCellEnabled = true;
|
||||
int totalMarkedCellsForPlayer = 0;
|
||||
for(std::map<Vec2i, MarkedCell>::iterator iterMap = mapMarkedCellList.begin();
|
||||
iterMap != mapMarkedCellList.end(); ++iterMap) {
|
||||
MarkedCell &bm = iterMap->second;
|
||||
if(bm.getPlayerIndex() == world.getThisFaction()->getStartLocationIndex()) {
|
||||
totalMarkedCellsForPlayer++;
|
||||
}
|
||||
}
|
||||
if(totalMarkedCellsForPlayer < 5) {
|
||||
isMarkCellEnabled = true;
|
||||
}
|
||||
}
|
||||
else if(result.first == unmarkCellPopupMenuIndex) {
|
||||
isUnMarkCellEnabled = true;
|
||||
|
@ -2338,7 +2348,7 @@ void Game::mouseDownLeft(int x, int y) {
|
|||
Vec3f vertex = sc->getVertex();
|
||||
Vec2i targetPos(vertex.x,vertex.z);
|
||||
|
||||
MarkedCell mc(targetPos,world.getThisFaction(),"none");
|
||||
MarkedCell mc(targetPos,world.getThisFaction(),"none",world.getThisFaction()->getStartLocationIndex());
|
||||
addOrReplaceInHighlightedCells(mc);
|
||||
|
||||
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
||||
|
@ -2352,7 +2362,7 @@ void Game::mouseDownLeft(int x, int y) {
|
|||
Vec3f vertex = sc->getVertex();
|
||||
Vec2i targetPos(vertex.x,vertex.z);
|
||||
|
||||
MarkedCell mc(targetPos,world.getThisFaction(),"placeholder for note");
|
||||
MarkedCell mc(targetPos,world.getThisFaction(),"placeholder for note",world.getThisFaction()->getStartLocationIndex());
|
||||
|
||||
//GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
||||
//gameNetworkInterface->sendMarkCellMessage(mc.getTargetPos(),mc.getFaction()->getIndex(),mc.getNote());
|
||||
|
@ -2418,7 +2428,7 @@ void Game::mouseDownLeft(int x, int y) {
|
|||
Vec2i surfaceCellPos = map->toSurfCoords(targetPos);
|
||||
|
||||
|
||||
MarkedCell mc(targetPos,world.getThisFaction(),"none");
|
||||
MarkedCell mc(targetPos,world.getThisFaction(),"none",world.getThisFaction()->getStartLocationIndex());
|
||||
addOrReplaceInHighlightedCells(mc);
|
||||
|
||||
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
||||
|
@ -2432,7 +2442,7 @@ void Game::mouseDownLeft(int x, int y) {
|
|||
renderer.computePosition(screenPos, targetPos);
|
||||
Vec2i surfaceCellPos = map->toSurfCoords(targetPos);
|
||||
|
||||
MarkedCell mc(targetPos,world.getThisFaction(),"placeholder for note");
|
||||
MarkedCell mc(targetPos,world.getThisFaction(),"placeholder for note",world.getThisFaction()->getStartLocationIndex());
|
||||
cellMarkedData = mc;
|
||||
//mapMarkedCellList[surfaceCellPos] = mc;
|
||||
|
||||
|
@ -2892,7 +2902,7 @@ void Game::processInputText(string text, bool cancelled) {
|
|||
mapMarkedCellList[cellMarkedPos] = cellMarkedData;
|
||||
|
||||
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
||||
gameNetworkInterface->sendMarkCellMessage(cellMarkedData.getTargetPos(),cellMarkedData.getFaction()->getIndex(),cellMarkedData.getNote());
|
||||
gameNetworkInterface->sendMarkCellMessage(cellMarkedData.getTargetPos(),cellMarkedData.getFaction()->getIndex(),cellMarkedData.getNote(),cellMarkedData.getFaction()->getStartLocationIndex());
|
||||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.forceQuadCacheUpdate();
|
||||
|
|
|
@ -482,7 +482,8 @@ void ClientInterface::updateLobby() {
|
|||
|
||||
MarkedCell msg(networkMessageMarkCell.getTarget(),
|
||||
networkMessageMarkCell.getFactionIndex(),
|
||||
networkMessageMarkCell.getText().c_str());
|
||||
networkMessageMarkCell.getText().c_str(),
|
||||
networkMessageMarkCell.getPlayerIndex());
|
||||
this->addMarkedCell(msg);
|
||||
}
|
||||
}
|
||||
|
@ -507,7 +508,7 @@ void ClientInterface::updateLobby() {
|
|||
|
||||
MarkedCell msg(networkMessageHighlightCell.getTarget(),
|
||||
networkMessageHighlightCell.getFactionIndex(),
|
||||
"none");
|
||||
"none",-1);
|
||||
this->setHighlightedCell(msg);
|
||||
}
|
||||
}
|
||||
|
@ -722,7 +723,8 @@ void ClientInterface::updateFrame(int *checkFrame) {
|
|||
|
||||
MarkedCell msg(networkMessageMarkCell.getTarget(),
|
||||
networkMessageMarkCell.getFactionIndex(),
|
||||
networkMessageMarkCell.getText().c_str());
|
||||
networkMessageMarkCell.getText().c_str(),
|
||||
networkMessageMarkCell.getPlayerIndex());
|
||||
this->addMarkedCell(msg);
|
||||
}
|
||||
}
|
||||
|
@ -748,7 +750,7 @@ void ClientInterface::updateFrame(int *checkFrame) {
|
|||
|
||||
MarkedCell msg(networkMessageHighlightCell.getTarget(),
|
||||
networkMessageHighlightCell.getFactionIndex(),
|
||||
"none");
|
||||
"none",-1);
|
||||
this->setHighlightedCell(msg);
|
||||
}
|
||||
}
|
||||
|
@ -1248,11 +1250,11 @@ void ClientInterface::sendTextMessage(const string &text, int teamIndex, bool ec
|
|||
}
|
||||
}
|
||||
|
||||
void ClientInterface::sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note) {
|
||||
void ClientInterface::sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note,int playerIndex) {
|
||||
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);
|
||||
|
||||
NetworkMessageMarkCell networkMessageMarkCell(targetPos,factionIndex, note);
|
||||
NetworkMessageMarkCell networkMessageMarkCell(targetPos,factionIndex, note,playerIndex);
|
||||
sendMessage(&networkMessageMarkCell);
|
||||
}
|
||||
|
||||
|
@ -1467,7 +1469,8 @@ bool ClientInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
|
|||
|
||||
MarkedCell msg(networkMessageMarkCell.getTarget(),
|
||||
networkMessageMarkCell.getFactionIndex(),
|
||||
networkMessageMarkCell.getText().c_str());
|
||||
networkMessageMarkCell.getText().c_str(),
|
||||
networkMessageMarkCell.getPlayerIndex());
|
||||
this->addMarkedCell(msg);
|
||||
}
|
||||
break;
|
||||
|
@ -1492,7 +1495,7 @@ bool ClientInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
|
|||
|
||||
MarkedCell msg(networkMessageHighlightCell.getTarget(),
|
||||
networkMessageHighlightCell.getFactionIndex(),
|
||||
"none");
|
||||
"none",-1);
|
||||
this->setHighlightedCell(msg);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
string targetLanguage);
|
||||
virtual void quitGame(bool userManuallyQuit);
|
||||
|
||||
virtual void sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note);
|
||||
virtual void sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note,int playerIndex);
|
||||
virtual void sendUnMarkCellMessage(Vec2i targetPos, int factionIndex);
|
||||
virtual void sendHighlightCellMessage(Vec2i targetPos, int factionIndex);
|
||||
//misc
|
||||
|
|
|
@ -577,7 +577,8 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
|||
if(receiveMessage(&networkMessageMarkCell)) {
|
||||
MarkedCell msg(networkMessageMarkCell.getTarget(),
|
||||
networkMessageMarkCell.getFactionIndex(),
|
||||
networkMessageMarkCell.getText().c_str());
|
||||
networkMessageMarkCell.getText().c_str(),
|
||||
networkMessageMarkCell.getPlayerIndex());
|
||||
|
||||
this->addMarkedCell(msg);
|
||||
gotCellMarkerMsg = true;
|
||||
|
@ -635,7 +636,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
|||
NetworkMessageHighlightCell networkMessageHighlightCell;
|
||||
if(receiveMessage(&networkMessageHighlightCell)) {
|
||||
MarkedCell msg(networkMessageHighlightCell.getTarget(),
|
||||
networkMessageHighlightCell.getFactionIndex(),"none");
|
||||
networkMessageHighlightCell.getFactionIndex(),"none",-1);
|
||||
|
||||
this->setHighlightedCell(msg);
|
||||
gotCellMarkerMsg = true;
|
||||
|
|
|
@ -87,6 +87,7 @@ protected:
|
|||
Vec2i targetPos;
|
||||
const Faction *faction;
|
||||
int factionIndex;
|
||||
int playerIndex;
|
||||
string note;
|
||||
int aliveCount;
|
||||
|
||||
|
@ -94,20 +95,23 @@ public:
|
|||
MarkedCell() {
|
||||
faction = NULL;
|
||||
factionIndex = -1;
|
||||
playerIndex = -1;
|
||||
note = "";
|
||||
aliveCount=200;
|
||||
}
|
||||
MarkedCell(Vec2i targetPos,const Faction *faction,string note) {
|
||||
MarkedCell(Vec2i targetPos,const Faction *faction,string note, int playerIndex) {
|
||||
this->targetPos = targetPos;
|
||||
this->faction = faction;
|
||||
this->factionIndex = -1;
|
||||
this->playerIndex = playerIndex;
|
||||
this->note = note;
|
||||
aliveCount=200;
|
||||
}
|
||||
MarkedCell(Vec2i targetPos,int factionIndex,string note) {
|
||||
MarkedCell(Vec2i targetPos,int factionIndex,string note, int playerIndex) {
|
||||
this->targetPos = targetPos;
|
||||
this->faction = NULL;
|
||||
this->factionIndex = factionIndex;
|
||||
this->playerIndex = playerIndex;
|
||||
this->note = note;
|
||||
aliveCount=200;
|
||||
}
|
||||
|
@ -120,8 +124,10 @@ public:
|
|||
void decrementAliveCount() { this->aliveCount--; }
|
||||
int getAliveCount() const { return aliveCount; }
|
||||
void setAliveCount(int value) { this->aliveCount = value; }
|
||||
int getPlayerIndex() const { return playerIndex; }
|
||||
|
||||
void setNote(string value) { note = value; }
|
||||
void setPlayerIndex(int value) { playerIndex = value; }
|
||||
};
|
||||
|
||||
class UnMarkedCell {
|
||||
|
@ -286,7 +292,7 @@ public:
|
|||
string targetLanguage)= 0;
|
||||
virtual void quitGame(bool userManuallyQuit)=0;
|
||||
|
||||
virtual void sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note) = 0;
|
||||
virtual void sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note,int playerIndex) = 0;
|
||||
virtual void sendUnMarkCellMessage(Vec2i targetPos, int factionIndex) = 0;
|
||||
virtual void sendHighlightCellMessage(Vec2i targetPos, int factionIndex) = 0;
|
||||
|
||||
|
|
|
@ -992,7 +992,7 @@ void NetworkMessageLoadingStatus::send(Socket* socket) const
|
|||
// class NetworkMessageMarkCell
|
||||
// =====================================================
|
||||
|
||||
NetworkMessageMarkCell::NetworkMessageMarkCell(Vec2i target, int factionIndex, const string &text) {
|
||||
NetworkMessageMarkCell::NetworkMessageMarkCell(Vec2i target, int factionIndex, const string &text, int playerIndex) {
|
||||
if(text.length() >= maxTextStringSize) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING / ERROR - text [%s] length = %d, max = %d\n",__FILE__,__FUNCTION__,__LINE__,text.c_str(),text.length(),maxTextStringSize);
|
||||
}
|
||||
|
@ -1002,6 +1002,7 @@ NetworkMessageMarkCell::NetworkMessageMarkCell(Vec2i target, int factionIndex, c
|
|||
data.targetX = target.x;
|
||||
data.targetY = target.y;
|
||||
data.factionIndex = factionIndex;
|
||||
data.playerIndex = playerIndex;
|
||||
}
|
||||
|
||||
NetworkMessageMarkCell * NetworkMessageMarkCell::getCopy() const {
|
||||
|
|
|
@ -752,6 +752,7 @@ private:
|
|||
int16 targetX;
|
||||
int16 targetY;
|
||||
int8 factionIndex;
|
||||
int8 playerIndex;
|
||||
NetworkString<maxTextStringSize> text;
|
||||
};
|
||||
|
||||
|
@ -760,11 +761,12 @@ private:
|
|||
|
||||
public:
|
||||
NetworkMessageMarkCell(){}
|
||||
NetworkMessageMarkCell(Vec2i target, int factionIndex, const string &text);
|
||||
NetworkMessageMarkCell(Vec2i target, int factionIndex, const string &text, int playerIndex);
|
||||
|
||||
string getText() const { return data.text.getString(); }
|
||||
Vec2i getTarget() const { return Vec2i(data.targetX,data.targetY); }
|
||||
int getFactionIndex() const { return data.factionIndex; }
|
||||
int getPlayerIndex() const { return data.playerIndex; }
|
||||
|
||||
virtual bool receive(Socket* socket);
|
||||
virtual void send(Socket* socket) const;
|
||||
|
|
|
@ -1128,7 +1128,7 @@ void ServerInterface::dispatchPendingMarkCellMessages(std::vector <string> &erro
|
|||
MarkedCell msg(chatText[chatIdx]);
|
||||
this->addMarkedCell(msg);
|
||||
|
||||
NetworkMessageMarkCell networkMessageMarkCell(msg.getTargetPos(),msg.getFactionIndex(),msg.getNote());
|
||||
NetworkMessageMarkCell networkMessageMarkCell(msg.getTargetPos(),msg.getFactionIndex(),msg.getNote(),msg.getPlayerIndex());
|
||||
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);
|
||||
|
@ -1480,14 +1480,16 @@ bool ServerInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
|
|||
|
||||
MarkedCell msg(networkMessageMarkCell.getTarget(),
|
||||
networkMessageMarkCell.getFactionIndex(),
|
||||
networkMessageMarkCell.getText().c_str());
|
||||
networkMessageMarkCell.getText().c_str(),
|
||||
networkMessageMarkCell.getPlayerIndex());
|
||||
|
||||
this->addMarkedCell(msg);
|
||||
|
||||
NetworkMessageMarkCell networkMessageMarkCellBroadcast(
|
||||
networkMessageMarkCell.getTarget(),
|
||||
networkMessageMarkCell.getFactionIndex(),
|
||||
networkMessageMarkCell.getText().c_str());
|
||||
networkMessageMarkCell.getText().c_str(),
|
||||
networkMessageMarkCell.getPlayerIndex());
|
||||
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);
|
||||
|
@ -1523,7 +1525,7 @@ bool ServerInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
|
|||
|
||||
MarkedCell msg(networkMessageHighlightCell.getTarget(),
|
||||
networkMessageHighlightCell.getFactionIndex(),
|
||||
"none");
|
||||
"none",-1);
|
||||
|
||||
this->setHighlightedCell(msg);
|
||||
|
||||
|
@ -1878,16 +1880,16 @@ void ServerInterface::sendTextMessage(const string& text, int teamIndex, bool ec
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void ServerInterface::sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note) {
|
||||
sendMarkCellMessage(targetPos, factionIndex, note, -1);
|
||||
void ServerInterface::sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note,int playerIndex) {
|
||||
sendMarkCellMessage(targetPos, factionIndex, note, playerIndex, -1);
|
||||
}
|
||||
|
||||
void ServerInterface::sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note, int lockedSlotIndex) {
|
||||
void ServerInterface::sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note, int playerIndex, 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);
|
||||
NetworkMessageMarkCell networkMessageMarkCell(targetPos,factionIndex, note);
|
||||
NetworkMessageMarkCell networkMessageMarkCell(targetPos,factionIndex, note, playerIndex);
|
||||
broadcastMessage(&networkMessageMarkCell, -1, lockedSlotIndex);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
|
|
@ -118,8 +118,8 @@ public:
|
|||
|
||||
void queueTextMessage(const string & text, int teamIndex, bool echoLocal, string targetLanguage);
|
||||
|
||||
virtual void sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note);
|
||||
void sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note, int lockedSlotIndex);
|
||||
virtual void sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note,int playerIndex);
|
||||
void sendMarkCellMessage(Vec2i targetPos, int factionIndex, string note, int playerIndex, int lockedSlotIndex);
|
||||
|
||||
virtual void sendHighlightCellMessage(Vec2i targetPos, int factionIndex);
|
||||
void sendHighlightCellMessage(Vec2i targetPos, int factionIndex, int lockedSlotIndex);
|
||||
|
|
Loading…
Reference in New Issue