Downloads containing MLLE-Include-1.4.asc

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Holiday Hare '17Featured Download ShadowGPW Single player 8.8 Download file
TSF with JJ2+ Only: Mystery of the Four... chandie Single player 6.6 Download file
JJ2 1.23 vanilla: Miscellaneous stuff Violet CLM Multiple N/A Download file
TSF with JJ2+ Only: Faster-Than-Light StarshipFeatured Download ThunDerDraGon Capture the flag 9 Download file
TSF with JJ2+ Only: BushidoFeatured Download Laro B. Capture the flag 8.1 Download file
TSF with JJ2+ Only: SolsticeFeatured Download PurpleJazz Battle 8.9 Download file
TSF with JJ2+ Only: Isla de MuertaFeatured Download Loon Battle 9.5 Download file
TSF with JJ2+ Only: Anniversary Bash 21 Levels Jazz2Online Multiple N/A Download file
TSF with JJ2+ Only: The Fingers of IcarusFeatured Download cooba Battle 8.8 Download file
JJ2+ Only: Level in which a spiked... happygreenfrog Single player 6.7 Download file
TSF with JJ2+ Only: Castle of Devan ShellFeatured Download Laro B. Capture the flag 8.7 Download file
TSF with JJ2+ Only: Holiday Hare '18Featured Download SmokeNC Single player 8.9 Download file
TSF with JJ2+ Only: Chasing the StarsFeatured Download cooba Battle 8.7 Download file
JJ2+ Only: Foo Single Player 2/14:...Featured Download Violet CLM Single player 10 Download file
TSF with JJ2+ Only: R├║nheimrFeatured Download Seren Battle 8.7 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: Re-Purposed Offshore...Featured Download FireSworD Capture the flag 8.9 Download file
TSF with JJ2+ Only: The CrackdownFeatured Download cooba Capture the flag 9 Download file
TSF with JJ2+ Only: Painted GardenFeatured Download PurpleJazz Capture the flag 8.6 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.8 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 Levels Jazz2Online Multiple N/A Download file
TSF with JJ2+ Only: Mt. CinderFeatured Download PurpleJazz Capture the flag 9 Download file
JJ2+ Only: ThermaeFeatured Download Jelly Jam Battle 8.5 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.7 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.4 Download file
TSF with JJ2+ Only: RabbitCity Remastered P4rr0t Single player 7.5 Download file

File preview

//2220731962
//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.





#pragma require 'MLLE-Include-1.4.asc'
namespace MLLE {
    jjPAL@ Palette;
    dictionary@ _layers;

