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