本文整理汇总了C++中CUnitTypeData::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ CUnitTypeData::Init方法的具体用法?C++ CUnitTypeData::Init怎么用?C++ CUnitTypeData::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUnitTypeData
的用法示例。
在下文中一共展示了CUnitTypeData::Init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CUnitTypeData
CUnitDefLoader::CUnitDefLoader(Global* GL){
// Initialize pointer to the Global class
G = GL;
// retrieve the number of unit definitions
unum = G->cb->GetNumUnitDefs();
// for debugging purposes:
//G->L.iprint("AI interface says this mod has this many units! :: "+to_string(unum));
// Check if a horrific error has occured
if(unum < 1){
// omgwtf this should never happen!
G->L.eprint("URGENT! GetNumUnitDefs returned ZERO!! This means that there are no unit definitions of any kind!!! Unrecoverable error!");
// A horrible event has occurred somewhere in the spring engine for this to have happened.
// Even if the AI could recover from this, the engine could not.
// Exit this method immediatly. A crash is likely but if the crash was fixed, the engine
// or another AI, would crash afterwards anyway.
return;
}
// initialize arrays
// The unitdeflist array will be passed to the engine where it will be filled with pointers
UnitDefList = new const UnitDef*[unum];
// retrieve the list of unit definition pointers from the engine
G->cb->GetUnitDefList(UnitDefList);
// for each definition
for(int n=0; n < unum; n++){
// retrieve the units definition
const UnitDef* pud = UnitDefList[n];
// initialize a UnitTypeData object
CUnitTypeData* cutd = new CUnitTypeData();
// now initialize the newly added object with the unit definition
cutd->Init(G,pud);
// add it into the main array
type_data[pud->id] = cutd;
// check if the unit definition is zero, if so skip
//if(pud == 0) continue;
// make sure the name is in the correct format and add it to the map container
string na = pud->name;
trim(na);
tolowercase(na);
defs[na] = pud->id;
}
}