Skip to content

Commit 458da8b

Browse files
Merge remote-tracking branch 'origin/master'
# Conflicts: # build/scripts/commands/general.js # build/scripts/index.js # build/scripts/translation.js # src/translation.ts
2 parents 677835c + a83870c commit 458da8b

8 files changed

Lines changed: 136 additions & 140 deletions

File tree

build/scripts/commands/general.js

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/scripts/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/scripts/translation.js

Lines changed: 35 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/src/env.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ class ObjectIntMap<K> {
6363
});
6464
}
6565
}
66+
class ObjectSet<T> {
67+
set = new Set<T>();
68+
get size(){ return this.set.size; }
69+
select(predicate:(item:T) => boolean){
70+
const out = new ObjectSet<T>;
71+
for(const item of this.set){
72+
if(predicate(item)) out.add(item);
73+
}
74+
return out;
75+
}
76+
each(func:(item:T) => unknown){ this.set.forEach(func); }
77+
add(item:T){ return this.set.add(item); }
78+
remove(item:T){ return this.set.delete(item); }
79+
isEmpty(){ return this.set.size == 0; }
80+
contains(item:T){ return this.set.has(item); }
81+
toSeq(){ return new Seq([...this.set]); }
82+
get(key:T){ return this.set.has(key) ? key : null; }
83+
first(){ return this.set.values().next().value ?? fail("Set is empty"); }
84+
clear(){ this.set.clear(); }
85+
}
6686

