Fixed unit tests / Fixed some major tile loading flaws

This commit is contained in:
Anuken
2019-07-23 23:29:48 -04:00
parent 52374ce06d
commit c80be4940f
17 changed files with 3206 additions and 3165 deletions

View File

@@ -37,7 +37,7 @@ public class Blocks implements ContentList{
//environment
air, spawn, deepwater, water, taintedWater, tar, stone, craters, charr, sand, darksand, ice, snow, darksandTaintedWater,
holostone, rocks, sporerocks, icerocks, cliffs, sporePine, pine, shrubs, whiteTree, whiteTreeDead, sporeCluster,
holostone, rocks, sporerocks, icerocks, cliffs, sporePine, snowPine, pine, shrubs, whiteTree, whiteTreeDead, sporeCluster,
iceSnow, sandWater, darksandWater, duneRocks, sandRocks, moss, sporeMoss, shale, shaleRocks, shaleBoulder, grass, salt,
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor5, ignarock, magmarock, hotrock, snowrocks, rock, snowrock, saltRocks,
darkPanel1, darkPanel2, darkPanel3, darkPanel4, darkPanel5, darkPanel6, darkMetal,
@@ -315,6 +315,10 @@ public class Blocks implements ContentList{
variants = 0;
}};
snowPine = new StaticTree("snow-pine"){{
variants = 0;
}};
pine = new StaticTree("pine"){{
variants = 0;
}};

View File

@@ -25,7 +25,7 @@ public class Zones implements ContentList{
alwaysUnlocked = true;
conditionWave = 5;
launchPeriod = 5;
resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.sand};
resources = new Item[]{Items.copper, Items.scrap, Items.lead};
}};
desertWastes = new Zone("desertWastes", new DesertWastesGenerator(260, 260)){{
@@ -170,7 +170,7 @@ public class Zones implements ContentList{
launchPeriod = 2;
zoneRequirements = ZoneRequirement.with(stainedMountains, 40);
blockRequirements = new Block[]{Blocks.thermalGenerator};
resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.coal, Items.titanium, Items.sand, Items.thorium};
resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.coal, Items.sand};
}};
nuclearComplex = new Zone("nuclearComplex", new MapGenerator("nuclearProductionComplex", 1)
@@ -193,7 +193,7 @@ public class Zones implements ContentList{
launchPeriod = 2;
zoneRequirements = ZoneRequirement.with(nuclearComplex, 40);
blockRequirements = new Block[]{Blocks.thermalGenerator};
resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.coal, Items.titanium, Items.sand, Items.thorium};
resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.coal, Items.titanium, Items.thorium};
}};
}
}

View File

@@ -99,7 +99,7 @@ public class EditorTile extends Tile{
}
if(overlayID() == overlay) return;
op(OpType.overlay, this.overlay);
op(OpType.overlay, this.overlay.id);
super.setOverlayID(overlay);
}

View File

@@ -1,17 +1,14 @@
package io.anuke.mindustry.io;
import io.anuke.arc.collection.*;
import io.anuke.arc.util.Log;
import io.anuke.arc.util.Time;
import io.anuke.arc.util.io.CounterInputStream;
import io.anuke.mindustry.entities.Entities;
import io.anuke.mindustry.entities.EntityGroup;
import io.anuke.mindustry.entities.traits.Entity;
import io.anuke.mindustry.entities.traits.SaveTrait;
import io.anuke.arc.util.*;
import io.anuke.arc.util.io.*;
import io.anuke.mindustry.entities.*;
import io.anuke.mindustry.entities.traits.*;
import io.anuke.mindustry.game.*;
import io.anuke.mindustry.gen.BrokenBlock;
import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.type.ContentType;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.maps.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.*;
import java.io.*;
@@ -270,8 +267,6 @@ public abstract class SaveVersion extends SaveFileReader{
}
content.setTemporaryMapper(map);
remapContent();
}
public void writeContentHeader(DataOutput stream) throws IOException{

View File

@@ -1,14 +1,14 @@
package io.anuke.mindustry.world;
import io.anuke.arc.collection.Array;
import io.anuke.arc.function.Consumer;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.collection.*;
import io.anuke.arc.function.*;
import io.anuke.arc.math.*;
import io.anuke.arc.math.geom.*;
import io.anuke.mindustry.content.Blocks;
import io.anuke.mindustry.entities.traits.TargetTrait;
import io.anuke.mindustry.entities.type.TileEntity;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.content.*;
import io.anuke.mindustry.entities.traits.*;
import io.anuke.mindustry.entities.type.*;
import io.anuke.mindustry.game.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.blocks.*;
import io.anuke.mindustry.world.modules.*;
@@ -22,25 +22,24 @@ public class Tile implements Position, TargetTrait{
public short x, y;
protected Block block;
protected Floor floor;
protected Floor overlay;
/** Rotation, 0-3. Also used to store offload location, in which case it can be any number.*/
protected byte rotation;
/** Team ordinal. */
protected byte team;
/** Ore that is on top of this (floor) block. */
protected short overlay = 0;
public Tile(int x, int y){
this.x = (short)x;
this.y = (short)y;
block = floor = (Floor)Blocks.air;
block = floor = overlay = (Floor)Blocks.air;
}
public Tile(int x, int y, int floor, int overlay, int wall){
this.x = (short)x;
this.y = (short)y;
this.floor = (Floor)content.block(floor);
this.overlay = (Floor)content.block(overlay);
this.block = content.block(wall);
this.overlay = (short)overlay;
//update entity and create it if needed
changed();
@@ -114,7 +113,7 @@ public class Tile implements Position, TargetTrait{
}
public Floor overlay(){
return (Floor)content.block(overlay);
return overlay;
}
@SuppressWarnings("unchecked")
@@ -157,12 +156,12 @@ public class Tile implements Position, TargetTrait{
/**This resets the overlay!*/
public void setFloor(Floor type){
this.floor = type;
this.overlay = 0;
this.overlay = (Floor)Blocks.air;
}
/** Sets the floor, preserving overlay.*/
public void setFloorUnder(Floor floor){
Block overlay = overlay();
Block overlay = this.overlay;
setFloor(floor);
setOverlay(overlay);
}
@@ -176,7 +175,7 @@ public class Tile implements Position, TargetTrait{
}
public short overlayID(){
return overlay;
return overlay.id;
}
public short blockID(){
@@ -188,7 +187,7 @@ public class Tile implements Position, TargetTrait{
}
public void setOverlayID(short ore){
this.overlay = ore;
this.overlay = (Floor)content.block(ore);
}
public void setOverlay(Block block){
@@ -304,7 +303,7 @@ public class Tile implements Position, TargetTrait{
}
public Item drop(){
return overlay == 0 || ((Floor)content.block(overlay)).itemDrop == null ? floor.itemDrop : ((Floor)content.block(overlay)).itemDrop;
return overlay == Blocks.air || overlay.itemDrop == null ? floor.itemDrop : overlay.itemDrop;
}
public void updateOcclusion(){
@@ -431,6 +430,6 @@ public class Tile implements Position, TargetTrait{
@Override
public String toString(){
return floor.name + ":" + block.name + ":" + content.block(overlay) + "[" + x + "," + y + "] " + "entity=" + (entity == null ? "null" : (entity.getClass())) + ":" + getTeam();
return floor.name + ":" + block.name + ":" + overlay + "[" + x + "," + y + "] " + "entity=" + (entity == null ? "null" : (entity.getClass())) + ":" + getTeam();
}
}