forked from Mirrorlandia_minetest/minetest
Use the logger; also, default to not showing much crap in console. Use --info-on-stderr to enable crap.
This commit is contained in:
parent
4846846a2d
commit
b65a5aceb0
139
src/client.cpp
139
src/client.cpp
@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "mapblock.h"
|
||||
#include "settings.h"
|
||||
#include "profiler.h"
|
||||
#include "log.h"
|
||||
|
||||
/*
|
||||
QueuedMeshUpdate
|
||||
@ -131,6 +132,8 @@ void * MeshUpdateThread::Thread()
|
||||
{
|
||||
ThreadStarted();
|
||||
|
||||
log_register_thread("MeshUpdateThread");
|
||||
|
||||
DSTACK(__FUNCTION_NAME);
|
||||
|
||||
BEGIN_DEBUG_EXCEPTION_HANDLER
|
||||
@ -163,7 +166,7 @@ void * MeshUpdateThread::Thread()
|
||||
r.mesh = mesh_new;
|
||||
r.ack_block_to_server = q->ack_block_to_server;
|
||||
|
||||
/*dstream<<"MeshUpdateThread: Processed "
|
||||
/*infostream<<"MeshUpdateThread: Processed "
|
||||
<<"("<<q->p.X<<","<<q->p.Y<<","<<q->p.Z<<")"
|
||||
<<std::endl;*/
|
||||
|
||||
@ -172,7 +175,7 @@ void * MeshUpdateThread::Thread()
|
||||
delete q;
|
||||
}
|
||||
|
||||
END_DEBUG_EXCEPTION_HANDLER
|
||||
END_DEBUG_EXCEPTION_HANDLER(errorstream)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -273,7 +276,7 @@ void Client::step(float dtime)
|
||||
else
|
||||
m_ignore_damage_timer = 0.0;
|
||||
|
||||
//dstream<<"Client steps "<<dtime<<std::endl;
|
||||
//infostream<<"Client steps "<<dtime<<std::endl;
|
||||
|
||||
{
|
||||
//TimeTaker timer("ReceiveAll()", m_device);
|
||||
@ -298,8 +301,8 @@ void Client::step(float dtime)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -343,9 +346,9 @@ void Client::step(float dtime)
|
||||
|
||||
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;*/
|
||||
|
||||
/*
|
||||
@ -424,7 +427,7 @@ void Client::step(float dtime)
|
||||
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);
|
||||
@ -458,7 +461,7 @@ void Client::step(float dtime)
|
||||
&deleted_blocks);
|
||||
|
||||
/*if(deleted_blocks.size() > 0)
|
||||
dstream<<"Client: Unloaded "<<deleted_blocks.size()
|
||||
infostream<<"Client: Unloaded "<<deleted_blocks.size()
|
||||
<<" unused blocks"<<std::endl;*/
|
||||
|
||||
/*
|
||||
@ -561,7 +564,7 @@ void Client::step(float dtime)
|
||||
//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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -587,7 +590,7 @@ void Client::step(float dtime)
|
||||
//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;*/
|
||||
|
||||
@ -601,7 +604,7 @@ void Client::step(float dtime)
|
||||
}
|
||||
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
|
||||
@ -628,12 +631,12 @@ void Client::step(float dtime)
|
||||
// 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;
|
||||
}
|
||||
@ -652,7 +655,7 @@ void Client::ReceiveAll()
|
||||
}
|
||||
catch(con::InvalidIncomingDataException &e)
|
||||
{
|
||||
dout_client<<DTIME<<"Client::ReceiveAll(): "
|
||||
infostream<<"Client::ReceiveAll(): "
|
||||
"InvalidIncomingDataException: what()="
|
||||
<<e.what()<<std::endl;
|
||||
}
|
||||
@ -691,7 +694,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
|
||||
ToClientCommand command = (ToClientCommand)readU16(&data[0]);
|
||||
|
||||
//dstream<<"Client: received command="<<command<<std::endl;
|
||||
//infostream<<"Client: received command="<<command<<std::endl;
|
||||
m_packetcounter.add((u16)command);
|
||||
|
||||
/*
|
||||
@ -700,7 +703,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
*/
|
||||
if(sender_peer_id != PEER_ID_SERVER)
|
||||
{
|
||||
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;
|
||||
@ -716,7 +719,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
|
||||
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)
|
||||
{
|
||||
@ -725,13 +728,13 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
|
||||
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;
|
||||
}
|
||||
@ -757,7 +760,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
{
|
||||
// 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
|
||||
@ -788,7 +791,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
|
||||
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;
|
||||
@ -842,9 +845,9 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
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);
|
||||
@ -867,7 +870,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
/*
|
||||
Update an existing block
|
||||
*/
|
||||
//dstream<<"Updating"<<std::endl;
|
||||
//infostream<<"Updating"<<std::endl;
|
||||
block->deSerialize(istr, ser_version);
|
||||
}
|
||||
else
|
||||
@ -875,7 +878,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
/*
|
||||
Create a new block
|
||||
*/
|
||||
//dstream<<"Creating new"<<std::endl;
|
||||
//infostream<<"Creating new"<<std::endl;
|
||||
block = new MapBlock(&m_env.getMap(), p);
|
||||
block->deSerialize(istr, ser_version);
|
||||
sector->insertBlock(block);
|
||||
@ -921,12 +924,12 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
/*
|
||||
Add it to mesh update queue and set it to be acknowledged after update.
|
||||
*/
|
||||
//std::cerr<<"Adding mesh update task for received block"<<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;
|
||||
{
|
||||
@ -935,7 +938,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_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;
|
||||
@ -972,7 +975,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
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;
|
||||
@ -984,7 +987,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
player->setPitch(pitch);
|
||||
player->setYaw(yaw);
|
||||
|
||||
/*dstream<<"Client: player "<<peer_id
|
||||
/*infostream<<"Client: player "<<peer_id
|
||||
<<" pitch="<<pitch
|
||||
<<" yaw="<<yaw<<std::endl;*/
|
||||
|
||||
@ -1001,13 +1004,13 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
}
|
||||
// Cancel if we don't have a peer id
|
||||
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
|
||||
@ -1026,7 +1029,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
|
||||
players_alive.push_back(peer_id);
|
||||
|
||||
/*dstream<<DTIME<<"peer_id="<<peer_id
|
||||
/*infostream<<"peer_id="<<peer_id
|
||||
<<" name="<<((char*)&data[start+2])<<std::endl;*/
|
||||
|
||||
// Don't update the info of the local player
|
||||
@ -1047,7 +1050,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
-1);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1060,7 +1063,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
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++)
|
||||
@ -1072,7 +1075,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
// Warn about a special case
|
||||
if((*ip)->peer_id == 0)
|
||||
{
|
||||
dstream<<DTIME<<"WARNING: Client: Removing "
|
||||
infostream<<"Client: Removing "
|
||||
"dead player with id=0"<<std::endl;
|
||||
}
|
||||
|
||||
@ -1086,11 +1089,11 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
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);
|
||||
}
|
||||
@ -1098,7 +1101,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
}
|
||||
else if(command == TOCLIENT_SECTORMETA)
|
||||
{
|
||||
dstream<<"Client received DEPRECATED TOCLIENT_SECTORMETA"<<std::endl;
|
||||
infostream<<"Client received DEPRECATED TOCLIENT_SECTORMETA"<<std::endl;
|
||||
#if 0
|
||||
/*
|
||||
[0] u16 command
|
||||
@ -1108,7 +1111,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
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
|
||||
@ -1121,14 +1124,14 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
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);
|
||||
@ -1154,7 +1157,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
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();
|
||||
@ -1167,8 +1170,8 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
|
||||
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
|
||||
@ -1233,7 +1236,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
// Read active block count
|
||||
u16 blockcount = readU16(is);
|
||||
if(blockcount != 0){
|
||||
dstream<<"WARNING: TOCLIENT_OBJECTDATA: blockcount != 0 "
|
||||
infostream<<"TOCLIENT_OBJECTDATA: blockcount != 0 "
|
||||
"not supported"<<std::endl;
|
||||
return;
|
||||
}
|
||||
@ -1245,7 +1248,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
|
||||
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:
|
||||
@ -1257,7 +1260,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
|
||||
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;
|
||||
}
|
||||
@ -1285,7 +1288,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
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);
|
||||
@ -1414,7 +1417,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
/*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
|
||||
@ -1449,13 +1452,13 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
|
||||
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;
|
||||
@ -1464,15 +1467,15 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1495,7 +1498,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
|
||||
}
|
||||
else
|
||||
{
|
||||
dout_client<<DTIME<<"WARNING: Client: Ignoring unknown command "
|
||||
infostream<<"Client: Ignoring unknown command "
|
||||
<<command<<std::endl;
|
||||
}
|
||||
}
|
||||
@ -1510,7 +1513,7 @@ void Client::groundAction(u8 action, v3s16 nodepos_undersurface,
|
||||
v3s16 nodepos_oversurface, u16 item)
|
||||
{
|
||||
if(connectedAndInitialized() == false){
|
||||
dout_client<<DTIME<<"Client::groundAction() "
|
||||
infostream<<"Client::groundAction() "
|
||||
"cancelled (not connected)"
|
||||
<<std::endl;
|
||||
return;
|
||||
@ -1542,7 +1545,7 @@ void Client::groundAction(u8 action, v3s16 nodepos_undersurface,
|
||||
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;
|
||||
@ -1954,12 +1957,12 @@ Inventory* Client::getInventory(InventoryContext *c, std::string id)
|
||||
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)
|
||||
@ -1977,7 +1980,7 @@ ClientActiveObject * Client::getSelectedActiveObject(
|
||||
|
||||
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.
|
||||
@ -2000,12 +2003,12 @@ ClientActiveObject * Client::getSelectedActiveObject(
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -2069,7 +2072,7 @@ void Client::clearTempMod(v3s16 p)
|
||||
|
||||
void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server)
|
||||
{
|
||||
/*dstream<<"Client::addUpdateMeshTask(): "
|
||||
/*infostream<<"Client::addUpdateMeshTask(): "
|
||||
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
|
||||
<<std::endl;*/
|
||||
|
||||
@ -2096,7 +2099,7 @@ void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server)
|
||||
// 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;*/
|
||||
|
||||
@ -2123,7 +2126,7 @@ void Client::addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server)
|
||||
{
|
||||
/*{
|
||||
v3s16 p = blockpos;
|
||||
dstream<<"Client::addUpdateMeshTaskWithEdge(): "
|
||||
infostream<<"Client::addUpdateMeshTaskWithEdge(): "
|
||||
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<")"
|
||||
<<std::endl;
|
||||
}*/
|
||||
|
@ -116,7 +116,7 @@ void TestCAO::step(float dtime, ClientEnvironment *env)
|
||||
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);
|
||||
}
|
||||
@ -124,7 +124,7 @@ void TestCAO::step(float dtime, ClientEnvironment *env)
|
||||
|
||||
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;
|
||||
@ -259,7 +259,7 @@ void ItemCAO::step(float dtime, ClientEnvironment *env)
|
||||
|
||||
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);
|
||||
@ -273,7 +273,7 @@ void ItemCAO::processMessage(const std::string &data)
|
||||
|
||||
void ItemCAO::initialize(const std::string &data)
|
||||
{
|
||||
dstream<<"ItemCAO: Got init data"<<std::endl;
|
||||
infostream<<"ItemCAO: Got init data"<<std::endl;
|
||||
|
||||
{
|
||||
std::istringstream is(data, std::ios::binary);
|
||||
@ -313,7 +313,7 @@ void ItemCAO::initialize(const std::string &data)
|
||||
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)
|
||||
@ -324,7 +324,7 @@ void ItemCAO::initialize(const std::string &data)
|
||||
}
|
||||
catch(SerializationError &e)
|
||||
{
|
||||
dstream<<"WARNING: "<<__FUNCTION_NAME
|
||||
infostream<<"WARNING: "<<__FUNCTION_NAME
|
||||
<<": error deSerializing inventorystring \""
|
||||
<<m_inventorystring<<"\""<<std::endl;
|
||||
}
|
||||
@ -446,7 +446,7 @@ void RatCAO::step(float dtime, ClientEnvironment *env)
|
||||
|
||||
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);
|
||||
@ -463,7 +463,7 @@ void RatCAO::processMessage(const std::string &data)
|
||||
|
||||
void RatCAO::initialize(const std::string &data)
|
||||
{
|
||||
//dstream<<"RatCAO: Got init data"<<std::endl;
|
||||
//infostream<<"RatCAO: Got init data"<<std::endl;
|
||||
|
||||
{
|
||||
std::istringstream is(data, std::ios::binary);
|
||||
@ -670,7 +670,7 @@ void Oerkki1CAO::step(float dtime, ClientEnvironment *env)
|
||||
|
||||
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);
|
||||
@ -692,7 +692,7 @@ void Oerkki1CAO::processMessage(const std::string &data)
|
||||
|
||||
void Oerkki1CAO::initialize(const std::string &data)
|
||||
{
|
||||
//dstream<<"Oerkki1CAO: Got init data"<<std::endl;
|
||||
//infostream<<"Oerkki1CAO: Got init data"<<std::endl;
|
||||
|
||||
{
|
||||
std::istringstream is(data, std::ios::binary);
|
||||
@ -831,7 +831,7 @@ void FireflyCAO::step(float dtime, ClientEnvironment *env)
|
||||
|
||||
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);
|
||||
@ -848,7 +848,7 @@ void FireflyCAO::processMessage(const std::string &data)
|
||||
|
||||
void FireflyCAO::initialize(const std::string &data)
|
||||
{
|
||||
//dstream<<"FireflyCAO: Got init data"<<std::endl;
|
||||
//infostream<<"FireflyCAO: Got init data"<<std::endl;
|
||||
|
||||
{
|
||||
std::istringstream is(data, std::ios::binary);
|
||||
@ -912,7 +912,7 @@ void MobV2CAO::addToScene(scene::ISceneManager *smgr)
|
||||
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;
|
||||
@ -944,7 +944,7 @@ void MobV2CAO::addToScene(scene::ISceneManager *smgr)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1023,7 +1023,7 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env)
|
||||
float mob_dir = atan2(cam_to_mob.Z, cam_to_mob.X) / PI * 180.;
|
||||
float 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)
|
||||
@ -1074,7 +1074,7 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1104,7 +1104,7 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1128,7 +1128,7 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env)
|
||||
|
||||
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);
|
||||
@ -1182,7 +1182,7 @@ void MobV2CAO::processMessage(const std::string &data)
|
||||
|
||||
void MobV2CAO::initialize(const std::string &data)
|
||||
{
|
||||
//dstream<<"MobV2CAO: Got init data"<<std::endl;
|
||||
//infostream<<"MobV2CAO: Got init data"<<std::endl;
|
||||
|
||||
{
|
||||
std::istringstream is(data, std::ios::binary);
|
||||
@ -1190,7 +1190,7 @@ void MobV2CAO::initialize(const std::string &data)
|
||||
u8 version = readU8(is);
|
||||
// check version
|
||||
if(version != 0){
|
||||
dstream<<__FUNCTION_NAME<<": Invalid version"<<std::endl;
|
||||
infostream<<__FUNCTION_NAME<<": Invalid version"<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1199,8 +1199,8 @@ void MobV2CAO::initialize(const std::string &data)
|
||||
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");
|
||||
|
@ -84,7 +84,7 @@ void TestSAO::step(float dtime, bool send_recommended)
|
||||
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;
|
||||
|
||||
@ -131,7 +131,7 @@ ServerActiveObject* ItemSAO::create(ServerEnvironment *env, u16 id, v3f pos,
|
||||
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);
|
||||
}
|
||||
@ -206,7 +206,7 @@ std::string ItemSAO::getClientInitializationData()
|
||||
|
||||
std::string ItemSAO::getStaticData()
|
||||
{
|
||||
dstream<<__FUNCTION_NAME<<std::endl;
|
||||
infostream<<__FUNCTION_NAME<<std::endl;
|
||||
std::ostringstream os(std::ios::binary);
|
||||
char buf[1];
|
||||
// version
|
||||
@ -222,14 +222,14 @@ InventoryItem * ItemSAO::createInventoryItem()
|
||||
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;
|
||||
}
|
||||
@ -237,7 +237,7 @@ InventoryItem * ItemSAO::createInventoryItem()
|
||||
|
||||
void ItemSAO::rightClick(Player *player)
|
||||
{
|
||||
dstream<<__FUNCTION_NAME<<std::endl;
|
||||
infostream<<__FUNCTION_NAME<<std::endl;
|
||||
InventoryItem *item = createInventoryItem();
|
||||
if(item == NULL)
|
||||
return;
|
||||
@ -424,7 +424,7 @@ std::string RatSAO::getClientInitializationData()
|
||||
|
||||
std::string RatSAO::getStaticData()
|
||||
{
|
||||
//dstream<<__FUNCTION_NAME<<std::endl;
|
||||
//infostream<<__FUNCTION_NAME<<std::endl;
|
||||
std::ostringstream os(std::ios::binary);
|
||||
// version
|
||||
writeU8(os, 0);
|
||||
@ -669,7 +669,7 @@ std::string Oerkki1SAO::getClientInitializationData()
|
||||
|
||||
std::string Oerkki1SAO::getStaticData()
|
||||
{
|
||||
//dstream<<__FUNCTION_NAME<<std::endl;
|
||||
//infostream<<__FUNCTION_NAME<<std::endl;
|
||||
std::ostringstream os(std::ios::binary);
|
||||
// version
|
||||
writeU8(os, 0);
|
||||
@ -689,7 +689,7 @@ u16 Oerkki1SAO::punch(const std::string &toolname, v3f dir)
|
||||
|
||||
void Oerkki1SAO::doDamage(u16 d)
|
||||
{
|
||||
dstream<<"oerkki damage: "<<d<<std::endl;
|
||||
infostream<<"oerkki damage: "<<d<<std::endl;
|
||||
|
||||
if(d < m_hp)
|
||||
{
|
||||
@ -877,7 +877,7 @@ std::string FireflySAO::getClientInitializationData()
|
||||
|
||||
std::string FireflySAO::getStaticData()
|
||||
{
|
||||
//dstream<<__FUNCTION_NAME<<std::endl;
|
||||
//infostream<<__FUNCTION_NAME<<std::endl;
|
||||
std::ostringstream os(std::ios::binary);
|
||||
// version
|
||||
writeU8(os, 0);
|
||||
@ -960,7 +960,7 @@ std::string MobV2SAO::getStaticData()
|
||||
|
||||
std::string MobV2SAO::getClientInitializationData()
|
||||
{
|
||||
//dstream<<__FUNCTION_NAME<<std::endl;
|
||||
//infostream<<__FUNCTION_NAME<<std::endl;
|
||||
|
||||
updateProperties();
|
||||
|
||||
@ -1092,7 +1092,7 @@ void MobV2SAO::step(float dtime, bool send_recommended)
|
||||
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;
|
||||
@ -1135,7 +1135,7 @@ void MobV2SAO::step(float dtime, bool send_recommended)
|
||||
dir.normalize();
|
||||
v3f speed = dir * BS * 10.0;
|
||||
v3f pos = m_base_position + shoot_pos;
|
||||
dstream<<__FUNCTION_NAME<<": Shooting fireball from "<<PP(pos)
|
||||
infostream<<__FUNCTION_NAME<<": Shooting fireball from "<<PP(pos)
|
||||
<<" at speed "<<PP(speed)<<std::endl;
|
||||
Settings properties;
|
||||
properties.set("looks", "fireball");
|
||||
@ -1152,7 +1152,7 @@ void MobV2SAO::step(float dtime, bool send_recommended)
|
||||
//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;
|
||||
}
|
||||
}
|
||||
@ -1229,7 +1229,7 @@ void MobV2SAO::step(float dtime, bool send_recommended)
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1271,16 +1271,16 @@ void MobV2SAO::step(float dtime, bool send_recommended)
|
||||
}
|
||||
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;
|
||||
@ -1310,7 +1310,7 @@ void MobV2SAO::step(float dtime, bool send_recommended)
|
||||
}
|
||||
else
|
||||
{
|
||||
dstream<<"MobV2SAO::step(): id="<<m_id<<" unknown move_type=\""
|
||||
infostream<<"MobV2SAO::step(): id="<<m_id<<" unknown move_type=\""
|
||||
<<m_move_type<<"\""<<std::endl;
|
||||
}
|
||||
|
||||
@ -1329,8 +1329,9 @@ u16 MobV2SAO::punch(const std::string &toolname, v3f dir,
|
||||
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;
|
||||
@ -1432,7 +1433,7 @@ void MobV2SAO::updateProperties()
|
||||
|
||||
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)
|
||||
{
|
||||
@ -1440,6 +1441,8 @@ void MobV2SAO::doDamage(u16 d)
|
||||
}
|
||||
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;
|
||||
|
19
src/debug.h
19
src/debug.h
@ -235,10 +235,9 @@ private:
|
||||
|
||||
#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);\
|
||||
}
|
||||
@ -257,24 +256,24 @@ public:
|
||||
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
|
||||
|
@ -27,6 +27,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#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)
|
||||
@ -302,7 +305,7 @@ void ServerEnvironment::serializePlayers(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;
|
||||
@ -311,24 +314,24 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
|
||||
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.
|
||||
{
|
||||
@ -336,7 +339,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
|
||||
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);
|
||||
@ -350,7 +353,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
|
||||
Player *player = *i;
|
||||
if(saved_players.find(player) != NULL)
|
||||
{
|
||||
/*dstream<<"Player "<<player->getName()
|
||||
/*infostream<<"Player "<<player->getName()
|
||||
<<" was already saved."<<std::endl;*/
|
||||
continue;
|
||||
}
|
||||
@ -358,7 +361,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
|
||||
// Don't save unnamed player
|
||||
if(playername == "")
|
||||
{
|
||||
//dstream<<"Not saving unnamed player."<<std::endl;
|
||||
//infostream<<"Not saving unnamed player."<<std::endl;
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
@ -379,18 +382,18 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
|
||||
}
|
||||
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);
|
||||
@ -398,7 +401,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
|
||||
}
|
||||
}
|
||||
|
||||
//dstream<<"Saved "<<saved_players.size()<<" players."<<std::endl;
|
||||
//infostream<<"Saved "<<saved_players.size()<<" players."<<std::endl;
|
||||
}
|
||||
|
||||
void ServerEnvironment::deSerializePlayers(const std::string &savedir)
|
||||
@ -416,7 +419,7 @@ 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;
|
||||
@ -425,7 +428,7 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
|
||||
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);
|
||||
@ -433,11 +436,11 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
|
||||
|
||||
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
|
||||
@ -446,20 +449,20 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
|
||||
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);
|
||||
@ -478,7 +481,7 @@ void ServerEnvironment::saveMeta(const std::string &savedir)
|
||||
std::ofstream os(path.c_str(), std::ios_base::binary);
|
||||
if(os.good() == false)
|
||||
{
|
||||
dstream<<"WARNING: ServerEnvironment::saveMeta(): Failed to open "
|
||||
infostream<<"ServerEnvironment::saveMeta(): Failed to open "
|
||||
<<path<<std::endl;
|
||||
throw SerializationError("Couldn't save env meta");
|
||||
}
|
||||
@ -498,7 +501,7 @@ void ServerEnvironment::loadMeta(const std::string &savedir)
|
||||
std::ifstream is(path.c_str(), std::ios_base::binary);
|
||||
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");
|
||||
}
|
||||
@ -595,7 +598,7 @@ void ServerEnvironment::activateBlock(MapBlock *block, u32 additional_dtime)
|
||||
// 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);
|
||||
@ -757,7 +760,7 @@ void ServerEnvironment::step(float dtime)
|
||||
{
|
||||
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);
|
||||
@ -778,7 +781,7 @@ void ServerEnvironment::step(float dtime)
|
||||
{
|
||||
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);
|
||||
@ -802,7 +805,7 @@ void ServerEnvironment::step(float dtime)
|
||||
{
|
||||
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);
|
||||
@ -838,7 +841,7 @@ void ServerEnvironment::step(float dtime)
|
||||
{
|
||||
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);
|
||||
@ -956,18 +959,24 @@ void ServerEnvironment::step(float dtime)
|
||||
v3f pos = intToFloat(p1, BS);
|
||||
int i = myrand()%5;
|
||||
if(i == 0 || i == 1){
|
||||
actionstream<<"A dungeon master spawns at "
|
||||
<<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);
|
||||
@ -983,6 +992,9 @@ void ServerEnvironment::step(float dtime)
|
||||
{
|
||||
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);
|
||||
@ -1111,7 +1123,7 @@ void ServerEnvironment::step(float dtime)
|
||||
//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;
|
||||
@ -1202,7 +1214,7 @@ bool ServerEnvironment::addActiveObjectAsStatic(ServerActiveObject *obj)
|
||||
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;
|
||||
@ -1282,13 +1294,13 @@ void ServerEnvironment::getRemovedActiveObjects(v3s16 pos, s16 radius,
|
||||
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)
|
||||
@ -1322,7 +1334,7 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object,
|
||||
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;
|
||||
@ -1331,12 +1343,12 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object,
|
||||
}
|
||||
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);
|
||||
@ -1358,7 +1370,7 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object,
|
||||
block->setChangedFlag();
|
||||
}
|
||||
else{
|
||||
dstream<<"WARNING: ServerEnv: Could not find a block for "
|
||||
infostream<<"ServerEnv: Could not find a block for "
|
||||
<<"storing newly added static active object"<<std::endl;
|
||||
}
|
||||
|
||||
@ -1380,7 +1392,7 @@ void ServerEnvironment::removeRemovedObjects()
|
||||
// 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);
|
||||
@ -1442,7 +1454,7 @@ void ServerEnvironment::activateObjects(MapBlock *block)
|
||||
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
|
||||
@ -1494,7 +1506,7 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
|
||||
// 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;
|
||||
@ -1553,7 +1565,7 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
|
||||
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;
|
||||
@ -1571,7 +1583,7 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
|
||||
continue;
|
||||
}
|
||||
|
||||
/*dstream<<"INFO: Server: Stored static data. Deleting object."
|
||||
/*infostream<<"Server: Stored static data. Deleting object."
|
||||
<<std::endl;*/
|
||||
// Delete active object
|
||||
delete obj;
|
||||
@ -1962,7 +1974,7 @@ u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
|
||||
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;
|
||||
@ -1971,12 +1983,12 @@ u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
|
||||
}
|
||||
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);
|
||||
@ -1989,7 +2001,7 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type,
|
||||
ClientActiveObject* obj = ClientActiveObject::create(type);
|
||||
if(obj == NULL)
|
||||
{
|
||||
dstream<<"WARNING: ClientEnvironment::addActiveObject(): "
|
||||
infostream<<"ClientEnvironment::addActiveObject(): "
|
||||
<<"id="<<id<<" type="<<type<<": Couldn't create object"
|
||||
<<std::endl;
|
||||
return;
|
||||
@ -2004,12 +2016,12 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type,
|
||||
|
||||
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;
|
||||
}
|
||||
@ -2024,7 +2036,7 @@ void ClientEnvironment::processActiveObjectMessage(u16 id,
|
||||
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;
|
||||
|
91
src/game.cpp
91
src/game.cpp
@ -41,6 +41,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "profiler.h"
|
||||
#include "mainmenumanager.h"
|
||||
#include "gettext.h"
|
||||
#include "log.h"
|
||||
|
||||
/*
|
||||
TODO: Move content-aware stuff to separate file by adding properties
|
||||
@ -122,7 +123,7 @@ struct TextDestSignNode : public TextDest
|
||||
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);
|
||||
}
|
||||
@ -161,7 +162,7 @@ void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font,
|
||||
InventoryList *mainlist = inventory->getList("main");
|
||||
if(mainlist == NULL)
|
||||
{
|
||||
dstream<<"WARNING: draw_hotbar(): mainlist == NULL"<<std::endl;
|
||||
errorstream<<"draw_hotbar(): mainlist == NULL"<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -299,7 +300,7 @@ void getPointedNode(Client *client, v3f player_position,
|
||||
|
||||
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;
|
||||
@ -706,7 +707,7 @@ void the_game(
|
||||
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);
|
||||
}
|
||||
@ -716,7 +717,7 @@ void the_game(
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
@ -731,7 +732,7 @@ void the_game(
|
||||
}
|
||||
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();
|
||||
@ -742,9 +743,9 @@ void the_game(
|
||||
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;
|
||||
@ -800,12 +801,12 @@ void the_game(
|
||||
{
|
||||
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;
|
||||
@ -963,7 +964,7 @@ void the_game(
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1029,7 +1030,7 @@ void the_game(
|
||||
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();
|
||||
@ -1082,8 +1083,8 @@ void the_game(
|
||||
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
|
||||
@ -1148,7 +1149,7 @@ void the_game(
|
||||
if(counter < 0)
|
||||
{
|
||||
counter = 30.0;
|
||||
client.printDebugInfo(dstream);
|
||||
client.printDebugInfo(infostream);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1161,8 +1162,8 @@ void the_game(
|
||||
{
|
||||
if(m_profiler_interval.step(0.030, profiler_print_interval))
|
||||
{
|
||||
dstream<<"Profiler:"<<std::endl;
|
||||
g_profiler->print(dstream);
|
||||
infostream<<"Profiler:"<<std::endl;
|
||||
g_profiler->print(infostream);
|
||||
g_profiler->clear();
|
||||
}
|
||||
}
|
||||
@ -1185,7 +1186,7 @@ void the_game(
|
||||
*/
|
||||
if(input->wasKeyDown(getKeySetting("keymap_inventory")))
|
||||
{
|
||||
dstream<<DTIME<<"the_game: "
|
||||
infostream<<"the_game: "
|
||||
<<"Launching inventory"<<std::endl;
|
||||
|
||||
GUIInventoryMenu *menu =
|
||||
@ -1211,7 +1212,7 @@ void the_game(
|
||||
}
|
||||
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,
|
||||
@ -1286,10 +1287,10 @@ void the_game(
|
||||
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();
|
||||
}
|
||||
@ -1327,7 +1328,7 @@ void the_game(
|
||||
{
|
||||
g_selected_item = i;
|
||||
|
||||
dstream<<DTIME<<"Selected item: "
|
||||
infostream<<"Selected item: "
|
||||
<<g_selected_item<<std::endl;
|
||||
}
|
||||
}
|
||||
@ -1339,12 +1340,12 @@ void the_game(
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1374,7 +1375,7 @@ void the_game(
|
||||
}
|
||||
|
||||
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{
|
||||
@ -1382,7 +1383,7 @@ void the_game(
|
||||
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))
|
||||
@ -1406,7 +1407,7 @@ void the_game(
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1486,7 +1487,7 @@ void the_game(
|
||||
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;
|
||||
@ -1575,7 +1576,7 @@ void the_game(
|
||||
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();
|
||||
@ -1610,7 +1611,7 @@ void the_game(
|
||||
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){
|
||||
@ -1620,7 +1621,7 @@ void the_game(
|
||||
}
|
||||
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);
|
||||
}
|
||||
@ -1687,7 +1688,7 @@ void the_game(
|
||||
{
|
||||
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))
|
||||
@ -1701,7 +1702,7 @@ void the_game(
|
||||
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())
|
||||
@ -1734,7 +1735,7 @@ void the_game(
|
||||
|
||||
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
|
||||
@ -1759,12 +1760,12 @@ void the_game(
|
||||
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);
|
||||
@ -1798,12 +1799,12 @@ void the_game(
|
||||
|
||||
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
|
||||
*/
|
||||
@ -1836,7 +1837,7 @@ void the_game(
|
||||
}
|
||||
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;
|
||||
|
||||
@ -1873,13 +1874,13 @@ void the_game(
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@ -2124,7 +2125,7 @@ void the_game(
|
||||
{
|
||||
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
|
||||
@ -2163,7 +2164,7 @@ void the_game(
|
||||
|
||||
//timer3.stop();
|
||||
|
||||
//dstream<<DTIME<<"smgr->drawAll()"<<std::endl;
|
||||
//infostream<<"smgr->drawAll()"<<std::endl;
|
||||
|
||||
{
|
||||
TimeTaker timer("smgr");
|
||||
@ -2189,7 +2190,7 @@ void the_game(
|
||||
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<<")"
|
||||
|
73
src/main.cpp
73
src/main.cpp
@ -438,6 +438,7 @@ Doing currently:
|
||||
#include "gettext.h"
|
||||
#include "settings.h"
|
||||
#include "profiler.h"
|
||||
#include "log.h"
|
||||
|
||||
// This makes textures
|
||||
ITextureSource *g_texturesource = NULL;
|
||||
@ -479,19 +480,15 @@ MainGameCallback *g_gamecallback = NULL;
|
||||
|
||||
// Connection
|
||||
std::ostream *dout_con_ptr = &dummyout;
|
||||
std::ostream *derr_con_ptr = &dstream_no_stderr;
|
||||
//std::ostream *dout_con_ptr = &dstream_no_stderr;
|
||||
//std::ostream *derr_con_ptr = &dstream_no_stderr;
|
||||
//std::ostream *dout_con_ptr = &dstream;
|
||||
//std::ostream *derr_con_ptr = &dstream;
|
||||
std::ostream *derr_con_ptr = &verbosestream;
|
||||
|
||||
// Server
|
||||
std::ostream *dout_server_ptr = &dstream;
|
||||
std::ostream *derr_server_ptr = &dstream;
|
||||
std::ostream *dout_server_ptr = &infostream;
|
||||
std::ostream *derr_server_ptr = &errorstream;
|
||||
|
||||
// Client
|
||||
std::ostream *dout_client_ptr = &dstream;
|
||||
std::ostream *derr_client_ptr = &dstream;
|
||||
std::ostream *dout_client_ptr = &infostream;
|
||||
std::ostream *derr_client_ptr = &errorstream;
|
||||
|
||||
/*
|
||||
gettime.h implementation
|
||||
@ -583,7 +580,6 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
//dstream<<"MyEventReceiver: mouse input"<<std::endl;
|
||||
left_active = event.MouseInput.isLeftPressed();
|
||||
middle_active = event.MouseInput.isMiddlePressed();
|
||||
right_active = event.MouseInput.isRightPressed();
|
||||
@ -1026,7 +1022,7 @@ void SpeedTests()
|
||||
|
||||
u32 dtime = timer.stop();
|
||||
u32 per_ms = n / dtime;
|
||||
std::cout<<"Done. "<<dtime<<"ms, "
|
||||
dstream<<"Done. "<<dtime<<"ms, "
|
||||
<<per_ms<<"/ms"<<std::endl;
|
||||
}
|
||||
}
|
||||
@ -1078,12 +1074,37 @@ void drawMenuBackground(video::IVideoDriver* driver)
|
||||
}
|
||||
}
|
||||
|
||||
class DstreamLogOutput: public ILogOutput
|
||||
{
|
||||
public:
|
||||
/* line: Full line with timestamp, level and thread */
|
||||
void printLog(const std::string &line)
|
||||
{
|
||||
dstream<<line<<std::endl;
|
||||
}
|
||||
} main_dstream_log_out;
|
||||
|
||||
class DstreamNoStderrLogOutput: public ILogOutput
|
||||
{
|
||||
public:
|
||||
/* line: Full line with timestamp, level and thread */
|
||||
void printLog(const std::string &line)
|
||||
{
|
||||
dstream_no_stderr<<line<<std::endl;
|
||||
}
|
||||
} main_dstream_no_stderr_log_out;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/*
|
||||
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
|
||||
@ -1110,6 +1131,7 @@ int main(int argc, char *argv[])
|
||||
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;
|
||||
|
||||
@ -1152,6 +1174,9 @@ int main(int argc, char *argv[])
|
||||
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();
|
||||
|
||||
@ -1182,7 +1207,7 @@ int main(int argc, char *argv[])
|
||||
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;
|
||||
@ -1210,7 +1235,7 @@ int main(int argc, char *argv[])
|
||||
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;
|
||||
}
|
||||
@ -1356,7 +1381,7 @@ int main(int argc, char *argv[])
|
||||
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;
|
||||
}
|
||||
@ -1427,14 +1452,14 @@ int main(int argc, char *argv[])
|
||||
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));
|
||||
@ -1522,7 +1547,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(error_message != L"")
|
||||
{
|
||||
dstream<<"WARNING: error_message = "
|
||||
errorstream<<"error_message = "
|
||||
<<wide_to_narrow(error_message)<<std::endl;
|
||||
|
||||
GUIMessageMenu *menu2 =
|
||||
@ -1534,7 +1559,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
video::IVideoDriver* driver = device->getVideoDriver();
|
||||
|
||||
dstream<<"Created main menu"<<std::endl;
|
||||
infostream<<"Created main menu"<<std::endl;
|
||||
|
||||
while(device->run() && kill == false)
|
||||
{
|
||||
@ -1559,7 +1584,7 @@ int main(int argc, char *argv[])
|
||||
if(device->run() == false || kill == true)
|
||||
break;
|
||||
|
||||
dstream<<"Dropping main menu"<<std::endl;
|
||||
infostream<<"Dropping main menu"<<std::endl;
|
||||
|
||||
menu->drop();
|
||||
|
||||
@ -1576,7 +1601,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
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));
|
||||
@ -1643,12 +1668,12 @@ int main(int argc, char *argv[])
|
||||
} //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
|
||||
@ -1657,7 +1682,7 @@ int main(int argc, char *argv[])
|
||||
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
|
||||
@ -1671,7 +1696,7 @@ int main(int argc, char *argv[])
|
||||
*/
|
||||
device->drop();
|
||||
|
||||
END_DEBUG_EXCEPTION_HANDLER
|
||||
END_DEBUG_EXCEPTION_HANDLER(errorstream)
|
||||
|
||||
debugstreams_deinit();
|
||||
|
||||
|
191
src/map.cpp
191
src/map.cpp
@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include <IMaterialRenderer.h>
|
||||
#endif
|
||||
#include "settings.h"
|
||||
#include "log.h"
|
||||
|
||||
/*
|
||||
SQLite format specification:
|
||||
@ -346,7 +347,7 @@ void Map::unspreadLight(enum LightBank bank,
|
||||
*/
|
||||
/*if(light_sources.find(n2pos))
|
||||
{
|
||||
std::cout<<"Removed from light_sources"<<std::endl;
|
||||
infostream<<"Removed from light_sources"<<std::endl;
|
||||
light_sources.remove(n2pos);
|
||||
}*/
|
||||
}
|
||||
@ -377,7 +378,7 @@ void Map::unspreadLight(enum LightBank bank,
|
||||
}
|
||||
}
|
||||
|
||||
/*dstream<<"unspreadLight(): Changed block "
|
||||
/*infostream<<"unspreadLight(): Changed block "
|
||||
<<blockchangecount<<" times"
|
||||
<<" for "<<from_nodes.size()<<" nodes"
|
||||
<<std::endl;*/
|
||||
@ -439,7 +440,7 @@ void Map::spreadLight(enum LightBank bank,
|
||||
{
|
||||
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
|
||||
@ -544,7 +545,7 @@ void Map::spreadLight(enum LightBank bank,
|
||||
}
|
||||
}
|
||||
|
||||
/*dstream<<"spreadLight(): Changed block "
|
||||
/*infostream<<"spreadLight(): Changed block "
|
||||
<<blockchangecount<<" times"
|
||||
<<" for "<<from_nodes.size()<<" nodes"
|
||||
<<std::endl;*/
|
||||
@ -728,7 +729,7 @@ void Map::updateLighting(enum LightBank bank,
|
||||
dummy block.
|
||||
*/
|
||||
//assert(0);
|
||||
dstream<<"updateLighting(): InvalidPositionException"
|
||||
infostream<<"updateLighting(): InvalidPositionException"
|
||||
<<std::endl;
|
||||
}
|
||||
}
|
||||
@ -752,7 +753,7 @@ void Map::updateLighting(enum LightBank bank,
|
||||
assert(0);
|
||||
}
|
||||
|
||||
/*dstream<<"Bottom for sunlight-propagated block ("
|
||||
/*infostream<<"Bottom for sunlight-propagated block ("
|
||||
<<pos.X<<","<<pos.Y<<","<<pos.Z<<") not valid"
|
||||
<<std::endl;*/
|
||||
|
||||
@ -799,7 +800,7 @@ void Map::updateLighting(enum LightBank bank,
|
||||
{
|
||||
u32 diff = modified_blocks.size() - count_was;
|
||||
count_was = modified_blocks.size();
|
||||
dstream<<"unspreadLight modified "<<diff<<std::endl;
|
||||
infostream<<"unspreadLight modified "<<diff<<std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
@ -811,7 +812,7 @@ void Map::updateLighting(enum LightBank bank,
|
||||
{
|
||||
u32 diff = modified_blocks.size() - count_was;
|
||||
count_was = modified_blocks.size();
|
||||
dstream<<"spreadLight modified "<<diff<<std::endl;
|
||||
infostream<<"spreadLight modified "<<diff<<std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -867,7 +868,7 @@ void Map::updateLighting(enum LightBank bank,
|
||||
//TimeTaker timer("blitBack");
|
||||
vmanip.blitBack(modified_blocks);
|
||||
}
|
||||
/*dstream<<"emerge_time="<<emerge_time<<std::endl;
|
||||
/*infostream<<"emerge_time="<<emerge_time<<std::endl;
|
||||
emerge_time = 0;*/
|
||||
}
|
||||
|
||||
@ -1471,12 +1472,12 @@ void Map::timerUpdate(float dtime, float unload_timeout,
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1543,7 +1544,7 @@ void Map::unloadUnusedData(float timeout,
|
||||
|
||||
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;
|
||||
|
||||
@ -1579,7 +1580,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
|
||||
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;
|
||||
@ -1807,7 +1808,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
|
||||
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);
|
||||
@ -1820,7 +1821,7 @@ NodeMetadata* Map::getNodeMetadata(v3s16 p)
|
||||
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;
|
||||
}
|
||||
@ -1835,7 +1836,7 @@ void Map::setNodeMetadata(v3s16 p, NodeMetadata *meta)
|
||||
MapBlock *block = getBlockNoCreateNoEx(blockpos);
|
||||
if(block == NULL)
|
||||
{
|
||||
dstream<<"WARNING: Map::setNodeMetadata(): Block not found"
|
||||
infostream<<"WARNING: Map::setNodeMetadata(): Block not found"
|
||||
<<std::endl;
|
||||
return;
|
||||
}
|
||||
@ -1849,7 +1850,7 @@ void Map::removeNodeMetadata(v3s16 p)
|
||||
MapBlock *block = getBlockNoCreateNoEx(blockpos);
|
||||
if(block == NULL)
|
||||
{
|
||||
dstream<<"WARNING: Map::removeNodeMetadata(): Block not found"
|
||||
infostream<<"WARNING: Map::removeNodeMetadata(): Block not found"
|
||||
<<std::endl;
|
||||
return;
|
||||
}
|
||||
@ -1897,7 +1898,7 @@ ServerMap::ServerMap(std::string savedir):
|
||||
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
|
||||
|
||||
@ -1935,7 +1936,7 @@ ServerMap::ServerMap(std::string savedir):
|
||||
// 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;
|
||||
}
|
||||
@ -1946,7 +1947,7 @@ ServerMap::ServerMap(std::string savedir):
|
||||
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;
|
||||
@ -1957,18 +1958,18 @@ ServerMap::ServerMap(std::string savedir):
|
||||
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;
|
||||
@ -1985,13 +1986,13 @@ ServerMap::ServerMap(std::string savedir):
|
||||
}
|
||||
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));
|
||||
@ -2002,7 +2003,7 @@ ServerMap::ServerMap(std::string savedir):
|
||||
|
||||
ServerMap::~ServerMap()
|
||||
{
|
||||
dstream<<__FUNCTION_NAME<<std::endl;
|
||||
infostream<<__FUNCTION_NAME<<std::endl;
|
||||
|
||||
try
|
||||
{
|
||||
@ -2010,16 +2011,16 @@ ServerMap::~ServerMap()
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -2050,7 +2051,7 @@ void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos)
|
||||
{
|
||||
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)
|
||||
@ -2134,19 +2135,19 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
|
||||
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
|
||||
@ -2159,7 +2160,7 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
|
||||
}
|
||||
|
||||
if(enable_mapgen_debug_info)
|
||||
dstream<<"finishBlockMake: changed_blocks.size()="
|
||||
infostream<<"finishBlockMake: changed_blocks.size()="
|
||||
<<changed_blocks.size()<<std::endl;
|
||||
|
||||
/*
|
||||
@ -2300,7 +2301,7 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
|
||||
*/
|
||||
//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)
|
||||
@ -2316,7 +2317,7 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -2352,7 +2353,7 @@ ServerMapSector * ServerMap::createSector(v2s16 p2d)
|
||||
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;
|
||||
@ -2394,7 +2395,7 @@ MapBlock * ServerMap::generateBlock(
|
||||
{
|
||||
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;*/
|
||||
|
||||
@ -2412,7 +2413,7 @@ MapBlock * ServerMap::generateBlock(
|
||||
*/
|
||||
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");
|
||||
}
|
||||
|
||||
@ -2458,7 +2459,7 @@ MapBlock * ServerMap::generateBlock(
|
||||
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;
|
||||
@ -2532,7 +2533,7 @@ MapBlock * ServerMap::createBlock(v3s16 p)
|
||||
}
|
||||
catch(InvalidPositionException &e)
|
||||
{
|
||||
dstream<<"createBlock: createSector() failed"<<std::endl;
|
||||
infostream<<"createBlock: createSector() failed"<<std::endl;
|
||||
throw e;
|
||||
}
|
||||
/*
|
||||
@ -2542,7 +2543,7 @@ MapBlock * ServerMap::createBlock(v3s16 p)
|
||||
*/
|
||||
/*catch(std::exception &e)
|
||||
{
|
||||
dstream<<"createBlock: createSector() failed: "
|
||||
infostream<<"createBlock: createSector() failed: "
|
||||
<<e.what()<<std::endl;
|
||||
throw e;
|
||||
}*/
|
||||
@ -2634,18 +2635,18 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool allow_generate)
|
||||
}
|
||||
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;
|
||||
@ -2681,7 +2682,7 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool allow_generate)
|
||||
else
|
||||
{
|
||||
// Valid block
|
||||
//dstream<<"emergeBlock(): Returning already valid block"<<std::endl;
|
||||
//infostream<<"emergeBlock(): Returning already valid block"<<std::endl;
|
||||
return block;
|
||||
}
|
||||
|
||||
@ -2691,7 +2692,7 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool allow_generate)
|
||||
*/
|
||||
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)
|
||||
{
|
||||
@ -2705,11 +2706,11 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool allow_generate)
|
||||
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.
|
||||
@ -2811,7 +2812,7 @@ void ServerMap::createDatabase() {
|
||||
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() {
|
||||
@ -2834,7 +2835,7 @@ 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");
|
||||
}
|
||||
|
||||
@ -2843,17 +2844,17 @@ void ServerMap::verifyDatabase() {
|
||||
|
||||
d = sqlite3_prepare(m_database, "SELECT `data` FROM `blocks` WHERE `pos`=? LIMIT 1", -1, &m_database_read, NULL);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2954,12 +2955,12 @@ void ServerMap::save(bool only_changed)
|
||||
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)
|
||||
@ -3000,7 +3001,7 @@ void ServerMap::save(bool only_changed)
|
||||
saveBlock(block);
|
||||
block_count++;
|
||||
|
||||
/*dstream<<"ServerMap: Written block ("
|
||||
/*infostream<<"ServerMap: Written block ("
|
||||
<<block->getPos().X<<","
|
||||
<<block->getPos().Y<<","
|
||||
<<block->getPos().Z<<")"
|
||||
@ -3017,7 +3018,7 @@ void ServerMap::save(bool only_changed)
|
||||
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."
|
||||
@ -3029,7 +3030,7 @@ void ServerMap::saveMapMeta()
|
||||
{
|
||||
DSTACK(__FUNCTION_NAME);
|
||||
|
||||
dstream<<"INFO: ServerMap::saveMapMeta(): "
|
||||
infostream<<"ServerMap::saveMapMeta(): "
|
||||
<<"seed="<<m_seed
|
||||
<<std::endl;
|
||||
|
||||
@ -3039,7 +3040,7 @@ void ServerMap::saveMapMeta()
|
||||
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");
|
||||
}
|
||||
@ -3058,14 +3059,14 @@ void ServerMap::loadMapMeta()
|
||||
{
|
||||
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");
|
||||
}
|
||||
@ -3087,9 +3088,7 @@ void ServerMap::loadMapMeta()
|
||||
|
||||
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)
|
||||
@ -3128,7 +3127,7 @@ MapSector* ServerMap::loadSectorMeta(std::string sectordir, bool save_after_load
|
||||
// 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;*/
|
||||
@ -3259,7 +3258,7 @@ bool ServerMap::loadSectorFull(v2s16 p2d)
|
||||
|
||||
if(loadlayout != 2)
|
||||
{
|
||||
dstream<<"Sector converted to new layout - deleting "<<
|
||||
infostream<<"Sector converted to new layout - deleting "<<
|
||||
sectordir1<<std::endl;
|
||||
fs::RecursiveDelete(sectordir1);
|
||||
}
|
||||
@ -3271,13 +3270,13 @@ bool ServerMap::loadSectorFull(v2s16 p2d)
|
||||
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)
|
||||
@ -3289,7 +3288,7 @@ 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;
|
||||
}
|
||||
@ -3334,12 +3333,12 @@ void ServerMap::saveBlock(MapBlock *block)
|
||||
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);
|
||||
@ -3415,7 +3414,7 @@ void ServerMap::loadBlock(std::string sectordir, std::string blockfile, MapSecto
|
||||
}
|
||||
catch(SerializationError &e)
|
||||
{
|
||||
dstream<<"WARNING: Invalid block data on disk "
|
||||
infostream<<"WARNING: Invalid block data on disk "
|
||||
<<"fullpath="<<fullpath
|
||||
<<" (SerializationError). "
|
||||
<<"what()="<<e.what()
|
||||
@ -3482,7 +3481,7 @@ void ServerMap::loadBlock(std::string *blob, v3s16 p3d, MapSector *sector, bool
|
||||
}
|
||||
catch(SerializationError &e)
|
||||
{
|
||||
dstream<<"WARNING: Invalid block data in database "
|
||||
infostream<<"WARNING: Invalid block data in database "
|
||||
<<" (SerializationError). "
|
||||
<<"what()="<<e.what()
|
||||
<<std::endl;
|
||||
@ -3503,7 +3502,7 @@ MapBlock* ServerMap::loadBlock(v3s16 blockpos)
|
||||
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) {
|
||||
/*
|
||||
@ -3769,7 +3768,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
||||
int time2 = time(0);
|
||||
if(time2 > time1 + 4)
|
||||
{
|
||||
dstream<<"ClientMap::renderMap(): "
|
||||
infostream<<"ClientMap::renderMap(): "
|
||||
"Rendering takes ages, returning."
|
||||
<<std::endl;
|
||||
return;
|
||||
@ -3931,7 +3930,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
||||
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;*/
|
||||
}
|
||||
|
||||
@ -4181,7 +4180,7 @@ MapVoxelManipulator::MapVoxelManipulator(Map *map)
|
||||
|
||||
MapVoxelManipulator::~MapVoxelManipulator()
|
||||
{
|
||||
/*dstream<<"MapVoxelManipulator: blocks: "<<m_loaded_blocks.size()
|
||||
/*infostream<<"MapVoxelManipulator: blocks: "<<m_loaded_blocks.size()
|
||||
<<std::endl;*/
|
||||
}
|
||||
|
||||
@ -4213,11 +4212,11 @@ void MapVoxelManipulator::emerge(VoxelArea a, s32 caller_id)
|
||||
{
|
||||
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())
|
||||
@ -4245,7 +4244,7 @@ void MapVoxelManipulator::emerge(VoxelArea a, s32 caller_id)
|
||||
m_loaded_blocks.insert(p, !block_data_inexistent);
|
||||
}
|
||||
|
||||
//dstream<<"emerge done"<<std::endl;
|
||||
//infostream<<"emerge done"<<std::endl;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4261,7 +4260,7 @@ void MapVoxelManipulator::blitBack
|
||||
|
||||
//TimeTaker timer1("blitBack");
|
||||
|
||||
/*dstream<<"blitBack(): m_loaded_blocks.size()="
|
||||
/*infostream<<"blitBack(): m_loaded_blocks.size()="
|
||||
<<m_loaded_blocks.size()<<std::endl;*/
|
||||
|
||||
/*
|
||||
@ -4350,10 +4349,10 @@ void ManualMapVoxelManipulator::initialEmerge(
|
||||
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);
|
||||
@ -4421,7 +4420,7 @@ void ManualMapVoxelManipulator::blitBackAll(
|
||||
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;
|
||||
@ -4429,7 +4428,7 @@ void ManualMapVoxelManipulator::blitBackAll(
|
||||
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;
|
||||
|
372
src/server.cpp
372
src/server.cpp
File diff suppressed because it is too large
Load Diff
@ -20,6 +20,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#include "utility.h"
|
||||
#include "settings.h"
|
||||
|
||||
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
|
||||
|
||||
void cmd_status(std::wostringstream &os,
|
||||
ServerCommandContext *ctx)
|
||||
{
|
||||
@ -94,10 +96,17 @@ void cmd_grantrevoke(std::wostringstream &os,
|
||||
std::string playername = wide_to_narrow(ctx->parms[1]);
|
||||
u64 privs = ctx->server->getPlayerAuthPrivs(playername);
|
||||
|
||||
if(ctx->parms[0] == L"grant")
|
||||
if(ctx->parms[0] == L"grant"){
|
||||
actionstream<<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);
|
||||
|
||||
@ -123,6 +132,9 @@ void cmd_time(std::wostringstream &os,
|
||||
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,
|
||||
@ -134,8 +146,9 @@ 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)";
|
||||
@ -156,6 +169,9 @@ void cmd_setting(std::wostringstream &os,
|
||||
|
||||
std::string confline = wide_to_narrow(ctx->paramstring);
|
||||
|
||||
actionstream<<ctx->player->getName()
|
||||
<<" sets: "<<confline<<std::endl;
|
||||
|
||||
g_settings->parseConfigLine(confline);
|
||||
|
||||
ctx->server->saveConfig();
|
||||
@ -186,6 +202,11 @@ void cmd_teleport(std::wostringstream &os,
|
||||
}
|
||||
|
||||
v3f dest(stoi(coords[0])*10, stoi(coords[1])*10, stoi(coords[2])*10);
|
||||
|
||||
actionstream<<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);
|
||||
|
||||
@ -226,6 +247,9 @@ void cmd_banunban(std::wostringstream &os, ServerCommandContext *ctx)
|
||||
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
|
||||
{
|
||||
@ -233,6 +257,9 @@ void cmd_banunban(std::wostringstream &os, ServerCommandContext *ctx)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "defaultsettings.h"
|
||||
#include "settings.h"
|
||||
#include "profiler.h"
|
||||
#include "log.h"
|
||||
|
||||
/*
|
||||
Settings.
|
||||
@ -94,15 +95,15 @@ ITextureSource *g_texturesource = NULL;
|
||||
|
||||
// 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
|
||||
@ -116,12 +117,37 @@ u32 getTimeMs()
|
||||
return porting::getTimeMs();
|
||||
}
|
||||
|
||||
class DstreamLogOutput: public ILogOutput
|
||||
{
|
||||
public:
|
||||
/* line: Full line with timestamp, level and thread */
|
||||
void printLog(const std::string &line)
|
||||
{
|
||||
dstream<<line<<std::endl;
|
||||
}
|
||||
} main_dstream_log_out;
|
||||
|
||||
class DstreamNoStderrLogOutput: public ILogOutput
|
||||
{
|
||||
public:
|
||||
/* line: Full line with timestamp, level and thread */
|
||||
void printLog(const std::string &line)
|
||||
{
|
||||
dstream_no_stderr<<line<<std::endl;
|
||||
}
|
||||
} main_dstream_no_stderr_log_out;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/*
|
||||
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
|
||||
@ -164,7 +190,7 @@ int main(int argc, char *argv[])
|
||||
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;
|
||||
@ -185,6 +211,7 @@ int main(int argc, char *argv[])
|
||||
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;
|
||||
|
||||
@ -217,6 +244,8 @@ int main(int argc, char *argv[])
|
||||
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
|
||||
@ -241,7 +270,7 @@ int main(int argc, char *argv[])
|
||||
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;
|
||||
}
|
||||
@ -334,10 +363,10 @@ int main(int argc, char *argv[])
|
||||
} //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();
|
||||
|
||||
|
@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include <sstream>
|
||||
#include "debug.h"
|
||||
#include "utility.h"
|
||||
#include "log.h"
|
||||
|
||||
enum ValueType
|
||||
{
|
||||
@ -81,7 +82,7 @@ public:
|
||||
if(trimmedline[0] == '#')
|
||||
return true;
|
||||
|
||||
//dstream<<"trimmedline=\""<<trimmedline<<"\""<<std::endl;
|
||||
//infostream<<"trimmedline=\""<<trimmedline<<"\""<<std::endl;
|
||||
|
||||
Strfnd sf(trim(line));
|
||||
|
||||
@ -94,7 +95,7 @@ public:
|
||||
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;
|
||||
@ -130,7 +131,7 @@ public:
|
||||
*/
|
||||
std::string line;
|
||||
std::getline(is, line);
|
||||
//dstream<<"got line: \""<<line<<"\""<<std::endl;
|
||||
//infostream<<"got line: \""<<line<<"\""<<std::endl;
|
||||
|
||||
return parseConfigLine(line);
|
||||
}
|
||||
@ -145,12 +146,12 @@ public:
|
||||
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));
|
||||
@ -215,7 +216,7 @@ public:
|
||||
|
||||
if(newvalue != value)
|
||||
{
|
||||
dstream<<"Changing value of \""<<name<<"\" = \""
|
||||
infostream<<"Changing value of \""<<name<<"\" = \""
|
||||
<<value<<"\" -> \""<<newvalue<<"\""
|
||||
<<std::endl;
|
||||
}
|
||||
@ -235,7 +236,7 @@ public:
|
||||
*/
|
||||
bool updateConfigFile(const char *filename)
|
||||
{
|
||||
dstream<<"Updating configuration file: \""
|
||||
infostream<<"Updating configuration file: \""
|
||||
<<filename<<"\""<<std::endl;
|
||||
|
||||
core::list<std::string> objects;
|
||||
@ -246,7 +247,7 @@ public:
|
||||
std::ifstream is(filename);
|
||||
if(is.good() == false)
|
||||
{
|
||||
dstream<<"INFO: updateConfigFile():"
|
||||
infostream<<"updateConfigFile():"
|
||||
" Error opening configuration file"
|
||||
" for reading: \""
|
||||
<<filename<<"\""<<std::endl;
|
||||
@ -264,7 +265,7 @@ public:
|
||||
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;
|
||||
@ -291,7 +292,7 @@ public:
|
||||
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";
|
||||
}
|
||||
@ -316,7 +317,7 @@ public:
|
||||
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;
|
||||
}
|
||||
@ -328,7 +329,7 @@ public:
|
||||
n = allowed_options.find(name);
|
||||
if(n == NULL)
|
||||
{
|
||||
dstream<<"Unknown command-line parameter \""
|
||||
errorstream<<"Unknown command-line parameter \""
|
||||
<<argname<<"\""<<std::endl;
|
||||
return false;
|
||||
}
|
||||
@ -345,7 +346,7 @@ public:
|
||||
{
|
||||
if(i >= argc)
|
||||
{
|
||||
dstream<<"Invalid command-line parameter \""
|
||||
errorstream<<"Invalid command-line parameter \""
|
||||
<<name<<"\": missing value"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
@ -354,7 +355,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
dstream<<"Valid command-line parameter: \""
|
||||
infostream<<"Valid command-line parameter: \""
|
||||
<<name<<"\" = \""<<value<<"\""
|
||||
<<std::endl;
|
||||
set(name, value);
|
||||
@ -403,7 +404,7 @@ public:
|
||||
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");
|
||||
}
|
||||
|
139
src/test.cpp
139
src/test.cpp
@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "content_mapnode.h"
|
||||
#include "mapsector.h"
|
||||
#include "settings.h"
|
||||
#include "log.h"
|
||||
|
||||
/*
|
||||
Asserts that the exception occurs
|
||||
@ -49,9 +50,9 @@ struct TestUtilities
|
||||
{
|
||||
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);
|
||||
@ -112,13 +113,13 @@ struct TestCompress
|
||||
|
||||
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);
|
||||
|
||||
@ -139,12 +140,12 @@ struct TestCompress
|
||||
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());
|
||||
|
||||
@ -168,13 +169,13 @@ struct TestCompress
|
||||
|
||||
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);
|
||||
|
||||
@ -195,12 +196,12 @@ struct TestCompress
|
||||
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());
|
||||
|
||||
@ -258,12 +259,12 @@ struct TestVoxelManipulator
|
||||
|
||||
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);
|
||||
@ -277,27 +278,27 @@ struct TestVoxelManipulator
|
||||
|
||||
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)));
|
||||
@ -343,12 +344,12 @@ struct TestVoxelManipulator
|
||||
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;
|
||||
/*
|
||||
@ -365,8 +366,8 @@ struct TestVoxelManipulator
|
||||
//v.flowWater(active_nodes, 0, true, 1000);
|
||||
v.flowWater(active_nodes, 0, false, 1000);
|
||||
|
||||
dstream<<"Final result of flowWater:"<<std::endl;
|
||||
v.print(dstream, VOXELPRINT_WATERPRESSURE);
|
||||
infostream<<"Final result of flowWater:"<<std::endl;
|
||||
v.print(infostream, VOXELPRINT_WATERPRESSURE);
|
||||
#endif
|
||||
|
||||
//assert(0);
|
||||
@ -765,15 +766,15 @@ struct TestConnection
|
||||
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);
|
||||
@ -791,14 +792,14 @@ struct TestConnection
|
||||
}
|
||||
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;
|
||||
@ -824,11 +825,11 @@ struct TestConnection
|
||||
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);
|
||||
@ -837,7 +838,7 @@ struct TestConnection
|
||||
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);
|
||||
@ -852,9 +853,9 @@ struct TestConnection
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -879,9 +880,9 @@ struct TestConnection
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -897,9 +898,9 @@ struct TestConnection
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -912,16 +913,16 @@ struct TestConnection
|
||||
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;
|
||||
@ -942,7 +943,7 @@ struct TestConnection
|
||||
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;
|
||||
@ -957,16 +958,16 @@ struct TestConnection
|
||||
|
||||
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;
|
||||
@ -974,10 +975,10 @@ struct TestConnection
|
||||
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;
|
||||
@ -988,17 +989,17 @@ struct TestConnection
|
||||
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);
|
||||
@ -1010,35 +1011,35 @@ struct TestConnection
|
||||
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);
|
||||
@ -1057,14 +1058,14 @@ struct TestConnection
|
||||
#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);
|
||||
@ -1078,6 +1079,6 @@ void run_tests()
|
||||
TEST(TestConnection);
|
||||
dout_con<<"=== END RUNNING UNIT TESTS FOR CONNECTION ==="<<std::endl;
|
||||
}
|
||||
dstream<<"run_tests() passed"<<std::endl;
|
||||
infostream<<"run_tests() passed"<<std::endl;
|
||||
}
|
||||
|
||||
|
117
src/tile.cpp
117
src/tile.cpp
@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "utility.h"
|
||||
#include "settings.h"
|
||||
#include <ICameraSceneNode.h>
|
||||
#include "log.h"
|
||||
|
||||
/*
|
||||
A cache from texture name to texture path
|
||||
@ -162,7 +163,7 @@ TextureSource::TextureSource(IrrlichtDevice *device):
|
||||
if(g_settings->getBool("enable_texture_atlas"))
|
||||
buildMainAtlas();
|
||||
else
|
||||
dstream<<"INFO: Not building texture atlas."<<std::endl;
|
||||
infostream<<"Not building texture atlas."<<std::endl;
|
||||
}
|
||||
|
||||
TextureSource::~TextureSource()
|
||||
@ -179,7 +180,7 @@ void TextureSource::processQueue()
|
||||
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;
|
||||
@ -196,7 +197,7 @@ void TextureSource::processQueue()
|
||||
|
||||
u32 TextureSource::getTextureId(const std::string &name)
|
||||
{
|
||||
//dstream<<"INFO: getTextureId(): \""<<name<<"\""<<std::endl;
|
||||
//infostream<<"getTextureId(): \""<<name<<"\""<<std::endl;
|
||||
|
||||
{
|
||||
/*
|
||||
@ -220,7 +221,7 @@ u32 TextureSource::getTextureId(const std::string &name)
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
@ -228,7 +229,7 @@ u32 TextureSource::getTextureId(const std::string &name)
|
||||
// Throw a request in
|
||||
m_get_texture_queue.add(name, 0, 0, &result_queue);
|
||||
|
||||
dstream<<"INFO: Waiting for texture from main thread, name=\""
|
||||
infostream<<"Waiting for texture from main thread, name=\""
|
||||
<<name<<"\""<<std::endl;
|
||||
|
||||
try
|
||||
@ -244,12 +245,12 @@ u32 TextureSource::getTextureId(const std::string &name)
|
||||
}
|
||||
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;
|
||||
}
|
||||
@ -278,12 +279,12 @@ video::IImage* generate_image_from_scratch(std::string name,
|
||||
*/
|
||||
u32 TextureSource::getTextureIdDirect(const std::string &name)
|
||||
{
|
||||
//dstream<<"INFO: getTextureIdDirect(): name=\""<<name<<"\""<<std::endl;
|
||||
//infostream<<"getTextureIdDirect(): name=\""<<name<<"\""<<std::endl;
|
||||
|
||||
// Empty name means texture 0
|
||||
if(name == "")
|
||||
{
|
||||
dstream<<"INFO: getTextureIdDirect(): name is empty"<<std::endl;
|
||||
infostream<<"getTextureIdDirect(): name is empty"<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -292,7 +293,7 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
|
||||
*/
|
||||
if(get_current_thread_id() != m_main_thread)
|
||||
{
|
||||
dstream<<"ERROR: TextureSource::getTextureIdDirect() "
|
||||
errorstream<<"TextureSource::getTextureIdDirect() "
|
||||
"called not from main thread"<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
@ -307,13 +308,13 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
|
||||
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;
|
||||
|
||||
/*
|
||||
@ -348,13 +349,13 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
|
||||
{
|
||||
// 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);
|
||||
@ -377,7 +378,7 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
|
||||
|
||||
if(image == NULL)
|
||||
{
|
||||
dstream<<"WARNING: getTextureIdDirect(): NULL image in "
|
||||
infostream<<"getTextureIdDirect(): NULL image in "
|
||||
<<"cache: \""<<base_image_name<<"\""
|
||||
<<std::endl;
|
||||
}
|
||||
@ -396,7 +397,7 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
|
||||
core::rect<s32>(pos_from, dim) // from
|
||||
);
|
||||
|
||||
/*dstream<<"INFO: getTextureIdDirect(): Loaded \""
|
||||
/*infostream<<"getTextureIdDirect(): Loaded \""
|
||||
<<base_image_name<<"\" from image cache"
|
||||
<<std::endl;*/
|
||||
}
|
||||
@ -408,12 +409,12 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
|
||||
*/
|
||||
|
||||
std::string last_part_of_name = name.substr(last_separator_position+1);
|
||||
//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;
|
||||
}
|
||||
@ -421,7 +422,7 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -450,7 +451,7 @@ u32 TextureSource::getTextureIdDirect(const std::string &name)
|
||||
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;
|
||||
@ -462,7 +463,7 @@ std::string TextureSource::getTextureName(u32 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 "";
|
||||
@ -484,7 +485,7 @@ AtlasPointer TextureSource::getTexture(u32 id)
|
||||
|
||||
void TextureSource::buildMainAtlas()
|
||||
{
|
||||
dstream<<"TextureSource::buildMainAtlas()"<<std::endl;
|
||||
infostream<<"TextureSource::buildMainAtlas()"<<std::endl;
|
||||
|
||||
//return; // Disable (for testing)
|
||||
|
||||
@ -500,7 +501,7 @@ void TextureSource::buildMainAtlas()
|
||||
//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;
|
||||
}
|
||||
@ -569,7 +570,7 @@ void TextureSource::buildMainAtlas()
|
||||
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;
|
||||
}
|
||||
|
||||
@ -580,7 +581,7 @@ void TextureSource::buildMainAtlas()
|
||||
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;
|
||||
}
|
||||
@ -588,13 +589,13 @@ void TextureSource::buildMainAtlas()
|
||||
// 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
|
||||
@ -673,7 +674,7 @@ void TextureSource::buildMainAtlas()
|
||||
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;
|
||||
}
|
||||
|
||||
@ -687,7 +688,7 @@ void TextureSource::buildMainAtlas()
|
||||
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();
|
||||
@ -712,7 +713,7 @@ video::IImage* generate_image_from_scratch(std::string name,
|
||||
}
|
||||
}
|
||||
|
||||
/*dstream<<"INFO: generate_image_from_scratch(): "
|
||||
/*infostream<<"generate_image_from_scratch(): "
|
||||
<<"last_separator_position="<<last_separator_position
|
||||
<<std::endl;*/
|
||||
|
||||
@ -725,7 +726,7 @@ video::IImage* generate_image_from_scratch(std::string name,
|
||||
{
|
||||
// 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);
|
||||
@ -737,12 +738,12 @@ video::IImage* generate_image_from_scratch(std::string name,
|
||||
*/
|
||||
|
||||
std::string last_part_of_name = name.substr(last_separator_position+1);
|
||||
//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;
|
||||
@ -762,20 +763,20 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
{
|
||||
// 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
|
||||
@ -800,7 +801,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
// 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
|
||||
@ -814,7 +815,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
// 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);
|
||||
@ -835,7 +836,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
{
|
||||
// A special texture modification
|
||||
|
||||
dstream<<"INFO: generate_image(): generating special "
|
||||
infostream<<"generate_image(): generating special "
|
||||
<<"modification \""<<part_of_name<<"\""
|
||||
<<std::endl;
|
||||
|
||||
@ -858,7 +859,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
{
|
||||
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;
|
||||
@ -952,7 +953,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
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)
|
||||
@ -960,7 +961,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
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(
|
||||
@ -968,7 +969,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
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 =
|
||||
@ -983,7 +984,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
}
|
||||
else
|
||||
{
|
||||
dstream<<"WARNING: img==NULL"<<std::endl;
|
||||
infostream<<"img==NULL"<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -995,7 +996,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
{
|
||||
if(baseimg == NULL)
|
||||
{
|
||||
dstream<<"WARNING: generate_image(): baseimg==NULL "
|
||||
infostream<<"generate_image(): baseimg==NULL "
|
||||
<<"for part_of_name=\""<<part_of_name
|
||||
<<"\", cancelling."<<std::endl;
|
||||
return false;
|
||||
@ -1015,7 +1016,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
{
|
||||
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;
|
||||
@ -1025,14 +1026,14 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
|
||||
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
|
||||
@ -1062,7 +1063,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
{
|
||||
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;
|
||||
@ -1076,14 +1077,14 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
|
||||
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
|
||||
@ -1117,7 +1118,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
{
|
||||
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;
|
||||
@ -1134,14 +1135,14 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
|
||||
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
|
||||
@ -1180,7 +1181,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
{
|
||||
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;
|
||||
@ -1198,7 +1199,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
|
||||
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);
|
||||
@ -1207,7 +1208,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
|
||||
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
|
||||
@ -1309,7 +1310,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
||||
}
|
||||
else
|
||||
{
|
||||
dstream<<"WARNING: generate_image(): Invalid "
|
||||
infostream<<"generate_image(): Invalid "
|
||||
" modification: \""<<part_of_name<<"\""<<std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "gettime.h"
|
||||
#include "sha1.h"
|
||||
#include "base64.h"
|
||||
#include "log.h"
|
||||
|
||||
TimeTaker::TimeTaker(const char *name, u32 *result)
|
||||
{
|
||||
@ -47,7 +48,7 @@ u32 TimeTaker::stop(bool quiet)
|
||||
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;
|
||||
@ -156,6 +157,21 @@ void mysrand(unsigned seed)
|
||||
next = seed;
|
||||
}
|
||||
|
||||
int myrand_range(int min, int max)
|
||||
{
|
||||
if(max-min > MYRAND_MAX)
|
||||
{
|
||||
errorstream<<"WARNING: myrand_range: max-min > MYRAND_MAX"<<std::endl;
|
||||
assert(0);
|
||||
}
|
||||
if(min > max)
|
||||
{
|
||||
assert(0);
|
||||
return max;
|
||||
}
|
||||
return (myrand()%(max-min+1))+min;
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
// Sets the color of all vertices in the mesh
|
||||
void setMeshVerticesColor(scene::IMesh* mesh, video::SColor& color)
|
||||
|
@ -1230,20 +1230,7 @@ int myrand(void);
|
||||
void mysrand(unsigned seed);
|
||||
#define MYRAND_MAX 32767
|
||||
|
||||
inline int myrand_range(int min, int max)
|
||||
{
|
||||
if(max-min > MYRAND_MAX)
|
||||
{
|
||||
dstream<<"WARNING: myrand_range: max-min > MYRAND_MAX"<<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
|
||||
|
Loading…
Reference in New Issue
Block a user