Skip to content

Instantly share code, notes, and snippets.

@progval
Last active February 23, 2020 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save progval/12e39b878aa0cf0e31c77a842502dd4f to your computer and use it in GitHub Desktop.
Save progval/12e39b878aa0cf0e31c77a842502dd4f to your computer and use it in GitHub Desktop.
Mindustry log builds
diff --git a/core/src/mindustry/graphics/MinimapRenderer.java b/core/src/mindustry/graphics/MinimapRenderer.java
index c34bb246e..84a8b8d5e 100644
--- a/core/src/mindustry/graphics/MinimapRenderer.java
+++ b/core/src/mindustry/graphics/MinimapRenderer.java
@@ -92,9 +92,13 @@ public class MinimapRenderer implements Disposable{
float rx = !withLabels ? (unit.x - rect.x) / rect.width * w : unit.x / (world.width() * tilesize) * w;
float ry = !withLabels ? (unit.y - rect.y) / rect.width * h : unit.y / (world.height() * tilesize) * h;
- Draw.mixcol(unit.getTeam().color, 1f);
+ Draw.color(unit.getTeam().color);
+ Fill.rect(x + rx, y + ry, Scl.scl(baseSize / 2f), Scl.scl(baseSize / 2f));
+
+ /* reverted, because I prefer colored rectangles to icons
float scale = Scl.scl(1f) / 2f * scaling * 32f;
- Draw.rect(unit.getIconRegion(), x + rx, y + ry, scale, scale, unit.rotation - 90);
+ Draw.rect(unit.getIconRegion(), x + rx, y + ry, scale, scale, unit.rotation - 90);*/
+
Draw.reset();
if(withLabels && unit instanceof Player){
diff --git a/core/src/mindustry/ui/fragments/ChatFragment.java b/core/src/mindustry/ui/fragments/ChatFragment.java
index a6cd4354c..17195fd48 100644
--- a/core/src/mindustry/ui/fragments/ChatFragment.java
+++ b/core/src/mindustry/ui/fragments/ChatFragment.java
@@ -174,6 +174,7 @@ public class ChatFragment extends Table{
if(message.replaceAll(" ", "").isEmpty()) return;
history.insert(1, message);
+ Log.info("sent: {0}", message);
Call.sendChatMessage(message);
}
@@ -227,6 +228,7 @@ public class ChatFragment extends Table{
}
public void addMessage(String message, String sender){
+ Log.info("received: <{0}> {1}", sender, message);
messages.insert(0, new ChatMessage(message, sender));
fadetime += 1f;
diff --git a/core/src/mindustry/world/blocks/BuildBlock.java b/core/src/mindustry/world/blocks/BuildBlock.java
index 19969df25..15e7e88f5 100644
--- a/core/src/mindustry/world/blocks/BuildBlock.java
+++ b/core/src/mindustry/world/blocks/BuildBlock.java
@@ -55,6 +55,11 @@ public class BuildBlock extends Block{
@Remote(called = Loc.server)
public static void onDeconstructFinish(Tile tile, Block block, int builderID){
+ String oldTileString = tile.toString();
+ Player builderPlayer = playerGroup.getByID(builderID);
+ Block tileBlock = tile.block();
+ Log.info("player {0}\n removed block {1}\n over {2}", builderPlayer != null ? builderPlayer.name : "<null>", block != null ? block.toString() : "<null>", oldTileString);
+
Team team = tile.getTeam();
Effects.effect(Fx.breakBlock, tile.drawx(), tile.drawy(), block.size);
Events.fire(new BlockBuildEndEvent(tile, playerGroup.getByID(builderID), team, true));
@@ -66,11 +71,15 @@ public class BuildBlock extends Block{
public static void onConstructFinish(Tile tile, Block block, int builderID, byte rotation, Team team, boolean skipConfig){
if(tile == null) return;
float healthf = tile.entity == null ? 1f : tile.entity.healthf();
+ String oldTileString = tile.toString();
tile.set(block, team, rotation);
if(tile.entity != null){
tile.entity.health = block.health * healthf;
}
//last builder was this local client player, call placed()
+ Player builderPlayer = playerGroup.getByID(builderID);
+ Block tileBlock = tile.block();
+ Log.info("player {0}\n built block {1}\n over {2}", builderPlayer != null ? builderPlayer.name : "<null>", tileBlock != null ? tileBlock.toString() : "<null>", oldTileString);
if(!headless && builderID == player.id){
if(!skipConfig){
tile.block().playerPlaced(tile);
diff --git a/core/src/mindustry/world/blocks/distribution/Sorter.java b/core/src/mindustry/world/blocks/distribution/Sorter.java
index 192c27a7d..31d57f94d 100644
--- a/core/src/mindustry/world/blocks/distribution/Sorter.java
+++ b/core/src/mindustry/world/blocks/distribution/Sorter.java
@@ -45,6 +45,9 @@ public class Sorter extends Block{
@Override
public void configured(Tile tile, Player player, int value){
+ if (player != null) {
+ Log.info("player {0}\tconfigured sorter at {1}\n", player.name, tile != null ? tile.toString() : "<null>");
+ }
tile.<SorterEntity>ent().sortItem = content.item(value);
if(!headless){
renderer.minimap.update(tile);
diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java
index 65de45331..4a69734fa 100644
--- a/core/src/mindustry/world/blocks/power/PowerNode.java
+++ b/core/src/mindustry/world/blocks/power/PowerNode.java
@@ -39,10 +39,15 @@ public class PowerNode extends PowerBlock{
@Override
public void configured(Tile tile, Player player, int value){
+
TileEntity entity = tile.entity;
Tile other = world.tile(value);
boolean contains = entity.power.links.contains(value), valid = other != null && other.entity != null && other.entity.power != null;
+ if (player != null) {
+ Log.info("player {0}\tconfigured ({1}) link between {2} and {3}\n", player.name, contains ? "unlink" : "link", tile != null ? tile.toString() : "<null>", other != null ? other.toString() : "<null>");
+ }
+
if(contains){
//unlink
entity.power.links.removeValue(value);
diff --git a/core/src/mindustry/world/blocks/storage/Unloader.java b/core/src/mindustry/world/blocks/storage/Unloader.java
index bd571efe0..5917393d6 100644
--- a/core/src/mindustry/world/blocks/storage/Unloader.java
+++ b/core/src/mindustry/world/blocks/storage/Unloader.java
@@ -55,6 +55,7 @@ public class Unloader extends Block{
@Override
public void configured(Tile tile, Player player, int value){
+ Log.info("player {0}\tconfigured unloader at {1}\n", player != null ? player.name : "<null>", tile != null ? tile.toString() : "<null>");
tile.entity.items.clear();
tile.<UnloaderEntity>ent().sortItem = content.item(value);
}
diff --git a/core/src/mindustry/world/blocks/units/CommandCenter.java b/core/src/mindustry/world/blocks/units/CommandCenter.java
index daf0d2c1a..6652a8909 100644
--- a/core/src/mindustry/world/blocks/units/CommandCenter.java
+++ b/core/src/mindustry/world/blocks/units/CommandCenter.java
@@ -104,6 +104,7 @@ public class CommandCenter extends Block{
@Override
public void configured(Tile tile, Player player, int value){
+ Log.info("player {0}\tconfigured command-center at {1}\n", player != null ? player.name : "<null>", tile != null ? tile.toString() : "<null>");
UnitCommand command = UnitCommand.all[value];
Effects.effect(((CommandCenter)tile.block()).effect, tile);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment