diff options
author | Treeki <treeki@gmail.com> | 2014-01-28 00:08:33 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2014-01-28 00:08:33 +0100 |
commit | b95ed984f8bd2fe413d53d4b8677fe3d04bc1ad9 (patch) | |
tree | 5da2f4d891215fb709f7165644fd4a0c92f1aefd /bouncer/netcore.cpp | |
parent | 277c08cbc35f4cb2b72f1b00ab3e5f8efd2f8fb2 (diff) | |
download | bounce4-b95ed984f8bd2fe413d53d4b8677fe3d04bc1ad9.tar.gz bounce4-b95ed984f8bd2fe413d53d4b8677fe3d04bc1ad9.zip |
implement server configuration loading/saving
Diffstat (limited to 'bouncer/netcore.cpp')
-rw-r--r-- | bouncer/netcore.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/bouncer/netcore.cpp b/bouncer/netcore.cpp index dee6ef7..0dd929f 100644 --- a/bouncer/netcore.cpp +++ b/bouncer/netcore.cpp @@ -1,4 +1,5 @@ #include "core.h" +#include "ini.h" NetCore::NetCore() { @@ -321,10 +322,49 @@ void NetCore::sendToClients(Packet::Type type, const Buffer &data) { + +void NetCore::loadConfig() { + auto sections = INI::load("config.ini"); + + for (auto §ion : sections) { + if (section.title == "Server" && serverCount < SERVER_LIMIT) { + Server *s = constructServer(section.data["type"].c_str()); + if (s) { + s->loadFromConfig(section.data); + registerServer(s); + } + } + } +} + +void NetCore::saveConfig() { + std::list<INI::Section> sections; + + for (int i = 0; i < serverCount; i++) { + INI::Section section; + section.title = "Server"; + + servers[i]->saveToConfig(section.data); + + sections.push_back(section); + } + + INI::save("config.ini", sections); +} + + + + Client *Bouncer::constructClient() { return new MobileClient(this); } +Server *Bouncer::constructServer(const char *type) { + if (strcmp(type, "IRCServer") == 0) + return new IRCServer(this); + + return 0; +} |