    bool Setup() {
        jjPAL palette = jjBackupPalette;
        @Palette = @palette;
        dictionary layers;
        @_layers = @layers;

        jjSTREAM crcCheck('MLLE-Include-1.4.asc');
        string crcLine;
        if (crcCheck.isEmpty() || !crcCheck.getLine(crcLine)) {
            jjDebug('MLLE::Setup: Include file has been renamed!');
            return false;
        }
        array<string> regexResults;
        if (!jjRegexMatch(crcLine, '\\/\\/(\\d+)\\r?', regexResults)) {
            jjDebug('MLLE::Setup: Include file is improperly formatted!');
            return false;
        }
        if (parseUInt(regexResults[1]) != jjCRC32(crcCheck)) {
            jjDebug('MLLE::Setup: Include file has been damaged!');
            return false;
        }
        
        jjSTREAM level(jjLevelFileName);
        if (level.isEmpty()) {
            jjDebug('MLLE::Setup: Level file cannot be read from that folder for security reasons!');
            return false;
        }
        level.discard(230);
        array<uint> CompressedDataSizes(4, 0);
        for (uint i = 0; i < CompressedDataSizes.length; ++i) {
            level.pop(CompressedDataSizes[i]);
            level.discard(4);
        }
        for (uint i = 0; i < CompressedDataSizes.length; ++i)
            level.discard(CompressedDataSizes[i]);

        if (level.getSize() < 20) {
            jjDebug('MLLE::Setup: Level file does not contain any additional data!');
            return false;
        }
        string magic;
        level.get(magic, 'MLLE'.length);
        if (magic != 'MLLE') {
            jjDebug('MLLE::Setup: Level was not saved by MLLE!');
            return false;
        }
        uint levelDataVersion;
        level.pop(levelDataVersion);
        if (levelDataVersion != 0x104) {
            jjDebug('MLLE::Setup: Level\'s Data5 section was saved in a different version of MLLE than this script!');
            return false;
        }

        uint csize, usize;
        level.pop(csize); level.pop(usize);
        jjSTREAM data5;
        if (!jjZlibUncompress(level, data5, usize)) {
            jjDebug('MLLE::Setup: Error during ZLIB uncompression!');
            return false;
        }

        bool pbool; uint8 pbyte; int8 pchar; float pfloat; int pint; uint puint, puint2;
        data5.pop(pbool); jjIsSnowing = pbool;
        data5.pop(pbool); jjIsSnowingOutdoorsOnly = pbool;
        data5.pop(pbyte); jjSnowingIntensity = pbyte;
        data5.pop(pbyte); jjSnowingType = SNOWING::Type(pbyte);

        if (jjIsSnowing) {
            if (jjSnowingType == SNOWING::SNOW && jjAnimSets[ANIM::SNOW] == 0)
                jjAnimSets[ANIM::SNOW].load();
            else if (jjSnowingType == SNOWING::LEAF && jjAnimSets[ANIM::PLUS_SCENERY] == 0)
                jjAnimSets[ANIM::PLUS_SCENERY].load();
        }

        data5.pop(pbool); jjWarpsTransmuteCoins = pbool;
        data5.pop(pbool); jjDelayGeneratedCrateOrigins = pbool;
        data5.pop(pint);  jjEcho = pint;
        data5.pop(puint); jjSetDarknessColor(_colorFromArgb(puint));
        data5.pop(pfloat);jjWaterChangeSpeed = pfloat;
        data5.pop(pbyte); jjWaterInteraction = WATERINTERACTION::WaterInteraction(pbyte);
        data5.pop(pint);  jjWaterLayer = pint;
        data5.pop(pbyte); jjWaterLighting = WATERLIGHT::wl(pbyte);
        data5.pop(pfloat); if (int(pfloat) < jjLayerHeight[4] * 32) jjSetWaterLevel(pfloat, true);
        data5.pop(puint); data5.pop(puint2); jjSetWaterGradient(_colorFromArgb(puint), _colorFromArgb(puint2));

        data5.pop(pbool); if (pbool) {
            for (uint i = 0; i < 256; ++i) {
                data5.pop(palette.color[i].red);
                data5.pop(palette.color[i].green);
                data5.pop(palette.color[i].blue);
            }
            palette.apply();
        }

        _recolorAnimationIf(data5, ANIM::PINBALL, 0, 4);
        _recolorAnimationIf(data5, ANIM::PINBALL, 2, 4);
        _recolorAnimationIf(data5, ANIM::CARROTPOLE, 0, 1);
        _recolorAnimationIf(data5, ANIM::DIAMPOLE, 0, 1);
        _recolorAnimationIf(data5, ANIM::PINBALL, 4, 8);
        _recolorAnimationIf(data5, ANIM::JUNGLEPOLE, 0, 1);
        _recolorAnimationIf(data5, ANIM::PLUS_SCENERY, 0, 17);
        _recolorAnimationIf(data5, ANIM::PSYCHPOLE, 0, 1);
        _recolorAnimationIf(data5, ANIM::SMALTREE, 0, 1);
        _recolorAnimationIf(data5, ANIM::SNOW, 0, 8);
        _recolorAnimationIf(data5, ANIM::COMMON, 2, 18);

        data5.pop(pbyte);
        for (uint i = 0; i < pbyte; ++i) {
            string tilesetFilename = _read7BitEncodedStringFromStream(data5);
            uint16 tileStart, tileCount;
            data5.pop(tileStart); data5.pop(tileCount);
            array<uint8>@ colors = null;
            data5.pop(pbool); if (pbool) {
                @colors = array<uint8>(256);
                for (uint j = 0; j < 256; ++j)
                    data5.pop(colors[j]);
            }
            jjTilesFromTileset(tilesetFilename, tileStart, tileCount, colors);
        }
        if (pbyte != 0) {
            array<uint> layersIDsWithTileMaps;
            for (uint i = 1; i <= 8; ++i)
                if (jjLayers[i].hasTileMap)
                    layersIDsWithTileMaps.insertLast(i);
            jjLayersFromLevel(jjLevelFileName, layersIDsWithTileMaps);
        }

        array<jjLAYER@> newLayerOrder, nonDefaultLayers;
        data5.pop(puint);
        for (uint i = 8; i < puint; i += 8) {
            array<uint> layerIDsToGrab;
            for (uint j = i; j < puint && j < i + 8; ++j) {
                layerIDsToGrab.insertLast((j & 7) + 1);
            }
            array<jjLAYER@> extraLayers = jjLayersFromLevel(jjLevelFileName.substr(0, jjLevelFileName.length() - 4) + '-MLLE-Data-' + (i/8) + '.j2l', layerIDsToGrab);
            for (uint j = 0; j < extraLayers.length(); ++j)
                nonDefaultLayers.insertLast(extraLayers[j]);
        }
        uint nextNonDefaultLayerID = 0;
        for (uint i = 0; i < puint; ++i) {
            data5.pop(pchar);
            jjLAYER@ layer;
            if (pchar >= 0)
                @layer = jjLayers[pchar + 1];
            else
                @layer = nonDefaultLayers[nextNonDefaultLayerID++];
            string layerName = _read7BitEncodedStringFromStream(data5);
            _layers.set(layerName, @layer);
            data5.pop(pbool);
            if (layer.hasTileMap)
                layer.hasTiles = !pbool;
            data5.pop(pbyte);
            layer.spriteMode = SPRITE::Mode(pbyte);
            data5.pop(pbyte);
            layer.spriteParam = pbyte;
            data5.pop(pint);
            layer.rotationAngle = pint;
            data5.pop(pint);
            layer.rotationRadiusMultiplier = pint;
            newLayerOrder.insertLast(layer);
        }
        jjLayerOrderSet(newLayerOrder);

        uint16 numberOfImages; data5.pop(numberOfImages);
        for (uint16 i = 0; i < numberOfImages; ++i) {
            uint16 tileID; data5.pop(tileID);
            jjPIXELMAP tile(32, 32);
            for (int y = 0; y < 32; ++y)
                for (int x = 0; x < 32; ++x)
                    data5.pop(tile[x,y]);
            tile.save(tileID, true);
        }
        data5.pop(numberOfImages);
        for (uint16 i = 0; i < numberOfImages; ++i) {
            uint16 tileID; data5.pop(tileID);
            jjMASKMAP tile;
            for (int y = 0; y < 32; ++y)
                for (int x = 0; x < 32; ++x)
                    data5.pop(tile[x,y]);
            tile.save(tileID, true);
        }

        if (!data5.isEmpty()) {
            jjDebug('MLLE::Setup: Warning, Data5 longer than expected');
        }
        
        return true;
    }

