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(){
|
public void update(){
|
||||||
if(!Net.client() || !Net.active()) return;
|
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){
|
public void handleSendMessage(String message){
|
||||||
ChatPacket packet = new ChatPacket();
|
ChatPacket packet = new ChatPacket();
|
||||||
packet.text = message;
|
packet.text = message;
|
||||||
|
|||||||
@@ -155,6 +155,11 @@ public class NetServer extends Module{
|
|||||||
packet.name = player.name;
|
packet.name = player.name;
|
||||||
Net.send(packet, SendMode.tcp);
|
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){
|
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{
|
public enum KickReason{
|
||||||
kick, invalidPassword
|
kick, invalidPassword
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class UpgradePacket{
|
||||||
|
public int id; //weapon ID only, currently
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public class Registrator {
|
|||||||
DisconnectPacket.class,
|
DisconnectPacket.class,
|
||||||
ChatPacket.class,
|
ChatPacket.class,
|
||||||
KickPacket.class,
|
KickPacket.class,
|
||||||
|
UpgradePacket.class,
|
||||||
|
|
||||||
Class.class,
|
Class.class,
|
||||||
byte[].class,
|
byte[].class,
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package io.anuke.mindustry.ui.dialogs;
|
|||||||
|
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.GameState;
|
import io.anuke.mindustry.core.GameState;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
import io.anuke.mindustry.resource.Weapon;
|
||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
@@ -52,9 +54,7 @@ public class UpgradeDialog extends FloatingDialog{
|
|||||||
button.getLabelCell().left();
|
button.getLabelCell().left();
|
||||||
button.pack();
|
button.pack();
|
||||||
|
|
||||||
|
|
||||||
button.update(()->{
|
button.update(()->{
|
||||||
|
|
||||||
if(control.hasWeapon(weapon)){
|
if(control.hasWeapon(weapon)){
|
||||||
button.setDisabled(true);
|
button.setDisabled(true);
|
||||||
button.setColor(Color.GRAY);
|
button.setColor(Color.GRAY);
|
||||||
@@ -128,6 +128,10 @@ public class UpgradeDialog extends FloatingDialog{
|
|||||||
ui.weaponfrag.updateWeapons();
|
ui.weaponfrag.updateWeapons();
|
||||||
run.listen();
|
run.listen();
|
||||||
Effects.sound("purchase");
|
Effects.sound("purchase");
|
||||||
|
|
||||||
|
if(Net.active() && Net.client()){
|
||||||
|
Vars.netClient.handleUpgrade(weapon);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user