MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / FindBestMagazine

Method FindBestMagazine

engine/Poseidon/AI/VehicleAIPilot.cpp:1197–1218  ·  view source on GitHub ↗

! \param type given magazine type \param ammo minimal amount of ammo magazine must contain \return index of magazine in array or -1 if not found */

Source from the content-addressed store, hash-verified

1195\return index of magazine in array or -1 if not found
1196*/
1197int EntityAI::FindBestMagazine(const MagazineType* type, int ammo) const
1198{
1199 int best = -1;
1200 for (int j = 0; j < NMagazines(); j++)
1201 {
1202 const Magazine* reserve = GetMagazine(j);
1203 if (!reserve)
1204 {
1205 continue;
1206 }
1207 if (reserve->_type != type)
1208 {
1209 continue;
1210 }
1211 if (reserve->_ammo > ammo)
1212 {
1213 ammo = reserve->_ammo;
1214 best = j;
1215 }
1216 }
1217 return best;
1218}
1219
1220static void GetReloadActions(EntityAI* veh, UIActions& actions, int iSlot, const MuzzleType* currentMuzzle)
1221{

Callers 2

GetReloadActionsFunction · 0.80
ObjFireExFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected