コード例 #1
0
void
FltDlg::OnLaunch(AWEvent* event)
{
	if (!filter_list || !hangar_list || !ship) return;

	int squad = filter_list->GetSelectedIndex();

	Hangar* hangar = ship->GetHangar();

	// selected squadron:
	if (squad < hangar->NumSquadrons()) {
		for (int i = 0; i < hangar_list->NumItems(); i++) {
			if (hangar_list->IsSelected(i)) {
				int nslot = hangar_list->GetItemData(i);
				hangar->Launch(squad, nslot);
				NetUtil::SendShipLaunch(ship, squad, nslot);
			}
		}
	}

	// selected pending filter:
	else if (squad == hangar->NumSquadrons()) {
		for (int item = 0; item < hangar_list->NumItems(); item++) {
			if (hangar_list->IsSelected(item)) {
				int squadron = hangar_list->GetItemData(item, 3);
				int slot     = hangar_list->GetItemData(item, 4);

				if (squadron >= 0 && slot >= 0) {
					hangar->Launch(squadron, slot);
					NetUtil::SendShipLaunch(ship, squadron, slot);
				}
			}
		}
	}
}
コード例 #2
0
void
NetGameClient::DoShipLaunch(NetMsg* msg)
{
	if (!msg) return;

	NetShipLaunch ship_launch;
	ship_launch.Unpack(msg->Data());

	Sim*  sim      = Sim::GetSim();
	int   squadron = ship_launch.GetSquadron();
	int   slot     = ship_launch.GetSlot();

	Ship* carrier = FindShipByObjID(ship_launch.GetObjID());

	if (carrier) {
		Hangar* hangar = carrier->GetHangar();

		if (hangar) {
			hangar->Launch(squadron, slot);
		}
	}
}