]> ruin.nu Git - hbs.git/blobdiff - bs/unittype.cpp
now compiles with gcc 3.1, might not work with gcc 3.0 though (not sure)
[hbs.git] / bs / unittype.cpp
index 27b3cd4affdeb107355804dc97afb551f283db02..836ddb95056f0d79978e78a48d4d5f9735762006 100644 (file)
@@ -40,7 +40,7 @@ void UnitType::setName(string sName)
 
 //////////////////////////////////////////////////////////////////////////
 //
-string UnitType::Name()
+string UnitType::Name() const
 {
        return m_sName;
 }
@@ -54,21 +54,21 @@ void UnitType::setRace(int iRace)
 
 //////////////////////////////////////////////////////////////////////////
 //
-int UnitType::Race()
+int UnitType::race() const
 {
        return m_iRace;
 }
 
 //////////////////////////////////////////////////////////////////////////
 //
-void UnitType::setClass(string sClass)
+void UnitType::setUnitClass(string sClass)
 {
        m_sClass = sClass;
 }
 
 //////////////////////////////////////////////////////////////////////////
 //
-string UnitType::Class()
+string UnitType::unitClass() const
 {
        return m_sClass;
 }
@@ -93,7 +93,7 @@ void UnitType::addTarget(string target)
  * If it finds the position it inserts the target there, if it reaches the end 
  * before it finds the correct possition it adds the target to the end. 
  */
-void UnitType::insTarget(string target, int index = 0)
+void UnitType::insTarget(string target, int index)
 {
 
        vector<string>::iterator i = m_vTarget.begin(); 
@@ -112,14 +112,14 @@ void UnitType::insTarget(string target, int index = 0)
 
 //////////////////////////////////////////////////////////////////////////
 //
-vector<string> UnitType::Target()
+vector<string> UnitType::target() const
 {
        return m_vTarget;
 }
 
 //////////////////////////////////////////////////////////////////////////
 //
-string UnitType::Target(int index)
+string UnitType::target(int index) const
 {
        return m_vTarget[index];
 }
@@ -133,7 +133,7 @@ void UnitType::setInitiative(int iInit)
 
 //////////////////////////////////////////////////////////////////////////
 //
-int     UnitType::Initiative()
+int     UnitType::initiative() const
 {
        return m_iInitiative;
 }
@@ -147,7 +147,7 @@ void UnitType::setAgility (int iAgil)
 
 //////////////////////////////////////////////////////////////////////////
 //
-int  UnitType::Agility()
+int  UnitType::agility() const
 {
        return m_iAgility;
 }
@@ -161,7 +161,7 @@ void UnitType::setWeaponSpeed(int iWPSP)
 
 //////////////////////////////////////////////////////////////////////////
 //
-int  UnitType::WeaponSpeed()
+int  UnitType::weaponSpeed() const
 {
        return m_iWeaponSpeed;
 }
@@ -175,7 +175,7 @@ void UnitType::setGuns(int iGuns)
 
 //////////////////////////////////////////////////////////////////////////
 //
-int UnitType::Guns()
+int UnitType::guns() const
 {
        return m_iGuns;
 }
@@ -189,7 +189,7 @@ void UnitType::setPower(int iPower)
 
 //////////////////////////////////////////////////////////////////////////
 //
-int  UnitType::Power()
+int  UnitType::power() const
 {
        return m_iPower;
 }
@@ -203,7 +203,7 @@ void UnitType::setArmor(int iArmor)
 
 //////////////////////////////////////////////////////////////////////////
 //
-int  UnitType::Armor()
+int  UnitType::armor() const
 {
        return m_iArmor;
 }
@@ -217,23 +217,40 @@ void UnitType::setEMP(int iEMP)
 
 //////////////////////////////////////////////////////////////////////////
 //
-int  UnitType::EMP()
+int  UnitType::EMP() const
 {
        return m_iEMP;
 }
 
 //////////////////////////////////////////////////////////////////////////
 //
-void UnitType::setTotalResources(int iTR)
+void UnitType::setResources(std::string type, int i)
 {
-       m_iTotalResources = iTR;
+       m_Resources[type] = i;
 }
 
 //////////////////////////////////////////////////////////////////////////
 //
-int UnitType::TotRes()
+void UnitType::setResources(map<std::string, int> res)
 {
-       return m_iTotalResources;
+       m_Resources = res;
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+std::map<std::string, int> UnitType::resources()
+{
+       return m_Resources;
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+int UnitType::totRes() const
+{
+       int totres = 0;
+       for (map<string, int>::const_iterator i = m_Resources.begin(); i != m_Resources.end(); ++i)
+               totres += i->second;
+       return totres;
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -245,7 +262,7 @@ void UnitType::setFuel(int iFuel)
 
 //////////////////////////////////////////////////////////////////////////
 //
-int  UnitType::Fuel()
+int  UnitType::fuel() const
 {
        return m_iFuel;
 }
@@ -259,7 +276,7 @@ void UnitType::setETA(int iETA)
 
 //////////////////////////////////////////////////////////////////////////
 //
-int  UnitType::ETA()
+int  UnitType::ETA() const
 {
        return m_iETA;
 }
@@ -273,7 +290,7 @@ void UnitType::setType(string type)
 
 //////////////////////////////////////////////////////////////////////////
 //
-string  UnitType::Type()
+string  UnitType::type() const
 {
        return m_sType;
 }