    jjLAYER@ GetLayer(const string &in name) {
        jjLAYER@ handle = null;
        _layers.get(name, @handle);
        return handle;
    }

    jjPALCOLOR _colorFromArgb(uint Argb) {
        return jjPALCOLOR(Argb >> 16, Argb >> 8, Argb >> 0);
    }

    uint _read7BitEncodedUintFromStream(jjSTREAM@ stream) {
        uint result = 0;
        while (true) {
            uint8 byteRead; stream.pop(byteRead);
            result |= (byteRead & 0x7F);
            if (byteRead >= 0x80)
                result <<= 7;
            else
                break;
        }
        return result;
    }
    string _read7BitEncodedStringFromStream(jjSTREAM@ stream) {
        string result;
        stream.get(result, _read7BitEncodedUintFromStream(stream));
        return result;
    }

    void _recolorAnimationIf(jjSTREAM@ stream, ANIM::Set set, uint animID, uint frameCount) {
        bool pbool; stream.pop(pbool); if (!pbool) return;

        if (jjAnimSets[set] == 0)
            jjAnimSets[set].load();
        const uint firstFrameID = jjAnimations[jjAnimSets[set] + animID];
        array<uint8> colors(256);
        for (uint i = 0; i < 256; ++i)
            stream.pop(colors[i]);
        for (uint i = 0; i < frameCount; ++i) {
            jjANIMFRAME@ frame = jjAnimFrames[firstFrameID + i];
            jjPIXELMAP image(frame);
            for (uint x = 0; x < image.width; ++x)
                for (uint y = 0; y < image.height; ++y)
                    image[x,y] = colors[image[x,y]];
            image.save(frame);
        }
    }
}