forked from mirror/openmw-tes3mp
Use master server address from config file
This commit is contained in:
parent
cb799ee446
commit
968546b20c
4 changed files with 44 additions and 21 deletions
|
@ -26,10 +26,10 @@ NetController *NetController::get()
|
||||||
return mThis;
|
return mThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetController::Create()
|
void NetController::Create(std::string addr, unsigned short port)
|
||||||
{
|
{
|
||||||
assert(!mThis);
|
assert(!mThis);
|
||||||
mThis = new NetController;
|
mThis = new NetController(addr, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetController::Destroy()
|
void NetController::Destroy()
|
||||||
|
@ -39,7 +39,7 @@ void NetController::Destroy()
|
||||||
mThis = nullptr;
|
mThis = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetController::NetController() : httpNetwork("127.0.0.1", 8080)
|
NetController::NetController(std::string addr, unsigned short port) : httpNetwork(addr, port)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -116,30 +116,19 @@ void NetController::downloadInfo(QAbstractItemModel *pModel, QModelIndex index)
|
||||||
model->setData(mi, PingRakNetServer(addr[0].toLatin1().data(), addr[1].toUShort()));
|
model->setData(mi, PingRakNetServer(addr[0].toLatin1().data(), addr[1].toUShort()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//qDebug() << data;
|
|
||||||
|
|
||||||
if (model->rowCount() != 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*model->insertRows(0, 6);
|
|
||||||
model->myData[0] = {"127.0.0.1:25565", 0, 20, 1, "Super Server"};
|
|
||||||
model->myData[1] = {"127.0.0.1:25565", 5, 20, 2, "Koncord's server"};
|
|
||||||
model->myData[2] = {"server.local:8888", 15, 15, 15, "tes3mp server", "custom mode"};
|
|
||||||
model->myData[3] = {"127.0.0.1:25562", 1, 2, 5, "Server"};
|
|
||||||
model->myData[4] = {"tes3mp.com:22222", 8, 9, 1000, "Antoher Server", "super duper mod"};
|
|
||||||
model->myData[5] = {"localhost:24", 1, 5, 5, "Test Server", "Another mod 0.1"};*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetController::updateInfo(QAbstractItemModel *pModel, QModelIndex index)
|
bool NetController::updateInfo(QAbstractItemModel *pModel, QModelIndex index)
|
||||||
{
|
{
|
||||||
qDebug() << "TODO: \"NetController::updateInfo(QAbstractItemModel *, QModelIndex)\" is not completed";
|
qDebug() << "TODO: \"NetController::updateInfo(QAbstractItemModel *, QModelIndex)\" is not completed";
|
||||||
ServerModel *model = ((ServerModel*)pModel);
|
ServerModel *model = ((ServerModel*)pModel);
|
||||||
|
|
||||||
|
bool result;
|
||||||
if (index.isValid() && index.row() >= 0)
|
if (index.isValid() && index.row() >= 0)
|
||||||
{
|
{
|
||||||
//ServerData &sd = model->myData[index.row()];
|
//ServerData &sd = model->myData[index.row()];
|
||||||
//qDebug() << sd.addr;
|
//qDebug() << sd.addr;
|
||||||
downloadInfo(pModel, index);
|
result = downloadInfo(pModel, index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ class NetController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static NetController *get();
|
static NetController *get();
|
||||||
static void Create();
|
static void Create(std::string addr, unsigned short port);
|
||||||
static void Destroy();
|
static void Destroy();
|
||||||
void updateInfo(QAbstractItemModel *pModel, QModelIndex index= QModelIndex());
|
void updateInfo(QAbstractItemModel *pModel, QModelIndex index= QModelIndex());
|
||||||
void updateInfo();
|
void updateInfo();
|
||||||
|
@ -25,7 +25,7 @@ public:
|
||||||
void selectServer(ServerData *pServerData);
|
void selectServer(ServerData *pServerData);
|
||||||
ServerData *selectedServer();
|
ServerData *selectedServer();
|
||||||
protected:
|
protected:
|
||||||
NetController();
|
NetController(std::string addr, unsigned short port);
|
||||||
~NetController();
|
~NetController();
|
||||||
private:
|
private:
|
||||||
NetController(const NetController &controller);
|
NetController(const NetController &controller);
|
||||||
|
|
|
@ -1,13 +1,46 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <components/settings/settings.hpp>
|
||||||
|
#include <components/files/configurationmanager.hpp>
|
||||||
#include "Main.hpp"
|
#include "Main.hpp"
|
||||||
#include "NetController.hpp"
|
#include "NetController.hpp"
|
||||||
|
|
||||||
|
std::string loadSettings (Settings::Manager & settings)
|
||||||
|
{
|
||||||
|
Files::ConfigurationManager mCfgMgr;
|
||||||
|
// Create the settings manager and load default settings file
|
||||||
|
const std::string localdefault = (mCfgMgr.getLocalPath() / "tes3mp-client-default.cfg").string();
|
||||||
|
const std::string globaldefault = (mCfgMgr.getGlobalPath() / "tes3mp-client-default.cfg").string();
|
||||||
|
|
||||||
|
// prefer local
|
||||||
|
if (boost::filesystem::exists(localdefault))
|
||||||
|
settings.loadDefault(localdefault);
|
||||||
|
else if (boost::filesystem::exists(globaldefault))
|
||||||
|
settings.loadDefault(globaldefault);
|
||||||
|
else
|
||||||
|
throw std::runtime_error ("No default settings file found! Make sure the file \"tes3mp-client-default.cfg\" was properly installed.");
|
||||||
|
|
||||||
|
// load user settings if they exist
|
||||||
|
const std::string settingspath = (mCfgMgr.getUserConfigPath() / "tes3mp-client.cfg").string();
|
||||||
|
if (boost::filesystem::exists(settingspath))
|
||||||
|
settings.loadUser(settingspath);
|
||||||
|
|
||||||
|
return settingspath;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
Settings::Manager mgr;
|
||||||
|
Files::ConfigurationManager cfgMgr;
|
||||||
|
|
||||||
|
loadSettings(mgr);
|
||||||
|
|
||||||
|
std::string addr = mgr.getString("address", "Master");
|
||||||
|
int port = mgr.getInt("port", "Master");
|
||||||
|
|
||||||
// initialize resources, if needed
|
// initialize resources, if needed
|
||||||
// Q_INIT_RESOURCE(resfile);
|
// Q_INIT_RESOURCE(resfile);
|
||||||
|
|
||||||
NetController::Create();
|
NetController::Create(addr, port);
|
||||||
atexit(NetController::Destroy);
|
atexit(NetController::Destroy);
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
Main d;
|
Main d;
|
||||||
|
|
|
@ -6,7 +6,8 @@ port = 25565
|
||||||
loglevel = 0
|
loglevel = 0
|
||||||
|
|
||||||
[Master]
|
[Master]
|
||||||
address = master.tes3mp.com:8080
|
address = master.tes3mp.com
|
||||||
|
port = 8080
|
||||||
|
|
||||||
[Chat]
|
[Chat]
|
||||||
# Use https://wiki.libsdl.org/SDL_Keycode for rebinding keys
|
# Use https://wiki.libsdl.org/SDL_Keycode for rebinding keys
|
||||||
|
|
Loading…
Reference in a new issue