mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-09-11 08:15:35 +03:00
Misc bugfixes
This commit is contained in:
parent
a7ecdf8aab
commit
668b09e955
@ -232,7 +232,7 @@ public class Vars implements Loadable{
|
||||
public static BeControl becontrol;
|
||||
public static AsyncCore asyncCore;
|
||||
public static BaseRegistry bases;
|
||||
public static GlobalConstants constants;
|
||||
public static GlobalVars logicVars;
|
||||
public static MapEditor editor;
|
||||
public static GameService service = new GameService();
|
||||
|
||||
@ -313,7 +313,7 @@ public class Vars implements Loadable{
|
||||
controlPath = new ControlPathfinder();
|
||||
fogControl = new FogControl();
|
||||
bases = new BaseRegistry();
|
||||
constants = new GlobalConstants();
|
||||
logicVars = new GlobalVars();
|
||||
javaPath =
|
||||
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() :
|
||||
@ -364,22 +364,24 @@ public class Vars implements Loadable{
|
||||
|
||||
Seq<String> logBuffer = new Seq<>();
|
||||
Log.logger = (level, text) -> {
|
||||
String result = text;
|
||||
String rawText = Log.format(stags[level.ordinal()] + "&fr " + text);
|
||||
System.out.println(rawText);
|
||||
synchronized(logBuffer){
|
||||
String result = text;
|
||||
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)){
|
||||
logBuffer.add(result);
|
||||
}else if(!headless){
|
||||
if(!OS.isWindows){
|
||||
for(String code : ColorCodes.values){
|
||||
result = result.replace(code, "");
|
||||
if(!headless && (ui == null || ui.scriptfrag == null)){
|
||||
logBuffer.add(result);
|
||||
}else if(!headless){
|
||||
if(!OS.isWindows){
|
||||
for(String code : ColorCodes.values){
|
||||
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. */
|
||||
public void init(){
|
||||
initialize(Content::init);
|
||||
if(constants != null) constants.init();
|
||||
if(logicVars != null) logicVars.init();
|
||||
Events.fire(new ContentInitEvent());
|
||||
}
|
||||
|
||||
|
@ -402,7 +402,9 @@ public class Logic implements ApplicationListener{
|
||||
@Remote(called = Loc.both)
|
||||
public static void updateGameOver(Team winner){
|
||||
state.gameOver = true;
|
||||
state.won = player.team() == winner;
|
||||
if(!headless){
|
||||
state.won = player.team() == winner;
|
||||
}
|
||||
}
|
||||
|
||||
@Remote(called = Loc.both)
|
||||
@ -502,7 +504,7 @@ public class Logic implements ApplicationListener{
|
||||
}
|
||||
Time.update();
|
||||
|
||||
constants.update();
|
||||
logicVars.update();
|
||||
|
||||
//weather is serverside
|
||||
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.
|
||||
//syncing will only make much of a difference when rand() is called infrequently
|
||||
GlobalConstants.rand.seed0 = rand0;
|
||||
GlobalConstants.rand.seed1 = rand1;
|
||||
GlobalVars.rand.seed0 = rand0;
|
||||
GlobalVars.rand.seed1 = rand1;
|
||||
|
||||
universe.updateNetSeconds(timeData);
|
||||
|
||||
|
@ -934,7 +934,7 @@ public class NetServer implements ApplicationListener{
|
||||
|
||||
//write basic state data.
|
||||
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();
|
||||
|
||||
|
@ -289,7 +289,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
|
||||
if(player.team().core() == null){
|
||||
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;
|
||||
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 powerNetCapacity -> power == null ? 0 : power.graph.getLastCapacity();
|
||||
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 size -> block.size;
|
||||
default -> Float.NaN; //gets converted to null in logic
|
||||
|
@ -28,7 +28,7 @@ import mindustry.world.blocks.environment.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.logic.GlobalConstants.*;
|
||||
import static mindustry.logic.GlobalVars.*;
|
||||
|
||||
@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{
|
||||
|
@ -122,6 +122,10 @@ public final class FogControl implements CustomChunk{
|
||||
return data.read.get(x + y * ww);
|
||||
}
|
||||
|
||||
public void resetFog(){
|
||||
fog = null;
|
||||
}
|
||||
|
||||
@Nullable FogData data(Team team){
|
||||
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()){
|
||||
event.tile.getLinkedTiles(t -> {
|
||||
Tile tile = world.tile(t.x, t.y - 1);
|
||||
if(tile.block() == Blocks.air){
|
||||
if(tile != null && tile.block() == Blocks.air){
|
||||
update(tile);
|
||||
}
|
||||
});
|
||||
|
@ -17,8 +17,8 @@ import java.io.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
/** Stores global constants for logic processors. */
|
||||
public class GlobalConstants{
|
||||
/** Stores global logic variables for logic processors. */
|
||||
public class GlobalVars{
|
||||
public static final int ctrlProcessor = 1, ctrlPlayer = 2, ctrlCommand = 3;
|
||||
public static final ContentType[] lookableContent = {ContentType.block, ContentType.unit, ContentType.item, ContentType.liquid};
|
||||
/** Global random state. */
|
@ -58,7 +58,7 @@ public class LAssembler{
|
||||
/** @return a variable ID by name.
|
||||
* This may be a constant variable referring to a number or object. */
|
||||
public int var(String symbol){
|
||||
int constId = Vars.constants.get(symbol);
|
||||
int constId = Vars.logicVars.get(symbol);
|
||||
if(constId > 0){
|
||||
//global constants are *negated* and stored separately
|
||||
return -constId;
|
||||
|
@ -108,7 +108,7 @@ public class LExecutor{
|
||||
|
||||
public Var var(int index){
|
||||
//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){
|
||||
@ -1104,7 +1104,7 @@ public class LExecutor{
|
||||
|
||||
@Override
|
||||
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 -> {
|
||||
b.label(() -> type.name());
|
||||
b.clicked(() -> showSelect(b, GlobalConstants.lookableContent, type, o -> {
|
||||
b.clicked(() -> showSelect(b, GlobalVars.lookableContent, type, o -> {
|
||||
type = o;
|
||||
}));
|
||||
}, Styles.logict, () -> {}).size(64f, 40f).pad(4f).color(table.color);
|
||||
|
@ -40,7 +40,7 @@ public enum LogicOp{
|
||||
floor("floor", Math::floor),
|
||||
ceil("ceil", Math::ceil),
|
||||
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)),
|
||||
cos("cos", d -> Math.cos(d * Mathf.doubleDegRad)),
|
||||
|
@ -195,6 +195,7 @@ public class Maps{
|
||||
|
||||
//create map, write it, etc etc etc
|
||||
Map map = new Map(file, world.width(), world.height(), tags, true);
|
||||
fogControl.resetFog();
|
||||
MapIO.writeMap(file, map);
|
||||
|
||||
if(!headless){
|
||||
|
@ -41,8 +41,8 @@ public class NetworkIO{
|
||||
stream.writeInt(state.wave);
|
||||
stream.writeFloat(state.wavetime);
|
||||
stream.writeDouble(state.tick);
|
||||
stream.writeLong(GlobalConstants.rand.seed0);
|
||||
stream.writeLong(GlobalConstants.rand.seed1);
|
||||
stream.writeLong(GlobalVars.rand.seed0);
|
||||
stream.writeLong(GlobalVars.rand.seed1);
|
||||
|
||||
Writes write = new Writes(stream);
|
||||
|
||||
@ -81,8 +81,8 @@ public class NetworkIO{
|
||||
state.wave = stream.readInt();
|
||||
state.wavetime = stream.readFloat();
|
||||
state.tick = stream.readDouble();
|
||||
GlobalConstants.rand.seed0 = stream.readLong();
|
||||
GlobalConstants.rand.seed1 = stream.readLong();
|
||||
GlobalVars.rand.seed0 = stream.readLong();
|
||||
GlobalVars.rand.seed1 = stream.readLong();
|
||||
|
||||
Reads read = new Reads(stream);
|
||||
|
||||
|
@ -51,6 +51,11 @@ public class ContinuousTurret extends Turret{
|
||||
return canConsume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldConsume(){
|
||||
return isShooting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BulletType peekAmmo(){
|
||||
return shootType;
|
||||
|
@ -134,7 +134,7 @@ public class ImagePacker{
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ public class ImagePacker{
|
||||
|
||||
if(logicidfile.exists()){
|
||||
try(DataInputStream in = new DataInputStream(logicidfile.readByteStream())){
|
||||
for(ContentType ctype : GlobalConstants.lookableContent){
|
||||
for(ContentType ctype : GlobalVars.lookableContent){
|
||||
short amount = in.readShort();
|
||||
for(int i = 0; i < amount; i++){
|
||||
String name = in.readUTF();
|
||||
@ -183,7 +183,7 @@ public class ImagePacker{
|
||||
|
||||
//write the resulting IDs
|
||||
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));
|
||||
out.writeShort(all.size);
|
||||
for(UnlockableContent u : all){
|
||||
|
Loading…
Reference in New Issue
Block a user