Merge branch 'antsif-a-port-field'

This commit is contained in:
Anuken 2025-02-08 23:35:23 -05:00
commit aba9041fce
5 changed files with 32 additions and 10 deletions

View File

@ -232,7 +232,7 @@ server.kicked.customClient = This server does not support custom builds. Downloa
server.kicked.gameover = Game over!
server.kicked.serverRestarting = The server is restarting.
server.versions = Your version:[accent] {0}[]\nServer version:[accent] {1}[]
host.info = The [accent]host[] button hosts a server on port [scarlet]6567[]. \nAnybody on the same [lightgray]wifi or local network[] should be able to see your server in their server list.\n\nIf you want people to be able to connect from anywhere by IP, [accent]port forwarding[] is required.\n\n[lightgray]Note: If someone is experiencing trouble connecting to your LAN game, make sure you have allowed Mindustry access to your local network in your firewall settings. Note that public networks sometimes do not allow server discovery.
host.info = The [accent]host[] button hosts a server on the specified port.\nAnybody on the same [lightgray]wifi or local network[] should be able to see your server in their server list.\n\nIf you want people to be able to connect from anywhere by IP, [accent]port forwarding[] is required.\n\n[lightgray]Note: If someone is experiencing trouble connecting to your LAN game, make sure you have allowed Mindustry access to your local network in your firewall settings. Note that public networks sometimes do not allow server discovery.
join.info = Here, you can enter a [accent]server IP[] to connect to, or discover [accent]local network[] or [accent]global[] servers to connect to.\nBoth LAN and WAN multiplayer is supported.\n\n[lightgray]If you want to connect to someone by IP, you would need to ask the host for their IP, which can be found by googling "my ip" from their device.
hostserver = Host Multiplayer Game
invitefriends = Invite Friends

View File

@ -229,7 +229,7 @@ server.kicked.customClient = Этот сервер не поддерживает
server.kicked.gameover = Игра окончена!
server.kicked.serverRestarting = Сервер перезапускается.
server.versions = Ваша версия:[accent] {0}[]\nВерсия сервера:[accent] {1}[]
host.info = Кнопка [accent]Открыть сервер[] запускает сервер на порте [scarlet]6567[].\nЛюбой пользователь в той же [lightgray]локальной сети или WiFi[] должен увидеть ваш сервер в своём списке серверов.\n\nЕсли вы хотите, чтобы люди могли подключаться откуда угодно по IP, то требуется [accent]переадресация (проброс) портов[] и наличие [red]ВНЕШНЕГО[] WAN адреса (WAN адрес [red]НЕ должен[] начинаться с [red]10[][lightgray].x.x.x[], [red]100.64[][lightgray].x.x[], [red]172.16[][lightgray].x.x[], [red]192.168[][lightgray].x.x[], [red]127[][lightgray].x.x.x[])!\nКлиентам мобильных операторов нужно уточнять информацию в личном кабинете на сайте вашего оператора!\n\n[lightgray]Примечание: Если у кого-то возникают проблемы с подключением к вашей игре по локальной сети, убедитесь, что вы разрешили доступ Mindustry к вашей локальной сети в настройках брандмауэра. Обратите внимание, что публичные сети иногда не позволяют обнаружение сервера.
host.info = Кнопка [accent]Открыть сервер[] запускает сервер на указанном порте.\nЛюбой пользователь в той же [lightgray]локальной сети или WiFi[] должен увидеть ваш сервер в своём списке серверов.\n\nЕсли вы хотите, чтобы люди могли подключаться откуда угодно по IP, то требуется [accent]переадресация (проброс) портов[] и наличие [red]ВНЕШНЕГО[] WAN адреса (WAN адрес [red]НЕ должен[] начинаться с [red]10[][lightgray].x.x.x[], [red]100.64[][lightgray].x.x[], [red]172.16[][lightgray].x.x[], [red]192.168[][lightgray].x.x[], [red]127[][lightgray].x.x.x[])!\nКлиентам мобильных операторов нужно уточнять информацию в личном кабинете на сайте вашего оператора!\n\n[lightgray]Примечание: Если у кого-то возникают проблемы с подключением к вашей игре по локальной сети, убедитесь, что вы разрешили доступ Mindustry к вашей локальной сети в настройках брандмауэра. Обратите внимание, что публичные сети иногда не позволяют обнаружение сервера.
join.info = Здесь вы можете ввести [accent]IP-адрес сервера[], найти доступные [accent]локальные[] и [accent]глобальные[] серверы для подключения.\nПоддерживаются оба многопользовательских режима: LAN и WAN.\n\n[lightgray]Если вы хотите подключиться к кому-то по IP-адресу, Вам нужно будет попросить IP-адрес у самого хоста. Хост может узнать IP-адрес своего устройства через Google запрос [accent]"my ip"[].
hostserver = Запустить многопользовательский сервер
invitefriends = Пригласить друзей

