From 3b74cc4a41d533a01b1c38ce422ec2409b99803f Mon Sep 17 00:00:00 2001 From: numzero Date: Sun, 25 Jun 2023 21:18:12 +0300 Subject: [PATCH] Replace PP with direct printing --- src/database/database-leveldb.cpp | 5 +-- src/database/database-redis.cpp | 11 +++--- src/database/database-sqlite3.cpp | 3 +- src/emerge.cpp | 9 ++--- src/main.cpp | 5 +-- src/map.cpp | 18 +++++----- src/mapblock.cpp | 31 ++++++++-------- src/network/serverpackethandler.cpp | 15 ++++---- src/nodemetadata.cpp | 4 +-- src/object_properties.cpp | 12 +++---- src/particles.h | 6 ++-- src/pathfinder.cpp | 55 +++++++++++++++-------------- src/rollback_interface.cpp | 8 ++--- src/script/cpp_api/s_item.cpp | 3 +- src/server/luaentity_sao.cpp | 3 +- src/serverenvironment.cpp | 19 +++++----- src/util/basic_macros.h | 8 ----- src/voxel.h | 4 +-- 18 files changed, 110 insertions(+), 109 deletions(-) diff --git a/src/database/database-leveldb.cpp b/src/database/database-leveldb.cpp index 80493d5f2..6a1325937 100644 --- a/src/database/database-leveldb.cpp +++ b/src/database/database-leveldb.cpp @@ -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" @@ -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; } @@ -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; } diff --git a/src/database/database-redis.cpp b/src/database/database-redis.cpp index 5ffff67b7..4509bb3c6 100644 --- a/src/database/database-redis.cpp +++ b/src/database/database-redis.cpp @@ -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 @@ -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; @@ -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); @@ -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); @@ -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; diff --git a/src/database/database-sqlite3.cpp b/src/database/database-sqlite3.cpp index 7b4b6ddbe..e73f9c77f 100644 --- a/src/database/database-sqlite3.cpp +++ b/src/database/database-sqlite3.cpp @@ -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 @@ -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; } diff --git a/src/emerge.cpp b/src/emerge.cpp index 3f8f7de86..5d096c5b0 100644 --- a/src/emerge.cpp +++ b/src/emerge.cpp @@ -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" @@ -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; } @@ -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) { @@ -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 @@ -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 diff --git a/src/main.cpp b/src/main.cpp index 7f14d0b96..309413f99 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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" @@ -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, " @@ -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; } diff --git a/src/map.cpp b/src/map.cpp index 3ed740395..620f374f9 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -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" @@ -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 #include #if USE_LEVELDB @@ -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 \"" <get(block->getNodeNoCheck(relpos)).name - <<"\" at "<setNodeNoCheck(relpos, n); @@ -917,7 +917,7 @@ std::vector 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) { @@ -947,7 +947,7 @@ NodeMetadata *Map::getNodeMetadata(v3s16 p) MapBlock *block = getBlockNoCreateNoEx(blockpos); if(!block){ infostream<<"Map::getNodeMetadata(): Need to 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; @@ -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 diff --git a/src/mapblock.cpp b/src/mapblock.cpp index 3efd64645..e3c307563 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -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 @@ -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); @@ -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; @@ -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 "<= 29) { // Timestamp - TRACESTREAM(<<"MapBlock::deSerialize "<= 29) { m_node_metadata.deSerialize(is, m_gamedef->idef()); @@ -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 (" - <= 25){ - TRACESTREAM(<<"MapBlock::deSerialize "<=25)"<getName() << " damaged by " - << (int)damage << " hp at " << PP(playersao->getBasePosition() / BS) + << (int)damage << " hp at " << (playersao->getBasePosition() / BS) << std::endl; PlayerHPChangeReason reason(PlayerHPChangeReason::FALL); @@ -883,7 +884,7 @@ void Server::handleCommand_Respawn(NetworkPacket* pkt) RespawnPlayer(peer_id); actionstream << player->getName() << " respawns at " - << PP(playersao->getBasePosition() / BS) << std::endl; + << (playersao->getBasePosition() / BS) << std::endl; // ActiveObject is added to environment in AsyncRunStep after // the previous addition has been successfully removed @@ -1149,8 +1150,8 @@ void Server::handleCommand_Interact(NetworkPacket *pkt) if (nocheat_p != p_under) { infostream << "Server: " << player->getName() << " started digging " - << PP(nocheat_p) << " and completed digging " - << PP(p_under) << "; not digging." << std::endl; + << nocheat_p << " and completed digging " + << p_under << "; not digging." << std::endl; is_valid_dig = false; // Call callbacks m_script->on_cheat(playersao, "finished_unknown_dig"); @@ -1173,7 +1174,7 @@ void Server::handleCommand_Interact(NetworkPacket *pkt) // If can't dig, ignore dig if (!params.diggable) { infostream << "Server: " << player->getName() - << " completed digging " << PP(p_under) + << " completed digging " << p_under << ", which is not diggable with tool; not digging." << std::endl; is_valid_dig = false; @@ -1199,7 +1200,7 @@ void Server::handleCommand_Interact(NetworkPacket *pkt) // Dig not possible else { infostream << "Server: " << player->getName() - << " completed digging " << PP(p_under) + << " completed digging " << p_under << "too fast; not digging." << std::endl; is_valid_dig = false; // Call callbacks @@ -1394,7 +1395,7 @@ void Server::handleCommand_NodeMetaFields(NetworkPacket* pkt) if (!pkt_read_formspec_fields(pkt, fields)) { warningstream << "Too large formspec fields! Ignoring for pos=" - << PP(p) << ", player=" << player->getName() << std::endl; + << p << ", player=" << player->getName() << std::endl; return; } diff --git a/src/nodemetadata.cpp b/src/nodemetadata.cpp index a2de1eac4..eb577b2da 100644 --- a/src/nodemetadata.cpp +++ b/src/nodemetadata.cpp @@ -21,9 +21,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "exceptions.h" #include "gamedef.h" #include "inventory.h" +#include "irrlicht_changes/printing.h" #include "log.h" #include "util/serialize.h" -#include "util/basic_macros.h" #include "constants.h" // MAP_BLOCKSIZE #include @@ -187,7 +187,7 @@ void NodeMetadataList::deSerialize(std::istream &is, } if (m_data.find(p) != m_data.end()) { warningstream << "NodeMetadataList::deSerialize(): " - << "already set data at position " << PP(p) + << "already set data at position " << p << ": Ignoring." << std::endl; continue; } diff --git a/src/object_properties.cpp b/src/object_properties.cpp index b6fddd15d..00f538d29 100644 --- a/src/object_properties.cpp +++ b/src/object_properties.cpp @@ -18,10 +18,10 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "object_properties.h" +#include "irrlicht_changes/printing.h" #include "irrlichttypes_bloated.h" #include "exceptions.h" #include "util/serialize.h" -#include "util/basic_macros.h" #include static const video::SColor NULL_BGCOLOR{0, 1, 1, 1}; @@ -39,10 +39,10 @@ std::string ObjectProperties::dump() os << ", breath_max=" << breath_max; os << ", physical=" << physical; os << ", collideWithObjects=" << collideWithObjects; - os << ", collisionbox=" << PP(collisionbox.MinEdge) << "," << PP(collisionbox.MaxEdge); + os << ", collisionbox=" << collisionbox.MinEdge << "," << collisionbox.MaxEdge; os << ", visual=" << visual; os << ", mesh=" << mesh; - os << ", visual_size=" << PP(visual_size); + os << ", visual_size=" << visual_size; os << ", textures=["; for (const std::string &texture : textures) { os << "\"" << texture << "\" "; @@ -54,8 +54,8 @@ std::string ObjectProperties::dump() << color.getGreen() << "," << color.getBlue() << "\" "; } os << "]"; - os << ", spritediv=" << PP2(spritediv); - os << ", initial_sprite_basepos=" << PP2(initial_sprite_basepos); + os << ", spritediv=" << spritediv; + os << ", initial_sprite_basepos=" << initial_sprite_basepos; os << ", is_visible=" << is_visible; os << ", makes_footstep_sound=" << makes_footstep_sound; os << ", automatic_rotate="<< automatic_rotate; @@ -71,7 +71,7 @@ std::string ObjectProperties::dump() else os << ", nametag_bgcolor=null "; - os << ", selectionbox=" << PP(selectionbox.MinEdge) << "," << PP(selectionbox.MaxEdge); + os << ", selectionbox=" << selectionbox.MinEdge << "," << selectionbox.MaxEdge; os << ", rotate_selectionbox=" << rotate_selectionbox; os << ", pointable=" << pointable; os << ", static_save=" << static_save; diff --git a/src/particles.h b/src/particles.h index 179d5ac5b..607fe5341 100644 --- a/src/particles.h +++ b/src/particles.h @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include +#include "irrlicht_changes/printing.h" #include "irrlichttypes_bloated.h" #include "tileanimation.h" #include "mapnode.h" @@ -138,10 +139,7 @@ namespace ParticleParamTypes inline std::string dump(const VectorParameter& v) { std::ostringstream oss; - if (N == 3) - oss << PP(v.val); - else - oss << PP2(v.val); + oss << v.val; return oss.str(); } diff --git a/src/pathfinder.cpp b/src/pathfinder.cpp index 5060aa1db..5420431f5 100644 --- a/src/pathfinder.cpp +++ b/src/pathfinder.cpp @@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "pathfinder.h" #include "map.h" #include "nodedef.h" +#include "irrlicht_changes/printing.h" //#define PATHFINDER_DEBUG //#define PATHFINDER_CALC_TIME @@ -524,25 +525,25 @@ void GridNodeContainer::initNode(v3s16 ipos, PathGridnode *p_node) if ((current.param0 == CONTENT_IGNORE) || (below.param0 == CONTENT_IGNORE)) { - DEBUG_OUT("Pathfinder: " << PP(realpos) << + DEBUG_OUT("Pathfinder: " << realpos << " current or below is invalid element" << std::endl); if (current.param0 == CONTENT_IGNORE) { elem.type = 'i'; - DEBUG_OUT(PP(ipos) << ": " << 'i' << std::endl); + DEBUG_OUT(ipos << ": " << 'i' << std::endl); } return; } //don't add anything if it isn't an air node if (ndef->get(current).walkable || !ndef->get(below).walkable) { - DEBUG_OUT("Pathfinder: " << PP(realpos) + DEBUG_OUT("Pathfinder: " << realpos << " not on surface" << std::endl); if (ndef->get(current).walkable) { elem.type = 's'; - DEBUG_OUT(PP(ipos) << ": " << 's' << std::endl); + DEBUG_OUT(ipos << ": " << 's' << std::endl); } else { elem.type = '-'; - DEBUG_OUT(PP(ipos) << ": " << '-' << std::endl); + DEBUG_OUT(ipos << ": " << '-' << std::endl); } return; } @@ -550,7 +551,7 @@ void GridNodeContainer::initNode(v3s16 ipos, PathGridnode *p_node) elem.valid = true; elem.pos = realpos; elem.type = 'g'; - DEBUG_OUT(PP(ipos) << ": " << 'a' << std::endl); + DEBUG_OUT(ipos << ": " << 'a' << std::endl); if (m_pathf->m_prefetch) { elem.directions[DIR_XP] = m_pathf->calcCost(realpos, v3s16( 1, 0, 0)); @@ -667,13 +668,13 @@ std::vector Pathfinder::getPath(v3s16 source, MapNode node_at_pos = m_map->getNode(destination); if (m_ndef->get(node_at_pos).walkable) { VERBOSE_TARGET << "Destination is walkable. " << - "Pos: " << PP(destination) << std::endl; + "Pos: " << destination << std::endl; return retval; } node_at_pos = m_map->getNode(source); if (m_ndef->get(node_at_pos).walkable) { VERBOSE_TARGET << "Source is walkable. " << - "Pos: " << PP(source) << std::endl; + "Pos: " << source << std::endl; return retval; } @@ -701,14 +702,14 @@ std::vector Pathfinder::getPath(v3s16 source, if (!startpos.valid) { VERBOSE_TARGET << "Invalid startpos " << - "Index: " << PP(StartIndex) << - "Realpos: " << PP(getRealPos(StartIndex)) << std::endl; + "Index: " << StartIndex << + "Realpos: " << getRealPos(StartIndex) << std::endl; return retval; } if (!endpos.valid) { VERBOSE_TARGET << "Invalid stoppos " << - "Index: " << PP(EndIndex) << - "Realpos: " << PP(getRealPos(EndIndex)) << std::endl; + "Index: " << EndIndex << + "Realpos: " << getRealPos(EndIndex) << std::endl; return retval; } @@ -833,7 +834,7 @@ PathCost Pathfinder::calcCost(v3s16 pos, v3s16 dir) //check limits if (!m_limits.isPointInside(pos2)) { - DEBUG_OUT("Pathfinder: " << PP(pos2) << + DEBUG_OUT("Pathfinder: " << pos2 << " no cost -> out of limits" << std::endl); return retval; } @@ -843,7 +844,7 @@ PathCost Pathfinder::calcCost(v3s16 pos, v3s16 dir) //did we get information about node? if (node_at_pos2.param0 == CONTENT_IGNORE ) { VERBOSE_TARGET << "Pathfinder: (1) area at pos: " - << PP(pos2) << " not loaded"; + << pos2 << " not loaded"; return retval; } @@ -854,7 +855,7 @@ PathCost Pathfinder::calcCost(v3s16 pos, v3s16 dir) //did we get information about node? if (node_below_pos2.param0 == CONTENT_IGNORE ) { VERBOSE_TARGET << "Pathfinder: (2) area at pos: " - << PP((pos2 + v3s16(0, -1, 0))) << " not loaded"; + << (pos2 + v3s16(0, -1, 0)) << " not loaded"; return retval; } @@ -864,7 +865,7 @@ PathCost Pathfinder::calcCost(v3s16 pos, v3s16 dir) retval.valid = true; retval.value = 1; retval.y_change = 0; - DEBUG_OUT("Pathfinder: "<< PP(pos) + DEBUG_OUT("Pathfinder: "<< pos << " cost same height found" << std::endl); } else { @@ -1040,8 +1041,8 @@ bool Pathfinder::updateAllCosts(v3s16 ipos, v3s16 ipos2 = ipos + direction; if (!isValidIndex(ipos2)) { - DEBUG_OUT(LVL " Pathfinder: " << PP(ipos2) << - " out of range, max=" << PP(m_limits.MaxEdge) << std::endl); + DEBUG_OUT(LVL " Pathfinder: " << ipos2 << + " out of range, max=" << m_limits.MaxEdge << std::endl); continue; } @@ -1049,7 +1050,7 @@ bool Pathfinder::updateAllCosts(v3s16 ipos, if (!g_pos2.valid) { VERBOSE_TARGET << LVL "Pathfinder: no data for new position: " - << PP(ipos2) << std::endl; + << ipos2 << std::endl; continue; } @@ -1066,7 +1067,7 @@ bool Pathfinder::updateAllCosts(v3s16 ipos, if ((g_pos2.totalcost < 0) || (g_pos2.totalcost > new_cost)) { DEBUG_OUT(LVL "Pathfinder: updating path at: "<< - PP(ipos2) << " from: " << g_pos2.totalcost << " to "<< + ipos2 << " from: " << g_pos2.totalcost << " to "<< new_cost << std::endl); if (updateAllCosts(ipos2, invert(direction), new_cost, level)) { @@ -1076,13 +1077,13 @@ bool Pathfinder::updateAllCosts(v3s16 ipos, else { DEBUG_OUT(LVL "Pathfinder:" " already found shorter path to: " - << PP(ipos2) << std::endl); + << ipos2 << std::endl); } } else { DEBUG_OUT(LVL "Pathfinder:" " not moving to invalid direction: " - << PP(directions[i]) << std::endl); + << directions[i] << std::endl); } } } @@ -1145,8 +1146,8 @@ bool Pathfinder::updateCostHeuristic(v3s16 isource, v3s16 idestination) // check if node is inside searchdistance and valid if (!isValidIndex(ipos)) { - DEBUG_OUT(LVL " Pathfinder: " << PP(current_pos) << - " out of search distance, max=" << PP(m_limits.MaxEdge) << std::endl); + DEBUG_OUT(LVL " Pathfinder: " << current_pos << + " out of search distance, max=" << m_limits.MaxEdge << std::endl); continue; } @@ -1258,8 +1259,8 @@ v3s16 Pathfinder::walkDownwards(v3s16 pos, unsigned int max_down) { } else { VERBOSE_TARGET << "Pos too far above ground: " << - "Index: " << PP(getIndexPos(pos)) << - "Realpos: " << PP(getRealPos(getIndexPos(pos))) << std::endl; + "Index: " << getIndexPos(pos) << + "Realpos: " << getRealPos(getIndexPos(pos)) << std::endl; } } else { DEBUG_OUT("Pathfinder: no surface found below pos" << std::endl); @@ -1433,7 +1434,7 @@ void Pathfinder::printPath(const std::vector &path) unsigned int current = 0; for (std::vector::iterator i = path.begin(); i != path.end(); ++i) { - std::cout << std::setw(3) << current << ":" << PP((*i)) << std::endl; + std::cout << std::setw(3) << current << ":" << *i << std::endl; current++; } } diff --git a/src/rollback_interface.cpp b/src/rollback_interface.cpp index a5a63076f..4e9fa5eab 100644 --- a/src/rollback_interface.cpp +++ b/src/rollback_interface.cpp @@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "util/serialize.h" #include "util/string.h" #include "util/numeric.h" -#include "util/basic_macros.h" #include "map.h" #include "gamedef.h" #include "nodedef.h" @@ -31,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "log.h" #include "inventorymanager.h" #include "inventory.h" +#include "irrlicht_changes/printing.h" #include "mapblock.h" @@ -55,7 +55,7 @@ std::string RollbackAction::toString() const std::ostringstream os(std::ios::binary); switch (type) { case TYPE_SET_NODE: - os << "set_node " << PP(p); + os << "set_node " << p; os << ": (" << serializeJsonString(n_old.name); os << ", " << itos(n_old.param1); os << ", " << itos(n_old.param2); @@ -152,7 +152,7 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam if (!map->addNodeWithEvent(p, n)) { infostream << "RollbackAction::applyRevert(): " << "AddNodeWithEvent failed at " - << PP(p) << " for " << n_old.name + << p << " for " << n_old.name << std::endl; return false; } @@ -166,7 +166,7 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam delete meta; infostream << "RollbackAction::applyRevert(): " << "setNodeMetadata failed at " - << PP(p) << " for " << n_old.name + << p << " for " << n_old.name << std::endl; return false; } diff --git a/src/script/cpp_api/s_item.cpp b/src/script/cpp_api/s_item.cpp index 2f7436bcf..feba36ffb 100644 --- a/src/script/cpp_api/s_item.cpp +++ b/src/script/cpp_api/s_item.cpp @@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "util/pointedthing.h" #include "inventory.h" #include "inventorymanager.h" +#include "irrlicht_changes/printing.h" #define WRAP_LUAERROR(e, detail) \ LuaError(std::string(__FUNCTION__) + ": " + (e).what() + ". " detail) @@ -238,7 +239,7 @@ bool ScriptApiItem::getItemCallback(const char *name, const char *callbackname, // Report error and clean up errorstream << "Item \"" << name << "\" not defined"; if (p) - errorstream << " at position " << PP(*p); + errorstream << " at position " << *p; errorstream << std::endl; lua_pop(L, 1); diff --git a/src/server/luaentity_sao.cpp b/src/server/luaentity_sao.cpp index 3b6ef1fba..98f0b9400 100644 --- a/src/server/luaentity_sao.cpp +++ b/src/server/luaentity_sao.cpp @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "collision.h" #include "constants.h" #include "inventory.h" +#include "irrlicht_changes/printing.h" #include "player_sao.h" #include "scripting_server.h" #include "server.h" @@ -390,7 +391,7 @@ std::string LuaEntitySAO::getDescription() std::ostringstream oss; oss << "LuaEntitySAO \"" << m_init_name << "\" "; auto pos = floatToInt(m_base_position, BS); - oss << "at " << PP(pos); + oss << "at " << pos; return oss.str(); } diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp index 5af031d3f..3925dab6d 100644 --- a/src/serverenvironment.cpp +++ b/src/serverenvironment.cpp @@ -48,6 +48,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #if USE_LEVELDB #include "database/database-leveldb.h" #endif +#include "irrlicht_changes/printing.h" #include "server/luaentity_sao.h" #include "server/player_sao.h" @@ -1282,7 +1283,7 @@ void ServerEnvironment::clearObjects(ClearObjectsMode mode) MapBlock *block = m_map->emergeBlock(p, false); if (!block) { errorstream << "ServerEnvironment::clearObjects(): " - << "Failed to emerge block " << PP(p) << std::endl; + << "Failed to emerge block " << p << std::endl; continue; } @@ -1858,7 +1859,7 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object, v3s16 p = floatToInt(objectpos, BS); errorstream<<"ServerEnvironment::addActiveObjectRaw(): " <<"could not emerge block for storing id="<getId() - <<" statically (pos="<m_static_block) << std::endl; + << obj->m_static_block << std::endl; } } else { infostream << "Failed to emerge block from which an object to " @@ -1996,7 +1997,7 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s) if (!obj) { errorstream << "ServerEnvironment::activateObjects(): " << "failed to create active object from static object " - << "in block " << PP(s_obj.pos / BS) + << "in block " << (s_obj.pos / BS) << " type=" << (int)s_obj.type << " data:" << std::endl; print_hexdump(verbosestream, s_obj.data); @@ -2004,7 +2005,7 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s) continue; } verbosestream << "ServerEnvironment::activateObjects(): " - << "activated static object pos=" << PP(s_obj.pos / BS) + << "activated static object pos=" << (s_obj.pos / BS) << " type=" << (int)s_obj.type << std::endl; // This will also add the object to the active static list addActiveObjectRaw(obj, false, dtime_s); @@ -2085,7 +2086,7 @@ void ServerEnvironment::deactivateFarObjects(bool _force_delete) verbosestream << "ServerEnvironment::deactivateFarObjects(): " << "deactivating object id=" << id << " on inactive block " - << PP(blockpos_o) << std::endl; + << blockpos_o << std::endl; // If known by some client, don't immediately delete. bool pending_delete = (obj->m_known_by_count > 0 && !force_delete); @@ -2119,7 +2120,7 @@ void ServerEnvironment::deactivateFarObjects(bool _force_delete) warningstream << "ServerEnvironment::deactivateFarObjects(): " << "id=" << id << " m_static_exists=true but " << "static data doesn't actually exist in " - << PP(obj->m_static_block) << std::endl; + << obj->m_static_block << std::endl; } } } @@ -2189,7 +2190,7 @@ void ServerEnvironment::deleteStaticFromBlock( block = m_map->emergeBlock(obj->m_static_block, false); if (!block) { if (!no_emerge) - errorstream << "ServerEnv: Failed to emerge block " << PP(obj->m_static_block) + errorstream << "ServerEnv: Failed to emerge block " << obj->m_static_block << " when deleting static data of object from it. id=" << id << std::endl; return; } @@ -2216,7 +2217,7 @@ bool ServerEnvironment::saveStaticToBlock( } if (!block) { - errorstream << "ServerEnv: Failed to emerge block " << PP(obj->m_static_block) + errorstream << "ServerEnv: Failed to emerge block " << obj->m_static_block << " when saving static data of object to it. id=" << store_id << std::endl; return false; } diff --git a/src/util/basic_macros.h b/src/util/basic_macros.h index 2b3316b73..7c3746417 100644 --- a/src/util/basic_macros.h +++ b/src/util/basic_macros.h @@ -42,11 +42,3 @@ with this program; if not, write to the Free Software Foundation, Inc., C(C &&other) = default; \ C &operator=(C &&) = default; -// Macros to facilitate writing position vectors to a stream -// Usage: -// v3s16 pos(1,2,3); -// mystream << "message " << PP(pos) << std::endl; - -#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" - -#define PP2(x) "("<<(x).X<<","<<(x).Y<<")" diff --git a/src/voxel.h b/src/voxel.h index 7a36b10bf..286e09abe 100644 --- a/src/voxel.h +++ b/src/voxel.h @@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mapnode.h" #include #include -#include "util/basic_macros.h" +#include "irrlicht_changes/printing.h" class NodeDefManager; @@ -339,7 +339,7 @@ public: */ void print(std::ostream &o) const { - o << PP(MinEdge) << PP(MaxEdge) << "=" + o << MinEdge << MaxEdge << "=" << m_cache_extent.X << "x" << m_cache_extent.Y << "x" << m_cache_extent.Z << "=" << getVolume(); }