Logging cleanup (#69)

* Mac OS X 10.6 & More C++03 Support

* Fix SDL2 options.txt loading for C++03

* Output/Logging Overhaul
* Added StandardOut class
* Renamed LOGX macros to LOG_X
* Removed LogMsg macros in favor of LOG_X
* Added console window for debug Windows builds

* Updated Xcode Project
+ StandardOut.hpp
+ StandardOut.cpp

* StandardOut_windows
* Replaced the Windows #ifdefs in StandardOut with StandardOut_windows

---------

Co-authored-by: Brent Da Mage <BrentDaMage@users.noreply.github.com>
This commit is contained in:
Brent
2023-08-28 02:55:41 -05:00
committed by GitHub
parent f7915a1dab
commit 5c1ea03747
43 changed files with 326 additions and 207 deletions

View File

@@ -183,7 +183,7 @@ void Inventory::addTestItem(int itemID, int amount, int auxValue)
if (inst.m_amount != 0)
{
LogMsg("AddTestItem: Couldn't add all %d of %s, only gave %d",
LOG_I("AddTestItem: Couldn't add all %d of %s, only gave %d",
amount, Item::items[itemID]->m_DescriptionID.c_str(), amount - inst.m_amount);
}
}
@@ -291,5 +291,5 @@ void Inventory::selectItemById(int itemID)
return;
}
LogMsg("selectItemById: %d doesn't exist", itemID);
LOG_W("selectItemById: %d doesn't exist", itemID);
}

View File

