From 65cc463f1d91fe99acf1c4dd9bce7e0038593022 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 3 Jul 2007 04:20:36 +0000 Subject: Fixed Logging, minor fixes, got rid of NatureEffect, and started migration from wxGTK to Qt git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@22 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/MapTrainer.cpp | 175 +++++++++++++++---------------------------------- 1 file changed, 53 insertions(+), 122 deletions(-) (limited to 'pokemod/MapTrainer.cpp') diff --git a/pokemod/MapTrainer.cpp b/pokemod/MapTrainer.cpp index 6c35a9f6..e1bbeab6 100644 --- a/pokemod/MapTrainer.cpp +++ b/pokemod/MapTrainer.cpp @@ -28,7 +28,8 @@ PokeGen::PokeMod::MapTrainer::MapTrainer(const Pokemod *par, const unsigned _id) coordinate(0, 0), skin(""), sight(0), - direction(UINT_MAX), + direction(UINT_MAX), + numFight(1), ai(""), appearFlag(0, 0), overworldDialog(UINT_MAX), @@ -63,25 +64,24 @@ void PokeGen::PokeMod::MapTrainer::Validate() LogVarNotSet("MapTrainer", id, "name"); isValid = false; } - if (!skin.DoesExist()) - { - if (skin == "") - LogVarNotSet("MapTrainer", id, "skin", name); - else - LogVarNotValid("MapTrainer", id, "skin", name); - isValid = false; - } + if (!Path(pokemod->GetPath() + "skins/" + skin).DoesExist()) + { + LogVarNotValid("MapTrainer", id, "skin", name); + isValid = false; + } if (DIR_END_NONE <= direction) { LogVarNotValid("MapTrainer", id, "direction", name); isValid = false; + } + if (!numFight || (pokemod->GetMaxFight() < numFight)) + { + LogVarNotValid("MapTrainer", id, "maxFight", name); + isValid = false; } - if (!ai.DoesExist()) + if (!Path(pokemod->GetPath() + "ai/" + ai).DoesExist()) { - if (ai == "") - LogVarNotSet("MapTrainer", id, "ai", name); - else - LogVarNotValid("MapTrainer", id, "ai", name); + LogVarNotValid("MapTrainer", id, "ai", name); isValid = false; } if (!pokemod->GetDialog(overworldDialog)) @@ -131,104 +131,6 @@ void PokeGen::PokeMod::MapTrainer::Validate() LogValidateOver("MapTrainer", id, isValid, name); } -#ifdef PG_DEBUG_WINDOW -void PokeGen::PokeMod::MapTrainer::Validate(const wxListBox &output) -{ - LogValidateStart("MapTrainer", id, name); - if (name == "") - { - LogVarNotSet("MapTrainer", id, "name"); - output.Append(ConsoleLogVarNotSet("MapTrainer", id, "name")); - isValid = false; - } - if (!skin.DoesExist()) - { - if (skin == "") - { - LogVarNotSet("MapTrainer", id, "skin", name); - output.Append(ConsoleLogVarNotSet("MapTrainer", id, "skin", name)); - } - else - { - LogVarNotValid("MapTrainer", id, "skin", name); - output.Append(ConsoleLogVarNotValid("MapTrainer", id, "skin", name)); - } - isValid = false; - } - if (DIR_END_NONE <= direction) - { - LogVarNotValid("MapTrainer", id, "direction", name); - output.Append(ConsoleLogVarNotValid("MapTrainer", id, "direction", name)); - isValid = false; - } - if (!ai.DoesExist()) - { - if (ai == "") - { - LogVarNotSet("MapTrainer", id, "ai", name); - output.Append(ConsoleLogVarNotSet("MapTrainer", id, "ai", name)); - } - else - { - LogVarNotValid("MapTrainer", id, "ai", name); - output.Append(ConsoleLogVarNotValid("MapTrainer", id, "ai", name)); - } - isValid = false; - } - if (!pokemod->GetDialog(overworldDialog)) - { - LogVarNotValid("MapTrainer", id, "overworldDialog", name); - output.Append(ConsoleLogVarNotValid("MapTrainer", id, "overworldDialog", name)); - isValid = false; - } - if (!pokemod->GetDialog(winDialog)) - { - LogVarNotValid("MapTrainer", id, "winDialog", name); - output.Append(ConsoleLogVarNotValid("MapTrainer", id, "winDialog", name)); - isValid = false; - } - if (!pokemod->GetDialog(loseDialog)) - { - LogVarNotValid("MapTrainer", id, "loseDialog", name); - output.Append(ConsoleLogVarNotValid("MapTrainer", id, "loseDialog", name)); - isValid = false; - } - if (!GetMapTrainerTeam(leadPokemon)) - { - LogVarNotValid("MapTrainer", id, "leadPokemon", name); - output.Append(ConsoleLogVarNotValid("MapTrainer", id, "leadPokemon", name)); - isValid = false; - } - if (GetMapTrainerTeamCount()) - { - std::map idChecker; - for (std::vector::iterator i = team.begin(); i != team.end(); ++i) - { - LogSubmoduleIterate("MapTrainer", id, "team Pokémon", i->GetId(), name); - if (!i->IsValid()) - isValid = false; - ++idChecker[i->GetId()]; - } - for (std::map::const_iterator i = idChecekr.begin(); i != idChecker.end(); ++i) - { - if (1 < i->second) - { - LogDuplicateId("MapTrainer", id, "team Pokémon", i->first, name); - output.Append(ConsoleLogDuplicateId("MapTrainer", id, "team Pokémon", i->first, name)); - isValid = false; - } - } - } - else - { - LogSubmoduleEmpty("MapTrainer", id, "team Pokémon", name); - output.Append(ConsoleLogSubmoduleEmpty("MapTrainer", id, "team Pokémon", name)); - isValid = false; - } - LogValidateOver("MapTrainer", id, isValid, name); -} -#endif - void PokeGen::PokeMod::MapTrainer::ImportIni(Ini &ini, const unsigned _id) { LogImportStart("MapTrainer"); @@ -248,7 +150,8 @@ void PokeGen::PokeMod::MapTrainer::ImportIni(Ini &ini, const unsigned _id) coordinate.Set(i, j); ini.GetValue("skin", skin); ini.GetValue("sight", sight, 0); - ini.GetValue("direction", direction); + ini.GetValue("direction", direction); + ini.GetValue("numFight", numFight, 1); ini.GetValue("ai", ai); ini.GetValue("appearFlag-f", i, 0); ini.GetValue("appearFlag-s", j, 0); @@ -271,7 +174,8 @@ void PokeGen::PokeMod::MapTrainer::ExportIni(std::ofstream &fout, const String & exMapTrainer.AddField("coordinate-y", coordinate.GetY()); exMapTrainer.AddField("skin", skin); exMapTrainer.AddField("sight", sight); - exMapTrainer.AddField("direction", direction); + exMapTrainer.AddField("direction", direction); + exMapTrainer.AddField("numFight", numFight); exMapTrainer.AddField("ai", ai); exMapTrainer.AddField("appearFlag-f", appearFlag.GetFlag()); exMapTrainer.AddField("appearFlag-s", appearFlag.GetStatus()); @@ -318,7 +222,8 @@ void PokeGen::PokeMod::MapTrainer::SetCoordinateY(const unsigned y) void PokeGen::PokeMod::MapTrainer::SetSkin(const Path &s) { LogSetVar("MapTrainer", id, "skin", s, name); - skin = s; + skin = s.GetFilename(); + s.CopyTo(pokemod->GetPath() + "skins/" + skin); } void PokeGen::PokeMod::MapTrainer::SetSight(const unsigned s) @@ -332,6 +237,13 @@ void PokeGen::PokeMod::MapTrainer::SetDirection(const unsigned d) LogSetVar("MapTrainer", id, "direction", d, name); if (d < DIR_END_NONE) direction = d; +} + +void PokeGen::PokeMod::MapTrainer::SetNumFight(const unsigned m) +{ + LogSetVar("MapTrainer", id, "maxFight", m, name); + if (m && (m <= pokemod->GetMaxFight())) + numFight = m; } void PokeGen::PokeMod::MapTrainer::SetDirection(const String &d) @@ -342,7 +254,8 @@ void PokeGen::PokeMod::MapTrainer::SetDirection(const String &d) void PokeGen::PokeMod::MapTrainer::SetAI(const Path &a) { LogSetVar("MapTrainer", id, "ai", a, name); - ai = a; + ai = a.GetFilename(); + a.CopyTo(pokemod->GetPath() + "ai/" + ai); } void PokeGen::PokeMod::MapTrainer::SetAppearFlag(const Flag &a) @@ -413,11 +326,17 @@ unsigned PokeGen::PokeMod::MapTrainer::GetCoordinateY() const return coordinate.GetY(); } -PokeGen::PokeMod::Path PokeGen::PokeMod::MapTrainer::GetSkin() const -{ - LogFetchVar("MapTrainer", id, "skin", skin, name); - return skin; -} +bool PokeGen::PokeMod::MapTrainer::GetSkinExists() const +{ + LogFetchVar("MapTrainer", id, "skin exists", skin, name); + return GetSkin().DoesExist(); +} + +PokeGen::PokeMod::Path PokeGen::PokeMod::MapTrainer::GetSkin() const +{ + LogFetchVar("MapTrainer", id, "skins", skin, name); + return Path(pokemod->GetPath() + "skins/" + skin); +} unsigned PokeGen::PokeMod::MapTrainer::GetSight() const { @@ -430,6 +349,12 @@ unsigned PokeGen::PokeMod::MapTrainer::GetDirection() const LogFetchVar("MapTrainer", id, "direction", direction, name); return direction; } + +unsigned PokeGen::PokeMod::MapTrainer::GetNumFight() const +{ + LogFetchVar("MapTrainer", id, "numFight", numFight, name); + return numFight; +} PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainer::GetDirectionString() const { @@ -439,10 +364,16 @@ PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainer::GetDirectionString() cons return ""; } +bool PokeGen::PokeMod::MapTrainer::GetAIExists() const +{ + LogFetchVar("MapTrainer", id, "ai exists", ai, name); + return GetAI().DoesExist(); +} + PokeGen::PokeMod::Path PokeGen::PokeMod::MapTrainer::GetAI() const { LogFetchVar("MapTrainer", id, "ai", ai, name); - return ai; + return Path(pokemod->GetPath() + "ai/" + ai); } PokeGen::PokeMod::Flag PokeGen::PokeMod::MapTrainer::GetAppearFlag() const -- cgit