Misc bugfixes
This commit is contained in:
@@ -232,7 +232,7 @@ public class Vars implements Loadable{
|
|||||||
public static BeControl becontrol;
|
public static BeControl becontrol;
|
||||||
public static AsyncCore asyncCore;
|
public static AsyncCore asyncCore;
|
||||||
public static BaseRegistry bases;
|
public static BaseRegistry bases;
|
||||||
public static GlobalConstants constants;
|
public static GlobalVars logicVars;
|
||||||
public static MapEditor editor;
|
public static MapEditor editor;
|
||||||
public static GameService service = new GameService();
|
public static GameService service = new GameService();
|
||||||
|
|
||||||
@@ -313,7 +313,7 @@ public class Vars implements Loadable{
|
|||||||
controlPath = new ControlPathfinder();
|
controlPath = new ControlPathfinder();
|
||||||
fogControl = new FogControl();
|
fogControl = new FogControl();
|
||||||
bases = new BaseRegistry();
|
bases = new BaseRegistry();
|
||||||
constants = new GlobalConstants();
|
logicVars = new GlobalVars();
|
||||||
javaPath =
|
javaPath =
|
||||||
new Fi(OS.prop("java.home")).child("bin/java").exists() ? new Fi(OS.prop("java.home")).child("bin/java").absolutePath() :
|
new Fi(OS.prop("java.home")).child("bin/java").exists() ? new Fi(OS.prop("java.home")).child("bin/java").absolutePath() :
|
||||||
Core.files.local("jre/bin/java").exists() ? Core.files.local("jre/bin/java").absolutePath() :
|
Core.files.local("jre/bin/java").exists() ? Core.files.local("jre/bin/java").absolutePath() :
|
||||||
@@ -364,22 +364,24 @@ public class Vars implements Loadable{
|
|||||||
|
|
||||||
Seq<String> logBuffer = new Seq<>();
|
Seq<String> logBuffer = new Seq<>();
|
||||||
Log.logger = (level, text) -> {
|
Log.logger = (level, text) -> {
|
||||||
String result = text;
|
synchronized(logBuffer){
|
||||||
String rawText = Log.format(stags[level.ordinal()] + "&fr " + text);
|
String result = text;
|
||||||
System.out.println(rawText);
|
String rawText = Log.format(stags[level.ordinal()] + "&fr " + text);
|
||||||
|
System.out.println(rawText);
|
||||||
|
|
||||||
result = tags[level.ordinal()] + " " + result;
|
result = tags[level.ordinal()] + " " + result;
|
||||||
|
|
||||||
if(!headless && (ui == null || ui.scriptfrag == null)){
|
if(!headless && (ui == null || ui.scriptfrag == null)){
|
||||||
logBuffer.add(result);
|
logBuffer.add(result);
|
||||||
}else if(!headless){
|
}else if(!headless){
|
||||||
if(!OS.isWindows){
|
if(!OS.isWindows){
|
||||||
for(String code : ColorCodes.values){
|
for(String code : ColorCodes.values){
|
||||||
result = result.replace(code, "");
|
result = result.replace(code, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ui.scriptfrag.addMessage(Log.removeColors(result));
|
ui.scriptfrag.addMessage(Log.removeColors(result));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class ContentLoader{
|
|||||||
/** Calls Content#init() on everything. Use only after all modules have been created. */
|
/** Calls Content#init() on everything. Use only after all modules have been created. */
|
||||||
public void init(){
|
public void init(){
|
||||||
initialize(Content::init);
|
initialize(Content::init);
|
||||||
if(constants != null) constants.init();
|
if(logicVars != null) logicVars.init();
|
||||||
Events.fire(new ContentInitEvent());
|
Events.fire(new ContentInitEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -402,7 +402,9 @@ public class Logic implements ApplicationListener{
|
|||||||
@Remote(called = Loc.both)
|
@Remote(called = Loc.both)
|
||||||
public static void updateGameOver(Team winner){
|
public static void updateGameOver(Team winner){
|
||||||
state.gameOver = true;
|
state.gameOver = true;
|
||||||
state.won = player.team() == winner;
|
if(!headless){
|
||||||
|
state.won = player.team() == winner;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(called = Loc.both)
|
@Remote(called = Loc.both)
|
||||||
@@ -502,7 +504,7 @@ public class Logic implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
Time.update();
|
Time.update();
|
||||||
|
|
||||||
constants.update();
|
logicVars.update();
|
||||||
|
|
||||||
//weather is serverside
|
//weather is serverside
|
||||||
if(!net.client() && !state.isEditor()){
|
if(!net.client() && !state.isEditor()){
|
||||||
|
|||||||
@@ -469,8 +469,8 @@ public class NetClient implements ApplicationListener{
|
|||||||
|
|
||||||
//note that this is far from a guarantee that random state is synced - tiny changes in delta and ping can throw everything off again.
|
//note that this is far from a guarantee that random state is synced - tiny changes in delta and ping can throw everything off again.
|
||||||
//syncing will only make much of a difference when rand() is called infrequently
|
//syncing will only make much of a difference when rand() is called infrequently
|
||||||
GlobalConstants.rand.seed0 = rand0;
|
GlobalVars.rand.seed0 = rand0;
|
||||||
GlobalConstants.rand.seed1 = rand1;
|
GlobalVars.rand.seed1 = rand1;
|
||||||
|
|
||||||
universe.updateNetSeconds(timeData);
|
universe.updateNetSeconds(timeData);
|
||||||
|
|
||||||
|
|||||||
@@ -934,7 +934,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
|
|
||||||
//write basic state data.
|
//write basic state data.
|
||||||
Call.stateSnapshot(player.con, state.wavetime, state.wave, state.enemies, state.serverPaused, state.gameOver,
|
Call.stateSnapshot(player.con, state.wavetime, state.wave, state.enemies, state.serverPaused, state.gameOver,
|
||||||
universe.seconds(), tps, GlobalConstants.rand.seed0, GlobalConstants.rand.seed1, syncStream.toByteArray());
|
universe.seconds(), tps, GlobalVars.rand.seed0, GlobalVars.rand.seed1, syncStream.toByteArray());
|
||||||
|
|
||||||
syncStream.reset();
|
syncStream.reset();
|
||||||
|
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
|
|
||||||
if(player.team().core() == null){
|
if(player.team().core() == null){
|
||||||
player.set(world.width() * tilesize/2f, world.height() * tilesize/2f);
|
player.set(world.width() * tilesize/2f, world.height() * tilesize/2f);
|
||||||
var unit = UnitTypes.alpha.spawn(player.team(), player.x, player.y);
|
var unit = (state.rules.hasEnv(Env.scorching) ? UnitTypes.evoke : UnitTypes.alpha).spawn(player.team(), player.x, player.y);
|
||||||
unit.spawnedByCore = true;
|
unit.spawnedByCore = true;
|
||||||
player.unit(unit);
|
player.unit(unit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1828,7 +1828,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
case powerNetStored -> power == null ? 0 : power.graph.getLastPowerStored();
|
case powerNetStored -> power == null ? 0 : power.graph.getLastPowerStored();
|
||||||
case powerNetCapacity -> power == null ? 0 : power.graph.getLastCapacity();
|
case powerNetCapacity -> power == null ? 0 : power.graph.getLastCapacity();
|
||||||
case enabled -> enabled ? 1 : 0;
|
case enabled -> enabled ? 1 : 0;
|
||||||
case controlled -> this instanceof ControlBlock c && c.isControlled() ? GlobalConstants.ctrlPlayer : 0;
|
case controlled -> this instanceof ControlBlock c && c.isControlled() ? GlobalVars.ctrlPlayer : 0;
|
||||||
case payloadCount -> getPayload() != null ? 1 : 0;
|
case payloadCount -> getPayload() != null ? 1 : 0;
|
||||||
case size -> block.size;
|
case size -> block.size;
|
||||||
default -> Float.NaN; //gets converted to null in logic
|
default -> Float.NaN; //gets converted to null in logic
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import mindustry.world.blocks.environment.*;
|
|||||||
import mindustry.world.blocks.payloads.*;
|
import mindustry.world.blocks.payloads.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
import static mindustry.logic.GlobalConstants.*;
|
import static mindustry.logic.GlobalVars.*;
|
||||||
|
|
||||||
@Component(base = true)
|
@Component(base = true)
|
||||||
abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, Itemsc, Rotc, Unitc, Weaponsc, Drawc, Boundedc, Syncc, Shieldc, Displayable, Senseable, Ranged, Minerc, Builderc{
|
abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, Itemsc, Rotc, Unitc, Weaponsc, Drawc, Boundedc, Syncc, Shieldc, Displayable, Senseable, Ranged, Minerc, Builderc{
|
||||||
|
|||||||
@@ -122,6 +122,10 @@ public final class FogControl implements CustomChunk{
|
|||||||
return data.read.get(x + y * ww);
|
return data.read.get(x + y * ww);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetFog(){
|
||||||
|
fog = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable FogData data(Team team){
|
@Nullable FogData data(Team team){
|
||||||
return fog == null || fog[team.id] == null ? null : fog[team.id];
|
return fog == null || fog[team.id] == null ? null : fog[team.id];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class MinimapRenderer{
|
|||||||
if(event.tile.block().solid && event.tile.y > 0 && event.tile.isCenter()){
|
if(event.tile.block().solid && event.tile.y > 0 && event.tile.isCenter()){
|
||||||
event.tile.getLinkedTiles(t -> {
|
event.tile.getLinkedTiles(t -> {
|
||||||
Tile tile = world.tile(t.x, t.y - 1);
|
Tile tile = world.tile(t.x, t.y - 1);
|
||||||
if(tile.block() == Blocks.air){
|
if(tile != null && tile.block() == Blocks.air){
|
||||||
update(tile);
|
update(tile);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import java.io.*;
|
|||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
/** Stores global constants for logic processors. */
|
/** Stores global logic variables for logic processors. */
|
||||||
public class GlobalConstants{
|
public class GlobalVars{
|
||||||
public static final int ctrlProcessor = 1, ctrlPlayer = 2, ctrlCommand = 3;
|
public static final int ctrlProcessor = 1, ctrlPlayer = 2, ctrlCommand = 3;
|
||||||
public static final ContentType[] lookableContent = {ContentType.block, ContentType.unit, ContentType.item, ContentType.liquid};
|
public static final ContentType[] lookableContent = {ContentType.block, ContentType.unit, ContentType.item, ContentType.liquid};
|
||||||
/** Global random state. */
|
/** Global random state. */
|
||||||
@@ -58,7 +58,7 @@ public class LAssembler{
|
|||||||
/** @return a variable ID by name.
|
/** @return a variable ID by name.
|
||||||
* This may be a constant variable referring to a number or object. */
|
* This may be a constant variable referring to a number or object. */
|
||||||
public int var(String symbol){
|
public int var(String symbol){
|
||||||
int constId = Vars.constants.get(symbol);
|
int constId = Vars.logicVars.get(symbol);
|
||||||
if(constId > 0){
|
if(constId > 0){
|
||||||
//global constants are *negated* and stored separately
|
//global constants are *negated* and stored separately
|
||||||
return -constId;
|
return -constId;
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public class LExecutor{
|
|||||||
|
|
||||||
public Var var(int index){
|
public Var var(int index){
|
||||||
//global constants have variable IDs < 0, and they are fetched from the global constants object after being negated
|
//global constants have variable IDs < 0, and they are fetched from the global constants object after being negated
|
||||||
return index < 0 ? constants.get(-index) : vars[index];
|
return index < 0 ? logicVars.get(-index) : vars[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable Building building(int index){
|
public @Nullable Building building(int index){
|
||||||
@@ -1104,7 +1104,7 @@ public class LExecutor{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(LExecutor exec){
|
public void run(LExecutor exec){
|
||||||
exec.setobj(dest, constants.lookupContent(type, exec.numi(from)));
|
exec.setobj(dest, logicVars.lookupContent(type, exec.numi(from)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -704,7 +704,7 @@ public class LStatements{
|
|||||||
|
|
||||||
table.button(b -> {
|
table.button(b -> {
|
||||||
b.label(() -> type.name());
|
b.label(() -> type.name());
|
||||||
b.clicked(() -> showSelect(b, GlobalConstants.lookableContent, type, o -> {
|
b.clicked(() -> showSelect(b, GlobalVars.lookableContent, type, o -> {
|
||||||
type = o;
|
type = o;
|
||||||
}));
|
}));
|
||||||
}, Styles.logict, () -> {}).size(64f, 40f).pad(4f).color(table.color);
|
}, Styles.logict, () -> {}).size(64f, 40f).pad(4f).color(table.color);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public enum LogicOp{
|
|||||||
floor("floor", Math::floor),
|
floor("floor", Math::floor),
|
||||||
ceil("ceil", Math::ceil),
|
ceil("ceil", Math::ceil),
|
||||||
sqrt("sqrt", Math::sqrt),
|
sqrt("sqrt", Math::sqrt),
|
||||||
rand("rand", d -> GlobalConstants.rand.nextDouble() * d),
|
rand("rand", d -> GlobalVars.rand.nextDouble() * d),
|
||||||
|
|
||||||
sin("sin", d -> Math.sin(d * Mathf.doubleDegRad)),
|
sin("sin", d -> Math.sin(d * Mathf.doubleDegRad)),
|
||||||
cos("cos", d -> Math.cos(d * Mathf.doubleDegRad)),
|
cos("cos", d -> Math.cos(d * Mathf.doubleDegRad)),
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ public class Maps{
|
|||||||
|
|
||||||
//create map, write it, etc etc etc
|
//create map, write it, etc etc etc
|
||||||
Map map = new Map(file, world.width(), world.height(), tags, true);
|
Map map = new Map(file, world.width(), world.height(), tags, true);
|
||||||
|
fogControl.resetFog();
|
||||||
MapIO.writeMap(file, map);
|
MapIO.writeMap(file, map);
|
||||||
|
|
||||||
if(!headless){
|
if(!headless){
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ public class NetworkIO{
|
|||||||
stream.writeInt(state.wave);
|
stream.writeInt(state.wave);
|
||||||
stream.writeFloat(state.wavetime);
|
stream.writeFloat(state.wavetime);
|
||||||
stream.writeDouble(state.tick);
|
stream.writeDouble(state.tick);
|
||||||
stream.writeLong(GlobalConstants.rand.seed0);
|
stream.writeLong(GlobalVars.rand.seed0);
|
||||||
stream.writeLong(GlobalConstants.rand.seed1);
|
stream.writeLong(GlobalVars.rand.seed1);
|
||||||
|
|
||||||
Writes write = new Writes(stream);
|
Writes write = new Writes(stream);
|
||||||
|
|
||||||
@@ -81,8 +81,8 @@ public class NetworkIO{
|
|||||||
state.wave = stream.readInt();
|
state.wave = stream.readInt();
|
||||||
state.wavetime = stream.readFloat();
|
state.wavetime = stream.readFloat();
|
||||||
state.tick = stream.readDouble();
|
state.tick = stream.readDouble();
|
||||||
GlobalConstants.rand.seed0 = stream.readLong();
|
GlobalVars.rand.seed0 = stream.readLong();
|
||||||
GlobalConstants.rand.seed1 = stream.readLong();
|
GlobalVars.rand.seed1 = stream.readLong();
|
||||||
|
|
||||||
Reads read = new Reads(stream);
|
Reads read = new Reads(stream);
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ public class ContinuousTurret extends Turret{
|
|||||||
return canConsume();
|
return canConsume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldConsume(){
|
||||||
|
return isShooting();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BulletType peekAmmo(){
|
public BulletType peekAmmo(){
|
||||||
return shootType;
|
return shootType;
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class ImagePacker{
|
|||||||
|
|
||||||
Seq<UnlockableContent> lookupCont = new Seq<>();
|
Seq<UnlockableContent> lookupCont = new Seq<>();
|
||||||
|
|
||||||
for(ContentType t : GlobalConstants.lookableContent){
|
for(ContentType t : GlobalVars.lookableContent){
|
||||||
lookupCont.addAll(Vars.content.<UnlockableContent>getBy(t).select(UnlockableContent::logicVisible));
|
lookupCont.addAll(Vars.content.<UnlockableContent>getBy(t).select(UnlockableContent::logicVisible));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ public class ImagePacker{
|
|||||||
|
|
||||||
if(logicidfile.exists()){
|
if(logicidfile.exists()){
|
||||||
try(DataInputStream in = new DataInputStream(logicidfile.readByteStream())){
|
try(DataInputStream in = new DataInputStream(logicidfile.readByteStream())){
|
||||||
for(ContentType ctype : GlobalConstants.lookableContent){
|
for(ContentType ctype : GlobalVars.lookableContent){
|
||||||
short amount = in.readShort();
|
short amount = in.readShort();
|
||||||
for(int i = 0; i < amount; i++){
|
for(int i = 0; i < amount; i++){
|
||||||
String name = in.readUTF();
|
String name = in.readUTF();
|
||||||
@@ -183,7 +183,7 @@ public class ImagePacker{
|
|||||||
|
|
||||||
//write the resulting IDs
|
//write the resulting IDs
|
||||||
try(DataOutputStream out = new DataOutputStream(logicidfile.write(false, 2048))){
|
try(DataOutputStream out = new DataOutputStream(logicidfile.write(false, 2048))){
|
||||||
for(ContentType t : GlobalConstants.lookableContent){
|
for(ContentType t : GlobalVars.lookableContent){
|
||||||
Seq<UnlockableContent> all = idToContent[t.ordinal()].values().toArray().sort(u -> registered[t.ordinal()].get(u));
|
Seq<UnlockableContent> all = idToContent[t.ordinal()].values().toArray().sort(u -> registered[t.ordinal()].get(u));
|
||||||
out.writeShort(all.size);
|
out.writeShort(all.size);
|
||||||
for(UnlockableContent u : all){
|
for(UnlockableContent u : all){
|
||||||
|
|||||||
Reference in New Issue
Block a user