From 3595239f08f2bc1df32ef22ed6de9bde10ca3384 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 4 Jun 2007 01:35:20 +0000 Subject: Style cleanup, minor Matrix fixes, duplication validations, Pokemod methods git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@19 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/Pokemod.cpp | 2611 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 2607 insertions(+), 4 deletions(-) (limited to 'pokemod/Pokemod.cpp') diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp index 4799fd89..615fb565 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: pokemod/Pokemod.cpp -// Purpose: +// Purpose: Define a custom PokéMod for PokéGen // Author: Ben Boeckel // Modified by: Ben Boeckel // Created: Sat Feb 24 21:41:19 2007 @@ -23,7 +23,54 @@ #include "Pokemod.h" -PokeGen::PokeMod::Pokemod::Pokemod() +PokeGen::PokeMod::Pokemod::Pokemod() : + title(""), + version(""), + description(""), + genderAllowed(false), + breedingAllowed(false), + eggSpecies(UINT_MAX), + holdItems(false), + criticalDomains(false), + contestAllowed(false), + abilityAllowed(false), + natureAllowed(false), + numDaycares(0), + numPokemonBoxes(0), + numPokemonPerBox(1), + maxParty(1), + maxFight(1), + maxMoves(1), + maxLevel(1), + maxMoney(0), + hardCash(false), + specialSplit(false), + specialDVSplit(false), + maxDVValue(16), + happiness(false), + happyFaintLoss(0), + happyLevelGain(0), + happySteps(0), + effortValuesAllowed(false), + maxTotalEV(0), + maxEVPerStat(0), + pokerusChance(1, 1), + startMap(UINT_MAX), + startMoney(0), + startCoordinate(0, 0), + startDirection(UINT_MAX), + startDialog(UINT_MAX), + walkSkin(""), + bikeSkin(""), + surfSkin(""), + flySkin(""), + fishSkin(""), + surfFishSkin(""), + superPCUname(""), + superPCPasswd(""), + struggleMove(UINT_MAX), + confuseMove(UINT_MAX), + typeChart(1, 1, Frac(1, 1, true)) { LogCtor("Pokemod", 0); } @@ -43,6 +90,7 @@ void PokeGen::PokeMod::Pokemod::Validate() { LogValidateStart("Pokemod", 0); // TODO (Validation#1#): Pokemod Validation +# warning "Pokemod Validation" LogValidateOver("Pokemod", 0, isValid); } @@ -55,10 +103,2565 @@ void PokeGen::PokeMod::Pokemod::Validate(const wxListBox &output) void PokeGen::PokeMod::Pokemod::ImportIni(std::ifstream &fin) { - // TODO (Ini#1#): Import Pokemod + LogImportStart("Pokemod"); + std::vector sections; + Ini meta("unset"); + while (fin.peek() != '\n') + { + Ini curSection(fin); + if (curSection.GetName() == "pokemod") + { + if (meta.GetName() == "unset") + { + Log(String("Pokemod: Multiple meta data sections in PokéMod file"), PM_DEBUG_ERROR); + return; + } + meta = curSection; + unsigned i; + unsigned j; + curSection.GetValue("title", title); + curSection.GetValue("version", version); + curSection.GetValue("description", description); + curSection.GetValue("genderAllowed", genderAllowed, false); + curSection.GetValue("breedingAllowed", breedingAllowed, false); + curSection.GetValue("eggSpecies", eggSpecies); + curSection.GetValue("holdItems", holdItems, false); + curSection.GetValue("criticalDomains", criticalDomains, false); + curSection.GetValue("contestAllowed", contestAllowed, false); + curSection.GetValue("abilityAllowed", abilityAllowed, false); + curSection.GetValue("natureAllowed", natureAllowed, false); + curSection.GetValue("numDaycares", numDaycares, 0); + curSection.GetValue("numPokemonBoxes", numPokemonBoxes, 0); + curSection.GetValue("numPokemonPerBox", numPokemonPerBox, 1); + curSection.GetValue("maxParty", maxParty, 1); + curSection.GetValue("maxFight", maxFight, 1); + curSection.GetValue("maxMoves", maxMoves, 1); + curSection.GetValue("maxLevel", maxLevel, 0); + curSection.GetValue("maxMoney", maxMoney, 0); + curSection.GetValue("hardCash", hardCash, false); + curSection.GetValue("specialSplit", specialSplit, false); + curSection.GetValue("specialDVSplit", specialDVSplit, false); + curSection.GetValue("maxDVValue", maxDVValue, 16); + curSection.GetValue("happiness", happiness, false); + curSection.GetValue("happyFaintLoss", happyFaintLoss, 0); + curSection.GetValue("happyLevelGain", happyLevelGain, 0); + curSection.GetValue("happySteps", happySteps, 0); + curSection.GetValue("effortValuesAllowed", effortValuesAllowed, false); + curSection.GetValue("maxTotalEV", maxTotalEV, 0); + curSection.GetValue("maxEVPerStat", maxEVPerStat, 0); + curSection.GetValue("pokerusChance-n", i, 1); + curSection.GetValue("pokerusChance-d", j, 1); + pokerusChance.Set(i, j); + curSection.GetValue("startMap", startMap); + curSection.GetValue("startMoney", startMoney, 0); + curSection.GetValue("startCoordinate-x", i, 0); + curSection.GetValue("startCoordinate-y", j, 0); + startCoordinate.Set(i, j); + curSection.GetValue("startDirection", startDirection); + curSection.GetValue("startDialog", startDialog); + curSection.GetValue("walkSkin", walkSkin); + curSection.GetValue("bikeSkin", bikeSkin); + curSection.GetValue("surfSkin", surfSkin); + curSection.GetValue("flySkin", flySkin); + curSection.GetValue("fishSkin", fishSkin); + curSection.GetValue("surfFishSkin", surfFishSkin); + curSection.GetValue("superPCUname", superPCUname); + curSection.GetValue("superPCPasswd", superPCPasswd); + curSection.GetValue("struggleMove", struggleMove); + curSection.GetValue("confuseMove", confuseMove); + } + else if (curSection.GetName() == "ability") + NewAbility(&curSection); + else if (curSection.GetName() == "author") + NewAuthor(&curSection); + else if (curSection.GetName() == "badge") + NewBadge(&curSection); + else if (curSection.GetName() == "coinList") + NewCoinList(&curSection); + else if (curSection.GetName() == "dialog") + NewDialog(&curSection); + else if (curSection.GetName() == "eggGroup") + NewEggGroup(&curSection); + else if (curSection.GetName() == "item") + NewItem(&curSection); + else if (curSection.GetName() == "itemStorage") + NewItemStorage(&curSection); + else if (curSection.GetName() == "map") + NewMap(&curSection); + else if (curSection.GetName() == "move") + NewMove(&curSection); + else if (curSection.GetName() == "nature") + NewNature(&curSection); + else if (curSection.GetName() == "pokemon") + NewPokemon(&curSection); + else if (curSection.GetName() == "status") + NewStatus(&curSection); + else if (curSection.GetName() == "store") + NewStore(&curSection); + else if (curSection.GetName() == "tile") + NewTile(&curSection); + else if (curSection.GetName() == "time") + NewTime(&curSection); + else if (curSection.GetName() == "type") + NewType(&curSection); + else + sections.push_back(curSection); + } + if (meta.GetName() == "unset") + { + Log(String("Pokemod: No meta data found in PokéMod file"), PM_DEBUG_ERROR); + return; + } + for (std::vector::iterator i = types.begin(); i != types.end(); ++i) + { + for (std::vector::iterator j = types.begin(); j != types.end(); ++j) + { + unsigned k; + unsigned l; + meta.GetValue(String("typeChart-%u-%u-n", i->GetId(), j->GetId()), k, 1); + meta.GetValue(String("typeChart-%u-%u-d", i->GetId(), j->GetId()), l, 1); + SetTypeChart(i->GetId(), j->GetId(), k, l); + } + } + std::stringstream ss; + std::string s; + std::string s1; + unsigned u; + for (std::vector::iterator i = sections.begin(); i != sections.end(); ++i) + { + ss.write(i->GetName().c_str(), i->GetName().length()); + ss >> s; + ss >> s1; + if (s == "abilityEffect") + { + if (Ability *a = (Ability *)GetAbility(s1)) + a->NewAbilityEffect(&*i); + sections.erase(i); + } + else if (s == "coinItem") + { + if (CoinList *c = (CoinList *)GetCoinList(s1)) + c->NewCoinItem(&*i); + sections.erase(i); + } + else if (s == "itemEffect") + { + if (Item *it = (Item *)GetItem(s1)) + it->NewItemEffect(&*i); + sections.erase(i); + } + else if (s == "mapEffect") + { + if (Map *m = (Map *)GetMap(s1)) + m->NewMapEffect(&*i); + sections.erase(i); + } + else if (s == "mapTrainer") + { + if (Map *m = (Map *)GetMap(s1)) + m->NewMapTrainer(&*i); + sections.erase(i); + } + else if (s == "mapWarp") + { + if (Map *m = (Map *)GetMap(s1)) + m->NewMapWarp(&*i); + sections.erase(i); + } + else if (s == "mapWildList") + { + if (Map *m = (Map *)GetMap(s1)) + m->NewMapWildList(&*i); + sections.erase(i); + } + else if (s == "moveEffect") + { + if (Move *m = (Move *)GetMove(s1)) + m->NewMoveEffect(&*i); + sections.erase(i); + } + else if (s == "natureEffect") + { + if (Nature *n = (Nature *)GetNature(s1)) + n->NewNatureEffect(&*i); + sections.erase(i); + } + else if (s == "pokemonAbility") + { + if (Pokemon *p = (Pokemon *)GetPokemon(s1)) + p->NewPokemonAbility(&*i); + sections.erase(i); + } + else if (s == "pokemonEvolution") + { + if (Pokemon *p = (Pokemon *)GetPokemon(s1)) + p->NewPokemonEvolution(&*i); + sections.erase(i); + } + else if (s == "pokemonItem") + { + if (Pokemon *p = (Pokemon *)GetPokemon(s1)) + p->NewPokemonItem(&*i); + sections.erase(i); + } + else if (s == "pokemonMove") + { + if (Pokemon *p = (Pokemon *)GetPokemon(s1)) + p->NewPokemonMove(&*i); + sections.erase(i); + } + else if (s == "pokemonNature") + { + if (Pokemon *p = (Pokemon *)GetPokemon(s1)) + p->NewPokemonNature(&*i); + sections.erase(i); + } + else if (s == "statusEffect") + { + if (Status *st = (Status *)GetStatus(s1)) + st->NewStatusEffect(&*i); + sections.erase(i); + } + ss.clear(); + } + for (std::vector::iterator i = sections.begin(); i != sections.end(); ++i) + { + if (s == "mapTrainerTeam") + { + ss >> u; + if (const Map *m = GetMap(s1)) + { + if (MapTrainer *t = (MapTrainer *)m->GetMapTrainer(u)) + t->NewMapTrainerTeam(&*i); + } + sections.erase(i); + } + else if (s == "mapWildPokemon") + { + ss >> u; + if (const Map *m = GetMap(s1)) + { + if (MapWildList *t = (MapWildList *)m->GetMapWildList(u)) + t->NewMapWildPokemon(&*i); + } + sections.erase(i); + } + } + for (std::vector::iterator i = sections.begin(); i != sections.end(); ++i) + Log(String("Pokemod: Unused INI section named \"%s\"", i->GetName().c_str()), PM_DEBUG_INFO); + LogImportOver("Pokemod", 0, title); } void PokeGen::PokeMod::Pokemod::ExportIni(std::ofstream &fout) const { - // TODO (Ini#1#): Export Pokemod + LogExportStart("Pokemod", 0, title); + Ini exPokemod("pokemod"); + exPokemod.AddField("title", title); + exPokemod.AddField("version", version); + exPokemod.AddField("description", description); + exPokemod.AddField("genderAllowed", genderAllowed); + exPokemod.AddField("breedingAllowed", breedingAllowed); + exPokemod.AddField("eggSpecies", eggSpecies); + exPokemod.AddField("holdItems", holdItems); + exPokemod.AddField("criticalDomains", criticalDomains); + exPokemod.AddField("contestAllowed", contestAllowed); + exPokemod.AddField("abilityAllowed", abilityAllowed); + exPokemod.AddField("natureAllowed", natureAllowed); + exPokemod.AddField("numDaycares", numDaycares); + exPokemod.AddField("numPokemonBoxes", numPokemonBoxes); + exPokemod.AddField("numPokemonPerBox", numPokemonPerBox); + exPokemod.AddField("maxParty", maxParty); + exPokemod.AddField("maxFight", maxFight); + exPokemod.AddField("maxMoves", maxMoves); + exPokemod.AddField("maxLevel", maxLevel); + exPokemod.AddField("maxMoney", maxMoney); + exPokemod.AddField("hardCash", hardCash); + exPokemod.AddField("specialSplit", specialSplit); + exPokemod.AddField("specialDVSplit", specialDVSplit); + exPokemod.AddField("maxDVValue", maxDVValue); + exPokemod.AddField("happiness", happiness); + exPokemod.AddField("happyFaintLoss", happyFaintLoss); + exPokemod.AddField("happyLevelGain", happyLevelGain); + exPokemod.AddField("happySteps", happySteps); + exPokemod.AddField("effortValuesAllowed", effortValuesAllowed); + exPokemod.AddField("maxTotalEV", maxTotalEV); + exPokemod.AddField("maxEVPerStat", maxEVPerStat); + exPokemod.AddField("pokerusChance-n", pokerusChance.GetNum()); + exPokemod.AddField("pokerusChance-d", pokerusChance.GetDenom()); + exPokemod.AddField("startMap", startMap); + exPokemod.AddField("startMoney", startMoney); + exPokemod.AddField("startCoordinate-x", startCoordinate.GetX()); + exPokemod.AddField("startCoordinate-y", startCoordinate.GetY()); + exPokemod.AddField("startDirection", startDirection); + exPokemod.AddField("startDialog", startDialog); + exPokemod.AddField("walkSkin", walkSkin); + exPokemod.AddField("bikeSkin", bikeSkin); + exPokemod.AddField("surfSkin", surfSkin); + exPokemod.AddField("flySkin", flySkin); + exPokemod.AddField("fishSkin", fishSkin); + exPokemod.AddField("surfFishSkin", surfFishSkin); + exPokemod.AddField("superPCUname", superPCUname); + exPokemod.AddField("superPCPasswd", superPCPasswd); + exPokemod.AddField("struggleMove", struggleMove); + exPokemod.AddField("confuseMove", confuseMove); + for (unsigned i = 1; i < typeChart.GetWidth(); ++i) + { + for (unsigned j = 1; j < typeChart.GetHeight(); ++j) + { + exPokemod.AddField(String("typeChart-%u-%u-n", typeChart[i][0].GetNum(), typeChart[0][j].GetNum()), typeChart[i][j].GetNum()); + exPokemod.AddField(String("typeChart-%u-%u-d", typeChart[i][0].GetNum(), typeChart[0][j].GetNum()), typeChart[i][j].GetDenom()); + } + } + exPokemod.Export(fout); + for (std::vector::const_iterator i = abilities.begin(); i != abilities.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = authors.begin(); i != authors.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = badges.begin(); i != badges.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = coinLists.begin(); i != coinLists.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = dialogs.begin(); i != dialogs.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = eggGroups.begin(); i != eggGroups.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = items.begin(); i != items.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = itemStorages.begin(); i != itemStorages.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = maps.begin(); i != maps.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = moves.begin(); i != moves.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = natures.begin(); i != natures.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = pokemon.begin(); i != pokemon.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = statuses.begin(); i != statuses.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = stores.begin(); i != stores.end(); ++i) + i->ExportIni(fout); + for (std::vector::const_iterator i = tiles.begin(); i != tiles.end(); ++i) + i->ExportIni(fout); + for (std::vector