mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-10-02 11:10:50 +03:00
Cap message block contents at 250 chars/1000 bytes (#11963)
This commit is contained in:
@@ -1169,7 +1169,7 @@ public class LExecutor{
|
|||||||
|
|
||||||
if(target.building() instanceof MessageBuild d && d.isValid() && (exec.privileged || (d.team == exec.team && !d.block.privileged))){
|
if(target.building() instanceof MessageBuild d && d.isValid() && (exec.privileged || (d.team == exec.team && !d.block.privileged))){
|
||||||
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(), ((MessageBlock)d.block).maxTextLength));
|
||||||
}
|
}
|
||||||
exec.textBuffer.setLength(0);
|
exec.textBuffer.setLength(0);
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import arc.util.pooling.*;
|
|||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.logic.*;
|
import mindustry.logic.*;
|
||||||
|
import mindustry.mod.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.ui.dialogs.*;
|
import mindustry.ui.dialogs.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
@@ -23,8 +24,10 @@ import mindustry.world.meta.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class MessageBlock extends Block{
|
public class MessageBlock extends Block{
|
||||||
//don't change this too much unless you want to run into issues with packet sizes
|
private static final int maxByteLength = 999;
|
||||||
public int maxTextLength = 300;
|
//maximum UTF-8 length per char is 4, so 4*250 = 1000 bytes, the max byte array size
|
||||||
|
@NoPatch
|
||||||
|
public int maxTextLength = 250;
|
||||||
public int maxNewlines = 24;
|
public int maxNewlines = 24;
|
||||||
|
|
||||||
public MessageBlock(String name){
|
public MessageBlock(String name){
|
||||||
|
|||||||
Reference in New Issue
Block a user