feat: add JSON support for serverPort and hostPort

This commit is contained in:
2025-12-28 16:56:37 +08:00
parent 19698996cd
commit e366d47790
4 changed files with 9 additions and 6 deletions

View File

@@ -81,7 +81,8 @@ struct Viewport {
};
struct NetworkConfig {
int port = 12345;
int serverPort = 12345;
int hostPort = 12345;
int maxPlayers = 2;
std::string serverIP = "127.0.0.1";
};

View File

@@ -37,7 +37,8 @@ static void loadNetwork(const json& j, NetworkConfig& network) {
std::cout << "Unkonw key " << key << "\n";
}
};
get("port", network.port);
get("server_port", network.serverPort);
get("host_port", network.hostPort);
get("max_players", network.maxPlayers);
get("server_ip", network.serverIP);
}