6787
class Seq<T> {
6888
constructor(public items:T[] = []){}
@@ -471,6 +491,9 @@ class LabelReliableCallPacket {
471491
worldx = 0;
472492
worldy = 0;
473493
}
494+
class SendChatMessageCallPacket {
495+
message:string | null = null;
496+
}
474497
class CommandRunner<T> {
475498
accept: (args:string[], parameter: T) => void;
476499
constructor({ accept }:{ accept: (args:string[], parameter: T) => void; }){
@@ -621,6 +644,9 @@ class Administration {
621644
getInfoOptional(id:string){
622645
return this.playerInfo.get(id);
623646
}
647+
static Config = class {
648+
649+
};
624650
}
625651
class MMap {
626652

@@ -646,6 +672,7 @@ const Vars = {
646672
},
647673
net: {
648674
send(object:any, reliable:boolean){},
675+
handleServer(packetType:Function, handler:any){}
649676
},
650677
mods: {
651678
getScripts(){
@@ -959,6 +986,14 @@ class Thread {
959986
run = this.runnable;
960987
}
961988

989+
const Http = {
990+
post(url:string, content:string){
991+
return { submit(){}, block(){}, error(){}, header(){return this;}, };
992+
},
993+
get(url:string, callback?:(res:HttpResponse) => unknown, error?:(err:any) => unknown){
994+
return { submit(){}, block(){}, error(){}, header(){return this;}, };
995+
},
996+
};
962997

963998
const Iconc = Object.fromEntries(["rotate", "modeSurvival", "power", "left", "redditAlien", "edit", "downOpen", "pencil", "file", "lockOpen", "right", "infoCircle", "pick", "settings", "spray1", "terrain", "exit", "wrench", "lock", "discord", "eye", "none", "play", "diagonal", "eraser", "trash", "liquid", "fileImage", "defense", "layers", "grid", "admin", "steam", "star", "chartBar", "chat", "android", "image", "map", "logic", "menu", "commandRally", "editor", "folder", "units", "commandAttack", "copy", "filter", "cancel", "terminal", "upload", "eyeOff", "save", "planeOutline", "fill", "distribution", "upOpen", "rightOpen", "modePvp", "download", "list", "flipX", "flipY", "effect", "paste", "planet", "waves", "up", "warning", "tree", "add", "down", "host", "spray", "info", "players", "resize", "refresh1", "production", "crafting", "pause", "googleplay", "hammer", "fileText", "modeAttack", "move", "zoom", "bookOpen", "refresh", "ok", "home", "githubSquare", "powerOld", "github", "undo", "box", "trello", "book", "export", "fileTextFill", "rightOpenOut", "turret", "leftOpen", "line", "itchio", "link", "filters", "redo"].map(n => [n, 0xFE60]));
964999

@@ -974,4 +1009,4 @@ const Packages = {
9741009
gen: { Map: MMap }
9751010
}
9761011
};
977-
Object.assign(globalThis, {Pattern, ObjectIntMap, Seq, Fi, Packages, Events, Trigger, Team, EventType, Timer, EffectCallPacket2, LabelReliableCallPacket, Vars, ServerControl, Core, Log, Menus, Time, CommandHandler, Gamemode, Fx, Effect, Vec2, Tmp, Paths, Path, Threads, CommandRunner, Strings, UnitTypes, Bits, Items, ItemStack, Iconc, Blocks, StatusEffects, Ratekeeper, Runtime, Thread});
1012+
Object.assign(globalThis, {Pattern, ObjectIntMap, Seq, Fi, Packages, Events, Trigger, Team, EventType, Timer, EffectCallPacket2, LabelReliableCallPacket, Vars, ServerControl, Core, Log, Menus, Time, CommandHandler, Gamemode, Fx, Effect, Vec2, Tmp, Paths, Path, Threads, CommandRunner, Strings, UnitTypes, Bits, Items, ItemStack, Iconc, Blocks, StatusEffects, Ratekeeper, Runtime, Thread, Administration, ObjectSet, ObjectMap, SendChatMessageCallPacket, Http});

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Vars.net.handleServer(SendChatMessageCallPacket, (connection: NetConnection, pac
157157

158158
if (filtered == null) return;
159159

160-
translation.messageHandoff(player, message);
160+
translation.handleMessage(player, message);
161161
}else if (response.type != CommandHandler.ResponseType.valid){
162162
const text = Vars.netServer.invalidHandler.handle(player, response);
163163

src/mindustryTypes.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ const Vars: {
7575
votesRequired():number;
7676
}
7777
net: {
78-
send(object:any, reliable:boolean):void;
78+
send(packet:any, reliable:boolean):void;
7979
closeServer():void;
80-
handleServer(object: any, handler:(object: any, connection: NetConnection) => void): void
80+
handleServer(packetType: new (...args:any[]) => unknown, handler:(packet: any, connection: NetConnection) => void): void;
8181
}
8282
mods: {
8383
getScripts(): Scripts;
@@ -464,6 +464,11 @@ const Time: {
464464
const GameState: {
465465
State: Record<"playing" | "paused" | "menu", any>;
466466
};
467+
const Http: {
468+
post(url:string, content:string):HttpRequest;
469+
get(url:string):HttpRequest;
470+
get(url:string, callback:(res:HttpResponse) => unknown, error:(err:any) => unknown):void;
471+
};
467472
class HttpRequest {
468473
submit(func:(response:HttpResponse) => void):void;
469474
block(func:(response:HttpResponse) => void):void;
@@ -531,11 +536,7 @@ class ByteArrayOutputStream extends OutputStream {
531536
class ByteArrayInputStream extends InputStream {
532537
constructor(bytes:number[]);
533538
}
534-
const Http: {
535-
post(url:string, content:string):HttpRequest;
536-
get(url:string):HttpRequest;
537-
get(url:string, callback:(res:HttpResponse) => unknown, error:(err:any) => unknown):void;
538-
};
539+
539540
class Seq<T> {
540541
items: Array<T | null>;
541542
size: number;
@@ -580,6 +581,7 @@ class ObjectSet<T> {
580581
select(predicate:(item:T) => boolean):ObjectSet<T>;
581582
each(func:(item:T) => unknown):void;
582583
add(item:T):boolean;
584+
addAll(items:T[]):void;
583585
remove(item:T):boolean;
584586
isEmpty():boolean;
585587
contains(item:T):boolean;

0 commit comments

Comments
 (0)