Skip to content

Commit

Permalink
Replace PP with direct printing
Browse files Browse the repository at this point in the history
  • Loading branch information
numberZero authored and sfan5 committed Jun 26, 2023
1 parent de77fe8 commit 3b74cc4
Show file tree
Hide file tree
Showing 18 changed files with 110 additions and 109 deletions.
5 changes: 3 additions & 2 deletions src/database/database-leveldb.cpp
Expand Up @@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"
#include "exceptions.h"
#include "remoteplayer.h"
#include "irrlicht_changes/printing.h"
#include "server/player_sao.h"
#include "util/serialize.h"
#include "util/string.h"
Expand Down Expand Up @@ -58,7 +59,7 @@ bool Database_LevelDB::saveBlock(const v3s16 &pos, const std::string &data)
i64tos(getBlockAsInteger(pos)), data);
if (!status.ok()) {
warningstream << "saveBlock: LevelDB error saving block "
<< PP(pos) << ": " << status.ToString() << std::endl;
<< pos << ": " << status.ToString() << std::endl;
return false;
}

Expand All @@ -80,7 +81,7 @@ bool Database_LevelDB::deleteBlock(const v3s16 &pos)
i64tos(getBlockAsInteger(pos)));
if (!status.ok()) {
warningstream << "deleteBlock: LevelDB error deleting block "
<< PP(pos) << ": " << status.ToString() << std::endl;
<< pos << ": " << status.ToString() << std::endl;
return false;
}

Expand Down
11 changes: 6 additions & 5 deletions src/database/database-redis.cpp
Expand Up @@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "settings.h"
#include "log.h"
#include "exceptions.h"
#include "irrlicht_changes/printing.h"
#include "util/string.h"

#include <hiredis.h>
Expand Down Expand Up @@ -98,13 +99,13 @@ bool Database_Redis::saveBlock(const v3s16 &pos, const std::string &data)
hash.c_str(), tmp.c_str(), data.c_str(), data.size()));
if (!reply) {
warningstream << "saveBlock: redis command 'HSET' failed on "
"block " << PP(pos) << ": " << ctx->errstr << std::endl;
"block " << pos << ": " << ctx->errstr << std::endl;
freeReplyObject(reply);
return false;
}

if (reply->type == REDIS_REPLY_ERROR) {
warningstream << "saveBlock: saving block " << PP(pos)
warningstream << "saveBlock: saving block " << pos
<< " failed: " << std::string(reply->str, reply->len) << std::endl;
freeReplyObject(reply);
return false;
Expand Down Expand Up @@ -134,7 +135,7 @@ void Database_Redis::loadBlock(const v3s16 &pos, std::string *block)
case REDIS_REPLY_ERROR: {
std::string errstr(reply->str, reply->len);
freeReplyObject(reply);
errorstream << "loadBlock: loading block " << PP(pos)
errorstream << "loadBlock: loading block " << pos
<< " failed: " << errstr << std::endl;
throw DatabaseException(std::string(
"Redis command 'HGET %s %s' errored: ") + errstr);
Expand All @@ -146,7 +147,7 @@ void Database_Redis::loadBlock(const v3s16 &pos, std::string *block)
}
}

