Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
theripper93 committed Oct 14, 2024
1 parent 484dbf5 commit 32f30a1
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 45 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion packs/levels-samples/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-003256
MANIFEST-003268
6 changes: 3 additions & 3 deletions packs/levels-samples/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2024/10/13-22:32:18.378 1bf4 Recovering log #3254
2024/10/13-22:32:18.381 1bf4 Delete type=0 #3254
2024/10/13-22:32:18.381 1bf4 Delete type=3 #3252
2024/10/14-14:33:38.434 40b4 Recovering log #3266
2024/10/14-14:33:38.438 40b4 Delete type=0 #3266
2024/10/14-14:33:38.438 40b4 Delete type=3 #3264
16 changes: 8 additions & 8 deletions packs/levels-samples/LOG.old
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
2024/10/13-21:52:43.379 6f68 Recovering log #3251
2024/10/13-21:52:43.382 6f68 Delete type=0 #3251
2024/10/13-21:52:43.382 6f68 Delete type=3 #3250
2024/10/13-22:32:13.661 74cc Level-0 table #3255: started
2024/10/13-22:32:13.661 74cc Level-0 table #3255: 0 bytes OK
2024/10/13-22:32:13.663 74cc Delete type=0 #3253
2024/10/13-22:32:13.667 74cc Manual compaction at level-0 from '!scenes!i1noRqT20RD5stIK' @ 72057594037927935 : 1 .. '!scenes.walls!zksLSgRdh6f8jiUO.z5ptMNOLPqAgK6MH' @ 0 : 0; will stop at (end)
2024/10/13-22:32:13.667 74cc Manual compaction at level-1 from '!scenes!i1noRqT20RD5stIK' @ 72057594037927935 : 1 .. '!scenes.walls!zksLSgRdh6f8jiUO.z5ptMNOLPqAgK6MH' @ 0 : 0; will stop at (end)
2024/10/14-14:31:44.523 40b4 Recovering log #3263
2024/10/14-14:31:44.526 40b4 Delete type=0 #3263
2024/10/14-14:31:44.526 40b4 Delete type=3 #3262
2024/10/14-14:32:47.498 475c Level-0 table #3267: started
2024/10/14-14:32:47.498 475c Level-0 table #3267: 0 bytes OK
2024/10/14-14:32:47.499 475c Delete type=0 #3265
2024/10/14-14:32:47.502 475c Manual compaction at level-0 from '!scenes!i1noRqT20RD5stIK' @ 72057594037927935 : 1 .. '!scenes.walls!zksLSgRdh6f8jiUO.z5ptMNOLPqAgK6MH' @ 0 : 0; will stop at (end)
2024/10/14-14:32:47.502 475c Manual compaction at level-1 from '!scenes!i1noRqT20RD5stIK' @ 72057594037927935 : 1 .. '!scenes.walls!zksLSgRdh6f8jiUO.z5ptMNOLPqAgK6MH' @ 0 : 0; will stop at (end)
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion packs/macros/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-003251
MANIFEST-003263
6 changes: 3 additions & 3 deletions packs/macros/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2024/10/13-22:32:18.371 1858 Recovering log #3249
2024/10/13-22:32:18.375 1858 Delete type=0 #3249
2024/10/13-22:32:18.375 1858 Delete type=3 #3247
2024/10/14-14:33:38.428 2b60 Recovering log #3261
2024/10/14-14:33:38.431 2b60 Delete type=0 #3261
2024/10/14-14:33:38.431 2b60 Delete type=3 #3259
16 changes: 8 additions & 8 deletions packs/macros/LOG.old
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
2024/10/13-21:52:43.371 4d74 Recovering log #3246
2024/10/13-21:52:43.375 4d74 Delete type=0 #3246
2024/10/13-21:52:43.375 4d74 Delete type=3 #3245
2024/10/13-22:32:13.651 74cc Level-0 table #3250: started
2024/10/13-22:32:13.651 74cc Level-0 table #3250: 0 bytes OK
2024/10/13-22:32:13.653 74cc Delete type=0 #3248
2024/10/13-22:32:13.659 74cc Manual compaction at level-0 from '!macros!2LfY4Ky5rRDkK7h8' @ 72057594037927935 : 1 .. '!macros!yx7Eb76rfzjh0LEO' @ 0 : 0; will stop at (end)
2024/10/13-22:32:13.659 74cc Manual compaction at level-1 from '!macros!2LfY4Ky5rRDkK7h8' @ 72057594037927935 : 1 .. '!macros!yx7Eb76rfzjh0LEO' @ 0 : 0; will stop at (end)
2024/10/14-14:31:44.510 2b60 Recovering log #3258
2024/10/14-14:31:44.513 2b60 Delete type=0 #3258
2024/10/14-14:31:44.513 2b60 Delete type=3 #3257
2024/10/14-14:32:47.497 475c Level-0 table #3262: started
2024/10/14-14:32:47.497 475c Level-0 table #3262: 0 bytes OK
2024/10/14-14:32:47.498 475c Delete type=0 #3260
2024/10/14-14:32:47.502 475c Manual compaction at level-0 from '!macros!2LfY4Ky5rRDkK7h8' @ 72057594037927935 : 1 .. '!macros!yx7Eb76rfzjh0LEO' @ 0 : 0; will stop at (end)
2024/10/14-14:32:47.502 475c Manual compaction at level-1 from '!macros!2LfY4Ky5rRDkK7h8' @ 72057594037927935 : 1 .. '!macros!yx7Eb76rfzjh0LEO' @ 0 : 0; will stop at (end)
Binary file not shown.
6 changes: 5 additions & 1 deletion scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {BackgroundHandler} from "./handlers/backgroundHandler.js";
import {RegionHandler} from "./handlers/regionHandler.js";
import { SettingsHandler } from "./handlers/settingsHandler.js";
import { LevelsAPI } from "./API.js";
import { registerWrappers } from "./wrappers.js";
import { registerWrappers, registerSetupWrappers } from "./wrappers.js";
import { inRange, getRangeForDocument, cloneTileMesh, inDistance } from "./helpers.js";
import { setupWarnings } from "./warnings.js";
import {LevelsMigration} from "./migration.js";
Expand Down Expand Up @@ -123,6 +123,10 @@ Hooks.on("init", () => {
Hooks.callAll("levelsReady", CONFIG.Levels);
});

