⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 munition.cpp

📁 空战游戏flacon源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
		}
		else
		{
			if(win)
				win->EnableCluster(-100);
			txt->SetFlagBitOn(C_BIT_TIMER);
			if (flt->GetFirstUnitWP ())
			{
				GetTimeString(flt->GetFirstUnitWP()->GetWPDepartureTime(),buf);
				txt->SetText(buf);
			}
			else
			{
				txt->SetText ("");
			}
		}
	}
	txt=(C_Text*)win->FindControl(FLIGHT_STATUS);
	if(txt)
	{
		txt->Refresh();
		if(status)
			txt->SetText(TXT_FLIGHT_STATUS);
		else
			txt->SetText(TXT_FLIGHT_TAKEOFF);
	}
	if(status)
		win->DisableCluster(-100);
	else
		win->EnableCluster(-100);
	vid = flt->GetVehicleID(0);
	PlaneCount=flt->GetTotalVehicles();
	vc = GetVehicleClassData(vid);
	for(i=0;i<4;i++)
	{
		if(i < PlaneCount)
		{
			switch(i)
			{
				case 0:
					btn=(C_Button *)win->FindControl(AIR_1);
					break;
				case 1:
					btn=(C_Button *)win->FindControl(AIR_2);
					break;
				case 2:
					btn=(C_Button *)win->FindControl(AIR_3);
					break;
				case 3:
					btn=(C_Button *)win->FindControl(AIR_4);
					break;
			}
			if(btn)
			{
				btn->Refresh();
				btn->SetState(1);
				btn->SetFlagBitOn(C_BIT_ENABLED);
				session=gCommsMgr->FindCampaignPlayer(flt->Id(),static_cast<uchar>(i));
				if(session)
				{
					_stprintf(buf,"%s",session->GetPlayerName());
				}
				else
				{
					TheCampaign.MissionEvaluator->GetPilotName(i,buf);
				}
				btn->SetAllLabel(buf);
				btn->Refresh();		 //@ mark here:  Set pilots
			}
			SetPlaneToArm(i,TRUE);
		}
		else
		{
			switch(i)
			{
				case 0:
					btn=(C_Button *)win->FindControl(AIR_1);
					break;
				case 1:
					btn=(C_Button *)win->FindControl(AIR_2);
					break;
				case 2:
					btn=(C_Button *)win->FindControl(AIR_3);
					break;
				case 3:
					btn=(C_Button *)win->FindControl(AIR_4);
					break;
			}
			if(btn)
			{
				btn->Refresh();
				btn->SetState(0);
				btn->SetFlagBitOff(C_BIT_ENABLED);
				btn->SetAllLabel(" ");
				btn->Refresh();
			}
			SetPlaneToArm(i,FALSE);
		}
	}
	win->ScanClientAreas();
	win->RefreshWindow();
}

