std::string password,
std::string address,
u16 port,
- std::wstring &error_message
+ std::wstring &error_message,
+ std::string configpath
)
{
video::IVideoDriver* driver = device->getVideoDriver();
if(address == ""){
draw_load_screen(L"Creating server...", driver, font);
std::cout<<DTIME<<"Creating server"<<std::endl;
- server = new Server(map_dir);
+ server = new Server(map_dir, configpath);
server->start(port);
}
std::string password,
std::string address,
u16 port,
- std::wstring &error_message
+ std::wstring &error_message,
+ std::string configpath
);
#endif
g_timegetter = new SimpleTimeGetter();
// Create server
- Server server(map_dir.c_str());
+ Server server(map_dir.c_str(), configpath);
server.start(port);
// Run server
password,
address,
port,
- error_message
+ error_message,
+ configpath
);
} //try
*/
Server::Server(
- std::string mapsavedir
+ std::string mapsavedir,
+ std::string configpath
):
m_env(new ServerMap(mapsavedir), this),
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this),
m_time_of_day_send_timer(0),
m_uptime(0),
m_mapsavedir(mapsavedir),
+ m_configpath(configpath),
m_shutdown_requested(false),
m_ignore_map_edit_events(false),
m_ignore_map_edit_events_peer_id(0)
message = message.substr(commandprefix.size());
WStrfnd f1(message);
- f1.next(L" ");
+ f1.next(L" "); // Skip over /#whatever
std::wstring paramstring = f1.next(L"");
ServerCommandContext *ctx = new ServerCommandContext(
}
os<<L"}";
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") != "")
- 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();
}
*/
Server(
- std::string mapsavedir
+ std::string mapsavedir,
+ std::string configpath
);
~Server();
void start(unsigned short port);
dstream<<"WARNING: Auth not found for "<<name<<std::endl;
}
}
+
+ // Saves g_settings to configpath given at initialization
+ void saveConfig()
+ {
+ if(m_configpath != "")
+ g_settings.updateConfigFile(m_configpath.c_str());
+ }
private:
// Map directory
std::string m_mapsavedir;
+ // Configuration path ("" = no configuration file)
+ std::string m_configpath;
+
bool m_shutdown_requested;
/*
return;
}
- std::string confline = wide_to_narrow(
- ctx->parms[1] + L" = " + ctx->paramstring);
+ /*std::string confline = wide_to_narrow(
+ ctx->parms[1] + L" = " + ctx->params[2]);*/
+
+ std::string confline = wide_to_narrow(ctx->paramstring);
+
g_settings.parseConfigLine(confline);
- os<< L"-!- Setting changed.";
+
+ ctx->server->saveConfig();
+
+ os<< L"-!- Setting changed and configuration saved.";
}
void cmd_teleport(std::wostringstream &os,
map_dir = g_settings.get("map-dir");
// Create server
- Server server(map_dir.c_str());
+ Server server(map_dir.c_str(), configpath);
server.start(port);
// Run server