Skip to content

Commit

Permalink
Improved performance
Browse files Browse the repository at this point in the history
  • Loading branch information
McTwist committed Aug 27, 2017
1 parent b5d5204 commit 158293b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Output Event - FireRelayNum (v4)
# Output Event - FireRelayNum (v5)
Choose which onRelays to fire

## Description
Expand Down
48 changes: 24 additions & 24 deletions server.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// ================
// Name :: FireRelayNum
// Version :: 4
// Version :: 5
// ================
// Made by :: McTwist
// Date :: 13-01-27
// Date :: 17-08-27
// Info :: Event that choose what onRelay to use
// License :: Free to use
// ================
Expand Down Expand Up @@ -47,66 +47,66 @@
// When processing an input event
function SimObject::ProcessFireRelay(%obj, %process, %client)
{
// Turn into temporary smarter data and avoid multiple relays
for (%i = 0; %i < getWordCount(%process); %i++)
%tempEvent[getWord(%process, %i)] = 1;

// Go through events
for (%i = 0; %i < %obj.numEvents; %i++)
// Onhly check for those events we are interested in
%count = getWordCount(%process);
for (%j = 0; %j < %count; %j++)
{
%i = getWord(%process, %j);

// Already processed
if (%tempEvent[%i])
continue;

// Enabled event
if (!%obj.eventEnabled[%i])
continue;

// The chosen event
if (!%tempEvent[%i])
continue;

// Not onRelay
if (%obj.eventInput[%i] !$= "onRelay")
continue;

// Target another brick
%targetBrick = (%obj.eventTargetIdx[%i] == -1);
if (%targetBrick)
if (%obj.eventTargetIdx[%i] == -1)
{
%num = outputEvent_GetNumParametersFromIdx("fxDTSBrick", %obj.eventOutputIdx[%i]);
%cObj = %obj.eventNT[%i];
%type = "fxDTSBrick";
%bricks = getBricksFromName(%obj.eventNT[%i]);
}
// Self
else
{
%type = inputEvent_GetTargetClass(%obj.getClassName(), %obj.eventInputIdx[%i], %obj.eventTargetIdx[%i]);
%num = outputEvent_GetNumParametersFromIdx(%type, %obj.eventOutputIdx[%i]);
%cObj = %obj;
%bricks = %obj;
}

// Parameters
%numParams = outputEvent_GetNumParametersFromIdx(%type, %obj.eventOutputIdx[%i]);

// Get parameters
%param = "";
for (%n = 1; %n <= %num; %n++)
for (%n = 1; %n <= %numParams; %n++)
%param = %param @ ", \"" @ expandEscape(%obj.eventOutputParameter[%i, %n]) @ "\"";

// Append client
if (%obj.eventOutputAppendClient[%i] && isObject(%client))
%param = %param @ ", " @ %client;

// Handle multiple bricks
%bricks = (%targetBrick) ? getBricksFromName(%cObj) : %cObj;

// Go through list/brick
%size = getWordCount(%bricks);
for (%n = 0; %n < %size; %n++)
{
%next = getWord(%bricks, %n);

// Call for event function
// Note: There is no other feasible way to do this on
eval("%event = %next.schedule(" @ %obj.eventDelay[%i] @ ", " @ %obj.eventOutput[%i] @ %param @ ");");

// To be able to cancel an event
%obj.addScheduledEvent(%event);
}

// Mark as processed
%tempEvent[%i] = 1;
}
return %obj;
}

// Events
Expand Down Expand Up @@ -279,4 +279,4 @@ function getBricksFromName(%name)
}

return %bricks;
}
}

0 comments on commit 158293b

Please sign in to comment.