1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Clean up RMG logs

This commit is contained in:
Tomasz Zieliński 2024-02-25 11:40:01 +01:00
parent 8d86216332
commit 2e8801084d
4 changed files with 25 additions and 10 deletions

View File

@ -24,6 +24,8 @@
VCMI_LIB_NAMESPACE_BEGIN
//#define ZONE_PLACEMENT_LOG true
class CRandomGenerator;
CZonePlacer::CZonePlacer(RmgMap & map)
@ -248,7 +250,8 @@ void CZonePlacer::placeOnGrid(CRandomGenerator* rand)
}
//TODO: toggle with a flag
logGlobal->info("Initial zone grid:");
#ifdef ZONE_PLACEMENT_LOG
logGlobal->trace("Initial zone grid:");
for (size_t x = 0; x < gridSize; ++x)
{
std::string s;
@ -263,8 +266,9 @@ void CZonePlacer::placeOnGrid(CRandomGenerator* rand)
s += " -- ";
}
}
logGlobal->info(s);
logGlobal->trace(s);
}
#endif
//Set initial position for zones - random position in square centered around (x, y)
for (size_t x = 0; x < gridSize; ++x)
@ -372,7 +376,9 @@ void CZonePlacer::placeZones(CRandomGenerator * rand)
bestSolution[zone.second] = zone.second->getCenter();
}
#ifdef ZONE_PLACEMENT_LOG
logGlobal->trace("Total distance between zones after this iteration: %2.4f, Total overlap: %2.4f, Improved: %s", totalDistance, totalOverlap , improvement);
#endif
return improvement;
};
@ -419,7 +425,9 @@ void CZonePlacer::placeZones(CRandomGenerator * rand)
for(const auto & zone : zones) //finalize zone positions
{
zone.second->setPos (cords (bestSolution[zone.second]));
#ifdef ZONE_PLACEMENT_LOG
logGlobal->trace("Placed zone %d at relative position %s and coordinates %s", zone.first, zone.second->getCenter().toString(), zone.second->getPos().toString());
#endif
}
}
@ -688,7 +696,9 @@ void CZonePlacer::moveOneZone(TZoneMap& zones, TForceVector& totalForces, TDista
return lhs.first > rhs.first; //Largest dispalcement first
});
#ifdef ZONE_PLACEMENT_LOG
logGlobal->trace("Worst misplacement/movement ratio: %3.2f", misplacedZones.front().first);
#endif
if (misplacedZones.size() >= 2)
{
@ -721,7 +731,9 @@ void CZonePlacer::moveOneZone(TZoneMap& zones, TForceVector& totalForces, TDista
}
if (secondZone)
{
#ifdef ZONE_PLACEMENT_LOG
logGlobal->trace("Swapping two misplaced zones %d and %d", firstZone->getId(), secondZone->getId());
#endif
auto firstCenter = firstZone->getCenter();
auto secondCenter = secondZone->getCenter();
@ -764,7 +776,9 @@ void CZonePlacer::moveOneZone(TZoneMap& zones, TForceVector& totalForces, TDista
{
float3 vec = targetZone->getCenter() - ourCenter;
float newDistanceBetweenZones = (std::max(misplacedZone->getSize(), targetZone->getSize())) / mapSize;
#ifdef ZONE_PLACEMENT_LOG
logGlobal->trace("Trying to move zone %d %s towards %d %s. Direction is %s", misplacedZone->getId(), ourCenter.toString(), targetZone->getId(), targetZone->getCenter().toString(), vec.toString());
#endif
misplacedZone->setCenter(targetZone->getCenter() - vec.unitVector() * newDistanceBetweenZones); //zones should now overlap by half size
}
@ -792,7 +806,9 @@ void CZonePlacer::moveOneZone(TZoneMap& zones, TForceVector& totalForces, TDista
{
float3 vec = ourCenter - targetZone->getCenter();
float newDistanceBetweenZones = (misplacedZone->getSize() + targetZone->getSize()) / mapSize;
#ifdef ZONE_PLACEMENT_LOG
logGlobal->trace("Trying to move zone %d %s away from %d %s. Direction is %s", misplacedZone->getId(), ourCenter.toString(), targetZone->getId(), targetZone->getCenter().toString(), vec.toString());
#endif
misplacedZone->setCenter(targetZone->getCenter() + vec.unitVector() * newDistanceBetweenZones); //zones should now be just separated
}

View File

@ -278,7 +278,7 @@ void Zone::fractalize()
float blockDistance = minDistance * spanFactor; //More obstacles in the Underground
freeDistance = freeDistance * marginFactor;
vstd::amax(freeDistance, 4 * 4);
logGlobal->info("Zone %d: treasureValue %d blockDistance: %2.f, freeDistance: %2.f", getId(), treasureValue, blockDistance, freeDistance);
logGlobal->trace("Zone %d: treasureValue %d blockDistance: %2.f, freeDistance: %2.f", getId(), treasureValue, blockDistance, freeDistance);
if(type != ETemplateZoneType::JUNCTION)
{
@ -381,7 +381,6 @@ void Zone::initModificators()
{
modificator->init();
}
logGlobal->info("Zone %d modificators initialized", getId());
}
CRandomGenerator& Zone::getRand()

View File

@ -80,7 +80,7 @@ void Modificator::run()
if(!finished)
{
logGlobal->info("Modificator zone %d - %s - started", zone.getId(), getName());
logGlobal->trace("Modificator zone %d - %s - started", zone.getId(), getName());
CStopWatch processTime;
try
{
@ -94,7 +94,7 @@ void Modificator::run()
dump();
#endif
finished = true;
logGlobal->info("Modificator zone %d - %s - done (%d ms)", zone.getId(), getName(), processTime.getDiff());
logGlobal->trace("Modificator zone %d - %s - done (%d ms)", zone.getId(), getName(), processTime.getDiff());
}
}

View File

@ -40,14 +40,14 @@ void QuestArtifactPlacer::addQuestArtZone(std::shared_ptr<Zone> otherZone)
void QuestArtifactPlacer::addQuestArtifact(const ArtifactID& id)
{
logGlobal->info("Need to place quest artifact %s", VLC->artifacts()->getById(id)->getNameTranslated());
logGlobal->trace("Need to place quest artifact %s", VLC->artifacts()->getById(id)->getNameTranslated());
RecursiveLock lock(externalAccessMutex);
questArtifactsToPlace.emplace_back(id);
}
void QuestArtifactPlacer::removeQuestArtifact(const ArtifactID& id)
{
logGlobal->info("Will not try to place quest artifact %s", VLC->artifacts()->getById(id)->getNameTranslated());
logGlobal->trace("Will not try to place quest artifact %s", VLC->artifacts()->getById(id)->getNameTranslated());
RecursiveLock lock(externalAccessMutex);
vstd::erase_if_present(questArtifactsToPlace, id);
}
@ -76,7 +76,7 @@ void QuestArtifactPlacer::findZonesForQuestArts()
}
}
logGlobal->info("Number of nearby zones suitable for quest artifacts: %d", questArtZones.size());
logGlobal->trace("Number of nearby zones suitable for quest artifacts: %d", questArtZones.size());
}
void QuestArtifactPlacer::placeQuestArtifacts(CRandomGenerator & rand)
@ -92,7 +92,7 @@ void QuestArtifactPlacer::placeQuestArtifacts(CRandomGenerator & rand)
continue;
auto artifactToReplace = *RandomGeneratorUtil::nextItem(artifactsToReplace, rand);
logGlobal->info("Replacing %s at %s with the quest artifact %s",
logGlobal->trace("Replacing %s at %s with the quest artifact %s",
artifactToReplace->getObjectName(),
artifactToReplace->getPosition().toString(),
VLC->artifacts()->getById(artifactToPlace)->getNameTranslated());