Removed synthetic accessors / Sector sanity tests

This commit is contained in:
Anuken 2020-08-19 15:13:29 -04:00
parent e9f72180e6
commit bbe6c5017a
33 changed files with 87 additions and 73 deletions

View File

@ -270,7 +270,7 @@ public class Blocks implements ContentList{
}};
grass = new Floor("grass"){{
attributes.set(Attribute.water, 0.1f);
}};
salt = new Floor("salt"){{

View File

@ -17,7 +17,7 @@ import static mindustry.content.UnitTypes.*;
import static mindustry.type.ItemStack.*;
public class TechTree implements ContentList{
private static ObjectMap<UnlockableContent, TechNode> map = new ObjectMap<>();
static ObjectMap<UnlockableContent, TechNode> map = new ObjectMap<>();
public static Seq<TechNode> all;
public static TechNode root;
@ -544,7 +544,7 @@ public class TechTree implements ContentList{
}
public static class TechNode{
private static TechNode context;
static TechNode context;
/** Depth in tech tree. */
public int depth;

View File

@ -484,6 +484,9 @@ public class World{
private class Context implements WorldContext{
Context(){
}
@Override
public Tile tile(int index){
return tiles.geti(index);

View File

@ -37,18 +37,18 @@ public class MapGenerateDialog extends BaseDialog{
private Pixmap pixmap;
private Texture texture;
private GenerateInput input = new GenerateInput();
private Seq<GenerateFilter> filters = new Seq<>();
Seq<GenerateFilter> filters = new Seq<>();
private int scaling = mobile ? 3 : 1;
private Table filterTable;
private AsyncExecutor executor = new AsyncExecutor(1);
private AsyncResult<Void> result;
private boolean generating;
boolean generating;
private GenTile returnTile = new GenTile();
private GenTile[][] buffer1, buffer2;
private Cons<Seq<GenerateFilter>> applier;
private CachedTile ctile = new CachedTile(){
CachedTile ctile = new CachedTile(){
//nothing.
@Override
protected void changeEntity(Team team, Prov<Building> entityprov, int rotation){
@ -408,6 +408,9 @@ public class MapGenerateDialog extends BaseDialog{
public byte team;
public short block, floor, ore;
GenTile(){
}
public void set(Block floor, Block wall, Block ore, Team team){
this.floor = floor.id;
this.block = wall.id;

View File

@ -22,7 +22,7 @@ import static mindustry.Vars.ui;
public class MapView extends Element implements GestureListener{
private MapEditor editor;
private EditorTool tool = EditorTool.pencil;
EditorTool tool = EditorTool.pencil;
private float offsetx, offsety;
private float zoom = 1f;
private boolean grid = false;
@ -31,11 +31,11 @@ public class MapView extends Element implements GestureListener{
private Rect rect = new Rect();
private Vec2[][] brushPolygons = new Vec2[MapEditor.brushSizes.length][0];
private boolean drawing;
private int lastx, lasty;
private int startx, starty;
private float mousex, mousey;
private EditorTool lastTool;
boolean drawing;
int lastx, lasty;
int startx, starty;
float mousex, mousey;
EditorTool lastTool;
public MapView(MapEditor editor){
this.editor = editor;
@ -204,7 +204,7 @@ public class MapView extends Element implements GestureListener{
zoom = Mathf.clamp(zoom, 0.2f, 20f);
}
private Point2 project(float x, float y){
Point2 project(float x, float y){
float ratio = 1f / ((float)editor.width() / editor.height());
float size = Math.min(width, height);
float sclwidth = size * zoom;

View File

@ -23,7 +23,7 @@ import static mindustry.game.SpawnGroup.*;
public class WaveInfoDialog extends BaseDialog{
private int displayed = 20;
private Seq<SpawnGroup> groups = new Seq<>();
Seq<SpawnGroup> groups = new Seq<>();
private Table table;
private int start = 0;

View File

@ -41,11 +41,10 @@ import static mindustry.Vars.*;
@Component(base = true)
abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, QuadTreeObject, Displayable, Senseable, Controllable{
//region vars and initialization
static final float timeToSleep = 60f * 1;
static final float timeToSleep = 60f * 1, timeToUncontrol = 60f * 6;
static final ObjectSet<Building> tmpTiles = new ObjectSet<>();
static final Seq<Building> tempTileEnts = new Seq<>();
static final Seq<Tile> tempTiles = new Seq<>();
static final float timeToUncontrol = 60f * 6;
static int sleepingEntities = 0;
@Import float x, y, health;

View File

@ -23,14 +23,14 @@ import java.util.*;
import static mindustry.Vars.*;
public class Saves{
private Seq<SaveSlot> saves = new Seq<>();
private @Nullable SaveSlot current;
Seq<SaveSlot> saves = new Seq<>();
@Nullable SaveSlot current;
private @Nullable SaveSlot lastSectorSave;
private AsyncExecutor previewExecutor = new AsyncExecutor(1);
AsyncExecutor previewExecutor = new AsyncExecutor(1);
private boolean saving;
private float time;
private long totalPlaytime;
long totalPlaytime;
private long lastTimestamp;
public Saves(){

View File

@ -23,9 +23,9 @@ public class Tutorial{
private static final int mineCopper = 18;
private static final int blocksToBreak = 3, blockOffset = -6;
private ObjectSet<String> events = new ObjectSet<>();
private ObjectIntMap<Block> blocksPlaced = new ObjectIntMap<>();
private int sentence;
ObjectSet<String> events = new ObjectSet<>();
ObjectIntMap<Block> blocksPlaced = new ObjectIntMap<>();
int sentence;
public TutorialStage stage = TutorialStage.values()[0];
public Tutorial(){

View File

@ -256,5 +256,8 @@ public class FloorRenderer implements Disposable{
/** Maps cache layer ID to cache ID in the batch.
* -1 means that this cache is unoccupied. */
int[] caches = new int[CacheLayer.all.length];
Chunk(){
}
}
}

View File

@ -68,7 +68,7 @@ public class JsonIO{
return json.prettyPrint(in);
}
private static void apply(Json json){
static void apply(Json json){
json.setIgnoreUnknownFields(true);
json.setElementType(Rules.class, "spawns", SpawnGroup.class);
json.setElementType(Rules.class, "loadout", ItemStack.class);

View File

@ -21,7 +21,7 @@ import mindustry.world.blocks.logic.*;
public class LCanvas extends Table{
private static final Color backgroundCol = Pal.darkMetal.cpy().mul(0.1f), gridCol = Pal.darkMetal.cpy().mul(0.5f);
private static Seq<Runnable> postDraw = new Seq<>();
static Seq<Runnable> postDraw = new Seq<>();
private Vec2 offset = new Vec2();
DragLayout statements;

View File

@ -7,7 +7,7 @@ public enum LCategory{
blocks(Pal.accentBack),
control(Color.cyan.cpy().shiftSaturation(-0.6f).mul(0.7f)),
operations(Pal.place.cpy().shiftSaturation(-0.5f).mul(0.7f)),
io(Pal.remove.cpy().shiftSaturation(-0.5f).mul(0.7f));;
io(Pal.remove.cpy().shiftSaturation(-0.5f).mul(0.7f));
public final Color color;

View File

@ -32,7 +32,7 @@ public class Maps{
/** List of all built-in maps. Filenames only. */
private static String[] defaultMapNames = {"maze", "fortress", "labyrinth", "islands", "tendrils", "caldera", "wasteland", "shattered", "fork", "triad", "veins", "glacier"};
/** Maps tagged as PvP */
private static final String[] pvpMaps = {"veins", "glacier"};
static final String[] pvpMaps = {"veins", "glacier"};
/** All maps stored in an ordered array. */
private Seq<Map> maps = new Seq<>();
/** Serializer for meta. */

View File

@ -35,9 +35,9 @@ import java.lang.reflect.*;
@SuppressWarnings("unchecked")
public class ContentParser{
private static final boolean ignoreUnknownFields = true;
private ObjectMap<Class<?>, ContentType> contentTypes = new ObjectMap<>();
ObjectMap<Class<?>, ContentType> contentTypes = new ObjectMap<>();
private ObjectMap<Class<?>, FieldParser> classParsers = new ObjectMap<Class<?>, FieldParser>(){{
ObjectMap<Class<?>, FieldParser> classParsers = new ObjectMap<Class<?>, FieldParser>(){{
put(Effect.class, (type, data) -> field(Fx.class, data));
put(Schematic.class, (type, data) -> {
Object result = fieldOpt(Loadouts.class, data);
@ -105,7 +105,7 @@ public class ContentParser{
private Seq<Runnable> reads = new Seq<>();
private Seq<Runnable> postreads = new Seq<>();
private ObjectSet<Object> toBeParsed = new ObjectSet<>();
private LoadedMod currentMod;
LoadedMod currentMod;
private Content currentContent;
private Json parser = new Json(){
@ -480,7 +480,7 @@ public class ContentParser{
return first != null ? first : Vars.content.getByName(type, currentMod.name + "-" + name);
}
private <T> T make(Class<T> type){
<T> T make(Class<T> type){
try{
Constructor<T> cons = type.getDeclaredConstructor();
cons.setAccessible(true);
@ -515,7 +515,7 @@ public class ContentParser{
}
}
private Object field(Class<?> type, JsonValue value){
Object field(Class<?> type, JsonValue value){
return field(type, value.asString());
}
@ -530,7 +530,7 @@ public class ContentParser{
}
}
private Object fieldOpt(Class<?> type, JsonValue value){
Object fieldOpt(Class<?> type, JsonValue value){
try{
return type.getField(value.asString()).get(null);
}catch(Exception e){
@ -538,7 +538,7 @@ public class ContentParser{
}
}
private void checkNullFields(Object object){
void checkNullFields(Object object){
if(object instanceof Number || object instanceof String || toBeParsed.contains(object)) return;
parser.getFields(object.getClass()).values().toSeq().each(field -> {
@ -559,7 +559,7 @@ public class ContentParser{
readFields(object, jsonMap);
}
private void readFields(Object object, JsonValue jsonMap){
void readFields(Object object, JsonValue jsonMap){
toBeParsed.remove(object);
Class type = object.getClass();
ObjectMap<String, FieldMetadata> fields = parser.getFields(type);
@ -593,7 +593,7 @@ public class ContentParser{
}
/** Tries to resolve a class from a list of potential class names. */
private <T> Class<T> resolve(String base, String... potentials){
<T> Class<T> resolve(String base, String... potentials){
if(!base.isEmpty() && Character.isLowerCase(base.charAt(0))) base = Strings.capitalize(base);
for(String type : potentials){

View File

@ -39,7 +39,7 @@ public class Mods implements Loadable{
private int totalSprites;
private MultiPacker packer;
private Seq<LoadedMod> mods = new Seq<>();
Seq<LoadedMod> mods = new Seq<>();
private ObjectMap<Class<?>, ModMeta> metas = new ObjectMap<>();
private boolean requiresReload, createdAtlas;

View File

@ -23,7 +23,7 @@ public class Scripts implements Disposable{
private final Context context;
private final Scriptable scope;
private boolean errored;
private LoadedMod currentMod = null;
LoadedMod currentMod = null;
public Scripts(){
Time.mark();

View File

@ -265,7 +265,7 @@ public class ArcNetProvider implements NetProvider{
return null;
}
private void handleException(Throwable e){
void handleException(Throwable e){
if(e instanceof ArcNetException){
Core.app.post(() -> net.showError(new IOException("mismatch")));
}else if(e instanceof ClosedChannelException){

View File

@ -15,8 +15,8 @@ import mindustry.ui.Links.*;
import static mindustry.Vars.*;
public class AboutDialog extends BaseDialog{
private Seq<String> contributors = new Seq<>();
private static ObjectSet<String> bannedItems = ObjectSet.with("google-play", "itch.io", "dev-builds", "f-droid");
Seq<String> contributors = new Seq<>();
static ObjectSet<String> bannedItems = ObjectSet.with("google-play", "itch.io", "dev-builds", "f-droid");
public AboutDialog(){
super("@about.button");

View File

@ -8,7 +8,7 @@ import mindustry.graphics.*;
public class ColorPicker extends BaseDialog{
private Cons<Color> cons = c -> {};
private Color current = new Color();
Color current = new Color();
public ColorPicker(){
super("@pickcolor");

View File

@ -20,7 +20,7 @@ import static mindustry.Vars.*;
public class CustomRulesDialog extends BaseDialog{
private Table main;
private Rules rules;
Rules rules;
private Prov<Rules> resetter;
private LoadoutDialog loadoutDialog;
private BaseDialog banDialog;

View File

@ -17,10 +17,10 @@ import java.util.*;
public class FileChooser extends BaseDialog{
private static final Fi homeDirectory = Core.files.absolute(Core.files.getExternalStoragePath());
private static Fi lastDirectory = homeDirectory;
static Fi lastDirectory = homeDirectory;
private Table files;
private Fi directory = lastDirectory;
Fi directory = lastDirectory;
private ScrollPane pane;
private TextField navigation, filefield;
private TextButton ok;
@ -163,7 +163,7 @@ public class FileChooser extends BaseDialog{
return handles;
}
private void updateFiles(boolean push){
void updateFiles(boolean push){
if(push) stack.push(directory);
navigation.setText(directory.toString());

View File

@ -30,15 +30,15 @@ import static mindustry.ui.dialogs.PlanetDialog.Mode.*;
public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
private final FrameBuffer buffer = new FrameBuffer(2, 2, true);
private final PlanetRenderer planets = renderer.planets;
final PlanetRenderer planets = renderer.planets;
private final LaunchLoadoutDialog loadouts = new LaunchLoadoutDialog();
private final Table stable = new Table().background(Styles.black3);
private int launchRange;
private float zoom = 1f, selectAlpha = 1f;
private @Nullable Sector selected, hovered, launchSector;
@Nullable Sector selected, hovered, launchSector;
private CoreBuild launcher;
private Mode mode = look;
Mode mode = look;
private boolean launching;
public PlanetDialog(){
@ -291,7 +291,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
}
//TODO localize
private void updateSelected(){
void updateSelected(){
Sector sector = selected;
if(sector == null){

View File

@ -32,14 +32,14 @@ import java.util.*;
import static mindustry.Vars.*;
public class ResearchDialog extends BaseDialog{
private final float nodeSize = Scl.scl(60f);
private ObjectSet<TechTreeNode> nodes = new ObjectSet<>();
private TechTreeNode root = new TechTreeNode(TechTree.root, null);
private Rect bounds = new Rect();
private ItemsDisplay itemDisplay;
private View view;
final float nodeSize = Scl.scl(60f);
ObjectSet<TechTreeNode> nodes = new ObjectSet<>();
TechTreeNode root = new TechTreeNode(TechTree.root, null);
Rect bounds = new Rect();
ItemsDisplay itemDisplay;
View view;
private ItemSeq items;
ItemSeq items;
public ResearchDialog(){
super("");

View File

@ -74,7 +74,7 @@ public class SchematicsDialog extends BaseDialog{
t.clear();
int i = 0;
String regex = "[`~!@#$%^&*()-_=+[{]}|;:'\",<.>/?]";
String regex = "[`~!@#$%^&*()-_=+{}|;:'\",<.>/?]";
String searchString = search.toLowerCase().replaceAll(regex, " ");
firstSchematic = null;

View File

@ -12,8 +12,8 @@ import mindustry.gen.*;
import static mindustry.Vars.*;
public class BlockConfigFragment extends Fragment{
private Table table = new Table();
private Building configTile;
Table table = new Table();
Building configTile;
@Override
public void build(Group parent){

View File

@ -31,12 +31,12 @@ public class BlockInventoryFragment extends Fragment{
private static final float holdWithdraw = 20f;
private static final float holdShrink = 120f;
private Table table = new Table();
private Building tile;
private float holdTime = 0f, emptyTime;
private boolean holding;
private float[] shrinkHoldTimes = new float[content.items().size];
private Item lastItem;
Table table = new Table();
Building tile;
float holdTime = 0f, emptyTime;
boolean holding;
float[] shrinkHoldTimes = new float[content.items().size];
Item lastItem;
{
Events.on(WorldLoadEvent.class, e -> hide());

View File

@ -16,7 +16,7 @@ import static mindustry.Vars.*;
public class MinimapFragment extends Fragment{
private boolean shown;
private float panx, pany, zoom = 1f, lastZoom = -1;
float panx, pany, zoom = 1f, lastZoom = -1;
private float baseSize = Scl.scl(5f);
private Element elem;

View File

@ -11,7 +11,7 @@ import java.util.*;
public class Tiles implements Iterable<Tile>{
public final int width, height;
private final Tile[] array;
final Tile[] array;
public Tiles(int width, int height){
this.array = new Tile[width * height];
@ -87,6 +87,9 @@ public class Tiles implements Iterable<Tile>{
private class TileIterator implements Iterator<Tile>{
int index = 0;
TileIterator(){
}
@Override
public boolean hasNext(){
return index < array.length;

View File

@ -31,8 +31,8 @@ public class ForceProjector extends Block{
public float basePowerDraw = 0.2f;
public @Load("@-top") TextureRegion topRegion;
private static ForceProjectorEntity paramEntity;
private static final Cons<Shielderc> shieldConsumer = trait -> {
static ForceProjectorEntity paramEntity;
static final Cons<Shielderc> shieldConsumer = trait -> {
if(trait.team() != paramEntity.team && Intersector.isInsideHexagon(paramEntity.x, paramEntity.y, paramEntity.realRadius() * 2f, trait.x(), trait.y())){
trait.absorb();
Fx.absorb.at(trait);

View File

@ -25,8 +25,8 @@ public class Conveyor extends Block implements Autotiler{
private static final float itemSpace = 0.4f;
private static final int capacity = 4;
private final Vec2 tr1 = new Vec2();
private final Vec2 tr2 = new Vec2();
final Vec2 tr1 = new Vec2();
final Vec2 tr2 = new Vec2();
public @Load(value = "@-#1-#2", lengths = {7, 4}) TextureRegion[][] regions;

View File

@ -16,7 +16,7 @@ import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class RepairPoint extends Block{
private static final Rect rect = new Rect();
static final Rect rect = new Rect();
public int timerTarget = timers++;

View File

@ -92,6 +92,9 @@ public class SectorTests{
//assertTrue(total < 75, "Sector spawns too many enemies at wave " + i + " (" + total + ")");
}
assertEquals(1, Team.sharded.cores().size, "Sector must have one core: " + zone);
assertTrue(Team.sharded.core().items.total() < 1000, "Sector must not have starting resources: " + zone);
assertTrue(hasSpawnPoint, "Sector \"" + zone.name + "\" has no spawn points.");
assertTrue(spawner.countSpawns() > 0 || (state.rules.attackMode && state.teams.get(state.rules.waveTeam).hasCore()), "Sector \"" + zone.name + "\" has no enemy spawn points: " + spawner.countSpawns());
}));