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

Method IssueVCommand

engine/Poseidon/UI/InGame/InGameUI.cpp:1266–1331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1264
1265void InGameUI::Init()
1266{
1267 ShowAll();
1268 ShowCursors();
1269}
1270
1271int ValidateWeapon(EntityAI* vehicle, int weapon)
1272{
1273 int n = vehicle->NMagazineSlots();
1274 if (weapon < 0 || weapon >= n)
1275 {
1276 return -1;
1277 }
1278
1279 return weapon;
1280}
1281
1282void InGameUI::ResetVehicle(EntityAI* vehicle)
1283{
1284 int weapon = vehicle->FirstWeapon();
1285 weapon = ValidateWeapon(vehicle, weapon);
1286 // if the weapon is not weapon, but rather special item, do not select it
1287 if (weapon >= 0)
1288 {
1289 const MagazineSlot& slot = vehicle->GetMagazineSlot(weapon);
1290 const WeaponType* type = slot._weapon;
1291 if (!(type->_weaponType & MaskSlotPrimary) && (type->_weaponType & (MaskSlotBinocular | MaskSlotSecondary)))
1292 {
1293 // do not autoselect binocular or secondary weapon
1294 weapon = -1;
1295 }
1296 }
1297 if (vehicle->QIsManual())
1298 {
1299 vehicle->SelectWeapon(weapon, true);
1300 }
1301
1302 if (vehicle == _target.IdExact())
1303 {
1304 _target = nullptr;
1305 }
1306 if (vehicle == _lockTarget.IdExact())
1307 {
1308 _lockTarget = nullptr, _lockAimValidUntil = Glob.uiTime - 60;
1309 }
1310
1311 _cursorWorld = false;
1312 _modelCursor = VForward;
1313 // commander should always use eye direction
1314
1315 AIUnit* unit = GWorld->FocusOn();
1316 bool isObserver = unit && unit == vehicle->ObserverUnit();
1317 bool isGunner = unit && unit == vehicle->GunnerUnit();
1318
1319 if (isObserver)
1320 {
1321 _worldCursor = vehicle->GetEyeDirection();
1322 }
1323 else if (weapon >= 0 && isGunner)

Callers

nothing calls this directly

Calls 8

FocusOnMethod · 0.80
SendMoveMethod · 0.80
SendRadioMessageMethod · 0.80
SendFireMethod · 0.80
SendJoinMethod · 0.80
SendSimpleCommandMethod · 0.80
CommanderUnitMethod · 0.45
IsLocalMethod · 0.45

Tested by

no test coverage detected