mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Minor cleanups and logging changes
This commit is contained in:
parent
77dd86a79c
commit
3cb8ce69d2
8 changed files with 37 additions and 41 deletions
|
@ -839,10 +839,10 @@ bool Client::loadMedia(const std::string &data, const std::string &filename,
|
|||
};
|
||||
name = removeStringEnd(filename, model_ext);
|
||||
if (!name.empty()) {
|
||||
verbosestream<<"Client: Storing model into memory: "
|
||||
<<"\""<<filename<<"\""<<std::endl;
|
||||
TRACESTREAM(<<"Client: Storing model into memory "
|
||||
"\""<<filename<<"\""<<std::endl);
|
||||
if(m_mesh_data.count(filename))
|
||||
errorstream<<"Multiple models with name \""<<filename.c_str()
|
||||
errorstream<<"Multiple models with name \""<<filename
|
||||
<<"\" found; replacing previous model"<<std::endl;
|
||||
m_mesh_data[filename] = data;
|
||||
return true;
|
||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -624,6 +624,7 @@ static bool use_debugger(int argc, char *argv[])
|
|||
warningstream << "Couldn't find a debugger to use. Try installing gdb or lldb." << std::endl;
|
||||
return false;
|
||||
}
|
||||
verbosestream << "Found debugger " << debugger_path << std::endl;
|
||||
|
||||
// Try to be helpful
|
||||
#ifdef NDEBUG
|
||||
|
@ -682,11 +683,11 @@ static bool use_debugger(int argc, char *argv[])
|
|||
static bool init_common(const Settings &cmd_args, int argc, char *argv[])
|
||||
{
|
||||
startup_message();
|
||||
set_default_settings();
|
||||
|
||||
sockets_init();
|
||||
|
||||
// Initialize g_settings
|
||||
set_default_settings();
|
||||
Settings::createLayer(SL_GLOBAL);
|
||||
|
||||
// Set cleanup callback(s) to run at process exit
|
||||
|
@ -702,10 +703,11 @@ static bool init_common(const Settings &cmd_args, int argc, char *argv[])
|
|||
// Initialize random seed
|
||||
u64 seed;
|
||||
if (!porting::secure_rand_fill_buf(&seed, sizeof(seed))) {
|
||||
verbosestream << "Secure randomness not available to seed global RNG." << std::endl;
|
||||
infostream << "Secure randomness not available to seed global RNG!" << std::endl;
|
||||
std::ostringstream oss;
|
||||
// some stuff that's hard to predict:
|
||||
oss << time(nullptr) << porting::getTimeUs() << argc << g_settings_path;
|
||||
// stuff that's somewhat unpredictable:
|
||||
oss << time(nullptr) << porting::getTimeUs() << argc
|
||||
<< g_settings_path << reinterpret_cast<intptr_t>(argv);
|
||||
print_version(oss);
|
||||
std::string data = oss.str();
|
||||
seed = murmur_hash_64_ua(data.c_str(), data.size(), 0xc0ffee);
|
||||
|
|
|
@ -34,8 +34,9 @@
|
|||
|
||||
void Server::handleCommand_Deprecated(NetworkPacket* pkt)
|
||||
{
|
||||
infostream << "Server: " << toServerCommandTable[pkt->getCommand()].name
|
||||
<< " not supported anymore" << std::endl;
|
||||
auto &h = toServerCommandTable[pkt->getCommand()];
|
||||
infostream << "Server: ignoring unsupported " << h.name << " from peer " <<
|
||||
pkt->getPeerId() << std::endl;
|
||||
}
|
||||
|
||||
void Server::handleCommand_Init(NetworkPacket* pkt)
|
||||
|
@ -55,8 +56,8 @@ void Server::handleCommand_Init(NetworkPacket* pkt)
|
|||
* respond for some time, your server was overloaded or
|
||||
* things like that.
|
||||
*/
|
||||
infostream << "Server::ProcessData(): Canceling: peer " << peer_id <<
|
||||
" not found" << std::endl;
|
||||
infostream << "Server: peer " << peer_id << " not found during INIT?!"
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1363,22 +1364,11 @@ void Server::handleCommand_InventoryFields(NetworkPacket* pkt)
|
|||
session_t peer_id = pkt->getPeerId();
|
||||
RemotePlayer *player = m_env->getPlayer(peer_id);
|
||||
|
||||
if (player == NULL) {
|
||||
errorstream <<
|
||||
"Server::ProcessData(): Canceling: No player for peer_id=" <<
|
||||
peer_id << " disconnecting peer!" << std::endl;
|
||||
DisconnectPeer(peer_id);
|
||||
if (!player)
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerSAO *playersao = player->getPlayerSAO();
|
||||
if (playersao == NULL) {
|
||||
errorstream <<
|
||||
"Server::ProcessData(): Canceling: No player object for peer_id=" <<
|
||||
peer_id << " disconnecting peer!" << std::endl;
|
||||
DisconnectPeer(peer_id);
|
||||
if (!playersao)
|
||||
return;
|
||||
}
|
||||
|
||||
std::string client_formspec_name;
|
||||
StringMap fields;
|
||||
|
@ -1480,7 +1470,7 @@ void Server::handleCommand_FirstSrp(NetworkPacket* pkt)
|
|||
acceptAuth(peer_id, false);
|
||||
} else {
|
||||
if (cstate < CS_SudoMode) {
|
||||
infostream << "Server::ProcessData(): Ignoring TOSERVER_FIRST_SRP from "
|
||||
infostream << "Server: Ignoring TOSERVER_FIRST_SRP from "
|
||||
<< addr_s << ": " << "Client has wrong state " << cstate << "."
|
||||
<< std::endl;
|
||||
return;
|
||||
|
|
|
@ -67,7 +67,6 @@ void MainMenuScripting::initializeModApi(lua_State *L, int top)
|
|||
asyncEngine.registerStateInitializer(ModApiHttp::InitializeAsync);
|
||||
|
||||
// Initialize async environment
|
||||
//TODO possibly make number of async threads configurable
|
||||
asyncEngine.initialize(MAINMENU_NUM_ASYNC_THREADS);
|
||||
}
|
||||
|
||||
|
|
|
@ -2556,6 +2556,7 @@ bool Server::addMediaFile(const std::string &filename,
|
|||
<< filename << "\"" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// If name is not in a supported format, ignore it
|
||||
const char *supported_ext[] = {
|
||||
".png", ".jpg", ".tga",
|
||||
|
@ -2594,7 +2595,7 @@ bool Server::addMediaFile(const std::string &filename,
|
|||
// Put in list
|
||||
m_media[filename] = MediaInfo(filepath, sha1);
|
||||
verbosestream << "Server: " << sha1_hex << " is " << filename
|
||||
<< std::endl;
|
||||
<< " (" << (filedata.size() >> 10) << "KiB)" << std::endl;
|
||||
|
||||
if (filedata_to)
|
||||
*filedata_to = std::move(filedata);
|
||||
|
@ -2752,8 +2753,8 @@ void Server::sendRequestedMedia(session_t peer_id,
|
|||
auto it = m_media.find(name);
|
||||
|
||||
if (it == m_media.end()) {
|
||||
errorstream<<"Server::sendRequestedMedia(): Client asked for "
|
||||
<<"unknown file \""<<(name)<<"\""<<std::endl;
|
||||
warningstream << "Server::sendRequestedMedia(): Client asked for "
|
||||
"unknown file \"" << name << "\"" << std::endl;
|
||||
continue;
|
||||
}
|
||||
const auto &m = it->second;
|
||||
|
@ -2762,7 +2763,7 @@ void Server::sendRequestedMedia(session_t peer_id,
|
|||
// have duplicate filenames. So we can't check it.
|
||||
if (!m.no_announce) {
|
||||
if (!client->markMediaSent(name)) {
|
||||
infostream << "Server::sendRequestedMedia(): Client asked has "
|
||||
warningstream << "Server::sendRequestedMedia(): Client has "
|
||||
"requested \"" << name << "\" before, not sending it again."
|
||||
<< std::endl;
|
||||
continue;
|
||||
|
|
|
@ -709,8 +709,8 @@ void ClientInterface::step(float dtime)
|
|||
try {
|
||||
Address addr = m_con->GetPeerAddress(it.second->peer_id);
|
||||
os << "Disconnecting lingering client from "
|
||||
<< addr.serializeString() << " (state="
|
||||
<< state2Name(state) << ")" << std::endl;
|
||||
<< addr.serializeString() << " peer_id=" << it.second->peer_id
|
||||
<< " (" << state2Name(state) << ")" << std::endl;
|
||||
m_con->DisconnectPeer(it.second->peer_id);
|
||||
} catch (con::PeerNotFoundException &e) {
|
||||
}
|
||||
|
@ -739,6 +739,7 @@ void ClientInterface::UpdatePlayerList()
|
|||
RemoteClient* client = lockedGetClientNoEx(i);
|
||||
if (client)
|
||||
client->PrintInfo(infostream);
|
||||
infostream << std::endl;
|
||||
}
|
||||
|
||||
m_clients_names.emplace_back(player->getName());
|
||||
|
|
|
@ -276,12 +276,12 @@ public:
|
|||
|
||||
void PrintInfo(std::ostream &o)
|
||||
{
|
||||
o<<"RemoteClient "<<peer_id<<": "
|
||||
<<"m_blocks_sent.size()="<<m_blocks_sent.size()
|
||||
<<", m_blocks_sending.size()="<<m_blocks_sending.size()
|
||||
<<", m_nearest_unsent_d="<<m_nearest_unsent_d
|
||||
<<", m_excess_gotblocks="<<m_excess_gotblocks
|
||||
<<std::endl;
|
||||
o << "RemoteClient " << peer_id << ": "
|
||||
<<"blocks_sent=" << m_blocks_sent.size()
|
||||
<<", blocks_sending=" << m_blocks_sending.size()
|
||||
<<", nearest_unsent_d=" << m_nearest_unsent_d
|
||||
<<", map_send_completion_timer=" << (int)(m_map_send_completion_timer + 0.5f)
|
||||
<<", excess_gotblocks=" << m_excess_gotblocks;
|
||||
m_excess_gotblocks = 0;
|
||||
}
|
||||
|
||||
|
@ -507,13 +507,17 @@ private:
|
|||
|
||||
// Connection
|
||||
std::shared_ptr<con::IConnection> m_con;
|
||||
|
||||
// FIXME?: as far as I can tell this lock is pointless because only the server
|
||||
// thread ever touches the clients. Consider how getClientNoEx() returns
|
||||
// a raw pointer too.
|
||||
std::recursive_mutex m_clients_mutex;
|
||||
// Connected clients (behind the mutex)
|
||||
RemoteClientMap m_clients;
|
||||
std::vector<std::string> m_clients_names; // for announcing to server list
|
||||
|
||||
// Environment
|
||||
ServerEnvironment *m_env;
|
||||
ServerEnvironment *m_env = nullptr;
|
||||
|
||||
float m_print_info_timer = 0;
|
||||
float m_check_linger_timer = 0;
|
||||
|
|
|
@ -58,8 +58,6 @@ ServerMap::ServerMap(const std::string &savedir, IGameDef *gamedef,
|
|||
settings_mgr(savedir + DIR_DELIM + "map_meta.txt"),
|
||||
m_emerge(emerge)
|
||||
{
|
||||
verbosestream<<FUNCTION_NAME<<std::endl;
|
||||
|
||||
// Tell the EmergeManager about our MapSettingsManager
|
||||
emerge->map_settings_mgr = &settings_mgr;
|
||||
|
||||
|
@ -576,6 +574,7 @@ MapDatabase *ServerMap::createDatabase(
|
|||
Settings &conf)
|
||||
{
|
||||
MapDatabase *db = nullptr;
|
||||
verbosestream << "Creating map database with backend \"" << name << "\"" << std::endl;
|
||||
|
||||
if (name == "sqlite3")
|
||||
db = new MapDatabaseSQLite3(savedir);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue