summaryrefslogtreecommitdiffstats
path: root/pokemod/Matrix.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-05-21 03:04:40 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-05-21 03:04:40 +0000
commit42375a0129fdd57355764c58ed27fa3a0a3c5465 (patch)
tree6d63c5e97c5f44ecf32edaf122c2a31868a31dc3 /pokemod/Matrix.cpp
parentfafbdab97afb5ec6498ea0ab66b693b9e335f6f1 (diff)
Various pokemod fixes (added AbilityEffect and Type)
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@10 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Matrix.cpp')
-rw-r--r--pokemod/Matrix.cpp258
1 files changed, 0 insertions, 258 deletions
diff --git a/pokemod/Matrix.cpp b/pokemod/Matrix.cpp
deleted file mode 100644
index 9fb32398..00000000
--- a/pokemod/Matrix.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name: pokemod/Map.cpp
-// Purpose: A 2D vector class
-// Author: Ben Boeckel
-// Modified by: Ben Boeckel
-// Created: Sun Apr 8 12:51:20 2007
-// Copyright: ©2007 Nerdy Productions
-// Licence:
-// 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
-// (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
-// MERCHANTABILITY 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.
-/////////////////////////////////////////////////////////////////////////////
-
-#include "Matrix.h"
-
-template<class T>
-PokeGen::PokeMod::Matrix<T>::Matrix(unsigned w, unsigned h, const T &d)
-{
- matrix.resize(w, std::vector<T>(h, d));
- width = w;
- height = h;
-}
-
-template<class T>
-PokeGen::PokeMod::Matrix<T>::Matrix(Ini &ini)
-{
- width = 0;
- height = 0;
- matrix.clear();
-}
-
-template<>
-PokeGen::PokeMod::Matrix<PokeGen::PokeMod::Point>::Matrix(Ini &ini)
-{
- ImportIni(ini);
-}
-
-template<>
-PokeGen::PokeMod::Matrix<PokeGen::PokeMod::Frac>::Matrix(Ini &ini)
-{
- ImportIni(ini);
-}
-
-template<class T>
-void PokeGen::PokeMod::Matrix<T>::ImportIni(Ini &ini)
-{
-}
-
-template<>
-void PokeGen::PokeMod::Matrix<PokeGen::PokeMod::Point>::ImportIni(Ini &ini)
-{
- LogImportStart("Matrix");
- ini.GetValue("width", width, 0);
- ini.GetValue("height", height, 0);
- if (!(width && height))
- return;
- matrix.resize(width, std::vector<Point>(height, Point(0, 0)));
- for (unsigned i = 0; i < width; ++i)
- {
- for (unsigned j = 0; j < height; ++j)
- {
- int k;
- int l;
- ini.GetValue(String("Element-%d-%d-x", i, j), k, 0);
- ini.GetValue(String("Element-%d-%d-y", i, j), l, 0);
- matrix[i][j].Set(k, l);
- }
- }
- LogImportOver("Matrix");
-}
-
-template<>
-void PokeGen::PokeMod::Matrix<PokeGen::PokeMod::Frac>::ImportIni(Ini &ini)
-{
- LogImportStart("Matrix");
- ini.GetValue("width", width, 0);
- ini.GetValue("height", height, 0);
- if (!(width && height))
- return;
- matrix.resize(width, std::vector<Frac>(height, Frac(1, 1)));
- for (unsigned i = 0; i < width; ++i)
- {
- for (unsigned j = 0; j < height; ++j)
- {
- unsigned k;
- unsigned l;
- bool m;
- ini.GetValue(String("Element-%d-%d-n", i, j), k, 0);
- ini.GetValue(String("Element-%d-%d-d", i, j), l, 0);
- ini.GetValue(String("Element-%d-%d-i", i, j), m, 0);
- matrix[i][j].Set(k, l, m);
- }
- }
- LogImportOver("Matrix");
-}
-
-template<>
-void PokeGen::PokeMod::Matrix<PokeGen::PokeMod::Point>::ExportIni(const String &val)
-{
- Log(String("Matrix Export: Starting %s", val.c_str()), PM_DEBUG_INFO);
- // Declare the elements
- Ini exMatrix(val);
- exMatrix.AddField("height", height);
- exMatrix.AddField("width", width);
- for (int i = 0; i < width; ++i)
- {
- for (unsigned j = 0; j < height; ++j)
- {
- exMatrix.AddField(String("Element-%d-%d-x", i, j), matrix[i][j].GetX());
- exMatrix.AddField(String("Element-%d-%d-y", i, j), matrix[i][j].GetY());
- }
- }
- Log(String("Matrix Export: Finished %s", val.c_str()), PM_DEBUG_INFO);
-}
-
-template<>
-void PokeGen::PokeMod::Matrix<PokeGen::PokeMod::Frac>::ExportIni(std::ofstream &fout, const String &val)
-{
- Log(String("Matrix Export: Starting %s", val.c_str()), PM_DEBUG_INFO);
- // Declare the elements
- Ini exMatrix(val);
- exMatrix.AddField("height", height);
- exMatrix.AddField("width", width);
- for (unsigned i = 0; i < width; ++i)
- {
- for (unsigned j = 0; j < height; ++j)
- {
- exMatrix.AddField(String("Element-%d-%d-i", i, j), matrix[i][j].GetImproper());
- exMatrix.AddField(String("Element-%d-%d-n", i, j), matrix[i][j].GetNum());
- exMatrix.AddField(String("Element-%d-%d-d", i, j), matrix[i][j].GetDenom());
- }
- }
- exMatrix.Export(fout);
- Log(String("Matrix Export: Finished %s", val.c_str()), PM_DEBUG_INFO);
-}
-
-template<class T>
-void PokeGen::PokeMod::Matrix<T>::AddRow(const T &d)
-{
- for (std::vector<T> *i = matrix.begin(); i != matrix.end(); ++i)
- i->push_back(d);
- ++height;
-}
-
-template<class T>
-void PokeGen::PokeMod::Matrix<T>::AddCol(const T &d)
-{
- matrix.push_back(std::vector<T>(GetHeight(), d));
- ++width;
-}
-
-template<class T>
-bool PokeGen::PokeMod::Matrix<T>::InsertRow(unsigned pos, const T &d)
-{
- if (height < pos)
- return false;
- for (std::vector<T> *i = matrix.begin(); i != matrix.end(); ++i)
- i->insert(pos, d);
- ++height;
- return true;
-}
-
-template<class T>
-bool PokeGen::PokeMod::Matrix<T>::InsertCol(unsigned pos, const T &d)
-{
- if (width < pos)
- return false;
- matrix.insert(pos, std::vector<T>(GetHeight(), d));
- ++width;
- return true;
-}
-
-template<class T>
-bool PokeGen::PokeMod::Matrix<T>::DeleteRow(unsigned pos)
-{
- if (height <= pos)
- return false;
- for (std::vector<T> *i = matrix.begin(); i != matrix.end(); ++i)
- i->erase(i->begin() + pos);
- --height;
- return true;
-}
-
-template<class T>
-bool PokeGen::PokeMod::Matrix<T>::DeleteCol(unsigned pos)
-{
- if (width <= pos)
- return false;
- matrix.erase(matrix.begin() + pos);
- --width;
- return true;
-}
-
-template<class T>
-bool PokeGen::PokeMod::Matrix<T>::Set(unsigned row, unsigned col, const T &s)
-{
- if ((width <= col) || (height <= col))
- return false;
- (matrix.begin() + col)->assign(row, s);
- return true;
-}
-
-template<class T>
-T PokeGen::PokeMod::Matrix<T>::Get(unsigned row, unsigned col)
-{
- if ((width <= col) || (height <= col))
- return T();
- return matrix[col][row];
-}
-
-template<class T>
-std::vector<T> PokeGen::PokeMod::Matrix<T>::GetRow(unsigned row)
-{
- std::vector<T> r;
- for (std::vector<T> *i = matrix.begin(); i != matrix.end(); ++i)
- r.push_back(i->at(row));
- return r;
-}
-
-template<class T>
-std::vector<T> PokeGen::PokeMod::Matrix<T>::GetCol(unsigned col)
-{
- return matrix[col];
-}
-
-template<class T>
-unsigned PokeGen::PokeMod::Matrix<T>::GetHeight()
-{
- return height;
-}
-
-template<class T>
-unsigned PokeGen::PokeMod::Matrix<T>::GetWidth()
-{
- return width;
-}
-
-template<class T>
-T PokeGen::PokeMod::Matrix<T>::operator[](Point &p)
-{
- return matrix[p.GetY()][p.GetX()];
-}
-
-template<class T>
-std::vector<T> PokeGen::PokeMod::Matrix<T>::operator[](int col)
-{
- return matrix[col];
-}