void UpdateStoresTally(C_Window *win)
{
	long i,wid,color,avail,availID;
	CONTROLLIST *cur;
	C_Text *txt;
	_TCHAR buf[STRING_BUFFER_SIZE];

	TallyStores();

	cur=win->GetControlList();
	while(cur)
	{
		// Update Inventory Numbers (Out -> High)
		if((cur->Control_->GetID() & 0xff000000) == (1 << 25))
		{
			cur->Control_->Refresh();
			avail=TotalAvailable(static_cast<short>(cur->Control_->GetID() & 0x0000ffff));
			if(!avail)
			{
				availID=TXT_SUPPLY_OUT;
				color=0x0000ff;
			}
			else if(avail < 700)
			{
				availID=TXT_SUPPLY_LOW;
				color=0x00ffff;
			}
			else if(avail < 1500)
			{
				availID=TXT_SUPPLY_MEDIUM;
				color=0xeeeeee;
			}
			else
			{
				availID=TXT_SUPPLY_HIGH;
				color=0x00ff00;
			}

			((C_Text*)cur->Control_)->SetText(availID);
			((C_Text*)cur->Control_)->SetFGColor(color);
			cur->Control_->Refresh();
		}
		// Update Onboard Count
		if((cur->Control_->GetID() & 0x0f000000) == (1 << 24))
		{
			cur->Control_->Refresh();
			_tcscpy(buf," ");
			((C_Text*)cur->Control_)->SetText(buf);

			wid=-1;
			for(i=0;i<QuantityCount[FirstPlane];i++)
			{
				if(Quantity[FirstPlane][0][i] == (cur->Control_->GetID() & 0x00ffffff))
				{
					wid=i;
					break;
				}
			}
			if(wid != -1)
				if(Quantity[FirstPlane][1][wid])
				{
					_stprintf(buf,"%1d",Quantity[FirstPlane][1][wid]);
					((C_Text*)cur->Control_)->SetText(buf);
				}
			cur->Control_->Refresh();
		}

		cur=cur->Next;
	}

	DetermineWeight(gLoadoutFlightID);

	txt=(C_Text*)win->FindControl(MAX_WEIGHT);
	if(txt)
	{
		_stprintf(buf,"%1d",_MAX_WEIGHT_[FirstPlane]);
		txt->SetText(buf);
		txt->Refresh();
	}
	txt=(C_Text*)win->FindControl(CURRENT_WEIGHT);
	if(txt)
	{
		if(_CURRENT_WEIGHT_[FirstPlane] > _MAX_WEIGHT_[FirstPlane])
			txt->SetFGColor(0x0000ff);
		else
			txt->SetFGColor(0xd9a051);
		_stprintf(buf,"%1d",_CURRENT_WEIGHT_[FirstPlane]);
		txt->SetText(buf);
		txt->Refresh();
	}
	txt=(C_Text*)win->FindControl(CLEAN_WEIGHT);
	if(txt)
	{
		_stprintf(buf,"%1d",_CLEAN_WEIGHT_[FirstPlane]);
		txt->SetText(buf);
		txt->Refresh();
	}
	txt=(C_Text*)win->FindControl(DRAG_FACTOR);
	if(txt)
	{
		_stprintf(buf,"%5.1f",_DRAG_FACTOR_[FirstPlane]);
		Uni_Float(buf);
		txt->SetText(buf);
		txt->Refresh();
	}
	txt=(C_Text*)win->FindControl(MUNITIONS_WEIGHT);
	if(txt)
	{
		_stprintf(buf,"%1d",_MUNITIONS_WEIGHT_[FirstPlane]);
		txt->SetText(buf);
		txt->Refresh();
	}
	txt=(C_Text*)win->FindControl(FUEL_WEIGHT);
	if(txt)
	{
		_stprintf(buf,"%1d",_FUEL_WEIGHT_[FirstPlane]);
		txt->SetText(buf);
		txt->Refresh();
	}
}

void InternalArmPlaneCB(long ID,short hittype,C_Base *control)
{
	long hp,count,weaponID,startcount;
	CONTROLLIST *cur;
	STORESLIST *store;
	int i;

	if(hittype != C_TYPE_LMOUSEUP && hittype != C_TYPE_REPEAT)
		return;

	hp=ID >> 16;
	weaponID=ID & 0x0000ffff;
	store=gStores->Find(weaponID);

	if(store == NULL)
		return;

	count=control->GetUserNumber(0);
	startcount=count;
	if(control->GetRelY() < control->GetH()/2)
		count++;
	else
		count--;
	if(count < 0)
		count=0;

	if(count > control->GetUserNumber(1))
		count=control->GetUserNumber(1);

	if(count && !TotalAvailable(static_cast<short>(weaponID)))
		count--;

	if(!count && count == startcount) //None available
	{
		return;
	}

	cur=control->Parent_->GetControlList();
	while(cur)
	{
		if(cur->Control_->GetGroup() == hp)
		{
			if(count)
			{
				cur->Control_->SetState(C_STATE_DISABLED);
				cur->Control_->SetUserNumber(0,0);
			}
			else
			{
				cur->Control_->SetState(0);
				cur->Control_->SetUserNumber(0,0);
			}
			cur->Control_->Refresh();
		}
		cur=cur->Next;
	}

	if(count)
		control->SetState(2);
	else
		control->SetState(0);

	control->SetUserNumber(0,count);

	for(i=0;i<4;i++)
	{
		if(PlaneEditList[i])
		{
			gCurStores[i].WeaponID[hp]=static_cast<uchar>(weaponID);
			if(count && !TotalAvailable(static_cast<short>(weaponID)))
				count--;
			gCurStores[i].WeaponCount[hp]=static_cast<uchar>(count);
		}
	}
	UpdateStoresTally(control->Parent_);

	control->Parent_->RefreshClient(2);
}

