Skip to content

Commit

Permalink
sync script improvs
Browse files Browse the repository at this point in the history
  • Loading branch information
Snirozu committed Dec 4, 2024
1 parent a14c1d8 commit d5cc3d5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ class Main extends Sprite
});
});

FlxG.signals.postUpdate.add(() -> {
if (online.backend.SyncScript.activeUpdate)
online.backend.SyncScript.dispatch("update", [FlxG.elapsed]);
});

online.backend.SyncScript.resyncScript(false, () -> {
online.backend.SyncScript.dispatch("init");
});
Expand Down
3 changes: 3 additions & 0 deletions source/online/backend/Deflection.hx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class Deflection {
classBlacklist.push(online.util.FileUtils);
classBlacklist.push(online.util.HTTPClient);

// SyncScript can load malicious scripts
classBlacklist.push(online.backend.SyncScript);

// `polymod.*`
// Contains functions which may allow for un-blacklisting other modules.
for (cls in CompileTime.getAllClasses('polymod')) {
Expand Down
4 changes: 4 additions & 0 deletions source/online/backend/SyncScript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import sys.FileSystem;
class SyncScript extends SScript {
public static var syncScript:SyncScript;
public static var data:Any = {};
public static var activeUpdate:Bool = false;

public static function resyncScript(threaded:Bool = true, ?onDone:Void->Void) {
if (threaded) {
Expand All @@ -25,6 +26,7 @@ class SyncScript extends SScript {

static function retrieveScript():String {
if (FileSystem.exists("sync.hxs") && ClientPrefs.isDebug()) {
Alert.alert("[WARNING] Loaded some script from the local storage!!!");
trace("loading sync script from local storage...");
return File.getContent("sync.hxs");
}
Expand Down Expand Up @@ -62,6 +64,8 @@ class SyncScript extends SScript {
set("data", data);
set("print", s -> Sys.println(s));
set("typeof", s -> Type.getClassName(Type.getClass(s)));
set("parent", () -> return this);
set("alert", (title, ?message) -> Alert.alert(title, message));
}
}
#end

0 comments on commit d5cc3d5

Please sign in to comment.