mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-05-02 02:23:56 +00:00
Add configurable room name, fix parameter naming in multiplayer extension
Read "multiplayer:room" from INI options (default "default") and use it in Connect() instead of a hardcoded string. Return early if room is blank, matching the relay URL check. Rename p_mgr to p_networkManager for consistency.
This commit is contained in:
parent
dac40932a6
commit
762a5f3941
@ -21,6 +21,7 @@ void Emscripten_SetupDefaultConfigOverrides(dictionary* p_dictionary)
|
||||
iniparser_set(p_dictionary, "extensions:multiplayer", "true");
|
||||
iniparser_set(p_dictionary, "multiplayer", NULL);
|
||||
iniparser_set(p_dictionary, "multiplayer:relay url", "ws://localhost:8787");
|
||||
iniparser_set(p_dictionary, "multiplayer:room", "default");
|
||||
|
||||
// Emscripten-only for now
|
||||
Emscripten_SetScaleAspect(iniparser_getboolean(p_dictionary, "isle:Original Aspect Ratio", true));
|
||||
|
||||
@ -31,8 +31,9 @@ class MultiplayerExt {
|
||||
static bool enabled;
|
||||
|
||||
static std::string relayUrl;
|
||||
static std::string room;
|
||||
|
||||
static void SetNetworkManager(Multiplayer::NetworkManager* p_mgr);
|
||||
static void SetNetworkManager(Multiplayer::NetworkManager* p_networkManager);
|
||||
static Multiplayer::NetworkManager* GetNetworkManager();
|
||||
|
||||
private:
|
||||
|
||||
@ -16,14 +16,16 @@ using namespace Extensions;
|
||||
std::map<std::string, std::string> MultiplayerExt::options;
|
||||
bool MultiplayerExt::enabled = false;
|
||||
std::string MultiplayerExt::relayUrl;
|
||||
std::string MultiplayerExt::room;
|
||||
Multiplayer::NetworkManager* MultiplayerExt::s_networkManager = nullptr;
|
||||
Multiplayer::NetworkTransport* MultiplayerExt::s_transport = nullptr;
|
||||
|
||||
void MultiplayerExt::Initialize()
|
||||
{
|
||||
relayUrl = options["multiplayer:relay url"];
|
||||
room = options["multiplayer:room"];
|
||||
|
||||
if (relayUrl.empty()) {
|
||||
if (relayUrl.empty() || room.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -33,7 +35,7 @@ void MultiplayerExt::Initialize()
|
||||
s_networkManager = new Multiplayer::NetworkManager();
|
||||
s_networkManager->Initialize(s_transport);
|
||||
|
||||
s_networkManager->Connect("default");
|
||||
s_networkManager->Connect(room.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -98,9 +100,9 @@ MxBool MultiplayerExt::HandleEntityNotify(LegoEntity* p_entity)
|
||||
return s_networkManager->HandleEntityMutation(p_entity, changeType);
|
||||
}
|
||||
|
||||
void MultiplayerExt::SetNetworkManager(Multiplayer::NetworkManager* p_mgr)
|
||||
void MultiplayerExt::SetNetworkManager(Multiplayer::NetworkManager* p_networkManager)
|
||||
{
|
||||
s_networkManager = p_mgr;
|
||||
s_networkManager = p_networkManager;
|
||||
}
|
||||
|
||||
Multiplayer::NetworkManager* MultiplayerExt::GetNetworkManager()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user