From e94d9893b8753e72adb92b2c5eb203830ddf641c Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 21 Jul 2007 01:39:22 +0000 Subject: Moved to GPLv3 and Qt4, Changed String -> QString, other minor fixes git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@23 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/Tile.cpp | 144 +++++++++++++++++++++---------------------------------- 1 file changed, 55 insertions(+), 89 deletions(-) (limited to 'pokemod/Tile.cpp') diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp index cd1e3d13..f514bb3e 100644 --- a/pokemod/Tile.cpp +++ b/pokemod/Tile.cpp @@ -6,19 +6,18 @@ // Created: Thu May 31 2007 13:52:39 // Copyright: ©2007 Nerdy Productions // Licence: -// This program is free software; you can redistribute it and/or modify +// This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or +// the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTTile or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// with this program. If not, see . ///////////////////////////////////////////////////////////////////////////// #include "Tile.h" @@ -32,13 +31,11 @@ PokeGen::PokeMod::Tile::Tile(const Pokemod *par, const unsigned _id) : fromRight(false), isWild(false), wildChance(1, 1), - isWater(false), waterType(UINT_MAX), underWater(UINT_MAX), - canDive(false), isCuttable(false), underCut(UINT_MAX), - canHeadbutt(false), + canHeadbutt(false), isRockClimb(false), forceType(UINT_MAX), forceDirection(UINT_MAX) @@ -78,28 +75,25 @@ void PokeGen::PokeMod::Tile::Validate() LogVarNotValid("Tile", id, "pic", name); isValid = false; } - if (isWater) + if (WTRT_END <= waterType) { - if (WTRT_END <= waterType) + LogVarNotValid("Tile", id, "waterType", name); + isValid = false; + } + else if (waterType == WTRT_WATERFALL) + { + if (!fromDown) { - LogVarNotValid("Tile", id, "waterType", name); + Log::Write(QString("Tile: Waterfall needs to be accessible from below in %u (%s)", id, name.c_str()), PM_DEBUG_ERROR | PM_DEBUG_VALIDATION); isValid = false; } - else if (waterType == WTRT_WATERFALL) - { - if (!fromDown) - { - Log::Write(String("Tile: Waterfall needs to be accessible from below in %u (%s)", id, name.c_str()), PM_DEBUG_ERROR | PM_DEBUG_VALIDATION); - isValid = false; - } - } - else if (waterType == WTRT_WHIRLPOOL) + } + else if (waterType == WTRT_WHIRLPOOL) + { + if (!pokemod->GetTile(underWater)) { - if (!pokemod->GetTile(underWater)) - { - LogVarNotValid("Tile", id, "underWater", name); - isValid = false; - } + LogVarNotValid("Tile", id, "underWater", name); + isValid = false; } } if (isCuttable) @@ -109,15 +103,15 @@ void PokeGen::PokeMod::Tile::Validate() LogVarNotValid("Tile", id, "underCut", name); isValid = false; } - } - if (isRockClimb) + } + if (isRockClimb) { - if (!fromDown) - { - Log::Write(String("Tile: Rock Climbing needs to be accessible from below in %u (%s)", id, name.c_str()), PM_DEBUG_ERROR | PM_DEBUG_VALIDATION); - isValid = false; - } - } + if (!fromDown) + { + Log::Write(QString("Tile: Rock Climbing needs to be accessible from below in %u (%s)", id, name.c_str()), PM_DEBUG_ERROR | PM_DEBUG_VALIDATION); + isValid = false; + } + } if (forceType < FT_END) { if ((forceType == FT_SLIP) || (forceType == FT_FORCE) || (forceType == FT_PUSH)) @@ -160,20 +154,18 @@ void PokeGen::PokeMod::Tile::ImportIni(Ini &ini, const unsigned _id) ini.GetValue("wildChance-n", i, 1); ini.GetValue("wildChance-d", j, 1); wildChance.Set(i, j); - ini.GetValue("isWater", isWater, false); ini.GetValue("waterType", waterType); ini.GetValue("underWater", underWater); - ini.GetValue("canDive", canDive, false); ini.GetValue("isCuttable", isCuttable, false); ini.GetValue("underCut", underCut); ini.GetValue("canHeadbutt", canHeadbutt, false); - ini.GetValue("isRockClimb", isRockClimb, false); + ini.GetValue("isRockClimb", isRockClimb, false); ini.GetValue("forceType", forceType); ini.GetValue("forceDirection", forceDirection); LogImportOver("Tile", id, name); } -void PokeGen::PokeMod::Tile::ExportIni(std::ofstream &fout) const +void PokeGen::PokeMod::Tile::ExportIni(QFile &fout) const { LogExportStart("Tile", id, name); Ini exTile("Tile"); @@ -187,21 +179,19 @@ void PokeGen::PokeMod::Tile::ExportIni(std::ofstream &fout) const exTile.AddField("isWild", isWild); exTile.AddField("wildChance-n", wildChance.GetNum()); exTile.AddField("wildChance-d", wildChance.GetDenom()); - exTile.AddField("isWater", isWater); exTile.AddField("waterType", waterType); exTile.AddField("underWater", underWater); - exTile.AddField("canDive", canDive); exTile.AddField("isCuttable", isCuttable); exTile.AddField("underCut", underCut); exTile.AddField("canHeadbutt", canHeadbutt); - exTile.AddField("isRockClimb", isRockClimb); + exTile.AddField("isRockClimb", isRockClimb); exTile.AddField("forceType", forceType); exTile.AddField("forceDirection", forceDirection); exTile.Export(fout); LogExportOver("Tile", id, name); } -void PokeGen::PokeMod::Tile::SetName(const String &n) +void PokeGen::PokeMod::Tile::SetName(const QString &n) { LogSetVar("Tile", id, "name", n); name = n; @@ -267,12 +257,6 @@ void PokeGen::PokeMod::Tile::SetWildChanceDenominator(const unsigned d) wildChance.SetDenom(d); } -void PokeGen::PokeMod::Tile::SetIsWater(const bool i) -{ - LogSetVar("Tile", id, "isWater", i, name); - isWater = i; -} - void PokeGen::PokeMod::Tile::SetWaterType(const unsigned w) { LogSetVar("Tile", id, "waterType", w, name); @@ -280,7 +264,7 @@ void PokeGen::PokeMod::Tile::SetWaterType(const unsigned w) waterType = w; } -void PokeGen::PokeMod::Tile::SetWaterType(const String &w) +void PokeGen::PokeMod::Tile::SetWaterType(const QString &w) { SetWaterType(FindIn(WTRT_END, w, WaterTypeStr)); } @@ -292,19 +276,13 @@ void PokeGen::PokeMod::Tile::SetUnderWater(const unsigned u) underWater = u; } -void PokeGen::PokeMod::Tile::SetUnderWater(const String &u) +void PokeGen::PokeMod::Tile::SetUnderWater(const QString &u) { LogSetVar("Tile", id, "underWater string", u, name); if (const Tile *t = pokemod->GetTile(u)) underWater = t->GetId(); } -void PokeGen::PokeMod::Tile::SetCanDive(const bool c) -{ - LogSetVar("Tile", id, "canDive", c, name); - canDive = c; -} - void PokeGen::PokeMod::Tile::SetIsCuttable(const bool i) { LogSetVar("Tile", id, "isCuttable", i, name); @@ -318,7 +296,7 @@ void PokeGen::PokeMod::Tile::SetUnderCut(const unsigned u) underCut = u; } -void PokeGen::PokeMod::Tile::SetUnderCut(const String &u) +void PokeGen::PokeMod::Tile::SetUnderCut(const QString &u) { LogSetVar("Tile", id, "underCut string", u, name); if (const Tile *t = pokemod->GetTile(u)) @@ -331,12 +309,12 @@ void PokeGen::PokeMod::Tile::SetCanHeadbutt(const bool c) canHeadbutt = c; } -void PokeGen::PokeMod::Tile::SetIsRockClimb(const bool i) -{ - LogSetVar("Tile", id, "isRockClimb", i, name); - isRockClimb = i; -} - +void PokeGen::PokeMod::Tile::SetIsRockClimb(const bool i) +{ + LogSetVar("Tile", id, "isRockClimb", i, name); + isRockClimb = i; +} + void PokeGen::PokeMod::Tile::SetForceType(const unsigned f) { LogSetVar("Tile", id, "forceType", f, name); @@ -344,7 +322,7 @@ void PokeGen::PokeMod::Tile::SetForceType(const unsigned f) forceType = f; } -void PokeGen::PokeMod::Tile::SetForceType(const String &f) +void PokeGen::PokeMod::Tile::SetForceType(const QString &f) { SetForceType(FindIn(FT_END, f, ForceTypeStr)); } @@ -356,12 +334,12 @@ void PokeGen::PokeMod::Tile::SetForceDirection(const unsigned f) forceDirection = f; } -void PokeGen::PokeMod::Tile::SetForceDirection(const String &f) +void PokeGen::PokeMod::Tile::SetForceDirection(const QString &f) { SetForceType(FindIn(DIR_END, f, DirectionStr)); } -PokeGen::PokeMod::String PokeGen::PokeMod::Tile::GetName() const +QString PokeGen::PokeMod::Tile::GetName() const { LogFetchVar("Tile", id, "name", name); return name; @@ -421,19 +399,13 @@ unsigned PokeGen::PokeMod::Tile::GetWildChanceDenominator() const return wildChance.GetDenom(); } -bool PokeGen::PokeMod::Tile::GetIsWater() const -{ - LogFetchVar("Tile", id, "isWater", isWater, name); - return isWater; -} - unsigned PokeGen::PokeMod::Tile::GetWaterType() const { LogFetchVar("Tile", id, "waterType", waterType, name); return waterType; } -PokeGen::PokeMod::String PokeGen::PokeMod::Tile::GetWaterTypeString() const +QString PokeGen::PokeMod::Tile::GetWaterTypeString() const { LogFetchVar("Tile", id, "waterType string", waterType, name); if (waterType < WTRT_END) @@ -447,7 +419,7 @@ unsigned PokeGen::PokeMod::Tile::GetUnderWater() const return underWater; } -PokeGen::PokeMod::String PokeGen::PokeMod::Tile::GetUnderWaterString() const +QString PokeGen::PokeMod::Tile::GetUnderWaterString() const { LogFetchVar("Tile", id, "underWater", underWater, name); if (const Tile *t = pokemod->GetTile(underWater)) @@ -455,12 +427,6 @@ PokeGen::PokeMod::String PokeGen::PokeMod::Tile::GetUnderWaterString() const return ""; } -bool PokeGen::PokeMod::Tile::GetCanDive() const -{ - LogFetchVar("Tile", id, "canDive", canDive, name); - return canDive; -} - bool PokeGen::PokeMod::Tile::GetIsCuttable() const { LogFetchVar("Tile", id, "isCuttable", isCuttable, name); @@ -473,7 +439,7 @@ unsigned PokeGen::PokeMod::Tile::GetUnderCut() const return underCut; } -PokeGen::PokeMod::String PokeGen::PokeMod::Tile::GetUnderCutString() const +QString PokeGen::PokeMod::Tile::GetUnderCutString() const { LogFetchVar("Tile", id, "underCut string", underCut, name); if (const Tile *t = pokemod->GetTile(underCut)) @@ -487,19 +453,19 @@ bool PokeGen::PokeMod::Tile::GetCanHeadbutt() const return canHeadbutt; } -bool PokeGen::PokeMod::Tile::GetIsRockClimb() const -{ - LogFetchVar("Tile", id, "isRockClimb", isRockClimb, name); - return isRockClimb; -} - +bool PokeGen::PokeMod::Tile::GetIsRockClimb() const +{ + LogFetchVar("Tile", id, "isRockClimb", isRockClimb, name); + return isRockClimb; +} + unsigned PokeGen::PokeMod::Tile::GetForceType() const { LogFetchVar("Tile", id, "forceType", forceType, name); return forceType; } -PokeGen::PokeMod::String PokeGen::PokeMod::Tile::GetForceTypeString() const +QString PokeGen::PokeMod::Tile::GetForceTypeString() const { LogFetchVar("Tile", id, "forceType string", forceType, name); if (forceType < FT_END) @@ -513,7 +479,7 @@ unsigned PokeGen::PokeMod::Tile::GetForceDirection() const return forceDirection; } -PokeGen::PokeMod::String PokeGen::PokeMod::Tile::GetForceDirectionString() const +QString PokeGen::PokeMod::Tile::GetForceDirectionString() const { LogFetchVar("Tile", id, "forceDirection string", forceDirection, name); if (forceDirection < DIR_END) -- cgit