<commit_before>#include "CParticleElectricDataFactory.hpp"
#include "CElectricDescription.hpp"
#include "CSimplePool.hpp"
#include "CRandom16.hpp"

namespace Retro
{

using CPF = CParticleDataFactory;

CElectricDescription* CParticleElectricDataFactory::GetGeneratorDesc(CInputStream &in, CSimplePool *resPool)
{
    return CreateElectricDescription(in, resPool);
}

CElectricDescription* CParticleElectricDataFactory::CreateElectricDescription(CInputStream &in, CSimplePool *resPool)
{
    FourCC cid = CParticleDataFactory::GetClassID(in);
    if (cid == FOURCC('ELSM'))
    {
        CElectricDescription* ret = new CElectricDescription;
        CreateELSM(desc, in, resPool);
        LoadELSMTokens(ret);
        return ret;
    }

    return nullptr;
}

bool CParticleElectricDataFactory::CreateELSM(CElectricDescription *desc, CInputStream &in, CSimplePool *resPool)
{
    CRandom16 rand;
    FourCC clsId = CPF::GetClassID(in);
    while (clsId != SBIG('_END'))
    {
        CGlobalRandom gr(rand);
        switch(clsId)
        {
        case SBIG(''):
            desc->x0_LIFE.reset(CPF::GetIntElement(in));
        break;
        case SBIG('SLIF'):
            desc->x4_SLIF.reset(CPF::GetIntElement(in));
        break;
        case SBIG('GRAT'):
            desc->x8_GRAT.reset(CPF::GetRealElement(in));
        break;
        case SBIG('SCNT'):
            desc->xc_SCNT.reset(CPF::GetIntElement(in));
        break;
        case SBIG('SSEG'):
            desc->x10_SSEG.reset(CPF::GetIntElement(in));
        break;
        case SBIG('COLR'):
            desc->x14_COLR.reset(CPF::GetColorElement(in));
        break;
        case SBIG('IEMT'):
            desc->x18_IEMT = CPF::GetBool(in);
        break;
        case SBIG('FEMT'):
            desc->x1c_FEMT = CPF::GetBool(in);
        break;
        case SBIG('AMPL'):
            desc->x20_AMPL = CPF::GetBool(in);
        break;
        case SBIG('AMPD'):
            desc->x24_AMPD = CPF::GetBool(in);
        break;
        case SBIG('LWD1'):
            desc->x28_LWD1 = CPF::GetBool(in);
        break;
        case SBIG('LWD2'):
            desc->x2c_LWD2 = CPF::GetBool(in);
        break;
        case SBIG('LWD3'):
            desc->x30_LWD3 = CPF::GetBool(in);
        break;
        case SBIG('LCL1'):
            desc->x34_LCL1.reset(CPF::GetColorElement(in));
        break;
        case SBIG('LCL2'):
            desc->x38_LCL2.reset(CPF::GetColorElement(in));
        break;
        case SBIG('LCL3'):
            desc->x3c_LCL3.reset(CPF::GetColorElement(in));
        break;
        case SBIG('SSWH'):
            desc->x40_SSWH = CPF::GetSwooshGeneratorDesc(in, resPool);
            break;
        case SBIG('GPSM'):
        {
            std::vector<TResId> tracker;
            tracker.reserve(8);
            desc->x50_GPSM = CPF::GetChildGeneratorDesc(in, resPool, tracker);
            break;
        }
        case SBIG('EPSM'):
        {
            std::vector<TResId> tracker;
            tracker.reserve(8);
            desc->x60_EPSM = CPF::GetChildGeneratorDesc(in, resPool, tracker);
            break;
        }
        case SBIG('ZERY'):
            desc->x70_ZERY = CPF::GetBool(in);
        break;
        }
    }
    return false;
}

std::unique_ptr<Retro::IObj> FParticleElecrticFactory(const Retro::SObjectTag &tag, Retro::CInputStream &in, const Retro::CVParamTransfer &vparms)
{
    CSimplePool* sp = static_cast<CSimplePool*>(static_cast<TObjOwnerParam<IObjectStore*>*>(vparms.GetObj())->GetParam());
    return TToken<CElectricDescription>::GetIObjObjectFor(std::unique_ptr<CElectricDescription>(CParticleElectricDataFactory::GetGeneratorDesc(in, sp)));
}

}
<commit_msg>ELSC fixes<commit_after>#include "CParticleElectricDataFactory.hpp"
#include "CElectricDescription.hpp"
#include "CSimplePool.hpp"
#include "CRandom16.hpp"

