Browse Source

Fixed false error messages on game startup

Ivan Savenko 2 years ago
parent
commit
ea1d177c9b
3 changed files with 12 additions and 14 deletions
  1. 7 2
      client/mapView/MapRenderer.cpp
  2. 1 0
      lib/NetPacksLib.cpp
  3. 4 12
      lib/serializer/Connection.cpp

+ 7 - 2
client/mapView/MapRenderer.cpp

@@ -98,8 +98,13 @@ void MapTileStorage::load(size_t index, const std::string & filename, EImageBlit
 
 
 	for(auto & entry : terrainAnimations)
 	for(auto & entry : terrainAnimations)
 	{
 	{
-		entry = std::make_unique<CAnimation>(filename);
-		entry->preload();
+		if (!filename.empty())
+		{
+			entry = std::make_unique<CAnimation>(filename);
+			entry->preload();
+		}
+		else
+			entry = std::make_unique<CAnimation>();
 
 
 		for(size_t i = 0; i < entry->size(); ++i)
 		for(size_t i = 0; i < entry->size(); ++i)
 			entry->getImage(i)->setBlitMode(blitMode);
 			entry->getImage(i)->setBlitMode(blitMode);

+ 1 - 0
lib/NetPacksLib.cpp

@@ -2166,6 +2166,7 @@ void BattleTriggerEffect::applyGs(CGameState * gs) const
 		break;
 		break;
 	}
 	}
 	case Bonus::ENCHANTER:
 	case Bonus::ENCHANTER:
+	case Bonus::MORALE:
 		break;
 		break;
 	case Bonus::FEAR:
 	case Bonus::FEAR:
 		st->fear = true;
 		st->fear = true;

+ 4 - 12
lib/serializer/Connection.cpp

@@ -83,7 +83,7 @@ CConnection::CConnection(const std::string & host, ui16 port, std::string Name,
 	if(error)
 	if(error)
 	{
 	{
 		logNetwork->error("Problem with resolving: \n%s", error.message());
 		logNetwork->error("Problem with resolving: \n%s", error.message());
-		goto connerror1;
+		throw std::runtime_error("Can't establish connection: Problem with resolving");
 	}
 	}
 	pom = endpoint_iterator;
 	pom = endpoint_iterator;
 	if(pom != end)
 	if(pom != end)
@@ -91,7 +91,7 @@ CConnection::CConnection(const std::string & host, ui16 port, std::string Name,
 	else
 	else
 	{
 	{
 		logNetwork->error("Critical problem: No endpoints found!");
 		logNetwork->error("Critical problem: No endpoints found!");
-		goto connerror1;
+		throw std::runtime_error("Can't establish connection: No endpoints found!");
 	}
 	}
 	while(pom != end)
 	while(pom != end)
 	{
 	{
@@ -110,20 +110,12 @@ CConnection::CConnection(const std::string & host, ui16 port, std::string Name,
 		}
 		}
 		else
 		else
 		{
 		{
-			logNetwork->error("Problem with connecting: %s", error.message());
+			throw std::runtime_error("Can't establish connection: Failed to connect!");
 		}
 		}
 		endpoint_iterator++;
 		endpoint_iterator++;
 	}
 	}
-
-	//we shouldn't be here - error handling
-connerror1:
-	logNetwork->error("Something went wrong... checking for error info");
-	if(error)
-		logNetwork->error(error.message());
-	else
-		logNetwork->error("No error info. ");
-	throw std::runtime_error("Can't establish connection :(");
 }
 }
+
 CConnection::CConnection(std::shared_ptr<TSocket> Socket, std::string Name, std::string UUID):
 CConnection::CConnection(std::shared_ptr<TSocket> Socket, std::string Name, std::string UUID):
 	iser(this),
 	iser(this),
 	oser(this),
 	oser(this),