本文整理汇总了C++中Train::SetWagon方法的典型用法代码示例。如果您正苦于以下问题:C++ Train::SetWagon方法的具体用法?C++ Train::SetWagon怎么用?C++ Train::SetWagon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Train
的用法示例。
在下文中一共展示了Train::SetWagon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertOldMultiheadToNew
/**
* Converts all trains to the new subtype format introduced in savegame 16.2
* It also links multiheaded engines or make them forget they are multiheaded if no suitable partner is found
*/
void ConvertOldMultiheadToNew()
{
Train *t;
FOR_ALL_TRAINS(t) SetBit(t->subtype, 7); // indicates that it's the old format and needs to be converted in the next loop
FOR_ALL_TRAINS(t) {
if (HasBit(t->subtype, 7) && ((t->subtype & ~0x80) == 0 || (t->subtype & ~0x80) == 4)) {
for (Train *u = t; u != NULL; u = u->Next()) {
const RailVehicleInfo *rvi = RailVehInfo(u->engine_type);
ClrBit(u->subtype, 7);
switch (u->subtype) {
case 0: // TS_Front_Engine
if (rvi->railveh_type == RAILVEH_MULTIHEAD) u->SetMultiheaded();
u->SetFrontEngine();
u->SetEngine();
break;
case 1: // TS_Artic_Part
u->subtype = 0;
u->SetArticulatedPart();
break;
case 2: // TS_Not_First
u->subtype = 0;
if (rvi->railveh_type == RAILVEH_WAGON) {
/* normal wagon */
u->SetWagon();
break;
}
if (rvi->railveh_type == RAILVEH_MULTIHEAD && rvi->image_index == u->spritenum - 1) {
/* rear end of a multiheaded engine */
u->SetMultiheaded();
break;
}
if (rvi->railveh_type == RAILVEH_MULTIHEAD) u->SetMultiheaded();
u->SetEngine();
break;
case 4: // TS_Free_Car
u->subtype = 0;
u->SetWagon();
u->SetFreeWagon();
break;
default: NOT_REACHED();
}
}
}
}
}