This commit is contained in:
MarcEricMartel 2023-06-10 14:25:42 -04:00
parent d7328fe437
commit 213d22d925
3 changed files with 34 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -98,10 +98,7 @@ public partial class start_game_menu : Control
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public override void _Process(double delta){}
private void startSingleGame() {
@ -110,10 +107,38 @@ public partial class start_game_menu : Control
}
private void startLANMultiGame(bool isHost = true) {
const string ERR = "Invalid IP address.";
if (isHost) {
ENetMultiplayerPeer peer = new ENetMultiplayerPeer ();
peer.CreateServer(666, 2);
Multiplayer.MultiplayerPeer = peer;
}
else {
string ip = _ip.Get("text").ToString();
if (!ip.Contains('.')) {
Error = ERR;
return;
}
private void selectLANMultiGame() {
Error = "lanmulti";
string[] ips = ip.Split('.');
if (ips.Length != 4) {
Error = ERR;
return;
}
for (int x =0; x < 4; ++x) {
int val = 0;
if (!int.TryParse(ips[0], out val) || val < 0 || val > 255) {
Error = ERR;
return;
}
}
ENetMultiplayerPeer peer = new ENetMultiplayerPeer ();
peer.CreateClient(ip, 666);
Multiplayer.MultiplayerPeer = peer;
}
}
}