Fixed bug with weapons not costing anything server-side
This commit is contained in:
@@ -255,6 +255,7 @@ public class NetClient extends Module {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
if(!Net.client() || !Net.active()) return;
|
||||
|
||||
@@ -265,6 +266,12 @@ public class NetClient extends Module {
|
||||
}
|
||||
}
|
||||
|
||||
public void handleUpgrade(Weapon weapon){
|
||||
UpgradePacket packet = new UpgradePacket();
|
||||
packet.id = weapon.ordinal();
|
||||
Net.send(packet, SendMode.tcp);
|
||||
}
|
||||
|
||||
public void handleSendMessage(String message){
|
||||
ChatPacket packet = new ChatPacket();
|
||||
packet.text = message;
|
||||
|
||||
@@ -155,6 +155,11 @@ public class NetServer extends Module{
|
||||
packet.name = player.name;
|
||||
Net.send(packet, SendMode.tcp);
|
||||
});
|
||||
|
||||
Net.handleServer(UpgradePacket.class, packet -> {
|
||||
Weapon weapon = Weapon.values()[packet.id];
|
||||
Vars.control.removeItems(weapon.requirements);
|
||||
});
|
||||
}
|
||||
|
||||
public void handleBullet(BulletType type, Entity owner, float x, float y, float angle, short damage){
|
||||
|
||||
@@ -114,4 +114,8 @@ public class Packets {
|
||||
public enum KickReason{
|
||||
kick, invalidPassword
|
||||
}
|
||||
|
||||
public static class UpgradePacket{
|
||||
public int id; //weapon ID only, currently
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public class Registrator {
|
||||
DisconnectPacket.class,
|
||||
ChatPacket.class,
|
||||
KickPacket.class,
|
||||
UpgradePacket.class,
|
||||
|
||||
Class.class,
|
||||
byte[].class,
|
||||
|
||||
@@ -2,8 +2,10 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
@@ -52,9 +54,7 @@ public class UpgradeDialog extends FloatingDialog{
|
||||
button.getLabelCell().left();
|
||||
button.pack();
|
||||
|
||||
|
||||
button.update(()->{
|
||||
|
||||
if(control.hasWeapon(weapon)){
|
||||
button.setDisabled(true);
|
||||
button.setColor(Color.GRAY);
|
||||
@@ -128,6 +128,10 @@ public class UpgradeDialog extends FloatingDialog{
|
||||
ui.weaponfrag.updateWeapons();
|
||||
run.listen();
|
||||
Effects.sound("purchase");
|
||||
|
||||
if(Net.active() && Net.client()){
|
||||
Vars.netClient.handleUpgrade(weapon);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user