More codegen fixes, fixed (one) multiplayer connect crash
This commit is contained in:
@@ -1,18 +1,5 @@
|
||||
package io.anuke.mindustry.net;
|
||||
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
public class NetEvents {
|
||||
|
||||
@Remote(unreliable = true, one = true, all = false)
|
||||
public static void callClientMethod(int something, Player player, String str, boolean bool){
|
||||
System.out.println("Called " + something + " ? " + bool);
|
||||
}
|
||||
|
||||
@Remote(local = false)
|
||||
public static void someOtherMethod(Tile tile){
|
||||
System.out.println("Called with tile " + tile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package io.anuke.mindustry.net;
|
||||
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
import io.anuke.mindustry.content.Weapons;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.io.Map;
|
||||
import io.anuke.mindustry.io.MapMeta;
|
||||
import io.anuke.mindustry.io.Version;
|
||||
import io.anuke.mindustry.type.Upgrade;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@@ -30,7 +33,7 @@ public class NetworkIO {
|
||||
|
||||
//--GENERAL STATE--
|
||||
stream.writeByte(state.mode.ordinal()); //gamemode
|
||||
stream.writeUTF(world.getMap().name); //map ID
|
||||
stream.writeUTF(world.getMap().name); //map name
|
||||
|
||||
stream.writeInt(state.wave); //wave
|
||||
stream.writeFloat(state.wavetime); //wave countdown
|
||||
@@ -133,10 +136,15 @@ public class NetworkIO {
|
||||
int width = stream.readShort();
|
||||
int height = stream.readShort();
|
||||
|
||||
//TODO send advanced map meta such as author, etc
|
||||
//TODO scan for cores
|
||||
Map currentMap = new Map(map, new MapMeta(0, new ObjectMap<>(), width, height, null), true, () -> null);
|
||||
world.setMap(currentMap);
|
||||
|
||||
Tile[][] tiles = world.createTiles(width, height);
|
||||
|
||||
for(int x = 0; x < world.width(); x ++){
|
||||
for(int y = 0; y < world.height(); y ++){
|
||||
for(int x = 0; x < width; x ++){
|
||||
for(int y = 0; y < height; y ++){
|
||||
byte floorid = stream.readByte();
|
||||
byte blockid = stream.readByte();
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@ import com.badlogic.gdx.utils.TimeUtils;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.gen.RemoteReadClient;
|
||||
import io.anuke.mindustry.io.Version;
|
||||
import io.anuke.mindustry.net.Packet.ImportantPacket;
|
||||
import io.anuke.mindustry.net.Packet.UnimportantPacket;
|
||||
import io.anuke.ucore.util.IOUtils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@@ -19,13 +21,40 @@ public class Packets {
|
||||
|
||||
public static class Disconnect implements ImportantPacket{
|
||||
public int id;
|
||||
public String addressTCP;
|
||||
}
|
||||
|
||||
public static class WorldStream extends Streamable{
|
||||
|
||||
}
|
||||
|
||||
public static class ConnectPacket implements Packet{
|
||||
public int version;
|
||||
public int players;
|
||||
public String name;
|
||||
public boolean mobile;
|
||||
public int color;
|
||||
public byte[] uuid;
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer buffer) {
|
||||
buffer.putInt(Version.build);
|
||||
IOUtils.writeString(buffer, name);
|
||||
buffer.put(mobile ? (byte)1 : 0);
|
||||
buffer.putInt(color);
|
||||
buffer.put(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuffer buffer) {
|
||||
version = buffer.getInt();
|
||||
name = IOUtils.readString(buffer);
|
||||
mobile = buffer.get() == 1;
|
||||
color = buffer.getInt();
|
||||
uuid = new byte[8];
|
||||
buffer.get(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvokePacket implements Packet{
|
||||
public byte type;
|
||||
|
||||
@@ -37,8 +66,6 @@ public class Packets {
|
||||
type = buffer.get();
|
||||
|
||||
if(Net.client()){
|
||||
//TODO implement
|
||||
//CallClient.readPacket(buffer, type);
|
||||
RemoteReadClient.readPacket(buffer, type);
|
||||
}else{
|
||||
byte[] bytes = new byte[writeLength];
|
||||
|
||||
@@ -11,6 +11,7 @@ public class Registrator {
|
||||
StreamBegin.class,
|
||||
StreamChunk.class,
|
||||
WorldStream.class,
|
||||
ConnectPacket.class,
|
||||
ClientSnapshotPacket.class,
|
||||
SnapshotPacket.class,
|
||||
InvokePacket.class
|
||||
|
||||
Reference in New Issue
Block a user