Use the logger; also, default to not showing much crap in console. Use --info-on-stderr to enable crap.

master
Perttu Ahola 2011-10-16 14:57:53 +03:00
parent 4846846a2d
commit b65a5aceb0
16 changed files with 844 additions and 646 deletions

View File

@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapblock.h" #include "mapblock.h"
#include "settings.h" #include "settings.h"
#include "profiler.h" #include "profiler.h"
#include "log.h"
/* /*
QueuedMeshUpdate QueuedMeshUpdate
@ -131,6 +132,8 @@ void * MeshUpdateThread::Thread()
{ {
ThreadStarted(); ThreadStarted();
log_register_thread("MeshUpdateThread");
DSTACK(__FUNCTION_NAME); DSTACK(__FUNCTION_NAME);
BEGIN_DEBUG_EXCEPTION_HANDLER BEGIN_DEBUG_EXCEPTION_HANDLER
@ -163,7 +166,7 @@ void * MeshUpdateThread::Thread()
r.mesh = mesh_new; r.mesh = mesh_new;
r.ack_block_to_server = q->ack_block_to_server; r.ack_block_to_server = q->ack_block_to_server;
/*dstream<<"MeshUpdateThread: Processed " /*infostream<<"MeshUpdateThread: Processed "
<<"("<<q->p.X<<","<<q->p.Y<<","<<q->p.Z<<")" <<"("<<q->p.X<<","<<q->p.Y<<","<<q->p.Z<<")"
<<std::endl;*/ <<std::endl;*/
@ -172,7 +175,7 @@ void * MeshUpdateThread::Thread()
delete q; delete q;
} }
END_DEBUG_EXCEPTION_HANDLER END_DEBUG_EXCEPTION_HANDLER(errorstream)
return NULL; return NULL;
} }
@ -273,7 +276,7 @@ void Client::step(float dtime)
else else
m_ignore_damage_timer = 0.0; m_ignore_damage_timer = 0.0;
//dstream<<"Client steps "<<dtime<<std::endl; //infostream<<"Client steps "<<dtime<<std::endl;
{ {
//TimeTaker timer("ReceiveAll()", m_device); //TimeTaker timer("ReceiveAll()", m_device);
@ -298,8 +301,8 @@ void Client::step(float dtime)
{ {
counter = 20.0; counter = 20.0;
dout_client<<"Client packetcounter (20s):"<<std::endl; infostream<<"Client packetcounter (20s):"<<std::endl;
m_packetcounter.print(dout_client); m_packetcounter.print(infostream);
m_packetcounter.clear(); m_packetcounter.clear();
} }
} }
@ -343,9 +346,9 @@ void Client::step(float dtime)
if(deleted_blocks.size() > 0) if(deleted_blocks.size() > 0)
{ {
/*dstream<<DTIME<<"Client: Deleted blocks of "<<num /*infostream<<"Client: Deleted blocks of "<<num
<<" unused sectors"<<std::endl;*/ <<" unused sectors"<<std::endl;*/
/*dstream<<DTIME<<"Client: Deleted "<<num /*infostream<<"Client: Deleted "<<num
<<" unused sectors"<<std::endl;*/ <<" unused sectors"<<std::endl;*/
/* /*
@ -424,7 +427,7 @@ void Client::step(float dtime)
memset((char*)&data[3], 0, PLAYERNAME_SIZE); memset((char*)&data[3], 0, PLAYERNAME_SIZE);
snprintf((char*)&data[3], PLAYERNAME_SIZE, "%s", myplayer->getName()); snprintf((char*)&data[3], PLAYERNAME_SIZE, "%s", myplayer->getName());
/*dstream<<"Client: sending initial password hash: \""<<m_password<<"\"" /*infostream<<"Client: sending initial password hash: \""<<m_password<<"\""
<<std::endl;*/ <<std::endl;*/
memset((char*)&data[23], 0, PASSWORD_SIZE); memset((char*)&data[23], 0, PASSWORD_SIZE);
@ -458,7 +461,7 @@ void Client::step(float dtime)
&deleted_blocks); &deleted_blocks);
/*if(deleted_blocks.size() > 0) /*if(deleted_blocks.size() > 0)
dstream<<"Client: Unloaded "<<deleted_blocks.size() infostream<<"Client: Unloaded "<<deleted_blocks.size()
<<" unused blocks"<<std::endl;*/ <<" unused blocks"<<std::endl;*/
/* /*
@ -561,7 +564,7 @@ void Client::step(float dtime)
//JMutexAutoLock lock(m_con_mutex); //bulk comment-out //JMutexAutoLock lock(m_con_mutex); //bulk comment-out
// connectedAndInitialized() is true, peer exists. // connectedAndInitialized() is true, peer exists.
con::Peer *peer = m_con.GetPeer(PEER_ID_SERVER); con::Peer *peer = m_con.GetPeer(PEER_ID_SERVER);
dstream<<DTIME<<"Client: avg_rtt="<<peer->avg_rtt<<std::endl; infostream<<"Client: avg_rtt="<<peer->avg_rtt<<std::endl;
} }
} }
@ -587,7 +590,7 @@ void Client::step(float dtime)
//TimeTaker timer("** Processing mesh update result queue"); //TimeTaker timer("** Processing mesh update result queue");
// 0ms // 0ms
/*dstream<<"Mesh update result queue size is " /*infostream<<"Mesh update result queue size is "
<<m_mesh_update_thread.m_queue_out.size() <<m_mesh_update_thread.m_queue_out.size()
<<std::endl;*/ <<std::endl;*/
@ -601,7 +604,7 @@ void Client::step(float dtime)
} }
if(r.ack_block_to_server) if(r.ack_block_to_server)
{ {
/*dstream<<"Client: ACK block ("<<r.p.X<<","<<r.p.Y /*infostream<<"Client: ACK block ("<<r.p.X<<","<<r.p.Y
<<","<<r.p.Z<<")"<<std::endl;*/ <<","<<r.p.Z<<")"<<std::endl;*/
/* /*
Acknowledge block Acknowledge block
@ -628,12 +631,12 @@ void Client::step(float dtime)
// Virtual methods from con::PeerHandler // Virtual methods from con::PeerHandler
void Client::peerAdded(con::Peer *peer) void Client::peerAdded(con::Peer *peer)
{ {
derr_client<<"Client::peerAdded(): peer->id=" infostream<<"Client::peerAdded(): peer->id="
<<peer->id<<std::endl; <<peer->id<<std::endl;
} }
void Client::deletingPeer(con::Peer *peer, bool timeout) void Client::deletingPeer(con::Peer *peer, bool timeout)
{ {
derr_client<<"Client::deletingPeer(): " infostream<<"Client::deletingPeer(): "
"Server Peer is getting deleted " "Server Peer is getting deleted "
<<"(timeout="<<timeout<<")"<<std::endl; <<"(timeout="<<timeout<<")"<<std::endl;
} }
@ -652,7 +655,7 @@ void Client::ReceiveAll()
} }
catch(con::InvalidIncomingDataException &e) catch(con::InvalidIncomingDataException &e)
{ {
dout_client<<DTIME<<"Client::ReceiveAll(): " infostream<<"Client::ReceiveAll(): "
"InvalidIncomingDataException: what()=" "InvalidIncomingDataException: what()="
<<e.what()<<std::endl; <<e.what()<<std::endl;
} }
@ -691,7 +694,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
ToClientCommand command = (ToClientCommand)readU16(&data[0]); ToClientCommand command = (ToClientCommand)readU16(&data[0]);
//dstream<<"Client: received command="<<command<<std::endl; //infostream<<"Client: received command="<<command<<std::endl;
m_packetcounter.add((u16)command); m_packetcounter.add((u16)command);
/* /*
@ -700,7 +703,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
*/ */
if(sender_peer_id != PEER_ID_SERVER) if(sender_peer_id != PEER_ID_SERVER)
{ {
dout_client<<DTIME<<"Client::ProcessData(): Discarding data not " infostream<<"Client::ProcessData(): Discarding data not "
"coming from server: peer_id="<<sender_peer_id "coming from server: peer_id="<<sender_peer_id
<<std::endl; <<std::endl;
return; return;
@ -716,7 +719,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
u8 ser_version = m_server_ser_ver; u8 ser_version = m_server_ser_ver;
//dstream<<"Client received command="<<(int)command<<std::endl; //infostream<<"Client received command="<<(int)command<<std::endl;
if(command == TOCLIENT_INIT) if(command == TOCLIENT_INIT)
{ {
@ -725,13 +728,13 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
u8 deployed = data[2]; u8 deployed = data[2];
dout_client<<DTIME<<"Client: TOCLIENT_INIT received with " infostream<<"Client: TOCLIENT_INIT received with "
"deployed="<<((int)deployed&0xff)<<std::endl; "deployed="<<((int)deployed&0xff)<<std::endl;
if(deployed < SER_FMT_VER_LOWEST if(deployed < SER_FMT_VER_LOWEST
|| deployed > SER_FMT_VER_HIGHEST) || deployed > SER_FMT_VER_HIGHEST)
{ {
derr_client<<DTIME<<"Client: TOCLIENT_INIT: Server sent " infostream<<"Client: TOCLIENT_INIT: Server sent "
<<"unsupported ser_fmt_ver"<<std::endl; <<"unsupported ser_fmt_ver"<<std::endl;
return; return;
} }
@ -757,7 +760,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
{ {
// Get map seed // Get map seed
m_map_seed = readU64(&data[2+1+6]); m_map_seed = readU64(&data[2+1+6]);
dstream<<"Client: received map seed: "<<m_map_seed<<std::endl; infostream<<"Client: received map seed: "<<m_map_seed<<std::endl;
} }
// Reply to server // Reply to server
@ -788,7 +791,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
if(ser_version == SER_FMT_VER_INVALID) if(ser_version == SER_FMT_VER_INVALID)
{ {
dout_client<<DTIME<<"WARNING: Client: Server serialization" infostream<<"Client: Server serialization"
" format invalid or not initialized." " format invalid or not initialized."
" Skipping incoming command="<<command<<std::endl; " Skipping incoming command="<<command<<std::endl;
return; return;
@ -842,9 +845,9 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
p.Y = readS16(&data[4]); p.Y = readS16(&data[4]);
p.Z = readS16(&data[6]); p.Z = readS16(&data[6]);
/*dout_client<<DTIME<<"Client: Thread: BLOCKDATA for (" /*infostream<<"Client: Thread: BLOCKDATA for ("
<<p.X<<","<<p.Y<<","<<p.Z<<")"<<std::endl;*/ <<p.X<<","<<p.Y<<","<<p.Z<<")"<<std::endl;*/
/*dstream<<DTIME<<"Client: Thread: BLOCKDATA for (" /*infostream<<"Client: Thread: BLOCKDATA for ("
<<p.X<<","<<p.Y<<","<<p.Z<<")"<<std::endl;*/ <<p.X<<","<<p.Y<<","<<p.Z<<")"<<std::endl;*/
std::string datastring((char*)&data[8], datasize-8); std::string datastring((char*)&data[8], datasize-8);
@ -867,7 +870,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
/* /*
Update an existing block Update an existing block
*/ */
//dstream<<"Updating"<<std::endl; //infostream<<"Updating"<<std::endl;
block->deSerialize(istr, ser_version); block->deSerialize(istr, ser_version);
} }
else else
@ -875,7 +878,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
/* /*
Create a new block Create a new block
*/ */
//dstream<<"Creating new"<<std::endl; //infostream<<"Creating new"<<std::endl;
block = new MapBlock(&m_env.getMap(), p); block = new MapBlock(&m_env.getMap(), p);
block->deSerialize(istr, ser_version); block->deSerialize(istr, ser_version);
sector->insertBlock(block); 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. Add it to mesh update queue and set it to be acknowledged after update.
*/ */
//std::cerr<<"Adding mesh update task for received block"<<std::endl; //infostream<<"Adding mesh update task for received block"<<std::endl;
addUpdateMeshTaskWithEdge(p, true); addUpdateMeshTaskWithEdge(p, true);
} }
else if(command == TOCLIENT_PLAYERPOS) else if(command == TOCLIENT_PLAYERPOS)
{ {
dstream<<"WARNING: Received deprecated TOCLIENT_PLAYERPOS" infostream<<"Received deprecated TOCLIENT_PLAYERPOS"
<<std::endl; <<std::endl;
/*u16 our_peer_id; /*u16 our_peer_id;
{ {
@ -935,7 +938,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
} }
// Cancel if we don't have a peer id // Cancel if we don't have a peer id
if(our_peer_id == PEER_ID_INEXISTENT){ if(our_peer_id == PEER_ID_INEXISTENT){
dout_client<<DTIME<<"TOCLIENT_PLAYERPOS cancelled: " infostream<<"TOCLIENT_PLAYERPOS cancelled: "
"we have no peer id" "we have no peer id"
<<std::endl; <<std::endl;
return; return;
@ -972,7 +975,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
v3s32 ss = readV3S32(&data[start+2+12]); v3s32 ss = readV3S32(&data[start+2+12]);
s32 pitch_i = readS32(&data[start+2+12+12]); s32 pitch_i = readS32(&data[start+2+12+12]);
s32 yaw_i = readS32(&data[start+2+12+12+4]); s32 yaw_i = readS32(&data[start+2+12+12+4]);
/*dstream<<"Client: got " /*infostream<<"Client: got "
<<"pitch_i="<<pitch_i <<"pitch_i="<<pitch_i
<<" yaw_i="<<yaw_i<<std::endl;*/ <<" yaw_i="<<yaw_i<<std::endl;*/
f32 pitch = (f32)pitch_i / 100.0; f32 pitch = (f32)pitch_i / 100.0;
@ -984,7 +987,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
player->setPitch(pitch); player->setPitch(pitch);
player->setYaw(yaw); player->setYaw(yaw);
/*dstream<<"Client: player "<<peer_id /*infostream<<"Client: player "<<peer_id
<<" pitch="<<pitch <<" pitch="<<pitch
<<" yaw="<<yaw<<std::endl;*/ <<" yaw="<<yaw<<std::endl;*/
@ -1001,13 +1004,13 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
} }
// Cancel if we don't have a peer id // Cancel if we don't have a peer id
if(our_peer_id == PEER_ID_INEXISTENT){ if(our_peer_id == PEER_ID_INEXISTENT){
dout_client<<DTIME<<"TOCLIENT_PLAYERINFO cancelled: " infostream<<"TOCLIENT_PLAYERINFO cancelled: "
"we have no peer id" "we have no peer id"
<<std::endl; <<std::endl;
return; return;
} }
//dstream<<DTIME<<"Client: Server reports players:"<<std::endl; //infostream<<"Client: Server reports players:"<<std::endl;
{ //envlock { //envlock
//JMutexAutoLock envlock(m_env_mutex); //bulk comment-out //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
@ -1026,7 +1029,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
players_alive.push_back(peer_id); players_alive.push_back(peer_id);
/*dstream<<DTIME<<"peer_id="<<peer_id /*infostream<<"peer_id="<<peer_id
<<" name="<<((char*)&data[start+2])<<std::endl;*/ <<" name="<<((char*)&data[start+2])<<std::endl;*/
// Don't update the info of the local player // Don't update the info of the local player
@ -1047,7 +1050,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
-1); -1);
player->peer_id = peer_id; player->peer_id = peer_id;
m_env.addPlayer(player); m_env.addPlayer(player);
dout_client<<DTIME<<"Client: Adding new player " infostream<<"Client: Adding new player "
<<peer_id<<std::endl; <<peer_id<<std::endl;
} }
@ -1060,7 +1063,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
Remove those players from the environment that Remove those players from the environment that
weren't listed by the server. weren't listed by the server.
*/ */
//dstream<<DTIME<<"Removing dead players"<<std::endl; //infostream<<"Removing dead players"<<std::endl;
core::list<Player*> players = m_env.getPlayers(); core::list<Player*> players = m_env.getPlayers();
core::list<Player*>::Iterator ip; core::list<Player*>::Iterator ip;
for(ip=players.begin(); ip!=players.end(); 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 // Warn about a special case
if((*ip)->peer_id == 0) if((*ip)->peer_id == 0)
{ {
dstream<<DTIME<<"WARNING: Client: Removing " infostream<<"Client: Removing "
"dead player with id=0"<<std::endl; "dead player with id=0"<<std::endl;
} }
@ -1086,11 +1089,11 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
break; break;
} }
} }
/*dstream<<DTIME<<"peer_id="<<((*ip)->peer_id) /*infostream<<"peer_id="<<((*ip)->peer_id)
<<" is_alive="<<is_alive<<std::endl;*/ <<" is_alive="<<is_alive<<std::endl;*/
if(is_alive) if(is_alive)
continue; continue;
dstream<<DTIME<<"Removing dead player "<<(*ip)->peer_id infostream<<"Removing dead player "<<(*ip)->peer_id
<<std::endl; <<std::endl;
m_env.removePlayer((*ip)->peer_id); m_env.removePlayer((*ip)->peer_id);
} }
@ -1098,7 +1101,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
} }
else if(command == TOCLIENT_SECTORMETA) else if(command == TOCLIENT_SECTORMETA)
{ {
dstream<<"Client received DEPRECATED TOCLIENT_SECTORMETA"<<std::endl; infostream<<"Client received DEPRECATED TOCLIENT_SECTORMETA"<<std::endl;
#if 0 #if 0
/* /*
[0] u16 command [0] u16 command
@ -1108,7 +1111,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
if(datasize < 3) if(datasize < 3)
return; return;
//dstream<<"Client received TOCLIENT_SECTORMETA"<<std::endl; //infostream<<"Client received TOCLIENT_SECTORMETA"<<std::endl;
{ //envlock { //envlock
//JMutexAutoLock envlock(m_env_mutex); //bulk comment-out //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
@ -1121,14 +1124,14 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
is.read((char*)buf, 1); is.read((char*)buf, 1);
u16 sector_count = readU8(buf); u16 sector_count = readU8(buf);
//dstream<<"sector_count="<<sector_count<<std::endl; //infostream<<"sector_count="<<sector_count<<std::endl;
for(u16 i=0; i<sector_count; i++) for(u16 i=0; i<sector_count; i++)
{ {
// Read position // Read position
is.read((char*)buf, 4); is.read((char*)buf, 4);
v2s16 pos = readV2S16(buf); v2s16 pos = readV2S16(buf);
/*dstream<<"Client: deserializing sector at " /*infostream<<"Client: deserializing sector at "
<<"("<<pos.X<<","<<pos.Y<<")"<<std::endl;*/ <<"("<<pos.X<<","<<pos.Y<<")"<<std::endl;*/
// Create sector // Create sector
assert(m_env.getMap().mapType() == MAPTYPE_CLIENT); assert(m_env.getMap().mapType() == MAPTYPE_CLIENT);
@ -1154,7 +1157,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
std::istringstream is(datastring, std::ios_base::binary); std::istringstream is(datastring, std::ios_base::binary);
//t3.stop(); //t3.stop();
//m_env.printPlayers(dstream); //m_env.printPlayers(infostream);
//TimeTaker t4("player get", m_device); //TimeTaker t4("player get", m_device);
Player *player = m_env.getLocalPlayer(); Player *player = m_env.getLocalPlayer();
@ -1167,8 +1170,8 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
m_inventory_updated = true; m_inventory_updated = true;
//dstream<<"Client got player inventory:"<<std::endl; //infostream<<"Client got player inventory:"<<std::endl;
//player->inventory.print(dstream); //player->inventory.print(infostream);
} }
} }
//DEBUG //DEBUG
@ -1233,7 +1236,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
// Read active block count // Read active block count
u16 blockcount = readU16(is); u16 blockcount = readU16(is);
if(blockcount != 0){ if(blockcount != 0){
dstream<<"WARNING: TOCLIENT_OBJECTDATA: blockcount != 0 " infostream<<"TOCLIENT_OBJECTDATA: blockcount != 0 "
"not supported"<<std::endl; "not supported"<<std::endl;
return; return;
} }
@ -1245,7 +1248,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
u16 time_of_day = readU16(&data[2]); u16 time_of_day = readU16(&data[2]);
time_of_day = time_of_day % 24000; time_of_day = time_of_day % 24000;
//dstream<<"Client: time_of_day="<<time_of_day<<std::endl; //infostream<<"Client: time_of_day="<<time_of_day<<std::endl;
/* /*
time_of_day: time_of_day:
@ -1257,7 +1260,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
u32 dr = m_env.getDayNightRatio(); u32 dr = m_env.getDayNightRatio();
dstream<<"Client: time_of_day="<<time_of_day infostream<<"Client: time_of_day="<<time_of_day
<<", dr="<<dr <<", dr="<<dr
<<std::endl; <<std::endl;
} }
@ -1285,7 +1288,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
message += (wchar_t)readU16(buf); message += (wchar_t)readU16(buf);
} }
/*dstream<<"Client received chat message: " /*infostream<<"Client received chat message: "
<<wide_to_narrow(message)<<std::endl;*/ <<wide_to_narrow(message)<<std::endl;*/
m_chat_queue.push_back(message); m_chat_queue.push_back(message);
@ -1414,7 +1417,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
/*player->setPitch(pitch); /*player->setPitch(pitch);
player->setYaw(yaw);*/ player->setYaw(yaw);*/
dstream<<"Client got TOCLIENT_MOVE_PLAYER" infostream<<"Client got TOCLIENT_MOVE_PLAYER"
<<" pos=("<<pos.X<<","<<pos.Y<<","<<pos.Z<<")" <<" pos=("<<pos.X<<","<<pos.Y<<","<<pos.Z<<")"
<<" pitch="<<pitch <<" pitch="<<pitch
<<" yaw="<<yaw <<" yaw="<<yaw
@ -1449,13 +1452,13 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
if (player == NULL) if (player == NULL)
{ {
dout_client<<DTIME<<"Client: ignoring player item " infostream<<"Client: ignoring player item "
<< deSerializeString(is) << deSerializeString(is)
<< " for non-existing peer id " << peer_id << " for non-existing peer id " << peer_id
<< std::endl; << std::endl;
continue; continue;
} else if (player->isLocal()) { } else if (player->isLocal()) {
dout_client<<DTIME<<"Client: ignoring player item " infostream<<"Client: ignoring player item "
<< deSerializeString(is) << deSerializeString(is)
<< " for local player" << std::endl; << " for local player" << std::endl;
continue; continue;
@ -1464,15 +1467,15 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
std::string itemstring(deSerializeString(is)); std::string itemstring(deSerializeString(is));
if (itemstring.empty()) { if (itemstring.empty()) {
inv->deleteItem(0); inv->deleteItem(0);
dout_client<<DTIME infostream
<<"Client: empty player item for peer " <<"Client: empty player item for peer "
<< peer_id << std::endl; << peer_id << std::endl;
} else { } else {
std::istringstream iss(itemstring); std::istringstream iss(itemstring);
delete inv->changeItem(0, InventoryItem::deSerialize(iss)); delete inv->changeItem(0, InventoryItem::deSerialize(iss));
dout_client<<DTIME<<"Client: player item for peer " << peer_id << ": "; infostream<<"Client: player item for peer " << peer_id << ": ";
player->getWieldItem()->serialize(dout_client); player->getWieldItem()->serialize(infostream);
dout_client<<std::endl; infostream<<std::endl;
} }
} }
} }
@ -1495,7 +1498,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
} }
else else
{ {
dout_client<<DTIME<<"WARNING: Client: Ignoring unknown command " infostream<<"Client: Ignoring unknown command "
<<command<<std::endl; <<command<<std::endl;
} }
} }
@ -1510,7 +1513,7 @@ void Client::groundAction(u8 action, v3s16 nodepos_undersurface,
v3s16 nodepos_oversurface, u16 item) v3s16 nodepos_oversurface, u16 item)
{ {
if(connectedAndInitialized() == false){ if(connectedAndInitialized() == false){
dout_client<<DTIME<<"Client::groundAction() " infostream<<"Client::groundAction() "
"cancelled (not connected)" "cancelled (not connected)"
<<std::endl; <<std::endl;
return; return;
@ -1542,7 +1545,7 @@ void Client::groundAction(u8 action, v3s16 nodepos_undersurface,
void Client::clickActiveObject(u8 button, u16 id, u16 item_i) void Client::clickActiveObject(u8 button, u16 id, u16 item_i)
{ {
if(connectedAndInitialized() == false){ if(connectedAndInitialized() == false){
dout_client<<DTIME<<"Client::clickActiveObject() " infostream<<"Client::clickActiveObject() "
"cancelled (not connected)" "cancelled (not connected)"
<<std::endl; <<std::endl;
return; return;
@ -1954,12 +1957,12 @@ Inventory* Client::getInventory(InventoryContext *c, std::string id)
NodeMetadata* meta = getNodeMetadata(p); NodeMetadata* meta = getNodeMetadata(p);
if(meta) if(meta)
return meta->getInventory(); return meta->getInventory();
dstream<<"nodemeta at ("<<p.X<<","<<p.Y<<","<<p.Z<<"): " infostream<<"nodemeta at ("<<p.X<<","<<p.Y<<","<<p.Z<<"): "
<<"no metadata found"<<std::endl; <<"no metadata found"<<std::endl;
return NULL; return NULL;
} }
dstream<<__FUNCTION_NAME<<": unknown id "<<id<<std::endl; infostream<<__FUNCTION_NAME<<": unknown id "<<id<<std::endl;
return NULL; return NULL;
} }
void Client::inventoryAction(InventoryAction *a) void Client::inventoryAction(InventoryAction *a)
@ -1977,7 +1980,7 @@ ClientActiveObject * Client::getSelectedActiveObject(
m_env.getActiveObjects(from_pos_f_on_map, max_d, objects); m_env.getActiveObjects(from_pos_f_on_map, max_d, objects);
//dstream<<"Collected "<<objects.size()<<" nearby objects"<<std::endl; //infostream<<"Collected "<<objects.size()<<" nearby objects"<<std::endl;
// Sort them. // Sort them.
// After this, the closest object is the first in the array. // After this, the closest object is the first in the array.
@ -2000,12 +2003,12 @@ ClientActiveObject * Client::getSelectedActiveObject(
if(offsetted_box.intersectsWithLine(shootline_on_map)) if(offsetted_box.intersectsWithLine(shootline_on_map))
{ {
//dstream<<"Returning selected object"<<std::endl; //infostream<<"Returning selected object"<<std::endl;
return obj; return obj;
} }
} }
//dstream<<"No object selected; returning NULL."<<std::endl; //infostream<<"No object selected; returning NULL."<<std::endl;
return NULL; return NULL;
} }
@ -2069,7 +2072,7 @@ void Client::clearTempMod(v3s16 p)
void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server) void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server)
{ {
/*dstream<<"Client::addUpdateMeshTask(): " /*infostream<<"Client::addUpdateMeshTask(): "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")" <<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;*/ <<std::endl;*/
@ -2096,7 +2099,7 @@ void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server)
// Add task to queue // Add task to queue
m_mesh_update_thread.m_queue_in.addBlock(p, data, ack_to_server); m_mesh_update_thread.m_queue_in.addBlock(p, data, ack_to_server);
/*dstream<<"Mesh update input queue size is " /*infostream<<"Mesh update input queue size is "
<<m_mesh_update_thread.m_queue_in.size() <<m_mesh_update_thread.m_queue_in.size()
<<std::endl;*/ <<std::endl;*/
@ -2123,7 +2126,7 @@ void Client::addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server)
{ {
/*{ /*{
v3s16 p = blockpos; v3s16 p = blockpos;
dstream<<"Client::addUpdateMeshTaskWithEdge(): " infostream<<"Client::addUpdateMeshTaskWithEdge(): "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")" <<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl; <<std::endl;
}*/ }*/

View File

@ -116,7 +116,7 @@ void TestCAO::step(float dtime, ClientEnvironment *env)
if(m_node) if(m_node)
{ {
v3f rot = m_node->getRotation(); v3f rot = m_node->getRotation();
//dstream<<"dtime="<<dtime<<", rot.Y="<<rot.Y<<std::endl; //infostream<<"dtime="<<dtime<<", rot.Y="<<rot.Y<<std::endl;
rot.Y += dtime * 180; rot.Y += dtime * 180;
m_node->setRotation(rot); m_node->setRotation(rot);
} }
@ -124,7 +124,7 @@ void TestCAO::step(float dtime, ClientEnvironment *env)
void TestCAO::processMessage(const std::string &data) void TestCAO::processMessage(const std::string &data)
{ {
dstream<<"TestCAO: Got data: "<<data<<std::endl; infostream<<"TestCAO: Got data: "<<data<<std::endl;
std::istringstream is(data, std::ios::binary); std::istringstream is(data, std::ios::binary);
u16 cmd; u16 cmd;
is>>cmd; is>>cmd;
@ -259,7 +259,7 @@ void ItemCAO::step(float dtime, ClientEnvironment *env)
void ItemCAO::processMessage(const std::string &data) void ItemCAO::processMessage(const std::string &data)
{ {
dstream<<"ItemCAO: Got message"<<std::endl; infostream<<"ItemCAO: Got message"<<std::endl;
std::istringstream is(data, std::ios::binary); std::istringstream is(data, std::ios::binary);
// command // command
u8 cmd = readU8(is); u8 cmd = readU8(is);
@ -273,7 +273,7 @@ void ItemCAO::processMessage(const std::string &data)
void ItemCAO::initialize(const std::string &data) void ItemCAO::initialize(const std::string &data)
{ {
dstream<<"ItemCAO: Got init data"<<std::endl; infostream<<"ItemCAO: Got init data"<<std::endl;
{ {
std::istringstream is(data, std::ios::binary); std::istringstream is(data, std::ios::binary);
@ -313,7 +313,7 @@ void ItemCAO::initialize(const std::string &data)
try{ try{
InventoryItem *item = NULL; InventoryItem *item = NULL;
item = InventoryItem::deSerialize(is); item = InventoryItem::deSerialize(is);
dstream<<__FUNCTION_NAME<<": m_inventorystring=\"" infostream<<__FUNCTION_NAME<<": m_inventorystring=\""
<<m_inventorystring<<"\" -> item="<<item <<m_inventorystring<<"\" -> item="<<item
<<std::endl; <<std::endl;
if(item) if(item)
@ -324,7 +324,7 @@ void ItemCAO::initialize(const std::string &data)
} }
catch(SerializationError &e) catch(SerializationError &e)
{ {
dstream<<"WARNING: "<<__FUNCTION_NAME infostream<<"WARNING: "<<__FUNCTION_NAME
<<": error deSerializing inventorystring \"" <<": error deSerializing inventorystring \""
<<m_inventorystring<<"\""<<std::endl; <<m_inventorystring<<"\""<<std::endl;
} }
@ -446,7 +446,7 @@ void RatCAO::step(float dtime, ClientEnvironment *env)
void RatCAO::processMessage(const std::string &data) void RatCAO::processMessage(const std::string &data)
{ {
//dstream<<"RatCAO: Got message"<<std::endl; //infostream<<"RatCAO: Got message"<<std::endl;
std::istringstream is(data, std::ios::binary); std::istringstream is(data, std::ios::binary);
// command // command
u8 cmd = readU8(is); u8 cmd = readU8(is);
@ -463,7 +463,7 @@ void RatCAO::processMessage(const std::string &data)
void RatCAO::initialize(const std::string &data) void RatCAO::initialize(const std::string &data)
{ {
//dstream<<"RatCAO: Got init data"<<std::endl; //infostream<<"RatCAO: Got init data"<<std::endl;
{ {
std::istringstream is(data, std::ios::binary); std::istringstream is(data, std::ios::binary);
@ -670,7 +670,7 @@ void Oerkki1CAO::step(float dtime, ClientEnvironment *env)
void Oerkki1CAO::processMessage(const std::string &data) void Oerkki1CAO::processMessage(const std::string &data)
{ {
//dstream<<"Oerkki1CAO: Got message"<<std::endl; //infostream<<"Oerkki1CAO: Got message"<<std::endl;
std::istringstream is(data, std::ios::binary); std::istringstream is(data, std::ios::binary);
// command // command
u8 cmd = readU8(is); u8 cmd = readU8(is);
@ -692,7 +692,7 @@ void Oerkki1CAO::processMessage(const std::string &data)
void Oerkki1CAO::initialize(const std::string &data) void Oerkki1CAO::initialize(const std::string &data)
{ {
//dstream<<"Oerkki1CAO: Got init data"<<std::endl; //infostream<<"Oerkki1CAO: Got init data"<<std::endl;
{ {
std::istringstream is(data, std::ios::binary); std::istringstream is(data, std::ios::binary);
@ -831,7 +831,7 @@ void FireflyCAO::step(float dtime, ClientEnvironment *env)
void FireflyCAO::processMessage(const std::string &data) void FireflyCAO::processMessage(const std::string &data)
{ {
//dstream<<"FireflyCAO: Got message"<<std::endl; //infostream<<"FireflyCAO: Got message"<<std::endl;
std::istringstream is(data, std::ios::binary); std::istringstream is(data, std::ios::binary);
// command // command
u8 cmd = readU8(is); u8 cmd = readU8(is);
@ -848,7 +848,7 @@ void FireflyCAO::processMessage(const std::string &data)
void FireflyCAO::initialize(const std::string &data) void FireflyCAO::initialize(const std::string &data)
{ {
//dstream<<"FireflyCAO: Got init data"<<std::endl; //infostream<<"FireflyCAO: Got init data"<<std::endl;
{ {
std::istringstream is(data, std::ios::binary); std::istringstream is(data, std::ios::binary);
@ -912,7 +912,7 @@ void MobV2CAO::addToScene(scene::ISceneManager *smgr)
if(m_node != NULL) if(m_node != NULL)
return; return;
/*dstream<<"MobV2CAO::addToScene using texture_name="<< /*infostream<<"MobV2CAO::addToScene using texture_name="<<
m_texture_name<<std::endl;*/ m_texture_name<<std::endl;*/
std::string texture_string = "[makealpha2:128,0,0;128,128,0:"; std::string texture_string = "[makealpha2:128,0,0;128,128,0:";
texture_string += m_texture_name; texture_string += m_texture_name;
@ -944,7 +944,7 @@ void MobV2CAO::addToScene(scene::ISceneManager *smgr)
bill->setTCoords(2, v2f(txs*0, tys*0)); bill->setTCoords(2, v2f(txs*0, tys*0));
bill->setTCoords(3, v2f(txs*0, tys*1)); bill->setTCoords(3, v2f(txs*0, tys*1));
} else { } else {
dstream<<"MobV2CAO: Unknown sprite type \""<<m_sprite_type<<"\"" infostream<<"MobV2CAO: Unknown sprite type \""<<m_sprite_type<<"\""
<<std::endl; <<std::endl;
} }
@ -1023,7 +1023,7 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env)
float mob_dir = atan2(cam_to_mob.Z, cam_to_mob.X) / PI * 180.; float mob_dir = atan2(cam_to_mob.Z, cam_to_mob.X) / PI * 180.;
float dir = mob_dir - m_yaw; float dir = mob_dir - m_yaw;
dir = wrapDegrees_180(dir); dir = wrapDegrees_180(dir);
//dstream<<"id="<<m_id<<" dir="<<dir<<std::endl; //infostream<<"id="<<m_id<<" dir="<<dir<<std::endl;
if(fabs(wrapDegrees_180(dir - 0)) <= 45.1) if(fabs(wrapDegrees_180(dir - 0)) <= 45.1)
col = 2; col = 2;
else if(fabs(wrapDegrees_180(dir - 90)) <= 45.1) else if(fabs(wrapDegrees_180(dir - 90)) <= 45.1)
@ -1074,7 +1074,7 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env)
bill->setTCoords(2, v2f(txs*(0+col), tys*(0+row))); bill->setTCoords(2, v2f(txs*(0+col), tys*(0+row)));
bill->setTCoords(3, v2f(txs*(0+col), tys*(1+row))); bill->setTCoords(3, v2f(txs*(0+col), tys*(1+row)));
} else { } else {
dstream<<"MobV2CAO::step(): Unknown sprite type \"" infostream<<"MobV2CAO::step(): Unknown sprite type \""
<<m_sprite_type<<"\""<<std::endl; <<m_sprite_type<<"\""<<std::endl;
} }
@ -1104,7 +1104,7 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env)
if(m_damage_visual_timer >= 0){ if(m_damage_visual_timer >= 0){
m_damage_visual_timer -= dtime; m_damage_visual_timer -= dtime;
if(m_damage_visual_timer <= 0){ if(m_damage_visual_timer <= 0){
dstream<<"id="<<m_id<<" damage visual ended"<<std::endl; infostream<<"id="<<m_id<<" damage visual ended"<<std::endl;
} }
} }
@ -1128,7 +1128,7 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env)
void MobV2CAO::processMessage(const std::string &data) void MobV2CAO::processMessage(const std::string &data)
{ {
//dstream<<"MobV2CAO: Got message"<<std::endl; //infostream<<"MobV2CAO: Got message"<<std::endl;
std::istringstream is(data, std::ios::binary); std::istringstream is(data, std::ios::binary);
// command // command
u8 cmd = readU8(is); u8 cmd = readU8(is);
@ -1182,7 +1182,7 @@ void MobV2CAO::processMessage(const std::string &data)
void MobV2CAO::initialize(const std::string &data) void MobV2CAO::initialize(const std::string &data)
{ {
//dstream<<"MobV2CAO: Got init data"<<std::endl; //infostream<<"MobV2CAO: Got init data"<<std::endl;
{ {
std::istringstream is(data, std::ios::binary); std::istringstream is(data, std::ios::binary);
@ -1190,7 +1190,7 @@ void MobV2CAO::initialize(const std::string &data)
u8 version = readU8(is); u8 version = readU8(is);
// check version // check version
if(version != 0){ if(version != 0){
dstream<<__FUNCTION_NAME<<": Invalid version"<<std::endl; infostream<<__FUNCTION_NAME<<": Invalid version"<<std::endl;
return; return;
} }
@ -1199,8 +1199,8 @@ void MobV2CAO::initialize(const std::string &data)
std::istringstream tmp_is(tmp_os.str(), std::ios::binary); std::istringstream tmp_is(tmp_os.str(), std::ios::binary);
m_properties->parseConfigLines(tmp_is, "MobArgsEnd"); m_properties->parseConfigLines(tmp_is, "MobArgsEnd");
dstream<<"INFO: MobV2CAO::initialize(): got properties:"<<std::endl; infostream<<"MobV2CAO::initialize(): got properties:"<<std::endl;
m_properties->writeLines(dstream); m_properties->writeLines(infostream);
m_properties->setDefault("looks", "dummy_default"); m_properties->setDefault("looks", "dummy_default");
m_properties->setDefault("yaw", "0"); m_properties->setDefault("yaw", "0");

View File

@ -84,7 +84,7 @@ void TestSAO::step(float dtime, bool send_recommended)
if(m_timer1 < 0.0) if(m_timer1 < 0.0)
{ {
m_timer1 += 0.125; m_timer1 += 0.125;
//dstream<<"TestSAO: id="<<getId()<<" sending data"<<std::endl; //infostream<<"TestSAO: id="<<getId()<<" sending data"<<std::endl;
std::string data; std::string data;
@ -131,7 +131,7 @@ ServerActiveObject* ItemSAO::create(ServerEnvironment *env, u16 id, v3f pos,
if(version != 0) if(version != 0)
return NULL; return NULL;
std::string inventorystring = deSerializeString(is); std::string inventorystring = deSerializeString(is);
dstream<<"ItemSAO::create(): Creating item \"" infostream<<"ItemSAO::create(): Creating item \""
<<inventorystring<<"\""<<std::endl; <<inventorystring<<"\""<<std::endl;
return new ItemSAO(env, id, pos, inventorystring); return new ItemSAO(env, id, pos, inventorystring);
} }
@ -206,7 +206,7 @@ std::string ItemSAO::getClientInitializationData()
std::string ItemSAO::getStaticData() std::string ItemSAO::getStaticData()
{ {
dstream<<__FUNCTION_NAME<<std::endl; infostream<<__FUNCTION_NAME<<std::endl;
std::ostringstream os(std::ios::binary); std::ostringstream os(std::ios::binary);
char buf[1]; char buf[1];
// version // version
@ -222,14 +222,14 @@ InventoryItem * ItemSAO::createInventoryItem()
try{ try{
std::istringstream is(m_inventorystring, std::ios_base::binary); std::istringstream is(m_inventorystring, std::ios_base::binary);
InventoryItem *item = InventoryItem::deSerialize(is); InventoryItem *item = InventoryItem::deSerialize(is);
dstream<<__FUNCTION_NAME<<": m_inventorystring=\"" infostream<<__FUNCTION_NAME<<": m_inventorystring=\""
<<m_inventorystring<<"\" -> item="<<item <<m_inventorystring<<"\" -> item="<<item
<<std::endl; <<std::endl;
return item; return item;
} }
catch(SerializationError &e) catch(SerializationError &e)
{ {
dstream<<__FUNCTION_NAME<<": serialization error: " infostream<<__FUNCTION_NAME<<": serialization error: "
<<"m_inventorystring=\""<<m_inventorystring<<"\""<<std::endl; <<"m_inventorystring=\""<<m_inventorystring<<"\""<<std::endl;
return NULL; return NULL;
} }
@ -237,7 +237,7 @@ InventoryItem * ItemSAO::createInventoryItem()
void ItemSAO::rightClick(Player *player) void ItemSAO::rightClick(Player *player)
{ {
dstream<<__FUNCTION_NAME<<std::endl; infostream<<__FUNCTION_NAME<<std::endl;
InventoryItem *item = createInventoryItem(); InventoryItem *item = createInventoryItem();
if(item == NULL) if(item == NULL)
return; return;
@ -424,7 +424,7 @@ std::string RatSAO::getClientInitializationData()
std::string RatSAO::getStaticData() std::string RatSAO::getStaticData()
{ {
//dstream<<__FUNCTION_NAME<<std::endl; //infostream<<__FUNCTION_NAME<<std::endl;
std::ostringstream os(std::ios::binary); std::ostringstream os(std::ios::binary);
// version // version
writeU8(os, 0); writeU8(os, 0);
@ -669,7 +669,7 @@ std::string Oerkki1SAO::getClientInitializationData()
std::string Oerkki1SAO::getStaticData() std::string Oerkki1SAO::getStaticData()
{ {
//dstream<<__FUNCTION_NAME<<std::endl; //infostream<<__FUNCTION_NAME<<std::endl;
std::ostringstream os(std::ios::binary); std::ostringstream os(std::ios::binary);
// version // version
writeU8(os, 0); writeU8(os, 0);
@ -689,7 +689,7 @@ u16 Oerkki1SAO::punch(const std::string &toolname, v3f dir)
void Oerkki1SAO::doDamage(u16 d) void Oerkki1SAO::doDamage(u16 d)
{ {
dstream<<"oerkki damage: "<<d<<std::endl; infostream<<"oerkki damage: "<<d<<std::endl;
if(d < m_hp) if(d < m_hp)
{ {
@ -877,7 +877,7 @@ std::string FireflySAO::getClientInitializationData()
std::string FireflySAO::getStaticData() std::string FireflySAO::getStaticData()
{ {
//dstream<<__FUNCTION_NAME<<std::endl; //infostream<<__FUNCTION_NAME<<std::endl;
std::ostringstream os(std::ios::binary); std::ostringstream os(std::ios::binary);
// version // version
writeU8(os, 0); writeU8(os, 0);
@ -960,7 +960,7 @@ std::string MobV2SAO::getStaticData()
std::string MobV2SAO::getClientInitializationData() std::string MobV2SAO::getClientInitializationData()
{ {
//dstream<<__FUNCTION_NAME<<std::endl; //infostream<<__FUNCTION_NAME<<std::endl;
updateProperties(); updateProperties();
@ -1092,7 +1092,7 @@ void MobV2SAO::step(float dtime, bool send_recommended)
if(dist < BS*16) if(dist < BS*16)
{ {
if(myrand_range(0,2) == 0){ if(myrand_range(0,2) == 0){
dstream<<"ACTION: id="<<m_id<<" got randomly disturbed by " infostream<<"ACTION: id="<<m_id<<" got randomly disturbed by "
<<player->getName()<<std::endl; <<player->getName()<<std::endl;
m_disturbing_player = player->getName(); m_disturbing_player = player->getName();
m_disturb_timer = 0; m_disturb_timer = 0;
@ -1135,7 +1135,7 @@ void MobV2SAO::step(float dtime, bool send_recommended)
dir.normalize(); dir.normalize();
v3f speed = dir * BS * 10.0; v3f speed = dir * BS * 10.0;
v3f pos = m_base_position + shoot_pos; v3f pos = m_base_position + shoot_pos;
dstream<<__FUNCTION_NAME<<": Shooting fireball from "<<PP(pos) infostream<<__FUNCTION_NAME<<": Shooting fireball from "<<PP(pos)
<<" at speed "<<PP(speed)<<std::endl; <<" at speed "<<PP(speed)<<std::endl;
Settings properties; Settings properties;
properties.set("looks", "fireball"); properties.set("looks", "fireball");
@ -1152,7 +1152,7 @@ void MobV2SAO::step(float dtime, bool send_recommended)
//m_env->addActiveObjectAsStatic(obj); //m_env->addActiveObjectAsStatic(obj);
m_env->addActiveObject(obj); m_env->addActiveObject(obj);
} else { } else {
dstream<<__FUNCTION_NAME<<": Unknown shoot_type="<<shoot_type infostream<<__FUNCTION_NAME<<": Unknown shoot_type="<<shoot_type
<<std::endl; <<std::endl;
} }
} }
@ -1229,7 +1229,7 @@ void MobV2SAO::step(float dtime, bool send_recommended)
m_base_position = pos_f; m_base_position = pos_f;
if((pos_f - next_pos_f).getLength() < 0.1 || arrived){ if((pos_f - next_pos_f).getLength() < 0.1 || arrived){
//dstream<<"id="<<m_id<<": arrived to "<<PP(m_next_pos_i)<<std::endl; //infostream<<"id="<<m_id<<": arrived to "<<PP(m_next_pos_i)<<std::endl;
m_next_pos_exists = false; m_next_pos_exists = false;
} }
} }
@ -1271,16 +1271,16 @@ void MobV2SAO::step(float dtime, bool send_recommended)
} }
u32 order[3*3*3]; u32 order[3*3*3];
get_random_u32_array(order, num_dps); get_random_u32_array(order, num_dps);
/*dstream<<"At pos "<<PP(pos_i)<<"; Random array: "; /*infostream<<"At pos "<<PP(pos_i)<<"; Random array: ";
for(int i=0; i<num_dps; i++){ for(int i=0; i<num_dps; i++){
dstream<<order[i]<<" "; infostream<<order[i]<<" ";
} }
dstream<<std::endl;*/ infostream<<std::endl;*/
for(int i=0; i<num_dps; i++){ for(int i=0; i<num_dps; i++){
v3s16 p = dps[order[i]] + pos_i; v3s16 p = dps[order[i]] + pos_i;
bool is_free = checkFreeAndWalkablePosition(map, bool is_free = checkFreeAndWalkablePosition(map,
p + pos_size_off, size_blocks); p + pos_size_off, size_blocks);
//dstream<<PP(p)<<" is_free="<<is_free<<std::endl; //infostream<<PP(p)<<" is_free="<<is_free<<std::endl;
if(!is_free) if(!is_free)
continue; continue;
m_next_pos_i = p; m_next_pos_i = p;
@ -1310,7 +1310,7 @@ void MobV2SAO::step(float dtime, bool send_recommended)
} }
else else
{ {
dstream<<"MobV2SAO::step(): id="<<m_id<<" unknown move_type=\"" infostream<<"MobV2SAO::step(): id="<<m_id<<" unknown move_type=\""
<<m_move_type<<"\""<<std::endl; <<m_move_type<<"\""<<std::endl;
} }
@ -1329,8 +1329,9 @@ u16 MobV2SAO::punch(const std::string &toolname, v3f dir,
assert(m_env); assert(m_env);
Map *map = &m_env->getMap(); Map *map = &m_env->getMap();
dstream<<"ACTION: "<<playername<<" punches id="<<m_id infostream<<"ACTION: "<<playername<<" punches id="<<m_id
<<" with a \""<<toolname<<"\""<<std::endl; <<" with a \""<<toolname<<"\" at "
<<PP(m_base_position/BS)<<std::endl;
m_disturb_timer = 0; m_disturb_timer = 0;
m_disturbing_player = playername; m_disturbing_player = playername;
@ -1432,7 +1433,7 @@ void MobV2SAO::updateProperties()
void MobV2SAO::doDamage(u16 d) void MobV2SAO::doDamage(u16 d)
{ {
dstream<<"MobV2 hp="<<m_hp<<" damage="<<d<<std::endl; infostream<<"MobV2 hp="<<m_hp<<" damage="<<d<<std::endl;
if(d < m_hp) if(d < m_hp)
{ {
@ -1440,6 +1441,8 @@ void MobV2SAO::doDamage(u16 d)
} }
else else
{ {
actionstream<<"A "<<(isPeaceful()?"peaceful":"non-peaceful")
<<" mob id="<<m_id<<" dies at "<<PP(m_base_position)<<std::endl;
// Die // Die
m_hp = 0; m_hp = 0;
m_removed = true; m_removed = true;

View File

@ -235,10 +235,9 @@ private:
#if CATCH_UNHANDLED_EXCEPTIONS == 1 #if CATCH_UNHANDLED_EXCEPTIONS == 1
#define BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER try{ #define BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER try{
#define END_PORTABLE_DEBUG_EXCEPTION_HANDLER\ #define END_PORTABLE_DEBUG_EXCEPTION_HANDLER(logstream)\
}catch(std::exception &e){\ }catch(std::exception &e){\
dstream<<std::endl<<DTIME\ logstream<<"ERROR: An unhandled exception occurred: "\
<<"ERROR: An unhandled exception occurred: "\
<<e.what()<<std::endl;\ <<e.what()<<std::endl;\
assert(0);\ assert(0);\
} }
@ -257,24 +256,24 @@ public:
BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER\ BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER\
_set_se_translator(se_trans_func); _set_se_translator(se_trans_func);
#define END_DEBUG_EXCEPTION_HANDLER \ #define END_DEBUG_EXCEPTION_HANDLER(logstream) \
END_PORTABLE_DEBUG_EXCEPTION_HANDLER END_PORTABLE_DEBUG_EXCEPTION_HANDLER(logstream)
#else // Probably mingw #else // Probably mingw
#define BEGIN_DEBUG_EXCEPTION_HANDLER\ #define BEGIN_DEBUG_EXCEPTION_HANDLER\
BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER
#define END_DEBUG_EXCEPTION_HANDLER\ #define END_DEBUG_EXCEPTION_HANDLER(logstream)\
END_PORTABLE_DEBUG_EXCEPTION_HANDLER END_PORTABLE_DEBUG_EXCEPTION_HANDLER(logstream)
#endif #endif
#else // Posix #else // Posix
#define BEGIN_DEBUG_EXCEPTION_HANDLER\ #define BEGIN_DEBUG_EXCEPTION_HANDLER\
BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER
#define END_DEBUG_EXCEPTION_HANDLER\ #define END_DEBUG_EXCEPTION_HANDLER(logstream)\
END_PORTABLE_DEBUG_EXCEPTION_HANDLER END_PORTABLE_DEBUG_EXCEPTION_HANDLER(logstream)
#endif #endif
#else #else
// Dummy ones // Dummy ones
#define BEGIN_DEBUG_EXCEPTION_HANDLER #define BEGIN_DEBUG_EXCEPTION_HANDLER
#define END_DEBUG_EXCEPTION_HANDLER #define END_DEBUG_EXCEPTION_HANDLER(logstream)
#endif #endif
#endif // DEBUG_HEADER #endif // DEBUG_HEADER

View File

@ -27,6 +27,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_sao.h" #include "content_sao.h"
#include "mapgen.h" #include "mapgen.h"
#include "settings.h" #include "settings.h"
#include "log.h"
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
Environment::Environment(): Environment::Environment():
m_time_of_day(9000) m_time_of_day(9000)
@ -302,7 +305,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
// Full path to this file // Full path to this file
std::string path = players_path + "/" + player_files[i].name; std::string path = players_path + "/" + player_files[i].name;
//dstream<<"Checking player file "<<path<<std::endl; //infostream<<"Checking player file "<<path<<std::endl;
// Load player to see what is its name // Load player to see what is its name
ServerRemotePlayer testplayer; ServerRemotePlayer testplayer;
@ -311,24 +314,24 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
std::ifstream is(path.c_str(), std::ios_base::binary); std::ifstream is(path.c_str(), std::ios_base::binary);
if(is.good() == false) if(is.good() == false)
{ {
dstream<<"Failed to read "<<path<<std::endl; infostream<<"Failed to read "<<path<<std::endl;
continue; continue;
} }
testplayer.deSerialize(is); testplayer.deSerialize(is);
} }
//dstream<<"Loaded test player with name "<<testplayer.getName()<<std::endl; //infostream<<"Loaded test player with name "<<testplayer.getName()<<std::endl;
// Search for the player // Search for the player
std::string playername = testplayer.getName(); std::string playername = testplayer.getName();
Player *player = getPlayer(playername.c_str()); Player *player = getPlayer(playername.c_str());
if(player == NULL) if(player == NULL)
{ {
dstream<<"Didn't find matching player, ignoring file "<<path<<std::endl; infostream<<"Didn't find matching player, ignoring file "<<path<<std::endl;
continue; continue;
} }
//dstream<<"Found matching player, overwriting."<<std::endl; //infostream<<"Found matching player, overwriting."<<std::endl;
// OK, found. Save player there. // OK, found. Save player there.
{ {
@ -336,7 +339,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
std::ofstream os(path.c_str(), std::ios_base::binary); std::ofstream os(path.c_str(), std::ios_base::binary);
if(os.good() == false) if(os.good() == false)
{ {
dstream<<"Failed to overwrite "<<path<<std::endl; infostream<<"Failed to overwrite "<<path<<std::endl;
continue; continue;
} }
player->serialize(os); player->serialize(os);
@ -350,7 +353,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
Player *player = *i; Player *player = *i;
if(saved_players.find(player) != NULL) if(saved_players.find(player) != NULL)
{ {
/*dstream<<"Player "<<player->getName() /*infostream<<"Player "<<player->getName()
<<" was already saved."<<std::endl;*/ <<" was already saved."<<std::endl;*/
continue; continue;
} }
@ -358,7 +361,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
// Don't save unnamed player // Don't save unnamed player
if(playername == "") if(playername == "")
{ {
//dstream<<"Not saving unnamed player."<<std::endl; //infostream<<"Not saving unnamed player."<<std::endl;
continue; continue;
} }
/* /*
@ -379,18 +382,18 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
} }
if(found == false) if(found == false)
{ {
dstream<<"WARNING: Didn't find free file for player"<<std::endl; infostream<<"Didn't find free file for player"<<std::endl;
continue; continue;
} }
{ {
/*dstream<<"Saving player "<<player->getName()<<" to " /*infostream<<"Saving player "<<player->getName()<<" to "
<<path<<std::endl;*/ <<path<<std::endl;*/
// Open file and serialize // Open file and serialize
std::ofstream os(path.c_str(), std::ios_base::binary); std::ofstream os(path.c_str(), std::ios_base::binary);
if(os.good() == false) if(os.good() == false)
{ {
dstream<<"WARNING: Failed to overwrite "<<path<<std::endl; infostream<<"Failed to overwrite "<<path<<std::endl;
continue; continue;
} }
player->serialize(os); player->serialize(os);
@ -398,7 +401,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
} }
} }
//dstream<<"Saved "<<saved_players.size()<<" players."<<std::endl; //infostream<<"Saved "<<saved_players.size()<<" players."<<std::endl;
} }
void ServerEnvironment::deSerializePlayers(const std::string &savedir) void ServerEnvironment::deSerializePlayers(const std::string &savedir)
@ -416,7 +419,7 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
// Full path to this file // Full path to this file
std::string path = players_path + "/" + player_files[i].name; std::string path = players_path + "/" + player_files[i].name;
dstream<<"Checking player file "<<path<<std::endl; infostream<<"Checking player file "<<path<<std::endl;
// Load player to see what is its name // Load player to see what is its name
ServerRemotePlayer testplayer; ServerRemotePlayer testplayer;
@ -425,7 +428,7 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
std::ifstream is(path.c_str(), std::ios_base::binary); std::ifstream is(path.c_str(), std::ios_base::binary);
if(is.good() == false) if(is.good() == false)
{ {
dstream<<"Failed to read "<<path<<std::endl; infostream<<"Failed to read "<<path<<std::endl;
continue; continue;
} }
testplayer.deSerialize(is); testplayer.deSerialize(is);
@ -433,11 +436,11 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
if(!string_allowed(testplayer.getName(), PLAYERNAME_ALLOWED_CHARS)) if(!string_allowed(testplayer.getName(), PLAYERNAME_ALLOWED_CHARS))
{ {
dstream<<"Not loading player with invalid name: " infostream<<"Not loading player with invalid name: "
<<testplayer.getName()<<std::endl; <<testplayer.getName()<<std::endl;
} }
dstream<<"Loaded test player with name "<<testplayer.getName() infostream<<"Loaded test player with name "<<testplayer.getName()
<<std::endl; <<std::endl;
// Search for the player // Search for the player
@ -446,20 +449,20 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
bool newplayer = false; bool newplayer = false;
if(player == NULL) if(player == NULL)
{ {
dstream<<"Is a new player"<<std::endl; infostream<<"Is a new player"<<std::endl;
player = new ServerRemotePlayer(); player = new ServerRemotePlayer();
newplayer = true; newplayer = true;
} }
// Load player // Load player
{ {
dstream<<"Reading player "<<testplayer.getName()<<" from " infostream<<"Reading player "<<testplayer.getName()<<" from "
<<path<<std::endl; <<path<<std::endl;
// Open file and deserialize // Open file and deserialize
std::ifstream is(path.c_str(), std::ios_base::binary); std::ifstream is(path.c_str(), std::ios_base::binary);
if(is.good() == false) if(is.good() == false)
{ {
dstream<<"Failed to read "<<path<<std::endl; infostream<<"Failed to read "<<path<<std::endl;
continue; continue;
} }
player->deSerialize(is); player->deSerialize(is);
@ -478,7 +481,7 @@ void ServerEnvironment::saveMeta(const std::string &savedir)
std::ofstream os(path.c_str(), std::ios_base::binary); std::ofstream os(path.c_str(), std::ios_base::binary);
if(os.good() == false) if(os.good() == false)
{ {
dstream<<"WARNING: ServerEnvironment::saveMeta(): Failed to open " infostream<<"ServerEnvironment::saveMeta(): Failed to open "
<<path<<std::endl; <<path<<std::endl;
throw SerializationError("Couldn't save env meta"); throw SerializationError("Couldn't save env meta");
} }
@ -498,7 +501,7 @@ void ServerEnvironment::loadMeta(const std::string &savedir)
std::ifstream is(path.c_str(), std::ios_base::binary); std::ifstream is(path.c_str(), std::ios_base::binary);
if(is.good() == false) if(is.good() == false)
{ {
dstream<<"WARNING: ServerEnvironment::loadMeta(): Failed to open " infostream<<"ServerEnvironment::loadMeta(): Failed to open "
<<path<<std::endl; <<path<<std::endl;
throw SerializationError("Couldn't load env meta"); throw SerializationError("Couldn't load env meta");
} }
@ -595,7 +598,7 @@ void ServerEnvironment::activateBlock(MapBlock *block, u32 additional_dtime)
// Set current time as timestamp (and let it set ChangedFlag) // Set current time as timestamp (and let it set ChangedFlag)
block->setTimestamp(m_game_time); block->setTimestamp(m_game_time);
//dstream<<"Block is "<<dtime_s<<" seconds old."<<std::endl; //infostream<<"Block is "<<dtime_s<<" seconds old."<<std::endl;
// Activate stored objects // Activate stored objects
activateObjects(block); activateObjects(block);
@ -757,7 +760,7 @@ void ServerEnvironment::step(float dtime)
{ {
v3s16 p = i.getNode()->getKey(); v3s16 p = i.getNode()->getKey();
/*dstream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z /*infostream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z
<<") became inactive"<<std::endl;*/ <<") became inactive"<<std::endl;*/
MapBlock *block = m_map->getBlockNoCreateNoEx(p); MapBlock *block = m_map->getBlockNoCreateNoEx(p);
@ -778,7 +781,7 @@ void ServerEnvironment::step(float dtime)
{ {
v3s16 p = i.getNode()->getKey(); v3s16 p = i.getNode()->getKey();
/*dstream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z /*infostream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z
<<") became active"<<std::endl;*/ <<") became active"<<std::endl;*/
MapBlock *block = m_map->getBlockNoCreateNoEx(p); MapBlock *block = m_map->getBlockNoCreateNoEx(p);
@ -802,7 +805,7 @@ void ServerEnvironment::step(float dtime)
{ {
v3s16 p = i.getNode()->getKey(); v3s16 p = i.getNode()->getKey();
/*dstream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z /*infostream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z
<<") being handled"<<std::endl;*/ <<") being handled"<<std::endl;*/
MapBlock *block = m_map->getBlockNoCreateNoEx(p); MapBlock *block = m_map->getBlockNoCreateNoEx(p);
@ -838,7 +841,7 @@ void ServerEnvironment::step(float dtime)
{ {
v3s16 p = i.getNode()->getKey(); v3s16 p = i.getNode()->getKey();
/*dstream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z /*infostream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z
<<") being handled"<<std::endl;*/ <<") being handled"<<std::endl;*/
MapBlock *block = m_map->getBlockNoCreateNoEx(p); MapBlock *block = m_map->getBlockNoCreateNoEx(p);
@ -956,18 +959,24 @@ void ServerEnvironment::step(float dtime)
v3f pos = intToFloat(p1, BS); v3f pos = intToFloat(p1, BS);
int i = myrand()%5; int i = myrand()%5;
if(i == 0 || i == 1){ if(i == 0 || i == 1){
actionstream<<"A dungeon master spawns at "
<<PP(p1)<<std::endl;
Settings properties; Settings properties;
getMob_dungeon_master(properties); getMob_dungeon_master(properties);
ServerActiveObject *obj = new MobV2SAO( ServerActiveObject *obj = new MobV2SAO(
this, 0, pos, &properties); this, 0, pos, &properties);
addActiveObject(obj); addActiveObject(obj);
} else if(i == 2 || i == 3){ } else if(i == 2 || i == 3){
actionstream<<"Rats spawn at "
<<PP(p1)<<std::endl;
for(int j=0; j<3; j++){ for(int j=0; j<3; j++){
ServerActiveObject *obj = new RatSAO( ServerActiveObject *obj = new RatSAO(
this, 0, pos); this, 0, pos);
addActiveObject(obj); addActiveObject(obj);
} }
} else { } else {
actionstream<<"An oerkki spawns at "
<<PP(p1)<<std::endl;
ServerActiveObject *obj = new Oerkki1SAO( ServerActiveObject *obj = new Oerkki1SAO(
this, 0, pos); this, 0, pos);
addActiveObject(obj); addActiveObject(obj);
@ -983,6 +992,9 @@ void ServerEnvironment::step(float dtime)
{ {
if(myrand()%50 == 0) if(myrand()%50 == 0)
{ {
actionstream<<"A sapling grows into a tree at "
<<PP(p)<<std::endl;
core::map<v3s16, MapBlock*> modified_blocks; core::map<v3s16, MapBlock*> modified_blocks;
v3s16 tree_p = p; v3s16 tree_p = p;
ManualMapVoxelManipulator vmanip(m_map); ManualMapVoxelManipulator vmanip(m_map);
@ -1111,7 +1123,7 @@ void ServerEnvironment::step(float dtime)
//ServerActiveObject *obj = new Oerkki1SAO(this, 0, pos); //ServerActiveObject *obj = new Oerkki1SAO(this, 0, pos);
//ServerActiveObject *obj = new FireflySAO(this, 0, pos); //ServerActiveObject *obj = new FireflySAO(this, 0, pos);
dstream<<DTIME<<"INFO: Server: Spawning MobV2SAO at " infostream<<"Server: Spawning MobV2SAO at "
<<"("<<pos.X<<","<<pos.Y<<","<<pos.Z<<")"<<std::endl; <<"("<<pos.X<<","<<pos.Y<<","<<pos.Z<<")"<<std::endl;
Settings properties; Settings properties;
@ -1202,7 +1214,7 @@ bool ServerEnvironment::addActiveObjectAsStatic(ServerActiveObject *obj)
succeeded = true; succeeded = true;
} }
else{ else{
dstream<<"WARNING: ServerEnvironment::addActiveObjectAsStatic: " infostream<<"ServerEnvironment::addActiveObjectAsStatic: "
<<"Could not find or generate " <<"Could not find or generate "
<<"a block for storing static object"<<std::endl; <<"a block for storing static object"<<std::endl;
succeeded = false; succeeded = false;
@ -1282,13 +1294,13 @@ void ServerEnvironment::getRemovedActiveObjects(v3s16 pos, s16 radius,
ServerActiveObject *object = getActiveObject(id); ServerActiveObject *object = getActiveObject(id);
if(object == NULL) if(object == NULL)
{ {
dstream<<"WARNING: ServerEnvironment::getRemovedActiveObjects():" infostream<<"ServerEnvironment::getRemovedActiveObjects():"
<<" object in current_objects is NULL"<<std::endl; <<" object in current_objects is NULL"<<std::endl;
} }
else if(object->m_removed == false) else if(object->m_removed == false)
{ {
f32 distance_f = object->getBasePosition().getDistanceFrom(pos_f); f32 distance_f = object->getBasePosition().getDistanceFrom(pos_f);
/*dstream<<"removed == false" /*infostream<<"removed == false"
<<"distance_f = "<<distance_f <<"distance_f = "<<distance_f
<<", radius_f = "<<radius_f<<std::endl;*/ <<", radius_f = "<<radius_f<<std::endl;*/
if(distance_f < radius_f) if(distance_f < radius_f)
@ -1322,7 +1334,7 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object,
u16 new_id = getFreeServerActiveObjectId(m_active_objects); u16 new_id = getFreeServerActiveObjectId(m_active_objects);
if(new_id == 0) if(new_id == 0)
{ {
dstream<<"WARNING: ServerEnvironment::addActiveObjectRaw(): " infostream<<"ServerEnvironment::addActiveObjectRaw(): "
<<"no free ids available"<<std::endl; <<"no free ids available"<<std::endl;
delete object; delete object;
return 0; return 0;
@ -1331,12 +1343,12 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object,
} }
if(isFreeServerActiveObjectId(object->getId(), m_active_objects) == false) if(isFreeServerActiveObjectId(object->getId(), m_active_objects) == false)
{ {
dstream<<"WARNING: ServerEnvironment::addActiveObjectRaw(): " infostream<<"ServerEnvironment::addActiveObjectRaw(): "
<<"id is not free ("<<object->getId()<<")"<<std::endl; <<"id is not free ("<<object->getId()<<")"<<std::endl;
delete object; delete object;
return 0; return 0;
} }
/*dstream<<"INFO: ServerEnvironment::addActiveObjectRaw(): " /*infostream<<"ServerEnvironment::addActiveObjectRaw(): "
<<"added (id="<<object->getId()<<")"<<std::endl;*/ <<"added (id="<<object->getId()<<")"<<std::endl;*/
m_active_objects.insert(object->getId(), object); m_active_objects.insert(object->getId(), object);
@ -1358,7 +1370,7 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object,
block->setChangedFlag(); block->setChangedFlag();
} }
else{ else{
dstream<<"WARNING: ServerEnv: Could not find a block for " infostream<<"ServerEnv: Could not find a block for "
<<"storing newly added static active object"<<std::endl; <<"storing newly added static active object"<<std::endl;
} }
@ -1380,7 +1392,7 @@ void ServerEnvironment::removeRemovedObjects()
// This shouldn't happen but check it // This shouldn't happen but check it
if(obj == NULL) if(obj == NULL)
{ {
dstream<<"WARNING: NULL object found in ServerEnvironment" infostream<<"NULL object found in ServerEnvironment"
<<" while finding removed objects. id="<<id<<std::endl; <<" while finding removed objects. id="<<id<<std::endl;
// Id to be removed from m_active_objects // Id to be removed from m_active_objects
objects_to_remove.push_back(id); objects_to_remove.push_back(id);
@ -1442,7 +1454,7 @@ void ServerEnvironment::activateObjects(MapBlock *block)
i = block->m_static_objects.m_stored.begin(); i = block->m_static_objects.m_stored.begin();
i != block->m_static_objects.m_stored.end(); i++) i != block->m_static_objects.m_stored.end(); i++)
{ {
/*dstream<<"INFO: Server: Creating an active object from " /*infostream<<"Server: Creating an active object from "
<<"static data"<<std::endl;*/ <<"static data"<<std::endl;*/
StaticObject &s_obj = *i; StaticObject &s_obj = *i;
// Create an active object from the data // Create an active object from the data
@ -1494,7 +1506,7 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
// This shouldn't happen but check it // This shouldn't happen but check it
if(obj == NULL) if(obj == NULL)
{ {
dstream<<"WARNING: NULL object found in ServerEnvironment" infostream<<"NULL object found in ServerEnvironment"
<<std::endl; <<std::endl;
assert(0); assert(0);
continue; continue;
@ -1553,7 +1565,7 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
obj->m_static_block = block->getPos(); obj->m_static_block = block->getPos();
} }
else{ else{
dstream<<"WARNING: ServerEnv: Could not find or generate " infostream<<"ServerEnv: Could not find or generate "
<<"a block for storing static object"<<std::endl; <<"a block for storing static object"<<std::endl;
obj->m_static_exists = false; obj->m_static_exists = false;
continue; continue;
@ -1571,7 +1583,7 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
continue; continue;
} }
/*dstream<<"INFO: Server: Stored static data. Deleting object." /*infostream<<"Server: Stored static data. Deleting object."
<<std::endl;*/ <<std::endl;*/
// Delete active object // Delete active object
delete obj; delete obj;
@ -1962,7 +1974,7 @@ u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
u16 new_id = getFreeClientActiveObjectId(m_active_objects); u16 new_id = getFreeClientActiveObjectId(m_active_objects);
if(new_id == 0) if(new_id == 0)
{ {
dstream<<"WARNING: ClientEnvironment::addActiveObject(): " infostream<<"ClientEnvironment::addActiveObject(): "
<<"no free ids available"<<std::endl; <<"no free ids available"<<std::endl;
delete object; delete object;
return 0; return 0;
@ -1971,12 +1983,12 @@ u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
} }
if(isFreeClientActiveObjectId(object->getId(), m_active_objects) == false) if(isFreeClientActiveObjectId(object->getId(), m_active_objects) == false)
{ {
dstream<<"WARNING: ClientEnvironment::addActiveObject(): " infostream<<"ClientEnvironment::addActiveObject(): "
<<"id is not free ("<<object->getId()<<")"<<std::endl; <<"id is not free ("<<object->getId()<<")"<<std::endl;
delete object; delete object;
return 0; return 0;
} }
dstream<<"INFO: ClientEnvironment::addActiveObject(): " infostream<<"ClientEnvironment::addActiveObject(): "
<<"added (id="<<object->getId()<<")"<<std::endl; <<"added (id="<<object->getId()<<")"<<std::endl;
m_active_objects.insert(object->getId(), object); m_active_objects.insert(object->getId(), object);
object->addToScene(m_smgr); object->addToScene(m_smgr);
@ -1989,7 +2001,7 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type,
ClientActiveObject* obj = ClientActiveObject::create(type); ClientActiveObject* obj = ClientActiveObject::create(type);
if(obj == NULL) if(obj == NULL)
{ {
dstream<<"WARNING: ClientEnvironment::addActiveObject(): " infostream<<"ClientEnvironment::addActiveObject(): "
<<"id="<<id<<" type="<<type<<": Couldn't create object" <<"id="<<id<<" type="<<type<<": Couldn't create object"
<<std::endl; <<std::endl;
return; return;
@ -2004,12 +2016,12 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type,
void ClientEnvironment::removeActiveObject(u16 id) void ClientEnvironment::removeActiveObject(u16 id)
{ {
dstream<<"ClientEnvironment::removeActiveObject(): " infostream<<"ClientEnvironment::removeActiveObject(): "
<<"id="<<id<<std::endl; <<"id="<<id<<std::endl;
ClientActiveObject* obj = getActiveObject(id); ClientActiveObject* obj = getActiveObject(id);
if(obj == NULL) if(obj == NULL)
{ {
dstream<<"WARNING: ClientEnvironment::removeActiveObject(): " infostream<<"ClientEnvironment::removeActiveObject(): "
<<"id="<<id<<" not found"<<std::endl; <<"id="<<id<<" not found"<<std::endl;
return; return;
} }
@ -2024,7 +2036,7 @@ void ClientEnvironment::processActiveObjectMessage(u16 id,
ClientActiveObject* obj = getActiveObject(id); ClientActiveObject* obj = getActiveObject(id);
if(obj == NULL) if(obj == NULL)
{ {
dstream<<"WARNING: ClientEnvironment::processActiveObjectMessage():" infostream<<"ClientEnvironment::processActiveObjectMessage():"
<<" got message for id="<<id<<", which doesn't exist." <<" got message for id="<<id<<", which doesn't exist."
<<std::endl; <<std::endl;
return; return;

View File

@ -41,6 +41,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "profiler.h" #include "profiler.h"
#include "mainmenumanager.h" #include "mainmenumanager.h"
#include "gettext.h" #include "gettext.h"
#include "log.h"
/* /*
TODO: Move content-aware stuff to separate file by adding properties TODO: Move content-aware stuff to separate file by adding properties
@ -122,7 +123,7 @@ struct TextDestSignNode : public TextDest
void gotText(std::wstring text) void gotText(std::wstring text)
{ {
std::string ntext = wide_to_narrow(text); std::string ntext = wide_to_narrow(text);
dstream<<"Changing text of a sign node: " infostream<<"Changing text of a sign node: "
<<ntext<<std::endl; <<ntext<<std::endl;
m_client->sendSignNodeText(m_p, ntext); m_client->sendSignNodeText(m_p, ntext);
} }
@ -161,7 +162,7 @@ void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font,
InventoryList *mainlist = inventory->getList("main"); InventoryList *mainlist = inventory->getList("main");
if(mainlist == NULL) if(mainlist == NULL)
{ {
dstream<<"WARNING: draw_hotbar(): mainlist == NULL"<<std::endl; errorstream<<"draw_hotbar(): mainlist == NULL"<<std::endl;
return; return;
} }
@ -299,7 +300,7 @@ void getPointedNode(Client *client, v3f player_position,
v3s16 pos_i = floatToInt(player_position, BS); v3s16 pos_i = floatToInt(player_position, BS);
/*dstream<<"pos_i=("<<pos_i.X<<","<<pos_i.Y<<","<<pos_i.Z<<")" /*infostream<<"pos_i=("<<pos_i.X<<","<<pos_i.Y<<","<<pos_i.Z<<")"
<<std::endl;*/ <<std::endl;*/
s16 a = d; s16 a = d;
@ -706,7 +707,7 @@ void the_game(
SharedPtr<Server> server; SharedPtr<Server> server;
if(address == ""){ if(address == ""){
draw_load_screen(L"Creating server...", driver, font); draw_load_screen(L"Creating server...", driver, font);
dstream<<DTIME<<"Creating server"<<std::endl; infostream<<"Creating server"<<std::endl;
server = new Server(map_dir, configpath); server = new Server(map_dir, configpath);
server->start(port); server->start(port);
} }
@ -716,7 +717,7 @@ void the_game(
*/ */
draw_load_screen(L"Creating client...", driver, font); draw_load_screen(L"Creating client...", driver, font);
dstream<<DTIME<<"Creating client"<<std::endl; infostream<<"Creating client"<<std::endl;
MapDrawControl draw_control; MapDrawControl draw_control;
Client client(device, playername.c_str(), password, draw_control); Client client(device, playername.c_str(), password, draw_control);
@ -731,7 +732,7 @@ void the_game(
} }
catch(ResolveError &e) catch(ResolveError &e)
{ {
dstream<<DTIME<<"Couldn't resolve address"<<std::endl; errorstream<<"Couldn't resolve address"<<std::endl;
//return 0; //return 0;
error_message = L"Couldn't resolve address"; error_message = L"Couldn't resolve address";
//gui_loadingtext->remove(); //gui_loadingtext->remove();
@ -742,9 +743,9 @@ void the_game(
Attempt to connect to the server Attempt to connect to the server
*/ */
dstream<<DTIME<<"Connecting to server at "; infostream<<"Connecting to server at ";
connect_address.print(&dstream); connect_address.print(&infostream);
dstream<<std::endl; infostream<<std::endl;
client.connect(connect_address); client.connect(connect_address);
bool could_connect = false; bool could_connect = false;
@ -800,12 +801,12 @@ void the_game(
{ {
error_message = L"Access denied. Reason: " error_message = L"Access denied. Reason: "
+client.accessDeniedReason(); +client.accessDeniedReason();
dstream<<DTIME<<wide_to_narrow(error_message)<<std::endl; errorstream<<wide_to_narrow(error_message)<<std::endl;
} }
else else
{ {
error_message = L"Connection timed out."; error_message = L"Connection timed out.";
dstream<<DTIME<<"Timed out."<<std::endl; errorstream<<"Timed out."<<std::endl;
} }
//gui_loadingtext->remove(); //gui_loadingtext->remove();
return; return;
@ -963,7 +964,7 @@ void the_game(
{ {
error_message = L"Access denied. Reason: " error_message = L"Access denied. Reason: "
+client.accessDeniedReason(); +client.accessDeniedReason();
dstream<<DTIME<<wide_to_narrow(error_message)<<std::endl; errorstream<<wide_to_narrow(error_message)<<std::endl;
break; break;
} }
@ -1029,7 +1030,7 @@ void the_game(
busytime = busytime_u32 / 1000.0; busytime = busytime_u32 / 1000.0;
} }
//dstream<<"busytime_u32="<<busytime_u32<<std::endl; //infostream<<"busytime_u32="<<busytime_u32<<std::endl;
// Necessary for device->getTimer()->getTime() // Necessary for device->getTimer()->getTime()
device->run(); device->run();
@ -1082,8 +1083,8 @@ void the_game(
Visualize frametime in terminal Visualize frametime in terminal
*/ */
/*for(u32 i=0; i<dtime*400; i++) /*for(u32 i=0; i<dtime*400; i++)
dstream<<"X"; infostream<<"X";
dstream<<std::endl;*/ infostream<<std::endl;*/
/* /*
Time average and jitter calculation Time average and jitter calculation
@ -1148,7 +1149,7 @@ void the_game(
if(counter < 0) if(counter < 0)
{ {
counter = 30.0; counter = 30.0;
client.printDebugInfo(dstream); client.printDebugInfo(infostream);
} }
} }
@ -1161,8 +1162,8 @@ void the_game(
{ {
if(m_profiler_interval.step(0.030, profiler_print_interval)) if(m_profiler_interval.step(0.030, profiler_print_interval))
{ {
dstream<<"Profiler:"<<std::endl; infostream<<"Profiler:"<<std::endl;
g_profiler->print(dstream); g_profiler->print(infostream);
g_profiler->clear(); g_profiler->clear();
} }
} }
@ -1185,7 +1186,7 @@ void the_game(
*/ */
if(input->wasKeyDown(getKeySetting("keymap_inventory"))) if(input->wasKeyDown(getKeySetting("keymap_inventory")))
{ {
dstream<<DTIME<<"the_game: " infostream<<"the_game: "
<<"Launching inventory"<<std::endl; <<"Launching inventory"<<std::endl;
GUIInventoryMenu *menu = GUIInventoryMenu *menu =
@ -1211,7 +1212,7 @@ void the_game(
} }
else if(input->wasKeyDown(EscapeKey)) else if(input->wasKeyDown(EscapeKey))
{ {
dstream<<DTIME<<"the_game: " infostream<<"the_game: "
<<"Launching pause menu"<<std::endl; <<"Launching pause menu"<<std::endl;
// It will delete itself by itself // It will delete itself by itself
(new GUIPauseMenu(guienv, guiroot, -1, g_gamecallback, (new GUIPauseMenu(guienv, guiroot, -1, g_gamecallback,
@ -1286,10 +1287,10 @@ void the_game(
if (driver->writeImageToFile(image, filename)) { if (driver->writeImageToFile(image, filename)) {
std::wstringstream sstr; std::wstringstream sstr;
sstr<<"Saved screenshot to '"<<filename<<"'"; sstr<<"Saved screenshot to '"<<filename<<"'";
dstream<<"Saved screenshot to '"<<filename<<"'"<<std::endl; infostream<<"Saved screenshot to '"<<filename<<"'"<<std::endl;
chat_lines.push_back(ChatLine(sstr.str())); chat_lines.push_back(ChatLine(sstr.str()));
} else{ } else{
dstream<<"Failed to save screenshot '"<<filename<<"'"<<std::endl; infostream<<"Failed to save screenshot '"<<filename<<"'"<<std::endl;
} }
image->drop(); image->drop();
} }
@ -1327,7 +1328,7 @@ void the_game(
{ {
g_selected_item = i; g_selected_item = i;
dstream<<DTIME<<"Selected item: " infostream<<"Selected item: "
<<g_selected_item<<std::endl; <<g_selected_item<<std::endl;
} }
} }
@ -1339,12 +1340,12 @@ void the_game(
if(draw_control.range_all) if(draw_control.range_all)
{ {
draw_control.range_all = false; draw_control.range_all = false;
dstream<<DTIME<<"Disabled full viewing range"<<std::endl; infostream<<"Disabled full viewing range"<<std::endl;
} }
else else
{ {
draw_control.range_all = true; draw_control.range_all = true;
dstream<<DTIME<<"Enabled full viewing range"<<std::endl; infostream<<"Enabled full viewing range"<<std::endl;
} }
} }
@ -1374,7 +1375,7 @@ void the_game(
} }
if(first_loop_after_window_activation){ if(first_loop_after_window_activation){
//dstream<<"window active, first loop"<<std::endl; //infostream<<"window active, first loop"<<std::endl;
first_loop_after_window_activation = false; first_loop_after_window_activation = false;
} }
else{ else{
@ -1382,7 +1383,7 @@ void the_game(
s32 dy = input->getMousePos().Y - displaycenter.Y; s32 dy = input->getMousePos().Y - displaycenter.Y;
if(invert_mouse) if(invert_mouse)
dy = -dy; dy = -dy;
//dstream<<"window active, pos difference "<<dx<<","<<dy<<std::endl; //infostream<<"window active, pos difference "<<dx<<","<<dy<<std::endl;
/*const float keyspeed = 500; /*const float keyspeed = 500;
if(input->isKeyDown(irr::KEY_UP)) if(input->isKeyDown(irr::KEY_UP))
@ -1406,7 +1407,7 @@ void the_game(
if(device->getCursorControl()->isVisible() == false) if(device->getCursorControl()->isVisible() == false)
device->getCursorControl()->setVisible(true); device->getCursorControl()->setVisible(true);
//dstream<<"window inactive"<<std::endl; //infostream<<"window inactive"<<std::endl;
first_loop_after_window_activation = true; first_loop_after_window_activation = true;
} }
@ -1486,7 +1487,7 @@ void the_game(
else if(event.type == CE_PLAYER_DAMAGE) else if(event.type == CE_PLAYER_DAMAGE)
{ {
//u16 damage = event.player_damage.amount; //u16 damage = event.player_damage.amount;
//dstream<<"Player damage: "<<damage<<std::endl; //infostream<<"Player damage: "<<damage<<std::endl;
damage_flash_timer = 0.05; damage_flash_timer = 0.05;
if(event.player_damage.amount >= 2){ if(event.player_damage.amount >= 2){
damage_flash_timer += 0.05 * event.player_damage.amount; damage_flash_timer += 0.05 * event.player_damage.amount;
@ -1575,7 +1576,7 @@ void the_game(
nodepos_old = v3s16(-32768,-32768,-32768); nodepos_old = v3s16(-32768,-32768,-32768);
} }
//dstream<<"Client returned selected_active_object != NULL"<<std::endl; //infostream<<"Client returned selected_active_object != NULL"<<std::endl;
core::aabbox3d<f32> *selection_box core::aabbox3d<f32> *selection_box
= selected_active_object->getSelectionBox(); = selected_active_object->getSelectionBox();
@ -1610,7 +1611,7 @@ void the_game(
do_punch = true; do_punch = true;
} }
if(do_punch){ if(do_punch){
dstream<<DTIME<<"Left-clicked object"<<std::endl; infostream<<"Left-clicked object"<<std::endl;
left_punch = true; left_punch = true;
} }
if(do_punch_damage){ if(do_punch_damage){
@ -1620,7 +1621,7 @@ void the_game(
} }
else if(input->getRightClicked()) else if(input->getRightClicked())
{ {
dstream<<DTIME<<"Right-clicked object"<<std::endl; infostream<<"Right-clicked object"<<std::endl;
client.clickActiveObject(1, client.clickActiveObject(1,
selected_active_object->getId(), g_selected_item); selected_active_object->getId(), g_selected_item);
} }
@ -1687,7 +1688,7 @@ void the_game(
{ {
if(nodepos != nodepos_old) if(nodepos != nodepos_old)
{ {
dstream<<DTIME<<"Pointing at ("<<nodepos.X<<"," infostream<<"Pointing at ("<<nodepos.X<<","
<<nodepos.Y<<","<<nodepos.Z<<")"<<std::endl; <<nodepos.Y<<","<<nodepos.Z<<")"<<std::endl;
if(nodepos_old != v3s16(-32768,-32768,-32768)) if(nodepos_old != v3s16(-32768,-32768,-32768))
@ -1701,7 +1702,7 @@ void the_game(
if(input->getLeftClicked() || if(input->getLeftClicked() ||
(input->getLeftState() && nodepos != nodepos_old)) (input->getLeftState() && nodepos != nodepos_old))
{ {
dstream<<DTIME<<"Started digging"<<std::endl; infostream<<"Started digging"<<std::endl;
client.groundAction(0, nodepos, neighbourpos, g_selected_item); client.groundAction(0, nodepos, neighbourpos, g_selected_item);
} }
if(input->getLeftClicked()) if(input->getLeftClicked())
@ -1734,7 +1735,7 @@ void the_game(
if(prop.diggable == false) if(prop.diggable == false)
{ {
/*dstream<<"Material "<<(int)material /*infostream<<"Material "<<(int)material
<<" not diggable with \"" <<" not diggable with \""
<<toolname<<"\""<<std::endl;*/ <<toolname<<"\""<<std::endl;*/
// I guess nobody will wait for this long // I guess nobody will wait for this long
@ -1759,12 +1760,12 @@ void the_game(
if(dig_index < CRACK_ANIMATION_LENGTH) if(dig_index < CRACK_ANIMATION_LENGTH)
{ {
//TimeTaker timer("client.setTempMod"); //TimeTaker timer("client.setTempMod");
//dstream<<"dig_index="<<dig_index<<std::endl; //infostream<<"dig_index="<<dig_index<<std::endl;
client.setTempMod(nodepos, NodeMod(NODEMOD_CRACK, dig_index)); client.setTempMod(nodepos, NodeMod(NODEMOD_CRACK, dig_index));
} }
else else
{ {
dstream<<DTIME<<"Digging completed"<<std::endl; infostream<<"Digging completed"<<std::endl;
client.groundAction(3, nodepos, neighbourpos, g_selected_item); client.groundAction(3, nodepos, neighbourpos, g_selected_item);
client.clearTempMod(nodepos); client.clearTempMod(nodepos);
client.removeNode(nodepos); client.removeNode(nodepos);
@ -1798,12 +1799,12 @@ void the_game(
if(input->getRightClicked()) if(input->getRightClicked())
{ {
dstream<<DTIME<<"Ground right-clicked"<<std::endl; infostream<<"Ground right-clicked"<<std::endl;
// If metadata provides an inventory view, activate it // If metadata provides an inventory view, activate it
if(meta && meta->getInventoryDrawSpecString() != "" && !random_input) if(meta && meta->getInventoryDrawSpecString() != "" && !random_input)
{ {
dstream<<DTIME<<"Launching custom inventory view"<<std::endl; infostream<<"Launching custom inventory view"<<std::endl;
/* /*
Construct the unique identification string of the node Construct the unique identification string of the node
*/ */
@ -1836,7 +1837,7 @@ void the_game(
} }
else if(meta && meta->typeId() == CONTENT_SIGN_WALL && !random_input) else if(meta && meta->typeId() == CONTENT_SIGN_WALL && !random_input)
{ {
dstream<<"Sign node right-clicked"<<std::endl; infostream<<"Sign node right-clicked"<<std::endl;
SignNodeMetadata *signmeta = (SignNodeMetadata*)meta; SignNodeMetadata *signmeta = (SignNodeMetadata*)meta;
@ -1873,13 +1874,13 @@ void the_game(
if(input->getLeftReleased()) if(input->getLeftReleased())
{ {
dstream<<DTIME<<"Left button released (stopped digging)" infostream<<"Left button released (stopped digging)"
<<std::endl; <<std::endl;
client.groundAction(2, v3s16(0,0,0), v3s16(0,0,0), 0); client.groundAction(2, v3s16(0,0,0), v3s16(0,0,0), 0);
} }
if(input->getRightReleased()) if(input->getRightReleased())
{ {
//dstream<<DTIME<<"Right released"<<std::endl; //inostream<<DTIME<<"Right released"<<std::endl;
// Nothing here // Nothing here
} }
@ -2124,7 +2125,7 @@ void the_game(
{ {
client.selectPlayerItem(g_selected_item); client.selectPlayerItem(g_selected_item);
old_selected_item = g_selected_item; old_selected_item = g_selected_item;
//dstream<<"Updating local inventory"<<std::endl; //infostream<<"Updating local inventory"<<std::endl;
client.getLocalInventory(local_inventory); client.getLocalInventory(local_inventory);
// Update wielded tool // Update wielded tool
@ -2163,7 +2164,7 @@ void the_game(
//timer3.stop(); //timer3.stop();
//dstream<<DTIME<<"smgr->drawAll()"<<std::endl; //infostream<<"smgr->drawAll()"<<std::endl;
{ {
TimeTaker timer("smgr"); TimeTaker timer("smgr");
@ -2189,7 +2190,7 @@ void the_game(
for(core::list< core::aabbox3d<f32> >::Iterator i=hilightboxes.begin(); for(core::list< core::aabbox3d<f32> >::Iterator i=hilightboxes.begin();
i != hilightboxes.end(); i++) i != hilightboxes.end(); i++)
{ {
/*dstream<<"hilightbox min=" /*infostream<<"hilightbox min="
<<"("<<i->MinEdge.X<<","<<i->MinEdge.Y<<","<<i->MinEdge.Z<<")" <<"("<<i->MinEdge.X<<","<<i->MinEdge.Y<<","<<i->MinEdge.Z<<")"
<<" max=" <<" max="
<<"("<<i->MaxEdge.X<<","<<i->MaxEdge.Y<<","<<i->MaxEdge.Z<<")" <<"("<<i->MaxEdge.X<<","<<i->MaxEdge.Y<<","<<i->MaxEdge.Z<<")"

View File

@ -438,6 +438,7 @@ Doing currently:
#include "gettext.h" #include "gettext.h"
#include "settings.h" #include "settings.h"
#include "profiler.h" #include "profiler.h"
#include "log.h"
// This makes textures // This makes textures
ITextureSource *g_texturesource = NULL; ITextureSource *g_texturesource = NULL;
@ -479,19 +480,15 @@ MainGameCallback *g_gamecallback = NULL;
// Connection // Connection
std::ostream *dout_con_ptr = &dummyout; std::ostream *dout_con_ptr = &dummyout;
std::ostream *derr_con_ptr = &dstream_no_stderr; std::ostream *derr_con_ptr = &verbosestream;
//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;
// Server // Server
std::ostream *dout_server_ptr = &dstream; std::ostream *dout_server_ptr = &infostream;
std::ostream *derr_server_ptr = &dstream; std::ostream *derr_server_ptr = &errorstream;
// Client // Client
std::ostream *dout_client_ptr = &dstream; std::ostream *dout_client_ptr = &infostream;
std::ostream *derr_client_ptr = &dstream; std::ostream *derr_client_ptr = &errorstream;
/* /*
gettime.h implementation gettime.h implementation
@ -583,7 +580,6 @@ public:
} }
else else
{ {
//dstream<<"MyEventReceiver: mouse input"<<std::endl;
left_active = event.MouseInput.isLeftPressed(); left_active = event.MouseInput.isLeftPressed();
middle_active = event.MouseInput.isMiddlePressed(); middle_active = event.MouseInput.isMiddlePressed();
right_active = event.MouseInput.isRightPressed(); right_active = event.MouseInput.isRightPressed();
@ -1026,7 +1022,7 @@ void SpeedTests()
u32 dtime = timer.stop(); u32 dtime = timer.stop();
u32 per_ms = n / dtime; u32 per_ms = n / dtime;
std::cout<<"Done. "<<dtime<<"ms, " dstream<<"Done. "<<dtime<<"ms, "
<<per_ms<<"/ms"<<std::endl; <<per_ms<<"/ms"<<std::endl;
} }
} }
@ -1078,12 +1074,37 @@ void drawMenuBackground(video::IVideoDriver* driver)
} }
} }
class DstreamLogOutput: public ILogOutput
{
public:
/* line: Full line with timestamp, level and thread */
void printLog(const std::string &line)
{
dstream<<line<<std::endl;
}
} main_dstream_log_out;
class DstreamNoStderrLogOutput: public ILogOutput
{
public:
/* line: Full line with timestamp, level and thread */
void printLog(const std::string &line)
{
dstream_no_stderr<<line<<std::endl;
}
} main_dstream_no_stderr_log_out;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
/* /*
Initialization Initialization
*/ */
log_add_output_maxlev(&main_dstream_log_out, LMT_ACTION);
log_add_output_all_levs(&main_dstream_no_stderr_log_out);
log_register_thread("main");
// Set locale. This is for forcing '.' as the decimal point. // Set locale. This is for forcing '.' as the decimal point.
std::locale::global(std::locale("C")); std::locale::global(std::locale("C"));
// This enables printing all characters in bitmap font // This enables printing all characters in bitmap font
@ -1110,6 +1131,7 @@ int main(int argc, char *argv[])
allowed_options.insert("dstream-on-stderr", ValueSpec(VALUETYPE_FLAG)); allowed_options.insert("dstream-on-stderr", ValueSpec(VALUETYPE_FLAG));
#endif #endif
allowed_options.insert("speedtests", ValueSpec(VALUETYPE_FLAG)); allowed_options.insert("speedtests", ValueSpec(VALUETYPE_FLAG));
allowed_options.insert("info-on-stderr", ValueSpec(VALUETYPE_FLAG));
Settings cmd_args; Settings cmd_args;
@ -1151,6 +1173,9 @@ int main(int argc, char *argv[])
if(cmd_args.getFlag("dstream-on-stderr") == false) if(cmd_args.getFlag("dstream-on-stderr") == false)
disable_stderr = true; disable_stderr = true;
#endif #endif
if(cmd_args.getFlag("info-on-stderr"))
log_add_output(&main_dstream_log_out, LMT_INFO);
porting::signal_handler_init(); porting::signal_handler_init();
bool &kill = *porting::signal_handler_killstatus(); bool &kill = *porting::signal_handler_killstatus();
@ -1182,7 +1207,7 @@ int main(int argc, char *argv[])
BEGIN_DEBUG_EXCEPTION_HANDLER BEGIN_DEBUG_EXCEPTION_HANDLER
// Print startup message // Print startup message
dstream<<DTIME<<PROJECT_NAME actionstream<<PROJECT_NAME<<
" with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST " with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST
<<", "<<BUILD_INFO <<", "<<BUILD_INFO
<<std::endl; <<std::endl;
@ -1210,7 +1235,7 @@ int main(int argc, char *argv[])
bool r = g_settings->readConfigFile(cmd_args.get("config").c_str()); bool r = g_settings->readConfigFile(cmd_args.get("config").c_str());
if(r == false) if(r == false)
{ {
dstream<<"Could not read configuration from \"" errorstream<<"Could not read configuration from \""
<<cmd_args.get("config")<<"\""<<std::endl; <<cmd_args.get("config")<<"\""<<std::endl;
return 1; return 1;
} }
@ -1356,7 +1381,7 @@ int main(int argc, char *argv[])
driverType = video::EDT_OPENGL; driverType = video::EDT_OPENGL;
else else
{ {
dstream<<"WARNING: Invalid video_driver specified; defaulting " errorstream<<"WARNING: Invalid video_driver specified; defaulting "
"to opengl"<<std::endl; "to opengl"<<std::endl;
driverType = video::EDT_OPENGL; driverType = video::EDT_OPENGL;
} }
@ -1427,14 +1452,14 @@ int main(int argc, char *argv[])
if(font) if(font)
skin->setFont(font); skin->setFont(font);
else else
dstream<<"WARNING: Font file was not found." errorstream<<"WARNING: Font file was not found."
" Using default font."<<std::endl; " Using default font."<<std::endl;
// If font was not found, this will get us one // If font was not found, this will get us one
font = skin->getFont(); font = skin->getFont();
assert(font); assert(font);
u32 text_height = font->getDimension(L"Hello, world!").Height; u32 text_height = font->getDimension(L"Hello, world!").Height;
dstream<<"text_height="<<text_height<<std::endl; infostream<<"text_height="<<text_height<<std::endl;
//skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255,0,0,0)); //skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255,0,0,0));
skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255,255,255,255)); skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255,255,255,255));
@ -1522,7 +1547,7 @@ int main(int argc, char *argv[])
if(error_message != L"") if(error_message != L"")
{ {
dstream<<"WARNING: error_message = " errorstream<<"error_message = "
<<wide_to_narrow(error_message)<<std::endl; <<wide_to_narrow(error_message)<<std::endl;
GUIMessageMenu *menu2 = GUIMessageMenu *menu2 =
@ -1534,7 +1559,7 @@ int main(int argc, char *argv[])
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
dstream<<"Created main menu"<<std::endl; infostream<<"Created main menu"<<std::endl;
while(device->run() && kill == false) while(device->run() && kill == false)
{ {
@ -1559,7 +1584,7 @@ int main(int argc, char *argv[])
if(device->run() == false || kill == true) if(device->run() == false || kill == true)
break; break;
dstream<<"Dropping main menu"<<std::endl; infostream<<"Dropping main menu"<<std::endl;
menu->drop(); menu->drop();
@ -1576,7 +1601,7 @@ int main(int argc, char *argv[])
password = translatePassword(playername, menudata.password); password = translatePassword(playername, menudata.password);
//dstream<<"Main: password hash: '"<<password<<"'"<<std::endl; //infostream<<"Main: password hash: '"<<password<<"'"<<std::endl;
address = wide_to_narrow(menudata.address); address = wide_to_narrow(menudata.address);
int newport = stoi(wide_to_narrow(menudata.port)); int newport = stoi(wide_to_narrow(menudata.port));
@ -1643,12 +1668,12 @@ int main(int argc, char *argv[])
} //try } //try
catch(con::PeerNotFoundException &e) catch(con::PeerNotFoundException &e)
{ {
dstream<<DTIME<<"Connection error (timed out?)"<<std::endl; errorstream<<"Connection error (timed out?)"<<std::endl;
error_message = L"Connection error (timed out?)"; error_message = L"Connection error (timed out?)";
} }
catch(SocketException &e) catch(SocketException &e)
{ {
dstream<<DTIME<<"Socket error (port already in use?)"<<std::endl; errorstream<<"Socket error (port already in use?)"<<std::endl;
error_message = L"Socket error (port already in use?)"; error_message = L"Socket error (port already in use?)";
} }
#ifdef NDEBUG #ifdef NDEBUG
@ -1657,7 +1682,7 @@ int main(int argc, char *argv[])
std::string narrow_message = "Some exception, what()=\""; std::string narrow_message = "Some exception, what()=\"";
narrow_message += e.what(); narrow_message += e.what();
narrow_message += "\""; narrow_message += "\"";
dstream<<DTIME<<narrow_message<<std::endl; errorstream<<narrow_message<<std::endl;
error_message = narrow_to_wide(narrow_message); error_message = narrow_to_wide(narrow_message);
} }
#endif #endif
@ -1671,7 +1696,7 @@ int main(int argc, char *argv[])
*/ */
device->drop(); device->drop();
END_DEBUG_EXCEPTION_HANDLER END_DEBUG_EXCEPTION_HANDLER(errorstream)
debugstreams_deinit(); debugstreams_deinit();

View File

@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IMaterialRenderer.h> #include <IMaterialRenderer.h>
#endif #endif
#include "settings.h" #include "settings.h"
#include "log.h"
/* /*
SQLite format specification: SQLite format specification:
@ -346,7 +347,7 @@ void Map::unspreadLight(enum LightBank bank,
*/ */
/*if(light_sources.find(n2pos)) /*if(light_sources.find(n2pos))
{ {
std::cout<<"Removed from light_sources"<<std::endl; infostream<<"Removed from light_sources"<<std::endl;
light_sources.remove(n2pos); light_sources.remove(n2pos);
}*/ }*/
} }
@ -377,7 +378,7 @@ void Map::unspreadLight(enum LightBank bank,
} }
} }
/*dstream<<"unspreadLight(): Changed block " /*infostream<<"unspreadLight(): Changed block "
<<blockchangecount<<" times" <<blockchangecount<<" times"
<<" for "<<from_nodes.size()<<" nodes" <<" for "<<from_nodes.size()<<" nodes"
<<std::endl;*/ <<std::endl;*/
@ -439,7 +440,7 @@ void Map::spreadLight(enum LightBank bank,
{ {
v3s16 pos = j.getNode()->getKey(); v3s16 pos = j.getNode()->getKey();
//v3s16 pos = *j; //v3s16 pos = *j;
//dstream<<"pos=("<<pos.X<<","<<pos.Y<<","<<pos.Z<<")"<<std::endl; //infostream<<"pos=("<<pos.X<<","<<pos.Y<<","<<pos.Z<<")"<<std::endl;
v3s16 blockpos = getNodeBlockPos(pos); v3s16 blockpos = getNodeBlockPos(pos);
// Only fetch a new block if the block position has changed // Only fetch a new block if the block position has changed
@ -544,7 +545,7 @@ void Map::spreadLight(enum LightBank bank,
} }
} }
/*dstream<<"spreadLight(): Changed block " /*infostream<<"spreadLight(): Changed block "
<<blockchangecount<<" times" <<blockchangecount<<" times"
<<" for "<<from_nodes.size()<<" nodes" <<" for "<<from_nodes.size()<<" nodes"
<<std::endl;*/ <<std::endl;*/
@ -728,7 +729,7 @@ void Map::updateLighting(enum LightBank bank,
dummy block. dummy block.
*/ */
//assert(0); //assert(0);
dstream<<"updateLighting(): InvalidPositionException" infostream<<"updateLighting(): InvalidPositionException"
<<std::endl; <<std::endl;
} }
} }
@ -752,7 +753,7 @@ void Map::updateLighting(enum LightBank bank,
assert(0); assert(0);
} }
/*dstream<<"Bottom for sunlight-propagated block (" /*infostream<<"Bottom for sunlight-propagated block ("
<<pos.X<<","<<pos.Y<<","<<pos.Z<<") not valid" <<pos.X<<","<<pos.Y<<","<<pos.Z<<") not valid"
<<std::endl;*/ <<std::endl;*/
@ -799,7 +800,7 @@ void Map::updateLighting(enum LightBank bank,
{ {
u32 diff = modified_blocks.size() - count_was; u32 diff = modified_blocks.size() - count_was;
count_was = modified_blocks.size(); count_was = modified_blocks.size();
dstream<<"unspreadLight modified "<<diff<<std::endl; infostream<<"unspreadLight modified "<<diff<<std::endl;
} }
{ {
@ -811,7 +812,7 @@ void Map::updateLighting(enum LightBank bank,
{ {
u32 diff = modified_blocks.size() - count_was; u32 diff = modified_blocks.size() - count_was;
count_was = modified_blocks.size(); count_was = modified_blocks.size();
dstream<<"spreadLight modified "<<diff<<std::endl; infostream<<"spreadLight modified "<<diff<<std::endl;
} }
#endif #endif
@ -867,7 +868,7 @@ void Map::updateLighting(enum LightBank bank,
//TimeTaker timer("blitBack"); //TimeTaker timer("blitBack");
vmanip.blitBack(modified_blocks); vmanip.blitBack(modified_blocks);
} }
/*dstream<<"emerge_time="<<emerge_time<<std::endl; /*infostream<<"emerge_time="<<emerge_time<<std::endl;
emerge_time = 0;*/ emerge_time = 0;*/
} }
@ -1471,12 +1472,12 @@ void Map::timerUpdate(float dtime, float unload_timeout,
if(deleted_blocks_count != 0) if(deleted_blocks_count != 0)
{ {
PrintInfo(dstream); // ServerMap/ClientMap: PrintInfo(infostream); // ServerMap/ClientMap:
dstream<<"Unloaded "<<deleted_blocks_count infostream<<"Unloaded "<<deleted_blocks_count
<<" blocks from memory"; <<" blocks from memory";
if(save_before_unloading) if(save_before_unloading)
dstream<<", of which "<<saved_blocks_count<<" were written"; infostream<<", of which "<<saved_blocks_count<<" were written";
dstream<<"."<<std::endl; infostream<<"."<<std::endl;
} }
} }
@ -1543,7 +1544,7 @@ void Map::unloadUnusedData(float timeout,
deleteSectors(sector_deletion_queue); deleteSectors(sector_deletion_queue);
dstream<<"Map: Unloaded "<<deleted_blocks_count<<" blocks from memory" infostream<<"Map: Unloaded "<<deleted_blocks_count<<" blocks from memory"
<<", of which "<<saved_blocks_count<<" were wr." <<", of which "<<saved_blocks_count<<" were wr."
<<std::endl; <<std::endl;
@ -1579,7 +1580,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
u32 initial_size = m_transforming_liquid.size(); u32 initial_size = m_transforming_liquid.size();
/*if(initial_size != 0) /*if(initial_size != 0)
dstream<<"transformLiquids(): initial_size="<<initial_size<<std::endl;*/ infostream<<"transformLiquids(): initial_size="<<initial_size<<std::endl;*/
// list of nodes that due to viscosity have not reached their max level height // list of nodes that due to viscosity have not reached their max level height
UniqueQueue<v3s16> must_reflow; UniqueQueue<v3s16> must_reflow;
@ -1807,7 +1808,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
break; break;
} }
} }
//dstream<<"Map::transformLiquids(): loopcount="<<loopcount<<std::endl; //infostream<<"Map::transformLiquids(): loopcount="<<loopcount<<std::endl;
while (must_reflow.size() > 0) while (must_reflow.size() > 0)
m_transforming_liquid.push_back(must_reflow.pop_front()); m_transforming_liquid.push_back(must_reflow.pop_front());
updateLighting(lighting_modified_blocks, modified_blocks); updateLighting(lighting_modified_blocks, modified_blocks);
@ -1820,7 +1821,7 @@ NodeMetadata* Map::getNodeMetadata(v3s16 p)
MapBlock *block = getBlockNoCreateNoEx(blockpos); MapBlock *block = getBlockNoCreateNoEx(blockpos);
if(block == NULL) if(block == NULL)
{ {
dstream<<"WARNING: Map::setNodeMetadata(): Block not found" infostream<<"WARNING: Map::setNodeMetadata(): Block not found"
<<std::endl; <<std::endl;
return NULL; return NULL;
} }
@ -1835,7 +1836,7 @@ void Map::setNodeMetadata(v3s16 p, NodeMetadata *meta)
MapBlock *block = getBlockNoCreateNoEx(blockpos); MapBlock *block = getBlockNoCreateNoEx(blockpos);
if(block == NULL) if(block == NULL)
{ {
dstream<<"WARNING: Map::setNodeMetadata(): Block not found" infostream<<"WARNING: Map::setNodeMetadata(): Block not found"
<<std::endl; <<std::endl;
return; return;
} }
@ -1849,7 +1850,7 @@ void Map::removeNodeMetadata(v3s16 p)
MapBlock *block = getBlockNoCreateNoEx(blockpos); MapBlock *block = getBlockNoCreateNoEx(blockpos);
if(block == NULL) if(block == NULL)
{ {
dstream<<"WARNING: Map::removeNodeMetadata(): Block not found" infostream<<"WARNING: Map::removeNodeMetadata(): Block not found"
<<std::endl; <<std::endl;
return; return;
} }
@ -1897,7 +1898,7 @@ ServerMap::ServerMap(std::string savedir):
m_database_read(NULL), m_database_read(NULL),
m_database_write(NULL) m_database_write(NULL)
{ {
dstream<<__FUNCTION_NAME<<std::endl; infostream<<__FUNCTION_NAME<<std::endl;
//m_chunksize = 8; // Takes a few seconds //m_chunksize = 8; // Takes a few seconds
@ -1935,7 +1936,7 @@ ServerMap::ServerMap(std::string savedir):
// If directory is empty, it is safe to save into it. // If directory is empty, it is safe to save into it.
if(fs::GetDirListing(m_savedir).size() == 0) if(fs::GetDirListing(m_savedir).size() == 0)
{ {
dstream<<DTIME<<"Server: Empty save directory is valid." infostream<<"Server: Empty save directory is valid."
<<std::endl; <<std::endl;
m_map_saving_enabled = true; m_map_saving_enabled = true;
} }
@ -1946,7 +1947,7 @@ ServerMap::ServerMap(std::string savedir):
loadMapMeta(); loadMapMeta();
} }
catch(FileNotGoodException &e){ catch(FileNotGoodException &e){
dstream<<DTIME<<"WARNING: Could not load map metadata" infostream<<"WARNING: Could not load map metadata"
//<<" Disabling chunk-based generator." //<<" Disabling chunk-based generator."
<<std::endl; <<std::endl;
//m_chunksize = 0; //m_chunksize = 0;
@ -1957,18 +1958,18 @@ ServerMap::ServerMap(std::string savedir):
loadChunkMeta(); loadChunkMeta();
} }
catch(FileNotGoodException &e){ catch(FileNotGoodException &e){
dstream<<DTIME<<"WARNING: Could not load chunk metadata." infostream<<"WARNING: Could not load chunk metadata."
<<" Disabling chunk-based generator." <<" Disabling chunk-based generator."
<<std::endl; <<std::endl;
m_chunksize = 0; m_chunksize = 0;
}*/ }*/
/*dstream<<DTIME<<"Server: Successfully loaded chunk " /*infostream<<"Server: Successfully loaded chunk "
"metadata and sector (0,0) from "<<savedir<< "metadata and sector (0,0) from "<<savedir<<
", assuming valid save directory." ", assuming valid save directory."
<<std::endl;*/ <<std::endl;*/
dstream<<DTIME<<"INFO: Server: Successfully loaded map " infostream<<"Server: Successfully loaded map "
<<"and chunk metadata from "<<savedir <<"and chunk metadata from "<<savedir
<<", assuming valid save directory." <<", assuming valid save directory."
<<std::endl; <<std::endl;
@ -1985,13 +1986,13 @@ ServerMap::ServerMap(std::string savedir):
} }
catch(std::exception &e) catch(std::exception &e)
{ {
dstream<<DTIME<<"WARNING: Server: Failed to load map from "<<savedir infostream<<"WARNING: Server: Failed to load map from "<<savedir
<<", exception: "<<e.what()<<std::endl; <<", exception: "<<e.what()<<std::endl;
dstream<<"Please remove the map or fix it."<<std::endl; infostream<<"Please remove the map or fix it."<<std::endl;
dstream<<"WARNING: Map saving will be disabled."<<std::endl; infostream<<"WARNING: Map saving will be disabled."<<std::endl;
} }
dstream<<DTIME<<"INFO: Initializing new map."<<std::endl; infostream<<"Initializing new map."<<std::endl;
// Create zero sector // Create zero sector
emergeSector(v2s16(0,0)); emergeSector(v2s16(0,0));
@ -2002,7 +2003,7 @@ ServerMap::ServerMap(std::string savedir):
ServerMap::~ServerMap() ServerMap::~ServerMap()
{ {
dstream<<__FUNCTION_NAME<<std::endl; infostream<<__FUNCTION_NAME<<std::endl;
try try
{ {
@ -2010,16 +2011,16 @@ ServerMap::~ServerMap()
{ {
// Save only changed parts // Save only changed parts
save(true); save(true);
dstream<<DTIME<<"Server: saved map to "<<m_savedir<<std::endl; infostream<<"Server: saved map to "<<m_savedir<<std::endl;
} }
else else
{ {
dstream<<DTIME<<"Server: map not saved"<<std::endl; infostream<<"Server: map not saved"<<std::endl;
} }
} }
catch(std::exception &e) catch(std::exception &e)
{ {
dstream<<DTIME<<"Server: Failed to save map to "<<m_savedir infostream<<"Server: Failed to save map to "<<m_savedir
<<", exception: "<<e.what()<<std::endl; <<", exception: "<<e.what()<<std::endl;
} }
@ -2050,7 +2051,7 @@ void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos)
{ {
bool enable_mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info"); bool enable_mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
if(enable_mapgen_debug_info) if(enable_mapgen_debug_info)
dstream<<"initBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<"," infostream<<"initBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<","
<<blockpos.Z<<")"<<std::endl; <<blockpos.Z<<")"<<std::endl;
// Do nothing if not inside limits (+-1 because of neighbors) // Do nothing if not inside limits (+-1 because of neighbors)
@ -2134,19 +2135,19 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
core::map<v3s16, MapBlock*> &changed_blocks) core::map<v3s16, MapBlock*> &changed_blocks)
{ {
v3s16 blockpos = data->blockpos; v3s16 blockpos = data->blockpos;
/*dstream<<"finishBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<"," /*infostream<<"finishBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<","
<<blockpos.Z<<")"<<std::endl;*/ <<blockpos.Z<<")"<<std::endl;*/
if(data->no_op) if(data->no_op)
{ {
//dstream<<"finishBlockMake(): no-op"<<std::endl; //infostream<<"finishBlockMake(): no-op"<<std::endl;
return NULL; return NULL;
} }
bool enable_mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info"); bool enable_mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
/*dstream<<"Resulting vmanip:"<<std::endl; /*infostream<<"Resulting vmanip:"<<std::endl;
data->vmanip.print(dstream);*/ data->vmanip.print(infostream);*/
/* /*
Blit generated stuff to map Blit generated stuff to map
@ -2159,7 +2160,7 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
} }
if(enable_mapgen_debug_info) if(enable_mapgen_debug_info)
dstream<<"finishBlockMake: changed_blocks.size()=" infostream<<"finishBlockMake: changed_blocks.size()="
<<changed_blocks.size()<<std::endl; <<changed_blocks.size()<<std::endl;
/* /*
@ -2300,7 +2301,7 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
*/ */
//save(true); //save(true);
/*dstream<<"finishBlockMake() done for ("<<blockpos.X<<","<<blockpos.Y<<"," /*infostream<<"finishBlockMake() done for ("<<blockpos.X<<","<<blockpos.Y<<","
<<blockpos.Z<<")"<<std::endl;*/ <<blockpos.Z<<")"<<std::endl;*/
#if 0 #if 0
if(enable_mapgen_debug_info) if(enable_mapgen_debug_info)
@ -2316,7 +2317,7 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
MapBlock *block = getBlockNoCreateNoEx(p); MapBlock *block = getBlockNoCreateNoEx(p);
char spos[20]; char spos[20];
snprintf(spos, 20, "(%2d,%2d,%2d)", x, y, z); snprintf(spos, 20, "(%2d,%2d,%2d)", x, y, z);
dstream<<"Generated "<<spos<<": " infostream<<"Generated "<<spos<<": "
<<analyze_block(block)<<std::endl; <<analyze_block(block)<<std::endl;
} }
} }
@ -2352,7 +2353,7 @@ ServerMapSector * ServerMap::createSector(v2s16 p2d)
ServerMapSector *sector = (ServerMapSector*)getSectorNoGenerateNoEx(p2d); ServerMapSector *sector = (ServerMapSector*)getSectorNoGenerateNoEx(p2d);
if(sector == NULL) if(sector == NULL)
{ {
dstream<<"ServerMap::createSector(): loadSectorFull didn't make a sector"<<std::endl; infostream<<"ServerMap::createSector(): loadSectorFull didn't make a sector"<<std::endl;
throw InvalidPositionException(""); throw InvalidPositionException("");
} }
return sector; return sector;
@ -2394,7 +2395,7 @@ MapBlock * ServerMap::generateBlock(
{ {
DSTACKF("%s: p=(%d,%d,%d)", __FUNCTION_NAME, p.X, p.Y, p.Z); DSTACKF("%s: p=(%d,%d,%d)", __FUNCTION_NAME, p.X, p.Y, p.Z);
/*dstream<<"generateBlock(): " /*infostream<<"generateBlock(): "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")" <<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;*/ <<std::endl;*/
@ -2412,7 +2413,7 @@ MapBlock * ServerMap::generateBlock(
*/ */
if(blockpos_over_limit(p)) if(blockpos_over_limit(p))
{ {
dstream<<__FUNCTION_NAME<<": Block position over limit"<<std::endl; infostream<<__FUNCTION_NAME<<": Block position over limit"<<std::endl;
throw InvalidPositionException("generateBlock(): pos. over limit"); throw InvalidPositionException("generateBlock(): pos. over limit");
} }
@ -2458,7 +2459,7 @@ MapBlock * ServerMap::generateBlock(
MapNode n = block->getNode(p); MapNode n = block->getNode(p);
if(n.getContent() == CONTENT_IGNORE) if(n.getContent() == CONTENT_IGNORE)
{ {
dstream<<"CONTENT_IGNORE at " infostream<<"CONTENT_IGNORE at "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")" <<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl; <<std::endl;
erroneus_content = true; erroneus_content = true;
@ -2532,7 +2533,7 @@ MapBlock * ServerMap::createBlock(v3s16 p)
} }
catch(InvalidPositionException &e) catch(InvalidPositionException &e)
{ {
dstream<<"createBlock: createSector() failed"<<std::endl; infostream<<"createBlock: createSector() failed"<<std::endl;
throw e; throw e;
} }
/* /*
@ -2542,7 +2543,7 @@ MapBlock * ServerMap::createBlock(v3s16 p)
*/ */
/*catch(std::exception &e) /*catch(std::exception &e)
{ {
dstream<<"createBlock: createSector() failed: " infostream<<"createBlock: createSector() failed: "
<<e.what()<<std::endl; <<e.what()<<std::endl;
throw e; throw e;
}*/ }*/
@ -2634,18 +2635,18 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool allow_generate)
} }
catch(InvalidPositionException &e) catch(InvalidPositionException &e)
{ {
dstream<<"emergeBlock: createSector() failed: " infostream<<"emergeBlock: createSector() failed: "
<<e.what()<<std::endl; <<e.what()<<std::endl;
dstream<<"Path to failed sector: "<<getSectorDir(p2d) infostream<<"Path to failed sector: "<<getSectorDir(p2d)
<<std::endl <<std::endl
<<"You could try to delete it."<<std::endl; <<"You could try to delete it."<<std::endl;
throw e; throw e;
} }
catch(VersionMismatchException &e) catch(VersionMismatchException &e)
{ {
dstream<<"emergeBlock: createSector() failed: " infostream<<"emergeBlock: createSector() failed: "
<<e.what()<<std::endl; <<e.what()<<std::endl;
dstream<<"Path to failed sector: "<<getSectorDir(p2d) infostream<<"Path to failed sector: "<<getSectorDir(p2d)
<<std::endl <<std::endl
<<"You could try to delete it."<<std::endl; <<"You could try to delete it."<<std::endl;
throw e; throw e;
@ -2681,7 +2682,7 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool allow_generate)
else else
{ {
// Valid block // Valid block
//dstream<<"emergeBlock(): Returning already valid block"<<std::endl; //infostream<<"emergeBlock(): Returning already valid block"<<std::endl;
return block; return block;
} }
@ -2691,7 +2692,7 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool allow_generate)
*/ */
if(only_from_disk && (does_not_exist || lighting_expired)) if(only_from_disk && (does_not_exist || lighting_expired))
{ {
//dstream<<"emergeBlock(): Was not on disk but not generating"<<std::endl; //infostream<<"emergeBlock(): Was not on disk but not generating"<<std::endl;
if(block == NULL) if(block == NULL)
{ {
@ -2705,11 +2706,11 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool allow_generate)
return block; return block;
} }
//dstream<<"Not found on disk, generating."<<std::endl; //infostream<<"Not found on disk, generating."<<std::endl;
// 0ms // 0ms
//TimeTaker("emergeBlock() generate"); //TimeTaker("emergeBlock() generate");
//dstream<<"emergeBlock(): Didn't find valid block -> making one"<<std::endl; //infostream<<"emergeBlock(): Didn't find valid block -> making one"<<std::endl;
/* /*
If the block doesn't exist, generate the block. If the block doesn't exist, generate the block.
@ -2811,7 +2812,7 @@ void ServerMap::createDatabase() {
if(e == SQLITE_ABORT) if(e == SQLITE_ABORT)
throw FileNotGoodException("Could not create database structure"); throw FileNotGoodException("Could not create database structure");
else else
dstream<<"Server: Database structure was created"; infostream<<"Server: Database structure was created";
} }
void ServerMap::verifyDatabase() { void ServerMap::verifyDatabase() {
@ -2834,7 +2835,7 @@ void ServerMap::verifyDatabase() {
d = sqlite3_open_v2(dbp.c_str(), &m_database, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); d = sqlite3_open_v2(dbp.c_str(), &m_database, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
if(d != SQLITE_OK) { if(d != SQLITE_OK) {
dstream<<"WARNING: Database failed to open: "<<sqlite3_errmsg(m_database)<<std::endl; infostream<<"WARNING: Database failed to open: "<<sqlite3_errmsg(m_database)<<std::endl;
throw FileNotGoodException("Cannot open database file"); throw FileNotGoodException("Cannot open database file");
} }
@ -2843,17 +2844,17 @@ void ServerMap::verifyDatabase() {
d = sqlite3_prepare(m_database, "SELECT `data` FROM `blocks` WHERE `pos`=? LIMIT 1", -1, &m_database_read, NULL); d = sqlite3_prepare(m_database, "SELECT `data` FROM `blocks` WHERE `pos`=? LIMIT 1", -1, &m_database_read, NULL);
if(d != SQLITE_OK) { if(d != SQLITE_OK) {
dstream<<"WARNING: Database read statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl; infostream<<"WARNING: Database read statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
throw FileNotGoodException("Cannot prepare read statement"); throw FileNotGoodException("Cannot prepare read statement");
} }
d = sqlite3_prepare(m_database, "REPLACE INTO `blocks` VALUES(?, ?)", -1, &m_database_write, NULL); d = sqlite3_prepare(m_database, "REPLACE INTO `blocks` VALUES(?, ?)", -1, &m_database_write, NULL);
if(d != SQLITE_OK) { if(d != SQLITE_OK) {
dstream<<"WARNING: Database write statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl; infostream<<"WARNING: Database write statment failed to prepare: "<<sqlite3_errmsg(m_database)<<std::endl;
throw FileNotGoodException("Cannot prepare write statement"); throw FileNotGoodException("Cannot prepare write statement");
} }
dstream<<"Server: Database opened"<<std::endl; infostream<<"Server: Database opened"<<std::endl;
} }
} }
@ -2954,12 +2955,12 @@ void ServerMap::save(bool only_changed)
DSTACK(__FUNCTION_NAME); DSTACK(__FUNCTION_NAME);
if(m_map_saving_enabled == false) if(m_map_saving_enabled == false)
{ {
dstream<<DTIME<<"WARNING: Not saving map, saving disabled."<<std::endl; infostream<<"WARNING: Not saving map, saving disabled."<<std::endl;
return; return;
} }
if(only_changed == false) if(only_changed == false)
dstream<<DTIME<<"ServerMap: Saving whole map, this can take time." infostream<<"ServerMap: Saving whole map, this can take time."
<<std::endl; <<std::endl;
if(only_changed == false || m_map_metadata_changed) if(only_changed == false || m_map_metadata_changed)
@ -3000,7 +3001,7 @@ void ServerMap::save(bool only_changed)
saveBlock(block); saveBlock(block);
block_count++; block_count++;
/*dstream<<"ServerMap: Written block (" /*infostream<<"ServerMap: Written block ("
<<block->getPos().X<<"," <<block->getPos().X<<","
<<block->getPos().Y<<"," <<block->getPos().Y<<","
<<block->getPos().Z<<")" <<block->getPos().Z<<")"
@ -3017,7 +3018,7 @@ void ServerMap::save(bool only_changed)
if(only_changed == false || sector_meta_count != 0 if(only_changed == false || sector_meta_count != 0
|| block_count != 0) || block_count != 0)
{ {
dstream<<DTIME<<"ServerMap: Written: " infostream<<"ServerMap: Written: "
<<sector_meta_count<<" sector metadata files, " <<sector_meta_count<<" sector metadata files, "
<<block_count<<" block files" <<block_count<<" block files"
<<", "<<block_count_all<<" blocks in memory." <<", "<<block_count_all<<" blocks in memory."
@ -3029,7 +3030,7 @@ void ServerMap::saveMapMeta()
{ {
DSTACK(__FUNCTION_NAME); DSTACK(__FUNCTION_NAME);
dstream<<"INFO: ServerMap::saveMapMeta(): " infostream<<"ServerMap::saveMapMeta(): "
<<"seed="<<m_seed <<"seed="<<m_seed
<<std::endl; <<std::endl;
@ -3039,7 +3040,7 @@ void ServerMap::saveMapMeta()
std::ofstream os(fullpath.c_str(), std::ios_base::binary); std::ofstream os(fullpath.c_str(), std::ios_base::binary);
if(os.good() == false) if(os.good() == false)
{ {
dstream<<"ERROR: ServerMap::saveMapMeta(): " infostream<<"ERROR: ServerMap::saveMapMeta(): "
<<"could not open"<<fullpath<<std::endl; <<"could not open"<<fullpath<<std::endl;
throw FileNotGoodException("Cannot open chunk metadata"); throw FileNotGoodException("Cannot open chunk metadata");
} }
@ -3058,14 +3059,14 @@ void ServerMap::loadMapMeta()
{ {
DSTACK(__FUNCTION_NAME); DSTACK(__FUNCTION_NAME);
dstream<<"INFO: ServerMap::loadMapMeta(): Loading map metadata" infostream<<"ServerMap::loadMapMeta(): Loading map metadata"
<<std::endl; <<std::endl;
std::string fullpath = m_savedir + "/map_meta.txt"; std::string fullpath = m_savedir + "/map_meta.txt";
std::ifstream is(fullpath.c_str(), std::ios_base::binary); std::ifstream is(fullpath.c_str(), std::ios_base::binary);
if(is.good() == false) if(is.good() == false)
{ {
dstream<<"ERROR: ServerMap::loadMapMeta(): " infostream<<"ERROR: ServerMap::loadMapMeta(): "
<<"could not open"<<fullpath<<std::endl; <<"could not open"<<fullpath<<std::endl;
throw FileNotGoodException("Cannot open map metadata"); throw FileNotGoodException("Cannot open map metadata");
} }
@ -3087,9 +3088,7 @@ void ServerMap::loadMapMeta()
m_seed = params.getU64("seed"); m_seed = params.getU64("seed");
dstream<<"INFO: ServerMap::loadMapMeta(): " infostream<<"ServerMap::loadMapMeta(): "<<"seed="<<m_seed<<std::endl;
<<"seed="<<m_seed
<<std::endl;
} }
void ServerMap::saveSectorMeta(ServerMapSector *sector) void ServerMap::saveSectorMeta(ServerMapSector *sector)
@ -3128,7 +3127,7 @@ MapSector* ServerMap::loadSectorMeta(std::string sectordir, bool save_after_load
// format. Just go ahead and create the sector. // format. Just go ahead and create the sector.
if(fs::PathExists(sectordir)) if(fs::PathExists(sectordir))
{ {
/*dstream<<"ServerMap::loadSectorMeta(): Sector metafile " /*infostream<<"ServerMap::loadSectorMeta(): Sector metafile "
<<fullpath<<" doesn't exist but directory does." <<fullpath<<" doesn't exist but directory does."
<<" Continuing with a sector with no metadata." <<" Continuing with a sector with no metadata."
<<std::endl;*/ <<std::endl;*/
@ -3259,7 +3258,7 @@ bool ServerMap::loadSectorFull(v2s16 p2d)
if(loadlayout != 2) if(loadlayout != 2)
{ {
dstream<<"Sector converted to new layout - deleting "<< infostream<<"Sector converted to new layout - deleting "<<
sectordir1<<std::endl; sectordir1<<std::endl;
fs::RecursiveDelete(sectordir1); fs::RecursiveDelete(sectordir1);
} }
@ -3271,13 +3270,13 @@ bool ServerMap::loadSectorFull(v2s16 p2d)
void ServerMap::beginSave() { void ServerMap::beginSave() {
verifyDatabase(); verifyDatabase();
if(sqlite3_exec(m_database, "BEGIN;", NULL, NULL, NULL) != SQLITE_OK) if(sqlite3_exec(m_database, "BEGIN;", NULL, NULL, NULL) != SQLITE_OK)
dstream<<"WARNING: beginSave() failed, saving might be slow."; infostream<<"WARNING: beginSave() failed, saving might be slow.";
} }
void ServerMap::endSave() { void ServerMap::endSave() {
verifyDatabase(); verifyDatabase();
if(sqlite3_exec(m_database, "COMMIT;", NULL, NULL, NULL) != SQLITE_OK) if(sqlite3_exec(m_database, "COMMIT;", NULL, NULL, NULL) != SQLITE_OK)
dstream<<"WARNING: endSave() failed, map might not have saved."; infostream<<"WARNING: endSave() failed, map might not have saved.";
} }
void ServerMap::saveBlock(MapBlock *block) void ServerMap::saveBlock(MapBlock *block)
@ -3289,7 +3288,7 @@ void ServerMap::saveBlock(MapBlock *block)
if(block->isDummy()) if(block->isDummy())
{ {
/*v3s16 p = block->getPos(); /*v3s16 p = block->getPos();
dstream<<"ServerMap::saveBlock(): WARNING: Not writing dummy block " infostream<<"ServerMap::saveBlock(): WARNING: Not writing dummy block "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"<<std::endl;*/ <<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"<<std::endl;*/
return; return;
} }
@ -3334,12 +3333,12 @@ void ServerMap::saveBlock(MapBlock *block)
const char *bytes = tmp.c_str(); const char *bytes = tmp.c_str();
if(sqlite3_bind_int64(m_database_write, 1, getBlockAsInteger(p3d)) != SQLITE_OK) if(sqlite3_bind_int64(m_database_write, 1, getBlockAsInteger(p3d)) != SQLITE_OK)
dstream<<"WARNING: Block position failed to bind: "<<sqlite3_errmsg(m_database)<<std::endl; infostream<<"WARNING: Block position failed to bind: "<<sqlite3_errmsg(m_database)<<std::endl;
if(sqlite3_bind_blob(m_database_write, 2, (void *)bytes, o.tellp(), NULL) != SQLITE_OK) // TODO this mught not be the right length if(sqlite3_bind_blob(m_database_write, 2, (void *)bytes, o.tellp(), NULL) != SQLITE_OK) // TODO this mught not be the right length
dstream<<"WARNING: Block data failed to bind: "<<sqlite3_errmsg(m_database)<<std::endl; infostream<<"WARNING: Block data failed to bind: "<<sqlite3_errmsg(m_database)<<std::endl;
int written = sqlite3_step(m_database_write); int written = sqlite3_step(m_database_write);
if(written != SQLITE_DONE) if(written != SQLITE_DONE)
dstream<<"WARNING: Block failed to save ("<<p3d.X<<", "<<p3d.Y<<", "<<p3d.Z<<") " infostream<<"WARNING: Block failed to save ("<<p3d.X<<", "<<p3d.Y<<", "<<p3d.Z<<") "
<<sqlite3_errmsg(m_database)<<std::endl; <<sqlite3_errmsg(m_database)<<std::endl;
// Make ready for later reuse // Make ready for later reuse
sqlite3_reset(m_database_write); sqlite3_reset(m_database_write);
@ -3415,7 +3414,7 @@ void ServerMap::loadBlock(std::string sectordir, std::string blockfile, MapSecto
} }
catch(SerializationError &e) catch(SerializationError &e)
{ {
dstream<<"WARNING: Invalid block data on disk " infostream<<"WARNING: Invalid block data on disk "
<<"fullpath="<<fullpath <<"fullpath="<<fullpath
<<" (SerializationError). " <<" (SerializationError). "
<<"what()="<<e.what() <<"what()="<<e.what()
@ -3482,7 +3481,7 @@ void ServerMap::loadBlock(std::string *blob, v3s16 p3d, MapSector *sector, bool
} }
catch(SerializationError &e) catch(SerializationError &e)
{ {
dstream<<"WARNING: Invalid block data in database " infostream<<"WARNING: Invalid block data in database "
<<" (SerializationError). " <<" (SerializationError). "
<<"what()="<<e.what() <<"what()="<<e.what()
<<std::endl; <<std::endl;
@ -3503,7 +3502,7 @@ MapBlock* ServerMap::loadBlock(v3s16 blockpos)
verifyDatabase(); verifyDatabase();
if(sqlite3_bind_int64(m_database_read, 1, getBlockAsInteger(blockpos)) != SQLITE_OK) if(sqlite3_bind_int64(m_database_read, 1, getBlockAsInteger(blockpos)) != SQLITE_OK)
dstream<<"WARNING: Could not bind block position for load: " infostream<<"WARNING: Could not bind block position for load: "
<<sqlite3_errmsg(m_database)<<std::endl; <<sqlite3_errmsg(m_database)<<std::endl;
if(sqlite3_step(m_database_read) == SQLITE_ROW) { if(sqlite3_step(m_database_read) == SQLITE_ROW) {
/* /*
@ -3769,7 +3768,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
int time2 = time(0); int time2 = time(0);
if(time2 > time1 + 4) if(time2 > time1 + 4)
{ {
dstream<<"ClientMap::renderMap(): " infostream<<"ClientMap::renderMap(): "
"Rendering takes ages, returning." "Rendering takes ages, returning."
<<std::endl; <<std::endl;
return; return;
@ -3931,7 +3930,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
m_control.blocks_drawn = blocks_drawn; m_control.blocks_drawn = blocks_drawn;
m_control.blocks_would_have_drawn = blocks_would_have_drawn; m_control.blocks_would_have_drawn = blocks_would_have_drawn;
/*dstream<<"renderMap(): is_transparent_pass="<<is_transparent_pass /*infostream<<"renderMap(): is_transparent_pass="<<is_transparent_pass
<<", rendered "<<vertex_count<<" vertices."<<std::endl;*/ <<", rendered "<<vertex_count<<" vertices."<<std::endl;*/
} }
@ -4181,7 +4180,7 @@ MapVoxelManipulator::MapVoxelManipulator(Map *map)
MapVoxelManipulator::~MapVoxelManipulator() MapVoxelManipulator::~MapVoxelManipulator()
{ {
/*dstream<<"MapVoxelManipulator: blocks: "<<m_loaded_blocks.size() /*infostream<<"MapVoxelManipulator: blocks: "<<m_loaded_blocks.size()
<<std::endl;*/ <<std::endl;*/
} }
@ -4213,11 +4212,11 @@ void MapVoxelManipulator::emerge(VoxelArea a, s32 caller_id)
{ {
TimeTaker timer1("emerge load", &emerge_load_time); TimeTaker timer1("emerge load", &emerge_load_time);
/*dstream<<"Loading block (caller_id="<<caller_id<<")" /*infostream<<"Loading block (caller_id="<<caller_id<<")"
<<" ("<<p.X<<","<<p.Y<<","<<p.Z<<")" <<" ("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<" wanted area: "; <<" wanted area: ";
a.print(dstream); a.print(infostream);
dstream<<std::endl;*/ infostream<<std::endl;*/
MapBlock *block = m_map->getBlockNoCreate(p); MapBlock *block = m_map->getBlockNoCreate(p);
if(block->isDummy()) if(block->isDummy())
@ -4245,7 +4244,7 @@ void MapVoxelManipulator::emerge(VoxelArea a, s32 caller_id)
m_loaded_blocks.insert(p, !block_data_inexistent); m_loaded_blocks.insert(p, !block_data_inexistent);
} }
//dstream<<"emerge done"<<std::endl; //infostream<<"emerge done"<<std::endl;
} }
/* /*
@ -4261,7 +4260,7 @@ void MapVoxelManipulator::blitBack
//TimeTaker timer1("blitBack"); //TimeTaker timer1("blitBack");
/*dstream<<"blitBack(): m_loaded_blocks.size()=" /*infostream<<"blitBack(): m_loaded_blocks.size()="
<<m_loaded_blocks.size()<<std::endl;*/ <<m_loaded_blocks.size()<<std::endl;*/
/* /*
@ -4350,10 +4349,10 @@ void ManualMapVoxelManipulator::initialEmerge(
u32 size_MB = block_area_nodes.getVolume()*4/1000000; u32 size_MB = block_area_nodes.getVolume()*4/1000000;
if(size_MB >= 1) if(size_MB >= 1)
{ {
dstream<<"initialEmerge: area: "; infostream<<"initialEmerge: area: ";
block_area_nodes.print(dstream); block_area_nodes.print(infostream);
dstream<<" ("<<size_MB<<"MB)"; infostream<<" ("<<size_MB<<"MB)";
dstream<<std::endl; infostream<<std::endl;
} }
addArea(block_area_nodes); addArea(block_area_nodes);
@ -4421,7 +4420,7 @@ void ManualMapVoxelManipulator::blitBackAll(
if(existed == false) if(existed == false)
{ {
// The Great Bug was found using this // The Great Bug was found using this
/*dstream<<"ManualMapVoxelManipulator::blitBackAll: " /*infostream<<"ManualMapVoxelManipulator::blitBackAll: "
<<"Inexistent ("<<p.X<<","<<p.Y<<","<<p.Z<<")" <<"Inexistent ("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;*/ <<std::endl;*/
continue; continue;
@ -4429,7 +4428,7 @@ void ManualMapVoxelManipulator::blitBackAll(
MapBlock *block = m_map->getBlockNoCreateNoEx(p); MapBlock *block = m_map->getBlockNoCreateNoEx(p);
if(block == NULL) if(block == NULL)
{ {
dstream<<"WARNING: "<<__FUNCTION_NAME infostream<<"WARNING: "<<__FUNCTION_NAME
<<": got NULL block " <<": got NULL block "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")" <<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl; <<std::endl;

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "utility.h" #include "utility.h"
#include "settings.h" #include "settings.h"
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
void cmd_status(std::wostringstream &os, void cmd_status(std::wostringstream &os,
ServerCommandContext *ctx) ServerCommandContext *ctx)
{ {
@ -94,10 +96,17 @@ void cmd_grantrevoke(std::wostringstream &os,
std::string playername = wide_to_narrow(ctx->parms[1]); std::string playername = wide_to_narrow(ctx->parms[1]);
u64 privs = ctx->server->getPlayerAuthPrivs(playername); u64 privs = ctx->server->getPlayerAuthPrivs(playername);
if(ctx->parms[0] == L"grant") if(ctx->parms[0] == L"grant"){
actionstream<<ctx->player->getName()<<" grants "
<<wide_to_narrow(ctx->parms[2])<<" to "
<<playername<<std::endl;
privs |= newprivs; privs |= newprivs;
else } else {
actionstream<<ctx->player->getName()<<" revokes "
<<wide_to_narrow(ctx->parms[2])<<" from "
<<playername<<std::endl;
privs &= ~newprivs; privs &= ~newprivs;
}
ctx->server->setPlayerAuthPrivs(playername, privs); ctx->server->setPlayerAuthPrivs(playername, privs);
@ -123,6 +132,9 @@ void cmd_time(std::wostringstream &os,
u32 time = stoi(wide_to_narrow(ctx->parms[1])); u32 time = stoi(wide_to_narrow(ctx->parms[1]));
ctx->server->setTimeOfDay(time); ctx->server->setTimeOfDay(time);
os<<L"-!- time_of_day changed."; os<<L"-!- time_of_day changed.";
actionstream<<ctx->player->getName()<<" sets time "
<<time<<std::endl;
} }
void cmd_shutdown(std::wostringstream &os, void cmd_shutdown(std::wostringstream &os,
@ -134,8 +146,9 @@ void cmd_shutdown(std::wostringstream &os,
return; return;
} }
dstream<<DTIME<<" Server: Operator requested shutdown." actionstream<<ctx->player->getName()
<<std::endl; <<" shuts down server"<<std::endl;
ctx->server->requestShutdown(); ctx->server->requestShutdown();
os<<L"*** Server shutting down (operator request)"; os<<L"*** Server shutting down (operator request)";
@ -156,6 +169,9 @@ void cmd_setting(std::wostringstream &os,
std::string confline = wide_to_narrow(ctx->paramstring); std::string confline = wide_to_narrow(ctx->paramstring);
actionstream<<ctx->player->getName()
<<" sets: "<<confline<<std::endl;
g_settings->parseConfigLine(confline); g_settings->parseConfigLine(confline);
ctx->server->saveConfig(); 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); v3f dest(stoi(coords[0])*10, stoi(coords[1])*10, stoi(coords[2])*10);
actionstream<<ctx->player->getName()<<" teleports from "
<<PP(ctx->player->getPosition()/BS)<<" to "
<<PP(dest/BS)<<std::endl;
ctx->player->setPosition(dest); ctx->player->setPosition(dest);
ctx->server->SendMovePlayer(ctx->player); ctx->server->SendMovePlayer(ctx->player);
@ -226,6 +247,9 @@ void cmd_banunban(std::wostringstream &os, ServerCommandContext *ctx)
ctx->server->setIpBanned(ip_string, player->getName()); ctx->server->setIpBanned(ip_string, player->getName());
os<<L"-!- Banned "<<narrow_to_wide(ip_string)<<L"|" os<<L"-!- Banned "<<narrow_to_wide(ip_string)<<L"|"
<<narrow_to_wide(player->getName()); <<narrow_to_wide(player->getName());
actionstream<<ctx->player->getName()<<" bans "
<<player->getName()<<" / "<<ip_string<<std::endl;
} }
else else
{ {
@ -233,6 +257,9 @@ void cmd_banunban(std::wostringstream &os, ServerCommandContext *ctx)
std::string desc = ctx->server->getBanDescription(ip_or_name); std::string desc = ctx->server->getBanDescription(ip_or_name);
ctx->server->unsetIpBanned(ip_or_name); ctx->server->unsetIpBanned(ip_or_name);
os<<L"-!- Unbanned "<<narrow_to_wide(desc); os<<L"-!- Unbanned "<<narrow_to_wide(desc);
actionstream<<ctx->player->getName()<<" unbans "
<<ip_or_name<<std::endl;
} }
} }

View File

@ -73,6 +73,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "defaultsettings.h" #include "defaultsettings.h"
#include "settings.h" #include "settings.h"
#include "profiler.h" #include "profiler.h"
#include "log.h"
/* /*
Settings. Settings.
@ -94,15 +95,15 @@ ITextureSource *g_texturesource = NULL;
// Connection // Connection
std::ostream *dout_con_ptr = &dummyout; std::ostream *dout_con_ptr = &dummyout;
std::ostream *derr_con_ptr = &dstream_no_stderr; std::ostream *derr_con_ptr = &verbosestream;
// Server // Server
std::ostream *dout_server_ptr = &dstream; std::ostream *dout_server_ptr = &infostream;
std::ostream *derr_server_ptr = &dstream; std::ostream *derr_server_ptr = &errorstream;
// Client // Client
std::ostream *dout_client_ptr = &dstream; std::ostream *dout_client_ptr = &infostream;
std::ostream *derr_client_ptr = &dstream; std::ostream *derr_client_ptr = &errorstream;
/* /*
gettime.h implementation gettime.h implementation
@ -116,12 +117,37 @@ u32 getTimeMs()
return porting::getTimeMs(); return porting::getTimeMs();
} }
class DstreamLogOutput: public ILogOutput
{
public:
/* line: Full line with timestamp, level and thread */
void printLog(const std::string &line)
{
dstream<<line<<std::endl;
}
} main_dstream_log_out;
class DstreamNoStderrLogOutput: public ILogOutput
{
public:
/* line: Full line with timestamp, level and thread */
void printLog(const std::string &line)
{
dstream_no_stderr<<line<<std::endl;
}
} main_dstream_no_stderr_log_out;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
/* /*
Initialization Initialization
*/ */
log_add_output_maxlev(&main_dstream_log_out, LMT_ACTION);
log_add_output_all_levs(&main_dstream_no_stderr_log_out);
log_register_thread("main");
// Set locale. This is for forcing '.' as the decimal point. // Set locale. This is for forcing '.' as the decimal point.
std::locale::global(std::locale("C")); std::locale::global(std::locale("C"));
// This enables printing all characters in bitmap font // This enables printing all characters in bitmap font
@ -164,7 +190,7 @@ int main(int argc, char *argv[])
BEGIN_DEBUG_EXCEPTION_HANDLER BEGIN_DEBUG_EXCEPTION_HANDLER
// Print startup message // Print startup message
dstream<<DTIME<<PROJECT_NAME << actionstream<<PROJECT_NAME<<
" with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST " with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST
<<", "<<BUILD_INFO <<", "<<BUILD_INFO
<<std::endl; <<std::endl;
@ -185,6 +211,7 @@ int main(int argc, char *argv[])
allowed_options.insert("disable-unittests", ValueSpec(VALUETYPE_FLAG)); allowed_options.insert("disable-unittests", ValueSpec(VALUETYPE_FLAG));
allowed_options.insert("enable-unittests", ValueSpec(VALUETYPE_FLAG)); allowed_options.insert("enable-unittests", ValueSpec(VALUETYPE_FLAG));
allowed_options.insert("map-dir", ValueSpec(VALUETYPE_STRING)); allowed_options.insert("map-dir", ValueSpec(VALUETYPE_STRING));
allowed_options.insert("info-on-stderr", ValueSpec(VALUETYPE_FLAG));
Settings cmd_args; Settings cmd_args;
@ -217,6 +244,8 @@ int main(int argc, char *argv[])
return cmd_args.getFlag("help") ? 0 : 1; return cmd_args.getFlag("help") ? 0 : 1;
} }
if(cmd_args.getFlag("info-on-stderr"))
log_add_output(&main_dstream_log_out, LMT_INFO);
/* /*
Basic initialization Basic initialization
@ -241,7 +270,7 @@ int main(int argc, char *argv[])
bool r = g_settings->readConfigFile(cmd_args.get("config").c_str()); bool r = g_settings->readConfigFile(cmd_args.get("config").c_str());
if(r == false) if(r == false)
{ {
dstream<<"Could not read configuration from \"" errorstream<<"Could not read configuration from \""
<<cmd_args.get("config")<<"\""<<std::endl; <<cmd_args.get("config")<<"\""<<std::endl;
return 1; return 1;
} }
@ -334,10 +363,10 @@ int main(int argc, char *argv[])
} //try } //try
catch(con::PeerNotFoundException &e) catch(con::PeerNotFoundException &e)
{ {
dstream<<DTIME<<"Connection timed out."<<std::endl; errorstream<<"Connection timed out."<<std::endl;
} }
END_DEBUG_EXCEPTION_HANDLER END_DEBUG_EXCEPTION_HANDLER(errorstream)
debugstreams_deinit(); debugstreams_deinit();

View File

@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <sstream> #include <sstream>
#include "debug.h" #include "debug.h"
#include "utility.h" #include "utility.h"
#include "log.h"
enum ValueType enum ValueType
{ {
@ -81,7 +82,7 @@ public:
if(trimmedline[0] == '#') if(trimmedline[0] == '#')
return true; return true;
//dstream<<"trimmedline=\""<<trimmedline<<"\""<<std::endl; //infostream<<"trimmedline=\""<<trimmedline<<"\""<<std::endl;
Strfnd sf(trim(line)); Strfnd sf(trim(line));
@ -94,7 +95,7 @@ public:
std::string value = sf.next("\n"); std::string value = sf.next("\n");
value = trim(value); value = trim(value);
/*dstream<<"Config name=\""<<name<<"\" value=\"" /*infostream<<"Config name=\""<<name<<"\" value=\""
<<value<<"\""<<std::endl;*/ <<value<<"\""<<std::endl;*/
m_settings[name] = value; m_settings[name] = value;
@ -130,7 +131,7 @@ public:
*/ */
std::string line; std::string line;
std::getline(is, line); std::getline(is, line);
//dstream<<"got line: \""<<line<<"\""<<std::endl; //infostream<<"got line: \""<<line<<"\""<<std::endl;
return parseConfigLine(line); return parseConfigLine(line);
} }
@ -145,12 +146,12 @@ public:
std::ifstream is(filename); std::ifstream is(filename);
if(is.good() == false) if(is.good() == false)
{ {
dstream<<"Error opening configuration file \"" errorstream<<"Error opening configuration file \""
<<filename<<"\""<<std::endl; <<filename<<"\""<<std::endl;
return false; return false;
} }
dstream<<"Parsing configuration file: \"" infostream<<"Parsing configuration file: \""
<<filename<<"\""<<std::endl; <<filename<<"\""<<std::endl;
while(parseConfigObject(is)); while(parseConfigObject(is));
@ -215,7 +216,7 @@ public:
if(newvalue != value) if(newvalue != value)
{ {
dstream<<"Changing value of \""<<name<<"\" = \"" infostream<<"Changing value of \""<<name<<"\" = \""
<<value<<"\" -> \""<<newvalue<<"\"" <<value<<"\" -> \""<<newvalue<<"\""
<<std::endl; <<std::endl;
} }
@ -235,7 +236,7 @@ public:
*/ */
bool updateConfigFile(const char *filename) bool updateConfigFile(const char *filename)
{ {
dstream<<"Updating configuration file: \"" infostream<<"Updating configuration file: \""
<<filename<<"\""<<std::endl; <<filename<<"\""<<std::endl;
core::list<std::string> objects; core::list<std::string> objects;
@ -246,7 +247,7 @@ public:
std::ifstream is(filename); std::ifstream is(filename);
if(is.good() == false) if(is.good() == false)
{ {
dstream<<"INFO: updateConfigFile():" infostream<<"updateConfigFile():"
" Error opening configuration file" " Error opening configuration file"
" for reading: \"" " for reading: \""
<<filename<<"\""<<std::endl; <<filename<<"\""<<std::endl;
@ -264,7 +265,7 @@ public:
std::ofstream os(filename); std::ofstream os(filename);
if(os.good() == false) if(os.good() == false)
{ {
dstream<<"Error opening configuration file" errorstream<<"Error opening configuration file"
" for writing: \"" " for writing: \""
<<filename<<"\""<<std::endl; <<filename<<"\""<<std::endl;
return false; return false;
@ -291,7 +292,7 @@ public:
continue; continue;
std::string name = i.getNode()->getKey(); std::string name = i.getNode()->getKey();
std::string value = i.getNode()->getValue(); std::string value = i.getNode()->getValue();
dstream<<"Adding \""<<name<<"\" = \""<<value<<"\"" infostream<<"Adding \""<<name<<"\" = \""<<value<<"\""
<<std::endl; <<std::endl;
os<<name<<" = "<<value<<"\n"; os<<name<<" = "<<value<<"\n";
} }
@ -316,7 +317,7 @@ public:
std::string argname = argv[i]; std::string argname = argv[i];
if(argname.substr(0, 2) != "--") if(argname.substr(0, 2) != "--")
{ {
dstream<<"Invalid command-line parameter \"" errorstream<<"Invalid command-line parameter \""
<<argname<<"\": --<option> expected."<<std::endl; <<argname<<"\": --<option> expected."<<std::endl;
return false; return false;
} }
@ -328,7 +329,7 @@ public:
n = allowed_options.find(name); n = allowed_options.find(name);
if(n == NULL) if(n == NULL)
{ {
dstream<<"Unknown command-line parameter \"" errorstream<<"Unknown command-line parameter \""
<<argname<<"\""<<std::endl; <<argname<<"\""<<std::endl;
return false; return false;
} }
@ -345,7 +346,7 @@ public:
{ {
if(i >= argc) if(i >= argc)
{ {
dstream<<"Invalid command-line parameter \"" errorstream<<"Invalid command-line parameter \""
<<name<<"\": missing value"<<std::endl; <<name<<"\": missing value"<<std::endl;
return false; return false;
} }
@ -354,7 +355,7 @@ public:
} }
dstream<<"Valid command-line parameter: \"" infostream<<"Valid command-line parameter: \""
<<name<<"\" = \""<<value<<"\"" <<name<<"\" = \""<<value<<"\""
<<std::endl; <<std::endl;
set(name, value); set(name, value);
@ -403,7 +404,7 @@ public:
n = m_defaults.find(name); n = m_defaults.find(name);
if(n == NULL) if(n == NULL)
{ {
dstream<<"INFO: Settings: Setting not found: \"" infostream<<"Settings: Setting not found: \""
<<name<<"\""<<std::endl; <<name<<"\""<<std::endl;
throw SettingNotFoundException("Setting not found"); throw SettingNotFoundException("Setting not found");
} }

View File

@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_mapnode.h" #include "content_mapnode.h"
#include "mapsector.h" #include "mapsector.h"
#include "settings.h" #include "settings.h"
#include "log.h"
/* /*
Asserts that the exception occurs Asserts that the exception occurs
@ -49,9 +50,9 @@ struct TestUtilities
{ {
void Run() void Run()
{ {
/*dstream<<"wrapDegrees(100.0) = "<<wrapDegrees(100.0)<<std::endl; /*infostream<<"wrapDegrees(100.0) = "<<wrapDegrees(100.0)<<std::endl;
dstream<<"wrapDegrees(720.5) = "<<wrapDegrees(720.5)<<std::endl; infostream<<"wrapDegrees(720.5) = "<<wrapDegrees(720.5)<<std::endl;
dstream<<"wrapDegrees(-0.5) = "<<wrapDegrees(-0.5)<<std::endl;*/ infostream<<"wrapDegrees(-0.5) = "<<wrapDegrees(-0.5)<<std::endl;*/
assert(fabs(wrapDegrees(100.0) - 100.0) < 0.001); assert(fabs(wrapDegrees(100.0) - 100.0) < 0.001);
assert(fabs(wrapDegrees(720.5) - 0.5) < 0.001); assert(fabs(wrapDegrees(720.5) - 0.5) < 0.001);
assert(fabs(wrapDegrees(-0.5) - (-0.5)) < 0.001); assert(fabs(wrapDegrees(-0.5) - (-0.5)) < 0.001);
@ -112,13 +113,13 @@ struct TestCompress
std::string str_out = os.str(); std::string str_out = os.str();
dstream<<"str_out.size()="<<str_out.size()<<std::endl; infostream<<"str_out.size()="<<str_out.size()<<std::endl;
dstream<<"TestCompress: 1,5,5,1 -> "; infostream<<"TestCompress: 1,5,5,1 -> ";
for(u32 i=0; i<str_out.size(); i++) for(u32 i=0; i<str_out.size(); i++)
{ {
dstream<<(u32)str_out[i]<<","; infostream<<(u32)str_out[i]<<",";
} }
dstream<<std::endl; infostream<<std::endl;
assert(str_out.size() == 10); assert(str_out.size() == 10);
@ -139,12 +140,12 @@ struct TestCompress
decompress(is, os2, 0); decompress(is, os2, 0);
std::string str_out2 = os2.str(); std::string str_out2 = os2.str();
dstream<<"decompress: "; infostream<<"decompress: ";
for(u32 i=0; i<str_out2.size(); i++) for(u32 i=0; i<str_out2.size(); i++)
{ {
dstream<<(u32)str_out2[i]<<","; infostream<<(u32)str_out2[i]<<",";
} }
dstream<<std::endl; infostream<<std::endl;
assert(str_out2.size() == fromdata.getSize()); assert(str_out2.size() == fromdata.getSize());
@ -168,13 +169,13 @@ struct TestCompress
std::string str_out = os.str(); std::string str_out = os.str();
dstream<<"str_out.size()="<<str_out.size()<<std::endl; infostream<<"str_out.size()="<<str_out.size()<<std::endl;
dstream<<"TestCompress: 1,5,5,1 -> "; infostream<<"TestCompress: 1,5,5,1 -> ";
for(u32 i=0; i<str_out.size(); i++) for(u32 i=0; i<str_out.size(); i++)
{ {
dstream<<(u32)str_out[i]<<","; infostream<<(u32)str_out[i]<<",";
} }
dstream<<std::endl; infostream<<std::endl;
/*assert(str_out.size() == 10); /*assert(str_out.size() == 10);
@ -195,12 +196,12 @@ struct TestCompress
decompress(is, os2, SER_FMT_VER_HIGHEST); decompress(is, os2, SER_FMT_VER_HIGHEST);
std::string str_out2 = os2.str(); std::string str_out2 = os2.str();
dstream<<"decompress: "; infostream<<"decompress: ";
for(u32 i=0; i<str_out2.size(); i++) for(u32 i=0; i<str_out2.size(); i++)
{ {
dstream<<(u32)str_out2[i]<<","; infostream<<(u32)str_out2[i]<<",";
} }
dstream<<std::endl; infostream<<std::endl;
assert(str_out2.size() == fromdata.getSize()); assert(str_out2.size() == fromdata.getSize());
@ -258,12 +259,12 @@ struct TestVoxelManipulator
assert(aa.size() == results.size()); assert(aa.size() == results.size());
dstream<<"Result of diff:"<<std::endl; infostream<<"Result of diff:"<<std::endl;
for(core::list<VoxelArea>::Iterator for(core::list<VoxelArea>::Iterator
i = aa.begin(); i != aa.end(); i++) i = aa.begin(); i != aa.end(); i++)
{ {
i->print(dstream); i->print(infostream);
dstream<<std::endl; infostream<<std::endl;
s32 j = results.linear_search(*i); s32 j = results.linear_search(*i);
assert(j != -1); assert(j != -1);
@ -277,27 +278,27 @@ struct TestVoxelManipulator
VoxelManipulator v; VoxelManipulator v;
v.print(dstream); v.print(infostream);
dstream<<"*** Setting (-1,0,-1)=2 ***"<<std::endl; infostream<<"*** Setting (-1,0,-1)=2 ***"<<std::endl;
v.setNodeNoRef(v3s16(-1,0,-1), MapNode(2)); v.setNodeNoRef(v3s16(-1,0,-1), MapNode(2));
v.print(dstream); v.print(infostream);
assert(v.getNode(v3s16(-1,0,-1)).getContent() == 2); assert(v.getNode(v3s16(-1,0,-1)).getContent() == 2);
dstream<<"*** Reading from inexistent (0,0,-1) ***"<<std::endl; infostream<<"*** Reading from inexistent (0,0,-1) ***"<<std::endl;
EXCEPTION_CHECK(InvalidPositionException, v.getNode(v3s16(0,0,-1))); EXCEPTION_CHECK(InvalidPositionException, v.getNode(v3s16(0,0,-1)));
v.print(dstream); v.print(infostream);
dstream<<"*** Adding area ***"<<std::endl; infostream<<"*** Adding area ***"<<std::endl;
v.addArea(a); v.addArea(a);
v.print(dstream); v.print(infostream);
assert(v.getNode(v3s16(-1,0,-1)).getContent() == 2); assert(v.getNode(v3s16(-1,0,-1)).getContent() == 2);
EXCEPTION_CHECK(InvalidPositionException, v.getNode(v3s16(0,1,1))); EXCEPTION_CHECK(InvalidPositionException, v.getNode(v3s16(0,1,1)));
@ -343,12 +344,12 @@ struct TestVoxelManipulator
p++; p++;
} }
v.print(dstream, VOXELPRINT_WATERPRESSURE); v.print(infostream, VOXELPRINT_WATERPRESSURE);
core::map<v3s16, u8> active_nodes; core::map<v3s16, u8> active_nodes;
v.updateAreaWaterPressure(area, active_nodes); v.updateAreaWaterPressure(area, active_nodes);
v.print(dstream, VOXELPRINT_WATERPRESSURE); v.print(infostream, VOXELPRINT_WATERPRESSURE);
//s16 highest_y = -32768; //s16 highest_y = -32768;
/* /*
@ -365,8 +366,8 @@ struct TestVoxelManipulator
//v.flowWater(active_nodes, 0, true, 1000); //v.flowWater(active_nodes, 0, true, 1000);
v.flowWater(active_nodes, 0, false, 1000); v.flowWater(active_nodes, 0, false, 1000);
dstream<<"Final result of flowWater:"<<std::endl; infostream<<"Final result of flowWater:"<<std::endl;
v.print(dstream, VOXELPRINT_WATERPRESSURE); v.print(infostream, VOXELPRINT_WATERPRESSURE);
#endif #endif
//assert(0); //assert(0);
@ -765,15 +766,15 @@ struct TestConnection
assert(readU8(&p1.data[6]) == channel); assert(readU8(&p1.data[6]) == channel);
assert(readU8(&p1.data[7]) == data1[0]); assert(readU8(&p1.data[7]) == data1[0]);
//dstream<<"initial data1[0]="<<((u32)data1[0]&0xff)<<std::endl; //infostream<<"initial data1[0]="<<((u32)data1[0]&0xff)<<std::endl;
SharedBuffer<u8> p2 = con::makeReliablePacket(data1, seqnum); SharedBuffer<u8> p2 = con::makeReliablePacket(data1, seqnum);
/*dstream<<"p2.getSize()="<<p2.getSize()<<", data1.getSize()=" /*infostream<<"p2.getSize()="<<p2.getSize()<<", data1.getSize()="
<<data1.getSize()<<std::endl; <<data1.getSize()<<std::endl;
dstream<<"readU8(&p2[3])="<<readU8(&p2[3]) infostream<<"readU8(&p2[3])="<<readU8(&p2[3])
<<" p2[3]="<<((u32)p2[3]&0xff)<<std::endl; <<" p2[3]="<<((u32)p2[3]&0xff)<<std::endl;
dstream<<"data1[0]="<<((u32)data1[0]&0xff)<<std::endl;*/ infostream<<"data1[0]="<<((u32)data1[0]&0xff)<<std::endl;*/
assert(p2.getSize() == 3 + data1.getSize()); assert(p2.getSize() == 3 + data1.getSize());
assert(readU8(&p2[0]) == TYPE_RELIABLE); assert(readU8(&p2[0]) == TYPE_RELIABLE);
@ -791,14 +792,14 @@ struct TestConnection
} }
void peerAdded(con::Peer *peer) void peerAdded(con::Peer *peer)
{ {
dstream<<"Handler("<<name<<")::peerAdded(): " infostream<<"Handler("<<name<<")::peerAdded(): "
"id="<<peer->id<<std::endl; "id="<<peer->id<<std::endl;
last_id = peer->id; last_id = peer->id;
count++; count++;
} }
void deletingPeer(con::Peer *peer, bool timeout) void deletingPeer(con::Peer *peer, bool timeout)
{ {
dstream<<"Handler("<<name<<")::deletingPeer(): " infostream<<"Handler("<<name<<")::deletingPeer(): "
"id="<<peer->id "id="<<peer->id
<<", timeout="<<timeout<<std::endl; <<", timeout="<<timeout<<std::endl;
last_id = peer->id; last_id = peer->id;
@ -824,11 +825,11 @@ struct TestConnection
Handler hand_server("server"); Handler hand_server("server");
Handler hand_client("client"); Handler hand_client("client");
dstream<<"** Creating server Connection"<<std::endl; infostream<<"** Creating server Connection"<<std::endl;
con::Connection server(proto_id, 512, 5.0, &hand_server); con::Connection server(proto_id, 512, 5.0, &hand_server);
server.Serve(30001); server.Serve(30001);
dstream<<"** Creating client Connection"<<std::endl; infostream<<"** Creating client Connection"<<std::endl;
con::Connection client(proto_id, 512, 5.0, &hand_client); con::Connection client(proto_id, 512, 5.0, &hand_client);
assert(hand_server.count == 0); assert(hand_server.count == 0);
@ -837,7 +838,7 @@ struct TestConnection
sleep_ms(50); sleep_ms(50);
Address server_address(127,0,0,1, 30001); Address server_address(127,0,0,1, 30001);
dstream<<"** running client.Connect()"<<std::endl; infostream<<"** running client.Connect()"<<std::endl;
client.Connect(server_address); client.Connect(server_address);
sleep_ms(50); sleep_ms(50);
@ -852,9 +853,9 @@ struct TestConnection
{ {
u16 peer_id; u16 peer_id;
u8 data[100]; u8 data[100];
dstream<<"** running server.Receive()"<<std::endl; infostream<<"** running server.Receive()"<<std::endl;
u32 size = server.Receive(peer_id, data, 100); u32 size = server.Receive(peer_id, data, 100);
dstream<<"** Server received: peer_id="<<peer_id infostream<<"** Server received: peer_id="<<peer_id
<<", size="<<size <<", size="<<size
<<std::endl; <<std::endl;
} }
@ -879,9 +880,9 @@ struct TestConnection
{ {
u16 peer_id; u16 peer_id;
u8 data[100]; u8 data[100];
dstream<<"** running client.Receive()"<<std::endl; infostream<<"** running client.Receive()"<<std::endl;
u32 size = client.Receive(peer_id, data, 100); u32 size = client.Receive(peer_id, data, 100);
dstream<<"** Client received: peer_id="<<peer_id infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size <<", size="<<size
<<std::endl; <<std::endl;
} }
@ -897,9 +898,9 @@ struct TestConnection
{ {
u16 peer_id; u16 peer_id;
u8 data[100]; u8 data[100];
dstream<<"** running server.Receive()"<<std::endl; infostream<<"** running server.Receive()"<<std::endl;
u32 size = server.Receive(peer_id, data, 100); u32 size = server.Receive(peer_id, data, 100);
dstream<<"** Server received: peer_id="<<peer_id infostream<<"** Server received: peer_id="<<peer_id
<<", size="<<size <<", size="<<size
<<std::endl; <<std::endl;
} }
@ -912,16 +913,16 @@ struct TestConnection
u32 datasize = sizeof(data);*/ u32 datasize = sizeof(data);*/
SharedBuffer<u8> data = SharedBufferFromString("Hello World!"); SharedBuffer<u8> data = SharedBufferFromString("Hello World!");
dstream<<"** running client.Send()"<<std::endl; infostream<<"** running client.Send()"<<std::endl;
client.Send(PEER_ID_SERVER, 0, data, true); client.Send(PEER_ID_SERVER, 0, data, true);
sleep_ms(50); sleep_ms(50);
u16 peer_id; u16 peer_id;
u8 recvdata[100]; u8 recvdata[100];
dstream<<"** running server.Receive()"<<std::endl; infostream<<"** running server.Receive()"<<std::endl;
u32 size = server.Receive(peer_id, recvdata, 100); u32 size = server.Receive(peer_id, recvdata, 100);
dstream<<"** Server received: peer_id="<<peer_id infostream<<"** Server received: peer_id="<<peer_id
<<", size="<<size <<", size="<<size
<<", data="<<*data <<", data="<<*data
<<std::endl; <<std::endl;
@ -942,7 +943,7 @@ struct TestConnection
Address client_address = Address client_address =
server.GetPeer(peer_id_client)->address; server.GetPeer(peer_id_client)->address;
dstream<<"*** Sending packets in wrong order (2,1,2)" infostream<<"*** Sending packets in wrong order (2,1,2)"
<<std::endl; <<std::endl;
u8 chn = 0; u8 chn = 0;
@ -957,16 +958,16 @@ struct TestConnection
sleep_ms(50); sleep_ms(50);
dstream<<"*** Receiving the packets"<<std::endl; infostream<<"*** Receiving the packets"<<std::endl;
u16 peer_id; u16 peer_id;
u8 recvdata[20]; u8 recvdata[20];
u32 size; u32 size;
dstream<<"** running client.Receive()"<<std::endl; infostream<<"** running client.Receive()"<<std::endl;
peer_id = 132; peer_id = 132;
size = client.Receive(peer_id, recvdata, 20); size = client.Receive(peer_id, recvdata, 20);
dstream<<"** Client received: peer_id="<<peer_id infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size <<", size="<<size
<<", data="<<recvdata <<", data="<<recvdata
<<std::endl; <<std::endl;
@ -974,10 +975,10 @@ struct TestConnection
assert(memcmp(*data1, recvdata, data1.getSize()) == 0); assert(memcmp(*data1, recvdata, data1.getSize()) == 0);
assert(peer_id == PEER_ID_SERVER); assert(peer_id == PEER_ID_SERVER);
dstream<<"** running client.Receive()"<<std::endl; infostream<<"** running client.Receive()"<<std::endl;
peer_id = 132; peer_id = 132;
size = client.Receive(peer_id, recvdata, 20); size = client.Receive(peer_id, recvdata, 20);
dstream<<"** Client received: peer_id="<<peer_id infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size <<", size="<<size
<<", data="<<recvdata <<", data="<<recvdata
<<std::endl; <<std::endl;
@ -988,17 +989,17 @@ struct TestConnection
bool got_exception = false; bool got_exception = false;
try try
{ {
dstream<<"** running client.Receive()"<<std::endl; infostream<<"** running client.Receive()"<<std::endl;
peer_id = 132; peer_id = 132;
size = client.Receive(peer_id, recvdata, 20); size = client.Receive(peer_id, recvdata, 20);
dstream<<"** Client received: peer_id="<<peer_id infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size <<", size="<<size
<<", data="<<recvdata <<", data="<<recvdata
<<std::endl; <<std::endl;
} }
catch(con::NoIncomingDataException &e) catch(con::NoIncomingDataException &e)
{ {
dstream<<"** No incoming data for client"<<std::endl; infostream<<"** No incoming data for client"<<std::endl;
got_exception = true; got_exception = true;
} }
assert(got_exception); assert(got_exception);
@ -1010,35 +1011,35 @@ struct TestConnection
data1[i] = i/4; data1[i] = i/4;
} }
dstream<<"Sending data (size="<<datasize<<"):"; infostream<<"Sending data (size="<<datasize<<"):";
for(int i=0; i<datasize && i<20; i++){ for(int i=0; i<datasize && i<20; i++){
if(i%2==0) DEBUGPRINT(" "); if(i%2==0) DEBUGPRINT(" ");
DEBUGPRINT("%.2X", ((int)((const char*)*data1)[i])&0xff); DEBUGPRINT("%.2X", ((int)((const char*)*data1)[i])&0xff);
} }
if(datasize>20) if(datasize>20)
dstream<<"..."; infostream<<"...";
dstream<<std::endl; infostream<<std::endl;
server.Send(peer_id_client, 0, data1, true); server.Send(peer_id_client, 0, data1, true);
sleep_ms(50); sleep_ms(50);
u8 recvdata[datasize + 1000]; u8 recvdata[datasize + 1000];
dstream<<"** running client.Receive()"<<std::endl; infostream<<"** running client.Receive()"<<std::endl;
u16 peer_id = 132; u16 peer_id = 132;
u16 size = client.Receive(peer_id, recvdata, datasize + 1000); u16 size = client.Receive(peer_id, recvdata, datasize + 1000);
dstream<<"** Client received: peer_id="<<peer_id infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size <<", size="<<size
<<std::endl; <<std::endl;
dstream<<"Received data (size="<<size<<"):"; infostream<<"Received data (size="<<size<<"):";
for(int i=0; i<size && i<20; i++){ for(int i=0; i<size && i<20; i++){
if(i%2==0) DEBUGPRINT(" "); if(i%2==0) DEBUGPRINT(" ");
DEBUGPRINT("%.2X", ((int)((const char*)recvdata)[i])&0xff); DEBUGPRINT("%.2X", ((int)((const char*)recvdata)[i])&0xff);
} }
if(size>20) if(size>20)
dstream<<"..."; infostream<<"...";
dstream<<std::endl; infostream<<std::endl;
assert(memcmp(*data1, recvdata, data1.getSize()) == 0); assert(memcmp(*data1, recvdata, data1.getSize()) == 0);
assert(peer_id == PEER_ID_SERVER); assert(peer_id == PEER_ID_SERVER);
@ -1057,14 +1058,14 @@ struct TestConnection
#define TEST(X)\ #define TEST(X)\
{\ {\
X x;\ X x;\
dstream<<"Running " #X <<std::endl;\ infostream<<"Running " #X <<std::endl;\
x.Run();\ x.Run();\
} }
void run_tests() void run_tests()
{ {
DSTACK(__FUNCTION_NAME); DSTACK(__FUNCTION_NAME);
dstream<<"run_tests() started"<<std::endl; infostream<<"run_tests() started"<<std::endl;
TEST(TestUtilities); TEST(TestUtilities);
TEST(TestSettings); TEST(TestSettings);
TEST(TestCompress); TEST(TestCompress);
@ -1078,6 +1079,6 @@ void run_tests()
TEST(TestConnection); TEST(TestConnection);
dout_con<<"=== END RUNNING UNIT TESTS FOR CONNECTION ==="<<std::endl; dout_con<<"=== END RUNNING UNIT TESTS FOR CONNECTION ==="<<std::endl;
} }
dstream<<"run_tests() passed"<<std::endl; infostream<<"run_tests() passed"<<std::endl;
} }

View File

@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "utility.h" #include "utility.h"
#include "settings.h" #include "settings.h"
#include <ICameraSceneNode.h> #include <ICameraSceneNode.h>
#include "log.h"
/* /*
A cache from texture name to texture path A cache from texture name to texture path
@ -162,7 +163,7 @@ TextureSource::TextureSource(IrrlichtDevice *device):
if(g_settings->getBool("enable_texture_atlas")) if(g_settings->getBool("enable_texture_atlas"))
buildMainAtlas(); buildMainAtlas();
else else
dstream<<"INFO: Not building texture atlas."<<std::endl; infostream<<"Not building texture atlas."<<std::endl;
} }
TextureSource::~TextureSource() TextureSource::~TextureSource()
@ -179,7 +180,7 @@ void TextureSource::processQueue()
GetRequest<std::string, u32, u8, u8> GetRequest<std::string, u32, u8, u8>
request = m_get_texture_queue.pop(); request = m_get_texture_queue.pop();
dstream<<"INFO: TextureSource::processQueue(): " infostream<<"TextureSource::processQueue(): "
<<"got texture request with " <<"got texture request with "
<<"name=\""<<request.key<<"\"" <<"name=\""<<request.key<<"\""
<<std::endl; <<std::endl;
@ -196,7 +197,7 @@ void TextureSource::processQueue()
u32 TextureSource::getTextureId(const std::string &name) u32 TextureSource::getTextureId(const std::string &name)
{ {
//dstream<<"INFO: getTextureId(): \""<<name<<"\""<<std::endl; //infostream<<"getTextureId(): \""<<name<<"\""<<std::endl;
{ {
/* /*
@ -220,7 +221,7 @@ u32 TextureSource::getTextureId(const std::string &name)
} }
else else
{ {
dstream<<"INFO: getTextureId(): Queued: name=\""<<name<<"\""<<std::endl; infostream<<"getTextureId(): Queued: name=\""<<name<<"\""<<std::endl;
// We're gonna ask the result to be put into here // We're gonna ask the result to be put into here
ResultQueue<std::string, u32, u8, u8> result_queue; ResultQueue<std::string, u32, u8, u8> result_queue;
@ -228,7 +229,7 @@ u32 TextureSource::getTextureId(const std::string &name)
// Throw a request in // Throw a request in
m_get_texture_queue.add(name, 0, 0, &result_queue); 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=\""
<<name<<"\""<<std::endl; <<name<<"\""<<std::endl;
try try
@ -244,12 +245,12 @@ u32 TextureSource::getTextureId(const std::string &name)
} }
catch(ItemNotFoundException &e) catch(ItemNotFoundException &e)
{ {
dstream<<"WARNING: Waiting for texture timed out."<<std::endl; infostream<<"Waiting for texture timed out."<<std::endl;
return 0; return 0;
} }
} }
dstream<<"WARNING: getTextureId(): Failed"<<std::endl; infostream<<"getTextureId(): Failed"<<std::endl;
return 0; return 0;
} }
@ -278,12 +279,12 @@ video::IImage* generate_image_from_scratch(std::string name,
*/ */
u32 TextureSource::getTextureIdDirect(const std::string &name) u32 TextureSource::getTextureIdDirect(const std::string &name)
{ {
//dstream<<"INFO: getTextureIdDirect(): name=\""<<name<<"\""<<std::endl; //infostream<<"getTextureIdDirect(): name=\""<<name<<"\""<<std::endl;
// Empty name means texture 0 // Empty name means texture 0
if(name == "") if(name == "")
{ {
dstream<<"INFO: getTextureIdDirect(): name is empty"<<std::endl; infostream<<"getTextureIdDirect(): name is empty"<<std::endl;
return 0; return 0;
} }
@ -292,7 +293,7 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
*/ */
if(get_current_thread_id() != m_main_thread) if(get_current_thread_id() != m_main_thread)
{ {
dstream<<"ERROR: TextureSource::getTextureIdDirect() " errorstream<<"TextureSource::getTextureIdDirect() "
"called not from main thread"<<std::endl; "called not from main thread"<<std::endl;
return 0; return 0;
} }
@ -307,13 +308,13 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
n = m_name_to_id.find(name); n = m_name_to_id.find(name);
if(n != NULL) if(n != NULL)
{ {
dstream<<"INFO: getTextureIdDirect(): \""<<name infostream<<"getTextureIdDirect(): \""<<name
<<"\" found in cache"<<std::endl; <<"\" found in cache"<<std::endl;
return n->getValue(); return n->getValue();
} }
} }
dstream<<"INFO: getTextureIdDirect(): \""<<name infostream<<"getTextureIdDirect(): \""<<name
<<"\" NOT found in cache. Creating it."<<std::endl; <<"\" NOT found in cache. Creating it."<<std::endl;
/* /*
@ -348,13 +349,13 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
{ {
// Construct base name // Construct base name
base_image_name = name.substr(0, last_separator_position); base_image_name = name.substr(0, last_separator_position);
/*dstream<<"INFO: getTextureIdDirect(): Calling itself recursively" /*infostream<<"getTextureIdDirect(): Calling itself recursively"
" to get base image of \""<<name<<"\" = \"" " to get base image of \""<<name<<"\" = \""
<<base_image_name<<"\""<<std::endl;*/ <<base_image_name<<"\""<<std::endl;*/
base_image_id = getTextureIdDirect(base_image_name); base_image_id = getTextureIdDirect(base_image_name);
} }
//dstream<<"base_image_id="<<base_image_id<<std::endl; //infostream<<"base_image_id="<<base_image_id<<std::endl;
video::IVideoDriver* driver = m_device->getVideoDriver(); video::IVideoDriver* driver = m_device->getVideoDriver();
assert(driver); assert(driver);
@ -377,7 +378,7 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
if(image == NULL) if(image == NULL)
{ {
dstream<<"WARNING: getTextureIdDirect(): NULL image in " infostream<<"getTextureIdDirect(): NULL image in "
<<"cache: \""<<base_image_name<<"\"" <<"cache: \""<<base_image_name<<"\""
<<std::endl; <<std::endl;
} }
@ -396,7 +397,7 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
core::rect<s32>(pos_from, dim) // from core::rect<s32>(pos_from, dim) // from
); );
/*dstream<<"INFO: getTextureIdDirect(): Loaded \"" /*infostream<<"getTextureIdDirect(): Loaded \""
<<base_image_name<<"\" from image cache" <<base_image_name<<"\" from image cache"
<<std::endl;*/ <<std::endl;*/
} }
@ -408,12 +409,12 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
*/ */
std::string last_part_of_name = name.substr(last_separator_position+1); std::string last_part_of_name = name.substr(last_separator_position+1);
//dstream<<"last_part_of_name=\""<<last_part_of_name<<"\""<<std::endl; //infostream<<"last_part_of_name=\""<<last_part_of_name<<"\""<<std::endl;
// Generate image according to part of name // Generate image according to part of name
if(generate_image(last_part_of_name, baseimg, m_device) == false) if(generate_image(last_part_of_name, baseimg, m_device) == false)
{ {
dstream<<"INFO: getTextureIdDirect(): " infostream<<"getTextureIdDirect(): "
"failed to generate \""<<last_part_of_name<<"\"" "failed to generate \""<<last_part_of_name<<"\""
<<std::endl; <<std::endl;
} }
@ -421,7 +422,7 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
// If no resulting image, print a warning // If no resulting image, print a warning
if(baseimg == NULL) if(baseimg == NULL)
{ {
dstream<<"WARNING: getTextureIdDirect(): baseimg is NULL (attempted to" infostream<<"getTextureIdDirect(): baseimg is NULL (attempted to"
" create texture \""<<name<<"\""<<std::endl; " create texture \""<<name<<"\""<<std::endl;
} }
@ -450,7 +451,7 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
m_atlaspointer_cache.push_back(nap); m_atlaspointer_cache.push_back(nap);
m_name_to_id.insert(name, id); m_name_to_id.insert(name, id);
/*dstream<<"INFO: getTextureIdDirect(): " /*infostream<<"getTextureIdDirect(): "
<<"Returning id="<<id<<" for name \""<<name<<"\""<<std::endl;*/ <<"Returning id="<<id<<" for name \""<<name<<"\""<<std::endl;*/
return id; return id;
@ -462,7 +463,7 @@ std::string TextureSource::getTextureName(u32 id)
if(id >= m_atlaspointer_cache.size()) if(id >= m_atlaspointer_cache.size())
{ {
dstream<<"WARNING: TextureSource::getTextureName(): id="<<id infostream<<"TextureSource::getTextureName(): id="<<id
<<" >= m_atlaspointer_cache.size()=" <<" >= m_atlaspointer_cache.size()="
<<m_atlaspointer_cache.size()<<std::endl; <<m_atlaspointer_cache.size()<<std::endl;
return ""; return "";
@ -484,7 +485,7 @@ AtlasPointer TextureSource::getTexture(u32 id)
void TextureSource::buildMainAtlas() void TextureSource::buildMainAtlas()
{ {
dstream<<"TextureSource::buildMainAtlas()"<<std::endl; infostream<<"TextureSource::buildMainAtlas()"<<std::endl;
//return; // Disable (for testing) //return; // Disable (for testing)
@ -500,7 +501,7 @@ void TextureSource::buildMainAtlas()
//assert(atlas_img); //assert(atlas_img);
if(atlas_img == NULL) if(atlas_img == NULL)
{ {
dstream<<"TextureSource::buildMainAtlas(): Failed to create atlas " errorstream<<"TextureSource::buildMainAtlas(): Failed to create atlas "
"image; not building texture atlas."<<std::endl; "image; not building texture atlas."<<std::endl;
return; return;
} }
@ -569,7 +570,7 @@ void TextureSource::buildMainAtlas()
video::IImage *img2 = generate_image_from_scratch(name, m_device); video::IImage *img2 = generate_image_from_scratch(name, m_device);
if(img2 == NULL) if(img2 == NULL)
{ {
dstream<<"WARNING: TextureSource::buildMainAtlas(): Couldn't generate texture atlas: Couldn't generate image \""<<name<<"\""<<std::endl; infostream<<"TextureSource::buildMainAtlas(): Couldn't generate texture atlas: Couldn't generate image \""<<name<<"\""<<std::endl;
continue; continue;
} }
@ -580,7 +581,7 @@ void TextureSource::buildMainAtlas()
if(dim.Width > max_size_in_atlas.Width if(dim.Width > max_size_in_atlas.Width
|| dim.Height > max_size_in_atlas.Height) || dim.Height > max_size_in_atlas.Height)
{ {
dstream<<"INFO: TextureSource::buildMainAtlas(): Not adding " infostream<<"TextureSource::buildMainAtlas(): Not adding "
<<"\""<<name<<"\" because image is large"<<std::endl; <<"\""<<name<<"\" because image is large"<<std::endl;
continue; continue;
} }
@ -588,13 +589,13 @@ void TextureSource::buildMainAtlas()
// Stop making atlas if atlas is full // Stop making atlas if atlas is full
if(pos_in_atlas.Y + dim.Height > atlas_dim.Height) if(pos_in_atlas.Y + dim.Height > atlas_dim.Height)
{ {
dstream<<"WARNING: TextureSource::buildMainAtlas(): " infostream<<"TextureSource::buildMainAtlas(): "
<<"Atlas is full, not adding more textures." <<"Atlas is full, not adding more textures."
<<std::endl; <<std::endl;
break; break;
} }
dstream<<"INFO: TextureSource::buildMainAtlas(): Adding \""<<name infostream<<"TextureSource::buildMainAtlas(): Adding \""<<name
<<"\" to texture atlas"<<std::endl; <<"\" to texture atlas"<<std::endl;
// Tile it a few times in the X direction // Tile it a few times in the X direction
@ -673,7 +674,7 @@ void TextureSource::buildMainAtlas()
if(m_name_to_id.find(name) == NULL) if(m_name_to_id.find(name) == NULL)
continue; continue;
u32 id = m_name_to_id[name]; u32 id = m_name_to_id[name];
//dstream<<"id of name "<<name<<" is "<<id<<std::endl; //infostream<<"id of name "<<name<<" is "<<id<<std::endl;
m_atlaspointer_cache[id].a.atlas = t; m_atlaspointer_cache[id].a.atlas = t;
} }
@ -687,7 +688,7 @@ void TextureSource::buildMainAtlas()
video::IImage* generate_image_from_scratch(std::string name, video::IImage* generate_image_from_scratch(std::string name,
IrrlichtDevice *device) IrrlichtDevice *device)
{ {
/*dstream<<"INFO: generate_image_from_scratch(): " /*infostream<<"generate_image_from_scratch(): "
"\""<<name<<"\""<<std::endl;*/ "\""<<name<<"\""<<std::endl;*/
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->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="<<last_separator_position <<"last_separator_position="<<last_separator_position
<<std::endl;*/ <<std::endl;*/
@ -725,7 +726,7 @@ video::IImage* generate_image_from_scratch(std::string name,
{ {
// Construct base name // Construct base name
base_image_name = name.substr(0, last_separator_position); base_image_name = name.substr(0, last_separator_position);
/*dstream<<"INFO: generate_image_from_scratch(): Calling itself recursively" /*infostream<<"generate_image_from_scratch(): Calling itself recursively"
" to get base image of \""<<name<<"\" = \"" " to get base image of \""<<name<<"\" = \""
<<base_image_name<<"\""<<std::endl;*/ <<base_image_name<<"\""<<std::endl;*/
baseimg = generate_image_from_scratch(base_image_name, device); baseimg = generate_image_from_scratch(base_image_name, device);
@ -737,12 +738,12 @@ video::IImage* generate_image_from_scratch(std::string name,
*/ */
std::string last_part_of_name = name.substr(last_separator_position+1); std::string last_part_of_name = name.substr(last_separator_position+1);
//dstream<<"last_part_of_name=\""<<last_part_of_name<<"\""<<std::endl; //infostream<<"last_part_of_name=\""<<last_part_of_name<<"\""<<std::endl;
// Generate image according to part of name // Generate image according to part of name
if(generate_image(last_part_of_name, baseimg, device) == false) if(generate_image(last_part_of_name, baseimg, device) == false)
{ {
dstream<<"INFO: generate_image_from_scratch(): " infostream<<"generate_image_from_scratch(): "
"failed to generate \""<<last_part_of_name<<"\"" "failed to generate \""<<last_part_of_name<<"\""
<<std::endl; <<std::endl;
return NULL; return NULL;
@ -762,20 +763,20 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
{ {
// A normal texture; load it from a file // A normal texture; load it from a file
std::string path = getTexturePath(part_of_name.c_str()); std::string path = getTexturePath(part_of_name.c_str());
/*dstream<<"INFO: generate_image(): Loading path \""<<path /*infostream<<"generate_image(): Loading path \""<<path
<<"\""<<std::endl;*/ <<"\""<<std::endl;*/
video::IImage *image = driver->createImageFromFile(path.c_str()); video::IImage *image = driver->createImageFromFile(path.c_str());
if(image == NULL) if(image == NULL)
{ {
dstream<<"WARNING: generate_image(): Could not load image \"" infostream<<"generate_image(): Could not load image \""
<<part_of_name<<"\" from path \""<<path<<"\"" <<part_of_name<<"\" from path \""<<path<<"\""
<<" while building texture"<<std::endl; <<" while building texture"<<std::endl;
//return false; //return false;
dstream<<"WARNING: generate_image(): Creating a dummy" infostream<<"generate_image(): Creating a dummy"
<<" image for \""<<part_of_name<<"\""<<std::endl; <<" image for \""<<part_of_name<<"\""<<std::endl;
// Just create a dummy image // Just create a dummy image
@ -800,7 +801,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
// If base image is NULL, load as base. // If base image is NULL, load as base.
if(baseimg == NULL) if(baseimg == NULL)
{ {
//dstream<<"INFO: Setting "<<part_of_name<<" as base"<<std::endl; //infostream<<"Setting "<<part_of_name<<" as base"<<std::endl;
/* /*
Copy it this way to get an alpha channel. Copy it this way to get an alpha channel.
Otherwise images with alpha cannot be blitted on Otherwise images with alpha cannot be blitted on
@ -814,7 +815,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
// Else blit on base. // Else blit on base.
else else
{ {
//dstream<<"INFO: Blitting "<<part_of_name<<" on base"<<std::endl; //infostream<<"Blitting "<<part_of_name<<" on base"<<std::endl;
// Size of the copied area // Size of the copied area
core::dimension2d<u32> dim = image->getDimension(); core::dimension2d<u32> dim = image->getDimension();
//core::dimension2d<u32> dim(16,16); //core::dimension2d<u32> dim(16,16);
@ -835,7 +836,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
{ {
// A special texture modification // A special texture modification
dstream<<"INFO: generate_image(): generating special " infostream<<"generate_image(): generating special "
<<"modification \""<<part_of_name<<"\"" <<"modification \""<<part_of_name<<"\""
<<std::endl; <<std::endl;
@ -858,7 +859,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
{ {
if(baseimg == NULL) if(baseimg == NULL)
{ {
dstream<<"WARNING: generate_image(): baseimg==NULL " infostream<<"generate_image(): baseimg==NULL "
<<"for part_of_name=\""<<part_of_name <<"for part_of_name=\""<<part_of_name
<<"\", cancelling."<<std::endl; <<"\", cancelling."<<std::endl;
return false; return false;
@ -952,7 +953,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
sf.next(":"); sf.next(":");
u32 w0 = stoi(sf.next("x")); u32 w0 = stoi(sf.next("x"));
u32 h0 = stoi(sf.next(":")); u32 h0 = stoi(sf.next(":"));
dstream<<"INFO: combined w="<<w0<<" h="<<h0<<std::endl; infostream<<"combined w="<<w0<<" h="<<h0<<std::endl;
core::dimension2d<u32> dim(w0,h0); core::dimension2d<u32> dim(w0,h0);
baseimg = driver->createImage(video::ECF_A8R8G8B8, dim); baseimg = driver->createImage(video::ECF_A8R8G8B8, dim);
while(sf.atend() == false) while(sf.atend() == false)
@ -960,7 +961,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
u32 x = stoi(sf.next(",")); u32 x = stoi(sf.next(","));
u32 y = stoi(sf.next("=")); u32 y = stoi(sf.next("="));
std::string filename = sf.next(":"); std::string filename = sf.next(":");
dstream<<"INFO: Adding \""<<filename infostream<<"Adding \""<<filename
<<"\" to combined ("<<x<<","<<y<<")" <<"\" to combined ("<<x<<","<<y<<")"
<<std::endl; <<std::endl;
video::IImage *img = driver->createImageFromFile( video::IImage *img = driver->createImageFromFile(
@ -968,7 +969,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
if(img) if(img)
{ {
core::dimension2d<u32> dim = img->getDimension(); core::dimension2d<u32> dim = img->getDimension();
dstream<<"INFO: Size "<<dim.Width infostream<<"Size "<<dim.Width
<<"x"<<dim.Height<<std::endl; <<"x"<<dim.Height<<std::endl;
core::position2d<s32> pos_base(x, y); core::position2d<s32> pos_base(x, y);
video::IImage *img2 = video::IImage *img2 =
@ -983,7 +984,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
} }
else else
{ {
dstream<<"WARNING: img==NULL"<<std::endl; infostream<<"img==NULL"<<std::endl;
} }
} }
} }
@ -995,7 +996,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
{ {
if(baseimg == NULL) if(baseimg == NULL)
{ {
dstream<<"WARNING: generate_image(): baseimg==NULL " infostream<<"generate_image(): baseimg==NULL "
<<"for part_of_name=\""<<part_of_name <<"for part_of_name=\""<<part_of_name
<<"\", cancelling."<<std::endl; <<"\", cancelling."<<std::endl;
return false; return false;
@ -1015,7 +1016,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
{ {
if(baseimg != NULL) if(baseimg != NULL)
{ {
dstream<<"WARNING: generate_image(): baseimg!=NULL " infostream<<"generate_image(): baseimg!=NULL "
<<"for part_of_name=\""<<part_of_name <<"for part_of_name=\""<<part_of_name
<<"\", cancelling."<<std::endl; <<"\", cancelling."<<std::endl;
return false; return false;
@ -1025,14 +1026,14 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
std::string path = getTexturePath(filename.c_str()); std::string path = getTexturePath(filename.c_str());
dstream<<"INFO: generate_image(): Loading path \""<<path infostream<<"generate_image(): Loading path \""<<path
<<"\""<<std::endl; <<"\""<<std::endl;
video::IImage *image = driver->createImageFromFile(path.c_str()); video::IImage *image = driver->createImageFromFile(path.c_str());
if(image == NULL) if(image == NULL)
{ {
dstream<<"WARNING: generate_image(): Loading path \"" infostream<<"generate_image(): Loading path \""
<<path<<"\" failed"<<std::endl; <<path<<"\" failed"<<std::endl;
} }
else else
@ -1062,7 +1063,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
{ {
if(baseimg != NULL) if(baseimg != NULL)
{ {
dstream<<"WARNING: generate_image(): baseimg!=NULL " infostream<<"generate_image(): baseimg!=NULL "
<<"for part_of_name=\""<<part_of_name <<"for part_of_name=\""<<part_of_name
<<"\", cancelling."<<std::endl; <<"\", cancelling."<<std::endl;
return false; return false;
@ -1076,14 +1077,14 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
std::string path = getTexturePath(filename.c_str()); std::string path = getTexturePath(filename.c_str());
dstream<<"INFO: generate_image(): Loading path \""<<path infostream<<"generate_image(): Loading path \""<<path
<<"\""<<std::endl; <<"\""<<std::endl;
video::IImage *image = driver->createImageFromFile(path.c_str()); video::IImage *image = driver->createImageFromFile(path.c_str());
if(image == NULL) if(image == NULL)
{ {
dstream<<"WARNING: generate_image(): Loading path \"" infostream<<"generate_image(): Loading path \""
<<path<<"\" failed"<<std::endl; <<path<<"\" failed"<<std::endl;
} }
else else
@ -1117,7 +1118,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
{ {
if(baseimg != NULL) if(baseimg != NULL)
{ {
dstream<<"WARNING: generate_image(): baseimg!=NULL " infostream<<"generate_image(): baseimg!=NULL "
<<"for part_of_name=\""<<part_of_name <<"for part_of_name=\""<<part_of_name
<<"\", cancelling."<<std::endl; <<"\", cancelling."<<std::endl;
return false; return false;
@ -1134,14 +1135,14 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
std::string path = getTexturePath(filename.c_str()); std::string path = getTexturePath(filename.c_str());
dstream<<"INFO: generate_image(): Loading path \""<<path infostream<<"generate_image(): Loading path \""<<path
<<"\""<<std::endl; <<"\""<<std::endl;
video::IImage *image = driver->createImageFromFile(path.c_str()); video::IImage *image = driver->createImageFromFile(path.c_str());
if(image == NULL) if(image == NULL)
{ {
dstream<<"WARNING: generate_image(): Loading path \"" infostream<<"generate_image(): Loading path \""
<<path<<"\" failed"<<std::endl; <<path<<"\" failed"<<std::endl;
} }
else else
@ -1180,7 +1181,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
{ {
if(baseimg != NULL) if(baseimg != NULL)
{ {
dstream<<"WARNING: generate_image(): baseimg!=NULL " infostream<<"generate_image(): baseimg!=NULL "
<<"for part_of_name=\""<<part_of_name <<"for part_of_name=\""<<part_of_name
<<"\", cancelling."<<std::endl; <<"\", cancelling."<<std::endl;
return false; return false;
@ -1198,7 +1199,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
if(driver->queryFeature(video::EVDF_RENDER_TO_TARGET) == false) if(driver->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"<<std::endl; " not supported. Creating fallback image"<<std::endl;
baseimg = generate_image_from_scratch( baseimg = generate_image_from_scratch(
imagename_top, device); imagename_top, device);
@ -1207,7 +1208,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
u32 w0 = 64; u32 w0 = 64;
u32 h0 = 64; u32 h0 = 64;
//dstream<<"INFO: inventorycube w="<<w0<<" h="<<h0<<std::endl; //infostream<<"inventorycube w="<<w0<<" h="<<h0<<std::endl;
core::dimension2d<u32> dim(w0,h0); core::dimension2d<u32> dim(w0,h0);
// Generate images for the faces of the cube // Generate images for the faces of the cube
@ -1309,7 +1310,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
} }
else else
{ {
dstream<<"WARNING: generate_image(): Invalid " infostream<<"generate_image(): Invalid "
" modification: \""<<part_of_name<<"\""<<std::endl; " modification: \""<<part_of_name<<"\""<<std::endl;
} }
} }

View File

@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gettime.h" #include "gettime.h"
#include "sha1.h" #include "sha1.h"
#include "base64.h" #include "base64.h"
#include "log.h"
TimeTaker::TimeTaker(const char *name, u32 *result) TimeTaker::TimeTaker(const char *name, u32 *result)
{ {
@ -47,7 +48,7 @@ u32 TimeTaker::stop(bool quiet)
else else
{ {
if(quiet == false) if(quiet == false)
std::cout<<m_name<<" took "<<dtime<<"ms"<<std::endl; infostream<<m_name<<" took "<<dtime<<"ms"<<std::endl;
} }
m_running = false; m_running = false;
return dtime; return dtime;
@ -156,6 +157,21 @@ void mysrand(unsigned seed)
next = seed; next = seed;
} }
int myrand_range(int min, int max)
{
if(max-min > MYRAND_MAX)
{
errorstream<<"WARNING: myrand_range: max-min > MYRAND_MAX"<<std::endl;
assert(0);
}
if(min > max)
{
assert(0);
return max;
}
return (myrand()%(max-min+1))+min;
}
#ifndef SERVER #ifndef SERVER
// Sets the color of all vertices in the mesh // Sets the color of all vertices in the mesh
void setMeshVerticesColor(scene::IMesh* mesh, video::SColor& color) void setMeshVerticesColor(scene::IMesh* mesh, video::SColor& color)

View File

@ -1230,20 +1230,7 @@ int myrand(void);
void mysrand(unsigned seed); void mysrand(unsigned seed);
#define MYRAND_MAX 32767 #define MYRAND_MAX 32767
inline int myrand_range(int min, int max) int myrand_range(int min, int max);
{
if(max-min > MYRAND_MAX)
{
dstream<<"WARNING: myrand_range: max-min > MYRAND_MAX"<<std::endl;
assert(0);
}
if(min > max)
{
assert(0);
return max;
}
return (myrand()%(max-min+1))+min;
}
/* /*
Miscellaneous functions Miscellaneous functions