errorstream << "loadBlock: loading block " << PP(pos)
errorstream << "loadBlock: loading block " << pos
<< " returned invalid reply type " << reply->type
<< ": " << std::string(reply->str, reply->len) << std::endl;
freeReplyObject(reply);
Expand All @@ -164,7 +165,7 @@ bool Database_Redis::deleteBlock(const v3s16 &pos)
throw DatabaseException(std::string(
"Redis command 'HDEL %s %s' failed: ") + ctx->errstr);
} else if (reply->type == REDIS_REPLY_ERROR) {
warningstream << "deleteBlock: deleting block " << PP(pos)
warningstream << "deleteBlock: deleting block " << pos
<< " failed: " << std::string(reply->str, reply->len) << std::endl;
freeReplyObject(reply);
return false;
Expand Down
3 changes: 2 additions & 1 deletion src/database/database-sqlite3.cpp
Expand Up @@ -34,6 +34,7 @@ SQLite format specification:
#include "porting.h"
#include "util/string.h"
#include "remoteplayer.h"
#include "irrlicht_changes/printing.h"
#include "server/player_sao.h"

#include <cassert>
Expand Down Expand Up @@ -252,7 +253,7 @@ bool MapDatabaseSQLite3::deleteBlock(const v3s16 &pos)

if (!good) {
warningstream << "deleteBlock: Block failed to delete "
<< PP(pos) << ": " << sqlite3_errmsg(m_database) << std::endl;
<< pos << ": " << sqlite3_errmsg(m_database) << std::endl;
}
return good;
}
Expand Down
9 changes: 5 additions & 4 deletions src/emerge.cpp
Expand Up @@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "config.h"
#include "constants.h"
#include "environment.h"
#include "irrlicht_changes/printing.h"
#include "log.h"
#include "map.h"
#include "mapblock.h"
Expand Down Expand Up @@ -631,7 +632,7 @@ MapBlock *EmergeThread::finishGen(v3s16 pos, BlockMakeData *bmdata,
MapBlock *block = m_map->getBlockNoCreateNoEx(pos);
if (!block) {
errorstream << "EmergeThread::finishGen: Couldn't grab block we "
"just generated: " << PP(pos) << std::endl;
"just generated: " << pos << std::endl;
return NULL;
}

Expand Down Expand Up @@ -701,7 +702,7 @@ void *EmergeThread::run()
continue;

bool allow_gen = bedata.flags & BLOCK_EMERGE_ALLOW_GEN;
EMERGE_DBG_OUT("pos=" PP(pos) " allow_gen=" << allow_gen);
EMERGE_DBG_OUT("pos=" << pos << " allow_gen=" << allow_gen);

action = getBlockOrStartGen(pos, allow_gen, &block, &bmdata);
if (action == EMERGE_GENERATED) {
Expand Down Expand Up @@ -733,7 +734,7 @@ void *EmergeThread::run()
}
} catch (VersionMismatchException &e) {
std::ostringstream err;
err << "World data version mismatch in MapBlock " << PP(pos) << std::endl
err << "World data version mismatch in MapBlock " << pos << std::endl
<< "----" << std::endl
<< "\"" << e.what() << "\"" << std::endl
<< "See debug.txt." << std::endl
Expand All @@ -742,7 +743,7 @@ void *EmergeThread::run()
m_server->setAsyncFatalError(err.str());
} catch (SerializationError &e) {
std::ostringstream err;
err << "Invalid data in MapBlock " << PP(pos) << std::endl
err << "Invalid data in MapBlock " << pos << std::endl
<< "----" << std::endl
<< "\"" << e.what() << "\"" << std::endl
<< "See debug.txt." << std::endl
Expand Down
5 changes: 3 additions & 2 deletions src/main.cpp
Expand Up @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlichttypes.h" // must be included before anything irrlicht, see comment in the file
#include "irrlicht.h" // createDevice
#include "irrlichttypes_extrabloated.h"
#include "irrlicht_changes/printing.h"
#include "benchmark/benchmark.h"
#include "chat_interface.h"
#include "debug.h"
Expand Down Expand Up @@ -1204,7 +1205,7 @@ static bool migrate_map_database(const GameParams &game_params, const Settings &
if (!data.empty()) {
new_db->saveBlock(*it, data);
} else {
errorstream << "Failed to load block " << PP(*it) << ", skipping it." << std::endl;
errorstream << "Failed to load block " << *it << ", skipping it." << std::endl;
}
if (++count % 0xFF == 0 && time(NULL) - last_update_time >= 1) {
std::cerr << " Migrated " << count << " blocks, "
Expand Down Expand Up @@ -1259,7 +1260,7 @@ static bool recompress_map_database(const GameParams &game_params, const Setting
std::string data;
db->loadBlock(*it, &data);
if (data.empty()) {
errorstream << "Failed to load block " << PP(*it) << std::endl;
errorstream << "Failed to load block " << *it << std::endl;
return false;
}

Expand Down
18 changes: 9 additions & 9 deletions src/map.cpp
Expand Up @@ -32,7 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h"
#include "gamedef.h"
#include "util/directiontables.h"
#include "util/basic_macros.h"
#include "rollback_interface.h"
#include "environment.h"
#include "reflowscan.h"
Expand All @@ -45,6 +44,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "database/database-dummy.h"
#include "database/database-sqlite3.h"
#include "script/scripting_server.h"
#include "irrlicht_changes/printing.h"
#include <deque>
#include <queue>
#if USE_LEVELDB
Expand Down Expand Up @@ -174,7 +174,7 @@ static void set_node_in_block(MapBlock *block, v3s16 relpos, MapNode n)
errorstream<<"Not allowing to place CONTENT_IGNORE"
<<" while trying to replace \""
<<nodedef->get(block->getNodeNoCheck(relpos)).name
<<"\" at "<<PP(p)<<" (block "<<PP(blockpos)<<")"<<std::endl;
<<"\" at "<<p<<" (block "<<blockpos<<")"<<std::endl;
return;
}
block->setNodeNoCheck(relpos, n);
Expand Down Expand Up @@ -917,7 +917,7 @@ std::vector<v3s16> Map::findNodesWithMetadata(v3s16 p1, v3s16 p2)
MapBlock *block = getBlockNoCreateNoEx(blockpos);
if (!block) {
verbosestream << "Map::getNodeMetadata(): Need to emerge "
<< PP(blockpos) << std::endl;
<< blockpos << std::endl;
block = emergeBlock(blockpos, false);
}
if (!block) {
Expand Down Expand Up @@ -947,7 +947,7 @@ NodeMetadata *Map::getNodeMetadata(v3s16 p)
MapBlock *block = getBlockNoCreateNoEx(blockpos);
if(!block){
infostream<<"Map::getNodeMetadata(): Need to emerge "
<<PP(blockpos)<<std::endl;
<<blockpos<<std::endl;
block = emergeBlock(blockpos, false);
}
if(!block){
Expand All @@ -966,7 +966,7 @@ bool Map::setNodeMetadata(v3s16 p, NodeMetadata *meta)
MapBlock *block = getBlockNoCreateNoEx(blockpos);
if(!block){
infostream<<"Map::setNodeMetadata(): Need to emerge "
<<PP(blockpos)<<std::endl;
<<blockpos<<std::endl;
block = emergeBlock(blockpos, false);
}
if(!block){
Expand Down Expand Up @@ -999,7 +999,7 @@ NodeTimer Map::getNodeTimer(v3s16 p)
MapBlock *block = getBlockNoCreateNoEx(blockpos);
if(!block){
infostream<<"Map::getNodeTimer(): Need to emerge "
<<PP(blockpos)<<std::endl;
<<blockpos<<std::endl;
block = emergeBlock(blockpos, false);
}
if(!block){
Expand All @@ -1020,7 +1020,7 @@ void Map::setNodeTimer(const NodeTimer &t)
MapBlock *block = getBlockNoCreateNoEx(blockpos);
if(!block){
infostream<<"Map::setNodeTimer(): Need to emerge "
<<PP(blockpos)<<std::endl;
<<blockpos<<std::endl;
block = emergeBlock(blockpos, false);
}
if(!block){
Expand Down Expand Up @@ -1348,7 +1348,7 @@ bool ServerMap::initBlockMake(v3s16 blockpos, BlockMakeData *data)
return false;

bool enable_mapgen_debug_info = m_emerge->enable_mapgen_debug_info;
EMERGE_DBG_OUT("initBlockMake(): " PP(bpmin) " - " PP(bpmax));
EMERGE_DBG_OUT("initBlockMake(): " << bpmin << " - " << bpmax);

v3s16 extra_borders(1, 1, 1);
v3s16 full_bpmin = bpmin - extra_borders;
Expand Down Expand Up @@ -1410,7 +1410,7 @@ void ServerMap::finishBlockMake(BlockMakeData *data,
v3s16 bpmax = data->blockpos_max;

bool enable_mapgen_debug_info = m_emerge->enable_mapgen_debug_info;
EMERGE_DBG_OUT("finishBlockMake(): " PP(bpmin) " - " PP(bpmax));
EMERGE_DBG_OUT("finishBlockMake(): " << bpmin << " - " << bpmax);

/*
Blit generated stuff to map
Expand Down
31 changes: 16 additions & 15 deletions src/mapblock.cpp
Expand Up @@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h"
#include "nodemetadata.h"
#include "gamedef.h"
#include "irrlicht_changes/printing.h"
#include "log.h"
#include "nameidmapping.h"
#include "content_mapnode.h" // For legacy name-id mapping
Expand Down Expand Up @@ -91,13 +92,13 @@ bool MapBlock::onObjectsActivation()
return false;

verbosestream << "MapBlock::onObjectsActivation(): "
<< "activating objects of block " << PP(getPos()) << " ("
<< "activating objects of block " << getPos() << " ("
<< m_static_objects.getStoredSize() << " objects)" << std::endl;

if (m_static_objects.getStoredSize() > g_settings->getU16("max_objects_per_block")) {
errorstream << "suspiciously large amount of objects detected: "
<< m_static_objects.getStoredSize() << " in "
<< PP(getPos()) << "; removing all of them." << std::endl;
<< getPos() << "; removing all of them." << std::endl;
// Clear stored list
m_static_objects.clearStored();
raiseModified(MOD_STATE_WRITE_NEEDED, MOD_REASON_TOO_MANY_OBJECTS);
Expand All @@ -111,7 +112,7 @@ bool MapBlock::saveStaticObject(u16 id, const StaticObject &obj, u32 reason)
{
if (m_static_objects.getStoredSize() >= g_settings->getU16("max_objects_per_block")) {
warningstream << "MapBlock::saveStaticObject(): Trying to store id = " << id
<< " statically but block " << PP(getPos()) << " already contains "
<< " statically but block " << getPos() << " already contains "
<< m_static_objects.getStoredSize() << " objects."
<< std::endl;
return false;
Expand Down Expand Up @@ -487,7 +488,7 @@ void MapBlock::deSerialize(std::istream &in_compressed, u8 version, bool disk)
if(!ser_ver_supported(version))
throw VersionMismatchException("ERROR: MapBlock format not supported");

TRACESTREAM(<<"MapBlock::deSerialize "<<PP(getPos())<<std::endl);
TRACESTREAM(<<"MapBlock::deSerialize "<<getPos()<<std::endl);

m_day_night_differs_expired = false;

Expand Down Expand Up @@ -515,18 +516,18 @@ void MapBlock::deSerialize(std::istream &in_compressed, u8 version, bool disk)
NameIdMapping nimap;
if (disk && version >= 29) {
// Timestamp
TRACESTREAM(<<"MapBlock::deSerialize "<<PP(getPos())
TRACESTREAM(<<"MapBlock::deSerialize "<<getPos()
<<": Timestamp"<<std::endl);
setTimestampNoChangedFlag(readU32(is));
m_disk_timestamp = m_timestamp;

// Node/id mapping
TRACESTREAM(<<"MapBlock::deSerialize "<<PP(getPos())
TRACESTREAM(<<"MapBlock::deSerialize "<<getPos()
<<": NameIdMapping"<<std::endl);
nimap.deSerialize(is);
}

TRACESTREAM(<<"MapBlock::deSerialize "<<PP(getPos())
TRACESTREAM(<<"MapBlock::deSerialize "<<getPos()
<<": Bulk node data"<<std::endl);
u8 content_width = readU8(is);
u8 params_width = readU8(is);
Expand All @@ -551,7 +552,7 @@ void MapBlock::deSerialize(std::istream &in_compressed, u8 version, bool disk)
/*
NodeMetadata
*/
TRACESTREAM(<<"MapBlock::deSerialize "<<PP(getPos())
TRACESTREAM(<<"MapBlock::deSerialize "<<getPos()
<<": Node metadata"<<std::endl);
if (version >= 29) {
m_node_metadata.deSerialize(is, m_gamedef->idef());
Expand All @@ -570,7 +571,7 @@ void MapBlock::deSerialize(std::istream &in_compressed, u8 version, bool disk)
} catch(SerializationError &e) {
warningstream<<"MapBlock::deSerialize(): Ignoring an error"
<<" while deserializing node metadata at ("
<<PP(getPos())<<": "<<e.what()<<std::endl;
<<getPos()<<": "<<e.what()<<std::endl;
}
}

Expand All @@ -584,25 +585,25 @@ void MapBlock::deSerialize(std::istream &in_compressed, u8 version, bool disk)
readU8(is);
}
if (version == 24) {
TRACESTREAM(<< "MapBlock::deSerialize " << PP(getPos())
TRACESTREAM(<< "MapBlock::deSerialize " << getPos()
<< ": Node timers (ver==24)" << std::endl);
m_node_timers.deSerialize(is, version);
}

// Static objects
TRACESTREAM(<<"MapBlock::deSerialize "<<PP(getPos())
TRACESTREAM(<<"MapBlock::deSerialize "<<getPos()
<<": Static objects"<<std::endl);
m_static_objects.deSerialize(is);

if (version < 29) {
// Timestamp
TRACESTREAM(<<"MapBlock::deSerialize "<<PP(getPos())
TRACESTREAM(<<"MapBlock::deSerialize "<<getPos()
<<": Timestamp"<<std::endl);
setTimestampNoChangedFlag(readU32(is));
m_disk_timestamp = m_timestamp;

// Node/id mapping
TRACESTREAM(<<"MapBlock::deSerialize "<<PP(getPos())
TRACESTREAM(<<"MapBlock::deSerialize "<<getPos()
<<": NameIdMapping"<<std::endl);
nimap.deSerialize(is);
}
Expand All @@ -611,13 +612,13 @@ void MapBlock::deSerialize(std::istream &in_compressed, u8 version, bool disk)
correctBlockNodeIds(&nimap, data, m_gamedef);

if(version >= 25){
TRACESTREAM(<<"MapBlock::deSerialize "<<PP(getPos())
TRACESTREAM(<<"MapBlock::deSerialize "<<getPos()
<<": Node timers (ver>=25)"<<std::endl);
m_node_timers.deSerialize(is, version);
}
}

TRACESTREAM(<<"MapBlock::deSerialize "<<PP(getPos())
TRACESTREAM(<<"MapBlock::deSerialize "<<getPos()
<<": Done."<<std::endl);
}

Expand Down

0 comments on commit 3b74cc4

Please sign in to comment.