Skip to content

Commit

Permalink
- Improve the config rate limit by including more packets
Browse files Browse the repository at this point in the history
- Cleanup
  • Loading branch information
buthed010203 committed Aug 20, 2023
1 parent a1062e9 commit 3e30d09
Show file tree
Hide file tree
Showing 24 changed files with 38 additions and 58 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ buildscript{
}

plugins{
id "org.jetbrains.kotlin.jvm" version "1.8.21"
id "org.jetbrains.kotlin.kapt" version "1.8.21" apply false
id "org.jetbrains.kotlin.jvm" version "1.9.0"
id "org.jetbrains.kotlin.kapt" version "1.9.0" apply false
}

allprojects{
Expand Down Expand Up @@ -359,7 +359,7 @@ project(":core"){
if(localArc && debugged()) api arcModule("extensions:recorder")
if(localArc) api arcModule(":extensions:packer")

implementation "org.jetbrains.kotlin:kotlin-reflect:1.8.21"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.9.0"
// implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0" Unused, removed to reduce jar size

compileOnly files("../bouncycastle/bcprov-jdk15on.jar")
Expand Down Expand Up @@ -418,7 +418,7 @@ project(":tests"){

dependencies{
testImplementation project(":core")
testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.8.21"
testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.9.0"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.7.1"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.7.1"
testImplementation arcModule("backends:backend-headless")
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import java.util.*

plugins {
kotlin("jvm") version "1.8.21"
kotlin("jvm") version "1.9.0"
}

repositories {
Expand Down
1 change: 0 additions & 1 deletion core/assets/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ client.stoppath.continue = Continue pathing
client.stoppath.stop = Stop pathing
client.toggleunits = [accent][[{0}][] to toggle unit visibility
client.toggleairunits = [accent][SHIFT + {0}][] to toggle air unit visibility
client.togglefog = [accent][CTRL + {0}][] to toggle hiding fog
client.toggleturrets = [accent][{0}][] to toggle turret visibility
client.toggleenemyturrets = [accent][{0}][] to toggle enemy turret visibility
client.toggleallyturrets = [accent][ALT + {0}][] to toggle ally turret visibility
Expand Down
1 change: 0 additions & 1 deletion core/assets/bundles/bundle_uk_UA.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ client.stoppath.continue = Продовжити слідування шляхо
client.stoppath.stop = Зупинити слідування шляхом
client.toggleunits = [accent][[{0}][] для перемикання видимості одиниці
client.toggleairunits = [accent][SHIFT + {0}][] для перемикання видимості повітряних одиниць
client.togglefog = [accent][CTRL + {0}][] щоб прибрати туман війни
client.toggleturrets = [accent][{0}][] для перемикання видимості вежі
client.toggleenemyturrets = [accent][{0}][] щоб перемкнути видимість радіус дії ворожої вежі
client.toggleallyturrets = [accent][ALT + {0}][] щоб увімкнути видимість союзних турелей
Expand Down
1 change: 0 additions & 1 deletion core/assets/bundles/bundle_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ client.stoppath.continue = 继续路径
client.stoppath.stop = 停止路径
client.toggleunits = [accent][[{0}][]切换单位是否可视
client.toggleairunits = [accent][Shift + {0}][]切换空中单位是否可视
client.togglefog = [accent][CTRL + {0}][]切换隐藏的迷雾
client.toggleturrets = [accent][{0}][]切换炮塔是否可视
client.toggleenemyturrets = [accent][[{0}][]切换敌人炮塔是否可视
client.toggleallyturrets = [accent][ALT + {0}][]切换己方炮塔是否可视
Expand Down
1 change: 0 additions & 1 deletion core/assets/features
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
* Ctrl {show_turret_ranges} - Inverted turret ranges. If you're an air unit, this shows turrets which target ground units and vice versa.
* Alt {show_turret_ranges} - Show your team's turret ranges.
* Shift {hide_blocks} - Hides build plans.
* Ctrl {invisible_units} - Hides fog.
* Shift {pause_building} - Switches to the frozen queue.
* Ctrl {pause_building} - Moves all frozen plans into build queue.
* Shift {deselect} - Freezes/Unfreezes build plans. Useful for prioritizing which build plans to execute first.
Expand Down
3 changes: 1 addition & 2 deletions core/src/mindustry/client/ClientVars.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public class ClientVars {
hidingBlocks, hidingPlans,
dispatchingBuildPlans,
showingOverdrives,
showingMassDrivers,
hidingFog;
showingMassDrivers;
@NotNull public static Seq<OverdriveProjector.OverdriveBuild> overdrives = new Seq<>(); // For whatever reason the stupid allBuildings method hates me so im just not using it FINISHME: Replace this by just expanding block clipsize and drawing a circle in the draw method rather than using this
@NotNull public static Seq<MassDriver.MassDriverBuild> massDrivers = new Seq<>(); // FINISHME: this too.
@NotNull public static Seq<PayloadMassDriver.PayloadDriverBuild> payloadMassDrivers = new Seq<>(); // i literally just copypasted the code
Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/client/utils/ServerUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ enum class Server( // FINISHME: This is horrible. Why have I done this?

override fun adminui() = ClientVars.rank >= 5
},
phoenix("Phoenix Network", MapVote(), Cmd("/w"), Cmd("/rtv"), Cmd("/freeze", 9), votekickString = "Type [cyan]/vote y"),
phoenix("Phoenix Network", null, Cmd("/w"), Cmd("/rtv"), Cmd("/freeze", 9), votekickString = "Type [cyan]/vote y"),
korea("Korea", ghost = true),
fish("Fish", null, Cmd("/msg")),
darkdustry("Darkdustry")
Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/core/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public void draw(){
}

Draw.draw(Layer.overlayUI, overlays::drawTop);
if(state.rules.fog && !hidingFog) Draw.draw(Layer.fogOfWar, fog::drawFog);
if(state.rules.fog) Draw.draw(Layer.fogOfWar, fog::drawFog);
Draw.draw(Layer.space, this::drawLanding);

Events.fire(Trigger.drawOver);
Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/core/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public float getDarkness(int x, int y){
int edgeBlend = 2;
int edgeDst;

if(!state.rules.limitMapArea || hidingFog){
if(!state.rules.limitMapArea){
edgeDst = Math.min(x, Math.min(y, Math.min(-(x - (tiles.width - 1)), -(y - (tiles.height - 1)))));
}else{
edgeDst =
Expand Down
4 changes: 2 additions & 2 deletions core/src/mindustry/entities/comp/BuildingComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public boolean isDiscovered(Team viewer){
return false;
}

if(viewer == null || !state.rules.staticFog || !state.rules.fog || hidingFog){
if(viewer == null || !state.rules.staticFog || !state.rules.fog){
return true;
}
if(block.size <= 2){
Expand Down Expand Up @@ -2006,7 +2006,7 @@ public void setProp(UnlockableContent content, double value){
@Replace
@Override
public boolean inFogTo(Team viewer){
if(team == viewer || !state.rules.fog || hidingFog) return false;
if(team == viewer || !state.rules.fog) return false;

int size = block.size, of = block.sizeOffset, tx = tile.x, ty = tile.y;

Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/entities/comp/UnitComp.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void handleSyncHidden(){
@Override
@Replace
public boolean inFogTo(Team viewer){
if(this.team == viewer || !state.rules.fog || hidingFog) return false;
if(this.team == viewer || !state.rules.fog) return false;

if(hitSize <= 16f){
return !fogControl.isVisible(viewer, x, y);
Expand Down
5 changes: 2 additions & 3 deletions core/src/mindustry/game/FogControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.io.*;

import static mindustry.Vars.*;
import static mindustry.client.ClientVars.*;

public final class FogControl implements CustomChunk{
private static volatile int ww, wh;
Expand Down Expand Up @@ -102,7 +101,7 @@ public FogControl(){
}

public boolean isDiscovered(Team team, int x, int y){
if(!state.rules.staticFog || !state.rules.fog || hidingFog || team == null || team.isAI()) return true;
if(!state.rules.staticFog || !state.rules.fog || team == null || team.isAI()) return true;

var data = getDiscovered(team);
if(data == null) return false;
Expand All @@ -115,7 +114,7 @@ public boolean isVisible(Team team, float x, float y){
}

public boolean isVisibleTile(Team team, int x, int y){
if(!state.rules.fog|| hidingFog || team == null || team.isAI()) return true;
if(!state.rules.fog || team == null || team.isAI()) return true;

var data = data(team);
if(data == null) return false;
Expand Down
15 changes: 7 additions & 8 deletions core/src/mindustry/graphics/BlockRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public BlockRenderer(){
shadowEvents.clear();
updateFloors.clear();
lastCamY = lastCamX = -99; //invalidate camera position so blocks get updated
hadMapLimit = state.rules.limitMapArea && !hidingFog;
hadMapLimit = state.rules.limitMapArea;

shadows.getTexture().setFilter(TextureFilter.linear, TextureFilter.linear);
shadows.resize(world.width(), world.height());
Expand All @@ -84,7 +84,6 @@ public BlockRenderer(){

var playerTeam = player.team();
var playerTeamFlag = 1L << playerTeam.id;
var noFog = !state.rules.fog || hidingFog;
for(Tile tile : world.tiles){
recordIndex(tile);

Expand All @@ -99,7 +98,7 @@ public BlockRenderer(){
updateFloors.add(new UpdateRenderState(tile, tileOverlay));
}

if(tileBuild != null && (tile.team() == playerTeam || noFog || (tileBuild.visibleFlags & playerTeamFlag) != 0)){
if(tileBuild != null && (tile.team() == playerTeam || !state.rules.fog || (tileBuild.visibleFlags & playerTeamFlag) != 0)){
tileBuild.wasVisible = true;
}

Expand All @@ -117,7 +116,7 @@ public BlockRenderer(){

//sometimes darkness gets disabled.
Events.run(Trigger.newGame, () -> {
if(hadMapLimit && (!state.rules.limitMapArea || hidingFog)){
if(hadMapLimit && !state.rules.limitMapArea){
updateDarkness();
renderer.minimap.updateAll();
}
Expand Down Expand Up @@ -161,18 +160,18 @@ public void updateDarkness(){
dark.begin();

//fill darkness with black when map area is limited
Core.graphics.clear(state.rules.limitMapArea && !hidingFog ? Color.black : Color.white);
Core.graphics.clear(state.rules.limitMapArea ? Color.black : Color.white);
Draw.proj().setOrtho(0, 0, dark.getWidth(), dark.getHeight());

//clear out initial starting area
if(state.rules.limitMapArea && !hidingFog){
if(state.rules.limitMapArea){
Draw.color(Color.white);
Fill.crect(state.rules.limitX, state.rules.limitY, state.rules.limitWidth, state.rules.limitHeight);
}

for(Tile tile : world.tiles){
//skip lighting outside rect
if(state.rules.limitMapArea && !hidingFog && !Rect.contains(state.rules.limitX, state.rules.limitY, state.rules.limitWidth - 1, state.rules.limitHeight - 1, tile.x, tile.y)){
if(state.rules.limitMapArea && !Rect.contains(state.rules.limitX, state.rules.limitY, state.rules.limitWidth - 1, state.rules.limitHeight - 1, tile.x, tile.y)){
continue;
}

Expand Down Expand Up @@ -306,7 +305,7 @@ public void drawShadows(){
for(Tile tile : shadowEvents){
if(tile == null) continue;
//draw white/shadow color depending on blend
Draw.color((!tile.block().hasShadow || (state.rules.fog && !hidingFog && tile.build != null && !tile.build.wasVisible)) ? Color.white : blendShadowColor);
Draw.color((!tile.block().hasShadow || (state.rules.fog && tile.build != null && !tile.build.wasVisible)) ? Color.white : blendShadowColor);
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
}

Expand Down
3 changes: 1 addition & 2 deletions core/src/mindustry/graphics/EnvRenderers.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import mindustry.world.meta.*;

import static mindustry.Vars.*;
import static mindustry.client.ClientVars.*;

public class EnvRenderers{

Expand Down Expand Up @@ -99,7 +98,7 @@ public static void init(){
}

//TODO layer looks better? should not be conditional
Draw.z(state.rules.fog && !hidingFog ? Layer.fogOfWar + 1 : Layer.weather - 1);
Draw.z(state.rules.fog ? Layer.fogOfWar + 1 : Layer.weather - 1);
Weather.drawNoiseLayers(tex, Color.scarlet, 1000f, 0.24f, 0.4f, 1f, 1f, 0f, 4, -1.3f, 0.7f, 0.8f, 0.9f);
Draw.reset();
});
Expand Down
5 changes: 2 additions & 3 deletions core/src/mindustry/graphics/MinimapRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import mindustry.world.*;

import static mindustry.Vars.*;
import static mindustry.client.ClientVars.*;

public class MinimapRenderer{
private static final float baseSize = 16f, updateInterval = 2f;
Expand Down Expand Up @@ -175,7 +174,7 @@ public void drawEntities(float x, float y, float w, float h, float scaling, bool

Draw.reset();

if(state.rules.fog && !hidingFog){
if(state.rules.fog){
if(fullView){
float z = zoom;
//max zoom out fixes everything, somehow?
Expand Down Expand Up @@ -362,7 +361,7 @@ public void updateUnitArray(){

private Block realBlock(Tile tile){
//TODO doesn't work properly until player goes and looks at block
return tile.build == null ? tile.block() : state.rules.fog && !hidingFog && !tile.build.wasVisible ? Blocks.air : tile.block();
return tile.build == null ? tile.block() : state.rules.fog && !tile.build.wasVisible ? Blocks.air : tile.block();
}

private int colorFor(Tile tile){
Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/graphics/OverlayRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void drawTop(){
}
}

if(Core.settings.getBool("indicators") && (!state.rules.fog || hidingFog)){
if(Core.settings.getBool("indicators") && !state.rules.fog){
Groups.unit.each(unit -> {
if(!unit.isLocal() && unit.team != player.team() && !rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f)
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(unit.x, unit.y)){
Expand Down
9 changes: 1 addition & 8 deletions core/src/mindustry/input/DesktopInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ public void buildUI(Group group){
if(isBuildingIgnoreNetworking() || dispatchingBuildPlans){
str.append("\n").append(bundle.format(dispatchingBuildPlans ? "client.stopsendbuildplans" : "client.sendbuildplans", keybinds.get(Binding.send_build_queue).key.toString()));
}
if (hidingFog){
str.append("\n").append(bundle.format("client.togglefog", keybinds.get(Binding.invisible_units).key.toString()));
}
if(hidingUnits || hidingAirUnits){
str.append("\n").append(bundle.format("client.toggleunits", keybinds.get(Binding.invisible_units).key.toString()));
str.append("\n").append(bundle.format("client.toggleairunits", keybinds.get(Binding.invisible_units).key.toString()));
Expand Down Expand Up @@ -305,11 +302,7 @@ public void update(){
}

if(input.keyTap(Binding.invisible_units) && scene.getKeyboardFocus() == null){
if (input.ctrl()) {
hidingFog = !hidingFog;
renderer.updateAllDarkness();
}
else if (input.shift()) hidingAirUnits = !hidingAirUnits;
if (input.shift()) hidingAirUnits = !hidingAirUnits;
else hidingUnits = !hidingUnits;
}

Expand Down
11 changes: 4 additions & 7 deletions core/src/mindustry/ui/dialogs/PausedDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void rebuild(){
});

if(!mobile){
float dw = 220f;
float dw = 230f;
cont.defaults().width(dw).height(55).pad(5f);

cont.button("@objective", Icon.info, () -> ui.fullText.show("@objective", state.rules.sector.preset.description))
Expand All @@ -56,7 +56,9 @@ void rebuild(){
}else{
ui.host.show();
}
}).disabled(b -> !((steam && net.server()) || !net.active())).colspan(2).width(dw * 2 + 10f).update(e -> e.setText(net.server() && steam ? "@invitefriends" : "@hostserver"));
}).disabled(b -> !((steam && net.server()) || !net.active())).update(e -> e.setText(net.server() && steam ? "@invitefriends" : "@hostserver"));
// FINISHME: Enable while not hosting but make this host when clicked (or add a tooltip or smth)
cont.button("@client.claj.manage", Icon.link, () -> ui.clajManager.show()).tooltip("@client.claj.info").disabled(f -> !net.server());

cont.row();

Expand All @@ -65,11 +67,6 @@ void rebuild(){

cont.row();

// FINISHME: Enable while not hosting but make this host when clicked (or add a tooltip or smth)
cont.button("@client.claj.manage", Icon.link, () -> ui.clajManager.show()).tooltip("@client.claj.info").colspan(2).width(dw + 10f).disabled(f -> !net.server());

cont.row();

cont.button("@client.keyshare", Icon.lock, () -> new TLSKeyDialog().show()).tooltip("@client.keysharedescription");
cont.button("@quit", Icon.exit, this::showQuitConfirm).update(s -> s.setText(control.saves.getCurrent() != null && control.saves.getCurrent().isAutosave() ? "@save.quit" : "@quit"));

Expand Down
2 changes: 1 addition & 1 deletion core/src/mindustry/ui/dialogs/SettingsMenuDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ public void rebuild(){
lastRebuild = Core.graphics.getFrameId();
boolean hasFocus = searchBar.hasKeyboard();
clearChildren();
// TODO inefficient. And rebuild() is also called every. single. setting.
// FINISHME: Inefficient
add(searchBarTable).fillX().padBottom(4);
row();

Expand Down
10 changes: 5 additions & 5 deletions core/src/mindustry/ui/fragments/ChatFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ private void sendMessage(){
}
message = messageBuild.toString();

handleClientCommand(message);
}

public static CommandHandler.CommandResponse handleClientCommand(String message){
//check if it's a command
CommandHandler.CommandResponse response = ClientVars.clientCommandHandler.handleMessage(message, player);
if(response.type == CommandHandler.ResponseType.noCommand){ //no command to handle
Expand All @@ -424,9 +428,7 @@ private void sendMessage(){
if (!message.startsWith(netServer.clientCommands.getPrefix())) { // Only fire when not running any command
Events.fire(new EventType.SendChatMessageEvent(msg));
}
return;
}else{

//a command was sent, now get the output
if(response.type != CommandHandler.ResponseType.valid){
String text;
Expand Down Expand Up @@ -457,11 +459,9 @@ private void sendMessage(){

player.sendMessage(text);
}
return;
}



return response;
}

public void toggle(){
Expand Down
1 change: 0 additions & 1 deletion core/src/mindustry/ui/fragments/HudFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ public void build(Group parent){
modeIcon(st, () -> hidingAirUnits, () -> hidingAirUnits ^= true, new SlashTextureRegionDrawable(Icon.planeOutline.getRegion(), new Color(1f, 1f, 1f, a)), "Hiding Air Units", Binding.invisible_units, "Shift");
modeIcon(st, () -> hidingBlocks, () -> hidingBlocks ^= true, new SlashTextureRegionDrawable(Icon.layers.getRegion(), new Color(1f, 1f, 1f, a)), "Hiding Blocks", Binding.hide_blocks);
modeIcon(st, () -> hidingPlans, () -> hidingPlans ^= true, new SlashTextureRegionDrawable(Icon.effect.getRegion(), new Color(0.5f, 0.5f, 0.5f, a)), "Hiding Plans", Binding.hide_blocks, "Shift");
modeIcon(st, () -> hidingFog, () -> hidingFog ^= true, new SlashTextureRegionDrawable(Icon.waves.getRegion(), new Color(0.5f, 0.5f, 0.5f, a)), "Hiding Fog", Binding.invisible_units, "Ctrl");
modeIcon(st, () -> showingMassDrivers, () -> showingMassDrivers ^= true, new TextureRegionDrawable(Blocks.massDriver.region), "Showing Massdriver Links", Binding.show_massdriver_configs);
modeIcon(st, () -> showingOverdrives, () -> showingOverdrives ^= true, new TextureRegionDrawable(Blocks.overdriveProjector.region), "Showing Overdrive Ranges", Binding.show_turret_ranges);
modeIcon(st, () -> Core.settings.getBool("showdomes"), () -> Core.settings.put("showdomes", !Core.settings.getBool("showdomes")), Icon.commandRally, "Showing Dome Ranges", Binding.show_reactor_and_dome_ranges);
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 3e30d09

Please sign in to comment.