@@ -40,7 +40,7 @@ Item::Item(int itemID)
if (Item::items[m_itemID])
{
printf("Item conflict id @ %d! Id already used\n", m_itemID);
LOG_W("Item conflict id @ %d! Id already used\n", m_itemID);
}
Item::items[m_itemID] = this;
@@ -66,7 +66,7 @@ Item* Item::setMaxStackSize(int mss)
Item* Item::setCraftingRemainingItem(Item* pItem)
{
if (m_maxStackSize > 1)
puts("Max stack size must be 1 for items with crafting results");
LOG_W("Max stack size must be 1 for items with crafting results");
m_pCraftingRemainingItem = pItem;

View File

@@ -83,7 +83,7 @@ ChunkSource* Level::createChunkSource()
}
#endif
puts("no level data, calling dimension->createRandomLevelSource");
LOG_I("No level data, calling dimension->createRandomLevelSource");
return m_pDimension->createRandomLevelSource();
}
@@ -1029,7 +1029,7 @@ _failure:
m_levelData.m_spawnPos.y = 32;
m_levelData.m_spawnPos.z = 0;
printf("Failed to validate spawn point, using (%d, %d, %d)\n", m_levelData.m_spawnPos.x, m_levelData.m_spawnPos.y, m_levelData.m_spawnPos.z);
LOG_W("Failed to validate spawn point, using (%d, %d, %d)", m_levelData.m_spawnPos.x, m_levelData.m_spawnPos.y, m_levelData.m_spawnPos.z);
return;
#endif
@@ -1075,13 +1075,13 @@ bool Level::addEntity(Entity* pEnt)
Entity* pOldEnt = getEntity(pEnt->hashCode());
if (pOldEnt)
{
LogMsg("Warning: entity %d already exists.", pEnt->hashCode());
LOG_W("Entity %d already exists.", pEnt->hashCode());
//removeEntity(pOldEnt);
}
if (!pEnt->isPlayer() && m_bIsMultiplayer)
{
LogMsg("Hey, why are you trying to add an non-player entity in a multiplayer world?");
LOG_W("Hey, why are you trying to add an non-player entity in a multiplayer world?");
}
//@NOTE: useless Mth::floor() calls
@@ -1194,7 +1194,7 @@ _failure:
m_levelData.m_spawnPos.y = 32;
m_levelData.m_spawnPos.z = 0;
printf("Failed to validate spawn point, using (%d, %d, %d)\n", m_levelData.m_spawnPos.x, m_levelData.m_spawnPos.y, m_levelData.m_spawnPos.z);
LOG_W("Failed to validate spawn point, using (%d, %d, %d)", m_levelData.m_spawnPos.x, m_levelData.m_spawnPos.y, m_levelData.m_spawnPos.z);
return;
#endif
@@ -1406,9 +1406,7 @@ void Level::tick(Entity* pEnt, bool b)
{
if (!hasChunksAt(tileX - 32, 0, tileZ - 32, tileX + 32, 128, tileZ + 32))
{
#ifndef ORIGINAL_CODE
LogMsg("Not updating entity %d because we don't have chunks around it loaded", pEnt->m_EntityID);
#endif
LOG_W("Not updating entity %d because we don't have chunks around it loaded", pEnt->m_EntityID);
return;
}

View File

@@ -745,7 +745,7 @@ void LevelChunk::setData(int x, int y, int z, int data)
// seems to set block data in 8192 block (4*16*128) chunks for some reason ?
void LevelChunk::setBlocks(uint8_t* pData, int y)
{
puts("LevelChunk::setBlocks");
LOG_I("LevelChunk::setBlocks");
for (int i = 0; i < 8192; i++)
{
m_pBlockData[8192 * y + i] = pData[i];
@@ -774,7 +774,7 @@ void LevelChunk::setBlocks(uint8_t* pData, int y)
int LevelChunk::setBlocksAndData(uint8_t* pData, int a3, int a4, int a5, int a6, int a7, int a8, int a9)
{
puts("LevelChunk::setBlocksAndData");
LOG_I("LevelChunk::setBlocksAndData");
if (a3 >= a6)
{

View File

@@ -38,7 +38,7 @@ RandomLevelSource::RandomLevelSource(Level* level, TLong seed, int x) :
field_7E90 = nullptr;
field_7E94 = nullptr;
LogMsg("Generating world with seed: %d", seed);
LOG_I("Generating world with seed: %d", seed);
for (int a = 0; a < 32; a++)
{
@@ -51,7 +51,7 @@ RandomLevelSource::RandomLevelSource(Level* level, TLong seed, int x) :
field_7280 = new float[1024];
Random random = m_random;
printf("random.get : %d\n", random.genrand_int32() >> 1);
LOG_I("random.get : %d", random.genrand_int32() >> 1);
}
// @BUG: Potential collisions.

View File

@@ -21,7 +21,7 @@ PerlinNoise::PerlinNoise(Random* pRandom, int nOctaves)
if (nOctaves == 10)
{
LogMsg("Ok");
LOG_I("PerlinNoise octaves are 10");
}
init(nOctaves);

View File

@@ -75,7 +75,7 @@ void ExternalFileLevelStorage::savePlayerData(LevelData* levelData, std::vector<
FILE* pFile = fopen((m_levelDirPath + "/" + "player.dat").c_str(), "wb");
if (!pFile)
{
LogMsg("Not saving player data");
LOG_W("Not saving player data");
return;
}
@@ -214,7 +214,7 @@ void ExternalFileLevelStorage::save(Level* level, LevelChunk* chunk)
SAFE_DELETE(m_pRegionFile);
m_pRegionFile = nullptr;
LogMsg("Not saving :( (x: %d z: %d)", chunk->m_chunkX, chunk->m_chunkZ);
LOG_W("Not saving :( (x: %d z: %d)", chunk->m_chunkX, chunk->m_chunkZ);
return;
}

View File

@@ -56,7 +56,7 @@ void ExternalFileLevelStorageSource::getLevelList(std::vector<LevelSummary>& vls
if (!de)
break;
LogMsg("Entry: %s", de->d_name);
LOG_I("Entry: %s", de->d_name);
if (de->d_type == DT_DIR)
{

View File

@@ -37,7 +37,7 @@ bool MemoryLevelStorageSource::isNewLevelIdAcceptable(const std::string& x)
void MemoryLevelStorageSource::deleteLevel(const std::string& x)
{
LogMsg("Delete level: %s", x.c_str());
LOG_I("Delete level: %s", x.c_str());
}
void MemoryLevelStorageSource::renameLevel(const std::string& x, const std::string& y)

View File

@@ -83,7 +83,7 @@ void Tile::_init(int ID, Material* pMaterial, int texture)
if (tiles[m_ID])
// @BUG: Printing &tiles[m_ID], but probably supposed to print tiles[m_ID]
printf("Slot %d is already occupied by %p when adding %p\n", m_ID, &tiles[m_ID], this);
LOG_W("Slot %d is already occupied by %p when adding %p", m_ID, &tiles[m_ID], this);
}
Tile::~Tile()