Downloads containing MLLE-Include-1.4.asc

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Chasing the Stars cooba Battle N/A Download file
JJ2+ Only: Foo Single Player 2/14:...Featured Download Violet CLM Single player 10 Download file
TSF with JJ2+ Only: R├║nheimr Seren Battle N/A Download file
TSF with JJ2+ Only: Desolation of the Aztecs happygreenfrog Battle N/A Download file
TSF with JJ2+ Only: RainV Violet CLM Tileset conversion N/A Download file
TSF with JJ2+ Only: Academy Superjazz Battle N/A Download file
TSF with JJ2+ Only: Carrot FarmFeatured Download Loon Capture the flag 9.3 Download file
TSF with JJ2+ Only: The CrackdownFeatured Download cooba Capture the flag 8.2 Download file
JJ2+ Only: Orbital IVFeatured Download FawFul Capture the flag 8.4 Download file
TSF with JJ2+ Only: Painted GardenFeatured Download PurpleJazz Capture the flag 8.2 Download file
JJ2+ Only: What in the blazes?Featured Download happygreenfrog Single player 8 Download file
TSF with JJ2+ Only: The Dragon EyrieFeatured Download PurpleJazz Capture the flag 8.7 Download file
JJ2+ Only: EmeraldusVFeatured Download Violet CLM Multiple 8.9 Download file
TSF with JJ2+ Only: Summer Madness ForthRightMC Single player 5.7 Download file
TSF with JJ2+ Only: Operation Cleanup: Turtle...Featured Download happygreenfrog Single player 8.2 Download file
JJ2+ Only: Infiltration MissionFeatured Download happygreenfrog Single player 8.1 Download file
TSF with JJ2+ Only: Anniversary Bash 20 Jazz2Online Multiple N/A Download file
TSF with JJ2+ Only: Mt. Cinder PurpleJazz Capture the flag N/A Download file
JJ2+ Only: ThermaeFeatured Download Jelly Jam Battle 8.2 Download file
JJ2+ Only: Chaostopia Claustrophobia happygreenfrog Battle 6.5 Download file
TSF with JJ2+ Only: Press GardenFeatured Download SmokeNC Battle 9.2 Download file
TSF with JJ2+ Only: RabbitCity 2 Remastered P4rr0t Single player N/A Download file
TSF with JJ2+ Only: Fishing VillageFeatured Download PurpleJazz Capture the flag 9 Download file
TSF with JJ2+ Only: Nocturne Blackraptor Battle 7.2 Download file
JJ2+ Only: The Redacted Missions happygreenfrog Single player 6.9 Download file
TSF with JJ2+ Only: Welcome to Chaostopia! happygreenfrog Single player 7.3 Download file
TSF with JJ2+ Only: RabbitCity Remastered P4rr0t Single player 7.5 Download file
TSF with JJ2+ Only: Holiday Hare '17Featured Download ShadowGPW Single player 8.7 Download file

File preview

  1. //2220731962
  2. //This is a standard library created by MLLE to read some JJ2+ properties from a level file whose script includes this library. DO NOT MANUALLY MODIFY THIS FILE.
  3.  
  4.  
  5.  
  6.  
  7.  
  8. #pragma require 'MLLE-Include-1.4.asc'
  9. namespace MLLE {
  10.     jjPAL@ Palette;
  11.     dictionary@ _layers;
  12.  
  13.     bool Setup() {
  14.         jjPAL palette = jjBackupPalette;
  15.         @Palette = @palette;
  16.         dictionary layers;
  17.         @_layers = @layers;
  18.  
  19.         jjSTREAM crcCheck('MLLE-Include-1.4.asc');
  20.         string crcLine;
  21.         if (crcCheck.isEmpty() || !crcCheck.getLine(crcLine)) {
  22.             jjDebug('MLLE::Setup: Include file has been renamed!');
  23.             return false;
  24.         }
  25.         array<string> regexResults;
  26.         if (!jjRegexMatch(crcLine, '\\/\\/(\\d+)\\r?', regexResults)) {
  27.             jjDebug('MLLE::Setup: Include file is improperly formatted!');
  28.             return false;
  29.         }
  30.         if (parseUInt(regexResults[1]) != jjCRC32(crcCheck)) {
  31.             jjDebug('MLLE::Setup: Include file has been damaged!');
  32.             return false;
  33.         }
  34.        
  35.         jjSTREAM level(jjLevelFileName);
  36.         if (level.isEmpty()) {
  37.             jjDebug('MLLE::Setup: Level file cannot be read from that folder for security reasons!');
  38.             return false;
  39.         }
  40.         level.discard(230);
  41.         array<uint> CompressedDataSizes(4, 0);
  42.         for (uint i = 0; i < CompressedDataSizes.length; ++i) {
  43.             level.pop(CompressedDataSizes[i]);
  44.             level.discard(4);
  45.         }
  46.         for (uint i = 0; i < CompressedDataSizes.length; ++i)
  47.             level.discard(CompressedDataSizes[i]);
  48.  
  49.         if (level.getSize() < 20) {
  50.             jjDebug('MLLE::Setup: Level file does not contain any additional data!');
  51.             return false;
  52.         }
  53.         string magic;
  54.         level.get(magic, 'MLLE'.length);
  55.         if (magic != 'MLLE') {
  56.             jjDebug('MLLE::Setup: Level was not saved by MLLE!');
  57.             return false;
  58.         }
  59.         uint levelDataVersion;
  60.         level.pop(levelDataVersion);
  61.         if (levelDataVersion != 0x104) {
  62.             jjDebug('MLLE::Setup: Level\'s Data5 section was saved in a different version of MLLE than this script!');
  63.             return false;
  64.         }
  65.  
  66.         uint csize, usize;
  67.         level.pop(csize); level.pop(usize);
  68.         jjSTREAM data5;
  69.         if (!jjZlibUncompress(level, data5, usize)) {
  70.             jjDebug('MLLE::Setup: Error during ZLIB uncompression!');
  71.             return false;
  72.         }
  73.  
  74.         bool pbool; uint8 pbyte; int8 pchar; float pfloat; int pint; uint puint, puint2;
  75.         data5.pop(pbool); jjIsSnowing = pbool;
  76.         data5.pop(pbool); jjIsSnowingOutdoorsOnly = pbool;
  77.         data5.pop(pbyte); jjSnowingIntensity = pbyte;
  78.         data5.pop(pbyte); jjSnowingType = SNOWING::Type(pbyte);
  79.  
  80.         if (jjIsSnowing) {
  81.             if (jjSnowingType == SNOWING::SNOW && jjAnimSets[ANIM::SNOW] == 0)
  82.                 jjAnimSets[ANIM::SNOW].load();
  83.             else if (jjSnowingType == SNOWING::LEAF && jjAnimSets[ANIM::PLUS_SCENERY] == 0)
  84.                 jjAnimSets[ANIM::PLUS_SCENERY].load();
  85.         }
  86.  
  87.         data5.pop(pbool); jjWarpsTransmuteCoins = pbool;
  88.         data5.pop(pbool); jjDelayGeneratedCrateOrigins = pbool;
  89.         data5.pop(pint);  jjEcho = pint;
  90.         data5.pop(puint); jjSetDarknessColor(_colorFromArgb(puint));
  91.         data5.pop(pfloat);jjWaterChangeSpeed = pfloat;
  92.         data5.pop(pbyte); jjWaterInteraction = WATERINTERACTION::WaterInteraction(pbyte);
  93.         data5.pop(pint);  jjWaterLayer = pint;
  94.         data5.pop(pbyte); jjWaterLighting = WATERLIGHT::wl(pbyte);
  95.         data5.pop(pfloat); if (int(pfloat) < jjLayerHeight[4] * 32) jjSetWaterLevel(pfloat, true);
  96.         data5.pop(puint); data5.pop(puint2); jjSetWaterGradient(_colorFromArgb(puint), _colorFromArgb(puint2));
  97.  
  98.         data5.pop(pbool); if (pbool) {
  99.             for (uint i = 0; i < 256; ++i) {
  100.                 data5.pop(palette.color[i].red);
  101.                 data5.pop(palette.color[i].green);
  102.                 data5.pop(palette.color[i].blue);
  103.             }
  104.             palette.apply();
  105.         }
  106.  
  107.         _recolorAnimationIf(data5, ANIM::PINBALL, 0, 4);
  108.         _recolorAnimationIf(data5, ANIM::PINBALL, 2, 4);
  109.         _recolorAnimationIf(data5, ANIM::CARROTPOLE, 0, 1);
  110.         _recolorAnimationIf(data5, ANIM::DIAMPOLE, 0, 1);
  111.         _recolorAnimationIf(data5, ANIM::PINBALL, 4, 8);
  112.         _recolorAnimationIf(data5, ANIM::JUNGLEPOLE, 0, 1);
  113.         _recolorAnimationIf(data5, ANIM::PLUS_SCENERY, 0, 17);
  114.         _recolorAnimationIf(data5, ANIM::PSYCHPOLE, 0, 1);
  115.         _recolorAnimationIf(data5, ANIM::SMALTREE, 0, 1);
  116.         _recolorAnimationIf(data5, ANIM::SNOW, 0, 8);
  117.         _recolorAnimationIf(data5, ANIM::COMMON, 2, 18);
  118.  
  119.         data5.pop(pbyte);
  120.         for (uint i = 0; i < pbyte; ++i) {
  121.             string tilesetFilename = _read7BitEncodedStringFromStream(data5);
  122.             uint16 tileStart, tileCount;
  123.             data5.pop(tileStart); data5.pop(tileCount);
  124.             array<uint8>@ colors = null;
  125.             data5.pop(pbool); if (pbool) {
  126.                 @colors = array<uint8>(256);
  127.                 for (uint j = 0; j < 256; ++j)
  128.                     data5.pop(colors[j]);
  129.             }
  130.             jjTilesFromTileset(tilesetFilename, tileStart, tileCount, colors);
  131.         }
  132.         if (pbyte != 0) {
  133.             array<uint> layersIDsWithTileMaps;
  134.             for (uint i = 1; i <= 8; ++i)
  135.                 if (jjLayers[i].hasTileMap)
  136.                     layersIDsWithTileMaps.insertLast(i);
  137.             jjLayersFromLevel(jjLevelFileName, layersIDsWithTileMaps);
  138.         }
  139.  
  140.         array<jjLAYER@> newLayerOrder, nonDefaultLayers;
  141.         data5.pop(puint);
  142.         for (uint i = 8; i < puint; i += 8) {
  143.             array<uint> layerIDsToGrab;
  144.             for (uint j = i; j < puint && j < i + 8; ++j) {
  145.                 layerIDsToGrab.insertLast((j & 7) + 1);
  146.             }
  147.             array<jjLAYER@> extraLayers = jjLayersFromLevel(jjLevelFileName.substr(0, jjLevelFileName.length() - 4) + '-MLLE-Data-' + (i/8) + '.j2l', layerIDsToGrab);
  148.             for (uint j = 0; j < extraLayers.length(); ++j)
  149.                 nonDefaultLayers.insertLast(extraLayers[j]);
  150.         }
  151.         uint nextNonDefaultLayerID = 0;
  152.         for (uint i = 0; i < puint; ++i) {
  153.             data5.pop(pchar);
  154.             jjLAYER@ layer;
  155.             if (pchar >= 0)
  156.                 @layer = jjLayers[pchar + 1];
  157.             else
  158.                 @layer = nonDefaultLayers[nextNonDefaultLayerID++];
  159.             string layerName = _read7BitEncodedStringFromStream(data5);
  160.             _layers.set(layerName, @layer);
  161.             data5.pop(pbool);
  162.             if (layer.hasTileMap)
  163.                 layer.hasTiles = !pbool;
  164.             data5.pop(pbyte);
  165.             layer.spriteMode = SPRITE::Mode(pbyte);
  166.             data5.pop(pbyte);
  167.             layer.spriteParam = pbyte;
  168.             data5.pop(pint);
  169.             layer.rotationAngle = pint;
  170.             data5.pop(pint);
  171.             layer.rotationRadiusMultiplier = pint;
  172.             newLayerOrder.insertLast(layer);
  173.         }
  174.         jjLayerOrderSet(newLayerOrder);
  175.  
  176.         uint16 numberOfImages; data5.pop(numberOfImages);
  177.         for (uint16 i = 0; i < numberOfImages; ++i) {
  178.             uint16 tileID; data5.pop(tileID);
  179.             jjPIXELMAP tile(32, 32);
  180.             for (int y = 0; y < 32; ++y)
  181.                 for (int x = 0; x < 32; ++x)
  182.                     data5.pop(tile[x,y]);
  183.             tile.save(tileID, true);
  184.         }
  185.         data5.pop(numberOfImages);
  186.         for (uint16 i = 0; i < numberOfImages; ++i) {
  187.             uint16 tileID; data5.pop(tileID);
  188.             jjMASKMAP tile;
  189.             for (int y = 0; y < 32; ++y)
  190.                 for (int x = 0; x < 32; ++x)
  191.                     data5.pop(tile[x,y]);
  192.             tile.save(tileID, true);
  193.         }
  194.  
  195.         if (!data5.isEmpty()) {
  196.             jjDebug('MLLE::Setup: Warning, Data5 longer than expected');
  197.         }
  198.        
  199.         return true;
  200.     }
  201.  
  202.     jjLAYER@ GetLayer(const string &in name) {
  203.         jjLAYER@ handle = null;
  204.         _layers.get(name, @handle);
  205.         return handle;
  206.     }
  207.  
  208.     jjPALCOLOR _colorFromArgb(uint Argb) {
  209.         return jjPALCOLOR(Argb >> 16, Argb >> 8, Argb >> 0);
  210.     }
  211.  
  212.     uint _read7BitEncodedUintFromStream(jjSTREAM@ stream) {
  213.         uint result = 0;
  214.         while (true) {
  215.             uint8 byteRead; stream.pop(byteRead);
  216.             result |= (byteRead & 0x7F);
  217.             if (byteRead >= 0x80)
  218.                 result <<= 7;
  219.             else
  220.                 break;
  221.         }
  222.         return result;
  223.     }
  224.     string _read7BitEncodedStringFromStream(jjSTREAM@ stream) {
  225.         string result;
  226.         stream.get(result, _read7BitEncodedUintFromStream(stream));
  227.         return result;
  228.     }
  229.  
  230.     void _recolorAnimationIf(jjSTREAM@ stream, ANIM::Set set, uint animID, uint frameCount) {
  231.         bool pbool; stream.pop(pbool); if (!pbool) return;
  232.  
  233.         if (jjAnimSets[set] == 0)
  234.             jjAnimSets[set].load();
  235.         const uint firstFrameID = jjAnimations[jjAnimSets[set] + animID];
  236.         array<uint8> colors(256);
  237.         for (uint i = 0; i < 256; ++i)
  238.             stream.pop(colors[i]);
  239.         for (uint i = 0; i < frameCount; ++i) {
  240.             jjANIMFRAME@ frame = jjAnimFrames[firstFrameID + i];
  241.             jjPIXELMAP image(frame);
  242.             for (uint x = 0; x < image.width; ++x)
  243.                 for (uint y = 0; y < image.height; ++y)
  244.                     image[x,y] = colors[image[x,y]];
  245.             image.save(frame);
  246.         }
  247.     }
  248. }