View File

@ -14,20 +14,25 @@ public class Host{
public final String versionType;
public final Gamemode mode;
public final @Nullable String modeName;
public int ping, port = Vars.port;
public int ping, port;
public Host(int ping, String name, String address, String mapname, int wave, int players, int version, String versionType, Gamemode mode, int playerLimit, String description, String modeName){
public Host(int ping, String name, String address, int port, String mapname, int wave, int players, int version, String versionType, Gamemode mode, int playerLimit, String description, String modeName){
this.ping = ping;
this.name = name;
this.address = address;
this.players = players;
this.port = port;
this.mapname = mapname;
this.wave = wave;
this.players = players;
this.version = version;
this.versionType = versionType;
this.playerLimit = playerLimit;
this.mode = mode;
this.playerLimit = playerLimit;
this.description = description;
this.modeName = modeName;
}
public Host(int ping, String name, String address, String mapname, int wave, int players, int version, String versionType, Gamemode mode, int playerLimit, String description, String modeName){
this(ping, name, address, Vars.port, mapname, wave, players, version, versionType, mode, playerLimit, description, modeName);
}
}

View File

@ -3,6 +3,8 @@ package mindustry.net;
import arc.*;
import arc.util.*;
import arc.util.io.*;
import mindustry.*;
import mindustry.content.*;
import mindustry.core.*;
import mindustry.ctype.*;
import mindustry.game.*;
@ -111,6 +113,7 @@ public class NetworkIO{
buffer.put((byte)state.rules.mode().ordinal());
buffer.putInt(netServer.admins.getPlayerLimit());
buffer.putInt(Core.settings.getInt("port", port));
writeString(buffer, description, 100);
if(state.rules.modeName != null){
@ -130,8 +133,10 @@ public class NetworkIO{
int limit = buffer.getInt();
String description = readString(buffer);
String modeName = readString(buffer);
int hostPort = buffer.getInt();
hostPort = hostPort != 0 ? hostPort : Vars.port;
return new Host(ping, host, hostAddress, map, wave, players, version, vertype, gamemode, limit, description, modeName.isEmpty() ? null : modeName);
return new Host(ping, host, hostAddress, hostPort, map, wave, players, version, vertype, gamemode, limit, description, modeName.isEmpty() ? null : modeName);
}
private static void writeString(ByteBuffer buffer, String string, int maxlen){

View File

@ -3,7 +3,6 @@ package mindustry.ui.dialogs;
import arc.*;
import arc.scene.ui.*;
import arc.util.*;
import mindustry.*;
import mindustry.core.*;
import mindustry.game.EventType.*;
import mindustry.gen.*;
@ -49,6 +48,19 @@ public class HostDialog extends BaseDialog{
cont.row();
TextField[] portField = {null};
cont.table(t -> {
t.add("@server.port").padRight(10);
portField[0] = t.field(String.valueOf(Core.settings.getInt("port", port)), text -> Core.settings.put("port", Strings.parseInt(text, 6567)))
.pad(8).grow().maxTextLength(5).valid(text -> {
int port = Strings.parseInt(text);
return port >= 1 && port <= 65535;
}).get();
}).width(w).height(70f).pad(4).colspan(3);
cont.row();
cont.add().width(65f);
cont.button("@host", () -> {
@ -58,7 +70,7 @@ public class HostDialog extends BaseDialog{
}
runHost();
}).width(w).height(70f);
}).width(w).height(70f).disabled(b -> !portField[0].isValid());
if(!steam){
cont.button("?", () -> ui.showInfo("@host.info")).size(65f, 70f).padLeft(6f);
@ -77,7 +89,7 @@ public class HostDialog extends BaseDialog{
ui.loadfrag.show("@hosting");
Time.runTask(5f, () -> {
try{
net.host(Vars.port);
net.host(Core.settings.getInt("port", port));
player.admin = true;
Events.fire(new HostEvent());