mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
WIP: add master_ip option
This commit is contained in:
parent
51a9f61e88
commit
7f1e392be2
@ -157,10 +157,16 @@ int main(int argc, char** argv) {
|
|||||||
auto* masterLookupStatement = Database::CreatePreppedStmt("SELECT id FROM `servers` WHERE `name` = 'master'");
|
auto* masterLookupStatement = Database::CreatePreppedStmt("SELECT id FROM `servers` WHERE `name` = 'master'");
|
||||||
auto* result = masterLookupStatement->executeQuery();
|
auto* result = masterLookupStatement->executeQuery();
|
||||||
|
|
||||||
|
auto master_server_ip = config.GetValue("master_ip");
|
||||||
|
|
||||||
|
if (master_server_ip == "") {
|
||||||
|
master_server_ip = Game::server->GetIP();
|
||||||
|
}
|
||||||
|
|
||||||
//If we found a server, update it's IP and port to the current one.
|
//If we found a server, update it's IP and port to the current one.
|
||||||
if (result->next()) {
|
if (result->next()) {
|
||||||
auto* updateStatement = Database::CreatePreppedStmt("UPDATE `servers` SET `ip` = ?, `port` = ? WHERE `id` = ?");
|
auto* updateStatement = Database::CreatePreppedStmt("UPDATE `servers` SET `ip` = ?, `port` = ? WHERE `id` = ?");
|
||||||
updateStatement->setString(1, Game::server->GetIP());
|
updateStatement->setString(1, master_server_ip);
|
||||||
updateStatement->setInt(2, Game::server->GetPort());
|
updateStatement->setInt(2, Game::server->GetPort());
|
||||||
updateStatement->setInt(3, result->getInt("id"));
|
updateStatement->setInt(3, result->getInt("id"));
|
||||||
updateStatement->execute();
|
updateStatement->execute();
|
||||||
@ -169,7 +175,7 @@ int main(int argc, char** argv) {
|
|||||||
else {
|
else {
|
||||||
//If we didn't find a server, create one.
|
//If we didn't find a server, create one.
|
||||||
auto* insertStatement = Database::CreatePreppedStmt("INSERT INTO `servers` (`name`, `ip`, `port`, `state`, `version`) VALUES ('master', ?, ?, 0, 171023)");
|
auto* insertStatement = Database::CreatePreppedStmt("INSERT INTO `servers` (`name`, `ip`, `port`, `state`, `version`) VALUES ('master', ?, ?, 0, 171023)");
|
||||||
insertStatement->setString(1, Game::server->GetIP());
|
insertStatement->setString(1, master_server_ip);
|
||||||
insertStatement->setInt(2, Game::server->GetPort());
|
insertStatement->setInt(2, Game::server->GetPort());
|
||||||
insertStatement->execute();
|
insertStatement->execute();
|
||||||
delete insertStatement;
|
delete insertStatement;
|
||||||
|
@ -30,8 +30,10 @@ services:
|
|||||||
- database:/var/lib/mysql
|
- database:/var/lib/mysql
|
||||||
networks:
|
networks:
|
||||||
- darkflame
|
- darkflame
|
||||||
ports:
|
# (optional) ports only exposed so that DB management tools can connect
|
||||||
- 3306:3306 # (optional) ports only exposed so that DB management tools can connect
|
# Remove the # of the next two lines to expose your database
|
||||||
|
# ports:
|
||||||
|
# - 3306:3306
|
||||||
|
|
||||||
darkflame:
|
darkflame:
|
||||||
container_name: DarkflameServer
|
container_name: DarkflameServer
|
||||||
|
@ -31,6 +31,9 @@ function update_ini_values() {
|
|||||||
update_ini worldconfig.ini chat_server_port $CHAT_SERVER_PORT
|
update_ini worldconfig.ini chat_server_port $CHAT_SERVER_PORT
|
||||||
update_ini worldconfig.ini max_clients $MAX_CLIENTS
|
update_ini worldconfig.ini max_clients $MAX_CLIENTS
|
||||||
|
|
||||||
|
# always use the internal docker hostname
|
||||||
|
update_ini masterconfig.ini master_ip "darkflame"
|
||||||
|
|
||||||
update_database_ini_values_for masterconfig.ini
|
update_database_ini_values_for masterconfig.ini
|
||||||
update_database_ini_values_for authconfig.ini
|
update_database_ini_values_for authconfig.ini
|
||||||
update_database_ini_values_for chatconfig.ini
|
update_database_ini_values_for chatconfig.ini
|
||||||
|
@ -7,6 +7,9 @@ mysql_password=
|
|||||||
# The public facing IP address. Can be 'localhost' for locally hosted servers
|
# The public facing IP address. Can be 'localhost' for locally hosted servers
|
||||||
external_ip=localhost
|
external_ip=localhost
|
||||||
|
|
||||||
|
# The internal ip of the master server
|
||||||
|
master_ip=localhost
|
||||||
|
|
||||||
# Port number
|
# Port number
|
||||||
port=2000
|
port=2000
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user