Ares
|
#include <src/Ext/HouseType/Body.h>
Public Member Functions | |
ExtData (const DWORD Canary, TT *const OwnerObject) | |
virtual | ~ExtData () |
virtual size_t | Size () const |
virtual void | LoadFromINIFile (TT *pThis, CCINIClass *pINI) |
virtual void | LoadFromRulesFile (TT *pThis, CCINIClass *pINI) |
virtual void | InitializeConstants (TT *pThis) |
virtual void | Initialize (TT *pThis) |
virtual void | InvalidatePointer (void *ptr) |
AircraftTypeClass * | GetParadropPlane () |
bool | GetParadropContent (TypeList< TechnoTypeClass * > **, TypeList< int > **) |
AnimTypeClass * | GetParachuteAnim () |
Public Attributes | |
char | FlagFile [0x20] |
char | LSFile [0x20] |
char | LSPALFile [0x20] |
char | TauntFile [0x20] |
char | LSName [0x20] |
char | LSSpecialName [0x20] |
char | LSBrief [0x20] |
char | StatusText [0x20] |
ColorScheme * | LoadTextColor |
int | RandomSelectionWeight |
int | CountryListIndex |
DynamicVectorClass < BuildingTypeClass * > | Powerplants |
TypeList< TechnoTypeClass * > | ParaDrop |
TypeList< int > | ParaDropNum |
ValueableIdx< int, AircraftTypeClass > | ParaDropPlane |
Valueable< AnimTypeClass * > | Parachute_Anim |
HouseTypeExt::ExtData::ExtData | ( | const DWORD | Canary, |
TT *const | OwnerObject | ||
) | [inline] |
: Extension<TT>(Canary, OwnerObject), RandomSelectionWeight (0), CountryListIndex (0), ParaDropPlane (-1), Parachute_Anim (NULL), LoadTextColor (NULL) { *FlagFile = 0; *LSFile = 0; *LSPALFile = 0; *TauntFile = 0; *LSName = 0; *LSSpecialName = 0; *LSBrief = 0; *StatusText = 0; };
virtual HouseTypeExt::ExtData::~ExtData | ( | ) | [inline, virtual] |
{ }
AnimTypeClass * HouseTypeExt::ExtData::GetParachuteAnim | ( | ) |
{ // country-specific parachute if(this->Parachute_Anim.Get()) { return this->Parachute_Anim; } // side-specific with fallback to rules int iSide = this->AttachedToObject->SideIndex; if(SideClass::Array->ValidIndex(iSide)) { if(SideExt::ExtData *pData = SideExt::ExtMap.Find(SideClass::Array->GetItem(iSide))) { if(pData->Parachute_Anim.Get()) { return pData->Parachute_Anim; } } else { Debug::Log("[GetParachuteAnim] House %s and its side have no valid parachute defined. Rules fallback failed.\n", this->AttachedToObject->ID); } } // this should not happen for non-civilian sides return AnimTypeClass::Find("PARACH"); }
bool HouseTypeExt::ExtData::GetParadropContent | ( | TypeList< TechnoTypeClass * > ** | pTypes, |
TypeList< int > ** | pNum | ||
) |
{ // no point in dereferencing null if(!pTypes || !pNum) { return false; } // tries to get the house's default contents and falls back to // the sides default contents. if(this->ParaDrop.Count) { *pTypes = &this->ParaDrop; *pNum = &this->ParaDropNum; } // fall back to side specific para drop if(!*pTypes || !(*pTypes)->Count) { SideClass* pSide = SideClass::Array->GetItem(this->AttachedToObject->SideIndex); if(SideExt::ExtData *pData = SideExt::ExtMap.Find(pSide)) { if(pData->ParaDropFallbackTypes && pData->ParaDropFallbackNum) { *pTypes = (TypeList<TechnoTypeClass*>*)pData->ParaDropFallbackTypes; *pNum = pData->ParaDropFallbackNum; } else { *pTypes = &pData->ParaDrop; *pNum = &pData->ParaDropNum; } } } return (*pTypes && *pNum); }
AircraftTypeClass * HouseTypeExt::ExtData::GetParadropPlane | ( | ) |
{ // tries to get the house's default plane and falls back to // the sides default plane. int iPlane = this->ParaDropPlane; int iSide = this->AttachedToObject->SideIndex; if((iPlane < 0) && (iSide >= 0)) { if(SideExt::ExtData *pData = SideExt::ExtMap.Find(SideClass::Array->GetItem(iSide))) { iPlane = pData->ParaDropPlane; } } // didn't help. default to the PDPlane like the game does. if(iPlane < 0) { iPlane = AircraftTypeClass::FindIndex("PDPLANE"); } if(AircraftTypeClass::Array->ValidIndex(iPlane)) { return AircraftTypeClass::Array->GetItem(iPlane); } else { Debug::Log("[GetParadropPlane] House %s and its side have no valid paradrop plane defined. Rules fallback failed.\n", this->AttachedToObject->ID); return NULL; } }
void HouseTypeExt::ExtData::Initialize | ( | TT * | pThis | ) | [virtual] |
{ this->Powerplants.Clear(); this->ParaDrop.Clear(); this->ParaDropNum.Clear(); BuildingTypeClass * pPower = NULL; switch (pThis->SideIndex) { case 0: pPower = RulesClass::Instance->GDIPowerPlant; this->LoadTextColor = ColorScheme::Find("AlliedLoad"); break; case 1: pPower = RulesClass::Instance->NodRegularPower; this->LoadTextColor = ColorScheme::Find("SovietLoad"); break; case 2: pPower = RulesClass::Instance->ThirdPowerPlant; this->LoadTextColor = ColorScheme::Find("YuriLoad"); if(!this->LoadTextColor) { // there is no YuriLoad in the original game. fall // back to a decent value. this->LoadTextColor = ColorScheme::Find("Purple"); } break; } if (pPower) { this->Powerplants.AddItem(pPower); } }
void HouseTypeExt::ExtData::InitializeConstants | ( | TT * | pThis | ) | [virtual] |
{ char* pID = pThis->ID; //We assign default values by country ID rather than index so you simply add a new country //without having to specify all the tags for the old ones if (!_strcmpi(pID, "Americans")) //USA { strcpy(this->FlagFile, "usai.pcx"); strcpy(this->LSBrief, "LoadBrief:USA"); strcpy(this->LSFile, "ls%sustates.shp"); strcpy(this->LSName, "Name:Americans"); strcpy(this->LSPALFile, "mplsu.pal"); strcpy(this->LSSpecialName, "Name:Para"); strcpy(this->StatusText, "STT:PlayerSideAmerica"); strcpy(this->TauntFile, "taunts\\tauam%02i.wav"); } else if (!_strcmpi(pID, "Alliance")) //Korea { strcpy(this->FlagFile, "japi.pcx"); strcpy(this->LSBrief, "LoadBrief:Korea"); strcpy(this->LSFile, "ls%skorea.shp"); strcpy(this->LSName, "Name:Alliance"); strcpy(this->LSPALFile, "mplsk.pal"); strcpy(this->LSSpecialName, "Name:BEAGLE"); strcpy(this->StatusText, "STT:PlayerSideKorea"); strcpy(this->TauntFile, "taunts\\tauko%02i.wav"); } else if (!_strcmpi(pID, "French")) //France { strcpy(this->FlagFile, "frai.pcx"); strcpy(this->LSBrief, "LoadBrief:French"); strcpy(this->LSFile, "ls%sfrance.shp"); strcpy(this->LSName, "Name:French"); strcpy(this->LSPALFile, "mplsf.pal"); strcpy(this->LSSpecialName, "Name:GTGCAN"); strcpy(this->StatusText, "STT:PlayerSideFrance"); strcpy(this->TauntFile, "taunts\\taufr%02i.wav"); } else if (!_strcmpi(pID, "Germans")) //Germany { strcpy(this->FlagFile, "geri.pcx"); strcpy(this->LSBrief, "LoadBrief:Germans"); strcpy(this->LSFile, "ls%sgermany.shp"); strcpy(this->LSName, "Name:Germans"); strcpy(this->LSPALFile, "mplsg.pal"); strcpy(this->LSSpecialName, "Name:TNKD"); strcpy(this->StatusText, "STT:PlayerSideGermany"); strcpy(this->TauntFile, "taunts\\tauge%02i.wav"); } else if (!_strcmpi(pID, "British")) //United Kingdom { strcpy(this->FlagFile, "gbri.pcx"); strcpy(this->LSBrief, "LoadBrief:British"); strcpy(this->LSFile, "ls%sukingdom.shp"); strcpy(this->LSName, "Name:British"); strcpy(this->LSPALFile, "mplsuk.pal"); strcpy(this->LSSpecialName, "Name:SNIPE"); strcpy(this->StatusText, "STT:PlayerSideBritain"); strcpy(this->TauntFile, "taunts\\taubr%02i.wav"); } else if (!_strcmpi(pID, "Africans")) //Libya { strcpy(this->FlagFile, "djbi.pcx"); strcpy(this->LSBrief, "LoadBrief:Lybia"); strcpy(this->LSFile, "ls%slibya.shp"); strcpy(this->LSName, "Name:Africans"); strcpy(this->LSPALFile, "mplsl.pal"); strcpy(this->LSSpecialName, "Name:DTRUCK"); strcpy(this->StatusText, "STT:PlayerSideLibya"); strcpy(this->TauntFile, "taunts\\tauli%02i.wav"); } else if (!_strcmpi(pID, "Arabs")) //Iraq { strcpy(this->FlagFile, "arbi.pcx"); strcpy(this->LSBrief, "LoadBrief:Iraq"); strcpy(this->LSFile, "ls%siraq.shp"); strcpy(this->LSName, "Name:Arabs"); strcpy(this->LSPALFile, "mplsi.pal"); strcpy(this->LSSpecialName, "Name:DESO"); strcpy(this->StatusText, "STT:PlayerSideIraq"); strcpy(this->TauntFile, "taunts\\tauir%02i.wav"); } else if (!_strcmpi(pID, "Confederation")) //Cuba { strcpy(this->FlagFile, "lati.pcx"); strcpy(this->LSBrief, "LoadBrief:Cuba"); strcpy(this->LSFile, "ls%scuba.shp"); strcpy(this->LSName, "Name:Confederation"); strcpy(this->LSPALFile, "mplsc.pal"); strcpy(this->LSSpecialName, "Name:TERROR"); strcpy(this->StatusText, "STT:PlayerSideCuba"); strcpy(this->TauntFile, "taunts\\taucu%02i.wav"); } else if (!_strcmpi(pID, "Russians")) //Russia { strcpy(this->FlagFile, "rusi.pcx"); strcpy(this->LSBrief, "LoadBrief:Russia"); strcpy(this->LSFile, "ls%srussia.shp"); strcpy(this->LSName, "Name:Russians"); strcpy(this->LSPALFile, "mplsr.pal"); strcpy(this->LSSpecialName, "Name:TTNK"); strcpy(this->StatusText, "STT:PlayerSideRussia"); strcpy(this->TauntFile, "taunts\\tauru%02i.wav"); } else if (!_strcmpi(pID, "YuriCountry")) //Yuri { strcpy(this->FlagFile, "yrii.pcx"); strcpy(this->LSBrief, "LoadBrief:YuriCountry"); strcpy(this->LSFile, "ls%syuri.shp"); strcpy(this->LSName, "Name:YuriCountry"); strcpy(this->LSPALFile, "mpyls.pal"); strcpy(this->LSSpecialName, "Name:YURI"); strcpy(this->StatusText, "STT:PlayerSideYuriCountry"); strcpy(this->TauntFile, "taunts\\tauyu%02i.wav"); } else //Unknown { strcpy(this->FlagFile, "rani.pcx"); strcpy(this->LSBrief, "GUI:Unknown"); strcpy(this->LSFile, "ls%sobs.shp"); strcpy(this->LSName, "GUI:Unknown"); strcpy(this->LSPALFile, "mplsobs.pal"); strcpy(this->LSSpecialName, "GUI:Unknown"); strcpy(this->StatusText, "GUI:Unknown"); strcpy(this->TauntFile, "taunts\\tauam%02i.wav"); } this->RandomSelectionWeight = 1; this->CountryListIndex = 100; }
virtual void HouseTypeExt::ExtData::InvalidatePointer | ( | void * | ptr | ) | [inline, virtual] |
Implements Extension< TT >.
{ }
void HouseTypeExt::ExtData::LoadFromINIFile | ( | TT * | pThis, |
CCINIClass * | pINI | ||
) | [virtual] |
{ char* pID = pThis->ID; if (!this->Powerplants.Count) { const char * section = "General"; const char * key = NULL; switch (pThis->SideIndex) { case 0: key = "GDIPowerPlant"; break; case 1: key = "NodRegularPower"; break; case 2: key = "ThirdPowerPlant"; break; } if(key) { if (pINI->ReadString(section, key, "", Ares::readBuffer, Ares::readLength)) { if (BuildingTypeClass *pBld = BuildingTypeClass::Find(Ares::readBuffer)) { this->Powerplants.AddItem(pBld); } else { Debug::INIParseFailed(section, key, Ares::readBuffer); } } } } if (pINI->ReadString(pID, "AI.PowerPlants", "", Ares::readBuffer, Ares::readLength)) { this->Powerplants.Clear(); for (char *bld = strtok(Ares::readBuffer, Ares::readDelims); bld; bld = strtok(NULL, Ares::readDelims)) { if (BuildingTypeClass *pBld = BuildingTypeClass::Find(bld)) { this->Powerplants.AddItem(pBld); } else { Debug::INIParseFailed(pID, "AI.PowerPlants", bld); } } } INI_EX exINI(pINI); this->Parachute_Anim.Parse(&exINI, pID, "Parachute.Anim"); this->ParaDropPlane.Read(&exINI, pID, "ParaDrop.Aircraft"); char* p = NULL; if(pINI->ReadString(pID, "ParaDrop.Types", "", Ares::readBuffer, Ares::readLength)) { this->ParaDrop.Clear(); for(p = strtok(Ares::readBuffer, Ares::readDelims); p && *p; p = strtok(NULL, Ares::readDelims)) { TechnoTypeClass* pTT = UnitTypeClass::Find(p); if(!pTT) { pTT = InfantryTypeClass::Find(p); } if(pTT) { this->ParaDrop.AddItem(pTT); } else { Debug::INIParseFailed(pID, "ParaDrop.Types", p); } } } if(pINI->ReadString(pID, "ParaDrop.Num", "", Ares::readBuffer, Ares::readLength)) { this->ParaDropNum.Clear(); for(p = strtok(Ares::readBuffer, Ares::readDelims); p && *p; p = strtok(NULL, Ares::readDelims)) { this->ParaDropNum.AddItem(atoi(p)); } } if(pINI->ReadString(pID, "LoadScreenText.Color", "", Ares::readBuffer, 0x80)) { if(ColorScheme* CS = ColorScheme::Find(Ares::readBuffer)) { this->LoadTextColor = CS; } } this->RandomSelectionWeight = pINI->ReadInteger(pID, "RandomSelectionWeight", this->RandomSelectionWeight); this->CountryListIndex = pINI->ReadInteger(pID, "ListIndex", this->CountryListIndex); }
void HouseTypeExt::ExtData::LoadFromRulesFile | ( | TT * | pThis, |
CCINIClass * | pINI | ||
) | [virtual] |
{ char* pID = pThis->ID; this->InitializeConstants(pThis); if (pINI->ReadString(pID, "File.Flag", "", Ares::readBuffer, Ares::readLength)) { AresCRT::strCopy(this->FlagFile, Ares::readBuffer, 0x20); if(!PCX::Instance->LoadFile(this->FlagFile)) { Debug::INIParseFailed(pID, "File.Flag", this->FlagFile); } } if (pINI->ReadString(pID, "File.LoadScreen", "", Ares::readBuffer, Ares::readLength)) { AresCRT::strCopy(this->LSFile, Ares::readBuffer, 0x20); } if (pINI->ReadString(pID, "File.LoadScreenPAL", "", Ares::readBuffer, Ares::readLength)) { AresCRT::strCopy(this->LSPALFile, Ares::readBuffer, 0x20); } if (pINI->ReadString(pID, "File.Taunt", "", Ares::readBuffer, Ares::readLength)) { AresCRT::strCopy(this->TauntFile, Ares::readBuffer, 0x20); } if (pINI->ReadString(pID, "LoadScreenText.Name", "", Ares::readBuffer, Ares::readLength)) { AresCRT::strCopy(this->LSName, Ares::readBuffer, 0x20); } if (pINI->ReadString(pID, "LoadScreenText.SpecialName", "", Ares::readBuffer, Ares::readLength)) { AresCRT::strCopy(this->LSSpecialName, Ares::readBuffer, 0x20); } if (pINI->ReadString(pID, "LoadScreenText.Brief", "", Ares::readBuffer, Ares::readLength)) { AresCRT::strCopy(this->LSBrief, Ares::readBuffer, 0x20); } if (pINI->ReadString(pID, "MenuText.Status", "", Ares::readBuffer, Ares::readLength)) { AresCRT::strCopy(this->StatusText, Ares::readBuffer, 0x20); } if(pINI->ReadString(pID, "LoadScreenText.Color", "", Ares::readBuffer, 0x80)) { if(ColorScheme* CS = ColorScheme::Find(Ares::readBuffer)) { this->LoadTextColor = CS; } } }
virtual size_t HouseTypeExt::ExtData::Size | ( | ) | const [inline, virtual] |
Implements Extension< TT >.
{ return sizeof(*this); };
char HouseTypeExt::ExtData::FlagFile[0x20] |
ColorScheme* HouseTypeExt::ExtData::LoadTextColor |
char HouseTypeExt::ExtData::LSBrief[0x20] |
char HouseTypeExt::ExtData::LSFile[0x20] |
char HouseTypeExt::ExtData::LSName[0x20] |
char HouseTypeExt::ExtData::LSPALFile[0x20] |
char HouseTypeExt::ExtData::LSSpecialName[0x20] |
Valueable<AnimTypeClass*> HouseTypeExt::ExtData::Parachute_Anim |
TypeList<TechnoTypeClass*> HouseTypeExt::ExtData::ParaDrop |
TypeList<int> HouseTypeExt::ExtData::ParaDropNum |
ValueableIdx<int, AircraftTypeClass> HouseTypeExt::ExtData::ParaDropPlane |
DynamicVectorClass<BuildingTypeClass *> HouseTypeExt::ExtData::Powerplants |
char HouseTypeExt::ExtData::StatusText[0x20] |
char HouseTypeExt::ExtData::TauntFile[0x20] |