forked from Mirrorlandia_minetest/minetest
Server configuration is now written when "/#setting whatever = whatever" is issued.
This commit is contained in:
parent
9b294ffa7a
commit
cdadbdbd17
@ -715,7 +715,8 @@ void the_game(
|
|||||||
std::string password,
|
std::string password,
|
||||||
std::string address,
|
std::string address,
|
||||||
u16 port,
|
u16 port,
|
||||||
std::wstring &error_message
|
std::wstring &error_message,
|
||||||
|
std::string configpath
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
video::IVideoDriver* driver = device->getVideoDriver();
|
video::IVideoDriver* driver = device->getVideoDriver();
|
||||||
@ -755,7 +756,7 @@ void the_game(
|
|||||||
if(address == ""){
|
if(address == ""){
|
||||||
draw_load_screen(L"Creating server...", driver, font);
|
draw_load_screen(L"Creating server...", driver, font);
|
||||||
std::cout<<DTIME<<"Creating server"<<std::endl;
|
std::cout<<DTIME<<"Creating server"<<std::endl;
|
||||||
server = new Server(map_dir);
|
server = new Server(map_dir, configpath);
|
||||||
server->start(port);
|
server->start(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,8 @@ void the_game(
|
|||||||
std::string password,
|
std::string password,
|
||||||
std::string address,
|
std::string address,
|
||||||
u16 port,
|
u16 port,
|
||||||
std::wstring &error_message
|
std::wstring &error_message,
|
||||||
|
std::string configpath
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1302,7 +1302,7 @@ int main(int argc, char *argv[])
|
|||||||
g_timegetter = new SimpleTimeGetter();
|
g_timegetter = new SimpleTimeGetter();
|
||||||
|
|
||||||
// Create server
|
// Create server
|
||||||
Server server(map_dir.c_str());
|
Server server(map_dir.c_str(), configpath);
|
||||||
server.start(port);
|
server.start(port);
|
||||||
|
|
||||||
// Run server
|
// Run server
|
||||||
@ -1641,7 +1641,8 @@ int main(int argc, char *argv[])
|
|||||||
password,
|
password,
|
||||||
address,
|
address,
|
||||||
port,
|
port,
|
||||||
error_message
|
error_message,
|
||||||
|
configpath
|
||||||
);
|
);
|
||||||
|
|
||||||
} //try
|
} //try
|
||||||
|
@ -1058,7 +1058,8 @@ u32 PIChecksum(core::list<PlayerInfo> &l)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Server::Server(
|
Server::Server(
|
||||||
std::string mapsavedir
|
std::string mapsavedir,
|
||||||
|
std::string configpath
|
||||||
):
|
):
|
||||||
m_env(new ServerMap(mapsavedir), this),
|
m_env(new ServerMap(mapsavedir), this),
|
||||||
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this),
|
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this),
|
||||||
@ -1069,6 +1070,7 @@ Server::Server(
|
|||||||
m_time_of_day_send_timer(0),
|
m_time_of_day_send_timer(0),
|
||||||
m_uptime(0),
|
m_uptime(0),
|
||||||
m_mapsavedir(mapsavedir),
|
m_mapsavedir(mapsavedir),
|
||||||
|
m_configpath(configpath),
|
||||||
m_shutdown_requested(false),
|
m_shutdown_requested(false),
|
||||||
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)
|
||||||
@ -3198,7 +3200,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||||||
message = message.substr(commandprefix.size());
|
message = message.substr(commandprefix.size());
|
||||||
|
|
||||||
WStrfnd f1(message);
|
WStrfnd f1(message);
|
||||||
f1.next(L" ");
|
f1.next(L" "); // Skip over /#whatever
|
||||||
std::wstring paramstring = f1.next(L"");
|
std::wstring paramstring = f1.next(L"");
|
||||||
|
|
||||||
ServerCommandContext *ctx = new ServerCommandContext(
|
ServerCommandContext *ctx = new ServerCommandContext(
|
||||||
@ -4023,9 +4025,9 @@ std::wstring Server::getStatusString()
|
|||||||
}
|
}
|
||||||
os<<L"}";
|
os<<L"}";
|
||||||
if(((ServerMap*)(&m_env.getMap()))->isSavingEnabled() == false)
|
if(((ServerMap*)(&m_env.getMap()))->isSavingEnabled() == false)
|
||||||
os<<std::endl<<" WARNING: Map saving is disabled.";
|
os<<std::endl<<L"# Server: "<<" WARNING: Map saving is disabled.";
|
||||||
if(g_settings.get("motd") != "")
|
if(g_settings.get("motd") != "")
|
||||||
os<<std::endl<<narrow_to_wide(g_settings.get("motd"));
|
os<<std::endl<<L"# Server: "<<narrow_to_wide(g_settings.get("motd"));
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
src/server.h
13
src/server.h
@ -364,7 +364,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Server(
|
Server(
|
||||||
std::string mapsavedir
|
std::string mapsavedir,
|
||||||
|
std::string configpath
|
||||||
);
|
);
|
||||||
~Server();
|
~Server();
|
||||||
void start(unsigned short port);
|
void start(unsigned short port);
|
||||||
@ -444,6 +445,13 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Saves g_settings to configpath given at initialization
|
||||||
|
void saveConfig()
|
||||||
|
{
|
||||||
|
if(m_configpath != "")
|
||||||
|
g_settings.updateConfigFile(m_configpath.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// con::PeerHandler implementation.
|
// con::PeerHandler implementation.
|
||||||
@ -606,6 +614,9 @@ private:
|
|||||||
// Map directory
|
// Map directory
|
||||||
std::string m_mapsavedir;
|
std::string m_mapsavedir;
|
||||||
|
|
||||||
|
// Configuration path ("" = no configuration file)
|
||||||
|
std::string m_configpath;
|
||||||
|
|
||||||
bool m_shutdown_requested;
|
bool m_shutdown_requested;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -142,10 +142,16 @@ void cmd_setting(std::wostringstream &os,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string confline = wide_to_narrow(
|
/*std::string confline = wide_to_narrow(
|
||||||
ctx->parms[1] + L" = " + ctx->paramstring);
|
ctx->parms[1] + L" = " + ctx->params[2]);*/
|
||||||
|
|
||||||
|
std::string confline = wide_to_narrow(ctx->paramstring);
|
||||||
|
|
||||||
g_settings.parseConfigLine(confline);
|
g_settings.parseConfigLine(confline);
|
||||||
os<< L"-!- Setting changed.";
|
|
||||||
|
ctx->server->saveConfig();
|
||||||
|
|
||||||
|
os<< L"-!- Setting changed and configuration saved.";
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_teleport(std::wostringstream &os,
|
void cmd_teleport(std::wostringstream &os,
|
||||||
|
@ -323,7 +323,7 @@ int main(int argc, char *argv[])
|
|||||||
map_dir = g_settings.get("map-dir");
|
map_dir = g_settings.get("map-dir");
|
||||||
|
|
||||||
// Create server
|
// Create server
|
||||||
Server server(map_dir.c_str());
|
Server server(map_dir.c_str(), configpath);
|
||||||
server.start(port);
|
server.start(port);
|
||||||
|
|
||||||
// Run server
|
// Run server
|
||||||
|
Loading…
Reference in New Issue
Block a user