Updated RDX item, changed packet creation to use pooling
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 241 B After Width: | Height: | Size: 233 B |
Binary file not shown.
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 107 KiB |
@@ -64,7 +64,7 @@ public class Items {
|
|||||||
fluxiness = 0.5f;
|
fluxiness = 0.5f;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
rdx = new Item("rdx", Color.valueOf("e3d39e")){
|
rdx = new Item("rdx", Color.valueOf("ff795e")){
|
||||||
{
|
{
|
||||||
material = false;
|
material = false;
|
||||||
flammability = 0.2f;
|
flammability = 0.2f;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.net;
|
package io.anuke.mindustry.net;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.utils.Pools;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.SyncEntity;
|
import io.anuke.mindustry.entities.SyncEntity;
|
||||||
@@ -16,7 +17,7 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
public class NetEvents {
|
public class NetEvents {
|
||||||
|
|
||||||
public static void handleFriendlyFireChange(boolean enabled){
|
public static void handleFriendlyFireChange(boolean enabled){
|
||||||
FriendlyFireChangePacket packet = new FriendlyFireChangePacket();
|
FriendlyFireChangePacket packet = Pools.obtain(FriendlyFireChangePacket.class);
|
||||||
packet.enabled = enabled;
|
packet.enabled = enabled;
|
||||||
|
|
||||||
netCommon.sendMessage(enabled ? "[accent]Friendly fire enabled." : "[accent]Friendly fire disabled.");
|
netCommon.sendMessage(enabled ? "[accent]Friendly fire enabled." : "[accent]Friendly fire disabled.");
|
||||||
@@ -25,57 +26,57 @@ public class NetEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void handleGameOver(){
|
public static void handleGameOver(){
|
||||||
Net.send(new GameOverPacket(), SendMode.tcp);
|
Net.send(Pools.obtain(GameOverPacket.class), SendMode.tcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleUnitDeath(Unit entity){
|
public static void handleUnitDeath(Unit entity){
|
||||||
EntityDeathPacket packet = new EntityDeathPacket();
|
EntityDeathPacket packet = Pools.obtain(EntityDeathPacket.class);
|
||||||
packet.id = entity.id;
|
packet.id = entity.id;
|
||||||
packet.group = (byte)entity.getGroup().getID();
|
packet.group = (byte)entity.getGroup().getID();
|
||||||
Net.send(packet, SendMode.tcp);
|
Net.send(packet, SendMode.tcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleBlockDestroyed(TileEntity entity){
|
public static void handleBlockDestroyed(TileEntity entity){
|
||||||
BlockDestroyPacket packet = new BlockDestroyPacket();
|
BlockDestroyPacket packet = Pools.obtain(BlockDestroyPacket.class);
|
||||||
packet.position = entity.tile.packedPosition();
|
packet.position = entity.tile.packedPosition();
|
||||||
Net.send(packet, SendMode.tcp);
|
Net.send(packet, SendMode.tcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleBlockDamaged(TileEntity entity){
|
public static void handleBlockDamaged(TileEntity entity){
|
||||||
BlockUpdatePacket packet = new BlockUpdatePacket();
|
BlockUpdatePacket packet = Pools.obtain(BlockUpdatePacket.class);
|
||||||
packet.health = (int)entity.health;
|
packet.health = (int)entity.health;
|
||||||
packet.position = entity.tile.packedPosition();
|
packet.position = entity.tile.packedPosition();
|
||||||
Net.send(packet, SendMode.udp);
|
Net.send(packet, SendMode.udp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleBlockConfig(Tile tile, byte data){
|
public static void handleBlockConfig(Tile tile, byte data){
|
||||||
BlockConfigPacket packet = new BlockConfigPacket();
|
BlockConfigPacket packet = Pools.obtain(BlockConfigPacket.class);
|
||||||
packet.data = data;
|
packet.data = data;
|
||||||
packet.position = tile.packedPosition();
|
packet.position = tile.packedPosition();
|
||||||
Net.send(packet, SendMode.tcp);
|
Net.send(packet, SendMode.tcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleBlockTap(Tile tile){
|
public static void handleBlockTap(Tile tile){
|
||||||
BlockTapPacket packet = new BlockTapPacket();
|
BlockTapPacket packet = Pools.obtain(BlockTapPacket.class);
|
||||||
packet.position = tile.packedPosition();
|
packet.position = tile.packedPosition();
|
||||||
Net.send(packet, SendMode.tcp);
|
Net.send(packet, SendMode.tcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleWeaponSwitch(){
|
public static void handleWeaponSwitch(){
|
||||||
WeaponSwitchPacket packet = new WeaponSwitchPacket();
|
WeaponSwitchPacket packet = Pools.obtain(WeaponSwitchPacket.class);
|
||||||
packet.weapon = Vars.player.weapon.id;
|
packet.weapon = Vars.player.weapon.id;
|
||||||
packet.playerid = Vars.player.id;
|
packet.playerid = Vars.player.id;
|
||||||
Net.send(packet, SendMode.tcp);
|
Net.send(packet, SendMode.tcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleUpgrade(Weapon weapon){
|
public static void handleUpgrade(Weapon weapon){
|
||||||
UpgradePacket packet = new UpgradePacket();
|
UpgradePacket packet = Pools.obtain(UpgradePacket.class);
|
||||||
packet.id = weapon.id;
|
packet.id = weapon.id;
|
||||||
Net.send(packet, SendMode.tcp);
|
Net.send(packet, SendMode.tcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleSendMessage(String message){
|
public static void handleSendMessage(String message){
|
||||||
ChatPacket packet = new ChatPacket();
|
ChatPacket packet = Pools.obtain(ChatPacket.class);
|
||||||
packet.text = message;
|
packet.text = message;
|
||||||
packet.name = player.name;
|
packet.name = player.name;
|
||||||
packet.id = player.id;
|
packet.id = player.id;
|
||||||
@@ -87,7 +88,7 @@ public class NetEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void handleShoot(SyncEntity entity, float x, float y, float angle, short data){
|
public static void handleShoot(SyncEntity entity, float x, float y, float angle, short data){
|
||||||
EntityShootPacket packet = new EntityShootPacket();
|
EntityShootPacket packet = Pools.obtain(EntityShootPacket.class);
|
||||||
packet.groupid = (byte)entity.getGroup().getID();
|
packet.groupid = (byte)entity.getGroup().getID();
|
||||||
packet.x = x;
|
packet.x = x;
|
||||||
packet.y = y;
|
packet.y = y;
|
||||||
@@ -98,7 +99,7 @@ public class NetEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void handlePlace(int x, int y, Block block, int rotation){
|
public static void handlePlace(int x, int y, Block block, int rotation){
|
||||||
PlacePacket packet = new PlacePacket();
|
PlacePacket packet = Pools.obtain(PlacePacket.class);
|
||||||
packet.x = (short)x;
|
packet.x = (short)x;
|
||||||
packet.y = (short)y;
|
packet.y = (short)y;
|
||||||
packet.rotation = (byte)rotation;
|
packet.rotation = (byte)rotation;
|
||||||
@@ -108,14 +109,14 @@ public class NetEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void handleBreak(int x, int y){
|
public static void handleBreak(int x, int y){
|
||||||
BreakPacket packet = new BreakPacket();
|
BreakPacket packet = Pools.obtain(BreakPacket.class);
|
||||||
packet.x = (short)x;
|
packet.x = (short)x;
|
||||||
packet.y = (short)y;
|
packet.y = (short)y;
|
||||||
Net.send(packet, SendMode.tcp);
|
Net.send(packet, SendMode.tcp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleAdminSet(Player player, boolean admin){
|
public static void handleAdminSet(Player player, boolean admin){
|
||||||
PlayerAdminPacket packet = new PlayerAdminPacket();
|
PlayerAdminPacket packet = Pools.obtain(PlayerAdminPacket.class);
|
||||||
packet.admin = admin;
|
packet.admin = admin;
|
||||||
packet.id = player.id;
|
packet.id = player.id;
|
||||||
player.isAdmin = admin;
|
player.isAdmin = admin;
|
||||||
@@ -123,7 +124,7 @@ public class NetEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void handleAdministerRequest(Player target, AdminAction action){
|
public static void handleAdministerRequest(Player target, AdminAction action){
|
||||||
AdministerRequestPacket packet = new AdministerRequestPacket();
|
AdministerRequestPacket packet = Pools.obtain(AdministerRequestPacket.class);
|
||||||
packet.id = target.id;
|
packet.id = target.id;
|
||||||
packet.action = action;
|
packet.action = action;
|
||||||
Net.send(packet, SendMode.tcp);
|
Net.send(packet, SendMode.tcp);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
|
|||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
import com.badlogic.gdx.utils.ObjectSet;
|
import com.badlogic.gdx.utils.ObjectSet;
|
||||||
|
import com.badlogic.gdx.utils.Pools;
|
||||||
import com.esotericsoftware.kryonet.*;
|
import com.esotericsoftware.kryonet.*;
|
||||||
import com.esotericsoftware.kryonet.Listener.LagListener;
|
import com.esotericsoftware.kryonet.Listener.LagListener;
|
||||||
import com.esotericsoftware.minlog.Log;
|
import com.esotericsoftware.minlog.Log;
|
||||||
@@ -132,6 +133,7 @@ public class KryoClient implements ClientProvider{
|
|||||||
}else{
|
}else{
|
||||||
client.sendUDP(object);
|
client.sendUDP(object);
|
||||||
}
|
}
|
||||||
|
Pools.free(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.anuke.kryonet;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.Base64Coder;
|
import com.badlogic.gdx.utils.Base64Coder;
|
||||||
|
import com.badlogic.gdx.utils.Pools;
|
||||||
import com.esotericsoftware.kryonet.Connection;
|
import com.esotericsoftware.kryonet.Connection;
|
||||||
import com.esotericsoftware.kryonet.FrameworkMessage;
|
import com.esotericsoftware.kryonet.FrameworkMessage;
|
||||||
import com.esotericsoftware.kryonet.Listener;
|
import com.esotericsoftware.kryonet.Listener;
|
||||||
@@ -361,6 +362,7 @@ public class KryoServer implements ServerProvider {
|
|||||||
Log.info("Connection removed {0}", k);
|
Log.info("Connection removed {0}", k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Pools.free(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user