Hooks.once("setup", () => {
registerSetupWrappers();
} );

Hooks.once("ready", () => {

if(game.user.isGM && game.settings.get("levels", "migrateOnStartup")) CONFIG.Levels.helpers.migration.migrateAll();
Expand Down
4 changes: 2 additions & 2 deletions scripts/handlers/sightHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class SightHandler {
if (config.tests._levels !== object) {
config.tests.length = 0;
for (const p of SightHandler.getTestPoints(object)) {
const elevation = p.z * unitsToPixel;
const elevation = p.z;
config.tests.push({ elevation, point: { x: p.x, y: p.y, z: elevation }, los: new Map() });
}
config.tests._levels = object;
Expand All @@ -206,7 +206,7 @@ export class SightHandler {
z = e;
}
z ??= canvas.primary.background.elevation;
z *= unitsToPixel;
//z *= unitsToPixel;
for (const test of config.tests) {
test.point.z = z;
test.elevation = z;
Expand Down
40 changes: 22 additions & 18 deletions scripts/wrappers.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,6 @@ export function registerWrappers() {
"MIXED",
);

const visibilityTestObjectStack = [];
libWrapper.register(
LevelsConfig.MODULE_ID,
"CanvasVisibility.prototype.testVisibility",
function visibilityWrapper(wrapped, ...args) {
const options = (args[1] ??= {});
if (options.object instanceof Token) options.tolerance = 0;
visibilityTestObjectStack.push(LevelsConfig.visibilityTestObject);
LevelsConfig.visibilityTestObject = args[1].object;
const res = wrapped(...args);
LevelsConfig.visibilityTestObject = visibilityTestObjectStack.pop();
return !!res;
},
"WRAPPER",
);

libWrapper.register(LevelsConfig.MODULE_ID, "CanvasVisibility.prototype._createVisibilityTestConfig", LevelsConfig.handlers.SightHandler._createVisibilityTestConfig, "OVERRIDE", { perf_mode: "FAST" });

libWrapper.register(LevelsConfig.MODULE_ID, "DetectionMode.prototype._testRange", LevelsConfig.handlers.SightHandler._testRange, "OVERRIDE", { perf_mode: "FAST" });

libWrapper.register(LevelsConfig.MODULE_ID, "ClockwiseSweepPolygon.prototype.contains", LevelsConfig.handlers.SightHandler.containsWrapper, "MIXED");
Expand All @@ -121,3 +103,25 @@ export function registerWrappers() {

libWrapper.register(LevelsConfig.MODULE_ID, "CONFIG.Token.objectClass.prototype.isVisible", LevelsConfig.handlers.UIHandler.tokenUIWrapperIsVisible, "WRAPPER");
}

export function registerSetupWrappers() {
const LevelsConfig = CONFIG.Levels;

const visibilityTestObjectStack = [];
libWrapper.register(
LevelsConfig.MODULE_ID,
"CONFIG.Canvas.groups.visibility.groupClass.prototype.testVisibility",
function visibilityWrapper(wrapped, ...args) {
const options = (args[1] ??= {});
if (options.object instanceof Token) options.tolerance = 0;
visibilityTestObjectStack.push(LevelsConfig.visibilityTestObject);
LevelsConfig.visibilityTestObject = args[1].object;
const res = wrapped(...args);
LevelsConfig.visibilityTestObject = visibilityTestObjectStack.pop();
return !!res;
},
"WRAPPER",
);

libWrapper.register(LevelsConfig.MODULE_ID, "CONFIG.Canvas.groups.visibility.groupClass.prototype._createVisibilityTestConfig", LevelsConfig.handlers.SightHandler._createVisibilityTestConfig, "OVERRIDE", { perf_mode: "FAST" });
}

0 comments on commit 32f30a1

Please sign in to comment.