namespace Retro
{

using CPF = CParticleDataFactory;

CElectricDescription* CParticleElectricDataFactory::GetGeneratorDesc(CInputStream &in, CSimplePool *resPool)
{
    return CreateElectricDescription(in, resPool);
}

CElectricDescription* CParticleElectricDataFactory::CreateElectricDescription(CInputStream &in, CSimplePool *resPool)
{
    FourCC cid = CParticleDataFactory::GetClassID(in);
    if (cid == FOURCC('ELSM'))
    {
        CElectricDescription* ret = new CElectricDescription;
        CreateELSM(desc, in, resPool);
        LoadELSMTokens(ret);
        return ret;
    }

    return nullptr;
}

bool CParticleElectricDataFactory::CreateELSM(CElectricDescription *desc, CInputStream &in, CSimplePool *resPool)
{
    CRandom16 rand;
    FourCC clsId = CPF::GetClassID(in);
    while (clsId != SBIG('_END'))
    {
        CGlobalRandom gr(rand);
        switch(clsId)
        {
        case SBIG(''):
            desc->x0_LIFE.reset(CPF::GetIntElement(in));
        break;
        case SBIG('SLIF'):
            desc->x4_SLIF.reset(CPF::GetIntElement(in));
        break;
        case SBIG('GRAT'):
            desc->x8_GRAT.reset(CPF::GetRealElement(in));
        break;
        case SBIG('SCNT'):
            desc->xc_SCNT.reset(CPF::GetIntElement(in));
        break;
        case SBIG('SSEG'):
            desc->x10_SSEG.reset(CPF::GetIntElement(in));
        break;
        case SBIG('COLR'):
            desc->x14_COLR.reset(CPF::GetColorElement(in));
        break;
        case SBIG('IEMT'):
            desc->x18_IEMT = CPF::GetBool(in);
        break;
        case SBIG('FEMT'):
            desc->x1c_FEMT = CPF::GetBool(in);
        break;
        case SBIG('AMPL'):
            desc->x20_AMPL = CPF::GetBool(in);
        break;
        case SBIG('AMPD'):
            desc->x24_AMPD = CPF::GetBool(in);
        break;
        case SBIG('LWD1'):
            desc->x28_LWD1 = CPF::GetBool(in);
        break;
        case SBIG('LWD2'):
            desc->x2c_LWD2 = CPF::GetBool(in);
        break;
        case SBIG('LWD3'):
            desc->x30_LWD3 = CPF::GetBool(in);
        break;
        case SBIG('LCL1'):
            desc->x34_LCL1.reset(CPF::GetColorElement(in));
        break;
        case SBIG('LCL2'):
            desc->x38_LCL2.reset(CPF::GetColorElement(in));
        break;
        case SBIG('LCL3'):
            desc->x3c_LCL3.reset(CPF::GetColorElement(in));
        break;
        case SBIG('SSWH'):
            desc->x40_SSWH = CPF::GetSwooshGeneratorDesc(in, resPool);
            break;
        case SBIG('GPSM'):
        {
            std::vector<TResId> tracker;
            tracker.reserve(8);
            desc->x50_GPSM = CPF::GetChildGeneratorDesc(in, resPool, tracker);
            break;
        }
        case SBIG('EPSM'):
        {
            std::vector<TResId> tracker;
            tracker.reserve(8);
            desc->x60_EPSM = CPF::GetChildGeneratorDesc(in, resPool, tracker);
            break;
        }
        case SBIG('ZERY'):
            desc->x70_ZERY = CPF::GetBool(in);
        break;
        default:
        {
            uint32_t clsName = clsId.toUint32();
            Log.report(LogVisor::FatalError, "Unknown ELSM class %.4s @%" PRIi64, &clsName, in.position());
            return false;
        }
        }
        clsId = GetClassID(in);
    }
    return true;
}

std::unique_ptr<Retro::IObj> FParticleElecrticFactory(const Retro::SObjectTag &tag, Retro::CInputStream &in, const Retro::CVParamTransfer &vparms)
{
    CSimplePool* sp = static_cast<CSimplePool*>(static_cast<TObjOwnerParam<IObjectStore*>*>(vparms.GetObj())->GetParam());
    return TToken<CElectricDescription>::GetIObjObjectFor(std::unique_ptr<CElectricDescription>(CParticleElectricDataFactory::GetGeneratorDesc(in, sp)));
}

}

{'fraction_non_alphanumeric': 0.13520609083749016, 'fraction_numerical': 0.014045681281176161, 'mean_word_length': 2.5159206275957544, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3100650', 'n_tokens_mistral': 2620, 'n_tokens_neox': 2546, 'n_words': 379}