void ArmPlaneCB(long ID,short hittype,C_Base *control)
{
	long hp,count,weaponID,startcount;
	CONTROLLIST *cur;
	STORESLIST *store;
	int i;
	F4CSECTIONHANDLE *Leave;

	if(hittype != C_TYPE_LMOUSEUP)
		return;

	hp=ID >> 16;
	weaponID=ID & 0x0000ffff;
	store=gStores->Find(weaponID);

	if(store == NULL || !control)
		return;

	count=control->GetUserNumber(0);
	startcount=count;
	count++;
	if(count > control->GetUserNumber(1))
		count=0;

	if(count &&  !TotalAvailable(static_cast<short>(weaponID)))
		count--;

	if(!count && count == startcount) //None available
	{
		return;
	}

	Leave=UI_Enter(control->Parent_);
	cur=control->Parent_->GetControlList();
	while(cur)
	{
		if(cur->Control_->GetGroup() == hp)
		{
			if(count)
			{
				cur->Control_->SetState(C_STATE_DISABLED);
				cur->Control_->SetUserNumber(0,0);
			}
			else
			{
				cur->Control_->SetState(0);
				cur->Control_->SetUserNumber(0,0);
			}
			cur->Control_->Refresh();
		}
		cur=cur->Next;
	}

	control->SetState(static_cast<short>(count<<1));
	control->SetUserNumber(0,count);

	for(i=0;i<4;i++)
	{
		if(PlaneEditList[i])
		{
			gCurStores[i].WeaponID[hp]=static_cast<uchar>(weaponID);
			if(count && !TotalAvailable(static_cast<short>(weaponID)))
				count--;
			gCurStores[i].WeaponCount[hp]=static_cast<uchar>(count);
			ClearHardPoint(i,hp,HardPoints/2,&gCurRails[i].rail[hp]);
			if(GetRackAndWeapon(gVCPtr,static_cast<short>(gVehID),gCurStores[i].WeaponID[hp],gCurStores[i].WeaponCount[hp],static_cast<short>(hp),static_cast<short>(HardPoints/2),&gCurRails[i].rail[hp]))
				LoadHardPoint(i,hp,HardPoints/2,&gCurRails[i].rail[hp]);
		}
	}
	UpdateStoresTally(control->Parent_);

	control->Parent_->RefreshClient(2);
	UI_Leave(Leave);
}

void SetCurrentLoadout()
{
	int i,j,Diff;
	CONTROLLIST *cur;
	C_Window *win;
	F4CSECTIONHANDLE *Leave;

	win=gMainHandler->FindWindow(MUNITIONS_WIN);
	if(win == NULL)
		return;

	Leave=UI_Enter(win);
	for(j=1;j<HardPoints;j++)
	{
		cur=win->GetControlList();
		while(cur)
		{
			if(cur->Control_->GetGroup() == j)
			{
				if(cur->Control_->GetID() == ((j << 16) | gCurStores[FirstPlane].WeaponID[j]))
				{
					Diff=0;
					for(i=0;i<4;i++)
					{
						if(PlaneEditList[i] && (gCurStores[FirstPlane].WeaponID[j] != gCurStores[i].WeaponID[j] || gCurStores[FirstPlane].WeaponCount[j] != gCurStores[i].WeaponCount[j]))
							Diff=1;
					}
					cur->Control_->SetUserNumber(0,gCurStores[FirstPlane].WeaponCount[j]);
					cur->Control_->SetState(static_cast<short>((gCurStores[FirstPlane].WeaponCount[j] << 1)+Diff));
				}
				else
				{
					Diff=0;
					for(i=0;i<4;i++)
					{
						if(PlaneEditList[i] && (cur->Control_->GetID() == ((j << 16) | gCurStores[i].WeaponID[j]) && i != FirstPlane))
							Diff=1;
					}
					cur->Control_->SetUserNumber(0,0);
					if(gCurStores[FirstPlane].WeaponCount[j] && !Diff)
						cur->Control_->SetState(C_STATE_DISABLED);
					else
						cur->Control_->SetState(static_cast<short>(Diff));
				}
				cur->Control_->Refresh();
			}
			cur=cur->Next;
		}
	}
	UpdateStoresTally(win);
	UI_Leave(Leave);
}

void SetupLoadoutDisplay()
{
	Flight flt;
	Squadron sqd;
	VehicleClassDataType *vc;
	WeaponClassDataType  *wc;
	Falcon4EntityClassType* classPtr;
	int vid,i,j,slist = -1,wtype;
	long fuel,avail;
	STORESLIST *wpn;

	flt=(Flight)vuDatabase->Find(gLoadoutFlightID);
	if(!flt)
		return;

	sqd=(Squadron)flt->GetUnitSquadron();
	if(!sqd)
		return;

	vid = flt->GetVehicleID(0);
	vc = GetVehicleClassData(vid);
	if(!vc)
		return;

	for(i=1;i<HardPoints;i++)
	{
		if(vc->Weapon[i] && vc->Weapons[i])
		{
			if(vc->Weapons[i] == 255)
			{
				for(j=0;j<MAX_WEAPONS_IN_LIST;j++)
				{
					if(GetListEntryWeapon(vc->Weapon[i],j))
					{
						wpn=gStores->Find(GetListEntryWeapon(vc->Weapon[i],j));
					
						if(wpn == NULL)
						{
							if(TheCampaign.Flags & CAMP_TACTICAL)
								avail=2000;
							else
							{
								avail=sqd->GetAvailableStores(GetListEntryWeapon(vc->Weapon[i],j));
								switch(avail)
								{
									case 0:
										break;
									case 1:
										avail=500;
										break;
									case 2:
										avail=1000;
										break;
									default:
										avail=2000;
										break;
								}
							}
							fuel=0;
							wc=&WeaponDataTable[GetListEntryWeapon(vc->Weapon[i],j)];
							classPtr = &Falcon4ClassTable[wc->Index];
							if(classPtr)
							{
								if(classPtr->vuClassData.classInfo_[VU_TYPE] == TYPE_MISSILE)
								{
									if(classPtr->vuClassData.classInfo_[VU_STYPE] == STYPE_MISSILE_AIR_AIR)
									{
										wtype=StoresList::_TYPE_MISSILE_;
										slist=StoresList::_AIR_TO_AIR_;
									}
									else
									{
										wtype=StoresList::_TYPE_MISSILE_;
										slist=StoresList::_AIR_TO_GROUND_;
									}
								}
								else if(classPtr->vuClassData.classInfo_[VU_TYPE] == TYPE_ROCKET ||
										classPtr->vuClassData.classInfo_[VU_TYPE] == TYPE_LAUNCHER)
								{
									wtype=StoresList::_TYPE_ROCKET_;
									slist=StoresList::_AIR_TO_GROUND_;
								}
								else if(classPtr->vuClassData.classInfo_[VU_TYPE] == TYPE_BOMB)
								{
									wtype=StoresList::_TYPE_BOMB_;
									slist=StoresList::_AIR_TO_GROUND_;
								}
								else if(classPtr->vuClassData.classInfo_[VU_TYPE] == TYPE_GUN)
								{
									wtype=StoresList::_TYPE_GUN_;
									slist=StoresList::_AIR_TO_GROUND_;
								}
								else if(classPtr->vuClassData.classInfo_[VU_TYPE] == TYPE_FUEL_TANK)
								{
									wtype=StoresList::_TYPE_FUEL_;
									slist=StoresList::_OTHER_;
									fuel=wc->Strength;
								}
								else
								{
									wtype=StoresList::_TYPE_OTHER_;
									slist=StoresList::_OTHER_;
								}
								wpn=gStores->Create(GetListEntryWeapon(vc->Weapon[i],static_cast<short>(j)),wc->Name,wtype,wc->Weight,fuel,wc->DragIndex,static_cast<short>(avail)); // add stores wgt,drag factor
							}
							else
							{
								wpn=gStores->Create(GetListEntryWeapon(vc->Weapon[i],static_cast<short>(j)),wc->Name,StoresList::_TYPE_OTHER_,wc->Weight,fuel,wc->DragIndex,static_cast<short>(avail)); // add stores wgt,drag factor
							}
							gStores->Add(wpn,slist);
						}
						wpn->HardPoint[i]=static_cast<short>(GetListEntryWeapons(vc->Weapon[i],j));
					}
				}
			}
			else
			{
				wpn=gStores->Find(vc->Weapon[i]);
				if(wpn == NULL)
				{
					if(TheCampaign.Flags & CAMP_TACTICAL)
						avail=2000;
					else
					{
						avail=sqd->GetAvailableStores(vc->Weapon[i]);
						switch(avail)
						{
							case 0:
								break;
							case 1:
								avail=500;
								break;
							case 2:
								avail=1000;
								break;
							default:
								avail=2000;
								break;
						}
					}
					fuel=0;
					wc=&WeaponDataTable[vc->Weapon[i]];
					classPtr = &Falcon4ClassTable[wc->Index];
					if(classPtr)
					{
						if(classPtr->vuClassData.classInfo_[VU_TYPE] == TYPE_MISSILE)
						{
							if(classPtr->vuClassData.classInfo_[VU_STYPE] == STYPE_MISSILE_AIR_AIR)
							{
								wtype=StoresList::_TYPE_MISSILE_;
								slist=StoresList::_AIR_TO_AIR_;
							}
							else
							{
								wtype=StoresList::_TYPE_MISSILE_;
								slist=StoresList::_AIR_TO_GROUND_;
							}
						}
						else if(classPtr->vuClassData.classInfo_[VU_TYPE] == TYPE_ROCKET ||
								classPtr->vuClassData.classInfo_[VU_TYPE] == TYPE_LAUNCHER)
						{
							wtype=StoresList::_TYPE_ROCKET_;
							slist=StoresList::_AIR_TO_GROUND_;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -