From: Perttu Ahola Date: Sun, 16 Oct 2011 11:57:53 +0000 (+0300) Subject: Use the logger; also, default to not showing much crap in console. Use --info-on... X-Git-Tag: 0.3.dev-20111021~49 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b65a5aceb0d6552d8ba4878bed5326c614dd3046;p=oweals%2Fminetest.git Use the logger; also, default to not showing much crap in console. Use --info-on-stderr to enable crap. --- diff --git a/src/client.cpp b/src/client.cpp index c40c9e513..75168c685 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mapblock.h" #include "settings.h" #include "profiler.h" +#include "log.h" /* QueuedMeshUpdate @@ -131,6 +132,8 @@ void * MeshUpdateThread::Thread() { ThreadStarted(); + log_register_thread("MeshUpdateThread"); + DSTACK(__FUNCTION_NAME); BEGIN_DEBUG_EXCEPTION_HANDLER @@ -163,7 +166,7 @@ void * MeshUpdateThread::Thread() r.mesh = mesh_new; r.ack_block_to_server = q->ack_block_to_server; - /*dstream<<"MeshUpdateThread: Processed " + /*infostream<<"MeshUpdateThread: Processed " <<"("<p.X<<","<p.Y<<","<p.Z<<")" < 0) { - /*dstream<getName()); - /*dstream<<"Client: sending initial password hash: \""< 0) - dstream<<"Client: Unloaded "<id=" + infostream<<"Client::peerAdded(): peer->id=" <id<deSerialize(istr, ser_version); } else @@ -875,7 +878,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) /* Create a new block */ - //dstream<<"Creating new"<deSerialize(istr, ser_version); sector->insertBlock(block); @@ -921,12 +924,12 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) /* Add it to mesh update queue and set it to be acknowledged after update. */ - //std::cerr<<"Adding mesh update task for received block"< players = m_env.getPlayers(); core::list::Iterator ip; for(ip=players.begin(); ip!=players.end(); ip++) @@ -1072,7 +1075,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) // Warn about a special case if((*ip)->peer_id == 0) { - dstream<peer_id + infostream<<"Removing dead player "<<(*ip)->peer_id <peer_id); } @@ -1098,7 +1101,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) } else if(command == TOCLIENT_SECTORMETA) { - dstream<<"Client received DEPRECATED TOCLIENT_SECTORMETA"<inventory.print(dstream); + //infostream<<"Client got player inventory:"<inventory.print(infostream); } } //DEBUG @@ -1233,7 +1236,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) // Read active block count u16 blockcount = readU16(is); if(blockcount != 0){ - dstream<<"WARNING: TOCLIENT_OBJECTDATA: blockcount != 0 " + infostream<<"TOCLIENT_OBJECTDATA: blockcount != 0 " "not supported"<setPitch(pitch); player->setYaw(yaw);*/ - dstream<<"Client got TOCLIENT_MOVE_PLAYER" + infostream<<"Client got TOCLIENT_MOVE_PLAYER" <<" pos=("<isLocal()) { - dout_client<deleteItem(0); - dout_client<changeItem(0, InventoryItem::deSerialize(iss)); - dout_client<getWieldItem()->serialize(dout_client); - dout_client<getWieldItem()->serialize(infostream); + infostream<getInventory(); - dstream<<"nodemeta at ("<getRotation(); - //dstream<<"dtime="<>cmd; @@ -259,7 +259,7 @@ void ItemCAO::step(float dtime, ClientEnvironment *env) void ItemCAO::processMessage(const std::string &data) { - dstream<<"ItemCAO: Got message"< item="<setTCoords(2, v2f(txs*0, tys*0)); bill->setTCoords(3, v2f(txs*0, tys*1)); } else { - dstream<<"MobV2CAO: Unknown sprite type \""<= 0){ m_damage_visual_timer -= dtime; if(m_damage_visual_timer <= 0){ - dstream<<"id="<parseConfigLines(tmp_is, "MobArgsEnd"); - dstream<<"INFO: MobV2CAO::initialize(): got properties:"<writeLines(dstream); + infostream<<"MobV2CAO::initialize(): got properties:"<writeLines(infostream); m_properties->setDefault("looks", "dummy_default"); m_properties->setDefault("yaw", "0"); diff --git a/src/content_sao.cpp b/src/content_sao.cpp index e218fc765..93073002b 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -84,7 +84,7 @@ void TestSAO::step(float dtime, bool send_recommended) if(m_timer1 < 0.0) { m_timer1 += 0.125; - //dstream<<"TestSAO: id="< item="<getName()<getName(); m_disturb_timer = 0; @@ -1135,7 +1135,7 @@ void MobV2SAO::step(float dtime, bool send_recommended) dir.normalize(); v3f speed = dir * BS * 10.0; v3f pos = m_base_position + shoot_pos; - dstream<<__FUNCTION_NAME<<": Shooting fireball from "<addActiveObjectAsStatic(obj); m_env->addActiveObject(obj); } else { - dstream<<__FUNCTION_NAME<<": Unknown shoot_type="<getMap(); - dstream<<"ACTION: "<serialize(os); @@ -350,7 +353,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir) Player *player = *i; if(saved_players.find(player) != NULL) { - /*dstream<<"Player "<getName() + /*infostream<<"Player "<getName() <<" was already saved."<getName()<<" to " + /*infostream<<"Saving player "<getName()<<" to " <serialize(os); @@ -398,7 +401,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir) } } - //dstream<<"Saved "<deSerialize(is); @@ -478,7 +481,7 @@ void ServerEnvironment::saveMeta(const std::string &savedir) std::ofstream os(path.c_str(), std::ios_base::binary); if(os.good() == false) { - dstream<<"WARNING: ServerEnvironment::saveMeta(): Failed to open " + infostream<<"ServerEnvironment::saveMeta(): Failed to open " <setTimestamp(m_game_time); - //dstream<<"Block is "<getKey(); - /*dstream<<"Server: Block ("<getBlockNoCreateNoEx(p); @@ -778,7 +781,7 @@ void ServerEnvironment::step(float dtime) { v3s16 p = i.getNode()->getKey(); - /*dstream<<"Server: Block ("<getBlockNoCreateNoEx(p); @@ -802,7 +805,7 @@ void ServerEnvironment::step(float dtime) { v3s16 p = i.getNode()->getKey(); - /*dstream<<"Server: Block ("<getBlockNoCreateNoEx(p); @@ -838,7 +841,7 @@ void ServerEnvironment::step(float dtime) { v3s16 p = i.getNode()->getKey(); - /*dstream<<"Server: Block ("<getBlockNoCreateNoEx(p); @@ -956,18 +959,24 @@ void ServerEnvironment::step(float dtime) v3f pos = intToFloat(p1, BS); int i = myrand()%5; if(i == 0 || i == 1){ + actionstream<<"A dungeon master spawns at " + < modified_blocks; v3s16 tree_p = p; ManualMapVoxelManipulator vmanip(m_map); @@ -1111,7 +1123,7 @@ void ServerEnvironment::step(float dtime) //ServerActiveObject *obj = new Oerkki1SAO(this, 0, pos); //ServerActiveObject *obj = new FireflySAO(this, 0, pos); - dstream<m_removed == false) { f32 distance_f = object->getBasePosition().getDistanceFrom(pos_f); - /*dstream<<"removed == false" + /*infostream<<"removed == false" <<"distance_f = "<getId(), m_active_objects) == false) { - dstream<<"WARNING: ServerEnvironment::addActiveObjectRaw(): " + infostream<<"ServerEnvironment::addActiveObjectRaw(): " <<"id is not free ("<getId()<<")"<getId(), object); @@ -1358,7 +1370,7 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object, block->setChangedFlag(); } else{ - dstream<<"WARNING: ServerEnv: Could not find a block for " + infostream<<"ServerEnv: Could not find a block for " <<"storing newly added static active object"<m_static_block = block->getPos(); } else{ - dstream<<"WARNING: ServerEnv: Could not find or generate " + infostream<<"ServerEnv: Could not find or generate " <<"a block for storing static object"<m_static_exists = false; continue; @@ -1571,7 +1583,7 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete) continue; } - /*dstream<<"INFO: Server: Stored static data. Deleting object." + /*infostream<<"Server: Stored static data. Deleting object." <getId(), m_active_objects) == false) { - dstream<<"WARNING: ClientEnvironment::addActiveObject(): " + infostream<<"ClientEnvironment::addActiveObject(): " <<"id is not free ("<getId()<<")"<getId(), object); object->addToScene(m_smgr); @@ -1989,7 +2001,7 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type, ClientActiveObject* obj = ClientActiveObject::create(type); if(obj == NULL) { - dstream<<"WARNING: ClientEnvironment::addActiveObject(): " + infostream<<"ClientEnvironment::addActiveObject(): " <<"id="<sendSignNodeText(m_p, ntext); } @@ -161,7 +162,7 @@ void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font, InventoryList *mainlist = inventory->getList("main"); if(mainlist == NULL) { - dstream<<"WARNING: draw_hotbar(): mainlist == NULL"< server; if(address == ""){ draw_load_screen(L"Creating server...", driver, font); - dstream<start(port); } @@ -716,7 +717,7 @@ void the_game( */ draw_load_screen(L"Creating client...", driver, font); - dstream<remove(); @@ -742,9 +743,9 @@ void the_game( Attempt to connect to the server */ - dstream<remove(); return; @@ -963,7 +964,7 @@ void the_game( { error_message = L"Access denied. Reason: " +client.accessDeniedReason(); - dstream<print(dstream); + infostream<<"Profiler:"<print(infostream); g_profiler->clear(); } } @@ -1185,7 +1186,7 @@ void the_game( */ if(input->wasKeyDown(getKeySetting("keymap_inventory"))) { - dstream<wasKeyDown(EscapeKey)) { - dstream<writeImageToFile(image, filename)) { std::wstringstream sstr; sstr<<"Saved screenshot to '"<drop(); } @@ -1327,7 +1328,7 @@ void the_game( { g_selected_item = i; - dstream<getMousePos().Y - displaycenter.Y; if(invert_mouse) dy = -dy; - //dstream<<"window active, pos difference "<isKeyDown(irr::KEY_UP)) @@ -1406,7 +1407,7 @@ void the_game( if(device->getCursorControl()->isVisible() == false) device->getCursorControl()->setVisible(true); - //dstream<<"window inactive"<= 2){ damage_flash_timer += 0.05 * event.player_damage.amount; @@ -1575,7 +1576,7 @@ void the_game( nodepos_old = v3s16(-32768,-32768,-32768); } - //dstream<<"Client returned selected_active_object != NULL"< *selection_box = selected_active_object->getSelectionBox(); @@ -1610,7 +1611,7 @@ void the_game( do_punch = true; } if(do_punch){ - dstream<getRightClicked()) { - dstream<getId(), g_selected_item); } @@ -1687,7 +1688,7 @@ void the_game( { if(nodepos != nodepos_old) { - dstream<getLeftClicked() || (input->getLeftState() && nodepos != nodepos_old)) { - dstream<getLeftClicked()) @@ -1734,7 +1735,7 @@ void the_game( if(prop.diggable == false) { - /*dstream<<"Material "<<(int)material + /*infostream<<"Material "<<(int)material <<" not diggable with \"" <getRightClicked()) { - dstream<getInventoryDrawSpecString() != "" && !random_input) { - dstream<typeId() == CONTENT_SIGN_WALL && !random_input) { - dstream<<"Sign node right-clicked"<getLeftReleased()) { - dstream<getRightReleased()) { - //dstream<drawAll()"<drawAll()"< >::Iterator i=hilightboxes.begin(); i != hilightboxes.end(); i++) { - /*dstream<<"hilightbox min=" + /*infostream<<"hilightbox min=" <<"("<MinEdge.X<<","<MinEdge.Y<<","<MinEdge.Z<<")" <<" max=" <<"("<MaxEdge.X<<","<MaxEdge.Y<<","<MaxEdge.Z<<")" diff --git a/src/main.cpp b/src/main.cpp index 37ee035f8..02cae0317 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -438,6 +438,7 @@ Doing currently: #include "gettext.h" #include "settings.h" #include "profiler.h" +#include "log.h" // This makes textures ITextureSource *g_texturesource = NULL; @@ -479,19 +480,15 @@ MainGameCallback *g_gamecallback = NULL; // Connection std::ostream *dout_con_ptr = &dummyout; -std::ostream *derr_con_ptr = &dstream_no_stderr; -//std::ostream *dout_con_ptr = &dstream_no_stderr; -//std::ostream *derr_con_ptr = &dstream_no_stderr; -//std::ostream *dout_con_ptr = &dstream; -//std::ostream *derr_con_ptr = &dstream; +std::ostream *derr_con_ptr = &verbosestream; // Server -std::ostream *dout_server_ptr = &dstream; -std::ostream *derr_server_ptr = &dstream; +std::ostream *dout_server_ptr = &infostream; +std::ostream *derr_server_ptr = &errorstream; // Client -std::ostream *dout_client_ptr = &dstream; -std::ostream *derr_client_ptr = &dstream; +std::ostream *dout_client_ptr = &infostream; +std::ostream *derr_client_ptr = &errorstream; /* gettime.h implementation @@ -583,7 +580,6 @@ public: } else { - //dstream<<"MyEventReceiver: mouse input"<readConfigFile(cmd_args.get("config").c_str()); if(r == false) { - dstream<<"Could not read configuration from \"" + errorstream<<"Could not read configuration from \"" <setFont(font); else - dstream<<"WARNING: Font file was not found." + errorstream<<"WARNING: Font file was not found." " Using default font."<getFont(); assert(font); u32 text_height = font->getDimension(L"Hello, world!").Height; - dstream<<"text_height="<run() && kill == false) { @@ -1559,7 +1584,7 @@ int main(int argc, char *argv[]) if(device->run() == false || kill == true) break; - dstream<<"Dropping main menu"<drop(); @@ -1576,7 +1601,7 @@ int main(int argc, char *argv[]) password = translatePassword(playername, menudata.password); - //dstream<<"Main: password hash: '"<drop(); - END_DEBUG_EXCEPTION_HANDLER + END_DEBUG_EXCEPTION_HANDLER(errorstream) debugstreams_deinit(); diff --git a/src/map.cpp b/src/map.cpp index a13c028fa..4c79c0ac4 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #endif #include "settings.h" +#include "log.h" /* SQLite format specification: @@ -346,7 +347,7 @@ void Map::unspreadLight(enum LightBank bank, */ /*if(light_sources.find(n2pos)) { - std::cout<<"Removed from light_sources"<getKey(); //v3s16 pos = *j; - //dstream<<"pos=("< & modified_blocks) u32 initial_size = m_transforming_liquid.size(); /*if(initial_size != 0) - dstream<<"transformLiquids(): initial_size="<getBool("enable_mapgen_debug_info"); if(enable_mapgen_debug_info) - dstream<<"initBlockMake(): ("< &changed_blocks) { v3s16 blockpos = data->blockpos; - /*dstream<<"finishBlockMake(): ("<no_op) { - //dstream<<"finishBlockMake(): no-op"<getBool("enable_mapgen_debug_info"); - /*dstream<<"Resulting vmanip:"<vmanip.print(dstream);*/ + /*infostream<<"Resulting vmanip:"<vmanip.print(infostream);*/ /* Blit generated stuff to map @@ -2159,7 +2160,7 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data, } if(enable_mapgen_debug_info) - dstream<<"finishBlockMake: changed_blocks.size()=" + infostream<<"finishBlockMake: changed_blocks.size()=" <getNode(p); if(n.getContent() == CONTENT_IGNORE) { - dstream<<"CONTENT_IGNORE at " + infostream<<"CONTENT_IGNORE at " <<"("< making one"< making one"<getPos().X<<"," <getPos().Y<<"," <getPos().Z<<")" @@ -3017,7 +3018,7 @@ void ServerMap::save(bool only_changed) if(only_changed == false || sector_meta_count != 0 || block_count != 0) { - dstream<isDummy()) { /*v3s16 p = block->getPos(); - dstream<<"ServerMap::saveBlock(): WARNING: Not writing dummy block " + infostream<<"ServerMap::saveBlock(): WARNING: Not writing dummy block " <<"("< time1 + 4) { - dstream<<"ClientMap::renderMap(): " + infostream<<"ClientMap::renderMap(): " "Rendering takes ages, returning." <getBlockNoCreate(p); if(block->isDummy()) @@ -4245,7 +4244,7 @@ void MapVoxelManipulator::emerge(VoxelArea a, s32 caller_id) m_loaded_blocks.insert(p, !block_data_inexistent); } - //dstream<<"emerge done"<getBlockNoCreateNoEx(p); if(block == NULL) { - dstream<<"WARNING: "<<__FUNCTION_NAME + infostream<<"WARNING: "<<__FUNCTION_NAME <<": got NULL block " <<"("<AsyncRunStep(); } - //dout_server<<"Running m_server->Receive()"<Receive()"<Receive(); } catch(con::NoIncomingDataException &e) @@ -92,11 +97,11 @@ void * ServerThread::Thread() } catch(con::PeerNotFoundException &e) { - dout_server<<"Server: PeerNotFoundException"< MAP_GENERATION_LIMIT / MAP_BLOCKSIZE) continue; - //derr_server<<"EmergeThread::Thread(): running"<isGenerated() == false) { if(enable_mapgen_debug_info) - dstream<<"EmergeThread: generating"< 0) { - /*dstream<<"lighting "<= g_settings->getU16 ("max_simultaneous_block_sends_per_client")) { - //dstream<<"Not sending any blocks, Queue full."<getPitch()); camera_dir.rotateXZBy(player->getYaw()); - /*dstream<<"camera_dir=("<getPlayerName(peer_id)< d_start+2) d_max_gen = d_start+2;*/ - //dstream<<"Starting from "<getPlayerName(peer_id) <<" (d="<::Iterator i = m_clients.getIterator(); i.atEnd() == false; i++) @@ -1314,8 +1323,8 @@ void Server::AsyncRunStep() Player *player = m_env.getPlayer(client->peer_id); if(player==NULL) continue; - std::cout<getName()<<"\t"; - client->PrintInfo(std::cout); + infostream<<"* "<getName()<<"\t"; + client->PrintInfo(infostream); } } } @@ -1327,7 +1336,7 @@ void Server::AsyncRunStep() Check added and deleted active objects */ { - //dstream<<"Server: Checking added and deleted active objects"<peer_id <<" has no associated player"<getType(); @@ -1439,7 +1448,7 @@ void Server::AsyncRunStep() // Send as reliable m_con.Send(client->peer_id, 0, reply, true); - dstream<<"INFO: Server: Sent object remove/add: " + infostream<<"Server: Sent object remove/add: " < 0 || unreliable_data.size() > 0) { - dstream<<"INFO: Server: Size of object message data: " + infostream<<"Server: Size of object message data: " <<"reliable: "<type == MEET_ADDNODE) { - //dstream<<"Server: MEET_ADDNODE"<p, event->n, event->already_known_by_peer, @@ -1631,7 +1640,7 @@ void Server::AsyncRunStep() } else if(event->type == MEET_REMOVENODE) { - //dstream<<"Server: MEET_REMOVENODE"<p, event->already_known_by_peer, @@ -1642,13 +1651,13 @@ void Server::AsyncRunStep() } else if(event->type == MEET_BLOCK_NODE_METADATA_CHANGED) { - dstream<<"Server: MEET_BLOCK_NODE_METADATA_CHANGED"<p); } else if(event->type == MEET_OTHER) { - dstream<<"Server: MEET_OTHER"<::Iterator i = event->modified_blocks.getIterator(); @@ -1661,7 +1670,7 @@ void Server::AsyncRunStep() else { prof.add("unknown", 1); - dstream<<"WARNING: Server: Unknown MapEditEvent " + infostream<<"WARNING: Server: Unknown MapEditEvent " <<((u32)event->type)< 0) { - dout_server<<"Server: Unloaded "<id<get("default_password"); } - /*dstream<<"Server: Client gave password '"<id<::Iterator + i = m_clients.getIterator(); + i.atEnd() == false; i++) + { + RemoteClient *client = i.getNode()->getValue(); + assert(client->peer_id == i.getNode()->getKey()); + if(client->serialization_version == SER_FMT_VER_INVALID) + continue; + // Get player + Player *player = m_env.getPlayer(client->peer_id); + if(!player) + continue; + // Get name of player + os<getName()<<" "; + } + + actionstream<getName()<<" joins game. List of players: " + <GotBlock(p); @@ -2214,7 +2245,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) throw con::InvalidIncomingDataException ("DELETEDBLOCKS length is too short"); v3s16 p = readV3S16(&data[2+1+i*6]); - /*dstream<<"Server: DELETEDBLOCKS (" + /*infostream<<"Server: DELETEDBLOCKS (" <SetBlockNotSent(p); @@ -2222,7 +2253,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) } else if(command == TOSERVER_CLICK_OBJECT) { - derr_server<<"Server: CLICK_OBJECT not supported anymore"<inventory.getList("main"); if(ilist != NULL) { + actionstream<getName()<<" picked up " + <getName()<getBool("creative_mode") == false) { // Skip if inventory has no free space if(ilist->roomForItem(item) == false) { - dout_server<<"Player inventory has no free space"<getName()<<" punches object " + <getId()<getName()<<" right clicks object " + <getId()<hp; @@ -2421,7 +2460,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) // If it's not diggable, do nothing if(content_diggable(material) == false) { - derr_server<<"Server: Not finishing digging: " + infostream<<"Server: Not finishing digging: " <<"Node not diggable" <nodeRemovalDisabled() == true) { - derr_server<<"Server: Not finishing digging: " + infostream<<"Server: Not finishing digging: " <<"Node metadata disables removal" <getName()<<" cannot remove node" + infostream<<"Player "<getName()<<" cannot remove node" <<" because privileges are "<getName()<<" digs "<getName()<<" cannot add node" + infostream<<"Player "<getName()<<" cannot add node" <<" because privileges are "<getMaterial()); + actionstream<getName()<<" places material " + <<(int)mitem->getMaterial() + <<" at "<getBool("creative_mode") && (getPlayerPrivs(player) & PRIV_BUILD) == 0) { - derr_server<<"Not allowing player to drop item: " + infostream<<"Not allowing player to drop item: " "creative mode and no build privs"<getName()<<" places "<getName() + <<" at "<getBool("creative_mode") == false) { @@ -2831,7 +2878,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) if(item->getCount() <= dropcount) { if(item->getCount() < dropcount) - dstream<<"WARNING: Server: dropped more items" + infostream<<"WARNING: Server: dropped more items" <<" than the slot contains"<inventory.getList("main"); @@ -2857,7 +2904,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) */ else { - derr_server<<"WARNING: Server: Invalid action " + infostream<<"WARNING: Server: Invalid action " <setText(text); + actionstream<getName()<<" writes \""<getBool("creative_mode") == true) { - dstream<<"TOSERVER_INVENTORY_ACTION: ignoring in creative mode" + infostream<<"TOSERVER_INVENTORY_ACTION: ignoring in creative mode" <getItem(0); + actionstream<getName()<<" crafts " + <getName()<getBool("enable_damage")) { + actionstream<getName()<<" damaged by " + <<(int)damage<<" hp at "<getPosition()/BS) + <getName(); if(m_authmanager.exists(playername) == false) { - dstream<<"Server: playername not found in authmanager"<getName()<<" changes password"<hp != 0) return; - + RespawnPlayer(player); + + actionstream<getName()<<" respawns at " + <getPosition()/BS)<clone(); @@ -3316,12 +3384,12 @@ Inventory* Server::getInventory(InventoryContext *c, std::string id) NodeMetadata *meta = m_env.getMap().getNodeMetadata(p); if(meta) return meta->getInventory(); - dstream<<"nodemeta at ("< Server::getPlayerInfo() @@ -3410,7 +3478,7 @@ core::list Server::getPlayerInfo() void Server::peerAdded(con::Peer *peer) { DSTACK(__FUNCTION_NAME); - dout_server<<"Server::peerAdded(): peer->id=" + infostream<<"Server::peerAdded(): peer->id=" <id<id=" + infostream<<"Server::deletingPeer(): peer->id=" <id<<", timeout="<getName()<<" dies"<hp = 0; @@ -4105,18 +4173,18 @@ v3f findSpawnPos(ServerMap &map) // Don't go underwater if(groundheight < WATER_LEVEL) { - //dstream<<"-> Underwater"< Underwater"< WATER_LEVEL + 4) { - //dstream<<"-> Underwater"< Underwater"<peer_id != 0) { - dstream<<"emergePlayer(): Player already connected"<getName()<<"\""<peer_id = 0; + + /* + Print out action + */ + { + std::ostringstream os(std::ios_base::binary); + for(core::map::Iterator + i = m_clients.getIterator(); + i.atEnd() == false; i++) + { + RemoteClient *client = i.getNode()->getValue(); + assert(client->peer_id == i.getNode()->getKey()); + if(client->serialization_version == SER_FMT_VER_INVALID) + continue; + // Get player + Player *player = m_env.getPlayer(client->peer_id); + if(!player) + continue; + // Get name of player + os<getName()<<" "; + } + + actionstream<getName() + <<" leaves game. List of players: " + <print(dstream); + infostream<<"Profiler:"<print(infostream); g_profiler->clear(); } } @@ -4413,10 +4507,10 @@ void dedicated_server_loop(Server &server, bool &kill) u32 sum = PIChecksum(list); if(sum != sum_old) { - dstream<PrintLine(&dstream); + i->PrintLine(&infostream); } } sum_old = sum; diff --git a/src/servercommand.cpp b/src/servercommand.cpp index 6c864e2c4..98777adcc 100644 --- a/src/servercommand.cpp +++ b/src/servercommand.cpp @@ -20,6 +20,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "utility.h" #include "settings.h" +#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" + void cmd_status(std::wostringstream &os, ServerCommandContext *ctx) { @@ -94,10 +96,17 @@ void cmd_grantrevoke(std::wostringstream &os, std::string playername = wide_to_narrow(ctx->parms[1]); u64 privs = ctx->server->getPlayerAuthPrivs(playername); - if(ctx->parms[0] == L"grant") + if(ctx->parms[0] == L"grant"){ + actionstream<player->getName()<<" grants " + <parms[2])<<" to " + <player->getName()<<" revokes " + <parms[2])<<" from " + <server->setPlayerAuthPrivs(playername, privs); @@ -123,6 +132,9 @@ void cmd_time(std::wostringstream &os, u32 time = stoi(wide_to_narrow(ctx->parms[1])); ctx->server->setTimeOfDay(time); os<player->getName()<<" sets time " + <player->getName() + <<" shuts down server"<server->requestShutdown(); os<paramstring); + actionstream<player->getName() + <<" sets: "<parseConfigLine(confline); ctx->server->saveConfig(); @@ -186,6 +202,11 @@ void cmd_teleport(std::wostringstream &os, } v3f dest(stoi(coords[0])*10, stoi(coords[1])*10, stoi(coords[2])*10); + + actionstream<player->getName()<<" teleports from " + <player->getPosition()/BS)<<" to " + <player->setPosition(dest); ctx->server->SendMovePlayer(ctx->player); @@ -226,6 +247,9 @@ void cmd_banunban(std::wostringstream &os, ServerCommandContext *ctx) ctx->server->setIpBanned(ip_string, player->getName()); os<getName()); + + actionstream<player->getName()<<" bans " + <getName()<<" / "<server->getBanDescription(ip_or_name); ctx->server->unsetIpBanned(ip_or_name); os<player->getName()<<" unbans " + <readConfigFile(cmd_args.get("config").c_str()); if(r == false) { - dstream<<"Could not read configuration from \"" + errorstream<<"Could not read configuration from \"" < #include "debug.h" #include "utility.h" +#include "log.h" enum ValueType { @@ -81,7 +82,7 @@ public: if(trimmedline[0] == '#') return true; - //dstream<<"trimmedline=\""< \""< objects; @@ -246,7 +247,7 @@ public: std::ifstream is(filename); if(is.good() == false) { - dstream<<"INFO: updateConfigFile():" + infostream<<"updateConfigFile():" " Error opening configuration file" " for reading: \"" <getKey(); std::string value = i.getNode()->getValue(); - dstream<<"Adding \""< expected."<= argc) { - dstream<<"Invalid command-line parameter \"" + errorstream<<"Invalid command-line parameter \"" < "; + infostream<<"str_out.size()="< "; for(u32 i=0; i "; + infostream<<"str_out.size()="< "; for(u32 i=0; i::Iterator i = aa.begin(); i != aa.end(); i++) { - i->print(dstream); - dstream<print(infostream); + infostream< active_nodes; v.updateAreaWaterPressure(area, active_nodes); - v.print(dstream, VOXELPRINT_WATERPRESSURE); + v.print(infostream, VOXELPRINT_WATERPRESSURE); //s16 highest_y = -32768; /* @@ -365,8 +366,8 @@ struct TestVoxelManipulator //v.flowWater(active_nodes, 0, true, 1000); v.flowWater(active_nodes, 0, false, 1000); - dstream<<"Final result of flowWater:"<20) - dstream<<"..."; - dstream<20) - dstream<<"..."; - dstream< +#include "log.h" /* A cache from texture name to texture path @@ -162,7 +163,7 @@ TextureSource::TextureSource(IrrlichtDevice *device): if(g_settings->getBool("enable_texture_atlas")) buildMainAtlas(); else - dstream<<"INFO: Not building texture atlas."< request = m_get_texture_queue.pop(); - dstream<<"INFO: TextureSource::processQueue(): " + infostream<<"TextureSource::processQueue(): " <<"got texture request with " <<"name=\""< result_queue; @@ -228,7 +229,7 @@ u32 TextureSource::getTextureId(const std::string &name) // Throw a request in m_get_texture_queue.add(name, 0, 0, &result_queue); - dstream<<"INFO: Waiting for texture from main thread, name=\"" + infostream<<"Waiting for texture from main thread, name=\"" <getValue(); } } - dstream<<"INFO: getTextureIdDirect(): \""<(pos_from, dim) // from ); - /*dstream<<"INFO: getTextureIdDirect(): Loaded \"" + /*infostream<<"getTextureIdDirect(): Loaded \"" <= m_atlaspointer_cache.size()) { - dstream<<"WARNING: TextureSource::getTextureName(): id="<= m_atlaspointer_cache.size()=" < max_size_in_atlas.Width || dim.Height > max_size_in_atlas.Height) { - dstream<<"INFO: TextureSource::buildMainAtlas(): Not adding " + infostream<<"TextureSource::buildMainAtlas(): Not adding " <<"\""< atlas_dim.Height) { - dstream<<"WARNING: TextureSource::buildMainAtlas(): " + infostream<<"TextureSource::buildMainAtlas(): " <<"Atlas is full, not adding more textures." <getVideoDriver(); @@ -712,7 +713,7 @@ video::IImage* generate_image_from_scratch(std::string name, } } - /*dstream<<"INFO: generate_image_from_scratch(): " + /*infostream<<"generate_image_from_scratch(): " <<"last_separator_position="<createImageFromFile(path.c_str()); if(image == NULL) { - dstream<<"WARNING: generate_image(): Could not load image \"" + infostream<<"generate_image(): Could not load image \"" < dim = image->getDimension(); //core::dimension2d dim(16,16); @@ -835,7 +836,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg, { // A special texture modification - dstream<<"INFO: generate_image(): generating special " + infostream<<"generate_image(): generating special " <<"modification \""<createImageFromFile( @@ -968,7 +969,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg, if(img) { core::dimension2d dim = img->getDimension(); - dstream<<"INFO: Size "< pos_base(x, y); video::IImage *img2 = @@ -983,7 +984,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg, } else { - dstream<<"WARNING: img==NULL"<createImageFromFile(path.c_str()); if(image == NULL) { - dstream<<"WARNING: generate_image(): Loading path \"" + infostream<<"generate_image(): Loading path \"" <createImageFromFile(path.c_str()); if(image == NULL) { - dstream<<"WARNING: generate_image(): Loading path \"" + infostream<<"generate_image(): Loading path \"" <createImageFromFile(path.c_str()); if(image == NULL) { - dstream<<"WARNING: generate_image(): Loading path \"" + infostream<<"generate_image(): Loading path \"" <queryFeature(video::EVDF_RENDER_TO_TARGET) == false) { - dstream<<"WARNING: generate_image(): EVDF_RENDER_TO_TARGET" + infostream<<"generate_image(): EVDF_RENDER_TO_TARGET" " not supported. Creating fallback image"< MYRAND_MAX) + { + errorstream<<"WARNING: myrand_range: max-min > MYRAND_MAX"< max) + { + assert(0); + return max; + } + return (myrand()%(max-min+1))+min; +} + #ifndef SERVER // Sets the color of all vertices in the mesh void setMeshVerticesColor(scene::IMesh* mesh, video::SColor& color) diff --git a/src/utility.h b/src/utility.h index 255b75c08..c741ab047 100644 --- a/src/utility.h +++ b/src/utility.h @@ -1230,20 +1230,7 @@ int myrand(void); void mysrand(unsigned seed); #define MYRAND_MAX 32767 -inline int myrand_range(int min, int max) -{ - if(max-min > MYRAND_MAX) - { - dstream<<"WARNING: myrand_range: max-min > MYRAND_MAX"< max) - { - assert(0); - return max; - } - return (myrand()%(max-min+1))+min; -} +int myrand_range(int min, int max); /* Miscellaneous functions