mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
Clean up log messages everywhere
This commit is contained in:
parent
6ec447a1aa
commit
f1d9880006
@ -609,8 +609,8 @@ minetest.register_abm({
|
|||||||
end,
|
end,
|
||||||
})--]]
|
})--]]
|
||||||
|
|
||||||
print("experimental modname="..dump(minetest.get_current_modname()))
|
minetest.log("experimental modname="..dump(minetest.get_current_modname()))
|
||||||
print("experimental modpath="..dump(minetest.get_modpath("experimental")))
|
minetest.log("experimental modpath="..dump(minetest.get_modpath("experimental")))
|
||||||
print("experimental worldpath="..dump(minetest.get_worldpath()))
|
minetest.log("experimental worldpath="..dump(minetest.get_worldpath()))
|
||||||
|
|
||||||
-- END
|
-- END
|
||||||
|
@ -38,8 +38,6 @@ Clouds::Clouds(
|
|||||||
m_camera_pos(0,0),
|
m_camera_pos(0,0),
|
||||||
m_time(0)
|
m_time(0)
|
||||||
{
|
{
|
||||||
dstream<<__FUNCTION_NAME<<std::endl;
|
|
||||||
|
|
||||||
m_material.setFlag(video::EMF_LIGHTING, false);
|
m_material.setFlag(video::EMF_LIGHTING, false);
|
||||||
m_material.setFlag(video::EMF_BACK_FACE_CULLING, false);
|
m_material.setFlag(video::EMF_BACK_FACE_CULLING, false);
|
||||||
m_material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
m_material.setFlag(video::EMF_BILINEAR_FILTER, false);
|
||||||
@ -54,7 +52,6 @@ Clouds::Clouds(
|
|||||||
|
|
||||||
Clouds::~Clouds()
|
Clouds::~Clouds()
|
||||||
{
|
{
|
||||||
dstream<<__FUNCTION_NAME<<std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clouds::OnRegisterSceneNode()
|
void Clouds::OnRegisterSceneNode()
|
||||||
|
@ -517,7 +517,7 @@ std::string LuaEntitySAO::getClientInitializationData()
|
|||||||
|
|
||||||
std::string LuaEntitySAO::getStaticData()
|
std::string LuaEntitySAO::getStaticData()
|
||||||
{
|
{
|
||||||
infostream<<__FUNCTION_NAME<<std::endl;
|
verbosestream<<__FUNCTION_NAME<<std::endl;
|
||||||
std::ostringstream os(std::ios::binary);
|
std::ostringstream os(std::ios::binary);
|
||||||
// version
|
// version
|
||||||
writeU8(os, 1);
|
writeU8(os, 1);
|
||||||
@ -641,7 +641,7 @@ std::string LuaEntitySAO::getDescription()
|
|||||||
os<<(m_base_position.Y/BS)<<",";
|
os<<(m_base_position.Y/BS)<<",";
|
||||||
os<<(m_base_position.Z/BS);
|
os<<(m_base_position.Z/BS);
|
||||||
os<<")";
|
os<<")";
|
||||||
return std::string("LuaEntitySAO");
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaEntitySAO::setVelocity(v3f velocity)
|
void LuaEntitySAO::setVelocity(v3f velocity)
|
||||||
|
@ -827,7 +827,7 @@ public:
|
|||||||
}
|
}
|
||||||
virtual void registerCraft(CraftDefinition *def)
|
virtual void registerCraft(CraftDefinition *def)
|
||||||
{
|
{
|
||||||
infostream<<"registerCraft: registering craft definition: "
|
verbosestream<<"registerCraft: registering craft definition: "
|
||||||
<<def->dump()<<std::endl;
|
<<def->dump()<<std::endl;
|
||||||
m_craft_definitions.push_back(def);
|
m_craft_definitions.push_back(def);
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ void debugstreams_init(bool disable_stderr, const char *filename)
|
|||||||
fprintf(g_debugstreams[1], "-------------\n\n");
|
fprintf(g_debugstreams[1], "-------------\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGPRINT("Debug streams initialized, disable_stderr=%d\n",
|
DEBUGPRINT("Debug streams initialized, %s\n",
|
||||||
disable_stderr);
|
disable_stderr?"not printing on stderr":"using stderr");
|
||||||
}
|
}
|
||||||
|
|
||||||
void debugstreams_deinit()
|
void debugstreams_deinit()
|
||||||
|
@ -454,7 +454,7 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
|
|||||||
// Full path to this file
|
// Full path to this file
|
||||||
std::string path = players_path + "/" + player_files[i].name;
|
std::string path = players_path + "/" + player_files[i].name;
|
||||||
|
|
||||||
infostream<<"Checking player file "<<path<<std::endl;
|
//infostream<<"Checking player file "<<path<<std::endl;
|
||||||
|
|
||||||
// Load player to see what is its name
|
// Load player to see what is its name
|
||||||
ServerRemotePlayer testplayer(this);
|
ServerRemotePlayer testplayer(this);
|
||||||
@ -475,8 +475,8 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
|
|||||||
<<testplayer.getName()<<std::endl;
|
<<testplayer.getName()<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
infostream<<"Loaded test player with name "<<testplayer.getName()
|
/*infostream<<"Loaded test player with name "<<testplayer.getName()
|
||||||
<<std::endl;
|
<<std::endl;*/
|
||||||
|
|
||||||
// Search for the player
|
// Search for the player
|
||||||
std::string playername = testplayer.getName();
|
std::string playername = testplayer.getName();
|
||||||
@ -484,7 +484,7 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
|
|||||||
bool newplayer = false;
|
bool newplayer = false;
|
||||||
if(player == NULL)
|
if(player == NULL)
|
||||||
{
|
{
|
||||||
infostream<<"Is a new player"<<std::endl;
|
//infostream<<"Is a new player"<<std::endl;
|
||||||
player = new ServerRemotePlayer(this);
|
player = new ServerRemotePlayer(this);
|
||||||
newplayer = true;
|
newplayer = true;
|
||||||
}
|
}
|
||||||
@ -493,7 +493,7 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
|
|||||||
|
|
||||||
// Load player
|
// Load player
|
||||||
{
|
{
|
||||||
infostream<<"Reading player "<<testplayer.getName()<<" from "
|
verbosestream<<"Reading player "<<testplayer.getName()<<" from "
|
||||||
<<path<<std::endl;
|
<<path<<std::endl;
|
||||||
// Open file and deserialize
|
// Open file and deserialize
|
||||||
std::ifstream is(path.c_str(), std::ios_base::binary);
|
std::ifstream is(path.c_str(), std::ios_base::binary);
|
||||||
@ -2254,7 +2254,7 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type,
|
|||||||
|
|
||||||
void ClientEnvironment::removeActiveObject(u16 id)
|
void ClientEnvironment::removeActiveObject(u16 id)
|
||||||
{
|
{
|
||||||
infostream<<"ClientEnvironment::removeActiveObject(): "
|
verbosestream<<"ClientEnvironment::removeActiveObject(): "
|
||||||
<<"id="<<id<<std::endl;
|
<<"id="<<id<<std::endl;
|
||||||
ClientActiveObject* obj = getActiveObject(id);
|
ClientActiveObject* obj = getActiveObject(id);
|
||||||
if(obj == NULL)
|
if(obj == NULL)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef GETTEXT_HEADER
|
#ifndef GETTEXT_HEADER
|
||||||
#include "config.h" // for USE_GETTEXT
|
#include "config.h" // for USE_GETTEXT
|
||||||
#include <iostream>
|
#include "log.h"
|
||||||
|
|
||||||
#if USE_GETTEXT
|
#if USE_GETTEXT
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
@ -41,9 +41,9 @@ inline void changeCtype(const char *l)
|
|||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
ret = setlocale(LC_CTYPE, l);
|
ret = setlocale(LC_CTYPE, l);
|
||||||
if(ret == NULL)
|
if(ret == NULL)
|
||||||
std::cout<<"locale could not be set"<<std::endl;
|
infostream<<"locale could not be set"<<std::endl;
|
||||||
else
|
else
|
||||||
std::cout<<"locale has been set to:"<<ret<<std::endl;
|
infostream<<"locale has been set to:"<<ret<<std::endl;
|
||||||
}
|
}
|
||||||
#define GETTEXT_HEADER
|
#define GETTEXT_HEADER
|
||||||
#endif
|
#endif
|
||||||
|
@ -286,7 +286,7 @@ public:
|
|||||||
}
|
}
|
||||||
virtual void registerItem(const ItemDefinition &def)
|
virtual void registerItem(const ItemDefinition &def)
|
||||||
{
|
{
|
||||||
infostream<<"ItemDefManager: registering \""<<def.name<<"\""<<std::endl;
|
verbosestream<<"ItemDefManager: registering \""<<def.name<<"\""<<std::endl;
|
||||||
// Ensure that the "" item (the hand) always has ToolCapabilities
|
// Ensure that the "" item (the hand) always has ToolCapabilities
|
||||||
if(def.name == "")
|
if(def.name == "")
|
||||||
assert(def.tool_capabilities != NULL);
|
assert(def.tool_capabilities != NULL);
|
||||||
@ -304,7 +304,7 @@ public:
|
|||||||
{
|
{
|
||||||
if(m_item_definitions.find(name) == m_item_definitions.end())
|
if(m_item_definitions.find(name) == m_item_definitions.end())
|
||||||
{
|
{
|
||||||
infostream<<"ItemDefManager: setting alias "<<name
|
verbosestream<<"ItemDefManager: setting alias "<<name
|
||||||
<<" -> "<<convert_to<<std::endl;
|
<<" -> "<<convert_to<<std::endl;
|
||||||
m_aliases[name] = convert_to;
|
m_aliases[name] = convert_to;
|
||||||
}
|
}
|
||||||
|
14
src/main.cpp
14
src/main.cpp
@ -1188,8 +1188,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
// Init material properties table
|
dstream<<"path_share = "<<porting::path_share<<std::endl;
|
||||||
//initializeMaterialProperties();
|
dstream<<"path_user = "<<porting::path_user<<std::endl;
|
||||||
|
|
||||||
// Debug handler
|
// Debug handler
|
||||||
BEGIN_DEBUG_EXCEPTION_HANDLER
|
BEGIN_DEBUG_EXCEPTION_HANDLER
|
||||||
@ -1323,16 +1323,6 @@ int main(int argc, char *argv[])
|
|||||||
Server server(map_dir, configpath, "mesetint");
|
Server server(map_dir, configpath, "mesetint");
|
||||||
server.start(port);
|
server.start(port);
|
||||||
|
|
||||||
// ASCII art for the win!
|
|
||||||
actionstream
|
|
||||||
<<" .__ __ __ "<<std::endl
|
|
||||||
<<" _____ |__| ____ _____/ |_ ____ _______/ |_ "<<std::endl
|
|
||||||
<<" / \\| |/ \\_/ __ \\ __\\/ __ \\ / ___/\\ __\\"<<std::endl
|
|
||||||
<<"| Y Y \\ | | \\ ___/| | \\ ___/ \\___ \\ | | "<<std::endl
|
|
||||||
<<"|__|_| /__|___| /\\___ >__| \\___ >____ > |__| "<<std::endl
|
|
||||||
<<" \\/ \\/ \\/ \\/ \\/ "<<std::endl;
|
|
||||||
actionstream<<"Listening at port "<<port<<"."<<std::endl;
|
|
||||||
|
|
||||||
// Run server
|
// Run server
|
||||||
dedicated_server_loop(server, kill);
|
dedicated_server_loop(server, kill);
|
||||||
|
|
||||||
|
49
src/map.cpp
49
src/map.cpp
@ -1916,7 +1916,7 @@ ServerMap::ServerMap(std::string savedir, IGameDef *gamedef):
|
|||||||
m_database_read(NULL),
|
m_database_read(NULL),
|
||||||
m_database_write(NULL)
|
m_database_write(NULL)
|
||||||
{
|
{
|
||||||
infostream<<__FUNCTION_NAME<<std::endl;
|
verbosestream<<__FUNCTION_NAME<<std::endl;
|
||||||
|
|
||||||
//m_chunksize = 8; // Takes a few seconds
|
//m_chunksize = 8; // Takes a few seconds
|
||||||
|
|
||||||
@ -1954,7 +1954,7 @@ ServerMap::ServerMap(std::string savedir, IGameDef *gamedef):
|
|||||||
// If directory is empty, it is safe to save into it.
|
// If directory is empty, it is safe to save into it.
|
||||||
if(fs::GetDirListing(m_savedir).size() == 0)
|
if(fs::GetDirListing(m_savedir).size() == 0)
|
||||||
{
|
{
|
||||||
infostream<<"Server: Empty save directory is valid."
|
infostream<<"ServerMap: Empty save directory is valid."
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
m_map_saving_enabled = true;
|
m_map_saving_enabled = true;
|
||||||
}
|
}
|
||||||
@ -1971,25 +1971,10 @@ ServerMap::ServerMap(std::string savedir, IGameDef *gamedef):
|
|||||||
//m_chunksize = 0;
|
//m_chunksize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*try{
|
infostream<<"ServerMap: Successfully loaded map "
|
||||||
// Load chunk metadata
|
<<"metadata from "<<savedir
|
||||||
loadChunkMeta();
|
|
||||||
}
|
|
||||||
catch(FileNotGoodException &e){
|
|
||||||
infostream<<"WARNING: Could not load chunk metadata."
|
|
||||||
<<" Disabling chunk-based generator."
|
|
||||||
<<std::endl;
|
|
||||||
m_chunksize = 0;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*infostream<<"Server: Successfully loaded chunk "
|
|
||||||
"metadata and sector (0,0) from "<<savedir<<
|
|
||||||
", assuming valid save directory."
|
|
||||||
<<std::endl;*/
|
|
||||||
|
|
||||||
infostream<<"Server: Successfully loaded map "
|
|
||||||
<<"and chunk metadata from "<<savedir
|
|
||||||
<<", assuming valid save directory."
|
<<", assuming valid save directory."
|
||||||
|
<<" seed="<<m_seed<<"."
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
|
|
||||||
m_map_saving_enabled = true;
|
m_map_saving_enabled = true;
|
||||||
@ -2004,7 +1989,7 @@ ServerMap::ServerMap(std::string savedir, IGameDef *gamedef):
|
|||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
infostream<<"WARNING: Server: Failed to load map from "<<savedir
|
infostream<<"WARNING: ServerMap: Failed to load map from "<<savedir
|
||||||
<<", exception: "<<e.what()<<std::endl;
|
<<", exception: "<<e.what()<<std::endl;
|
||||||
infostream<<"Please remove the map or fix it."<<std::endl;
|
infostream<<"Please remove the map or fix it."<<std::endl;
|
||||||
infostream<<"WARNING: Map saving will be disabled."<<std::endl;
|
infostream<<"WARNING: Map saving will be disabled."<<std::endl;
|
||||||
@ -2021,7 +2006,7 @@ ServerMap::ServerMap(std::string savedir, IGameDef *gamedef):
|
|||||||
|
|
||||||
ServerMap::~ServerMap()
|
ServerMap::~ServerMap()
|
||||||
{
|
{
|
||||||
infostream<<__FUNCTION_NAME<<std::endl;
|
verbosestream<<__FUNCTION_NAME<<std::endl;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -2029,16 +2014,16 @@ ServerMap::~ServerMap()
|
|||||||
{
|
{
|
||||||
// Save only changed parts
|
// Save only changed parts
|
||||||
save(MOD_STATE_WRITE_AT_UNLOAD);
|
save(MOD_STATE_WRITE_AT_UNLOAD);
|
||||||
infostream<<"Server: saved map to "<<m_savedir<<std::endl;
|
infostream<<"ServerMap: Saved map to "<<m_savedir<<std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
infostream<<"Server: map not saved"<<std::endl;
|
infostream<<"ServerMap: Map not saved"<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
infostream<<"Server: Failed to save map to "<<m_savedir
|
infostream<<"ServerMap: Failed to save map to "<<m_savedir
|
||||||
<<", exception: "<<e.what()<<std::endl;
|
<<", exception: "<<e.what()<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2693,7 +2678,7 @@ void ServerMap::createDatabase() {
|
|||||||
if(e == SQLITE_ABORT)
|
if(e == SQLITE_ABORT)
|
||||||
throw FileNotGoodException("Could not create database structure");
|
throw FileNotGoodException("Could not create database structure");
|
||||||
else
|
else
|
||||||
infostream<<"Server: Database structure was created";
|
infostream<<"ServerMap: Database structure was created";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerMap::verifyDatabase() {
|
void ServerMap::verifyDatabase() {
|
||||||
@ -2741,7 +2726,7 @@ void ServerMap::verifyDatabase() {
|
|||||||
throw FileNotGoodException("Cannot prepare read statement");
|
throw FileNotGoodException("Cannot prepare read statement");
|
||||||
}
|
}
|
||||||
|
|
||||||
infostream<<"Server: Database opened"<<std::endl;
|
infostream<<"ServerMap: Database opened"<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2977,9 +2962,9 @@ void ServerMap::saveMapMeta()
|
|||||||
{
|
{
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
infostream<<"ServerMap::saveMapMeta(): "
|
/*infostream<<"ServerMap::saveMapMeta(): "
|
||||||
<<"seed="<<m_seed
|
<<"seed="<<m_seed
|
||||||
<<std::endl;
|
<<std::endl;*/
|
||||||
|
|
||||||
createDirs(m_savedir);
|
createDirs(m_savedir);
|
||||||
|
|
||||||
@ -3006,8 +2991,8 @@ void ServerMap::loadMapMeta()
|
|||||||
{
|
{
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
infostream<<"ServerMap::loadMapMeta(): Loading map metadata"
|
/*infostream<<"ServerMap::loadMapMeta(): Loading map metadata"
|
||||||
<<std::endl;
|
<<std::endl;*/
|
||||||
|
|
||||||
std::string fullpath = m_savedir + DIR_DELIM + "map_meta.txt";
|
std::string fullpath = m_savedir + DIR_DELIM + "map_meta.txt";
|
||||||
std::ifstream is(fullpath.c_str(), std::ios_base::binary);
|
std::ifstream is(fullpath.c_str(), std::ios_base::binary);
|
||||||
@ -3035,7 +3020,7 @@ void ServerMap::loadMapMeta()
|
|||||||
|
|
||||||
m_seed = params.getU64("seed");
|
m_seed = params.getU64("seed");
|
||||||
|
|
||||||
infostream<<"ServerMap::loadMapMeta(): "<<"seed="<<m_seed<<std::endl;
|
verbosestream<<"ServerMap::loadMapMeta(): "<<"seed="<<m_seed<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerMap::saveSectorMeta(ServerMapSector *sector)
|
void ServerMap::saveSectorMeta(ServerMapSector *sector)
|
||||||
|
@ -368,7 +368,7 @@ public:
|
|||||||
// IWritableNodeDefManager
|
// IWritableNodeDefManager
|
||||||
virtual void set(content_t c, const ContentFeatures &def)
|
virtual void set(content_t c, const ContentFeatures &def)
|
||||||
{
|
{
|
||||||
infostream<<"registerNode: registering content id \""<<c
|
verbosestream<<"registerNode: registering content id \""<<c
|
||||||
<<"\": name=\""<<def.name<<"\""<<std::endl;
|
<<"\": name=\""<<def.name<<"\""<<std::endl;
|
||||||
assert(c <= MAX_CONTENT);
|
assert(c <= MAX_CONTENT);
|
||||||
// Don't allow redefining CONTENT_IGNORE (but allow air)
|
// Don't allow redefining CONTENT_IGNORE (but allow air)
|
||||||
|
@ -71,7 +71,6 @@ void sigint_handler(int sig)
|
|||||||
|
|
||||||
void signal_handler_init(void)
|
void signal_handler_init(void)
|
||||||
{
|
{
|
||||||
dstream<<"signal_handler_init()"<<std::endl;
|
|
||||||
(void)signal(SIGINT, sigint_handler);
|
(void)signal(SIGINT, sigint_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +113,6 @@ void signal_handler_init(void)
|
|||||||
|
|
||||||
void signal_handler_init(void)
|
void signal_handler_init(void)
|
||||||
{
|
{
|
||||||
dstream<<"signal_handler_init()"<<std::endl;
|
|
||||||
SetConsoleCtrlHandler( (PHANDLER_ROUTINE)event_handler,TRUE);
|
SetConsoleCtrlHandler( (PHANDLER_ROUTINE)event_handler,TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,9 +286,6 @@ void initializePaths()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // RUN_IN_PLACE
|
#endif // RUN_IN_PLACE
|
||||||
|
|
||||||
dstream<<"path_share = "<<path_share<<std::endl;
|
|
||||||
dstream<<"path_user = "<<path_user<<std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace porting
|
} //namespace porting
|
||||||
|
@ -89,7 +89,7 @@ int luaErrorHandler(lua_State *L) {
|
|||||||
|
|
||||||
bool script_load(lua_State *L, const char *path)
|
bool script_load(lua_State *L, const char *path)
|
||||||
{
|
{
|
||||||
infostream<<"Loading and running script from "<<path<<std::endl;
|
verbosestream<<"Loading and running script from "<<path<<std::endl;
|
||||||
|
|
||||||
lua_pushcfunction(L, luaErrorHandler);
|
lua_pushcfunction(L, luaErrorHandler);
|
||||||
int errorhandler = lua_gettop(L);
|
int errorhandler = lua_gettop(L);
|
||||||
|
@ -2240,7 +2240,7 @@ private:
|
|||||||
ObjectRef *ref = checkobject(L, 1);
|
ObjectRef *ref = checkobject(L, 1);
|
||||||
ServerActiveObject *co = getobject(ref);
|
ServerActiveObject *co = getobject(ref);
|
||||||
if(co == NULL) return 0;
|
if(co == NULL) return 0;
|
||||||
infostream<<"ObjectRef::l_remove(): id="<<co->getId()<<std::endl;
|
verbosestream<<"ObjectRef::l_remove(): id="<<co->getId()<<std::endl;
|
||||||
co->m_removed = true;
|
co->m_removed = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2340,8 +2340,8 @@ private:
|
|||||||
ServerActiveObject *co = getobject(ref);
|
ServerActiveObject *co = getobject(ref);
|
||||||
if(co == NULL) return 0;
|
if(co == NULL) return 0;
|
||||||
int hp = lua_tonumber(L, 2);
|
int hp = lua_tonumber(L, 2);
|
||||||
infostream<<"ObjectRef::l_set_hp(): id="<<co->getId()
|
/*infostream<<"ObjectRef::l_set_hp(): id="<<co->getId()
|
||||||
<<" hp="<<hp<<std::endl;
|
<<" hp="<<hp<<std::endl;*/
|
||||||
// Do it
|
// Do it
|
||||||
co->setHP(hp);
|
co->setHP(hp);
|
||||||
// Return
|
// Return
|
||||||
@ -2357,8 +2357,8 @@ private:
|
|||||||
ServerActiveObject *co = getobject(ref);
|
ServerActiveObject *co = getobject(ref);
|
||||||
if(co == NULL) return 0;
|
if(co == NULL) return 0;
|
||||||
int hp = co->getHP();
|
int hp = co->getHP();
|
||||||
infostream<<"ObjectRef::l_get_hp(): id="<<co->getId()
|
/*infostream<<"ObjectRef::l_get_hp(): id="<<co->getId()
|
||||||
<<" hp="<<hp<<std::endl;
|
<<" hp="<<hp<<std::endl;*/
|
||||||
// Return
|
// Return
|
||||||
lua_pushnumber(L, hp);
|
lua_pushnumber(L, hp);
|
||||||
return 1;
|
return 1;
|
||||||
@ -3029,12 +3029,12 @@ public:
|
|||||||
EnvRef(ServerEnvironment *env):
|
EnvRef(ServerEnvironment *env):
|
||||||
m_env(env)
|
m_env(env)
|
||||||
{
|
{
|
||||||
infostream<<"EnvRef created"<<std::endl;
|
//infostream<<"EnvRef created"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
~EnvRef()
|
~EnvRef()
|
||||||
{
|
{
|
||||||
infostream<<"EnvRef destructing"<<std::endl;
|
//infostream<<"EnvRef destructing"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates an EnvRef and leaves it on top of stack
|
// Creates an EnvRef and leaves it on top of stack
|
||||||
@ -3230,7 +3230,7 @@ static int l_register_item_raw(lua_State *L)
|
|||||||
lua_getfield(L, table, "name");
|
lua_getfield(L, table, "name");
|
||||||
if(lua_isstring(L, -1)){
|
if(lua_isstring(L, -1)){
|
||||||
std::string name = lua_tostring(L, -1);
|
std::string name = lua_tostring(L, -1);
|
||||||
infostream<<"register_item_raw: "<<name<<std::endl;
|
verbosestream<<"register_item_raw: "<<name<<std::endl;
|
||||||
} else {
|
} else {
|
||||||
throw LuaError(L, "register_item_raw: name is not defined or not a string");
|
throw LuaError(L, "register_item_raw: name is not defined or not a string");
|
||||||
}
|
}
|
||||||
@ -3672,7 +3672,7 @@ void scriptapi_export(lua_State *L, Server *server)
|
|||||||
{
|
{
|
||||||
realitycheck(L);
|
realitycheck(L);
|
||||||
assert(lua_checkstack(L, 20));
|
assert(lua_checkstack(L, 20));
|
||||||
infostream<<"scriptapi_export"<<std::endl;
|
verbosestream<<"scriptapi_export()"<<std::endl;
|
||||||
StackUnroller stack_unroller(L);
|
StackUnroller stack_unroller(L);
|
||||||
|
|
||||||
// Store server as light userdata in registry
|
// Store server as light userdata in registry
|
||||||
@ -3732,7 +3732,7 @@ void scriptapi_add_environment(lua_State *L, ServerEnvironment *env)
|
|||||||
{
|
{
|
||||||
realitycheck(L);
|
realitycheck(L);
|
||||||
assert(lua_checkstack(L, 20));
|
assert(lua_checkstack(L, 20));
|
||||||
infostream<<"scriptapi_add_environment"<<std::endl;
|
verbosestream<<"scriptapi_add_environment"<<std::endl;
|
||||||
StackUnroller stack_unroller(L);
|
StackUnroller stack_unroller(L);
|
||||||
|
|
||||||
// Create EnvRef on stack
|
// Create EnvRef on stack
|
||||||
@ -4230,7 +4230,7 @@ bool scriptapi_luaentity_add(lua_State *L, u16 id, const char *name)
|
|||||||
{
|
{
|
||||||
realitycheck(L);
|
realitycheck(L);
|
||||||
assert(lua_checkstack(L, 20));
|
assert(lua_checkstack(L, 20));
|
||||||
infostream<<"scriptapi_luaentity_add: id="<<id<<" name=\""
|
verbosestream<<"scriptapi_luaentity_add: id="<<id<<" name=\""
|
||||||
<<name<<"\""<<std::endl;
|
<<name<<"\""<<std::endl;
|
||||||
StackUnroller stack_unroller(L);
|
StackUnroller stack_unroller(L);
|
||||||
|
|
||||||
@ -4281,7 +4281,7 @@ void scriptapi_luaentity_activate(lua_State *L, u16 id,
|
|||||||
{
|
{
|
||||||
realitycheck(L);
|
realitycheck(L);
|
||||||
assert(lua_checkstack(L, 20));
|
assert(lua_checkstack(L, 20));
|
||||||
infostream<<"scriptapi_luaentity_activate: id="<<id<<std::endl;
|
verbosestream<<"scriptapi_luaentity_activate: id="<<id<<std::endl;
|
||||||
StackUnroller stack_unroller(L);
|
StackUnroller stack_unroller(L);
|
||||||
|
|
||||||
// Get minetest.luaentities[id]
|
// Get minetest.luaentities[id]
|
||||||
@ -4306,7 +4306,7 @@ void scriptapi_luaentity_rm(lua_State *L, u16 id)
|
|||||||
{
|
{
|
||||||
realitycheck(L);
|
realitycheck(L);
|
||||||
assert(lua_checkstack(L, 20));
|
assert(lua_checkstack(L, 20));
|
||||||
infostream<<"scriptapi_luaentity_rm: id="<<id<<std::endl;
|
verbosestream<<"scriptapi_luaentity_rm: id="<<id<<std::endl;
|
||||||
|
|
||||||
// Get minetest.luaentities table
|
// Get minetest.luaentities table
|
||||||
lua_getglobal(L, "minetest");
|
lua_getglobal(L, "minetest");
|
||||||
@ -4326,7 +4326,7 @@ std::string scriptapi_luaentity_get_staticdata(lua_State *L, u16 id)
|
|||||||
{
|
{
|
||||||
realitycheck(L);
|
realitycheck(L);
|
||||||
assert(lua_checkstack(L, 20));
|
assert(lua_checkstack(L, 20));
|
||||||
infostream<<"scriptapi_luaentity_get_staticdata: id="<<id<<std::endl;
|
//infostream<<"scriptapi_luaentity_get_staticdata: id="<<id<<std::endl;
|
||||||
StackUnroller stack_unroller(L);
|
StackUnroller stack_unroller(L);
|
||||||
|
|
||||||
// Get minetest.luaentities[id]
|
// Get minetest.luaentities[id]
|
||||||
@ -4356,7 +4356,7 @@ void scriptapi_luaentity_get_properties(lua_State *L, u16 id,
|
|||||||
{
|
{
|
||||||
realitycheck(L);
|
realitycheck(L);
|
||||||
assert(lua_checkstack(L, 20));
|
assert(lua_checkstack(L, 20));
|
||||||
infostream<<"scriptapi_luaentity_get_properties: id="<<id<<std::endl;
|
//infostream<<"scriptapi_luaentity_get_properties: id="<<id<<std::endl;
|
||||||
StackUnroller stack_unroller(L);
|
StackUnroller stack_unroller(L);
|
||||||
|
|
||||||
// Get minetest.luaentities[id]
|
// Get minetest.luaentities[id]
|
||||||
|
205
src/server.cpp
205
src/server.cpp
@ -824,18 +824,11 @@ void PlayerInfo::PrintLine(std::ostream *s)
|
|||||||
(*s)<<std::endl;
|
(*s)<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 PIChecksum(core::list<PlayerInfo> &l)
|
static std::string padStringRight(std::string s, size_t len)
|
||||||
{
|
{
|
||||||
core::list<PlayerInfo>::Iterator i;
|
if(len > s.size())
|
||||||
u32 checksum = 1;
|
s.insert(s.end(), len - s.size(), ' ');
|
||||||
u32 a = 10;
|
return s;
|
||||||
for(i=l.begin(); i!=l.end(); i++)
|
|
||||||
{
|
|
||||||
checksum += a * (i->id+1);
|
|
||||||
checksum ^= 0x435aafcd;
|
|
||||||
a *= 10;
|
|
||||||
}
|
|
||||||
return checksum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -867,11 +860,6 @@ Server::Server(
|
|||||||
m_ignore_map_edit_events(false),
|
m_ignore_map_edit_events(false),
|
||||||
m_ignore_map_edit_events_peer_id(0)
|
m_ignore_map_edit_events_peer_id(0)
|
||||||
{
|
{
|
||||||
infostream<<"Server created."<<std::endl;
|
|
||||||
infostream<<"- path_world = "<<path_world<<std::endl;
|
|
||||||
infostream<<"- path_config = "<<path_config<<std::endl;
|
|
||||||
infostream<<"- gamename = "<<gamename<<std::endl;
|
|
||||||
|
|
||||||
m_liquid_transform_timer = 0.0;
|
m_liquid_transform_timer = 0.0;
|
||||||
m_print_info_timer = 0.0;
|
m_print_info_timer = 0.0;
|
||||||
m_objectdata_timer = 0.0;
|
m_objectdata_timer = 0.0;
|
||||||
@ -884,13 +872,36 @@ Server::Server(
|
|||||||
m_step_dtime = 0.0;
|
m_step_dtime = 0.0;
|
||||||
|
|
||||||
// Figure out some paths
|
// Figure out some paths
|
||||||
|
// share/server
|
||||||
m_path_share = porting::path_share + DIR_DELIM + "server";
|
m_path_share = porting::path_share + DIR_DELIM + "server";
|
||||||
m_path_game = m_path_share + DIR_DELIM + "games" + DIR_DELIM + m_gamename;
|
// game
|
||||||
|
m_path_game = porting::path_user + DIR_DELIM + "server" + DIR_DELIM
|
||||||
|
+ "games" + DIR_DELIM + m_gamename;
|
||||||
|
bool user_game = true; // Game is in user's directory
|
||||||
|
if(!fs::PathExists(m_path_game)){
|
||||||
|
m_path_game = m_path_share + DIR_DELIM + "games" + DIR_DELIM
|
||||||
|
+ m_gamename;
|
||||||
|
user_game = false;
|
||||||
|
}
|
||||||
|
if(!fs::PathExists(m_path_game)){
|
||||||
|
throw ServerError("Could not find game files for game \""
|
||||||
|
+gamename+"\"");
|
||||||
|
}
|
||||||
|
// addons
|
||||||
|
if(!user_game)
|
||||||
m_path_addons.insert(m_path_share + DIR_DELIM + "addons"
|
m_path_addons.insert(m_path_share + DIR_DELIM + "addons"
|
||||||
+ DIR_DELIM + m_gamename);
|
+ DIR_DELIM + m_gamename);
|
||||||
m_path_addons.insert(porting::path_user + DIR_DELIM + "server"
|
m_path_addons.insert(porting::path_user + DIR_DELIM + "server"
|
||||||
+ DIR_DELIM + "addons" + DIR_DELIM + m_gamename);
|
+ DIR_DELIM + "addons" + DIR_DELIM + m_gamename);
|
||||||
|
|
||||||
|
infostream<<"Server created for gamename=\""<<gamename<<"\""<<std::endl;
|
||||||
|
infostream<<"- path_world = "<<m_path_world<<std::endl;
|
||||||
|
infostream<<"- path_config = "<<m_path_config<<std::endl;
|
||||||
|
infostream<<"- path_game = "<<m_path_game<<std::endl;
|
||||||
|
for(std::set<std::string>::const_iterator i = m_path_addons.begin();
|
||||||
|
i != m_path_addons.end(); i++)
|
||||||
|
infostream<<"- path_addons+= "<<(*i)<<std::endl;
|
||||||
|
|
||||||
// Path to builtin.lua
|
// Path to builtin.lua
|
||||||
std::string builtinpath = m_path_share + DIR_DELIM + "builtin.lua";
|
std::string builtinpath = m_path_share + DIR_DELIM + "builtin.lua";
|
||||||
|
|
||||||
@ -905,11 +916,10 @@ Server::Server(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print out mod search paths
|
// Print out mod search paths
|
||||||
infostream<<"- mod search paths:"<<std::endl;
|
|
||||||
for(core::list<std::string>::Iterator i = m_modspaths.begin();
|
for(core::list<std::string>::Iterator i = m_modspaths.begin();
|
||||||
i != m_modspaths.end(); i++){
|
i != m_modspaths.end(); i++){
|
||||||
std::string modspath = *i;
|
std::string modspath = *i;
|
||||||
infostream<<" "<<modspath<<std::endl;
|
infostream<<"- modspath += "<<modspath<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock environment
|
// Lock environment
|
||||||
@ -918,27 +928,37 @@ Server::Server(
|
|||||||
|
|
||||||
// Initialize scripting
|
// Initialize scripting
|
||||||
|
|
||||||
infostream<<"Server: Initializing scripting"<<std::endl;
|
infostream<<"Server: Initializing Lua"<<std::endl;
|
||||||
m_lua = script_init();
|
m_lua = script_init();
|
||||||
assert(m_lua);
|
assert(m_lua);
|
||||||
// Export API
|
// Export API
|
||||||
scriptapi_export(m_lua, this);
|
scriptapi_export(m_lua, this);
|
||||||
// Load and run builtin.lua
|
// Load and run builtin.lua
|
||||||
infostream<<"Server: Loading builtin Lua stuff from \""<<builtinpath
|
infostream<<"Server: Loading builtin.lua [\""
|
||||||
<<"\""<<std::endl;
|
<<builtinpath<<"\"]"<<std::endl;
|
||||||
bool success = scriptapi_loadmod(m_lua, builtinpath, "__builtin");
|
bool success = scriptapi_loadmod(m_lua, builtinpath, "__builtin");
|
||||||
if(!success){
|
if(!success){
|
||||||
errorstream<<"Server: Failed to load and run "
|
errorstream<<"Server: Failed to load and run "
|
||||||
<<builtinpath<<std::endl;
|
<<builtinpath<<std::endl;
|
||||||
throw ModError("Failed to load and run "+builtinpath);
|
throw ModError("Failed to load and run "+builtinpath);
|
||||||
}
|
}
|
||||||
// Load and run "mod" scripts
|
// Find mods in mod search paths
|
||||||
m_mods = getMods(m_modspaths);
|
m_mods = getMods(m_modspaths);
|
||||||
|
// Print 'em
|
||||||
|
infostream<<"Server: Loading mods: ";
|
||||||
|
for(core::list<ModSpec>::Iterator i = m_mods.begin();
|
||||||
|
i != m_mods.end(); i++){
|
||||||
|
const ModSpec &mod = *i;
|
||||||
|
infostream<<mod.name<<" ";
|
||||||
|
}
|
||||||
|
infostream<<std::endl;
|
||||||
|
// Load and run "mod" scripts
|
||||||
for(core::list<ModSpec>::Iterator i = m_mods.begin();
|
for(core::list<ModSpec>::Iterator i = m_mods.begin();
|
||||||
i != m_mods.end(); i++){
|
i != m_mods.end(); i++){
|
||||||
const ModSpec &mod = *i;
|
const ModSpec &mod = *i;
|
||||||
infostream<<"Server: Loading mod \""<<mod.name<<"\""<<std::endl;
|
|
||||||
std::string scriptpath = mod.path + DIR_DELIM + "init.lua";
|
std::string scriptpath = mod.path + DIR_DELIM + "init.lua";
|
||||||
|
infostream<<" ["<<padStringRight(mod.name, 12)<<"] [\""
|
||||||
|
<<scriptpath<<"\"]"<<std::endl;
|
||||||
bool success = scriptapi_loadmod(m_lua, scriptpath, mod.name);
|
bool success = scriptapi_loadmod(m_lua, scriptpath, mod.name);
|
||||||
if(!success){
|
if(!success){
|
||||||
errorstream<<"Server: Failed to load and run "
|
errorstream<<"Server: Failed to load and run "
|
||||||
@ -983,7 +1003,7 @@ Server::Server(
|
|||||||
|
|
||||||
Server::~Server()
|
Server::~Server()
|
||||||
{
|
{
|
||||||
infostream<<"Server::~Server()"<<std::endl;
|
infostream<<"Server destructing"<<std::endl;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Send shutdown message
|
Send shutdown message
|
||||||
@ -1084,7 +1104,15 @@ void Server::start(unsigned short port)
|
|||||||
m_thread.setRun(true);
|
m_thread.setRun(true);
|
||||||
m_thread.Start();
|
m_thread.Start();
|
||||||
|
|
||||||
infostream<<"Server started on port "<<port<<"."<<std::endl;
|
// ASCII art for the win!
|
||||||
|
actionstream
|
||||||
|
<<" .__ __ __ "<<std::endl
|
||||||
|
<<" _____ |__| ____ _____/ |_ ____ _______/ |_ "<<std::endl
|
||||||
|
<<" / \\| |/ \\_/ __ \\ __\\/ __ \\ / ___/\\ __\\"<<std::endl
|
||||||
|
<<"| Y Y \\ | | \\ ___/| | \\ ___/ \\___ \\ | | "<<std::endl
|
||||||
|
<<"|__|_| /__|___| /\\___ >__| \\___ >____ > |__| "<<std::endl
|
||||||
|
<<" \\/ \\/ \\/ \\/ \\/ "<<std::endl;
|
||||||
|
actionstream<<"Server listening on port "<<port<<"."<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::stop()
|
void Server::stop()
|
||||||
@ -1514,7 +1542,7 @@ void Server::AsyncRunStep()
|
|||||||
// Send as reliable
|
// Send as reliable
|
||||||
m_con.Send(client->peer_id, 0, reply, true);
|
m_con.Send(client->peer_id, 0, reply, true);
|
||||||
|
|
||||||
infostream<<"Server: Sent object remove/add: "
|
verbosestream<<"Server: Sent object remove/add: "
|
||||||
<<removed_objects.size()<<" removed, "
|
<<removed_objects.size()<<" removed, "
|
||||||
<<added_objects.size()<<" added, "
|
<<added_objects.size()<<" added, "
|
||||||
<<"packet size is "<<reply.getSize()<<std::endl;
|
<<"packet size is "<<reply.getSize()<<std::endl;
|
||||||
@ -1677,15 +1705,13 @@ void Server::AsyncRunStep()
|
|||||||
if(m_unsent_map_edit_queue.size() >= 4)
|
if(m_unsent_map_edit_queue.size() >= 4)
|
||||||
disable_single_change_sending = true;
|
disable_single_change_sending = true;
|
||||||
|
|
||||||
bool got_any_events = false;
|
int event_count = m_unsent_map_edit_queue.size();
|
||||||
|
|
||||||
// We'll log the amount of each
|
// We'll log the amount of each
|
||||||
Profiler prof;
|
Profiler prof;
|
||||||
|
|
||||||
while(m_unsent_map_edit_queue.size() != 0)
|
while(m_unsent_map_edit_queue.size() != 0)
|
||||||
{
|
{
|
||||||
got_any_events = true;
|
|
||||||
|
|
||||||
MapEditEvent* event = m_unsent_map_edit_queue.pop_front();
|
MapEditEvent* event = m_unsent_map_edit_queue.pop_front();
|
||||||
|
|
||||||
// Players far away from the change are stored here.
|
// Players far away from the change are stored here.
|
||||||
@ -1776,10 +1802,12 @@ void Server::AsyncRunStep()
|
|||||||
break;*/
|
break;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if(got_any_events)
|
if(event_count >= 5){
|
||||||
{
|
|
||||||
infostream<<"Server: MapEditEvents:"<<std::endl;
|
infostream<<"Server: MapEditEvents:"<<std::endl;
|
||||||
prof.print(infostream);
|
prof.print(infostream);
|
||||||
|
} else if(event_count != 0){
|
||||||
|
verbosestream<<"Server: MapEditEvents:"<<std::endl;
|
||||||
|
prof.print(verbosestream);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1900,6 +1928,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string addr_s = m_con.GetPeerAddress(peer_id).serializeString();
|
||||||
|
|
||||||
u8 peer_ser_ver = getClient(peer_id)->serialization_version;
|
u8 peer_ser_ver = getClient(peer_id)->serialization_version;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -1920,7 +1950,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
if(datasize < 2+1+PLAYERNAME_SIZE)
|
if(datasize < 2+1+PLAYERNAME_SIZE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
infostream<<"Server: Got TOSERVER_INIT from "
|
verbosestream<<"Server: Got TOSERVER_INIT from "
|
||||||
<<peer_id<<std::endl;
|
<<peer_id<<std::endl;
|
||||||
|
|
||||||
// First byte after command is maximum supported
|
// First byte after command is maximum supported
|
||||||
@ -1938,8 +1968,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
|
|
||||||
if(deployed == SER_FMT_VER_INVALID)
|
if(deployed == SER_FMT_VER_INVALID)
|
||||||
{
|
{
|
||||||
actionstream<<"Server: A mismatched client tried to connect."
|
actionstream<<"Server: A mismatched client tried to connect from "
|
||||||
<<std::endl;
|
<<addr_s<<std::endl;
|
||||||
infostream<<"Server: Cannot negotiate "
|
infostream<<"Server: Cannot negotiate "
|
||||||
"serialization version with peer "
|
"serialization version with peer "
|
||||||
<<peer_id<<std::endl;
|
<<peer_id<<std::endl;
|
||||||
@ -1965,7 +1995,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
|
|
||||||
if(net_proto_version == 0)
|
if(net_proto_version == 0)
|
||||||
{
|
{
|
||||||
actionstream<<"Server: An old tried to connect."
|
actionstream<<"Server: An old tried to connect from "<<addr_s
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
SendAccessDenied(m_con, peer_id, std::wstring(
|
SendAccessDenied(m_con, peer_id, std::wstring(
|
||||||
L"Your client's version is not supported.\n"
|
L"Your client's version is not supported.\n"
|
||||||
@ -1979,8 +2009,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
{
|
{
|
||||||
if(net_proto_version != PROTOCOL_VERSION)
|
if(net_proto_version != PROTOCOL_VERSION)
|
||||||
{
|
{
|
||||||
actionstream<<"Server: A mismatched client tried to connect."
|
actionstream<<"Server: A mismatched client tried to connect"
|
||||||
<<std::endl;
|
<<" from "<<addr_s<<std::endl;
|
||||||
SendAccessDenied(m_con, peer_id, std::wstring(
|
SendAccessDenied(m_con, peer_id, std::wstring(
|
||||||
L"Your client's version is not supported.\n"
|
L"Your client's version is not supported.\n"
|
||||||
L"Server version is ")
|
L"Server version is ")
|
||||||
@ -2009,7 +2039,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
if(playername[0]=='\0')
|
if(playername[0]=='\0')
|
||||||
{
|
{
|
||||||
actionstream<<"Server: Player with an empty name "
|
actionstream<<"Server: Player with an empty name "
|
||||||
<<"tried to connect."<<std::endl;
|
<<"tried to connect from "<<addr_s<<std::endl;
|
||||||
SendAccessDenied(m_con, peer_id,
|
SendAccessDenied(m_con, peer_id,
|
||||||
L"Empty name");
|
L"Empty name");
|
||||||
return;
|
return;
|
||||||
@ -2018,12 +2048,15 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
if(string_allowed(playername, PLAYERNAME_ALLOWED_CHARS)==false)
|
if(string_allowed(playername, PLAYERNAME_ALLOWED_CHARS)==false)
|
||||||
{
|
{
|
||||||
actionstream<<"Server: Player with an invalid name "
|
actionstream<<"Server: Player with an invalid name "
|
||||||
<<"tried to connect."<<std::endl;
|
<<"tried to connect from "<<addr_s<<std::endl;
|
||||||
SendAccessDenied(m_con, peer_id,
|
SendAccessDenied(m_con, peer_id,
|
||||||
L"Name contains unallowed characters");
|
L"Name contains unallowed characters");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
infostream<<"Server: New connection: \""<<playername<<"\" from "
|
||||||
|
<<m_con.GetPeerAddress(peer_id).serializeString()<<std::endl;
|
||||||
|
|
||||||
// Get password
|
// Get password
|
||||||
char password[PASSWORD_SIZE];
|
char password[PASSWORD_SIZE];
|
||||||
if(datasize < 2+1+PLAYERNAME_SIZE+PASSWORD_SIZE)
|
if(datasize < 2+1+PLAYERNAME_SIZE+PASSWORD_SIZE)
|
||||||
@ -2124,7 +2157,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
|
|
||||||
if(command == TOSERVER_INIT2)
|
if(command == TOSERVER_INIT2)
|
||||||
{
|
{
|
||||||
infostream<<"Server: Got TOSERVER_INIT2 from "
|
verbosestream<<"Server: Got TOSERVER_INIT2 from "
|
||||||
<<peer_id<<std::endl;
|
<<peer_id<<std::endl;
|
||||||
|
|
||||||
|
|
||||||
@ -2135,6 +2168,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
Send some initialization data
|
Send some initialization data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
infostream<<"Server: Sending content to "
|
||||||
|
<<getPlayerName(peer_id)<<std::endl;
|
||||||
|
|
||||||
// Send item definitions
|
// Send item definitions
|
||||||
SendItemDef(m_con, peer_id, m_itemdef);
|
SendItemDef(m_con, peer_id, m_itemdef);
|
||||||
|
|
||||||
@ -2389,7 +2425,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
{
|
{
|
||||||
// Strip command and create a stream
|
// Strip command and create a stream
|
||||||
std::string datastring((char*)&data[2], datasize-2);
|
std::string datastring((char*)&data[2], datasize-2);
|
||||||
infostream<<"TOSERVER_INVENTORY_ACTION: data="<<datastring<<std::endl;
|
verbosestream<<"TOSERVER_INVENTORY_ACTION: data="<<datastring<<std::endl;
|
||||||
std::istringstream is(datastring, std::ios_base::binary);
|
std::istringstream is(datastring, std::ios_base::binary);
|
||||||
// Create an action
|
// Create an action
|
||||||
InventoryAction *a = InventoryAction::deSerialize(is);
|
InventoryAction *a = InventoryAction::deSerialize(is);
|
||||||
@ -2801,18 +2837,19 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
std::string datastring((char*)&data[2], datasize-2);
|
std::string datastring((char*)&data[2], datasize-2);
|
||||||
std::istringstream is(datastring, std::ios_base::binary);
|
std::istringstream is(datastring, std::ios_base::binary);
|
||||||
|
|
||||||
infostream<<"TOSERVER_REQUEST_TEXTURES: "<<std::endl;
|
|
||||||
|
|
||||||
core::list<TextureRequest> tosend;
|
core::list<TextureRequest> tosend;
|
||||||
|
|
||||||
u16 numtextures = readU16(is);
|
u16 numtextures = readU16(is);
|
||||||
|
|
||||||
|
infostream<<"Sending "<<numtextures<<" textures to "
|
||||||
|
<<getPlayerName(peer_id)<<std::endl;
|
||||||
|
verbosestream<<"TOSERVER_REQUEST_TEXTURES: "<<std::endl;
|
||||||
|
|
||||||
for(int i = 0; i < numtextures; i++) {
|
for(int i = 0; i < numtextures; i++) {
|
||||||
|
|
||||||
std::string name = deSerializeString(is);
|
std::string name = deSerializeString(is);
|
||||||
|
|
||||||
tosend.push_back(TextureRequest(name));
|
tosend.push_back(TextureRequest(name));
|
||||||
infostream<<"TOSERVER_REQUEST_TEXTURES: requested texture " << name <<std::endl;
|
verbosestream<<"TOSERVER_REQUEST_TEXTURES: requested texture "
|
||||||
|
<<name<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendTexturesRequested(peer_id, tosend);
|
SendTexturesRequested(peer_id, tosend);
|
||||||
@ -2845,11 +2882,12 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
PointedThing pointed;
|
PointedThing pointed;
|
||||||
pointed.deSerialize(tmp_is);
|
pointed.deSerialize(tmp_is);
|
||||||
|
|
||||||
infostream<<"TOSERVER_INTERACT: action="<<(int)action<<", item="<<item_i<<", pointed="<<pointed.dump()<<std::endl;
|
verbosestream<<"TOSERVER_INTERACT: action="<<(int)action<<", item="
|
||||||
|
<<item_i<<", pointed="<<pointed.dump()<<std::endl;
|
||||||
|
|
||||||
if(player->hp == 0)
|
if(player->hp == 0)
|
||||||
{
|
{
|
||||||
infostream<<"TOSERVER_INTERACT: "<<srp->getName()
|
verbosestream<<"TOSERVER_INTERACT: "<<srp->getName()
|
||||||
<<" tried to interact, but is dead!"<<std::endl;
|
<<" tried to interact, but is dead!"<<std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2874,7 +2912,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
pointed_object = m_env->getActiveObject(pointed.object_id);
|
pointed_object = m_env->getActiveObject(pointed.object_id);
|
||||||
if(pointed_object == NULL)
|
if(pointed_object == NULL)
|
||||||
{
|
{
|
||||||
infostream<<"TOSERVER_INTERACT: "
|
verbosestream<<"TOSERVER_INTERACT: "
|
||||||
"pointed object is NULL"<<std::endl;
|
"pointed object is NULL"<<std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2962,7 +3000,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
actionstream<<player->getName()<<" punches object "
|
actionstream<<player->getName()<<" punches object "
|
||||||
<<pointed.object_id<<std::endl;
|
<<pointed.object_id<<": "
|
||||||
|
<<pointed_object->getDescription()<<std::endl;
|
||||||
|
|
||||||
ItemStack punchitem = srp->getWieldedItem();
|
ItemStack punchitem = srp->getWieldedItem();
|
||||||
ToolCapabilities toolcap =
|
ToolCapabilities toolcap =
|
||||||
@ -3031,7 +3070,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
actionstream<<player->getName()<<" right-clicks object "
|
actionstream<<player->getName()<<" right-clicks object "
|
||||||
<<pointed.object_id<<std::endl;
|
<<pointed.object_id<<": "
|
||||||
|
<<pointed_object->getDescription()<<std::endl;
|
||||||
|
|
||||||
// Do stuff
|
// Do stuff
|
||||||
pointed_object->rightClick(srp);
|
pointed_object->rightClick(srp);
|
||||||
@ -3238,7 +3278,7 @@ core::list<PlayerInfo> Server::getPlayerInfo()
|
|||||||
void Server::peerAdded(con::Peer *peer)
|
void Server::peerAdded(con::Peer *peer)
|
||||||
{
|
{
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
infostream<<"Server::peerAdded(): peer->id="
|
verbosestream<<"Server::peerAdded(): peer->id="
|
||||||
<<peer->id<<std::endl;
|
<<peer->id<<std::endl;
|
||||||
|
|
||||||
PeerChange c;
|
PeerChange c;
|
||||||
@ -3251,7 +3291,7 @@ void Server::peerAdded(con::Peer *peer)
|
|||||||
void Server::deletingPeer(con::Peer *peer, bool timeout)
|
void Server::deletingPeer(con::Peer *peer, bool timeout)
|
||||||
{
|
{
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
infostream<<"Server::deletingPeer(): peer->id="
|
verbosestream<<"Server::deletingPeer(): peer->id="
|
||||||
<<peer->id<<", timeout="<<timeout<<std::endl;
|
<<peer->id<<", timeout="<<timeout<<std::endl;
|
||||||
|
|
||||||
PeerChange c;
|
PeerChange c;
|
||||||
@ -3333,8 +3373,8 @@ void Server::SendItemDef(con::Connection &con, u16 peer_id,
|
|||||||
|
|
||||||
// Make data buffer
|
// Make data buffer
|
||||||
std::string s = os.str();
|
std::string s = os.str();
|
||||||
infostream<<"Server::SendItemDef(): Sending item definitions: size="
|
verbosestream<<"Server: Sending item definitions to id("<<peer_id
|
||||||
<<s.size()<<std::endl;
|
<<"): size="<<s.size()<<std::endl;
|
||||||
SharedBuffer<u8> data((u8*)s.c_str(), s.size());
|
SharedBuffer<u8> data((u8*)s.c_str(), s.size());
|
||||||
// Send as reliable
|
// Send as reliable
|
||||||
con.Send(peer_id, 0, data, true);
|
con.Send(peer_id, 0, data, true);
|
||||||
@ -3360,8 +3400,8 @@ void Server::SendNodeDef(con::Connection &con, u16 peer_id,
|
|||||||
|
|
||||||
// Make data buffer
|
// Make data buffer
|
||||||
std::string s = os.str();
|
std::string s = os.str();
|
||||||
infostream<<"Server::SendNodeDef(): Sending node definitions: size="
|
verbosestream<<"Server: Sending node definitions to id("<<peer_id
|
||||||
<<s.size()<<std::endl;
|
<<"): size="<<s.size()<<std::endl;
|
||||||
SharedBuffer<u8> data((u8*)s.c_str(), s.size());
|
SharedBuffer<u8> data((u8*)s.c_str(), s.size());
|
||||||
// Send as reliable
|
// Send as reliable
|
||||||
con.Send(peer_id, 0, data, true);
|
con.Send(peer_id, 0, data, true);
|
||||||
@ -3512,7 +3552,7 @@ void Server::SendMovePlayer(Player *player)
|
|||||||
v3f pos = player->getPosition();
|
v3f pos = player->getPosition();
|
||||||
f32 pitch = player->getPitch();
|
f32 pitch = player->getPitch();
|
||||||
f32 yaw = player->getYaw();
|
f32 yaw = player->getYaw();
|
||||||
infostream<<"Server sending TOCLIENT_MOVE_PLAYER"
|
verbosestream<<"Server: Sending TOCLIENT_MOVE_PLAYER"
|
||||||
<<" pos=("<<pos.X<<","<<pos.Y<<","<<pos.Z<<")"
|
<<" pos=("<<pos.X<<","<<pos.Y<<","<<pos.Z<<")"
|
||||||
<<" pitch="<<pitch
|
<<" pitch="<<pitch
|
||||||
<<" yaw="<<yaw
|
<<" yaw="<<yaw
|
||||||
@ -3760,10 +3800,11 @@ void Server::SendBlocks(float dtime)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::PrepareTextures() {
|
void Server::PrepareTextures()
|
||||||
|
{
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
infostream<<"Server::PrepareTextures(): Calculate sha1 sums of textures"<<std::endl;
|
infostream<<"Server: Calculating texture checksums"<<std::endl;
|
||||||
|
|
||||||
for(core::list<ModSpec>::Iterator i = m_mods.begin();
|
for(core::list<ModSpec>::Iterator i = m_mods.begin();
|
||||||
i != m_mods.end(); i++){
|
i != m_mods.end(); i++){
|
||||||
@ -3823,7 +3864,7 @@ void Server::PrepareTextures() {
|
|||||||
|
|
||||||
// Put in list
|
// Put in list
|
||||||
this->m_Textures[tname] = TextureInformation(tpath,digest_string);
|
this->m_Textures[tname] = TextureInformation(tpath,digest_string);
|
||||||
infostream<<"Server::PrepareTextures(): added sha1 for "<< tname <<std::endl;
|
verbosestream<<"Server: sha1 for "<<tname<<"\tis "<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3844,7 +3885,8 @@ struct SendableTextureAnnouncement
|
|||||||
void Server::SendTextureAnnouncement(u16 peer_id){
|
void Server::SendTextureAnnouncement(u16 peer_id){
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
infostream<<"Server::SendTextureAnnouncement()"<<std::endl;
|
verbosestream<<"Server: Announcing textures to id("<<peer_id<<")"
|
||||||
|
<<std::endl;
|
||||||
|
|
||||||
core::list<SendableTextureAnnouncement> texture_announcements;
|
core::list<SendableTextureAnnouncement> texture_announcements;
|
||||||
|
|
||||||
@ -3881,7 +3923,6 @@ void Server::SendTextureAnnouncement(u16 peer_id){
|
|||||||
|
|
||||||
// Make data buffer
|
// Make data buffer
|
||||||
std::string s = os.str();
|
std::string s = os.str();
|
||||||
infostream<<"Server::SendTextureAnnouncement(): Send to client"<<std::endl;
|
|
||||||
SharedBuffer<u8> data((u8*)s.c_str(), s.size());
|
SharedBuffer<u8> data((u8*)s.c_str(), s.size());
|
||||||
|
|
||||||
// Send as reliable
|
// Send as reliable
|
||||||
@ -3906,7 +3947,8 @@ struct SendableTexture
|
|||||||
void Server::SendTexturesRequested(u16 peer_id,core::list<TextureRequest> tosend) {
|
void Server::SendTexturesRequested(u16 peer_id,core::list<TextureRequest> tosend) {
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
infostream<<"Server::SendTexturesRequested(): Sending textures to client"<<std::endl;
|
verbosestream<<"Server::SendTexturesRequested(): "
|
||||||
|
<<"Sending textures to client"<<std::endl;
|
||||||
|
|
||||||
/* Read textures */
|
/* Read textures */
|
||||||
|
|
||||||
@ -4002,7 +4044,8 @@ void Server::SendTexturesRequested(u16 peer_id,core::list<TextureRequest> tosend
|
|||||||
|
|
||||||
// Make data buffer
|
// Make data buffer
|
||||||
std::string s = os.str();
|
std::string s = os.str();
|
||||||
infostream<<"Server::SendTexturesRequested(): bunch "<<i<<"/"<<num_bunches
|
verbosestream<<"Server::SendTexturesRequested(): bunch "
|
||||||
|
<<i<<"/"<<num_bunches
|
||||||
<<" textures="<<texture_bunches[i].size()
|
<<" textures="<<texture_bunches[i].size()
|
||||||
<<" size=" <<s.size()<<std::endl;
|
<<" size=" <<s.size()<<std::endl;
|
||||||
SharedBuffer<u8> data((u8*)s.c_str(), s.size());
|
SharedBuffer<u8> data((u8*)s.c_str(), s.size());
|
||||||
@ -4496,7 +4539,7 @@ void Server::handlePeerChanges()
|
|||||||
{
|
{
|
||||||
PeerChange c = m_peer_change_queue.pop_front();
|
PeerChange c = m_peer_change_queue.pop_front();
|
||||||
|
|
||||||
infostream<<"Server: Handling peer change: "
|
verbosestream<<"Server: Handling peer change: "
|
||||||
<<"id="<<c.peer_id<<", timeout="<<c.timeout
|
<<"id="<<c.peer_id<<", timeout="<<c.timeout
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
|
|
||||||
@ -4525,7 +4568,7 @@ void dedicated_server_loop(Server &server, bool &kill)
|
|||||||
{
|
{
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
infostream<<"dedicated_server_loop()"<<std::endl;
|
verbosestream<<"dedicated_server_loop()"<<std::endl;
|
||||||
|
|
||||||
IntervalLimiter m_profiler_interval;
|
IntervalLimiter m_profiler_interval;
|
||||||
|
|
||||||
@ -4542,7 +4585,7 @@ void dedicated_server_loop(Server &server, bool &kill)
|
|||||||
|
|
||||||
if(server.getShutdownRequested() || kill)
|
if(server.getShutdownRequested() || kill)
|
||||||
{
|
{
|
||||||
infostream<<DTIME<<" dedicated_server_loop(): Quitting."<<std::endl;
|
infostream<<"Dedicated server quitting"<<std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4560,30 +4603,6 @@ void dedicated_server_loop(Server &server, bool &kill)
|
|||||||
g_profiler->clear();
|
g_profiler->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Player info
|
|
||||||
*/
|
|
||||||
static int counter = 0;
|
|
||||||
counter--;
|
|
||||||
if(counter <= 0)
|
|
||||||
{
|
|
||||||
counter = 10;
|
|
||||||
|
|
||||||
core::list<PlayerInfo> list = server.getPlayerInfo();
|
|
||||||
core::list<PlayerInfo>::Iterator i;
|
|
||||||
static u32 sum_old = 0;
|
|
||||||
u32 sum = PIChecksum(list);
|
|
||||||
if(sum != sum_old)
|
|
||||||
{
|
|
||||||
infostream<<DTIME<<"Player info:"<<std::endl;
|
|
||||||
for(i=list.begin(); i!=list.end(); i++)
|
|
||||||
{
|
|
||||||
i->PrintLine(&infostream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sum_old = sum;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
src/server.h
21
src/server.h
@ -40,6 +40,23 @@ class IWritableItemDefManager;
|
|||||||
class IWritableNodeDefManager;
|
class IWritableNodeDefManager;
|
||||||
class IWritableCraftDefManager;
|
class IWritableCraftDefManager;
|
||||||
|
|
||||||
|
class ServerError : public std::exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ServerError(const std::string &s)
|
||||||
|
{
|
||||||
|
m_s = "ServerError: ";
|
||||||
|
m_s += s;
|
||||||
|
}
|
||||||
|
virtual ~ServerError() throw()
|
||||||
|
{}
|
||||||
|
virtual const char * what() const throw()
|
||||||
|
{
|
||||||
|
return m_s.c_str();
|
||||||
|
}
|
||||||
|
std::string m_s;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Some random functions
|
Some random functions
|
||||||
*/
|
*/
|
||||||
@ -211,8 +228,6 @@ struct PlayerInfo
|
|||||||
void PrintLine(std::ostream *s);
|
void PrintLine(std::ostream *s);
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 PIChecksum(core::list<PlayerInfo> &l);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Used for queueing and sorting block transfers in containers
|
Used for queueing and sorting block transfers in containers
|
||||||
|
|
||||||
@ -608,7 +623,7 @@ private:
|
|||||||
{
|
{
|
||||||
Player *player = m_env->getPlayer(peer_id);
|
Player *player = m_env->getPlayer(peer_id);
|
||||||
if(player == NULL)
|
if(player == NULL)
|
||||||
return "[id="+itos(peer_id);
|
return "[id="+itos(peer_id)+"]";
|
||||||
return player->getName();
|
return player->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,8 +425,6 @@ public:
|
|||||||
n = m_defaults.find(name);
|
n = m_defaults.find(name);
|
||||||
if(n == NULL)
|
if(n == NULL)
|
||||||
{
|
{
|
||||||
infostream<<"Settings: Setting not found: \""
|
|
||||||
<<name<<"\""<<std::endl;
|
|
||||||
throw SettingNotFoundException("Setting not found");
|
throw SettingNotFoundException("Setting not found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user