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

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@@ -661,6 +661,7 @@ block.spore-pine.name = Spore Pine
block.sporerocks.name = Spore Rocks block.sporerocks.name = Spore Rocks
block.rock.name = Rock block.rock.name = Rock
block.snowrock.name = Snow Rock block.snowrock.name = Snow Rock
block.snow-pine.name = Snow Pine
block.shale.name = Shale block.shale.name = Shale
block.shale-boulder.name = Shale Boulder block.shale-boulder.name = Shale Boulder
block.moss.name = Moss block.moss.name = Moss

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 709 B

After

Width:  |  Height:  |  Size: 713 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 676 KiB

After

Width:  |  Height:  |  Size: 676 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 KiB

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 277 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 459 KiB

After

Width:  |  Height:  |  Size: 458 KiB

View File

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

View File

@@ -25,7 +25,7 @@ public class Zones implements ContentList{
alwaysUnlocked = true; alwaysUnlocked = true;
conditionWave = 5; conditionWave = 5;
launchPeriod = 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)){{ desertWastes = new Zone("desertWastes", new DesertWastesGenerator(260, 260)){{
@@ -170,7 +170,7 @@ public class Zones implements ContentList{
launchPeriod = 2; launchPeriod = 2;
zoneRequirements = ZoneRequirement.with(stainedMountains, 40); zoneRequirements = ZoneRequirement.with(stainedMountains, 40);
blockRequirements = new Block[]{Blocks.thermalGenerator}; 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) nuclearComplex = new Zone("nuclearComplex", new MapGenerator("nuclearProductionComplex", 1)
@@ -193,7 +193,7 @@ public class Zones implements ContentList{
launchPeriod = 2; launchPeriod = 2;
zoneRequirements = ZoneRequirement.with(nuclearComplex, 40); zoneRequirements = ZoneRequirement.with(nuclearComplex, 40);
blockRequirements = new Block[]{Blocks.thermalGenerator}; 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; if(overlayID() == overlay) return;
op(OpType.overlay, this.overlay); op(OpType.overlay, this.overlay.id);
super.setOverlayID(overlay); super.setOverlayID(overlay);
} }

View File

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

View File

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

View File

@@ -15,7 +15,7 @@ import io.anuke.mindustry.ui.dialogs.FileChooser;
import org.lwjgl.util.tinyfd.TinyFileDialogs; import org.lwjgl.util.tinyfd.TinyFileDialogs;
import java.net.NetworkInterface; import java.net.NetworkInterface;
import java.util.Enumeration; import java.util.*;
import static io.anuke.mindustry.Vars.*; import static io.anuke.mindustry.Vars.*;

View File

@@ -1,8 +1,8 @@
include 'desktop', 'core', 'net', 'server', 'ios', 'annotations', 'tools', 'tests' include 'desktop', 'core', 'net', 'server', 'ios', 'annotations', 'tools', 'tests'
def use = { String name, String path -> def use = { String name ->
include(name) include(name)
project(name).projectDir = new File(settingsDir, path) project(name).projectDir = new File(settingsDir, "../${name.substring(1).replace(":", "/")}")
} }
Properties properties = new Properties() Properties properties = new Properties()
@@ -21,21 +21,21 @@ if(new File(settingsDir, 'local.properties').exists()){
if(!hasProperty("release")){ if(!hasProperty("release")){
if(new File(settingsDir, '../Arc').exists()){ if(new File(settingsDir, '../Arc').exists()){
use(':Arc', '../Arc') use(':Arc')
use(':Arc:arc-core', '../Arc/arc-core') use(':Arc:arc-core')
use(':Arc:extensions', '../Arc/extensions') use(':Arc:extensions')
use(':Arc:extensions:freetype', '../Arc/extensions/freetype') use(':Arc:extensions:freetype')
use(':Arc:extensions:recorder', '../Arc/extensions/recorder') use(':Arc:extensions:recorder')
use(':Arc:extensions:arcnet', '../Arc/extensions/arcnet') use(':Arc:extensions:arcnet')
use(':Arc:extensions:packer', '../Arc/extensions/packer') use(':Arc:extensions:packer')
use(':Arc:backends', '../Arc/backends') use(':Arc:backends')
use(':Arc:backends:backend-lwjgl3', '../Arc/backends/backend-lwjgl3') use(':Arc:backends:backend-lwjgl3')
use(':Arc:backends:backend-android', '../Arc/backends/backend-android') use(':Arc:backends:backend-android')
use(':Arc:backends:backend-robovm', '../Arc/backends/backend-robovm') use(':Arc:backends:backend-robovm')
use(':Arc:backends:backend-headless', '../Arc/backends/backend-headless') use(':Arc:backends:backend-headless')
} }
if(new File(settingsDir, '../debug').exists()){ if(new File(settingsDir, '../debug').exists()){
use(':debug', '../debug') use(':debug')
} }
}else{ }else{
println("Not including local repositories.") println("Not including local repositories.")