Made server log stop command, partial teleporter fix
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Wed Feb 14 17:49:43 EST 2018
|
#Wed Feb 14 23:25:13 EST 2018
|
||||||
version=beta
|
version=beta
|
||||||
androidBuildCode=219
|
androidBuildCode=226
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.3
|
code=3.3
|
||||||
build=custom build
|
build=custom build
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import io.anuke.mindustry.resource.Item;
|
|||||||
import io.anuke.mindustry.world.Map;
|
import io.anuke.mindustry.world.Map;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||||
import io.anuke.mindustry.world.blocks.types.distribution.Teleporter;
|
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.entities.BaseBulletType;
|
import io.anuke.ucore.entities.BaseBulletType;
|
||||||
import io.anuke.ucore.entities.Entities;
|
import io.anuke.ucore.entities.Entities;
|
||||||
@@ -281,8 +280,8 @@ public class NetClient extends Module {
|
|||||||
tile.entity.items[packet.itemid] --;
|
tile.entity.items[packet.itemid] --;
|
||||||
next.block().handleItem(Item.getByID(packet.itemid), next, tile);
|
next.block().handleItem(Item.getByID(packet.itemid), next, tile);
|
||||||
|
|
||||||
if(tile.block() instanceof Teleporter)
|
//if(tile.block() instanceof Teleporter)
|
||||||
Log.info("Recieved dump for teleporter! items: {0}", tile.entity.totalItems());
|
// Log.info("Recieved dump for teleporter! items: {0}", tile.entity.totalItems());
|
||||||
};
|
};
|
||||||
|
|
||||||
if(threads.isEnabled()){
|
if(threads.isEnabled()){
|
||||||
@@ -292,11 +291,11 @@ public class NetClient extends Module {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Net.handleClient(ItemAddPacket.class, packet -> {
|
Net.handleClient(ItemSetPacket.class, packet -> {
|
||||||
Runnable r = () -> {
|
Runnable r = () -> {
|
||||||
Tile tile = world.tile(packet.position);
|
Tile tile = world.tile(packet.position);
|
||||||
if (tile == null || tile.entity == null) return;
|
if (tile == null || tile.entity == null) return;
|
||||||
tile.entity.items[packet.itemid] ++;
|
tile.entity.items[packet.itemid] = packet.amount;
|
||||||
};
|
};
|
||||||
|
|
||||||
if(threads.isEnabled()){
|
if(threads.isEnabled()){
|
||||||
|
|||||||
@@ -138,10 +138,11 @@ public class NetEvents {
|
|||||||
Net.send(packet, SendMode.udp);
|
Net.send(packet, SendMode.udp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleItemAdd(Tile tile, Item item){
|
public static void handleItemSet(Tile tile, Item item, byte amount){
|
||||||
ItemAddPacket packet = new ItemAddPacket();
|
ItemSetPacket packet = new ItemSetPacket();
|
||||||
packet.position = tile.packedPosition();
|
packet.position = tile.packedPosition();
|
||||||
packet.itemid = (byte)item.id;
|
packet.itemid = (byte)item.id;
|
||||||
|
packet.amount = amount;
|
||||||
Net.send(packet, SendMode.udp);
|
Net.send(packet, SendMode.udp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -523,20 +523,22 @@ public class Packets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ItemAddPacket implements Packet, UnimportantPacket{
|
public static class ItemSetPacket implements Packet, UnimportantPacket{
|
||||||
public int position;
|
public int position;
|
||||||
public byte itemid;
|
public byte itemid, amount;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuffer buffer) {
|
public void write(ByteBuffer buffer) {
|
||||||
buffer.putInt(position);
|
buffer.putInt(position);
|
||||||
buffer.put(itemid);
|
buffer.put(itemid);
|
||||||
|
buffer.put(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuffer buffer) {
|
public void read(ByteBuffer buffer) {
|
||||||
position = buffer.getInt();
|
position = buffer.getInt();
|
||||||
itemid = buffer.get();
|
itemid = buffer.get();
|
||||||
|
amount = buffer.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class Registrator {
|
|||||||
MapAckPacket.class,
|
MapAckPacket.class,
|
||||||
EntitySpawnPacket.class,
|
EntitySpawnPacket.class,
|
||||||
ItemTransferPacket.class,
|
ItemTransferPacket.class,
|
||||||
ItemAddPacket.class,
|
ItemSetPacket.class,
|
||||||
ItemOffloadPacket.class
|
ItemOffloadPacket.class
|
||||||
};
|
};
|
||||||
private static ObjectIntMap<Class<?>> ids = new ObjectIntMap<>();
|
private static ObjectIntMap<Class<?>> ids = new ObjectIntMap<>();
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ package io.anuke.mindustry.world.blocks.types;
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
|
||||||
import io.anuke.ucore.function.Predicate;
|
import io.anuke.ucore.function.Predicate;
|
||||||
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
public class Floor extends Block{
|
public class Floor extends Block{
|
||||||
protected Predicate<Block> blends = block -> block != this;
|
protected Predicate<Block> blends = block -> block != this;
|
||||||
protected boolean blend = true;
|
protected boolean blend = true;
|
||||||
@@ -45,7 +45,7 @@ public class Floor extends Block{
|
|||||||
int sx = -dx*8+2, sy = -dy*8+2;
|
int sx = -dx*8+2, sy = -dy*8+2;
|
||||||
int x = Mathf.clamp(sx, 0, 12);
|
int x = Mathf.clamp(sx, 0, 12);
|
||||||
int y = Mathf.clamp(sy, 0, 12);
|
int y = Mathf.clamp(sy, 0, 12);
|
||||||
int w = Mathf.clamp(sx+8, 0, 12)-x, h = Mathf.clamp(sy+8, 0, 12)-y;
|
int w = Mathf.clamp(sx+8, 0, 12) - x, h = Mathf.clamp(sy+8, 0, 12) - y;
|
||||||
|
|
||||||
float rx = Mathf.clamp(dx*8, 0, 8-w);
|
float rx = Mathf.clamp(dx*8, 0, 8-w);
|
||||||
float ry = Mathf.clamp(dy*8, 0, 8-h);
|
float ry = Mathf.clamp(dy*8, 0, 8-h);
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ public class Teleporter extends PowerBlock{
|
|||||||
Tile target = links.random();
|
Tile target = links.random();
|
||||||
target.entity.addItem(item, 1);
|
target.entity.addItem(item, 1);
|
||||||
|
|
||||||
if(Net.server()) NetEvents.handleItemAdd(target, item);
|
if(Net.server()) NetEvents.handleItemSet(target, item, (byte)1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ public class Teleporter extends PowerBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(Tile remove : removal)
|
for(Tile remove : removal)
|
||||||
teleporters[entity.color].remove(remove);
|
teleporters[entity.color].remove(remove);
|
||||||
|
|
||||||
return returns;
|
return returns;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ public class ServerControl extends Module {
|
|||||||
Net.closeServer();
|
Net.closeServer();
|
||||||
state.set(State.menu);
|
state.set(State.menu);
|
||||||
netServer.reset();
|
netServer.reset();
|
||||||
|
Log.info("Stopped server.");
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.register("host", "<mapname> <mode>", "Open the server with a specific map.", arg -> {
|
handler.register("host", "<mapname> <mode>", "Open the server with a specific map.", arg -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user