mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-10-02 11:10:50 +03:00
Texture streaming Android compat fix
This commit is contained in:
@@ -168,11 +168,16 @@ public class NetClient implements ApplicationListener{
|
||||
net.handleClient(TextureStream.class, data -> {
|
||||
try(DataInputStream in = new DataInputStream(data.stream)){
|
||||
String name = in.readUTF();
|
||||
byte[] pngData = in.readAllBytes();
|
||||
int length = in.readInt();
|
||||
byte[] pngData = new byte[length];
|
||||
in.readFully(pngData);
|
||||
if(!headless){
|
||||
//empty image data means we're removing the texture instead. see NetServer.removeTexture()
|
||||
if(pngData.length == 0) state.data.removeTexture(name);
|
||||
else state.data.addTexture(name, pngData);
|
||||
if(pngData.length == 0){
|
||||
state.data.removeTexture(name);
|
||||
}else{
|
||||
state.data.addTexture(name, pngData);
|
||||
}
|
||||
}
|
||||
}catch(IOException e){
|
||||
Log.err("Failed to read server texture stream", e);
|
||||
|
||||
@@ -87,7 +87,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{
|
||||
}else if(mining() && item != null){
|
||||
mineTimer += Time.delta * type.mineSpeed * state.rules.unitMineSpeed(team());
|
||||
|
||||
if(Mathf.chance(0.07 * Time.delta)){
|
||||
if(Mathf.chance(0.08 * Time.delta)){
|
||||
Fx.unitMine.at(mineTile.worldx() + Mathf.range(tilesize / 2f), mineTile.worldy() + Mathf.range(tilesize / 2f), 0f, item.color);
|
||||
}
|
||||
|
||||
|
||||
@@ -178,6 +178,7 @@ public class NetworkIO{
|
||||
public static void packTexture(OutputStream os, String name, byte[] pngData){
|
||||
try(DataOutputStream stream = new DataOutputStream(os)){
|
||||
stream.writeUTF(name);
|
||||
stream.writeInt(pngData.length);
|
||||
stream.write(pngData);
|
||||
}catch(IOException e){
|
||||
throw new RuntimeException(e);
|
||||
|
||||
Reference in New Issue
Block a user