Fixed placement teleporter crash, invalid packet handling
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Sun Feb 25 23:41:37 EST 2018
|
#Mon Feb 26 10:05:40 EST 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=288
|
androidBuildCode=290
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.3
|
code=3.3
|
||||||
build=custom build
|
build=custom build
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class Logic extends Module {
|
|||||||
|
|
||||||
if(world.getCore() != null && world.getCore().block() != ProductionBlocks.core && !state.gameOver){
|
if(world.getCore() != null && world.getCore().block() != ProductionBlocks.core && !state.gameOver){
|
||||||
state.gameOver = true;
|
state.gameOver = true;
|
||||||
NetEvents.handleGameOver();
|
if(Net.server()) NetEvents.handleGameOver();
|
||||||
Events.fire(GameOverEvent.class);
|
Events.fire(GameOverEvent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,6 +170,11 @@ public class NetClient extends Module {
|
|||||||
|
|
||||||
Net.handleClient(PlacePacket.class, (packet) -> {
|
Net.handleClient(PlacePacket.class, (packet) -> {
|
||||||
Placement.placeBlock(packet.x, packet.y, Block.getByID(packet.block), packet.rotation, true, false);
|
Placement.placeBlock(packet.x, packet.y, Block.getByID(packet.block), packet.rotation, true, false);
|
||||||
|
|
||||||
|
if(packet.playerid == player.id){
|
||||||
|
Tile tile = world.tile(packet.x, packet.y);
|
||||||
|
if(tile != null) Block.getByID(packet.block).placed(tile);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Net.handleClient(BreakPacket.class, (packet) -> {
|
Net.handleClient(BreakPacket.class, (packet) -> {
|
||||||
|
|||||||
@@ -115,10 +115,11 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void placeBlock(int x, int y, Block result, int rotation, boolean effects, boolean sound){
|
public void placeBlock(int x, int y, Block result, int rotation, boolean effects, boolean sound){
|
||||||
if(!Net.client()) Placement.placeBlock(x, y, result, rotation, effects, sound);
|
if(!Net.client()){
|
||||||
|
Placement.placeBlock(x, y, result, rotation, effects, sound);
|
||||||
Tile tile = world.tile(x, y);
|
Tile tile = world.tile(x, y);
|
||||||
if(tile != null) result.placed(tile);
|
if(tile != null) result.placed(tile);
|
||||||
|
}
|
||||||
|
|
||||||
if(Net.active()){
|
if(Net.active()){
|
||||||
NetEvents.handlePlace(x, y, result, rotation);
|
NetEvents.handlePlace(x, y, result, rotation);
|
||||||
|
|||||||
@@ -27,14 +27,7 @@ public class Placement {
|
|||||||
if(tile == null) return;
|
if(tile == null) return;
|
||||||
|
|
||||||
Block block = tile.isLinked() ? tile.getLinked().block() : tile.block();
|
Block block = tile.isLinked() ? tile.getLinked().block() : tile.block();
|
||||||
Recipe result = null;
|
Recipe result = Recipes.getByResult(block);
|
||||||
|
|
||||||
for(Recipe recipe : Recipes.all()){
|
|
||||||
if(recipe.result == block){
|
|
||||||
result = recipe;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(result != null){
|
if(result != null){
|
||||||
for(ItemStack stack : result.requirements){
|
for(ItemStack stack : result.requirements){
|
||||||
@@ -100,6 +93,12 @@ public class Placement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Recipe recipe = Recipes.getByResult(type);
|
||||||
|
|
||||||
|
if(recipe == null || !state.inventory.hasItems(recipe.requirements)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
rect.setSize(type.width * tilesize, type.height * tilesize);
|
rect.setSize(type.width * tilesize, type.height * tilesize);
|
||||||
Vector2 offset = type.getPlaceOffset();
|
Vector2 offset = type.getPlaceOffset();
|
||||||
rect.setCenter(offset.x + x * tilesize, offset.y + y * tilesize);
|
rect.setCenter(offset.x + x * tilesize, offset.y + y * tilesize);
|
||||||
|
|||||||
Reference in New Issue
Block a user