Make logger automatically put a newline (#675)

at the end of the line
remove all the newlines in log calls
This commit is contained in:
Aaron Kimbrell
2022-07-24 21:26:51 -05:00
committed by GitHub
parent a7fb6eb3f3
commit e97ae92624
86 changed files with 1249 additions and 1252 deletions

View File

@@ -18,11 +18,10 @@ Level::Level(Zone* parentZone, const std::string& filepath) {
m_ParentZone = parentZone;
std::ifstream file(filepath, std::ios_base::in | std::ios_base::binary);
if (file) {
//printf("Opened %s\n", filepath.c_str());
ReadChunks(file);
}
else {
Game::logger->Log("Level", "Failed to load %s\n", filepath.c_str());
Game::logger->Log("Level", "Failed to load %s", filepath.c_str());
}
file.close();
@@ -96,7 +95,7 @@ void Level::ReadChunks(std::ifstream & file) {
for (uint32_t i = 0; i < s; ++i) {
file.ignore(4); //a uint
file.ignore(4); //two floats
file.ignore(4);
file.ignore(4);
}
}
}
@@ -110,7 +109,7 @@ void Level::ReadChunks(std::ifstream & file) {
if (header.chunkVersion >= 36) {
file.ignore(3 * 4);
}
if (header.chunkVersion < 42) {
file.ignore(3 * 4);
@@ -176,7 +175,7 @@ void Level::ReadSceneObjectDataChunk(std::ifstream & file, Header & header) {
BinaryIO::BinaryRead(file, obj.rotation);
BinaryIO::BinaryRead(file, obj.scale);
//This is a little bit of a bodge, but because the alpha client (HF) doesn't store the
//This is a little bit of a bodge, but because the alpha client (HF) doesn't store the
//spawn position / rotation like the later versions do, we need to check the LOT for the spawn pos & set it.
if (obj.lot == LOT_MARKER_PLAYER_START) {
dZoneManager::Instance()->GetZone()->SetSpawnPos(obj.position);
@@ -186,18 +185,18 @@ void Level::ReadSceneObjectDataChunk(std::ifstream & file, Header & header) {
std::u16string ldfString = u"";
uint32_t length = 0;
BinaryIO::BinaryRead(file, length);
for (uint32_t i = 0; i < length; ++i) {
uint16_t data;
BinaryIO::BinaryRead(file, data);
ldfString.push_back(data);
}
std::string sData = GeneralUtils::UTF16ToWTF8(ldfString);
std::stringstream ssData(sData);
std::string token;
char deliminator = '\n';
while (std::getline(ssData, token, deliminator)) {
LDFBaseData * ldfData = LDFBaseData::DataFromString(token);
obj.settings.push_back(ldfData);
@@ -260,11 +259,11 @@ void Level::ReadSceneObjectDataChunk(std::ifstream & file, Header & header) {
if (data->GetKey() == u"spawner_active_on_load") {
spawnInfo.activeOnLoad = std::stoi(data->GetValueAsString());
}
if (data->GetKey() == u"active_on_load") {
spawnInfo.activeOnLoad = std::stoi(data->GetValueAsString());
}
if (data->GetKey() == u"respawn") {
if (data->GetValueType() == eLDFType::LDF_TYPE_FLOAT) // Floats are in seconds
{
@@ -350,6 +349,5 @@ void Level::ReadSceneObjectDataChunk(std::ifstream & file, Header & header) {
}
}
//printf("Loaded %u objects!\n", objectsCount);
header.sceneObjects = chunk;
}

View File

@@ -24,7 +24,7 @@ Zone::Zone(const LWOMAPID & mapID, const LWOINSTANCEID & instanceID, const LWOCL
}
Zone::~Zone() {
Game::logger->Log("Zone", "Destroying zone %i\n", m_ZoneID.GetMapID());
Game::logger->Log("Zone", "Destroying zone %i", m_ZoneID.GetMapID());
for (std::map<LWOSCENEID, SceneRef>::iterator it = m_Scenes.begin(); it != m_Scenes.end(); ++it) {
if (it->second.level != nullptr) delete it->second.level;
}
@@ -45,12 +45,12 @@ void Zone::LoadZoneIntoMemory() {
std::ifstream file(m_ZoneFilePath, std::ios::binary);
if (file) {
BinaryIO::BinaryRead(file, m_ZoneFileFormatVersion);
uint32_t mapRevision = 0;
if (m_ZoneFileFormatVersion >= Zone::ZoneFileFormatVersion::Alpha) BinaryIO::BinaryRead(file, mapRevision);
BinaryIO::BinaryRead(file, m_WorldID);
if ((uint16_t)m_WorldID != m_ZoneID.GetMapID()) Game::logger->Log("Zone", "WorldID: %i doesn't match MapID %i! Is this intended?\n", m_WorldID, m_ZoneID.GetMapID());
if ((uint16_t)m_WorldID != m_ZoneID.GetMapID()) Game::logger->Log("Zone", "WorldID: %i doesn't match MapID %i! Is this intended?", m_WorldID, m_ZoneID.GetMapID());
AddRevision(LWOSCENEID_INVALID, mapRevision);
@@ -58,7 +58,7 @@ void Zone::LoadZoneIntoMemory() {
BinaryIO::BinaryRead(file, m_Spawnpoint);
BinaryIO::BinaryRead(file, m_SpawnpointRotation);
}
if (m_ZoneFileFormatVersion <= Zone::ZoneFileFormatVersion::LateAlpha) {
uint8_t sceneCount;
BinaryIO::BinaryRead(file, sceneCount);
@@ -102,7 +102,7 @@ void Zone::LoadZoneIntoMemory() {
for (uint32_t i = 0; i < pathCount; ++i) {
LoadPath(file);
}
for (Path path : m_Paths) {
if (path.pathType == PathType::Spawner) {
SpawnerInfo info = SpawnerInfo();
@@ -150,16 +150,16 @@ void Zone::LoadZoneIntoMemory() {
Spawner* spawner = new Spawner(info);
dZoneManager::Instance()->AddSpawner(info.spawnerID, spawner);
}
}
//m_PathData.resize(m_PathDataLength);
//file.read((char*)&m_PathData[0], m_PathDataLength);
}
}
else {
Game::logger->Log("Zone", "Failed to open: %s\n", m_ZoneFilePath.c_str());
Game::logger->Log("Zone", "Failed to open: %s", m_ZoneFilePath.c_str());
}
m_ZonePath = m_ZoneFilePath.substr(0, m_ZoneFilePath.rfind('/') + 1);
@@ -226,7 +226,7 @@ void Zone::AddRevision(LWOSCENEID sceneID, uint32_t revision) {
const void Zone::PrintAllGameObjects() {
for (std::pair<LWOSCENEID, SceneRef> scene : m_Scenes) {
Game::logger->Log("Zone", "\nIn sceneID: %i\n\n", scene.first.GetSceneID());
Game::logger->Log("Zone", "In sceneID: %i", scene.first.GetSceneID());
scene.second.level->PrintAllObjects();
}
}
@@ -242,7 +242,7 @@ void Zone::LoadScene(std::ifstream & file) {
std::string luTriggersPath = scene.filename.substr(0, scene.filename.size() - 4) + ".lutriggers";
std::vector<LUTriggers::Trigger*> triggers = LoadLUTriggers(luTriggersPath, scene.id);
for (LUTriggers::Trigger* trigger : triggers) {
scene.triggers.insert({ trigger->id, trigger });
}
@@ -283,13 +283,13 @@ std::vector<LUTriggers::Trigger*> Zone::LoadLUTriggers(std::string triggerFile,
if (!doc) return lvlTriggers;
if (doc->Parse(data.str().c_str(), data.str().size()) == 0) {
//Game::logger->Log("Zone", "Loaded LUTriggers from file %s!\n", triggerFile.c_str());
//Game::logger->Log("Zone", "Loaded LUTriggers from file %s!", triggerFile.c_str());
}
else {
Game::logger->Log("Zone", "Failed to load LUTriggers from file %s\n", triggerFile.c_str());
Game::logger->Log("Zone", "Failed to load LUTriggers from file %s", triggerFile.c_str());
return lvlTriggers;
}
tinyxml2::XMLElement* triggers = doc->FirstChildElement("triggers");
if (!triggers) return lvlTriggers;
@@ -323,7 +323,7 @@ std::vector<LUTriggers::Trigger*> Zone::LoadLUTriggers(std::string triggerFile,
currentTrigger = currentTrigger->NextSiblingElement("trigger");
lvlTriggers.push_back(newTrigger);
}
delete doc;
return lvlTriggers;
@@ -474,8 +474,8 @@ void Zone::LoadPath(std::ifstream & file) {
BinaryIO::BinaryRead(file, waypoint.position.x);
BinaryIO::BinaryRead(file, waypoint.position.y);
BinaryIO::BinaryRead(file, waypoint.position.z);
if (path.pathType == PathType::Spawner || path.pathType == PathType::MovingPlatform || path.pathType == PathType::Race) {
BinaryIO::BinaryRead(file, waypoint.rotation.w);
BinaryIO::BinaryRead(file, waypoint.rotation.x);
@@ -565,7 +565,7 @@ void Zone::LoadPath(std::ifstream & file) {
path.pathWaypoints.push_back(waypoint);
}
m_Paths.push_back(path);
}

View File

@@ -15,7 +15,7 @@
dZoneManager* dZoneManager::m_Address = nullptr;
void dZoneManager::Initialize(const LWOZONEID& zoneID) {
Game::logger->Log("dZoneManager", "Preparing zone: %i/%i/%i\n", zoneID.GetMapID(), zoneID.GetInstanceID(), zoneID.GetCloneID());
Game::logger->Log("dZoneManager", "Preparing zone: %i/%i/%i", zoneID.GetMapID(), zoneID.GetInstanceID(), zoneID.GetCloneID());
int64_t startTime = 0;
int64_t endTime = 0;
@@ -40,7 +40,7 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) {
}
}
Game::logger->Log("dZoneManager", "Creating zone control object %i\n", zoneControlTemplate);
Game::logger->Log("dZoneManager", "Creating zone control object %i", zoneControlTemplate);
// Create ZoneControl object
EntityInfo info;
@@ -53,7 +53,7 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) {
endTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
Game::logger->Log("dZoneManager", "Zone prepared in: %llu ms\n", (endTime - startTime));
Game::logger->Log("dZoneManager", "Zone prepared in: %llu ms", (endTime - startTime));
VanityUtilities::SpawnVanity();
}
@@ -89,7 +89,7 @@ void dZoneManager::NotifyZone(const dZoneNotifier & notifier, const LWOOBJID& ob
case dZoneNotifier::SpawnedChildObjectDestroyed:
break;
case dZoneNotifier::ReloadZone:
Game::logger->Log("dZoneManager", "Forcing reload of zone %i\n", m_ZoneID.GetMapID());
Game::logger->Log("dZoneManager", "Forcing reload of zone %i", m_ZoneID.GetMapID());
LoadZone(m_ZoneID);
m_pZone->Initalize();
@@ -102,10 +102,10 @@ void dZoneManager::NotifyZone(const dZoneNotifier & notifier, const LWOOBJID& ob
m_pZone->PrintAllGameObjects();
break;
case dZoneNotifier::InvalidNotifier:
Game::logger->Log("dZoneManager", "Got an invalid zone notifier.\n");
Game::logger->Log("dZoneManager", "Got an invalid zone notifier.");
break;
default:
Game::logger->Log("dZoneManager", "Unknown zone notifier: %i\n", int(notifier));
Game::logger->Log("dZoneManager", "Unknown zone notifier: %i", int(notifier));
}
}
@@ -188,7 +188,7 @@ void dZoneManager::RemoveSpawner(const LWOOBJID id)
auto* spawner = GetSpawner(id);
if (spawner == nullptr) {
Game::logger->Log("dZoneManager", "Failed to find spawner (%llu)\n", id);
Game::logger->Log("dZoneManager", "Failed to find spawner (%llu)", id);
return;
}
@@ -199,7 +199,7 @@ void dZoneManager::RemoveSpawner(const LWOOBJID id)
}
else {
Game::logger->Log("dZoneManager", "Failed to find spawner entity (%llu)\n", id);
Game::logger->Log("dZoneManager", "Failed to find spawner entity (%llu)", id);
}
for (auto* node : spawner->m_Info.nodes)
@@ -218,7 +218,7 @@ void dZoneManager::RemoveSpawner(const LWOOBJID id)
spawner->Deactivate();
Game::logger->Log("dZoneManager", "Destroying spawner (%llu)\n", id);
Game::logger->Log("dZoneManager", "Destroying spawner (%llu)", id);
m_Spawners.erase(id);