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


C++ Ship::GetFlightDeck方法代码示例

本文整理汇总了C++中Ship::GetFlightDeck方法的典型用法代码示例。如果您正苦于以下问题:C++ Ship::GetFlightDeck方法的具体用法?C++ Ship::GetFlightDeck怎么用?C++ Ship::GetFlightDeck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ship的用法示例。


在下文中一共展示了Ship::GetFlightDeck方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: new

void
NetGameClient::DoElemCreate(NetMsg* msg)
{
	if (!msg) return;

	NetElemCreate elem_create;
	elem_create.Unpack(msg->Data());

	const char* elem_name = elem_create.GetName().data();

	::Print("NetGameClient::DoElemCreate name: %s iff: %d type %s\n",
	elem_name,
	elem_create.GetIFF(),
	Mission::RoleName(elem_create.GetType()));

	Sim*     sim   = Sim::GetSim();
	Element* elem  = sim->FindElement(elem_name);
	if (elem) {
		::Print("  element '%' already exists - ignored\n", elem_name);
		return;
	}

	elem = sim->CreateElement(elem_name,
	elem_create.GetIFF(),
	elem_create.GetType());

	int*     load     = elem_create.GetLoadout();
	int*     slots    = elem_create.GetSlots();
	int      squadron = elem_create.GetSquadron();
	int      code     = elem_create.GetObjCode();
	Text     target   = elem_create.GetObjective();
	bool     alert    = elem_create.GetAlert();
	bool     active   = elem_create.GetInFlight();

	elem->SetIntelLevel(elem_create.GetIntel());
	elem->SetLoadout(load);

	if (code > Instruction::RTB || target.length() > 0) {
		Instruction* obj  = new(__FILE__,__LINE__) Instruction(code, target);
		elem->AddObjective(obj);
	}

	Ship* carrier = sim->FindShip(elem_create.GetCarrier());
	if (carrier) {
		elem->SetCarrier(carrier);

		Hangar* hangar = carrier->GetHangar();
		if (hangar) {
			Text squadron_name = hangar->SquadronName(squadron);
			elem->SetSquadron(squadron_name);

			if (active) {
				for (int i = 0; i < 4; i++) {
					int slot = slots[i];
					if (slot > -1) {
						hangar->GotoActiveFlight(squadron, slot, elem, load);
					}
				}
			}

			else {
				FlightDeck* deck   = 0;
				int         queue  = 1000;

				for (int i = 0; i < carrier->NumFlightDecks(); i++) {
					FlightDeck* d = carrier->GetFlightDeck(i);

					if (d && d->IsLaunchDeck()) {
						int dq = hangar->PreflightQueue(d);

						if (dq < queue) {
							queue = dq;
							deck  = d;
						}
					}
				}

				for (int i = 0; i < 4; i++) {
					int slot = slots[i];
					if (slot > -1) {
						hangar->GotoAlert(squadron, slot, deck, elem, load, !alert);
					}
				}
			}
		}
	}
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:87,代码来源:NetGameClient.cpp

示例2: if

void
NetGameClient::DoObjKill(NetMsg* msg)
{
	if (!msg) return;

	NetObjKill obj_kill;
	obj_kill.Unpack(msg->Data());

	Ship* ship = FindShipByObjID(obj_kill.GetObjID());
	if (ship) {
		Ship* killer = FindShipByObjID(obj_kill.GetKillerID());
		Text  killer_name = Game::GetText("NetGameClient.unknown");

		if (killer)
		killer_name = killer->Name();

		// log the kill:
		switch (obj_kill.GetKillType()) {
		default:
		case NetObjKill::KILL_MISC:
			Print("Ship '%s' destroyed (misc) (%s)\n", ship->Name(), FormatGameTime());
			break;

		case NetObjKill::KILL_PRIMARY:
		case NetObjKill::KILL_SECONDARY:
			Print("Ship '%s' killed by '%s' (%s)\n", ship->Name(), killer_name.data(), FormatGameTime());
			break;

		case NetObjKill::KILL_COLLISION:
			Print("Ship '%s' killed in collision with '%s' (%s)\n", ship->Name(), killer_name.data(), FormatGameTime());
			break;

		case NetObjKill::KILL_CRASH:
			Print("Ship '%s' destroyed (crash) (%s)\n", ship->Name(), FormatGameTime());

		case NetObjKill::KILL_DOCK:
			Print("Ship '%s' docked (%s)\n", ship->Name(), FormatGameTime());
		}

		// record the kill in the stats:
		if (killer && obj_kill.GetKillType() != NetObjKill::KILL_DOCK) {
			ShipStats* kstats = ShipStats::Find(killer->Name());
			if (kstats) {
				if (obj_kill.GetKillType() == NetObjKill::KILL_PRIMARY)
				kstats->AddEvent(SimEvent::GUNS_KILL, ship->Name());
				
				else if (obj_kill.GetKillType() == NetObjKill::KILL_SECONDARY)
				kstats->AddEvent(SimEvent::MISSILE_KILL, ship->Name());
			}

			if (killer && killer->GetIFF() != ship->GetIFF()) {
				if (ship->GetIFF() > 0 || killer->GetIFF() > 1)
				kstats->AddPoints(ship->Value());
			}
		}

		ShipStats* killee = ShipStats::Find(ship->Name());
		if (killee) {
			if (obj_kill.GetKillType() == NetObjKill::KILL_DOCK)
			killee->AddEvent(SimEvent::DOCK, killer_name);
			else 
			killee->AddEvent(SimEvent::DESTROYED, killer_name);
		}

		if (obj_kill.GetKillType() == NetObjKill::KILL_DOCK) {
			FlightDeck* deck = killer->GetFlightDeck(obj_kill.GetFlightDeck());
			sim->NetDockShip(ship, killer, deck);
		}
		else {
			ship->InflictNetDamage(ship->Integrity());
			ship->DeathSpiral();

			if (!obj_kill.GetRespawn())
			ship->SetRespawnCount(0);
			else
			ship->SetRespawnLoc(obj_kill.GetRespawnLoc());
		}
	}

	// this shouldn't happen in practice, 
	// but if it does, this is what should be done:
	else {
		Shot* shot = FindShotByObjID(obj_kill.GetObjID());

		if (shot) {
			::Print("NetGameClient::DoObjKill destroying shot '%s'\n", shot->Name());
			shot->Destroy();
		}
	}
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:90,代码来源:NetGameClient.cpp


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