Author Topic: [BL SOURCE CODE/REFERENCE] ServerLoadSaveFile_Start/Tick/End/Color Data  (Read 4305 times)

Code: [Select]
function QueueSO::pop(%obj)
{
if(%obj.head != %obj.tail)
{
%obj.head--;
if(%obj.head < 0)
{
%obj.head = %obj.size-1;
%ret = %obj.val[%obj.head];
%obj.val[%obj.head] = 0;
}
}
return %ret;
}

More like this:

Code: [Select]
function QueueSO::pop(%obj)
{
if(%obj.head != %obj.tail)
{
%obj.head--;
if(%obj.head < 0)
{
%obj.head = %obj.size-1;
}
%ret = %obj.val[%obj.head];
%obj.val[%obj.head] = 0;
}
return %ret;
}



Posted new functions.

whats the func to paint something
sorry wrong thread
« Last Edit: June 13, 2017, 12:28:06 AM by Potatoh »

Am I the only one that get bothered that the source uses float as index?

Am I the only one that get bothered that the source uses float as index?
i get really bothered when the source does comparisons like %index == 2.0

Posted music datablock creation.

Posted music datablock creation.
Problem on line 38/39 of createMusicDatablocks
Code: [Select]
%command = "datablock AudioProfile(" @ %dbName @ ") {" @ "filename = " @ %filename @ ";" @ "description = AudioMusicLooping3d;" @ "preload = true;" @ "uiName = " @ %uiName @ ";" @ "};";
eval(%command);
%filename, %uiname, and maybe description need escaped quotes to work with eval.
So like-
Code: [Select]
%command = "datablock AudioProfile(" @ %dbName @ ") {" @ "filename = \"" @ %filename @ "\";" @ "description = \"AudioMusicLooping3d\";" @ "preload = true;" @ "uiName = \"" @ %uiName @ "\";" @ "};";

description definitely doesn't

Note: If you're using that code as inspiration, don't do that anyway. You should be taking advantage of eval's scope if you have to use it.

eval("datablock AudioProfile(" @ %dbName @ "){filename=%filename;description=AudioMusicLooping3d;preload=1;uiName=%uiName;};");

It was never posted on the forums but someone created an add-on that rewrites the music datablock creation function to raise the size limit: https://blocklandglass.com/addons/addon.php?id=596

It was never posted on the forums but someone created an add-on that rewrites the music datablock creation function to raise the size limit: https://blocklandglass.com/addons/addon.php?id=596
CreateMusicDatablocks.

function createMusicDatablocks()
{
   updateMusicList();
   %dir = "Add-ons/Music/*.ogg";
   %fileCount = getFileCount(%dir);
   %filename = findFirstFile(%dir);
   %i = 0;
   while(%i < %fileCount)
   {
      %base = fileBase(%filename);
      %uiName = strreplace(%base, "_", " ");
      %varName = getSafeVariableName(%base);
      if (!$Server::Dedicated)
      {
         if (getRealTime() - $lastProgressBarTime > 200.0)
         {
            LoadingProgress.setValue(%i / %fileCount);
            $lastProgressBarTime = getRealTime();
            Canvas.repaint();
         }
      }
      if (!isValidMusicFilename(%filename))
      {
         %filename = findNextFile(%dir);
      }
      else
      {
         if (getFileLength(%filename) > 1048576.0)
         {
            error("ERROR: Music file " @ %filename @ " > 1mb - ignoring");
            %filename = findNextFile(%dir);
         }
         else
         {
            if ($Music__[%varName] $= 1)
            {
               %dbName = "musicData_" @ %varName;
               %command = "datablock AudioProfile(" @ %dbName @ ") {" @ "filename = " @ %filename @ ";" @ "description = AudioMusicLooping3d;" @ "preload = true;" @ "uiName = " @ %uiName @ ";" @ "};";
               eval(%command);
               if (%dbName.isStereo())
               {
                  error("ERROR: Stereo sound detected on " @ %dbName.getName() @ " - Removing datablock.");
                  schedule(1000, 0, MessageAll, '', "Stereo sound detected on  " @ fileName(%dbName.fileName) @ " - Removing datablock.");
                  %dbName.uiName = "";
                  %dbName.delete();
                  if (getBuildString() $= "Ship")
                  {
                     fileDelete(%filename);
                  }
                  else
                  {
                     warning("WARNING: \'" @ %filename @ "\' is a stereo music block and would be deleted if this was the public build!");
                  }
               }
            }
            %filename = findNextFile(%dir);
         }
      }
      %i = %i + 1.0;
   }
}


ya its a really easy change lol
« Last Edit: June 15, 2017, 08:32:17 PM by Conan »

Looks like the OP contents got reverted. I'll ask Mocha to update it

Why not post the decompiler itself?

5 internet points on it being written in python.

Why not post the decompiler itself?

5 internet points on it being written in python.
+5 internet points
somebody's busy converting it to c++ but gave up until he can find a good way to store the string tables