[3.3.5] SpellOnLevel script that broke from old TC to Newest rev.

I’ve been dealing with this issue for days now, and after getting frustrated enough decided to post on here.

I have noticed Trainer.cpp and Trainer.h are new files in the newer revision and hence alot of changes has been made from the older revisions, stuff from creature has been reworked and implemented into the new file game/creature/Trainer for instance.

This is the piece of code that has been causing my compiler to error for the last couple of days without any success fixes:

auto spells = sObjectMgr->GetNpcTrainerSpells(Trainer); // class trainer
        if (!spells)
            return;
        auto spellList = spells->spellList;
        for (auto itr = spellList.begin(); itr != spellList.end(); ++itr)
        {
            TrainerSpell const* tSpell = &itr->second;

            const SpellInfo* info = sSpellMgr->GetSpellInfo(tSpell->SpellID);
            if (!info)
                continue;

            bool valid = true;
            for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
            {
                if (!tSpell->ReqAbility[i])
                    continue;
                if (!player->IsSpellFitByClassAndRace(tSpell->ReqAbility[i]))
                {
                    valid = false;
                    break;
                }
            }

            if (!valid)
                continue;
            if (info->Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL)
                player->CastSpell(player, tSpell->SpellID, false);
            else
                player->LearnSpell(tSpell->SpellID, false);
        }

Errors are the following:

[FONT=Consolas]fresh tc\elunatrinitywotlk\src\server\scripts\custom\learnspellonlevelup.cpp(38): error C2039: ‘spellList’: is not a member of ‘Trainer::Trainer’ [/FONT]

[FONT=Consolas]fresh tc\elunatrinitywotlk\src\server\game\entities\creature\trainer.h(65): note: see declaration of ‘Trainer::Trainer’ [/FONT]

[FONT=Consolas]fresh tc\elunatrinitywotlk\src\server\scripts\custom\learnspellonlevelup.cpp(39): error C3536: ‘spellList’: cannot be used before it is initialized [/FONT]

[FONT=Consolas]fresh tc\elunatrinitywotlk\src\server\scripts\custom\learnspellonlevelup.cpp(39): error C3536: ‘itr’: cannot be used before it is initialized [/FONT]

[FONT=Consolas]fresh tc\elunatrinitywotlk\src\server\scripts\custom\learnspellonlevelup.cpp(41): error C2065: ‘trainerSpell’: undeclared identifier [/FONT]

[FONT=Consolas]fresh tc\elunatrinitywotlk\src\server\scripts\custom\learnspellonlevelup.cpp(41): error C2143: syntax error: missing ‘;’ before ‘const’ [/FONT]

[FONT=Consolas]fresh tc\elunatrinitywotlk\src\server\scripts\custom\learnspellonlevelup.cpp(41): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int[/FONT]