mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-10 10:47:13 +07:00
Upgrade purchase verification, various bugfixes for 3.5
This commit is contained in:
parent
8eb2a13efd
commit
5c748fbe54
@ -25,7 +25,7 @@ allprojects {
|
||||
appName = 'Mindustry'
|
||||
gdxVersion = '1.9.8'
|
||||
aiVersion = '1.8.1'
|
||||
uCoreVersion = '9503bcb'
|
||||
uCoreVersion = '238babe'
|
||||
|
||||
getVersionString = {
|
||||
String buildVersion = getBuildVersion()
|
||||
|
@ -1,7 +1,7 @@
|
||||
#Autogenerated file. Do not modify.
|
||||
#Sat Mar 24 12:13:33 EDT 2018
|
||||
#Sat Mar 24 14:04:34 EDT 2018
|
||||
version=release
|
||||
androidBuildCode=459
|
||||
androidBuildCode=470
|
||||
name=Mindustry
|
||||
code=3.4
|
||||
build=custom build
|
||||
|
@ -16,11 +16,15 @@ import io.anuke.mindustry.net.Net.SendMode;
|
||||
import io.anuke.mindustry.net.NetworkIO;
|
||||
import io.anuke.mindustry.net.Packets.*;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.Upgrade;
|
||||
import io.anuke.mindustry.resource.UpgradeRecipes;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Map;
|
||||
import io.anuke.mindustry.world.Placement;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.BaseBulletType;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
@ -298,6 +302,15 @@ public class NetClient extends Module {
|
||||
Player player = playerGroup.getByID(packet.info.playerid);
|
||||
ui.traces.show(player, packet.info);
|
||||
});
|
||||
|
||||
Net.handleClient(UpgradePacket.class, packet -> {
|
||||
Weapon weapon = (Weapon) Upgrade.getByID(packet.id);
|
||||
|
||||
state.inventory.removeItems(UpgradeRecipes.get(weapon));
|
||||
control.upgrades().addWeapon(weapon);
|
||||
ui.hudfrag.updateWeapons();
|
||||
Effects.sound("purchase");
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,6 +60,8 @@ public class NetServer extends Module{
|
||||
|
||||
TraceInfo trace = admins.getTrace(Net.getConnection(id).address);
|
||||
PlayerInfo info = admins.getInfo(uuid);
|
||||
trace.uuid = uuid;
|
||||
trace.android = packet.android;
|
||||
|
||||
if(admins.isIDBanned(uuid)){
|
||||
kick(id, KickReason.banned);
|
||||
@ -74,8 +76,6 @@ public class NetServer extends Module{
|
||||
String ip = Net.getConnection(id).address;
|
||||
|
||||
admins.updatePlayerJoined(uuid, ip, packet.name);
|
||||
trace.uuid = uuid;
|
||||
trace.android = packet.android;
|
||||
|
||||
if(packet.version != Version.build && Version.build != -1 && packet.version != -1){
|
||||
kick(id, packet.version > Version.build ? KickReason.serverOutdated : KickReason.clientOutdated);
|
||||
@ -121,7 +121,7 @@ public class NetServer extends Module{
|
||||
Player player = connections.get(id);
|
||||
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
NetworkIO.writeWorld(player, weapons.get(player.name, new ByteArray()), stream);
|
||||
NetworkIO.writeWorld(player, weapons.get(admins.getTrace(Net.getConnection(id).address).uuid, new ByteArray()), stream);
|
||||
WorldData data = new WorldData();
|
||||
data.stream = new ByteArrayInputStream(stream.toByteArray());
|
||||
Net.sendStream(id, data);
|
||||
@ -178,7 +178,7 @@ public class NetServer extends Module{
|
||||
info.fastShots ++;
|
||||
}else{
|
||||
|
||||
if(info.fastShots - 2 > (int)(wtrc / (weapon.getReload() / 2f))){
|
||||
if(info.fastShots - 1 > (int)(wtrc / (weapon.getReload() / 2f))){
|
||||
kick(id, KickReason.kick);
|
||||
}
|
||||
|
||||
@ -246,11 +246,22 @@ public class NetServer extends Module{
|
||||
Player player = connections.get(id);
|
||||
|
||||
Weapon weapon = (Weapon) Upgrade.getByID(packet.id);
|
||||
String uuid = admins.getTrace(Net.getConnection(id).address).uuid;
|
||||
|
||||
if (!weapons.containsKey(player.name)) weapons.put(player.name, new ByteArray());
|
||||
if (!weapons.get(player.name).contains(weapon.id)) weapons.get(player.name).add(weapon.id);
|
||||
if(!state.inventory.hasItems(UpgradeRecipes.get(weapon))){
|
||||
return;
|
||||
}
|
||||
|
||||
if (!weapons.containsKey(uuid)) weapons.put(uuid, new ByteArray());
|
||||
|
||||
if (!weapons.get(uuid).contains(weapon.id)){
|
||||
weapons.get(uuid).add(weapon.id);
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
|
||||
state.inventory.removeItems(UpgradeRecipes.get(weapon));
|
||||
Net.sendTo(id, packet, SendMode.tcp);
|
||||
});
|
||||
|
||||
Net.handleServer(WeaponSwitchPacket.class, (id, packet) -> {
|
||||
@ -348,9 +359,8 @@ public class NetServer extends Module{
|
||||
Log.info("Kicking connection #{0} / IP: {1}. Reason: {2}", connection, con.address, reason);
|
||||
}
|
||||
|
||||
PlayerInfo info = admins.getInfo(admins.getTrace(con.address).uuid);
|
||||
|
||||
if(reason == KickReason.kick || reason == KickReason.banned){
|
||||
if((reason == KickReason.kick || reason == KickReason.banned) && admins.getTrace(con.address).uuid != null){
|
||||
PlayerInfo info = admins.getInfo(admins.getTrace(con.address).uuid);
|
||||
info.timesKicked ++;
|
||||
info.lastKicked = TimeUtils.millis();
|
||||
}
|
||||
|
@ -12,9 +12,7 @@ import io.anuke.ucore.core.Settings;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.gwt;
|
||||
import static io.anuke.mindustry.Vars.logic;
|
||||
import static io.anuke.mindustry.Vars.saveDirectory;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class SaveIO{
|
||||
public static final IntMap<SaveFileVersion> versions = new IntMap<>();
|
||||
|
@ -96,9 +96,13 @@ public class NetEvents {
|
||||
public static void handleSendMessage(String message){
|
||||
ChatPacket packet = new ChatPacket();
|
||||
packet.text = message;
|
||||
packet.name = Vars.player.name;
|
||||
packet.id = Vars.player.id;
|
||||
packet.name = player.name;
|
||||
packet.id = player.id;
|
||||
Net.send(packet, SendMode.tcp);
|
||||
|
||||
if(Net.server() && !headless){
|
||||
ui.chatfrag.addMessage(message, netCommon.colorizeName(player.id, player.name));
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleShoot(Weapon weapon, float x, float y, float angle){
|
||||
|
@ -18,7 +18,7 @@ public class BackgroundFragment implements Fragment {
|
||||
Draw.color();
|
||||
|
||||
TextureRegion back = Draw.region("background");
|
||||
float backscl = Math.max(Gdx.graphics.getWidth() / (float)back.getRegionWidth() * 1.5f, Unit.dp.scl(5f));
|
||||
float backscl = (int)Math.max(Gdx.graphics.getWidth() / (float)back.getRegionWidth() * 1.5f, Unit.dp.scl(5f));
|
||||
|
||||
Draw.alpha(0.5f);
|
||||
Core.batch.draw(back, w/2 - back.getRegionWidth()*backscl/2, h/2 - back.getRegionHeight()*backscl/2,
|
||||
@ -31,7 +31,7 @@ public class BackgroundFragment implements Fragment {
|
||||
float logoh = logo.getRegionHeight()*logoscl;
|
||||
|
||||
Draw.color();
|
||||
Core.batch.draw(logo, w/2 - logow/2, h - logoh + 15 - Unit.dp.scl(portrait ? 30f : 0), logow, logoh);
|
||||
Core.batch.draw(logo, (int)(w/2 - logow/2), (int)(h - logoh + 15 - Unit.dp.scl(portrait ? 30f : 0)), logow, logoh);
|
||||
}).visible(() -> state.is(State.menu)).grow();
|
||||
}
|
||||
}
|
||||
|
@ -89,14 +89,15 @@ public class WeaponFactory extends Block{
|
||||
tip.setInstant(true);
|
||||
|
||||
ImageButton button = content.addImageButton("white", 8*4, () -> {
|
||||
state.inventory.removeItems(requirements);
|
||||
control.upgrades().addWeapon(weapon);
|
||||
ui.hudfrag.updateWeapons();
|
||||
run.listen();
|
||||
Effects.sound("purchase");
|
||||
|
||||
if(Net.client()){
|
||||
NetEvents.handleUpgrade(weapon);
|
||||
}else{
|
||||
state.inventory.removeItems(requirements);
|
||||
control.upgrades().addWeapon(weapon);
|
||||
ui.hudfrag.updateWeapons();
|
||||
run.listen();
|
||||
Effects.sound("purchase");
|
||||
}
|
||||
}).size(49f, 54f).padBottom(-5).get();
|
||||
|
||||
|
@ -147,11 +147,12 @@ public class ServerControl extends Module {
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
while(result == null || result.visible)
|
||||
while(result == null || !result.visible)
|
||||
result = world.maps().getAllMaps().random();
|
||||
Log.info("&ly&fiNo map specified, so &lb{0}&ly was chosen randomly.", result.name);
|
||||
}
|
||||
|
||||
GameMode mode = null;
|
||||
GameMode mode;
|
||||
try{
|
||||
mode = arg.length < 2 ? GameMode.waves : GameMode.valueOf(arg[1]);
|
||||
}catch (IllegalArgumentException e){
|
||||
@ -441,7 +442,7 @@ public class ServerControl extends Module {
|
||||
}else{
|
||||
Log.info("&lyAdmins:");
|
||||
for(PlayerInfo info : admins){
|
||||
Log.info(" &luy {0} / ID: '{1}' / IP: '{2}'", info.lastName, info.id, info.lastIP);
|
||||
Log.info(" &lm {0} / ID: '{1}' / IP: '{2}'", info.lastName, info.id, info.lastIP);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -545,6 +546,7 @@ public class ServerControl extends Module {
|
||||
Log.info(" &lyIP: {0}", info.lastIP);
|
||||
Log.info(" &lyall IPs used: {0}", info.ips);
|
||||
Log.info(" &lytimes joined: {0}", info.timesJoined);
|
||||
Log.info(" &lytimes kicked: {0}", info.timesKicked);
|
||||
Log.info("");
|
||||
Log.info(" &lytotal blocks broken: {0}", info.totalBlocksBroken);
|
||||
Log.info(" &lytotal blocks placed: {0}", info.totalBlockPlaced);
|
||||
|
Loading…
Reference in New Issue
Block a user