当前位置: 首页>>代码示例>>C++>>正文


C++ CUnitTypeData::Init方法代码示例

本文整理汇总了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;
	}
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:62,代码来源:CUnitDefLoader.cpp


注:本文中的CUnitTypeData::Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。