Cleanup & bugfixes

This commit is contained in:
Anuken 2021-01-15 11:16:08 -05:00
parent 593a7b060c
commit a342a7d638
4 changed files with 20 additions and 32 deletions

View File

@ -81,13 +81,6 @@ public class Logic implements ApplicationListener{
state.wavetime = state.rules.waveSpacing; state.wavetime = state.rules.waveSpacing;
SectorDamage.applyCalculatedDamage(); SectorDamage.applyCalculatedDamage();
//make sure damaged buildings are counted
for(Tile tile : world.tiles){
if(tile.build != null && tile.build.damaged()){
indexer.notifyTileDamaged(tile.build);
}
}
} }
//reset values //reset values

View File

@ -569,7 +569,7 @@ public class LExecutor{
int address = exec.numi(position); int address = exec.numi(position);
Building from = exec.building(target); Building from = exec.building(target);
if(from instanceof MemoryBuild mem){ if(from instanceof MemoryBuild mem && from.team == exec.team){
exec.setnum(output, address < 0 || address >= mem.memory.length ? 0 : mem.memory[address]); exec.setnum(output, address < 0 || address >= mem.memory.length ? 0 : mem.memory[address]);
} }
@ -593,7 +593,7 @@ public class LExecutor{
int address = exec.numi(position); int address = exec.numi(position);
Building from = exec.building(target); Building from = exec.building(target);
if(from instanceof MemoryBuild mem){ if(from instanceof MemoryBuild mem && from.team == exec.team){
if(address >= 0 && address < mem.memory.length){ if(address >= 0 && address < mem.memory.length){
mem.memory[address] = exec.num(value); mem.memory[address] = exec.num(value);
@ -620,7 +620,7 @@ public class LExecutor{
Object target = exec.obj(from); Object target = exec.obj(from);
Object sense = exec.obj(type); Object sense = exec.obj(type);
//TODO should remote enemy buildings be senseable? //note that remote units/buildings can be sensed as well
if(target instanceof Senseable se){ if(target instanceof Senseable se){
if(sense instanceof Content){ if(sense instanceof Content){
exec.setnum(to, se.sense(((Content)sense))); exec.setnum(to, se.sense(((Content)sense)));
@ -857,8 +857,7 @@ public class LExecutor{
//graphics on headless servers are useless. //graphics on headless servers are useless.
if(Vars.headless) return; if(Vars.headless) return;
Building build = exec.building(target); if(exec.building(target) instanceof LogicDisplayBuild d && d.team == exec.team){
if(build instanceof LogicDisplayBuild d){
if(d.commands.size + exec.graphicsBuffer.size < maxDisplayBuffer){ if(d.commands.size + exec.graphicsBuffer.size < maxDisplayBuffer){
for(int i = 0; i < exec.graphicsBuffer.size; i++){ for(int i = 0; i < exec.graphicsBuffer.size; i++){
d.commands.addLast(exec.graphicsBuffer.items[i]); d.commands.addLast(exec.graphicsBuffer.items[i]);
@ -920,8 +919,7 @@ public class LExecutor{
@Override @Override
public void run(LExecutor exec){ public void run(LExecutor exec){
Building build = exec.building(target); if(exec.building(target) instanceof MessageBuild d && d.team == exec.team){
if(build instanceof MessageBuild d){
d.message.setLength(0); d.message.setLength(0);
d.message.append(exec.textBuffer, 0, Math.min(exec.textBuffer.length(), maxTextBuffer)); d.message.append(exec.textBuffer, 0, Math.min(exec.textBuffer.length(), maxTextBuffer));

View File

@ -24,7 +24,7 @@ public class SectorDamage{
public static final int maxRetWave = 40, maxWavesSimulated = 50; public static final int maxRetWave = 40, maxWavesSimulated = 50;
//direct damage is for testing only //direct damage is for testing only
private static final boolean direct = false, rubble = true; private static final boolean rubble = true;
/** @return calculated capture progress of the enemy */ /** @return calculated capture progress of the enemy */
public static float getDamage(SectorInfo info){ public static float getDamage(SectorInfo info){
@ -225,7 +225,6 @@ public class SectorDamage{
//create sparse tile array for fast range query //create sparse tile array for fast range query
int sparseSkip = 5, sparseSkip2 = 3; int sparseSkip = 5, sparseSkip2 = 3;
//TODO if this is slow, use a quadtree
Seq<Tile> sparse = new Seq<>(path.size / sparseSkip + 1); Seq<Tile> sparse = new Seq<>(path.size / sparseSkip + 1);
Seq<Tile> sparse2 = new Seq<>(path.size / sparseSkip2 + 1); Seq<Tile> sparse2 = new Seq<>(path.size / sparseSkip2 + 1);
@ -485,23 +484,21 @@ public class SectorDamage{
if(other.build != null && other.team() != state.rules.waveTeam){ if(other.build != null && other.team() != state.rules.waveTeam){
resultDamage -= other.build.health(); resultDamage -= other.build.health();
if(direct){ other.build.health -= currDamage;
other.build.damage(currDamage); //don't kill the core!
}else{ //indirect damage happens at game load time if(other.block() instanceof CoreBlock) other.build.health = Math.max(other.build.health, 1f);
other.build.health -= currDamage;
//don't kill the core!
if(other.block() instanceof CoreBlock) other.build.health = Math.max(other.build.health, 1f);
//remove the block when destroyed //remove the block when destroyed
if(other.build.health < 0){ if(other.build.health < 0){
//rubble //rubble
if(rubble && !other.floor().solid && !other.floor().isLiquid && Mathf.chance(0.4)){ if(rubble && !other.floor().solid && !other.floor().isLiquid && Mathf.chance(0.4)){
Effect.rubble(other.build.x, other.build.y, other.block().size); Effect.rubble(other.build.x, other.build.y, other.block().size);
}
other.build.addPlan(false);
other.remove();
} }
other.build.addPlan(false);
other.remove();
}else{
indexer.notifyTileDamaged(other.build);
} }
}else if(other.solid() && !other.synthetic()){ //skip damage propagation through solid blocks }else if(other.solid() && !other.synthetic()){ //skip damage propagation through solid blocks

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=f89e6a465fe9d139bd192960c2ebdff33c2af86a archash=25dcd2f7664f3c5a669447fdf8dffaea7e65fe0d