- bugfixes for handling missing maps on client
This commit is contained in:
parent
da35728c34
commit
0e8ed05c2e
|
@ -54,6 +54,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
|
||||
currentFactionLogo = "";
|
||||
factionTexture=NULL;
|
||||
lastMissingMap="";
|
||||
|
||||
activeInputLabel = NULL;
|
||||
lastNetworkSendPing = 0;
|
||||
|
@ -797,6 +798,7 @@ void MenuStateConnectedGame::update() {
|
|||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
if(chrono.getMillis() > 0) chrono.start();
|
||||
|
||||
try {
|
||||
bool mustSwitchPlayerName = false;
|
||||
if(clientInterface->getGameSettingsReceived()) {
|
||||
updateDataSynchDetailText = true;
|
||||
|
@ -832,12 +834,19 @@ void MenuStateConnectedGame::update() {
|
|||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] hasFactions = %d, currentFactionName [%s]\n",__FILE__,__FUNCTION__,__LINE__,hasFactions,currentFactionName.c_str());
|
||||
|
||||
// map
|
||||
maps.push_back(formatString(gameSettings->getMap()));
|
||||
listBoxMap.setItems(maps);
|
||||
if(currentMap != gameSettings->getMap()) {// load the setup again
|
||||
currentMap = gameSettings->getMap();
|
||||
}
|
||||
loadMapInfo(Map::getMapPath(currentMap), &mapInfo, true);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
bool mapLoaded = loadMapInfo(Map::getMapPath(currentMap,"",false), &mapInfo, true);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(mapLoaded == true) {
|
||||
maps.push_back(formatString(gameSettings->getMap()));
|
||||
}
|
||||
else {
|
||||
maps.push_back("***missing***");
|
||||
}
|
||||
listBoxMap.setItems(maps);
|
||||
labelMapInfo.setText(mapInfo.desc);
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -963,7 +972,7 @@ void MenuStateConnectedGame::update() {
|
|||
//update lobby
|
||||
clientInterface= NetworkManager::getInstance().getClientInterface();
|
||||
if(clientInterface != NULL && clientInterface->isConnected()) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] clientInterface = %p\n",__FILE__,__FUNCTION__,__LINE__,clientInterface);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] clientInterface = %p\n",__FILE__,__FUNCTION__,__LINE__,clientInterface);
|
||||
clientInterface->updateLobby();
|
||||
|
||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
|
@ -973,7 +982,7 @@ void MenuStateConnectedGame::update() {
|
|||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
if(chrono.getMillis() > 0) chrono.start();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
clientInterface= NetworkManager::getInstance().getClientInterface();
|
||||
if(clientInterface != NULL && clientInterface->isConnected()) {
|
||||
|
@ -1021,6 +1030,14 @@ void MenuStateConnectedGame::update() {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const runtime_error &ex) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"Error [%s]",ex.what());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf);
|
||||
//throw runtime_error(szBuf);
|
||||
showMessageBox( szBuf, "Error", false);
|
||||
}
|
||||
|
||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
if(chrono.getMillis() > 0) chrono.start();
|
||||
|
@ -1119,7 +1136,8 @@ bool MenuStateConnectedGame::hasNetworkGameSettings()
|
|||
}
|
||||
catch(const std::exception &ex) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
sprintf(szBuf,"Error [%s]",ex.what());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf);
|
||||
//throw runtime_error(szBuf);
|
||||
showMessageBox( szBuf, "Error", false);
|
||||
}
|
||||
|
@ -1295,7 +1313,7 @@ void MenuStateConnectedGame::cleanupFactionTexture() {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::loadMapInfo(string file, MapInfo *mapInfo, bool loadMapPreview) {
|
||||
bool MenuStateConnectedGame::loadMapInfo(string file, MapInfo *mapInfo, bool loadMapPreview) {
|
||||
|
||||
struct MapFileHeader{
|
||||
int32 version;
|
||||
|
@ -1309,10 +1327,21 @@ void MenuStateConnectedGame::loadMapInfo(string file, MapInfo *mapInfo, bool loa
|
|||
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
try{
|
||||
bool mapLoaded = false;
|
||||
try {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] map [%s]\n",__FILE__,__FUNCTION__,__LINE__,file.c_str());
|
||||
|
||||
if(file != "") {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
lastMissingMap = file;
|
||||
|
||||
FILE *f= fopen(file.c_str(), "rb");
|
||||
if(f==NULL)
|
||||
throw runtime_error("Can't open file");
|
||||
if(f==NULL) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
throw runtime_error("[2]Can't open file");
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
MapFileHeader header;
|
||||
size_t readBytes = fread(&header, sizeof(MapFileHeader), 1, f);
|
||||
|
@ -1340,12 +1369,36 @@ void MenuStateConnectedGame::loadMapInfo(string file, MapInfo *mapInfo, bool loa
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
mapPreview.loadFromFile(file.c_str());
|
||||
}
|
||||
|
||||
mapLoaded = true;
|
||||
}
|
||||
catch(exception e){
|
||||
else {
|
||||
mapInfo->desc = "***missing***";
|
||||
|
||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||
ClientInterface* clientInterface= networkManager.getClientInterface();
|
||||
const GameSettings *gameSettings = clientInterface->getGameSettings();
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] map [%s] lastMissingMap [%s] gameSettings->getMap() [%s]\n",__FILE__,__FUNCTION__,__LINE__,file.c_str(),lastMissingMap.c_str(),gameSettings->getMap().c_str());
|
||||
if(lastMissingMap != gameSettings->getMap()) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
lastMissingMap = gameSettings->getMap();
|
||||
|
||||
char szMsg[1024]="";
|
||||
sprintf(szMsg,"Player: %s is missing the map: %s",getHumanPlayerName().c_str(),gameSettings->getMap().c_str());
|
||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(exception &e){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||
|
||||
//throw runtime_error("Error loading map file: "+file+'\n'+e.what());
|
||||
showMessageBox( "Error loading map file: "+file+'\n'+e.what(), "Error", false);
|
||||
}
|
||||
|
||||
return mapLoaded;
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::showMessageBox(const string &text, const string &header, bool toggle){
|
||||
|
|
|
@ -123,6 +123,8 @@ private:
|
|||
GraphicMessageBox mainMessageBox;
|
||||
int mainMessageBoxState;
|
||||
|
||||
std::string lastMissingMap;
|
||||
|
||||
public:
|
||||
|
||||
MenuStateConnectedGame(Program *program, MainMenu *mainMenu, JoinMenu joinMenuInfo=jmSimple, bool openNetworkSlots= false);
|
||||
|
@ -149,7 +151,7 @@ private:
|
|||
|
||||
void cleanupFactionTexture();
|
||||
void loadFactionTexture(string filepath);
|
||||
void loadMapInfo(string file, MapInfo *mapInfo, bool loadMapPreview);
|
||||
bool loadMapInfo(string file, MapInfo *mapInfo, bool loadMapPreview);
|
||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||
|
||||
};
|
||||
|
|
|
@ -150,7 +150,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
|
||||
for ( int i = 0 ; i<mapFiles.size(); i++ )
|
||||
{// fetch info and put map in right list
|
||||
loadMapInfo(Map::getMapPath(mapFiles.at(i)), &mapInfo, false);
|
||||
loadMapInfo(Map::getMapPath(mapFiles.at(i),"",false), &mapInfo, false);
|
||||
playerSortedMaps[mapInfo.players].push_back(mapFiles.at(i));
|
||||
formattedPlayerSortedMaps[mapInfo.players].push_back(formatString(mapFiles.at(i)));
|
||||
}
|
||||
|
@ -750,7 +750,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
|
||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||
|
||||
loadMapInfo(Map::getMapPath(getCurrentMapFile()), &mapInfo, true);
|
||||
loadMapInfo(Map::getMapPath(getCurrentMapFile(),"",false), &mapInfo, true);
|
||||
labelMapInfo.setText(mapInfo.desc);
|
||||
updateControlers();
|
||||
updateNetworkSlots();
|
||||
|
@ -2086,7 +2086,7 @@ void MenuStateCustomGame::loadMapInfo(string file, MapInfo *mapInfo, bool loadMa
|
|||
mapPreview.loadFromFile(file.c_str());
|
||||
}
|
||||
}
|
||||
catch(exception e){
|
||||
catch(exception &e){
|
||||
throw runtime_error("Error loading map file: [" + file + "] msg: " + e.what());
|
||||
}
|
||||
|
||||
|
|
|
@ -159,13 +159,13 @@ std::string ClientInterface::getServerIpAddress() {
|
|||
}
|
||||
|
||||
void ClientInterface::updateLobby() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//clear chat variables
|
||||
clearChatInfo();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
NetworkMessageType networkMessageType = getNextMessageType(true);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
switch(networkMessageType)
|
||||
{
|
||||
case nmtInvalid:
|
||||
|
|
|
@ -451,7 +451,7 @@ void ConnectionSlot::update(bool checkForNewClients) {
|
|||
int32 tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,scenarioDir), string("/") + serverInterface->getGameSettings()->getTileset() + string("/*"), ".xml", NULL);
|
||||
int32 techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,scenarioDir), "/" + serverInterface->getGameSettings()->getTech() + "/*", ".xml", NULL);
|
||||
Checksum checksum;
|
||||
string file = Map::getMapPath(serverInterface->getGameSettings()->getMap(),scenarioDir);
|
||||
string file = Map::getMapPath(serverInterface->getGameSettings()->getMap(),scenarioDir,false);
|
||||
checksum.addFile(file);
|
||||
int32 mapCRC = checksum.getSum();
|
||||
|
||||
|
@ -512,7 +512,7 @@ void ConnectionSlot::update(bool checkForNewClients) {
|
|||
this->setNetworkGameDataSynchCheckTechMismatchReport(report);
|
||||
}
|
||||
if(networkGameDataSynchCheckOkMap == false) {
|
||||
vctFileList.push_back(std::pair<string,int32>(Map::getMapPath(serverInterface->getGameSettings()->getMap(),scenarioDir),mapCRC));
|
||||
vctFileList.push_back(std::pair<string,int32>(Map::getMapPath(serverInterface->getGameSettings()->getMap(),scenarioDir,false),mapCRC));
|
||||
}
|
||||
|
||||
//for(int i = 0; i < vctFileList.size(); i++)
|
||||
|
|
|
@ -497,7 +497,7 @@ NetworkMessageSynchNetworkGameData::NetworkMessageSynchNetworkGameData(const Gam
|
|||
|
||||
//map
|
||||
Checksum checksum;
|
||||
string file = Map::getMapPath(gameSettings->getMap(),scenarioDir);
|
||||
string file = Map::getMapPath(gameSettings->getMap(),scenarioDir,false);
|
||||
checksum.addFile(file);
|
||||
data.header.mapCRC = checksum.getSum();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user