#include "mapblock.h"
#include "settings.h"
#include "profiler.h"
+#include "log.h"
/*
QueuedMeshUpdate
{
ThreadStarted();
+ log_register_thread("MeshUpdateThread");
+
DSTACK(__FUNCTION_NAME);
BEGIN_DEBUG_EXCEPTION_HANDLER
r.mesh = mesh_new;
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<<")"
<<std::endl;*/
delete q;
}
- END_DEBUG_EXCEPTION_HANDLER
+ END_DEBUG_EXCEPTION_HANDLER(errorstream)
return NULL;
}
else
m_ignore_damage_timer = 0.0;
- //dstream<<"Client steps "<<dtime<<std::endl;
+ //infostream<<"Client steps "<<dtime<<std::endl;
{
//TimeTaker timer("ReceiveAll()", m_device);
{
counter = 20.0;
- dout_client<<"Client packetcounter (20s):"<<std::endl;
- m_packetcounter.print(dout_client);
+ infostream<<"Client packetcounter (20s):"<<std::endl;
+ m_packetcounter.print(infostream);
m_packetcounter.clear();
}
}
if(deleted_blocks.size() > 0)
{
- /*dstream<<DTIME<<"Client: Deleted blocks of "<<num
+ /*infostream<<"Client: Deleted blocks of "<<num
<<" unused sectors"<<std::endl;*/
- /*dstream<<DTIME<<"Client: Deleted "<<num
+ /*infostream<<"Client: Deleted "<<num
<<" unused sectors"<<std::endl;*/
/*
memset((char*)&data[3], 0, PLAYERNAME_SIZE);
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;*/
memset((char*)&data[23], 0, PASSWORD_SIZE);
&deleted_blocks);
/*if(deleted_blocks.size() > 0)
- dstream<<"Client: Unloaded "<<deleted_blocks.size()
+ infostream<<"Client: Unloaded "<<deleted_blocks.size()
<<" unused blocks"<<std::endl;*/
/*
//JMutexAutoLock lock(m_con_mutex); //bulk comment-out
// connectedAndInitialized() is true, peer exists.
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;
}
}
//TimeTaker timer("** Processing mesh update result queue");
// 0ms
- /*dstream<<"Mesh update result queue size is "
+ /*infostream<<"Mesh update result queue size is "
<<m_mesh_update_thread.m_queue_out.size()
<<std::endl;*/
}
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;*/
/*
Acknowledge block
// Virtual methods from con::PeerHandler
void Client::peerAdded(con::Peer *peer)
{
- derr_client<<"Client::peerAdded(): peer->id="
+ infostream<<"Client::peerAdded(): peer->id="
<<peer->id<<std::endl;
}
void Client::deletingPeer(con::Peer *peer, bool timeout)
{
- derr_client<<"Client::deletingPeer(): "
+ infostream<<"Client::deletingPeer(): "
"Server Peer is getting deleted "
<<"(timeout="<<timeout<<")"<<std::endl;
}
}
catch(con::InvalidIncomingDataException &e)
{
- dout_client<<DTIME<<"Client::ReceiveAll(): "
+ infostream<<"Client::ReceiveAll(): "
"InvalidIncomingDataException: what()="
<<e.what()<<std::endl;
}
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);
/*
*/
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
<<std::endl;
return;
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)
{
u8 deployed = data[2];
- dout_client<<DTIME<<"Client: TOCLIENT_INIT received with "
+ infostream<<"Client: TOCLIENT_INIT received with "
"deployed="<<((int)deployed&0xff)<<std::endl;
if(deployed < SER_FMT_VER_LOWEST
|| 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;
return;
}
{
// Get map seed
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
if(ser_version == SER_FMT_VER_INVALID)
{
- dout_client<<DTIME<<"WARNING: Client: Server serialization"
+ infostream<<"Client: Server serialization"
" format invalid or not initialized."
" Skipping incoming command="<<command<<std::endl;
return;
p.Y = readS16(&data[4]);
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;*/
- /*dstream<<DTIME<<"Client: Thread: BLOCKDATA for ("
+ /*infostream<<"Client: Thread: BLOCKDATA for ("
<<p.X<<","<<p.Y<<","<<p.Z<<")"<<std::endl;*/
std::string datastring((char*)&data[8], datasize-8);
/*
Update an existing block
*/
- //dstream<<"Updating"<<std::endl;
+ //infostream<<"Updating"<<std::endl;
block->deSerialize(istr, ser_version);
}
else
/*
Create a new block
*/
- //dstream<<"Creating new"<<std::endl;
+ //infostream<<"Creating new"<<std::endl;
block = new MapBlock(&m_env.getMap(), p);
block->deSerialize(istr, ser_version);
sector->insertBlock(block);
/*
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);
}
else if(command == TOCLIENT_PLAYERPOS)
{
- dstream<<"WARNING: Received deprecated TOCLIENT_PLAYERPOS"
+ infostream<<"Received deprecated TOCLIENT_PLAYERPOS"
<<std::endl;
/*u16 our_peer_id;
{
}
// Cancel if we don't have a peer id
if(our_peer_id == PEER_ID_INEXISTENT){
- dout_client<<DTIME<<"TOCLIENT_PLAYERPOS cancelled: "
+ infostream<<"TOCLIENT_PLAYERPOS cancelled: "
"we have no peer id"
<<std::endl;
return;
v3s32 ss = readV3S32(&data[start+2+12]);
s32 pitch_i = readS32(&data[start+2+12+12]);
s32 yaw_i = readS32(&data[start+2+12+12+4]);
- /*dstream<<"Client: got "
+ /*infostream<<"Client: got "
<<"pitch_i="<<pitch_i
<<" yaw_i="<<yaw_i<<std::endl;*/
f32 pitch = (f32)pitch_i / 100.0;
player->setPitch(pitch);
player->setYaw(yaw);
- /*dstream<<"Client: player "<<peer_id
+ /*infostream<<"Client: player "<<peer_id
<<" pitch="<<pitch
<<" yaw="<<yaw<<std::endl;*/
}
// Cancel if we don't have a peer id
if(our_peer_id == PEER_ID_INEXISTENT){
- dout_client<<DTIME<<"TOCLIENT_PLAYERINFO cancelled: "
+ infostream<<"TOCLIENT_PLAYERINFO cancelled: "
"we have no peer id"
<<std::endl;
return;
}
- //dstream<<DTIME<<"Client: Server reports players:"<<std::endl;
+ //infostream<<"Client: Server reports players:"<<std::endl;
{ //envlock
//JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
players_alive.push_back(peer_id);
- /*dstream<<DTIME<<"peer_id="<<peer_id
+ /*infostream<<"peer_id="<<peer_id
<<" name="<<((char*)&data[start+2])<<std::endl;*/
// Don't update the info of the local player
-1);
player->peer_id = peer_id;
m_env.addPlayer(player);
- dout_client<<DTIME<<"Client: Adding new player "
+ infostream<<"Client: Adding new player "
<<peer_id<<std::endl;
}
Remove those players from the environment that
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*>::Iterator ip;
for(ip=players.begin(); ip!=players.end(); ip++)
// Warn about a special case
if((*ip)->peer_id == 0)
{
- dstream<<DTIME<<"WARNING: Client: Removing "
+ infostream<<"Client: Removing "
"dead player with id=0"<<std::endl;
}
break;
}
}
- /*dstream<<DTIME<<"peer_id="<<((*ip)->peer_id)
+ /*infostream<<"peer_id="<<((*ip)->peer_id)
<<" is_alive="<<is_alive<<std::endl;*/
if(is_alive)
continue;
- dstream<<DTIME<<"Removing dead player "<<(*ip)->peer_id
+ infostream<<"Removing dead player "<<(*ip)->peer_id
<<std::endl;
m_env.removePlayer((*ip)->peer_id);
}
}
else if(command == TOCLIENT_SECTORMETA)
{
- dstream<<"Client received DEPRECATED TOCLIENT_SECTORMETA"<<std::endl;
+ infostream<<"Client received DEPRECATED TOCLIENT_SECTORMETA"<<std::endl;
#if 0
/*
[0] u16 command
if(datasize < 3)
return;
- //dstream<<"Client received TOCLIENT_SECTORMETA"<<std::endl;
+ //infostream<<"Client received TOCLIENT_SECTORMETA"<<std::endl;
{ //envlock
//JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
is.read((char*)buf, 1);
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++)
{
// Read position
is.read((char*)buf, 4);
v2s16 pos = readV2S16(buf);
- /*dstream<<"Client: deserializing sector at "
+ /*infostream<<"Client: deserializing sector at "
<<"("<<pos.X<<","<<pos.Y<<")"<<std::endl;*/
// Create sector
assert(m_env.getMap().mapType() == MAPTYPE_CLIENT);
std::istringstream is(datastring, std::ios_base::binary);
//t3.stop();
- //m_env.printPlayers(dstream);
+ //m_env.printPlayers(infostream);
//TimeTaker t4("player get", m_device);
Player *player = m_env.getLocalPlayer();
m_inventory_updated = true;
- //dstream<<"Client got player inventory:"<<std::endl;
- //player->inventory.print(dstream);
+ //infostream<<"Client got player inventory:"<<std::endl;
+ //player->inventory.print(infostream);
}
}
//DEBUG
// Read active block count
u16 blockcount = readU16(is);
if(blockcount != 0){
- dstream<<"WARNING: TOCLIENT_OBJECTDATA: blockcount != 0 "
+ infostream<<"TOCLIENT_OBJECTDATA: blockcount != 0 "
"not supported"<<std::endl;
return;
}
u16 time_of_day = readU16(&data[2]);
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:
u32 dr = m_env.getDayNightRatio();
- dstream<<"Client: time_of_day="<<time_of_day
+ infostream<<"Client: time_of_day="<<time_of_day
<<", dr="<<dr
<<std::endl;
}
message += (wchar_t)readU16(buf);
}
- /*dstream<<"Client received chat message: "
+ /*infostream<<"Client received chat message: "
<<wide_to_narrow(message)<<std::endl;*/
m_chat_queue.push_back(message);
/*player->setPitch(pitch);
player->setYaw(yaw);*/
- dstream<<"Client got TOCLIENT_MOVE_PLAYER"
+ infostream<<"Client got TOCLIENT_MOVE_PLAYER"
<<" pos=("<<pos.X<<","<<pos.Y<<","<<pos.Z<<")"
<<" pitch="<<pitch
<<" yaw="<<yaw
if (player == NULL)
{
- dout_client<<DTIME<<"Client: ignoring player item "
+ infostream<<"Client: ignoring player item "
<< deSerializeString(is)
<< " for non-existing peer id " << peer_id
<< std::endl;
continue;
} else if (player->isLocal()) {
- dout_client<<DTIME<<"Client: ignoring player item "
+ infostream<<"Client: ignoring player item "
<< deSerializeString(is)
<< " for local player" << std::endl;
continue;
std::string itemstring(deSerializeString(is));
if (itemstring.empty()) {
inv->deleteItem(0);
- dout_client<<DTIME
+ infostream
<<"Client: empty player item for peer "
<< peer_id << std::endl;
} else {
std::istringstream iss(itemstring);
delete inv->changeItem(0, InventoryItem::deSerialize(iss));
- dout_client<<DTIME<<"Client: player item for peer " << peer_id << ": ";
- player->getWieldItem()->serialize(dout_client);
- dout_client<<std::endl;
+ infostream<<"Client: player item for peer " << peer_id << ": ";
+ player->getWieldItem()->serialize(infostream);
+ infostream<<std::endl;
}
}
}
}
else
{
- dout_client<<DTIME<<"WARNING: Client: Ignoring unknown command "
+ infostream<<"Client: Ignoring unknown command "
<<command<<std::endl;
}
}
v3s16 nodepos_oversurface, u16 item)
{
if(connectedAndInitialized() == false){
- dout_client<<DTIME<<"Client::groundAction() "
+ infostream<<"Client::groundAction() "
"cancelled (not connected)"
<<std::endl;
return;
void Client::clickActiveObject(u8 button, u16 id, u16 item_i)
{
if(connectedAndInitialized() == false){
- dout_client<<DTIME<<"Client::clickActiveObject() "
+ infostream<<"Client::clickActiveObject() "
"cancelled (not connected)"
<<std::endl;
return;
NodeMetadata* meta = getNodeMetadata(p);
if(meta)
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;
return NULL;
}
- dstream<<__FUNCTION_NAME<<": unknown id "<<id<<std::endl;
+ infostream<<__FUNCTION_NAME<<": unknown id "<<id<<std::endl;
return NULL;
}
void Client::inventoryAction(InventoryAction *a)
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.
// After this, the closest object is the first in the array.
if(offsetted_box.intersectsWithLine(shootline_on_map))
{
- //dstream<<"Returning selected object"<<std::endl;
+ //infostream<<"Returning selected object"<<std::endl;
return obj;
}
}
- //dstream<<"No object selected; returning NULL."<<std::endl;
+ //infostream<<"No object selected; returning NULL."<<std::endl;
return NULL;
}
void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server)
{
- /*dstream<<"Client::addUpdateMeshTask(): "
+ /*infostream<<"Client::addUpdateMeshTask(): "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;*/
// Add task to queue
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()
<<std::endl;*/
{
/*{
v3s16 p = blockpos;
- dstream<<"Client::addUpdateMeshTaskWithEdge(): "
+ infostream<<"Client::addUpdateMeshTaskWithEdge(): "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;
}*/
if(m_node)
{
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;
m_node->setRotation(rot);
}
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);
u16 cmd;
is>>cmd;
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);
// command
u8 cmd = readU8(is);
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);
try{
InventoryItem *item = NULL;
item = InventoryItem::deSerialize(is);
- dstream<<__FUNCTION_NAME<<": m_inventorystring=\""
+ infostream<<__FUNCTION_NAME<<": m_inventorystring=\""
<<m_inventorystring<<"\" -> item="<<item
<<std::endl;
if(item)
}
catch(SerializationError &e)
{
- dstream<<"WARNING: "<<__FUNCTION_NAME
+ infostream<<"WARNING: "<<__FUNCTION_NAME
<<": error deSerializing inventorystring \""
<<m_inventorystring<<"\""<<std::endl;
}
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);
// command
u8 cmd = readU8(is);
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);
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);
// command
u8 cmd = readU8(is);
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);
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);
// command
u8 cmd = readU8(is);
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);
if(m_node != NULL)
return;
- /*dstream<<"MobV2CAO::addToScene using texture_name="<<
+ /*infostream<<"MobV2CAO::addToScene using texture_name="<<
m_texture_name<<std::endl;*/
std::string texture_string = "[makealpha2:128,0,0;128,128,0:";
texture_string += m_texture_name;
bill->setTCoords(2, v2f(txs*0, tys*0));
bill->setTCoords(3, v2f(txs*0, tys*1));
} else {
- dstream<<"MobV2CAO: Unknown sprite type \""<<m_sprite_type<<"\""
+ infostream<<"MobV2CAO: Unknown sprite type \""<<m_sprite_type<<"\""
<<std::endl;
}
float mob_dir = atan2(cam_to_mob.Z, cam_to_mob.X) / PI * 180.;
float dir = mob_dir - m_yaw;
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)
col = 2;
else if(fabs(wrapDegrees_180(dir - 90)) <= 45.1)
bill->setTCoords(2, v2f(txs*(0+col), tys*(0+row)));
bill->setTCoords(3, v2f(txs*(0+col), tys*(1+row)));
} else {
- dstream<<"MobV2CAO::step(): Unknown sprite type \""
+ infostream<<"MobV2CAO::step(): Unknown sprite type \""
<<m_sprite_type<<"\""<<std::endl;
}
if(m_damage_visual_timer >= 0){
m_damage_visual_timer -= dtime;
if(m_damage_visual_timer <= 0){
- dstream<<"id="<<m_id<<" damage visual ended"<<std::endl;
+ infostream<<"id="<<m_id<<" damage visual ended"<<std::endl;
}
}
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);
// command
u8 cmd = readU8(is);
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);
u8 version = readU8(is);
// check version
if(version != 0){
- dstream<<__FUNCTION_NAME<<": Invalid version"<<std::endl;
+ infostream<<__FUNCTION_NAME<<": Invalid version"<<std::endl;
return;
}
std::istringstream tmp_is(tmp_os.str(), std::ios::binary);
m_properties->parseConfigLines(tmp_is, "MobArgsEnd");
- dstream<<"INFO: MobV2CAO::initialize(): got properties:"<<std::endl;
- m_properties->writeLines(dstream);
+ infostream<<"MobV2CAO::initialize(): got properties:"<<std::endl;
+ m_properties->writeLines(infostream);
m_properties->setDefault("looks", "dummy_default");
m_properties->setDefault("yaw", "0");
if(m_timer1 < 0.0)
{
m_timer1 += 0.125;
- //dstream<<"TestSAO: id="<<getId()<<" sending data"<<std::endl;
+ //infostream<<"TestSAO: id="<<getId()<<" sending data"<<std::endl;
std::string data;
if(version != 0)
return NULL;
std::string inventorystring = deSerializeString(is);
- dstream<<"ItemSAO::create(): Creating item \""
+ infostream<<"ItemSAO::create(): Creating item \""
<<inventorystring<<"\""<<std::endl;
return new ItemSAO(env, id, pos, inventorystring);
}
std::string ItemSAO::getStaticData()
{
- dstream<<__FUNCTION_NAME<<std::endl;
+ infostream<<__FUNCTION_NAME<<std::endl;
std::ostringstream os(std::ios::binary);
char buf[1];
// version
try{
std::istringstream is(m_inventorystring, std::ios_base::binary);
InventoryItem *item = InventoryItem::deSerialize(is);
- dstream<<__FUNCTION_NAME<<": m_inventorystring=\""
+ infostream<<__FUNCTION_NAME<<": m_inventorystring=\""
<<m_inventorystring<<"\" -> item="<<item
<<std::endl;
return item;
}
catch(SerializationError &e)
{
- dstream<<__FUNCTION_NAME<<": serialization error: "
+ infostream<<__FUNCTION_NAME<<": serialization error: "
<<"m_inventorystring=\""<<m_inventorystring<<"\""<<std::endl;
return NULL;
}
void ItemSAO::rightClick(Player *player)
{
- dstream<<__FUNCTION_NAME<<std::endl;
+ infostream<<__FUNCTION_NAME<<std::endl;
InventoryItem *item = createInventoryItem();
if(item == NULL)
return;
std::string RatSAO::getStaticData()
{
- //dstream<<__FUNCTION_NAME<<std::endl;
+ //infostream<<__FUNCTION_NAME<<std::endl;
std::ostringstream os(std::ios::binary);
// version
writeU8(os, 0);
std::string Oerkki1SAO::getStaticData()
{
- //dstream<<__FUNCTION_NAME<<std::endl;
+ //infostream<<__FUNCTION_NAME<<std::endl;
std::ostringstream os(std::ios::binary);
// version
writeU8(os, 0);
void Oerkki1SAO::doDamage(u16 d)
{
- dstream<<"oerkki damage: "<<d<<std::endl;
+ infostream<<"oerkki damage: "<<d<<std::endl;
if(d < m_hp)
{
std::string FireflySAO::getStaticData()
{
- //dstream<<__FUNCTION_NAME<<std::endl;
+ //infostream<<__FUNCTION_NAME<<std::endl;
std::ostringstream os(std::ios::binary);
// version
writeU8(os, 0);
std::string MobV2SAO::getClientInitializationData()
{
- //dstream<<__FUNCTION_NAME<<std::endl;
+ //infostream<<__FUNCTION_NAME<<std::endl;
updateProperties();
if(dist < BS*16)
{
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;
m_disturbing_player = player->getName();
m_disturb_timer = 0;
dir.normalize();
v3f speed = dir * BS * 10.0;
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;
Settings properties;
properties.set("looks", "fireball");
//m_env->addActiveObjectAsStatic(obj);
m_env->addActiveObject(obj);
} else {
- dstream<<__FUNCTION_NAME<<": Unknown shoot_type="<<shoot_type
+ infostream<<__FUNCTION_NAME<<": Unknown shoot_type="<<shoot_type
<<std::endl;
}
}
m_base_position = pos_f;
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;
}
}
}
u32 order[3*3*3];
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++){
- dstream<<order[i]<<" ";
+ infostream<<order[i]<<" ";
}
- dstream<<std::endl;*/
+ infostream<<std::endl;*/
for(int i=0; i<num_dps; i++){
v3s16 p = dps[order[i]] + pos_i;
bool is_free = checkFreeAndWalkablePosition(map,
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)
continue;
m_next_pos_i = p;
}
else
{
- dstream<<"MobV2SAO::step(): id="<<m_id<<" unknown move_type=\""
+ infostream<<"MobV2SAO::step(): id="<<m_id<<" unknown move_type=\""
<<m_move_type<<"\""<<std::endl;
}
assert(m_env);
Map *map = &m_env->getMap();
- dstream<<"ACTION: "<<playername<<" punches id="<<m_id
- <<" with a \""<<toolname<<"\""<<std::endl;
+ infostream<<"ACTION: "<<playername<<" punches id="<<m_id
+ <<" with a \""<<toolname<<"\" at "
+ <<PP(m_base_position/BS)<<std::endl;
m_disturb_timer = 0;
m_disturbing_player = playername;
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)
{
}
else
{
+ actionstream<<"A "<<(isPeaceful()?"peaceful":"non-peaceful")
+ <<" mob id="<<m_id<<" dies at "<<PP(m_base_position)<<std::endl;
// Die
m_hp = 0;
m_removed = true;
#if CATCH_UNHANDLED_EXCEPTIONS == 1
#define BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER try{
- #define END_PORTABLE_DEBUG_EXCEPTION_HANDLER\
+ #define END_PORTABLE_DEBUG_EXCEPTION_HANDLER(logstream)\
}catch(std::exception &e){\
- dstream<<std::endl<<DTIME\
- <<"ERROR: An unhandled exception occurred: "\
+ logstream<<"ERROR: An unhandled exception occurred: "\
<<e.what()<<std::endl;\
assert(0);\
}
BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER\
_set_se_translator(se_trans_func);
- #define END_DEBUG_EXCEPTION_HANDLER \
- END_PORTABLE_DEBUG_EXCEPTION_HANDLER
+ #define END_DEBUG_EXCEPTION_HANDLER(logstream) \
+ END_PORTABLE_DEBUG_EXCEPTION_HANDLER(logstream)
#else // Probably mingw
#define BEGIN_DEBUG_EXCEPTION_HANDLER\
BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER
- #define END_DEBUG_EXCEPTION_HANDLER\
- END_PORTABLE_DEBUG_EXCEPTION_HANDLER
+ #define END_DEBUG_EXCEPTION_HANDLER(logstream)\
+ END_PORTABLE_DEBUG_EXCEPTION_HANDLER(logstream)
#endif
#else // Posix
#define BEGIN_DEBUG_EXCEPTION_HANDLER\
BEGIN_PORTABLE_DEBUG_EXCEPTION_HANDLER
- #define END_DEBUG_EXCEPTION_HANDLER\
- END_PORTABLE_DEBUG_EXCEPTION_HANDLER
+ #define END_DEBUG_EXCEPTION_HANDLER(logstream)\
+ END_PORTABLE_DEBUG_EXCEPTION_HANDLER(logstream)
#endif
#else
// Dummy ones
#define BEGIN_DEBUG_EXCEPTION_HANDLER
- #define END_DEBUG_EXCEPTION_HANDLER
+ #define END_DEBUG_EXCEPTION_HANDLER(logstream)
#endif
#endif // DEBUG_HEADER
#include "content_sao.h"
#include "mapgen.h"
#include "settings.h"
+#include "log.h"
+
+#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
Environment::Environment():
m_time_of_day(9000)
// Full path to this file
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
ServerRemotePlayer testplayer;
std::ifstream is(path.c_str(), std::ios_base::binary);
if(is.good() == false)
{
- dstream<<"Failed to read "<<path<<std::endl;
+ infostream<<"Failed to read "<<path<<std::endl;
continue;
}
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
std::string playername = testplayer.getName();
Player *player = getPlayer(playername.c_str());
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;
}
- //dstream<<"Found matching player, overwriting."<<std::endl;
+ //infostream<<"Found matching player, overwriting."<<std::endl;
// OK, found. Save player there.
{
std::ofstream os(path.c_str(), std::ios_base::binary);
if(os.good() == false)
{
- dstream<<"Failed to overwrite "<<path<<std::endl;
+ infostream<<"Failed to overwrite "<<path<<std::endl;
continue;
}
player->serialize(os);
Player *player = *i;
if(saved_players.find(player) != NULL)
{
- /*dstream<<"Player "<<player->getName()
+ /*infostream<<"Player "<<player->getName()
<<" was already saved."<<std::endl;*/
continue;
}
// Don't save unnamed player
if(playername == "")
{
- //dstream<<"Not saving unnamed player."<<std::endl;
+ //infostream<<"Not saving unnamed player."<<std::endl;
continue;
}
/*
}
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;
}
{
- /*dstream<<"Saving player "<<player->getName()<<" to "
+ /*infostream<<"Saving player "<<player->getName()<<" to "
<<path<<std::endl;*/
// Open file and serialize
std::ofstream os(path.c_str(), std::ios_base::binary);
if(os.good() == false)
{
- dstream<<"WARNING: Failed to overwrite "<<path<<std::endl;
+ infostream<<"Failed to overwrite "<<path<<std::endl;
continue;
}
player->serialize(os);
}
}
- //dstream<<"Saved "<<saved_players.size()<<" players."<<std::endl;
+ //infostream<<"Saved "<<saved_players.size()<<" players."<<std::endl;
}
void ServerEnvironment::deSerializePlayers(const std::string &savedir)
// Full path to this file
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
ServerRemotePlayer testplayer;
std::ifstream is(path.c_str(), std::ios_base::binary);
if(is.good() == false)
{
- dstream<<"Failed to read "<<path<<std::endl;
+ infostream<<"Failed to read "<<path<<std::endl;
continue;
}
testplayer.deSerialize(is);
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;
}
- dstream<<"Loaded test player with name "<<testplayer.getName()
+ infostream<<"Loaded test player with name "<<testplayer.getName()
<<std::endl;
// Search for the player
bool newplayer = false;
if(player == NULL)
{
- dstream<<"Is a new player"<<std::endl;
+ infostream<<"Is a new player"<<std::endl;
player = new ServerRemotePlayer();
newplayer = true;
}
// Load player
{
- dstream<<"Reading player "<<testplayer.getName()<<" from "
+ infostream<<"Reading player "<<testplayer.getName()<<" from "
<<path<<std::endl;
// Open file and deserialize
std::ifstream is(path.c_str(), std::ios_base::binary);
if(is.good() == false)
{
- dstream<<"Failed to read "<<path<<std::endl;
+ infostream<<"Failed to read "<<path<<std::endl;
continue;
}
player->deSerialize(is);
std::ofstream os(path.c_str(), std::ios_base::binary);
if(os.good() == false)
{
- dstream<<"WARNING: ServerEnvironment::saveMeta(): Failed to open "
+ infostream<<"ServerEnvironment::saveMeta(): Failed to open "
<<path<<std::endl;
throw SerializationError("Couldn't save env meta");
}
std::ifstream is(path.c_str(), std::ios_base::binary);
if(is.good() == false)
{
- dstream<<"WARNING: ServerEnvironment::loadMeta(): Failed to open "
+ infostream<<"ServerEnvironment::loadMeta(): Failed to open "
<<path<<std::endl;
throw SerializationError("Couldn't load env meta");
}
// Set current time as timestamp (and let it set ChangedFlag)
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
activateObjects(block);
{
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;*/
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
{
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;*/
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
{
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;*/
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
{
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;*/
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
v3f pos = intToFloat(p1, BS);
int i = myrand()%5;
if(i == 0 || i == 1){
+ actionstream<<"A dungeon master spawns at "
+ <<PP(p1)<<std::endl;
Settings properties;
getMob_dungeon_master(properties);
ServerActiveObject *obj = new MobV2SAO(
this, 0, pos, &properties);
addActiveObject(obj);
} else if(i == 2 || i == 3){
+ actionstream<<"Rats spawn at "
+ <<PP(p1)<<std::endl;
for(int j=0; j<3; j++){
ServerActiveObject *obj = new RatSAO(
this, 0, pos);
addActiveObject(obj);
}
} else {
+ actionstream<<"An oerkki spawns at "
+ <<PP(p1)<<std::endl;
ServerActiveObject *obj = new Oerkki1SAO(
this, 0, pos);
addActiveObject(obj);
{
if(myrand()%50 == 0)
{
+ actionstream<<"A sapling grows into a tree at "
+ <<PP(p)<<std::endl;
+
core::map<v3s16, MapBlock*> modified_blocks;
v3s16 tree_p = p;
ManualMapVoxelManipulator vmanip(m_map);
//ServerActiveObject *obj = new Oerkki1SAO(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;
Settings properties;
succeeded = true;
}
else{
- dstream<<"WARNING: ServerEnvironment::addActiveObjectAsStatic: "
+ infostream<<"ServerEnvironment::addActiveObjectAsStatic: "
<<"Could not find or generate "
<<"a block for storing static object"<<std::endl;
succeeded = false;
ServerActiveObject *object = getActiveObject(id);
if(object == NULL)
{
- dstream<<"WARNING: ServerEnvironment::getRemovedActiveObjects():"
+ infostream<<"ServerEnvironment::getRemovedActiveObjects():"
<<" object in current_objects is NULL"<<std::endl;
}
else if(object->m_removed == false)
{
f32 distance_f = object->getBasePosition().getDistanceFrom(pos_f);
- /*dstream<<"removed == false"
+ /*infostream<<"removed == false"
<<"distance_f = "<<distance_f
<<", radius_f = "<<radius_f<<std::endl;*/
if(distance_f < radius_f)
u16 new_id = getFreeServerActiveObjectId(m_active_objects);
if(new_id == 0)
{
- dstream<<"WARNING: ServerEnvironment::addActiveObjectRaw(): "
+ infostream<<"ServerEnvironment::addActiveObjectRaw(): "
<<"no free ids available"<<std::endl;
delete object;
return 0;
}
if(isFreeServerActiveObjectId(object->getId(), m_active_objects) == false)
{
- dstream<<"WARNING: ServerEnvironment::addActiveObjectRaw(): "
+ infostream<<"ServerEnvironment::addActiveObjectRaw(): "
<<"id is not free ("<<object->getId()<<")"<<std::endl;
delete object;
return 0;
}
- /*dstream<<"INFO: ServerEnvironment::addActiveObjectRaw(): "
+ /*infostream<<"ServerEnvironment::addActiveObjectRaw(): "
<<"added (id="<<object->getId()<<")"<<std::endl;*/
m_active_objects.insert(object->getId(), object);
block->setChangedFlag();
}
else{
- dstream<<"WARNING: ServerEnv: Could not find a block for "
+ infostream<<"ServerEnv: Could not find a block for "
<<"storing newly added static active object"<<std::endl;
}
// This shouldn't happen but check it
if(obj == NULL)
{
- dstream<<"WARNING: NULL object found in ServerEnvironment"
+ infostream<<"NULL object found in ServerEnvironment"
<<" while finding removed objects. id="<<id<<std::endl;
// Id to be removed from m_active_objects
objects_to_remove.push_back(id);
i = block->m_static_objects.m_stored.begin();
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;*/
StaticObject &s_obj = *i;
// Create an active object from the data
// This shouldn't happen but check it
if(obj == NULL)
{
- dstream<<"WARNING: NULL object found in ServerEnvironment"
+ infostream<<"NULL object found in ServerEnvironment"
<<std::endl;
assert(0);
continue;
obj->m_static_block = block->getPos();
}
else{
- dstream<<"WARNING: ServerEnv: Could not find or generate "
+ infostream<<"ServerEnv: Could not find or generate "
<<"a block for storing static object"<<std::endl;
obj->m_static_exists = false;
continue;
continue;
}
- /*dstream<<"INFO: Server: Stored static data. Deleting object."
+ /*infostream<<"Server: Stored static data. Deleting object."
<<std::endl;*/
// Delete active object
delete obj;
u16 new_id = getFreeClientActiveObjectId(m_active_objects);
if(new_id == 0)
{
- dstream<<"WARNING: ClientEnvironment::addActiveObject(): "
+ infostream<<"ClientEnvironment::addActiveObject(): "
<<"no free ids available"<<std::endl;
delete object;
return 0;
}
if(isFreeClientActiveObjectId(object->getId(), m_active_objects) == false)
{
- dstream<<"WARNING: ClientEnvironment::addActiveObject(): "
+ infostream<<"ClientEnvironment::addActiveObject(): "
<<"id is not free ("<<object->getId()<<")"<<std::endl;
delete object;
return 0;
}
- dstream<<"INFO: ClientEnvironment::addActiveObject(): "
+ infostream<<"ClientEnvironment::addActiveObject(): "
<<"added (id="<<object->getId()<<")"<<std::endl;
m_active_objects.insert(object->getId(), object);
object->addToScene(m_smgr);
ClientActiveObject* obj = ClientActiveObject::create(type);
if(obj == NULL)
{
- dstream<<"WARNING: ClientEnvironment::addActiveObject(): "
+ infostream<<"ClientEnvironment::addActiveObject(): "
<<"id="<<id<<" type="<<type<<": Couldn't create object"
<<std::endl;
return;
void ClientEnvironment::removeActiveObject(u16 id)
{
- dstream<<"ClientEnvironment::removeActiveObject(): "
+ infostream<<"ClientEnvironment::removeActiveObject(): "
<<"id="<<id<<std::endl;
ClientActiveObject* obj = getActiveObject(id);
if(obj == NULL)
{
- dstream<<"WARNING: ClientEnvironment::removeActiveObject(): "
+ infostream<<"ClientEnvironment::removeActiveObject(): "
<<"id="<<id<<" not found"<<std::endl;
return;
}
ClientActiveObject* obj = getActiveObject(id);
if(obj == NULL)
{
- dstream<<"WARNING: ClientEnvironment::processActiveObjectMessage():"
+ infostream<<"ClientEnvironment::processActiveObjectMessage():"
<<" got message for id="<<id<<", which doesn't exist."
<<std::endl;
return;
#include "profiler.h"
#include "mainmenumanager.h"
#include "gettext.h"
+#include "log.h"
/*
TODO: Move content-aware stuff to separate file by adding properties
void gotText(std::wstring 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;
m_client->sendSignNodeText(m_p, ntext);
}
InventoryList *mainlist = inventory->getList("main");
if(mainlist == NULL)
{
- dstream<<"WARNING: draw_hotbar(): mainlist == NULL"<<std::endl;
+ errorstream<<"draw_hotbar(): mainlist == NULL"<<std::endl;
return;
}
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;*/
s16 a = d;
SharedPtr<Server> server;
if(address == ""){
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->start(port);
}
*/
draw_load_screen(L"Creating client...", driver, font);
- dstream<<DTIME<<"Creating client"<<std::endl;
+ infostream<<"Creating client"<<std::endl;
MapDrawControl draw_control;
Client client(device, playername.c_str(), password, draw_control);
}
catch(ResolveError &e)
{
- dstream<<DTIME<<"Couldn't resolve address"<<std::endl;
+ errorstream<<"Couldn't resolve address"<<std::endl;
//return 0;
error_message = L"Couldn't resolve address";
//gui_loadingtext->remove();
Attempt to connect to the server
*/
- dstream<<DTIME<<"Connecting to server at ";
- connect_address.print(&dstream);
- dstream<<std::endl;
+ infostream<<"Connecting to server at ";
+ connect_address.print(&infostream);
+ infostream<<std::endl;
client.connect(connect_address);
bool could_connect = false;
{
error_message = L"Access denied. Reason: "
+client.accessDeniedReason();
- dstream<<DTIME<<wide_to_narrow(error_message)<<std::endl;
+ errorstream<<wide_to_narrow(error_message)<<std::endl;
}
else
{
error_message = L"Connection timed out.";
- dstream<<DTIME<<"Timed out."<<std::endl;
+ errorstream<<"Timed out."<<std::endl;
}
//gui_loadingtext->remove();
return;
{
error_message = L"Access denied. Reason: "
+client.accessDeniedReason();
- dstream<<DTIME<<wide_to_narrow(error_message)<<std::endl;
+ errorstream<<wide_to_narrow(error_message)<<std::endl;
break;
}
busytime = busytime_u32 / 1000.0;
}
- //dstream<<"busytime_u32="<<busytime_u32<<std::endl;
+ //infostream<<"busytime_u32="<<busytime_u32<<std::endl;
// Necessary for device->getTimer()->getTime()
device->run();
Visualize frametime in terminal
*/
/*for(u32 i=0; i<dtime*400; i++)
- dstream<<"X";
- dstream<<std::endl;*/
+ infostream<<"X";
+ infostream<<std::endl;*/
/*
Time average and jitter calculation
if(counter < 0)
{
counter = 30.0;
- client.printDebugInfo(dstream);
+ client.printDebugInfo(infostream);
}
}
{
if(m_profiler_interval.step(0.030, profiler_print_interval))
{
- dstream<<"Profiler:"<<std::endl;
- g_profiler->print(dstream);
+ infostream<<"Profiler:"<<std::endl;
+ g_profiler->print(infostream);
g_profiler->clear();
}
}
*/
if(input->wasKeyDown(getKeySetting("keymap_inventory")))
{
- dstream<<DTIME<<"the_game: "
+ infostream<<"the_game: "
<<"Launching inventory"<<std::endl;
GUIInventoryMenu *menu =
}
else if(input->wasKeyDown(EscapeKey))
{
- dstream<<DTIME<<"the_game: "
+ infostream<<"the_game: "
<<"Launching pause menu"<<std::endl;
// It will delete itself by itself
(new GUIPauseMenu(guienv, guiroot, -1, g_gamecallback,
if (driver->writeImageToFile(image, filename)) {
std::wstringstream sstr;
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()));
} else{
- dstream<<"Failed to save screenshot '"<<filename<<"'"<<std::endl;
+ infostream<<"Failed to save screenshot '"<<filename<<"'"<<std::endl;
}
image->drop();
}
{
g_selected_item = i;
- dstream<<DTIME<<"Selected item: "
+ infostream<<"Selected item: "
<<g_selected_item<<std::endl;
}
}
if(draw_control.range_all)
{
draw_control.range_all = false;
- dstream<<DTIME<<"Disabled full viewing range"<<std::endl;
+ infostream<<"Disabled full viewing range"<<std::endl;
}
else
{
draw_control.range_all = true;
- dstream<<DTIME<<"Enabled full viewing range"<<std::endl;
+ infostream<<"Enabled full viewing range"<<std::endl;
}
}
}
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;
}
else{
s32 dy = input->getMousePos().Y - displaycenter.Y;
if(invert_mouse)
dy = -dy;
- //dstream<<"window active, pos difference "<<dx<<","<<dy<<std::endl;
+ //infostream<<"window active, pos difference "<<dx<<","<<dy<<std::endl;
/*const float keyspeed = 500;
if(input->isKeyDown(irr::KEY_UP))
if(device->getCursorControl()->isVisible() == false)
device->getCursorControl()->setVisible(true);
- //dstream<<"window inactive"<<std::endl;
+ //infostream<<"window inactive"<<std::endl;
first_loop_after_window_activation = true;
}
else if(event.type == CE_PLAYER_DAMAGE)
{
//u16 damage = event.player_damage.amount;
- //dstream<<"Player damage: "<<damage<<std::endl;
+ //infostream<<"Player damage: "<<damage<<std::endl;
damage_flash_timer = 0.05;
if(event.player_damage.amount >= 2){
damage_flash_timer += 0.05 * event.player_damage.amount;
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
= selected_active_object->getSelectionBox();
do_punch = true;
}
if(do_punch){
- dstream<<DTIME<<"Left-clicked object"<<std::endl;
+ infostream<<"Left-clicked object"<<std::endl;
left_punch = true;
}
if(do_punch_damage){
}
else if(input->getRightClicked())
{
- dstream<<DTIME<<"Right-clicked object"<<std::endl;
+ infostream<<"Right-clicked object"<<std::endl;
client.clickActiveObject(1,
selected_active_object->getId(), g_selected_item);
}
{
if(nodepos != nodepos_old)
{
- dstream<<DTIME<<"Pointing at ("<<nodepos.X<<","
+ infostream<<"Pointing at ("<<nodepos.X<<","
<<nodepos.Y<<","<<nodepos.Z<<")"<<std::endl;
if(nodepos_old != v3s16(-32768,-32768,-32768))
if(input->getLeftClicked() ||
(input->getLeftState() && nodepos != nodepos_old))
{
- dstream<<DTIME<<"Started digging"<<std::endl;
+ infostream<<"Started digging"<<std::endl;
client.groundAction(0, nodepos, neighbourpos, g_selected_item);
}
if(input->getLeftClicked())
if(prop.diggable == false)
{
- /*dstream<<"Material "<<(int)material
+ /*infostream<<"Material "<<(int)material
<<" not diggable with \""
<<toolname<<"\""<<std::endl;*/
// I guess nobody will wait for this long
if(dig_index < CRACK_ANIMATION_LENGTH)
{
//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));
}
else
{
- dstream<<DTIME<<"Digging completed"<<std::endl;
+ infostream<<"Digging completed"<<std::endl;
client.groundAction(3, nodepos, neighbourpos, g_selected_item);
client.clearTempMod(nodepos);
client.removeNode(nodepos);
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(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
*/
}
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;
if(input->getLeftReleased())
{
- dstream<<DTIME<<"Left button released (stopped digging)"
+ infostream<<"Left button released (stopped digging)"
<<std::endl;
client.groundAction(2, v3s16(0,0,0), v3s16(0,0,0), 0);
}
if(input->getRightReleased())
{
- //dstream<<DTIME<<"Right released"<<std::endl;
+ //inostream<<DTIME<<"Right released"<<std::endl;
// Nothing here
}
{
client.selectPlayerItem(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);
// Update wielded tool
//timer3.stop();
- //dstream<<DTIME<<"smgr->drawAll()"<<std::endl;
+ //infostream<<"smgr->drawAll()"<<std::endl;
{
TimeTaker timer("smgr");
for(core::list< core::aabbox3d<f32> >::Iterator i=hilightboxes.begin();
i != hilightboxes.end(); i++)
{
- /*dstream<<"hilightbox min="
+ /*infostream<<"hilightbox min="
<<"("<<i->MinEdge.X<<","<<i->MinEdge.Y<<","<<i->MinEdge.Z<<")"
<<" max="
<<"("<<i->MaxEdge.X<<","<<i->MaxEdge.Y<<","<<i->MaxEdge.Z<<")"
#include "gettext.h"
#include "settings.h"
#include "profiler.h"
+#include "log.h"
// This makes textures
ITextureSource *g_texturesource = NULL;
// Connection
std::ostream *dout_con_ptr = &dummyout;
-std::ostream *derr_con_ptr = &dstream_no_stderr;
-//std::ostream *dout_con_ptr = &dstream_no_stderr;
-//std::ostream *derr_con_ptr = &dstream_no_stderr;
-//std::ostream *dout_con_ptr = &dstream;
-//std::ostream *derr_con_ptr = &dstream;
+std::ostream *derr_con_ptr = &verbosestream;
// Server
-std::ostream *dout_server_ptr = &dstream;
-std::ostream *derr_server_ptr = &dstream;
+std::ostream *dout_server_ptr = &infostream;
+std::ostream *derr_server_ptr = &errorstream;
// Client
-std::ostream *dout_client_ptr = &dstream;
-std::ostream *derr_client_ptr = &dstream;
+std::ostream *dout_client_ptr = &infostream;
+std::ostream *derr_client_ptr = &errorstream;
/*
gettime.h implementation
}
else
{
- //dstream<<"MyEventReceiver: mouse input"<<std::endl;
left_active = event.MouseInput.isLeftPressed();
middle_active = event.MouseInput.isMiddlePressed();
right_active = event.MouseInput.isRightPressed();
u32 dtime = timer.stop();
u32 per_ms = n / dtime;
- std::cout<<"Done. "<<dtime<<"ms, "
+ dstream<<"Done. "<<dtime<<"ms, "
<<per_ms<<"/ms"<<std::endl;
}
}
}
}
+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[])
{
/*
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.
std::locale::global(std::locale("C"));
// This enables printing all characters in bitmap font
allowed_options.insert("dstream-on-stderr", ValueSpec(VALUETYPE_FLAG));
#endif
allowed_options.insert("speedtests", ValueSpec(VALUETYPE_FLAG));
+ allowed_options.insert("info-on-stderr", ValueSpec(VALUETYPE_FLAG));
Settings cmd_args;
if(cmd_args.getFlag("dstream-on-stderr") == false)
disable_stderr = true;
#endif
+
+ if(cmd_args.getFlag("info-on-stderr"))
+ log_add_output(&main_dstream_log_out, LMT_INFO);
porting::signal_handler_init();
bool &kill = *porting::signal_handler_killstatus();
BEGIN_DEBUG_EXCEPTION_HANDLER
// Print startup message
- dstream<<DTIME<<PROJECT_NAME
+ actionstream<<PROJECT_NAME<<
" with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST
<<", "<<BUILD_INFO
<<std::endl;
bool r = g_settings->readConfigFile(cmd_args.get("config").c_str());
if(r == false)
{
- dstream<<"Could not read configuration from \""
+ errorstream<<"Could not read configuration from \""
<<cmd_args.get("config")<<"\""<<std::endl;
return 1;
}
driverType = video::EDT_OPENGL;
else
{
- dstream<<"WARNING: Invalid video_driver specified; defaulting "
+ errorstream<<"WARNING: Invalid video_driver specified; defaulting "
"to opengl"<<std::endl;
driverType = video::EDT_OPENGL;
}
if(font)
skin->setFont(font);
else
- dstream<<"WARNING: Font file was not found."
+ errorstream<<"WARNING: Font file was not found."
" Using default font."<<std::endl;
// If font was not found, this will get us one
font = skin->getFont();
assert(font);
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,255,255,255));
if(error_message != L"")
{
- dstream<<"WARNING: error_message = "
+ errorstream<<"error_message = "
<<wide_to_narrow(error_message)<<std::endl;
GUIMessageMenu *menu2 =
video::IVideoDriver* driver = device->getVideoDriver();
- dstream<<"Created main menu"<<std::endl;
+ infostream<<"Created main menu"<<std::endl;
while(device->run() && kill == false)
{
if(device->run() == false || kill == true)
break;
- dstream<<"Dropping main menu"<<std::endl;
+ infostream<<"Dropping main menu"<<std::endl;
menu->drop();
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);
int newport = stoi(wide_to_narrow(menudata.port));
} //try
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?)";
}
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?)";
}
#ifdef NDEBUG
std::string narrow_message = "Some exception, what()=\"";
narrow_message += e.what();
narrow_message += "\"";
- dstream<<DTIME<<narrow_message<<std::endl;
+ errorstream<<narrow_message<<std::endl;
error_message = narrow_to_wide(narrow_message);
}
#endif
*/
device->drop();
- END_DEBUG_EXCEPTION_HANDLER
+ END_DEBUG_EXCEPTION_HANDLER(errorstream)
debugstreams_deinit();
#include <IMaterialRenderer.h>
#endif
#include "settings.h"
+#include "log.h"
/*
SQLite format specification:
*/
/*if(light_sources.find(n2pos))
{
- std::cout<<"Removed from light_sources"<<std::endl;
+ infostream<<"Removed from light_sources"<<std::endl;
light_sources.remove(n2pos);
}*/
}
}
}
- /*dstream<<"unspreadLight(): Changed block "
+ /*infostream<<"unspreadLight(): Changed block "
<<blockchangecount<<" times"
<<" for "<<from_nodes.size()<<" nodes"
<<std::endl;*/
{
v3s16 pos = j.getNode()->getKey();
//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);
// Only fetch a new block if the block position has changed
}
}
- /*dstream<<"spreadLight(): Changed block "
+ /*infostream<<"spreadLight(): Changed block "
<<blockchangecount<<" times"
<<" for "<<from_nodes.size()<<" nodes"
<<std::endl;*/
dummy block.
*/
//assert(0);
- dstream<<"updateLighting(): InvalidPositionException"
+ infostream<<"updateLighting(): InvalidPositionException"
<<std::endl;
}
}
assert(0);
}
- /*dstream<<"Bottom for sunlight-propagated block ("
+ /*infostream<<"Bottom for sunlight-propagated block ("
<<pos.X<<","<<pos.Y<<","<<pos.Z<<") not valid"
<<std::endl;*/
{
u32 diff = modified_blocks.size() - count_was;
count_was = modified_blocks.size();
- dstream<<"unspreadLight modified "<<diff<<std::endl;
+ infostream<<"unspreadLight modified "<<diff<<std::endl;
}
{
{
u32 diff = modified_blocks.size() - count_was;
count_was = modified_blocks.size();
- dstream<<"spreadLight modified "<<diff<<std::endl;
+ infostream<<"spreadLight modified "<<diff<<std::endl;
}
#endif
//TimeTaker timer("blitBack");
vmanip.blitBack(modified_blocks);
}
- /*dstream<<"emerge_time="<<emerge_time<<std::endl;
+ /*infostream<<"emerge_time="<<emerge_time<<std::endl;
emerge_time = 0;*/
}
if(deleted_blocks_count != 0)
{
- PrintInfo(dstream); // ServerMap/ClientMap:
- dstream<<"Unloaded "<<deleted_blocks_count
+ PrintInfo(infostream); // ServerMap/ClientMap:
+ infostream<<"Unloaded "<<deleted_blocks_count
<<" blocks from memory";
if(save_before_unloading)
- dstream<<", of which "<<saved_blocks_count<<" were written";
- dstream<<"."<<std::endl;
+ infostream<<", of which "<<saved_blocks_count<<" were written";
+ infostream<<"."<<std::endl;
}
}
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."
<<std::endl;
u32 initial_size = m_transforming_liquid.size();
/*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
UniqueQueue<v3s16> must_reflow;
break;
}
}
- //dstream<<"Map::transformLiquids(): loopcount="<<loopcount<<std::endl;
+ //infostream<<"Map::transformLiquids(): loopcount="<<loopcount<<std::endl;
while (must_reflow.size() > 0)
m_transforming_liquid.push_back(must_reflow.pop_front());
updateLighting(lighting_modified_blocks, modified_blocks);
MapBlock *block = getBlockNoCreateNoEx(blockpos);
if(block == NULL)
{
- dstream<<"WARNING: Map::setNodeMetadata(): Block not found"
+ infostream<<"WARNING: Map::setNodeMetadata(): Block not found"
<<std::endl;
return NULL;
}
MapBlock *block = getBlockNoCreateNoEx(blockpos);
if(block == NULL)
{
- dstream<<"WARNING: Map::setNodeMetadata(): Block not found"
+ infostream<<"WARNING: Map::setNodeMetadata(): Block not found"
<<std::endl;
return;
}
MapBlock *block = getBlockNoCreateNoEx(blockpos);
if(block == NULL)
{
- dstream<<"WARNING: Map::removeNodeMetadata(): Block not found"
+ infostream<<"WARNING: Map::removeNodeMetadata(): Block not found"
<<std::endl;
return;
}
m_database_read(NULL),
m_database_write(NULL)
{
- dstream<<__FUNCTION_NAME<<std::endl;
+ infostream<<__FUNCTION_NAME<<std::endl;
//m_chunksize = 8; // Takes a few seconds
// If directory is empty, it is safe to save into it.
if(fs::GetDirListing(m_savedir).size() == 0)
{
- dstream<<DTIME<<"Server: Empty save directory is valid."
+ infostream<<"Server: Empty save directory is valid."
<<std::endl;
m_map_saving_enabled = true;
}
loadMapMeta();
}
catch(FileNotGoodException &e){
- dstream<<DTIME<<"WARNING: Could not load map metadata"
+ infostream<<"WARNING: Could not load map metadata"
//<<" Disabling chunk-based generator."
<<std::endl;
//m_chunksize = 0;
loadChunkMeta();
}
catch(FileNotGoodException &e){
- dstream<<DTIME<<"WARNING: Could not load chunk metadata."
+ infostream<<"WARNING: Could not load chunk metadata."
<<" Disabling chunk-based generator."
<<std::endl;
m_chunksize = 0;
}*/
- /*dstream<<DTIME<<"Server: Successfully loaded chunk "
+ /*infostream<<"Server: Successfully loaded chunk "
"metadata and sector (0,0) from "<<savedir<<
", assuming valid save directory."
<<std::endl;*/
- dstream<<DTIME<<"INFO: Server: Successfully loaded map "
+ infostream<<"Server: Successfully loaded map "
<<"and chunk metadata from "<<savedir
<<", assuming valid save directory."
<<std::endl;
}
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;
- dstream<<"Please remove the map or fix it."<<std::endl;
- dstream<<"WARNING: Map saving will be disabled."<<std::endl;
+ infostream<<"Please remove the map or fix it."<<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
emergeSector(v2s16(0,0));
ServerMap::~ServerMap()
{
- dstream<<__FUNCTION_NAME<<std::endl;
+ infostream<<__FUNCTION_NAME<<std::endl;
try
{
{
// Save only changed parts
save(true);
- dstream<<DTIME<<"Server: saved map to "<<m_savedir<<std::endl;
+ infostream<<"Server: saved map to "<<m_savedir<<std::endl;
}
else
{
- dstream<<DTIME<<"Server: map not saved"<<std::endl;
+ infostream<<"Server: map not saved"<<std::endl;
}
}
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;
}
{
bool enable_mapgen_debug_info = g_settings->getBool("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;
// Do nothing if not inside limits (+-1 because of neighbors)
core::map<v3s16, MapBlock*> &changed_blocks)
{
v3s16 blockpos = data->blockpos;
- /*dstream<<"finishBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<","
+ /*infostream<<"finishBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<","
<<blockpos.Z<<")"<<std::endl;*/
if(data->no_op)
{
- //dstream<<"finishBlockMake(): no-op"<<std::endl;
+ //infostream<<"finishBlockMake(): no-op"<<std::endl;
return NULL;
}
bool enable_mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
- /*dstream<<"Resulting vmanip:"<<std::endl;
- data->vmanip.print(dstream);*/
+ /*infostream<<"Resulting vmanip:"<<std::endl;
+ data->vmanip.print(infostream);*/
/*
Blit generated stuff to map
}
if(enable_mapgen_debug_info)
- dstream<<"finishBlockMake: changed_blocks.size()="
+ infostream<<"finishBlockMake: changed_blocks.size()="
<<changed_blocks.size()<<std::endl;
/*
*/
//save(true);
- /*dstream<<"finishBlockMake() done for ("<<blockpos.X<<","<<blockpos.Y<<","
+ /*infostream<<"finishBlockMake() done for ("<<blockpos.X<<","<<blockpos.Y<<","
<<blockpos.Z<<")"<<std::endl;*/
#if 0
if(enable_mapgen_debug_info)
MapBlock *block = getBlockNoCreateNoEx(p);
char spos[20];
snprintf(spos, 20, "(%2d,%2d,%2d)", x, y, z);
- dstream<<"Generated "<<spos<<": "
+ infostream<<"Generated "<<spos<<": "
<<analyze_block(block)<<std::endl;
}
}
ServerMapSector *sector = (ServerMapSector*)getSectorNoGenerateNoEx(p2d);
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("");
}
return sector;
{
DSTACKF("%s: p=(%d,%d,%d)", __FUNCTION_NAME, p.X, p.Y, p.Z);
- /*dstream<<"generateBlock(): "
+ /*infostream<<"generateBlock(): "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;*/
*/
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");
}
MapNode n = block->getNode(p);
if(n.getContent() == CONTENT_IGNORE)
{
- dstream<<"CONTENT_IGNORE at "
+ infostream<<"CONTENT_IGNORE at "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;
erroneus_content = true;
}
catch(InvalidPositionException &e)
{
- dstream<<"createBlock: createSector() failed"<<std::endl;
+ infostream<<"createBlock: createSector() failed"<<std::endl;
throw e;
}
/*
*/
/*catch(std::exception &e)
{
- dstream<<"createBlock: createSector() failed: "
+ infostream<<"createBlock: createSector() failed: "
<<e.what()<<std::endl;
throw e;
}*/
}
catch(InvalidPositionException &e)
{
- dstream<<"emergeBlock: createSector() failed: "
+ infostream<<"emergeBlock: createSector() failed: "
<<e.what()<<std::endl;
- dstream<<"Path to failed sector: "<<getSectorDir(p2d)
+ infostream<<"Path to failed sector: "<<getSectorDir(p2d)
<<std::endl
<<"You could try to delete it."<<std::endl;
throw e;
}
catch(VersionMismatchException &e)
{
- dstream<<"emergeBlock: createSector() failed: "
+ infostream<<"emergeBlock: createSector() failed: "
<<e.what()<<std::endl;
- dstream<<"Path to failed sector: "<<getSectorDir(p2d)
+ infostream<<"Path to failed sector: "<<getSectorDir(p2d)
<<std::endl
<<"You could try to delete it."<<std::endl;
throw e;
else
{
// Valid block
- //dstream<<"emergeBlock(): Returning already valid block"<<std::endl;
+ //infostream<<"emergeBlock(): Returning already valid block"<<std::endl;
return block;
}
*/
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)
{
return block;
}
- //dstream<<"Not found on disk, generating."<<std::endl;
+ //infostream<<"Not found on disk, generating."<<std::endl;
// 0ms
//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(e == SQLITE_ABORT)
throw FileNotGoodException("Could not create database structure");
else
- dstream<<"Server: Database structure was created";
+ infostream<<"Server: Database structure was created";
}
void ServerMap::verifyDatabase() {
d = sqlite3_open_v2(dbp.c_str(), &m_database, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
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");
}
d = sqlite3_prepare(m_database, "SELECT `data` FROM `blocks` WHERE `pos`=? LIMIT 1", -1, &m_database_read, NULL);
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");
}
d = sqlite3_prepare(m_database, "REPLACE INTO `blocks` VALUES(?, ?)", -1, &m_database_write, NULL);
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");
}
- dstream<<"Server: Database opened"<<std::endl;
+ infostream<<"Server: Database opened"<<std::endl;
}
}
DSTACK(__FUNCTION_NAME);
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;
}
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;
if(only_changed == false || m_map_metadata_changed)
saveBlock(block);
block_count++;
- /*dstream<<"ServerMap: Written block ("
+ /*infostream<<"ServerMap: Written block ("
<<block->getPos().X<<","
<<block->getPos().Y<<","
<<block->getPos().Z<<")"
if(only_changed == false || sector_meta_count != 0
|| block_count != 0)
{
- dstream<<DTIME<<"ServerMap: Written: "
+ infostream<<"ServerMap: Written: "
<<sector_meta_count<<" sector metadata files, "
<<block_count<<" block files"
<<", "<<block_count_all<<" blocks in memory."
{
DSTACK(__FUNCTION_NAME);
- dstream<<"INFO: ServerMap::saveMapMeta(): "
+ infostream<<"ServerMap::saveMapMeta(): "
<<"seed="<<m_seed
<<std::endl;
std::ofstream os(fullpath.c_str(), std::ios_base::binary);
if(os.good() == false)
{
- dstream<<"ERROR: ServerMap::saveMapMeta(): "
+ infostream<<"ERROR: ServerMap::saveMapMeta(): "
<<"could not open"<<fullpath<<std::endl;
throw FileNotGoodException("Cannot open chunk metadata");
}
{
DSTACK(__FUNCTION_NAME);
- dstream<<"INFO: ServerMap::loadMapMeta(): Loading map metadata"
+ infostream<<"ServerMap::loadMapMeta(): Loading map metadata"
<<std::endl;
std::string fullpath = m_savedir + "/map_meta.txt";
std::ifstream is(fullpath.c_str(), std::ios_base::binary);
if(is.good() == false)
{
- dstream<<"ERROR: ServerMap::loadMapMeta(): "
+ infostream<<"ERROR: ServerMap::loadMapMeta(): "
<<"could not open"<<fullpath<<std::endl;
throw FileNotGoodException("Cannot open map metadata");
}
m_seed = params.getU64("seed");
- dstream<<"INFO: ServerMap::loadMapMeta(): "
- <<"seed="<<m_seed
- <<std::endl;
+ infostream<<"ServerMap::loadMapMeta(): "<<"seed="<<m_seed<<std::endl;
}
void ServerMap::saveSectorMeta(ServerMapSector *sector)
// format. Just go ahead and create the sector.
if(fs::PathExists(sectordir))
{
- /*dstream<<"ServerMap::loadSectorMeta(): Sector metafile "
+ /*infostream<<"ServerMap::loadSectorMeta(): Sector metafile "
<<fullpath<<" doesn't exist but directory does."
<<" Continuing with a sector with no metadata."
<<std::endl;*/
if(loadlayout != 2)
{
- dstream<<"Sector converted to new layout - deleting "<<
+ infostream<<"Sector converted to new layout - deleting "<<
sectordir1<<std::endl;
fs::RecursiveDelete(sectordir1);
}
void ServerMap::beginSave() {
verifyDatabase();
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() {
verifyDatabase();
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)
if(block->isDummy())
{
/*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;*/
return;
}
const char *bytes = tmp.c_str();
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
- 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);
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;
// Make ready for later reuse
sqlite3_reset(m_database_write);
}
catch(SerializationError &e)
{
- dstream<<"WARNING: Invalid block data on disk "
+ infostream<<"WARNING: Invalid block data on disk "
<<"fullpath="<<fullpath
<<" (SerializationError). "
<<"what()="<<e.what()
}
catch(SerializationError &e)
{
- dstream<<"WARNING: Invalid block data in database "
+ infostream<<"WARNING: Invalid block data in database "
<<" (SerializationError). "
<<"what()="<<e.what()
<<std::endl;
verifyDatabase();
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;
if(sqlite3_step(m_database_read) == SQLITE_ROW) {
/*
int time2 = time(0);
if(time2 > time1 + 4)
{
- dstream<<"ClientMap::renderMap(): "
+ infostream<<"ClientMap::renderMap(): "
"Rendering takes ages, returning."
<<std::endl;
return;
m_control.blocks_drawn = blocks_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;*/
}
MapVoxelManipulator::~MapVoxelManipulator()
{
- /*dstream<<"MapVoxelManipulator: blocks: "<<m_loaded_blocks.size()
+ /*infostream<<"MapVoxelManipulator: blocks: "<<m_loaded_blocks.size()
<<std::endl;*/
}
{
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<<")"
<<" wanted area: ";
- a.print(dstream);
- dstream<<std::endl;*/
+ a.print(infostream);
+ infostream<<std::endl;*/
MapBlock *block = m_map->getBlockNoCreate(p);
if(block->isDummy())
m_loaded_blocks.insert(p, !block_data_inexistent);
}
- //dstream<<"emerge done"<<std::endl;
+ //infostream<<"emerge done"<<std::endl;
}
/*
//TimeTaker timer1("blitBack");
- /*dstream<<"blitBack(): m_loaded_blocks.size()="
+ /*infostream<<"blitBack(): m_loaded_blocks.size()="
<<m_loaded_blocks.size()<<std::endl;*/
/*
u32 size_MB = block_area_nodes.getVolume()*4/1000000;
if(size_MB >= 1)
{
- dstream<<"initialEmerge: area: ";
- block_area_nodes.print(dstream);
- dstream<<" ("<<size_MB<<"MB)";
- dstream<<std::endl;
+ infostream<<"initialEmerge: area: ";
+ block_area_nodes.print(infostream);
+ infostream<<" ("<<size_MB<<"MB)";
+ infostream<<std::endl;
}
addArea(block_area_nodes);
if(existed == false)
{
// The Great Bug was found using this
- /*dstream<<"ManualMapVoxelManipulator::blitBackAll: "
+ /*infostream<<"ManualMapVoxelManipulator::blitBackAll: "
<<"Inexistent ("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;*/
continue;
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
if(block == NULL)
{
- dstream<<"WARNING: "<<__FUNCTION_NAME
+ infostream<<"WARNING: "<<__FUNCTION_NAME
<<": got NULL block "
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<std::endl;
#include "serverobject.h"
#include "settings.h"
#include "profiler.h"
+#include "log.h"
+
+#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
#define BLOCK_EMERGE_FLAG_FROMDISK (1<<0)
{
ThreadStarted();
+ log_register_thread("ServerThread");
+
DSTACK(__FUNCTION_NAME);
BEGIN_DEBUG_EXCEPTION_HANDLER
m_server->AsyncRunStep();
}
- //dout_server<<"Running m_server->Receive()"<<std::endl;
+ //infostream<<"Running m_server->Receive()"<<std::endl;
m_server->Receive();
}
catch(con::NoIncomingDataException &e)
}
catch(con::PeerNotFoundException &e)
{
- dout_server<<"Server: PeerNotFoundException"<<std::endl;
+ infostream<<"Server: PeerNotFoundException"<<std::endl;
}
}
- END_DEBUG_EXCEPTION_HANDLER
+ END_DEBUG_EXCEPTION_HANDLER(errorstream)
return NULL;
}
{
ThreadStarted();
+ log_register_thread("EmergeThread");
+
DSTACK(__FUNCTION_NAME);
BEGIN_DEBUG_EXCEPTION_HANDLER
|| p.Z > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE)
continue;
- //derr_server<<"EmergeThread::Thread(): running"<<std::endl;
+ //infostream<<"EmergeThread::Thread(): running"<<std::endl;
//TimeTaker timer("block emerge");
}
if(enable_mapgen_debug_info)
- dstream<<"EmergeThread: p="
+ infostream<<"EmergeThread: p="
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<") "
<<"only_from_disk="<<only_from_disk<<std::endl;
if(!block || block->isDummy() || !block->isGenerated())
{
if(enable_mapgen_debug_info)
- dstream<<"EmergeThread: not in memory, loading"<<std::endl;
+ infostream<<"EmergeThread: not in memory, loading"<<std::endl;
// Get, load or create sector
/*ServerMapSector *sector =
if(block == NULL || block->isGenerated() == false)
{
if(enable_mapgen_debug_info)
- dstream<<"EmergeThread: generating"<<std::endl;
+ infostream<<"EmergeThread: generating"<<std::endl;
block = map.generateBlock(p, modified_blocks);
}
}
if(enable_mapgen_debug_info)
- dstream<<"EmergeThread: ended up with: "
+ infostream<<"EmergeThread: ended up with: "
<<analyze_block(block)<<std::endl;
if(block == NULL)
#if 0
if(lighting_invalidated_blocks.size() > 0)
{
- /*dstream<<"lighting "<<lighting_invalidated_blocks.size()
+ /*infostream<<"lighting "<<lighting_invalidated_blocks.size()
<<" blocks"<<std::endl;*/
// 50-100ms for single block generation
}
- END_DEBUG_EXCEPTION_HANDLER
+ END_DEBUG_EXCEPTION_HANDLER(errorstream)
return NULL;
}
if(m_blocks_sending.size() >= g_settings->getU16
("max_simultaneous_block_sends_per_client"))
{
- //dstream<<"Not sending any blocks, Queue full."<<std::endl;
+ //infostream<<"Not sending any blocks, Queue full."<<std::endl;
return;
}
camera_dir.rotateYZBy(player->getPitch());
camera_dir.rotateXZBy(player->getYaw());
- /*dstream<<"camera_dir=("<<camera_dir.X<<","<<camera_dir.Y<<","
+ /*infostream<<"camera_dir=("<<camera_dir.X<<","<<camera_dir.Y<<","
<<camera_dir.Z<<")"<<std::endl;*/
/*
m_last_center = center;
}
- /*dstream<<"m_nearest_unsent_reset_timer="
+ /*infostream<<"m_nearest_unsent_reset_timer="
<<m_nearest_unsent_reset_timer<<std::endl;*/
// This has to be incremented only when the nothing to send pause
{
m_nearest_unsent_reset_timer = 0;
m_nearest_unsent_d = 0;
- /*dstream<<"Resetting m_nearest_unsent_d for "
+ /*infostream<<"Resetting m_nearest_unsent_d for "
<<server->getPlayerName(peer_id)<<std::endl;*/
}
//s16 last_nearest_unsent_d = m_nearest_unsent_d;
s16 d_start = m_nearest_unsent_d;
- //dstream<<"d_start="<<d_start<<std::endl;
+ //infostream<<"d_start="<<d_start<<std::endl;
u16 max_simul_sends_setting = g_settings->getU16
("max_simultaneous_block_sends_per_client");
/*if(d_max_gen > d_start+2)
d_max_gen = d_start+2;*/
- //dstream<<"Starting from "<<d_start<<std::endl;
+ //infostream<<"Starting from "<<d_start<<std::endl;
bool sending_something = false;
s16 d;
for(d = d_start; d <= d_max; d++)
{
- //dstream<<"RemoteClient::SendBlocks(): d="<<d<<std::endl;
+ //infostream<<"RemoteClient::SendBlocks(): d="<<d<<std::endl;
/*
If m_nearest_unsent_d was changed by the EmergeThread
}
#endif
- //dstream<<"d="<<d<<std::endl;
+ //infostream<<"d="<<d<<std::endl;
/*
Don't generate or send if not in sight
// Allow two blocks in queue per client
if(server->m_emerge_queue.peerItemCount(peer_id) < 2)
{
- //dstream<<"Adding block to emerge queue"<<std::endl;
+ //infostream<<"Adding block to emerge queue"<<std::endl;
// Add it to the emerge queue and trigger the thread
}
queue_full_break:
- //dstream<<"Stopped at "<<d<<std::endl;
+ //infostream<<"Stopped at "<<d<<std::endl;
if(no_blocks_found_for_sending)
{
{
// Pause time in seconds
m_nothing_to_send_pause_timer = 1.0;
- /*dstream<<"nothing to send to "
+ /*infostream<<"nothing to send to "
<<server->getPlayerName(peer_id)
<<" (d="<<d<<")"<<std::endl;*/
}
/*timer_result = timer.stop(true);
if(timer_result != 0)
- dstream<<"GetNextBlocks duration: "<<timer_result<<" (!=0)"<<std::endl;*/
+ infostream<<"GetNextBlocks duration: "<<timer_result<<" (!=0)"<<std::endl;*/
}
void RemoteClient::SendObjectData(
// Can't send anything without knowing version
if(serialization_version == SER_FMT_VER_INVALID)
{
- dstream<<"RemoteClient::SendObjectData(): Not sending, no version."
+ infostream<<"RemoteClient::SendObjectData(): Not sending, no version."
<<std::endl;
return;
}
Send data
*/
- //dstream<<"Server: Sending object data to "<<peer_id<<std::endl;
+ //infostream<<"Server: Sending object data to "<<peer_id<<std::endl;
// Make data buffer
std::string s = os.str();
m_blocks_sending.remove(p);
else
{
- /*dstream<<"RemoteClient::GotBlock(): Didn't find in"
+ /*infostream<<"RemoteClient::GotBlock(): Didn't find in"
" m_blocks_sending"<<std::endl;*/
m_excess_gotblocks++;
}
if(m_blocks_sending.find(p) == NULL)
m_blocks_sending.insert(p, 0.0);
else
- dstream<<"RemoteClient::SentBlock(): Sent block"
+ infostream<<"RemoteClient::SentBlock(): Sent block"
" already in m_blocks_sending"<<std::endl;
}
// If file exists, load environment metadata
if(fs::PathExists(m_mapsavedir+"/env_meta.txt"))
{
- dstream<<"Server: Loading environment metadata"<<std::endl;
+ infostream<<"Server: Loading environment metadata"<<std::endl;
m_env.loadMeta(m_mapsavedir);
}
// Load players
- dstream<<"Server: Loading players"<<std::endl;
+ infostream<<"Server: Loading players"<<std::endl;
m_env.deSerializePlayers(m_mapsavedir);
}
Server::~Server()
{
- dstream<<"Server::~Server()"<<std::endl;
+ infostream<<"Server::~Server()"<<std::endl;
/*
Send shutdown message
/*
Save players
*/
- dstream<<"Server: Saving players"<<std::endl;
+ infostream<<"Server: Saving players"<<std::endl;
m_env.serializePlayers(m_mapsavedir);
/*
Save environment metadata
*/
- dstream<<"Server: Saving environment metadata"<<std::endl;
+ infostream<<"Server: Saving environment metadata"<<std::endl;
m_env.saveMeta(m_mapsavedir);
}
m_thread.setRun(true);
m_thread.Start();
- dout_server<<"Server: Started on port "<<port<<std::endl;
+ infostream<<"Server: Started on port "<<port<<std::endl;
}
void Server::stop()
{
DSTACK(__FUNCTION_NAME);
- dout_server<<"Server: Stopping and waiting threads"<<std::endl;
+ infostream<<"Server: Stopping and waiting threads"<<std::endl;
// Stop threads (set run=false first so both start stopping)
m_thread.setRun(false);
m_thread.stop();
m_emergethread.stop();
- dout_server<<"Server: Threads stopped"<<std::endl;
+ infostream<<"Server: Threads stopped"<<std::endl;
}
void Server::step(float dtime)
if(dtime < 0.001)
return;
- //dstream<<"Server steps "<<dtime<<std::endl;
- //dstream<<"Server::AsyncRunStep(): dtime="<<dtime<<std::endl;
+ //infostream<<"Server steps "<<dtime<<std::endl;
+ //infostream<<"Server::AsyncRunStep(): dtime="<<dtime<<std::endl;
{
JMutexAutoLock lock1(m_step_dtime_mutex);
m_env.setTimeOfDay((m_env.getTimeOfDay() + units) % 24000);
- //dstream<<"Server: m_time_of_day = "<<m_time_of_day.get()<<std::endl;
+ //infostream<<"Server: m_time_of_day = "<<m_time_of_day.get()<<std::endl;
/*
Send to clients at constant intervals
counter = 0.0;
JMutexAutoLock lock2(m_con_mutex);
-
+
+ if(m_clients.size() != 0)
+ infostream<<"Players:"<<std::endl;
for(core::map<u16, RemoteClient*>::Iterator
i = m_clients.getIterator();
i.atEnd() == false; i++)
Player *player = m_env.getPlayer(client->peer_id);
if(player==NULL)
continue;
- std::cout<<player->getName()<<"\t";
- client->PrintInfo(std::cout);
+ infostream<<"* "<<player->getName()<<"\t";
+ client->PrintInfo(infostream);
}
}
}
Check added and deleted active objects
*/
{
- //dstream<<"Server: Checking added and deleted active objects"<<std::endl;
+ //infostream<<"Server: Checking added and deleted active objects"<<std::endl;
JMutexAutoLock envlock(m_env_mutex);
JMutexAutoLock conlock(m_con_mutex);
if(player==NULL)
{
// This can happen if the client timeouts somehow
- /*dstream<<"WARNING: "<<__FUNCTION_NAME<<": Client "
+ /*infostream<<"WARNING: "<<__FUNCTION_NAME<<": Client "
<<client->peer_id
<<" has no associated player"<<std::endl;*/
continue;
// Ignore if nothing happened
if(removed_objects.size() == 0 && added_objects.size() == 0)
{
- //dstream<<"INFO: active objects: none changed"<<std::endl;
+ //infostream<<"active objects: none changed"<<std::endl;
continue;
}
// Get object type
u8 type = ACTIVEOBJECT_TYPE_INVALID;
if(obj == NULL)
- dstream<<"WARNING: "<<__FUNCTION_NAME
+ infostream<<"WARNING: "<<__FUNCTION_NAME
<<": NULL object"<<std::endl;
else
type = obj->getType();
// Send as reliable
m_con.Send(client->peer_id, 0, reply, true);
- dstream<<"INFO: Server: Sent object remove/add: "
+ infostream<<"Server: Sent object remove/add: "
<<removed_objects.size()<<" removed, "
<<added_objects.size()<<" added, "
<<"packet size is "<<reply.getSize()<<std::endl;
/*if(reliable_data.size() > 0 || unreliable_data.size() > 0)
{
- dstream<<"INFO: Server: Size of object message data: "
+ infostream<<"Server: Size of object message data: "
<<"reliable: "<<reliable_data.size()
<<", unreliable: "<<unreliable_data.size()
<<std::endl;
if(event->type == MEET_ADDNODE)
{
- //dstream<<"Server: MEET_ADDNODE"<<std::endl;
+ //infostream<<"Server: MEET_ADDNODE"<<std::endl;
prof.add("MEET_ADDNODE", 1);
if(disable_single_change_sending)
sendAddNode(event->p, event->n, event->already_known_by_peer,
}
else if(event->type == MEET_REMOVENODE)
{
- //dstream<<"Server: MEET_REMOVENODE"<<std::endl;
+ //infostream<<"Server: MEET_REMOVENODE"<<std::endl;
prof.add("MEET_REMOVENODE", 1);
if(disable_single_change_sending)
sendRemoveNode(event->p, event->already_known_by_peer,
}
else if(event->type == MEET_BLOCK_NODE_METADATA_CHANGED)
{
- dstream<<"Server: MEET_BLOCK_NODE_METADATA_CHANGED"<<std::endl;
+ infostream<<"Server: MEET_BLOCK_NODE_METADATA_CHANGED"<<std::endl;
prof.add("MEET_BLOCK_NODE_METADATA_CHANGED", 1);
setBlockNotSent(event->p);
}
else if(event->type == MEET_OTHER)
{
- dstream<<"Server: MEET_OTHER"<<std::endl;
+ infostream<<"Server: MEET_OTHER"<<std::endl;
prof.add("MEET_OTHER", 1);
for(core::map<v3s16, bool>::Iterator
i = event->modified_blocks.getIterator();
else
{
prof.add("unknown", 1);
- dstream<<"WARNING: Server: Unknown MapEditEvent "
+ infostream<<"WARNING: Server: Unknown MapEditEvent "
<<((u32)event->type)<<std::endl;
}
if(got_any_events)
{
- dstream<<"Server: MapEditEvents:"<<std::endl;
- prof.print(dstream);
+ infostream<<"Server: MapEditEvents:"<<std::endl;
+ prof.print(infostream);
}
}
/*if(deleted_count > 0)
{
- dout_server<<"Server: Unloaded "<<deleted_count
+ infostream<<"Server: Unloaded "<<deleted_count
<<" blocks from memory"<<std::endl;
}*/
}
catch(con::InvalidIncomingDataException &e)
{
- derr_server<<"Server::Receive(): "
+ infostream<<"Server::Receive(): "
"InvalidIncomingDataException: what()="
<<e.what()<<std::endl;
}
/*JMutexAutoLock envlock(m_env_mutex);
- dout_server<<"ServerThread: peer_id="<<peer_id
+ infostream<<"ServerThread: peer_id="<<peer_id
<<" has apparently closed connection. "
<<"Removing player."<<std::endl;
}
catch(con::PeerNotFoundException &e)
{
- derr_server<<DTIME<<"Server::ProcessData(): Cancelling: peer "
+ infostream<<"Server::ProcessData(): Cancelling: peer "
<<peer_id<<" not found"<<std::endl;
return;
}
if(datasize < 2+1+PLAYERNAME_SIZE)
return;
- derr_server<<DTIME<<"Server: Got TOSERVER_INIT from "
+ infostream<<"Server: Got TOSERVER_INIT from "
<<peer->id<<std::endl;
// First byte after command is maximum supported
if(deployed == SER_FMT_VER_INVALID)
{
- derr_server<<DTIME<<"Server: Cannot negotiate "
+ infostream<<"Server: Cannot negotiate "
"serialization version with peer "
<<peer_id<<std::endl;
SendAccessDenied(m_con, peer_id,
if(playername[0]=='\0')
{
- derr_server<<DTIME<<"Server: Player has empty name"<<std::endl;
+ infostream<<"Server: Player has empty name"<<std::endl;
SendAccessDenied(m_con, peer_id,
L"Empty name");
return;
if(string_allowed(playername, PLAYERNAME_ALLOWED_CHARS)==false)
{
- derr_server<<DTIME<<"Server: Player has invalid name"<<std::endl;
+ infostream<<"Server: Player has invalid name"<<std::endl;
SendAccessDenied(m_con, peer_id,
L"Name contains unallowed characters");
return;
checkpwd = g_settings->get("default_password");
}
- /*dstream<<"Server: Client gave password '"<<password
+ /*infostream<<"Server: Client gave password '"<<password
<<"', the correct one is '"<<checkpwd<<"'"<<std::endl;*/
if(password != checkpwd && m_authmanager.exists(playername))
{
- derr_server<<DTIME<<"Server: peer_id="<<peer_id
+ infostream<<"Server: peer_id="<<peer_id
<<": supplied invalid password for "
<<playername<<std::endl;
SendAccessDenied(m_con, peer_id, L"Invalid password");
// Add player to auth manager
if(m_authmanager.exists(playername) == false)
{
- derr_server<<DTIME<<"Server: adding player "<<playername
+ infostream<<"Server: adding player "<<playername
<<" to auth manager"<<std::endl;
m_authmanager.add(playername);
m_authmanager.setPassword(playername, checkpwd);
// If failed, cancel
if(player == NULL)
{
- derr_server<<DTIME<<"Server: peer_id="<<peer_id
+ infostream<<"Server: peer_id="<<peer_id
<<": failed to emerge player"<<std::endl;
return;
}
if(command == TOSERVER_INIT2)
{
- derr_server<<DTIME<<"Server: Got TOSERVER_INIT2 from "
+ infostream<<"Server: Got TOSERVER_INIT2 from "
<<peer->id<<std::endl;
// Send player items to all players
SendPlayerItems();
+ Player *player = m_env.getPlayer(peer_id);
+
// Send HP
- {
- Player *player = m_env.getPlayer(peer_id);
- SendPlayerHP(player);
- }
+ SendPlayerHP(player);
// Send time of day
{
/*
Check HP, respawn if necessary
*/
+ HandlePlayerHP(player, 0);
+
+ /*
+ Print out action
+ */
{
- Player *player = m_env.getPlayer(peer_id);
- HandlePlayerHP(player, 0);
+ std::ostringstream os(std::ios_base::binary);
+ for(core::map<u16, RemoteClient*>::Iterator
+ i = m_clients.getIterator();
+ i.atEnd() == false; i++)
+ {
+ RemoteClient *client = i.getNode()->getValue();
+ assert(client->peer_id == i.getNode()->getKey());
+ if(client->serialization_version == SER_FMT_VER_INVALID)
+ continue;
+ // Get player
+ Player *player = m_env.getPlayer(client->peer_id);
+ if(!player)
+ continue;
+ // Get name of player
+ os<<player->getName()<<" ";
+ }
+
+ actionstream<<player->getName()<<" joins game. List of players: "
+ <<os.str()<<std::endl;
}
return;
if(peer_ser_ver == SER_FMT_VER_INVALID)
{
- derr_server<<DTIME<<"Server::ProcessData(): Cancelling: Peer"
+ infostream<<"Server::ProcessData(): Cancelling: Peer"
" serialization format invalid or not initialized."
" Skipping incoming command="<<command<<std::endl;
return;
Player *player = m_env.getPlayer(peer_id);
if(player == NULL){
- derr_server<<"Server::ProcessData(): Cancelling: "
+ infostream<<"Server::ProcessData(): Cancelling: "
"No player for peer_id="<<peer_id
<<std::endl;
return;
v3f speed((f32)ss.X/100., (f32)ss.Y/100., (f32)ss.Z/100.);
pitch = wrapDegrees(pitch);
yaw = wrapDegrees(yaw);
+
player->setPosition(position);
player->setSpeed(speed);
player->setPitch(pitch);
player->setYaw(yaw);
- /*dout_server<<"Server::ProcessData(): Moved player "<<peer_id<<" to "
+ /*infostream<<"Server::ProcessData(): Moved player "<<peer_id<<" to "
<<"("<<position.X<<","<<position.Y<<","<<position.Z<<")"
<<" pitch="<<pitch<<" yaw="<<yaw<<std::endl;*/
}
throw con::InvalidIncomingDataException
("GOTBLOCKS length is too short");
v3s16 p = readV3S16(&data[2+1+i*6]);
- /*dstream<<"Server: GOTBLOCKS ("
+ /*infostream<<"Server: GOTBLOCKS ("
<<p.X<<","<<p.Y<<","<<p.Z<<")"<<std::endl;*/
RemoteClient *client = getClient(peer_id);
client->GotBlock(p);
throw con::InvalidIncomingDataException
("DELETEDBLOCKS length is too short");
v3s16 p = readV3S16(&data[2+1+i*6]);
- /*dstream<<"Server: DELETEDBLOCKS ("
+ /*infostream<<"Server: DELETEDBLOCKS ("
<<p.X<<","<<p.Y<<","<<p.Z<<")"<<std::endl;*/
RemoteClient *client = getClient(peer_id);
client->SetBlockNotSent(p);
}
else if(command == TOSERVER_CLICK_OBJECT)
{
- derr_server<<"Server: CLICK_OBJECT not supported anymore"<<std::endl;
+ infostream<<"Server: CLICK_OBJECT not supported anymore"<<std::endl;
return;
}
else if(command == TOSERVER_CLICK_ACTIVEOBJECT)
if(obj == NULL)
{
- derr_server<<"Server: CLICK_ACTIVEOBJECT: object not found"
+ infostream<<"Server: CLICK_ACTIVEOBJECT: object not found"
<<std::endl;
return;
}
InventoryList *ilist = player->inventory.getList("main");
if(ilist != NULL)
{
+ actionstream<<player->getName()<<" picked up "
+ <<item->getName()<<std::endl;
if(g_settings->getBool("creative_mode") == false)
{
// Skip if inventory has no free space
if(ilist->roomForItem(item) == false)
{
- dout_server<<"Player inventory has no free space"<<std::endl;
+ infostream<<"Player inventory has no free space"<<std::endl;
return;
}
Item cannot be picked up. Punch it instead.
*/
+ actionstream<<player->getName()<<" punches object "
+ <<obj->getId()<<std::endl;
+
ToolItem *titem = NULL;
std::string toolname = "";
// Right click, do something with object
if(button == 1)
{
+ actionstream<<player->getName()<<" right clicks object "
+ <<obj->getId()<<std::endl;
+
// Track hp changes super-crappily
u16 oldhp = player->hp;
// If it's not diggable, do nothing
if(content_diggable(material) == false)
{
- derr_server<<"Server: Not finishing digging: "
+ infostream<<"Server: Not finishing digging: "
<<"Node not diggable"
<<std::endl;
cannot_remove_node = true;
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p_under);
if(meta && meta->nodeRemovalDisabled() == true)
{
- derr_server<<"Server: Not finishing digging: "
+ infostream<<"Server: Not finishing digging: "
<<"Node metadata disables removal"
<<std::endl;
cannot_remove_node = true;
}
catch(InvalidPositionException &e)
{
- derr_server<<"Server: Not finishing digging: Node not found."
+ infostream<<"Server: Not finishing digging: Node not found."
<<" Adding block to emerge queue."
<<std::endl;
m_emerge_queue.addBlock(peer_id,
// Make sure the player is allowed to do it
if((getPlayerPrivs(player) & PRIV_BUILD) == 0)
{
- dstream<<"Player "<<player->getName()<<" cannot remove node"
+ infostream<<"Player "<<player->getName()<<" cannot remove node"
<<" because privileges are "<<getPlayerPrivs(player)
<<std::endl;
cannot_remove_node = true;
*/
if(cannot_remove_node)
{
- derr_server<<"Server: Not finishing digging."<<std::endl;
+ infostream<<"Server: Not finishing digging."<<std::endl;
// Client probably has wrong data.
// Set block not sent, so that client will get
// a valid one.
- dstream<<"Client "<<peer_id<<" tried to dig "
+ infostream<<"Client "<<peer_id<<" tried to dig "
<<"node; but node cannot be removed."
<<" setting MapBlock not sent."<<std::endl;
RemoteClient *client = getClient(peer_id);
return;
}
+ actionstream<<player->getName()<<" digs "<<PP(p_under)
+ <<", gets material "<<(int)material<<", mineral "
+ <<(int)mineral<<std::endl;
+
/*
Send the removal to all close-by players.
- If other player is close, send REMOVENODE
if(prop.diggable == false)
{
- derr_server<<"Server: WARNING: Player digged"
+ infostream<<"Server: WARNING: Player digged"
<<" with impossible material + tool"
<<" combination"<<std::endl;
}
bool no_enough_privs =
((getPlayerPrivs(player) & PRIV_BUILD)==0);
if(no_enough_privs)
- dstream<<"Player "<<player->getName()<<" cannot add node"
+ infostream<<"Player "<<player->getName()<<" cannot add node"
<<" because privileges are "<<getPlayerPrivs(player)
<<std::endl;
// Client probably has wrong data.
// Set block not sent, so that client will get
// a valid one.
- dstream<<"Client "<<peer_id<<" tried to place"
+ infostream<<"Client "<<peer_id<<" tried to place"
<<" node in invalid position; setting"
<<" MapBlock not sent."<<std::endl;
RemoteClient *client = getClient(peer_id);
}
catch(InvalidPositionException &e)
{
- derr_server<<"Server: Ignoring ADDNODE: Node not found"
+ infostream<<"Server: Ignoring ADDNODE: Node not found"
<<" Adding block to emerge queue."
<<std::endl;
m_emerge_queue.addBlock(peer_id,
MapNode n;
n.setContent(mitem->getMaterial());
+ actionstream<<player->getName()<<" places material "
+ <<(int)mitem->getMaterial()
+ <<" at "<<PP(p_under)<<std::endl;
+
// Calculate direction for wall mounted stuff
if(content_features(n).wall_mounted)
n.param2 = packDir(p_under - p_over);
MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(blockpos);
if(block==NULL)
{
- derr_server<<"Error while placing object: "
+ infostream<<"Error while placing object: "
"block not found"<<std::endl;
return;
}
if(g_settings->getBool("creative_mode") &&
(getPlayerPrivs(player) & PRIV_BUILD) == 0)
{
- derr_server<<"Not allowing player to drop item: "
+ infostream<<"Not allowing player to drop item: "
"creative mode and no build privs"<<std::endl;
return;
}
- dout_server<<"Placing a miscellaneous item on map"
- <<std::endl;
-
// Calculate a position for it
v3f pos = intToFloat(p_over, BS);
//pos.Y -= BS*0.45;
if(obj == NULL)
{
- derr_server<<"WARNING: item resulted in NULL object, "
+ infostream<<"WARNING: item resulted in NULL object, "
<<"not placing onto map"
<<std::endl;
}
else
{
+ actionstream<<player->getName()<<" places "<<item->getName()
+ <<" at "<<PP(p_over)<<std::endl;
+
// Add the object to the environment
m_env.addActiveObject(obj);
- dout_server<<"Placed object"<<std::endl;
+ infostream<<"Placed object"<<std::endl;
if(g_settings->getBool("creative_mode") == false)
{
if(item->getCount() <= dropcount)
{
if(item->getCount() < dropcount)
- dstream<<"WARNING: Server: dropped more items"
+ infostream<<"WARNING: Server: dropped more items"
<<" than the slot contains"<<std::endl;
InventoryList *ilist = player->inventory.getList("main");
*/
else
{
- derr_server<<"WARNING: Server: Invalid action "
+ infostream<<"WARNING: Server: Invalid action "
<<action<<std::endl;
}
}
[0] u16 command
[2] u8 button
*/
- dstream<<"TOSERVER_RELEASE ignored"<<std::endl;
+ infostream<<"TOSERVER_RELEASE ignored"<<std::endl;
}
#endif
else if(command == TOSERVER_SIGNTEXT)
{
- derr_server<<"Server: TOSERVER_SIGNTEXT not supported anymore"
+ infostream<<"Server: TOSERVER_SIGNTEXT not supported anymore"
<<std::endl;
return;
}
SignNodeMetadata *signmeta = (SignNodeMetadata*)meta;
signmeta->setText(text);
+ actionstream<<player->getName()<<" writes \""<<text<<"\" to sign "
+ <<" at "<<PP(p)<<std::endl;
+
v3s16 blockpos = getNodeBlockPos(p);
MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(blockpos);
if(block)
/*// Ignore inventory changes if in creative mode
if(g_settings->getBool("creative_mode") == true)
{
- dstream<<"TOSERVER_INVENTORY_ACTION: ignoring in creative mode"
+ infostream<<"TOSERVER_INVENTORY_ACTION: ignoring in creative mode"
<<std::endl;
return;
}*/
// Strip command and create a stream
std::string datastring((char*)&data[2], datasize-2);
- dstream<<"TOSERVER_INVENTORY_ACTION: data="<<datastring<<std::endl;
+ infostream<<"TOSERVER_INVENTORY_ACTION: data="<<datastring<<std::endl;
std::istringstream is(datastring, std::ios_base::binary);
// Create an action
InventoryAction *a = InventoryAction::deSerialize(is);
{
player->craftresult_is_preview = false;
clist->decrementMaterials(1);
+
+ /* Print out action */
+ InventoryList *list =
+ player->inventory.getList("craftresult");
+ assert(list);
+ InventoryItem *item = list->getItem(0);
+ actionstream<<player->getName()<<" crafts "
+ <<item->getName()<<std::endl;
}
/*
If the craftresult is placed on itself, move it to
}
else
{
- dstream<<"TOSERVER_INVENTORY_ACTION: "
+ infostream<<"TOSERVER_INVENTORY_ACTION: "
<<"InventoryAction::deSerialize() returned NULL"
<<std::endl;
}
if(line != L"")
{
- dstream<<"CHAT: "<<wide_to_narrow(line)<<std::endl;
+ if(send_to_others)
+ actionstream<<"CHAT: "<<wide_to_narrow(line)<<std::endl;
/*
Send the message to clients
if(g_settings->getBool("enable_damage"))
{
+ actionstream<<player->getName()<<" damaged by "
+ <<(int)damage<<" hp at "<<PP(player->getPosition()/BS)
+ <<std::endl;
+
HandlePlayerHP(player, damage);
}
else
newpwd += c;
}
- dstream<<"Server: Client requests a password change from "
+ infostream<<"Server: Client requests a password change from "
<<"'"<<oldpwd<<"' to '"<<newpwd<<"'"<<std::endl;
std::string playername = player->getName();
if(m_authmanager.exists(playername) == false)
{
- dstream<<"Server: playername not found in authmanager"<<std::endl;
+ infostream<<"Server: playername not found in authmanager"<<std::endl;
// Wrong old password supplied!!
SendChatMessage(peer_id, L"playername not found in authmanager");
return;
if(oldpwd != checkpwd)
{
- dstream<<"Server: invalid old password"<<std::endl;
+ infostream<<"Server: invalid old password"<<std::endl;
// Wrong old password supplied!!
SendChatMessage(peer_id, L"Invalid old password supplied. Password NOT changed.");
return;
}
+ actionstream<<player->getName()<<" changes password"<<std::endl;
+
m_authmanager.setPassword(playername, newpwd);
- dstream<<"Server: password change successful for "<<playername
+ infostream<<"Server: password change successful for "<<playername
<<std::endl;
SendChatMessage(peer_id, L"Password change successful");
}
{
if(player->hp != 0)
return;
-
+
RespawnPlayer(player);
+
+ actionstream<<player->getName()<<" respawns at "
+ <<PP(player->getPosition()/BS)<<std::endl;
}
else
{
- derr_server<<"WARNING: Server::ProcessData(): Ignoring "
+ infostream<<"Server::ProcessData(): Ignoring "
"unknown command "<<command<<std::endl;
}
} //try
catch(SendFailedException &e)
{
- derr_server<<"Server::ProcessData(): SendFailedException: "
+ errorstream<<"Server::ProcessData(): SendFailedException: "
<<"what="<<e.what()
<<std::endl;
}
void Server::onMapEditEvent(MapEditEvent *event)
{
- //dstream<<"Server::onMapEditEvent()"<<std::endl;
+ //infostream<<"Server::onMapEditEvent()"<<std::endl;
if(m_ignore_map_edit_events)
return;
MapEditEvent *e = event->clone();
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p);
if(meta)
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;
return NULL;
}
- dstream<<__FUNCTION_NAME<<": unknown id "<<id<<std::endl;
+ infostream<<__FUNCTION_NAME<<": unknown id "<<id<<std::endl;
return NULL;
}
void Server::inventoryModified(InventoryContext *c, std::string id)
return;
}
- dstream<<__FUNCTION_NAME<<": unknown id "<<id<<std::endl;
+ infostream<<__FUNCTION_NAME<<": unknown id "<<id<<std::endl;
}
core::list<PlayerInfo> Server::getPlayerInfo()
void Server::peerAdded(con::Peer *peer)
{
DSTACK(__FUNCTION_NAME);
- dout_server<<"Server::peerAdded(): peer->id="
+ infostream<<"Server::peerAdded(): peer->id="
<<peer->id<<std::endl;
PeerChange c;
void Server::deletingPeer(con::Peer *peer, bool timeout)
{
DSTACK(__FUNCTION_NAME);
- dout_server<<"Server::deletingPeer(): peer->id="
+ infostream<<"Server::deletingPeer(): peer->id="
<<peer->id<<", timeout="<<timeout<<std::endl;
PeerChange c;
{
Player *player = *i;
- /*dstream<<"Server sending player info for player with "
+ /*infostream<<"Server sending player info for player with "
"peer_id="<<player->peer_id<<std::endl;*/
writeU16(&data[start], player->peer_id);
v3f pos = player->getPosition();
f32 pitch = player->getPitch();
f32 yaw = player->getYaw();
- dstream<<"Server sending TOCLIENT_MOVE_PLAYER"
+ infostream<<"Server sending TOCLIENT_MOVE_PLAYER"
<<" pos=("<<pos.X<<","<<pos.Y<<","<<pos.Z<<")"
<<" pitch="<<pitch
<<" yaw="<<yaw
}
// Print result
- dstream<<"Server: Sending block ("<<p.X<<","<<p.Y<<","<<p.Z<<"): ";
+ infostream<<"Server: Sending block ("<<p.X<<","<<p.Y<<","<<p.Z<<"): ";
if(completely_air)
- dstream<<"[completely air] ";
- dstream<<std::endl;
+ infostream<<"[completely air] ";
+ infostream<<std::endl;
#endif
/*
writeS16(&reply[6], p.Z);
memcpy(&reply[8], *blockdata, blockdata.getSize());
- /*dstream<<"Server: Sending block ("<<p.X<<","<<p.Y<<","<<p.Z<<")"
+ /*infostream<<"Server: Sending block ("<<p.X<<","<<p.Y<<","<<p.Z<<")"
<<": \tpacket size: "<<replysize<<std::endl;*/
/*
}
else
{
- dstream<<"Server::HandlePlayerHP(): Player "
+ infostream<<"Server::HandlePlayerHP(): Player "
<<player->getName()<<" dies"<<std::endl;
player->hp = 0;
// Don't go underwater
if(groundheight < WATER_LEVEL)
{
- //dstream<<"-> Underwater"<<std::endl;
+ //infostream<<"-> Underwater"<<std::endl;
continue;
}
// Don't go to high places
if(groundheight > WATER_LEVEL + 4)
{
- //dstream<<"-> Underwater"<<std::endl;
+ //infostream<<"-> Underwater"<<std::endl;
continue;
}
// Found a good place
- //dstream<<"Searched through "<<i<<" places."<<std::endl;
+ //infostream<<"Searched through "<<i<<" places."<<std::endl;
break;
}
#endif
// If player is already connected, cancel
if(player->peer_id != 0)
{
- dstream<<"emergePlayer(): Player already connected"<<std::endl;
+ infostream<<"emergePlayer(): Player already connected"<<std::endl;
return NULL;
}
*/
if(m_env.getPlayer(peer_id) != NULL)
{
- dstream<<"emergePlayer(): Player with wrong name but same"
+ infostream<<"emergePlayer(): Player with wrong name but same"
" peer_id already exists"<<std::endl;
return NULL;
}
Set player position
*/
- dstream<<"Server: Finding spawn place for player \""
+ infostream<<"Server: Finding spawn place for player \""
<<player->getName()<<"\""<<std::endl;
v3f pos = findSpawnPos(m_env.getServerMap());
Player *player = m_env.getPlayer(c.peer_id);
if(player != NULL)
player->peer_id = 0;
+
+ /*
+ Print out action
+ */
+ {
+ std::ostringstream os(std::ios_base::binary);
+ for(core::map<u16, RemoteClient*>::Iterator
+ i = m_clients.getIterator();
+ i.atEnd() == false; i++)
+ {
+ RemoteClient *client = i.getNode()->getValue();
+ assert(client->peer_id == i.getNode()->getKey());
+ if(client->serialization_version == SER_FMT_VER_INVALID)
+ continue;
+ // Get player
+ Player *player = m_env.getPlayer(client->peer_id);
+ if(!player)
+ continue;
+ // Get name of player
+ os<<player->getName()<<" ";
+ }
+
+ actionstream<<player->getName()
+ <<" leaves game. List of players: "
+ <<os.str()<<std::endl;
+ }
}
// Delete client
{
PeerChange c = m_peer_change_queue.pop_front();
- dout_server<<"Server: Handling peer change: "
+ infostream<<"Server: Handling peer change: "
<<"id="<<c.peer_id<<", timeout="<<c.timeout
<<std::endl;
{
DSTACK(__FUNCTION_NAME);
- dstream<<DTIME<<std::endl;
- dstream<<"========================"<<std::endl;
- dstream<<"Running dedicated server"<<std::endl;
- dstream<<"========================"<<std::endl;
- dstream<<std::endl;
+ infostream<<DTIME<<std::endl;
+ infostream<<"========================"<<std::endl;
+ infostream<<"Running dedicated server"<<std::endl;
+ infostream<<"========================"<<std::endl;
+ infostream<<std::endl;
IntervalLimiter m_profiler_interval;
if(server.getShutdownRequested() || kill)
{
- dstream<<DTIME<<" dedicated_server_loop(): Quitting."<<std::endl;
+ infostream<<DTIME<<" dedicated_server_loop(): Quitting."<<std::endl;
break;
}
{
if(m_profiler_interval.step(0.030, profiler_print_interval))
{
- dstream<<"Profiler:"<<std::endl;
- g_profiler->print(dstream);
+ infostream<<"Profiler:"<<std::endl;
+ g_profiler->print(infostream);
g_profiler->clear();
}
}
u32 sum = PIChecksum(list);
if(sum != sum_old)
{
- dstream<<DTIME<<"Player info:"<<std::endl;
+ infostream<<DTIME<<"Player info:"<<std::endl;
for(i=list.begin(); i!=list.end(); i++)
{
- i->PrintLine(&dstream);
+ i->PrintLine(&infostream);
}
}
sum_old = sum;
#include "utility.h"
#include "settings.h"
+#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
+
void cmd_status(std::wostringstream &os,
ServerCommandContext *ctx)
{
std::string playername = wide_to_narrow(ctx->parms[1]);
u64 privs = ctx->server->getPlayerAuthPrivs(playername);
- if(ctx->parms[0] == L"grant")
+ if(ctx->parms[0] == L"grant"){
+ actionstream<<ctx->player->getName()<<" grants "
+ <<wide_to_narrow(ctx->parms[2])<<" to "
+ <<playername<<std::endl;
privs |= newprivs;
- else
+ } else {
+ actionstream<<ctx->player->getName()<<" revokes "
+ <<wide_to_narrow(ctx->parms[2])<<" from "
+ <<playername<<std::endl;
privs &= ~newprivs;
+ }
ctx->server->setPlayerAuthPrivs(playername, privs);
u32 time = stoi(wide_to_narrow(ctx->parms[1]));
ctx->server->setTimeOfDay(time);
os<<L"-!- time_of_day changed.";
+
+ actionstream<<ctx->player->getName()<<" sets time "
+ <<time<<std::endl;
}
void cmd_shutdown(std::wostringstream &os,
return;
}
- dstream<<DTIME<<" Server: Operator requested shutdown."
- <<std::endl;
+ actionstream<<ctx->player->getName()
+ <<" shuts down server"<<std::endl;
+
ctx->server->requestShutdown();
os<<L"*** Server shutting down (operator request)";
std::string confline = wide_to_narrow(ctx->paramstring);
+ actionstream<<ctx->player->getName()
+ <<" sets: "<<confline<<std::endl;
+
g_settings->parseConfigLine(confline);
ctx->server->saveConfig();
}
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->server->SendMovePlayer(ctx->player);
ctx->server->setIpBanned(ip_string, player->getName());
os<<L"-!- Banned "<<narrow_to_wide(ip_string)<<L"|"
<<narrow_to_wide(player->getName());
+
+ actionstream<<ctx->player->getName()<<" bans "
+ <<player->getName()<<" / "<<ip_string<<std::endl;
}
else
{
std::string desc = ctx->server->getBanDescription(ip_or_name);
ctx->server->unsetIpBanned(ip_or_name);
os<<L"-!- Unbanned "<<narrow_to_wide(desc);
+
+ actionstream<<ctx->player->getName()<<" unbans "
+ <<ip_or_name<<std::endl;
}
}
#include "defaultsettings.h"
#include "settings.h"
#include "profiler.h"
+#include "log.h"
/*
Settings.
// Connection
std::ostream *dout_con_ptr = &dummyout;
-std::ostream *derr_con_ptr = &dstream_no_stderr;
+std::ostream *derr_con_ptr = &verbosestream;
// Server
-std::ostream *dout_server_ptr = &dstream;
-std::ostream *derr_server_ptr = &dstream;
+std::ostream *dout_server_ptr = &infostream;
+std::ostream *derr_server_ptr = &errorstream;
// Client
-std::ostream *dout_client_ptr = &dstream;
-std::ostream *derr_client_ptr = &dstream;
+std::ostream *dout_client_ptr = &infostream;
+std::ostream *derr_client_ptr = &errorstream;
/*
gettime.h implementation
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[])
{
/*
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.
std::locale::global(std::locale("C"));
// This enables printing all characters in bitmap font
BEGIN_DEBUG_EXCEPTION_HANDLER
// Print startup message
- dstream<<DTIME<<PROJECT_NAME <<
+ actionstream<<PROJECT_NAME<<
" with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST
<<", "<<BUILD_INFO
<<std::endl;
allowed_options.insert("disable-unittests", ValueSpec(VALUETYPE_FLAG));
allowed_options.insert("enable-unittests", ValueSpec(VALUETYPE_FLAG));
allowed_options.insert("map-dir", ValueSpec(VALUETYPE_STRING));
+ allowed_options.insert("info-on-stderr", ValueSpec(VALUETYPE_FLAG));
Settings cmd_args;
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
bool r = g_settings->readConfigFile(cmd_args.get("config").c_str());
if(r == false)
{
- dstream<<"Could not read configuration from \""
+ errorstream<<"Could not read configuration from \""
<<cmd_args.get("config")<<"\""<<std::endl;
return 1;
}
} //try
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();
#include <sstream>
#include "debug.h"
#include "utility.h"
+#include "log.h"
enum ValueType
{
if(trimmedline[0] == '#')
return true;
- //dstream<<"trimmedline=\""<<trimmedline<<"\""<<std::endl;
+ //infostream<<"trimmedline=\""<<trimmedline<<"\""<<std::endl;
Strfnd sf(trim(line));
std::string value = sf.next("\n");
value = trim(value);
- /*dstream<<"Config name=\""<<name<<"\" value=\""
+ /*infostream<<"Config name=\""<<name<<"\" value=\""
<<value<<"\""<<std::endl;*/
m_settings[name] = value;
*/
std::string line;
std::getline(is, line);
- //dstream<<"got line: \""<<line<<"\""<<std::endl;
+ //infostream<<"got line: \""<<line<<"\""<<std::endl;
return parseConfigLine(line);
}
std::ifstream is(filename);
if(is.good() == false)
{
- dstream<<"Error opening configuration file \""
+ errorstream<<"Error opening configuration file \""
<<filename<<"\""<<std::endl;
return false;
}
- dstream<<"Parsing configuration file: \""
+ infostream<<"Parsing configuration file: \""
<<filename<<"\""<<std::endl;
while(parseConfigObject(is));
if(newvalue != value)
{
- dstream<<"Changing value of \""<<name<<"\" = \""
+ infostream<<"Changing value of \""<<name<<"\" = \""
<<value<<"\" -> \""<<newvalue<<"\""
<<std::endl;
}
*/
bool updateConfigFile(const char *filename)
{
- dstream<<"Updating configuration file: \""
+ infostream<<"Updating configuration file: \""
<<filename<<"\""<<std::endl;
core::list<std::string> objects;
std::ifstream is(filename);
if(is.good() == false)
{
- dstream<<"INFO: updateConfigFile():"
+ infostream<<"updateConfigFile():"
" Error opening configuration file"
" for reading: \""
<<filename<<"\""<<std::endl;
std::ofstream os(filename);
if(os.good() == false)
{
- dstream<<"Error opening configuration file"
+ errorstream<<"Error opening configuration file"
" for writing: \""
<<filename<<"\""<<std::endl;
return false;
continue;
std::string name = i.getNode()->getKey();
std::string value = i.getNode()->getValue();
- dstream<<"Adding \""<<name<<"\" = \""<<value<<"\""
+ infostream<<"Adding \""<<name<<"\" = \""<<value<<"\""
<<std::endl;
os<<name<<" = "<<value<<"\n";
}
std::string argname = argv[i];
if(argname.substr(0, 2) != "--")
{
- dstream<<"Invalid command-line parameter \""
+ errorstream<<"Invalid command-line parameter \""
<<argname<<"\": --<option> expected."<<std::endl;
return false;
}
n = allowed_options.find(name);
if(n == NULL)
{
- dstream<<"Unknown command-line parameter \""
+ errorstream<<"Unknown command-line parameter \""
<<argname<<"\""<<std::endl;
return false;
}
{
if(i >= argc)
{
- dstream<<"Invalid command-line parameter \""
+ errorstream<<"Invalid command-line parameter \""
<<name<<"\": missing value"<<std::endl;
return false;
}
}
- dstream<<"Valid command-line parameter: \""
+ infostream<<"Valid command-line parameter: \""
<<name<<"\" = \""<<value<<"\""
<<std::endl;
set(name, value);
n = m_defaults.find(name);
if(n == NULL)
{
- dstream<<"INFO: Settings: Setting not found: \""
+ infostream<<"Settings: Setting not found: \""
<<name<<"\""<<std::endl;
throw SettingNotFoundException("Setting not found");
}
#include "content_mapnode.h"
#include "mapsector.h"
#include "settings.h"
+#include "log.h"
/*
Asserts that the exception occurs
{
void Run()
{
- /*dstream<<"wrapDegrees(100.0) = "<<wrapDegrees(100.0)<<std::endl;
- dstream<<"wrapDegrees(720.5) = "<<wrapDegrees(720.5)<<std::endl;
- dstream<<"wrapDegrees(-0.5) = "<<wrapDegrees(-0.5)<<std::endl;*/
+ /*infostream<<"wrapDegrees(100.0) = "<<wrapDegrees(100.0)<<std::endl;
+ infostream<<"wrapDegrees(720.5) = "<<wrapDegrees(720.5)<<std::endl;
+ infostream<<"wrapDegrees(-0.5) = "<<wrapDegrees(-0.5)<<std::endl;*/
assert(fabs(wrapDegrees(100.0) - 100.0) < 0.001);
assert(fabs(wrapDegrees(720.5) - 0.5) < 0.001);
assert(fabs(wrapDegrees(-0.5) - (-0.5)) < 0.001);
std::string str_out = os.str();
- dstream<<"str_out.size()="<<str_out.size()<<std::endl;
- dstream<<"TestCompress: 1,5,5,1 -> ";
+ infostream<<"str_out.size()="<<str_out.size()<<std::endl;
+ infostream<<"TestCompress: 1,5,5,1 -> ";
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);
decompress(is, os2, 0);
std::string str_out2 = os2.str();
- dstream<<"decompress: ";
+ infostream<<"decompress: ";
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());
std::string str_out = os.str();
- dstream<<"str_out.size()="<<str_out.size()<<std::endl;
- dstream<<"TestCompress: 1,5,5,1 -> ";
+ infostream<<"str_out.size()="<<str_out.size()<<std::endl;
+ infostream<<"TestCompress: 1,5,5,1 -> ";
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);
decompress(is, os2, SER_FMT_VER_HIGHEST);
std::string str_out2 = os2.str();
- dstream<<"decompress: ";
+ infostream<<"decompress: ";
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(aa.size() == results.size());
- dstream<<"Result of diff:"<<std::endl;
+ infostream<<"Result of diff:"<<std::endl;
for(core::list<VoxelArea>::Iterator
i = aa.begin(); i != aa.end(); i++)
{
- i->print(dstream);
- dstream<<std::endl;
+ i->print(infostream);
+ infostream<<std::endl;
s32 j = results.linear_search(*i);
assert(j != -1);
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.print(dstream);
+ v.print(infostream);
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)));
- v.print(dstream);
+ v.print(infostream);
- dstream<<"*** Adding area ***"<<std::endl;
+ infostream<<"*** Adding area ***"<<std::endl;
v.addArea(a);
- v.print(dstream);
+ v.print(infostream);
assert(v.getNode(v3s16(-1,0,-1)).getContent() == 2);
EXCEPTION_CHECK(InvalidPositionException, v.getNode(v3s16(0,1,1)));
p++;
}
- v.print(dstream, VOXELPRINT_WATERPRESSURE);
+ v.print(infostream, VOXELPRINT_WATERPRESSURE);
core::map<v3s16, u8> active_nodes;
v.updateAreaWaterPressure(area, active_nodes);
- v.print(dstream, VOXELPRINT_WATERPRESSURE);
+ v.print(infostream, VOXELPRINT_WATERPRESSURE);
//s16 highest_y = -32768;
/*
//v.flowWater(active_nodes, 0, true, 1000);
v.flowWater(active_nodes, 0, false, 1000);
- dstream<<"Final result of flowWater:"<<std::endl;
- v.print(dstream, VOXELPRINT_WATERPRESSURE);
+ infostream<<"Final result of flowWater:"<<std::endl;
+ v.print(infostream, VOXELPRINT_WATERPRESSURE);
#endif
//assert(0);
assert(readU8(&p1.data[6]) == channel);
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);
- /*dstream<<"p2.getSize()="<<p2.getSize()<<", data1.getSize()="
+ /*infostream<<"p2.getSize()="<<p2.getSize()<<", data1.getSize()="
<<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;
- 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(readU8(&p2[0]) == TYPE_RELIABLE);
}
void peerAdded(con::Peer *peer)
{
- dstream<<"Handler("<<name<<")::peerAdded(): "
+ infostream<<"Handler("<<name<<")::peerAdded(): "
"id="<<peer->id<<std::endl;
last_id = peer->id;
count++;
}
void deletingPeer(con::Peer *peer, bool timeout)
{
- dstream<<"Handler("<<name<<")::deletingPeer(): "
+ infostream<<"Handler("<<name<<")::deletingPeer(): "
"id="<<peer->id
<<", timeout="<<timeout<<std::endl;
last_id = peer->id;
Handler hand_server("server");
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);
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);
assert(hand_server.count == 0);
sleep_ms(50);
Address server_address(127,0,0,1, 30001);
- dstream<<"** running client.Connect()"<<std::endl;
+ infostream<<"** running client.Connect()"<<std::endl;
client.Connect(server_address);
sleep_ms(50);
{
u16 peer_id;
u8 data[100];
- dstream<<"** running server.Receive()"<<std::endl;
+ infostream<<"** running server.Receive()"<<std::endl;
u32 size = server.Receive(peer_id, data, 100);
- dstream<<"** Server received: peer_id="<<peer_id
+ infostream<<"** Server received: peer_id="<<peer_id
<<", size="<<size
<<std::endl;
}
{
u16 peer_id;
u8 data[100];
- dstream<<"** running client.Receive()"<<std::endl;
+ infostream<<"** running client.Receive()"<<std::endl;
u32 size = client.Receive(peer_id, data, 100);
- dstream<<"** Client received: peer_id="<<peer_id
+ infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size
<<std::endl;
}
{
u16 peer_id;
u8 data[100];
- dstream<<"** running server.Receive()"<<std::endl;
+ infostream<<"** running server.Receive()"<<std::endl;
u32 size = server.Receive(peer_id, data, 100);
- dstream<<"** Server received: peer_id="<<peer_id
+ infostream<<"** Server received: peer_id="<<peer_id
<<", size="<<size
<<std::endl;
}
u32 datasize = sizeof(data);*/
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);
sleep_ms(50);
u16 peer_id;
u8 recvdata[100];
- dstream<<"** running server.Receive()"<<std::endl;
+ infostream<<"** running server.Receive()"<<std::endl;
u32 size = server.Receive(peer_id, recvdata, 100);
- dstream<<"** Server received: peer_id="<<peer_id
+ infostream<<"** Server received: peer_id="<<peer_id
<<", size="<<size
<<", data="<<*data
<<std::endl;
Address 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;
u8 chn = 0;
sleep_ms(50);
- dstream<<"*** Receiving the packets"<<std::endl;
+ infostream<<"*** Receiving the packets"<<std::endl;
u16 peer_id;
u8 recvdata[20];
u32 size;
- dstream<<"** running client.Receive()"<<std::endl;
+ infostream<<"** running client.Receive()"<<std::endl;
peer_id = 132;
size = client.Receive(peer_id, recvdata, 20);
- dstream<<"** Client received: peer_id="<<peer_id
+ infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size
<<", data="<<recvdata
<<std::endl;
assert(memcmp(*data1, recvdata, data1.getSize()) == 0);
assert(peer_id == PEER_ID_SERVER);
- dstream<<"** running client.Receive()"<<std::endl;
+ infostream<<"** running client.Receive()"<<std::endl;
peer_id = 132;
size = client.Receive(peer_id, recvdata, 20);
- dstream<<"** Client received: peer_id="<<peer_id
+ infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size
<<", data="<<recvdata
<<std::endl;
bool got_exception = false;
try
{
- dstream<<"** running client.Receive()"<<std::endl;
+ infostream<<"** running client.Receive()"<<std::endl;
peer_id = 132;
size = client.Receive(peer_id, recvdata, 20);
- dstream<<"** Client received: peer_id="<<peer_id
+ infostream<<"** Client received: peer_id="<<peer_id
<<", size="<<size
<<", data="<<recvdata
<<std::endl;
}
catch(con::NoIncomingDataException &e)
{
- dstream<<"** No incoming data for client"<<std::endl;
+ infostream<<"** No incoming data for client"<<std::endl;
got_exception = true;
}
assert(got_exception);
data1[i] = i/4;
}
- dstream<<"Sending data (size="<<datasize<<"):";
+ infostream<<"Sending data (size="<<datasize<<"):";
for(int i=0; i<datasize && i<20; i++){
if(i%2==0) DEBUGPRINT(" ");
DEBUGPRINT("%.2X", ((int)((const char*)*data1)[i])&0xff);
}
if(datasize>20)
- dstream<<"...";
- dstream<<std::endl;
+ infostream<<"...";
+ infostream<<std::endl;
server.Send(peer_id_client, 0, data1, true);
sleep_ms(50);
u8 recvdata[datasize + 1000];
- dstream<<"** running client.Receive()"<<std::endl;
+ infostream<<"** running client.Receive()"<<std::endl;
u16 peer_id = 132;
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
<<std::endl;
- dstream<<"Received data (size="<<size<<"):";
+ infostream<<"Received data (size="<<size<<"):";
for(int i=0; i<size && i<20; i++){
if(i%2==0) DEBUGPRINT(" ");
DEBUGPRINT("%.2X", ((int)((const char*)recvdata)[i])&0xff);
}
if(size>20)
- dstream<<"...";
- dstream<<std::endl;
+ infostream<<"...";
+ infostream<<std::endl;
assert(memcmp(*data1, recvdata, data1.getSize()) == 0);
assert(peer_id == PEER_ID_SERVER);
#define TEST(X)\
{\
X x;\
- dstream<<"Running " #X <<std::endl;\
+ infostream<<"Running " #X <<std::endl;\
x.Run();\
}
void run_tests()
{
DSTACK(__FUNCTION_NAME);
- dstream<<"run_tests() started"<<std::endl;
+ infostream<<"run_tests() started"<<std::endl;
TEST(TestUtilities);
TEST(TestSettings);
TEST(TestCompress);
TEST(TestConnection);
dout_con<<"=== END RUNNING UNIT TESTS FOR CONNECTION ==="<<std::endl;
}
- dstream<<"run_tests() passed"<<std::endl;
+ infostream<<"run_tests() passed"<<std::endl;
}
#include "utility.h"
#include "settings.h"
#include <ICameraSceneNode.h>
+#include "log.h"
/*
A cache from texture name to texture path
if(g_settings->getBool("enable_texture_atlas"))
buildMainAtlas();
else
- dstream<<"INFO: Not building texture atlas."<<std::endl;
+ infostream<<"Not building texture atlas."<<std::endl;
}
TextureSource::~TextureSource()
GetRequest<std::string, u32, u8, u8>
request = m_get_texture_queue.pop();
- dstream<<"INFO: TextureSource::processQueue(): "
+ infostream<<"TextureSource::processQueue(): "
<<"got texture request with "
<<"name=\""<<request.key<<"\""
<<std::endl;
u32 TextureSource::getTextureId(const std::string &name)
{
- //dstream<<"INFO: getTextureId(): \""<<name<<"\""<<std::endl;
+ //infostream<<"getTextureId(): \""<<name<<"\""<<std::endl;
{
/*
}
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
ResultQueue<std::string, u32, u8, u8> result_queue;
// Throw a request in
m_get_texture_queue.add(name, 0, 0, &result_queue);
- dstream<<"INFO: Waiting for texture from main thread, name=\""
+ infostream<<"Waiting for texture from main thread, name=\""
<<name<<"\""<<std::endl;
try
}
catch(ItemNotFoundException &e)
{
- dstream<<"WARNING: Waiting for texture timed out."<<std::endl;
+ infostream<<"Waiting for texture timed out."<<std::endl;
return 0;
}
}
- dstream<<"WARNING: getTextureId(): Failed"<<std::endl;
+ infostream<<"getTextureId(): Failed"<<std::endl;
return 0;
}
*/
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
if(name == "")
{
- dstream<<"INFO: getTextureIdDirect(): name is empty"<<std::endl;
+ infostream<<"getTextureIdDirect(): name is empty"<<std::endl;
return 0;
}
*/
if(get_current_thread_id() != m_main_thread)
{
- dstream<<"ERROR: TextureSource::getTextureIdDirect() "
+ errorstream<<"TextureSource::getTextureIdDirect() "
"called not from main thread"<<std::endl;
return 0;
}
n = m_name_to_id.find(name);
if(n != NULL)
{
- dstream<<"INFO: getTextureIdDirect(): \""<<name
+ infostream<<"getTextureIdDirect(): \""<<name
<<"\" found in cache"<<std::endl;
return n->getValue();
}
}
- dstream<<"INFO: getTextureIdDirect(): \""<<name
+ infostream<<"getTextureIdDirect(): \""<<name
<<"\" NOT found in cache. Creating it."<<std::endl;
/*
{
// Construct base name
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<<"\" = \""
<<base_image_name<<"\""<<std::endl;*/
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();
assert(driver);
if(image == NULL)
{
- dstream<<"WARNING: getTextureIdDirect(): NULL image in "
+ infostream<<"getTextureIdDirect(): NULL image in "
<<"cache: \""<<base_image_name<<"\""
<<std::endl;
}
core::rect<s32>(pos_from, dim) // from
);
- /*dstream<<"INFO: getTextureIdDirect(): Loaded \""
+ /*infostream<<"getTextureIdDirect(): Loaded \""
<<base_image_name<<"\" from image cache"
<<std::endl;*/
}
*/
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
if(generate_image(last_part_of_name, baseimg, m_device) == false)
{
- dstream<<"INFO: getTextureIdDirect(): "
+ infostream<<"getTextureIdDirect(): "
"failed to generate \""<<last_part_of_name<<"\""
<<std::endl;
}
// If no resulting image, print a warning
if(baseimg == NULL)
{
- dstream<<"WARNING: getTextureIdDirect(): baseimg is NULL (attempted to"
+ infostream<<"getTextureIdDirect(): baseimg is NULL (attempted to"
" create texture \""<<name<<"\""<<std::endl;
}
m_atlaspointer_cache.push_back(nap);
m_name_to_id.insert(name, id);
- /*dstream<<"INFO: getTextureIdDirect(): "
+ /*infostream<<"getTextureIdDirect(): "
<<"Returning id="<<id<<" for name \""<<name<<"\""<<std::endl;*/
return id;
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()<<std::endl;
return "";
void TextureSource::buildMainAtlas()
{
- dstream<<"TextureSource::buildMainAtlas()"<<std::endl;
+ infostream<<"TextureSource::buildMainAtlas()"<<std::endl;
//return; // Disable (for testing)
//assert(atlas_img);
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;
return;
}
video::IImage *img2 = generate_image_from_scratch(name, m_device);
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;
}
if(dim.Width > max_size_in_atlas.Width
|| 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;
continue;
}
// Stop making atlas if atlas is full
if(pos_in_atlas.Y + dim.Height > atlas_dim.Height)
{
- dstream<<"WARNING: TextureSource::buildMainAtlas(): "
+ infostream<<"TextureSource::buildMainAtlas(): "
<<"Atlas is full, not adding more textures."
<<std::endl;
break;
}
- dstream<<"INFO: TextureSource::buildMainAtlas(): Adding \""<<name
+ infostream<<"TextureSource::buildMainAtlas(): Adding \""<<name
<<"\" to texture atlas"<<std::endl;
// Tile it a few times in the X direction
if(m_name_to_id.find(name) == NULL)
continue;
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;
}
video::IImage* generate_image_from_scratch(std::string name,
IrrlichtDevice *device)
{
- /*dstream<<"INFO: generate_image_from_scratch(): "
+ /*infostream<<"generate_image_from_scratch(): "
"\""<<name<<"\""<<std::endl;*/
video::IVideoDriver* driver = device->getVideoDriver();
}
}
- /*dstream<<"INFO: generate_image_from_scratch(): "
+ /*infostream<<"generate_image_from_scratch(): "
<<"last_separator_position="<<last_separator_position
<<std::endl;*/
{
// Construct base name
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<<"\" = \""
<<base_image_name<<"\""<<std::endl;*/
baseimg = generate_image_from_scratch(base_image_name, device);
*/
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
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<<"\""
<<std::endl;
return NULL;
{
// A normal texture; load it from a file
std::string path = getTexturePath(part_of_name.c_str());
- /*dstream<<"INFO: generate_image(): Loading path \""<<path
+ /*infostream<<"generate_image(): Loading path \""<<path
<<"\""<<std::endl;*/
video::IImage *image = driver->createImageFromFile(path.c_str());
if(image == NULL)
{
- dstream<<"WARNING: generate_image(): Could not load image \""
+ infostream<<"generate_image(): Could not load image \""
<<part_of_name<<"\" from path \""<<path<<"\""
<<" while building texture"<<std::endl;
//return false;
- dstream<<"WARNING: generate_image(): Creating a dummy"
+ infostream<<"generate_image(): Creating a dummy"
<<" image for \""<<part_of_name<<"\""<<std::endl;
// Just create a dummy image
// If base image is NULL, load as base.
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.
Otherwise images with alpha cannot be blitted on
// Else blit on base.
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
core::dimension2d<u32> dim = image->getDimension();
//core::dimension2d<u32> dim(16,16);
{
// A special texture modification
- dstream<<"INFO: generate_image(): generating special "
+ infostream<<"generate_image(): generating special "
<<"modification \""<<part_of_name<<"\""
<<std::endl;
{
if(baseimg == NULL)
{
- dstream<<"WARNING: generate_image(): baseimg==NULL "
+ infostream<<"generate_image(): baseimg==NULL "
<<"for part_of_name=\""<<part_of_name
<<"\", cancelling."<<std::endl;
return false;
sf.next(":");
u32 w0 = stoi(sf.next("x"));
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);
baseimg = driver->createImage(video::ECF_A8R8G8B8, dim);
while(sf.atend() == false)
u32 x = stoi(sf.next(","));
u32 y = stoi(sf.next("="));
std::string filename = sf.next(":");
- dstream<<"INFO: Adding \""<<filename
+ infostream<<"Adding \""<<filename
<<"\" to combined ("<<x<<","<<y<<")"
<<std::endl;
video::IImage *img = driver->createImageFromFile(
if(img)
{
core::dimension2d<u32> dim = img->getDimension();
- dstream<<"INFO: Size "<<dim.Width
+ infostream<<"Size "<<dim.Width
<<"x"<<dim.Height<<std::endl;
core::position2d<s32> pos_base(x, y);
video::IImage *img2 =
}
else
{
- dstream<<"WARNING: img==NULL"<<std::endl;
+ infostream<<"img==NULL"<<std::endl;
}
}
}
{
if(baseimg == NULL)
{
- dstream<<"WARNING: generate_image(): baseimg==NULL "
+ infostream<<"generate_image(): baseimg==NULL "
<<"for part_of_name=\""<<part_of_name
<<"\", cancelling."<<std::endl;
return false;
{
if(baseimg != NULL)
{
- dstream<<"WARNING: generate_image(): baseimg!=NULL "
+ infostream<<"generate_image(): baseimg!=NULL "
<<"for part_of_name=\""<<part_of_name
<<"\", cancelling."<<std::endl;
return false;
std::string path = getTexturePath(filename.c_str());
- dstream<<"INFO: generate_image(): Loading path \""<<path
+ infostream<<"generate_image(): Loading path \""<<path
<<"\""<<std::endl;
video::IImage *image = driver->createImageFromFile(path.c_str());
if(image == NULL)
{
- dstream<<"WARNING: generate_image(): Loading path \""
+ infostream<<"generate_image(): Loading path \""
<<path<<"\" failed"<<std::endl;
}
else
{
if(baseimg != NULL)
{
- dstream<<"WARNING: generate_image(): baseimg!=NULL "
+ infostream<<"generate_image(): baseimg!=NULL "
<<"for part_of_name=\""<<part_of_name
<<"\", cancelling."<<std::endl;
return false;
std::string path = getTexturePath(filename.c_str());
- dstream<<"INFO: generate_image(): Loading path \""<<path
+ infostream<<"generate_image(): Loading path \""<<path
<<"\""<<std::endl;
video::IImage *image = driver->createImageFromFile(path.c_str());
if(image == NULL)
{
- dstream<<"WARNING: generate_image(): Loading path \""
+ infostream<<"generate_image(): Loading path \""
<<path<<"\" failed"<<std::endl;
}
else
{
if(baseimg != NULL)
{
- dstream<<"WARNING: generate_image(): baseimg!=NULL "
+ infostream<<"generate_image(): baseimg!=NULL "
<<"for part_of_name=\""<<part_of_name
<<"\", cancelling."<<std::endl;
return false;
std::string path = getTexturePath(filename.c_str());
- dstream<<"INFO: generate_image(): Loading path \""<<path
+ infostream<<"generate_image(): Loading path \""<<path
<<"\""<<std::endl;
video::IImage *image = driver->createImageFromFile(path.c_str());
if(image == NULL)
{
- dstream<<"WARNING: generate_image(): Loading path \""
+ infostream<<"generate_image(): Loading path \""
<<path<<"\" failed"<<std::endl;
}
else
{
if(baseimg != NULL)
{
- dstream<<"WARNING: generate_image(): baseimg!=NULL "
+ infostream<<"generate_image(): baseimg!=NULL "
<<"for part_of_name=\""<<part_of_name
<<"\", cancelling."<<std::endl;
return 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;
baseimg = generate_image_from_scratch(
imagename_top, device);
u32 w0 = 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);
// Generate images for the faces of the cube
}
else
{
- dstream<<"WARNING: generate_image(): Invalid "
+ infostream<<"generate_image(): Invalid "
" modification: \""<<part_of_name<<"\""<<std::endl;
}
}
#include "gettime.h"
#include "sha1.h"
#include "base64.h"
+#include "log.h"
TimeTaker::TimeTaker(const char *name, u32 *result)
{
else
{
if(quiet == false)
- std::cout<<m_name<<" took "<<dtime<<"ms"<<std::endl;
+ infostream<<m_name<<" took "<<dtime<<"ms"<<std::endl;
}
m_running = false;
return dtime;
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
// Sets the color of all vertices in the mesh
void setMeshVerticesColor(scene::IMesh* mesh, video::SColor& color)
void mysrand(unsigned seed);
#define MYRAND_MAX 32767
-inline int myrand_range(int min, int max)
-{
- if(max-min > MYRAND_MAX)
- {
- dstream<<"WARNING: myrand_range: max-min > MYRAND_MAX"<<std::endl;
- assert(0);
- }
- if(min > max)
- {
- assert(0);
- return max;
- }
- return (myrand()%(max-min+1))+min;
-}
+int myrand_range(int min, int max);
/*
Miscellaneous functions