mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-27 18:38:14 -05:00
Update #45 - Fixed various issues with the client
This commit is contained in:
@ -153,7 +153,7 @@ public class SingleplayerServerController implements ISaveFormat {
|
||||
}
|
||||
|
||||
public static boolean isChannelNameAllowed(String ch) {
|
||||
return !IPC_CHANNEL.equals(ch) && !PLAYER_CHANNEL.equals(ch);
|
||||
return !ch.startsWith("~!");
|
||||
}
|
||||
|
||||
public static void openPlayerChannel(String ch) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.sp.lan;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
||||
@ -42,6 +43,8 @@ class LANClientPeer {
|
||||
protected long startTime;
|
||||
|
||||
protected String localICECandidate = null;
|
||||
protected boolean localChannel = false;
|
||||
protected List<byte[]> packetPreBuffer = null;
|
||||
|
||||
protected LANClientPeer(String clientId) {
|
||||
this.clientId = clientId;
|
||||
@ -75,7 +78,19 @@ class LANClientPeer {
|
||||
|
||||
protected void handleSuccess() {
|
||||
if(state == SENT_ICE_CANDIDATE) {
|
||||
state = RECEIVED_SUCCESS;
|
||||
if(localChannel) {
|
||||
SingleplayerServerController.openPlayerChannel(clientId);
|
||||
PlatformWebRTC.serverLANPeerMapIPC(clientId, clientId);
|
||||
if(packetPreBuffer != null) {
|
||||
for(byte[] b : packetPreBuffer) {
|
||||
ClientPlatformSingleplayer.sendPacket(new IPCPacketData(clientId, b));
|
||||
}
|
||||
packetPreBuffer = null;
|
||||
}
|
||||
state = CONNECTED;
|
||||
}else {
|
||||
state = RECEIVED_SUCCESS;
|
||||
}
|
||||
}else if(state != CONNECTED) {
|
||||
logger.error("Relay [{}] unexpected IPacket05ClientSuccess for '{}'", LANServerController.lanRelaySocket.getURI(), clientId);
|
||||
}
|
||||
@ -113,13 +128,7 @@ class LANClientPeer {
|
||||
localICECandidate = ((LANPeerEvent.LANPeerICECandidateEvent)evt).candidates;
|
||||
continue read_loop;
|
||||
}
|
||||
}
|
||||
case RECEIVED_ICE_CANDIDATE: {
|
||||
if(evt instanceof LANPeerEvent.LANPeerICECandidateEvent) {
|
||||
LANServerController.lanRelaySocket.writePacket(new RelayPacket03ICECandidate(clientId, ((LANPeerEvent.LANPeerICECandidateEvent)evt).candidates));
|
||||
state = SENT_ICE_CANDIDATE;
|
||||
continue read_loop;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RECEIVED_DESCRIPTION: {
|
||||
if(evt instanceof LANPeerEvent.LANPeerDescriptionEvent) {
|
||||
@ -127,15 +136,50 @@ class LANClientPeer {
|
||||
state = SENT_DESCRIPTION;
|
||||
continue read_loop;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RECEIVED_ICE_CANDIDATE: {
|
||||
if(evt instanceof LANPeerEvent.LANPeerICECandidateEvent) {
|
||||
LANServerController.lanRelaySocket.writePacket(new RelayPacket03ICECandidate(clientId, ((LANPeerEvent.LANPeerICECandidateEvent)evt).candidates));
|
||||
state = SENT_ICE_CANDIDATE;
|
||||
continue read_loop;
|
||||
}else if(evt instanceof LANPeerEvent.LANPeerDataChannelEvent) {
|
||||
localChannel = true;
|
||||
continue read_loop;
|
||||
}else if(evt instanceof LANPeerEvent.LANPeerPacketEvent) {
|
||||
if(packetPreBuffer == null) packetPreBuffer = new LinkedList<>();
|
||||
packetPreBuffer.add(((LANPeerEvent.LANPeerPacketEvent)evt).payload);
|
||||
continue read_loop;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SENT_ICE_CANDIDATE: {
|
||||
if(evt instanceof LANPeerEvent.LANPeerDataChannelEvent) {
|
||||
localChannel = true;
|
||||
continue read_loop;
|
||||
}else if(evt instanceof LANPeerEvent.LANPeerPacketEvent) {
|
||||
if(packetPreBuffer == null) packetPreBuffer = new LinkedList<>();
|
||||
packetPreBuffer.add(((LANPeerEvent.LANPeerPacketEvent)evt).payload);
|
||||
continue read_loop;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SENT_ICE_CANDIDATE:
|
||||
case RECEIVED_SUCCESS: {
|
||||
if(evt instanceof LANPeerEvent.LANPeerDataChannelEvent) {
|
||||
SingleplayerServerController.openPlayerChannel(clientId);
|
||||
PlatformWebRTC.serverLANPeerMapIPC(clientId, clientId);
|
||||
if(packetPreBuffer != null) {
|
||||
for(byte[] b : packetPreBuffer) {
|
||||
ClientPlatformSingleplayer.sendPacket(new IPCPacketData(clientId, b));
|
||||
}
|
||||
packetPreBuffer = null;
|
||||
}
|
||||
state = CONNECTED;
|
||||
continue read_loop;
|
||||
}else if(evt instanceof LANPeerEvent.LANPeerICECandidateEvent) {
|
||||
continue read_loop;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CONNECTED: {
|
||||
if(evt instanceof LANPeerEvent.LANPeerPacketEvent) {
|
||||
@ -144,6 +188,7 @@ class LANClientPeer {
|
||||
ClientPlatformSingleplayer.sendPacket(new IPCPacketData(clientId, ((LANPeerEvent.LANPeerPacketEvent)evt).payload));
|
||||
continue read_loop;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
|
@ -12,6 +12,7 @@ import net.lax1dude.eaglercraft.v1_8.EagUtils;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformWebRTC;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.SingleplayerServerController;
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.relay.RelayManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.relay.RelayServerSocket;
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.relay.pkt.*;
|
||||
@ -142,7 +143,9 @@ public class LANServerController {
|
||||
while((pkt = lanRelaySocket.readPacket()) != null) {
|
||||
if(pkt instanceof RelayPacket02NewClient) {
|
||||
RelayPacket02NewClient ipkt = (RelayPacket02NewClient) pkt;
|
||||
if(clients.containsKey(ipkt.clientId)) {
|
||||
if(!SingleplayerServerController.isChannelNameAllowed(ipkt.clientId)) {
|
||||
logger.error("Relay [{}] relay tried to open disallowed channel name: '{}'", lanRelaySocket.getURI(), ipkt.clientId);
|
||||
}else if(clients.containsKey(ipkt.clientId)) {
|
||||
logger.error("Relay [{}] relay provided duplicate client '{}'", lanRelaySocket.getURI(), ipkt.clientId);
|
||||
}else {
|
||||
clients.put(ipkt.clientId, new LANClientPeer(ipkt.clientId));
|
||||
|
@ -103,11 +103,10 @@ public class WorldConverterEPK {
|
||||
public static byte[] exportWorld(String worldName) {
|
||||
String realWorldName = worldName;
|
||||
String worldOwner = "UNKNOWN";
|
||||
String splitter = new String(new char[] { (char)253, (char)233, (char)233 });
|
||||
if(worldName.contains(splitter)) {
|
||||
int i = worldName.lastIndexOf(splitter);
|
||||
worldOwner = worldName.substring(i + 3);
|
||||
realWorldName = worldName.substring(0, i);
|
||||
int j = worldName.lastIndexOf(new String(new char[] { (char)253, (char)233, (char)233 }));
|
||||
if(j != -1) {
|
||||
worldOwner = worldName.substring(j + 3);
|
||||
realWorldName = worldName.substring(0, j);
|
||||
}
|
||||
VFile2 worldDir = EaglerIntegratedServerWorker.saveFormat.getSaveLoader(realWorldName, false).getWorldDirectory();
|
||||
logger.info("Exporting world directory \"{}\" as EPK", worldDir.getPath());
|
||||
|
@ -70,7 +70,6 @@ public class WorldConverterMCA {
|
||||
ZipEntry f = null;
|
||||
int lastProgUpdate = 0;
|
||||
int prog = 0;
|
||||
byte[] bb = new byte[16384];
|
||||
while ((f = zis.getNextEntry()) != null) {
|
||||
if (f.getName().contains("__MACOSX/")) continue;
|
||||
if (f.isDirectory()) continue;
|
||||
@ -85,7 +84,7 @@ public class WorldConverterMCA {
|
||||
j += k;
|
||||
}
|
||||
}else {
|
||||
b = EaglerInputStream.inputStreamToBytes(zis);
|
||||
b = EaglerInputStream.inputStreamToBytesNoClose(zis);
|
||||
}
|
||||
String fileName = f.getName().substring(folderPrefixOffset);
|
||||
if (fileName.equals("level.dat") || fileName.equals("level.dat_old")) {
|
||||
|
Reference in New Issue
Block a user