Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
SAI/CommentGenerator: init phase mask comments
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoBorzi committed Jun 8, 2015
1 parent 2541c79 commit 7e59bf9
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion js/app/sai/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
$scope.generateComments = function() {

var i, fullLine, smartScript, randomEmotes, smartScriptLink, event_phase_mask, event_flags,
arrayOfSplitPhases, event_phase_mask2, log2, l2, power,
commentUnitFlag, unitFlags,
commentNpcFlag, npcFlags,
commentGoFlag, goFlags,
Expand Down Expand Up @@ -815,7 +816,41 @@
}
}

// TODO: 'event_phase_mask'
event_phase_mask = smartScriptLink != null ? smartScriptLink.event_phase_mask : smartScript.event_phase_mask;

if (event_phase_mask != app.saiConstants.phaseMask.ALWAYS)
{
arrayOfSplitPhases = [];

event_phase_mask2 = event_phase_mask;
log2 = 0;

while (event_phase_mask2 >= 2)
{
event_phase_mask2 /= 2;
log2++;
}

for (l2 = log2; l2 >= 0; l2--)
{
power = Math.pow(2, l2);

if (event_phase_mask >= power)
{
event_phase_mask -= power;
arrayOfSplitPhases.push(power);
}
}

Array.reverse(arrayOfSplitPhases); //! Reverse them so they are ascending
fullLine += " (Phase";

if (arrayOfSplitPhases.length > 1) {
fullLine += "s";
}

fullLine += " " + arrayOfSplitPhases.join(" & ") + ")";
}

event_flags = smartScriptLink != null ? smartScriptLink.event_flags : smartScript.event_flags;

Expand Down

5 comments on commit 7e59bf9

@JasperAppec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making me feel bad! By far the worst code I've ever written. 😢

@FrancescoBorzi
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should improve it :P

@JasperAppec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free, hit me up when you find a better method to extract each mask value from a bitmask and convert it into a readable string (so in this case "Phases 1 & 2 & 3" for example). 😄

@FrancescoBorzi
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I will do it in future, at the moment our priority is to verify that everything already implemented is working as intended, then release the 2.1.0 version which includes a basic SAI Editor.

@JasperAppec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. :)

Please sign in to comment.