If I had a load of if statments that where basically following the same format, is there a way in which I can place them into a function inside the UnitData class.
The UnitData class is just a set of var with functons to change them and return their values
This bit of code is declared at the begining of main()
UnitData unitdata; UnitData* unitlist = new UnitList[256];
This is futher down the file, the tags are strings that apper in textfiles as the data is read in through a filereading system
for(int readfile=0; readfile < half; readfile++) {
open_unitdata_file >> unitdata_statment_str;
open_unitdata_file >> unitdata_number_str;
//! Check if string is equal to the unit_type_tag.
if(unitdata_statment_str.compare(unit_type_tag) ==0) {
unitlist[i].SetUnitType(unitdata_number_str);
}
//! TO DO: std::string SetCloseWeapon(std::string);
//! TO DO: std::string SetRangeWeapon(std::string);
//! Check if string is equal to the unit_life_tag.
if(unitdata_statment_str.compare(unit_life_tag) == 0) {
int health_convert = filedata.getnumber(unitdata_number_str);
unitlist[i].SetMaxLife(health_convert);
}
}

New Topic/Question
Reply



MultiQuote






|