Fix/jumpgate load#189
Conversation
TheGiddyLimit
left a comment
There was a problem hiding this comment.
in addition to the other feedback, please avoid pushing the dist/ ... changes
you can either rebase/amend your commits to remove those changes, make a new set of commits without committing the dist/ files, or I can just copy out the rest of the patch if/when the PR is otherwise ready
| {name: "bestiary index", url: `${MONSTER_DATA_DIR}index.json`}, | ||
| {name: "bestiary fluff index", url: `${MONSTER_DATA_DIR}fluff-index.json`}, | ||
| {name: "bestiary metadata", url: `${MONSTER_DATA_DIR}legendarygroups.json`}, | ||
| {name: "adventures index", url: `${DATA_URL}adventures.json`}, |
There was a problem hiding this comment.
this file definitely should exist (see https://5e.tools/data/adventures.json); what errors are you seeing?
There was a problem hiding this comment.
yeah that endpoint responded with 404
There was a problem hiding this comment.
works in browser .
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://5e.tools/data/adventures.json. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.
There was a problem hiding this comment.
can run this in the console while in a roll20 game
var x = await fetch("https://5e.tools/data/adventures.json")
will give same result
There was a problem hiding this comment.
👍 have asked the server host to take a look at it, because it really should be available, but it's behind some CloudFlare thing
| d20plus.sheet = "ogl"; | ||
| if (window.is_gm && (!d20.journal.customSheets || !d20.journal.customSheets)) { | ||
| const sheets = d20.journal.customSheets ?? d20.journal.characterSheetsManager.getAllSheets(); | ||
| if (window.is_gm && sheets.length < 1) { |
There was a problem hiding this comment.
sheets.length < 1 -> !sheets.length
There was a problem hiding this comment.
nah, wanted to avoid the concept where length property did not exist. this clearly denotes its expecting an array since the jumpgate now stores sheets in an array (roll20 supports more than 1 sheet type for campaign now)
can make it cleaner though. as long as it handles both jumpgate and non jumpgate games.
i'm not too attached to format
There was a problem hiding this comment.
certainly isn't clear enough for me to understand what's going on, so, would appreciate a revision to make it more explicit; you're saying you're relying on undefined < 1 === false..?
if d20.journal.customSheets and d20.journal.characterSheetsManager.getAllSheets() are two fundamentally different data types, then there should just be two different branches, one to handle each. I.e., I'd prefer duplicated code to confusing checks at every usage point
There was a problem hiding this comment.
i see. yes, they are 2 fundamentally different ways to provide sheets. 1 is an array 1 is 1 item in a non existent array
| if (firstSheet.layouthtml.indexOf("shaped_d20") > 0) d20plus.sheet = "shaped"; | ||
| if (firstSheet.layouthtml.indexOf("DnD5e_Character_Sheet") > 0) d20plus.sheet = "community"; |
There was a problem hiding this comment.
while you're here,
firstSheet.layouthtml.indexOf("shaped_d20") > 0 -> firstSheet.layouthtml.includes("shaped_d20")
firstSheet.layouthtml.indexOf("DnD5e_Character_Sheet") > 0 -> firstSheet.layouthtml.includes("DnD5e_Character_Sheet")
| $iptUrl.data("id", "lmop"); | ||
| const $sel = $("#button-adventures-select"); | ||
| adventureMetadata.adventure.forEach(a => { | ||
| if (adventureMetadata.adventure){ |
There was a problem hiding this comment.
this smells like a hack due to disabling the adventure index load..? Or is there some other purpose
There was a problem hiding this comment.
if u want to call it a hack. if there is no result from the adventures list it will still cause the rest of the load to break when other features are still functional which sounds unnecessary
| d20.engine.canvas.sortTokens = _.bind(d20plus.mod.sortTokens, d20.engine.canvas); | ||
| d20.engine.canvas.drawAnyLayer = _.bind(d20plus.mod.drawAnyLayer, d20.engine.canvas); | ||
| d20.engine.canvas.drawTokensWithoutAuras = _.bind(d20plus.mod.drawTokensWithoutAuras, d20.engine.canvas); | ||
| if (d20.engine.canvas){ |
| cacheRenderLoop(); | ||
| }; | ||
|
|
||
| if (!d20.engine.canvas.on) { |
There was a problem hiding this comment.
repeated from above? Is this something that could be factored out, and given e.g. a useful function name explaining what it's doing?
additionally, what is $.on/$.off doing? Are these ever defined?
There was a problem hiding this comment.
so $.off and on are query event listener hooks.
the repeat is because i was not certain with 100% certainty where the first call to the d20.enginge.canvas was.
so wit this i created the functions to apply the event listeners.
was too lazy to rely on element.addEventListener with the custom events that were expected to exist here so relied on jquery.
i'm not even sure if his is a full fix.
there are still things i want to fix later
There was a problem hiding this comment.
i think i had a backup in there . like pulling the ref to the relevant canvas and stuff. i think i tried to prototype it too. but havent been able to get it working
There was a problem hiding this comment.
revised. found the location for them.$.fn.on/off
| d20plus.engine.forwardOneLayer(n); | ||
| return false; | ||
| }); | ||
| if (typeof(Mousetrap) !== "undefined"){ |
There was a problem hiding this comment.
nit typeof(Mousetrap) -> typeof Mousetrap
| .then(response => response.json()) | ||
| .then(data => { | ||
| // check if blocked | ||
| if (data.block) |
There was a problem hiding this comment.
nit: move non-block-statement if statement onto same line as condition (or wrap in { })
There was a problem hiding this comment.
ok so u prefer single like non-block if statements?
like this?
if(conditionIsMet) doTheThing();
There was a problem hiding this comment.
missing a space, but yes
if (conditionIsMet) doTheThing();
| if ((typeof window.d20 !== "undefined" || window.currentPlayer?.d20) && !$("#loading-overlay").is(":visible") && !hasRunInit) { | ||
| hasRunInit = true; | ||
| if (!window.d20) window.d20 = window.currentPlayer.d20; | ||
| d20.engine.canvas ??= $("#babylonCanvas").get(0); |
There was a problem hiding this comment.
why not document.getElementById(...) and skip the jQuery cruft?
There was a problem hiding this comment.
no reason. if jquery had to be loaded before this was loaded thought i'd use it. less characters.
if u want getElementById can change for better portability. not attached
There was a problem hiding this comment.
in the case where it's jQuery selector -> immediately de-reference it to underlying DOM element (with .get(0) or [0]), then prefer using the browser built-in
character count is less important than flipping between two mental contexts for the sake of half a line
|
appreciate the submission generally, but, hard to judge a set of changes without information on the intent/effect of those changes screenshots of things working (or even better, "before" screenshot of things not working, and "after" screenshots of the working version with fixes applied) would be greatly appreciated |
sorry about that. i think the editorconfig overwrote the dist folder rollback on my amends. saving the file added the spaces etc. |
no worries. since the live version is completely broken i thought i'd share my progress on fixing some of the functionality. |
|
next update:
|
|
should dist folder be added to gitignore? |
not currently, as the compiled scripts are committed when a new release is put out |


prevents some errors and enables some features.