mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-28 13:47:32 +07:00
Optional custom displayed gamemode
This commit is contained in:
@ -92,6 +92,8 @@ public class Rules{
|
||||
public Team defaultTeam = Team.sharded;
|
||||
/** team of the enemy in waves/sectors */
|
||||
public Team waveTeam = Team.crux;
|
||||
/** name of the custom mode that this ruleset describes, or null. */
|
||||
public @Nullable String modeName;
|
||||
/** special tags for additional info */
|
||||
public StringMap tags = new StringMap();
|
||||
|
||||
|
@ -562,23 +562,5 @@ public class LExecutor{
|
||||
}
|
||||
}
|
||||
|
||||
public static class GetBuildI implements LInstruction{
|
||||
public int dest;
|
||||
public int x, y;
|
||||
|
||||
public GetBuildI(int dest, int x, int y){
|
||||
this.dest = dest;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
GetBuildI(){}
|
||||
|
||||
@Override
|
||||
public void run(LExecutor exec){
|
||||
exec.setobj(dest, Vars.world.build(exec.numi(x), exec.numi(y)));
|
||||
}
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class LStatements{
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("read")
|
||||
@RegisterStatement("getlink")
|
||||
public static class GetLinkStatement extends LStatement{
|
||||
public String output = "result", address = "0";
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mindustry.net;
|
||||
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.*;
|
||||
import mindustry.game.*;
|
||||
|
||||
@ -12,9 +13,10 @@ public class Host{
|
||||
public final int version;
|
||||
public final String versionType;
|
||||
public final Gamemode mode;
|
||||
public final @Nullable String modeName;
|
||||
public int ping, port = Vars.port;
|
||||
|
||||
public Host(String name, String address, String mapname, int wave, int players, int version, String versionType, Gamemode mode, int playerLimit, String description){
|
||||
public Host(String name, String address, String mapname, int wave, int players, int version, String versionType, Gamemode mode, int playerLimit, String description, String modeName){
|
||||
this.name = name;
|
||||
this.address = address;
|
||||
this.players = players;
|
||||
@ -25,5 +27,6 @@ public class Host{
|
||||
this.playerLimit = playerLimit;
|
||||
this.mode = mode;
|
||||
this.description = description;
|
||||
this.modeName = modeName;
|
||||
}
|
||||
}
|
||||
|
@ -68,10 +68,10 @@ public class NetworkIO{
|
||||
String description = headless && !Config.desc.string().equals("off") ? Config.desc.string() : "";
|
||||
String map = state.map.name();
|
||||
|
||||
ByteBuffer buffer = ByteBuffer.allocate(512);
|
||||
ByteBuffer buffer = ByteBuffer.allocate(500);
|
||||
|
||||
writeString(buffer, name, 100);
|
||||
writeString(buffer, map);
|
||||
writeString(buffer, map, 64);
|
||||
|
||||
buffer.putInt(Core.settings.getInt("totalPlayers", Groups.player.size()));
|
||||
buffer.putInt(state.wave);
|
||||
@ -82,6 +82,9 @@ public class NetworkIO{
|
||||
buffer.putInt(netServer.admins.getPlayerLimit());
|
||||
|
||||
writeString(buffer, description, 100);
|
||||
if(state.rules.modeName != null){
|
||||
writeString(buffer, state.rules.modeName, 50);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@ -95,8 +98,9 @@ public class NetworkIO{
|
||||
Gamemode gamemode = Gamemode.all[buffer.get()];
|
||||
int limit = buffer.getInt();
|
||||
String description = readString(buffer);
|
||||
String modeName = readString(buffer);
|
||||
|
||||
return new Host(host, hostAddress, map, wave, players, version, vertype, gamemode, limit, description);
|
||||
return new Host(host, hostAddress, map, wave, players, version, vertype, gamemode, limit, description, modeName.isEmpty() ? null : modeName);
|
||||
}
|
||||
|
||||
private static void writeString(ByteBuffer buffer, String string, int maxlen){
|
||||
|
@ -230,7 +230,7 @@ public class JoinDialog extends BaseDialog{
|
||||
}
|
||||
t.add("[lightgray]" + (Core.bundle.format("players" + (host.players == 1 && host.playerLimit <= 0 ? ".single" : ""), (host.players == 0 ? "[lightgray]" : "[accent]") + host.players + (host.playerLimit > 0 ? "[lightgray]/[accent]" + host.playerLimit : "")+ "[lightgray]"))).left();
|
||||
t.row();
|
||||
t.add("[lightgray]" + Core.bundle.format("save.map", host.mapname) + "[lightgray] / " + host.mode.toString()).width(targetWidth() - 10f).left().get().setEllipsis(true);
|
||||
t.add("[lightgray]" + Core.bundle.format("save.map", host.mapname) + "[lightgray] / " + (host.modeName == null ? host.mode.toString() : host.modeName)).width(targetWidth() - 10f).left().get().setEllipsis(true);
|
||||
}).expand().left().bottom().padLeft(12f).padBottom(8);
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,8 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
||||
smat.getLobbyData(lobby, "versionType"),
|
||||
Gamemode.valueOf(smat.getLobbyData(lobby, "gamemode")),
|
||||
smat.getLobbyMemberLimit(lobby),
|
||||
""
|
||||
"",
|
||||
null
|
||||
);
|
||||
hosts.add(out);
|
||||
}catch(Exception e){
|
||||
|
Reference in New Issue
Block a user