MDV factories always generate "accessed none" log errors whenever an MDV spawns

Issue #93 resolved
Matt Hands created an issue

DH_MobileDeployVehicles is the parent class of all MDV factories. In its SpawnVehicle function it tries to cast to all 3 MDV vehicle classes without != none checks, so each MDV factory always generates 2 "accessed none" errors whenever an MDV spawns.

The casts are done to pass the leveller's bRequiresSquadLeaderToDrive setting to the spawned vehicle.

class DH_MobileDeployVehicles extends DH_VehicleFactory;

var()  bool  bRequiresSLToDrive; //requires a leader to drive the MDV

//modified function to set the spawned vehicle with a custom tag (called by the teleporter)
function SpawnVehicle()
{
    //Call the super
    super.SpawnVehicle();

    //Because RequiresLeader is defaulted to true, lets only change it to false if needed
    if( !bRequiresSLToDrive )
    {
        if( LastSpawnedVehicle != None )
        {
            DH_MobileDeployVehicle_Allies(LastSpawnedVehicle).bMustBeSL = bRequiresSLToDrive;
            DH_MobileDeployVehicle_UK(LastSpawnedVehicle).bMustBeSL = bRequiresSLToDrive;
            DH_MobileDeployVehicle_Axis(LastSpawnedVehicle).bMustBeSL = bRequiresSLToDrive;
        }
    }
}

Comments (2)

  1. Matt Hands reporter

    The easy fix would be to subclass SpawnVehicle to set bRequiresSLToDrive in each specific MDV factory class.

    But really this sort of thing is much better handled by the proposed simple change to DH_VehicleFactory's SpawnVehicle, where the factory will be set as the vehicle's owner in the Spawn function. That will allow any vehicle to access any settings that have been specified in the factory class, during the vehicle's own initialisation.

    This situation is a typical example, where the MDV's PostBeginPlay would simply set bRequiresSLToDrive = DH_MobileDeployVehicles(Owner).bRequiresSLToDrive.

    So best to hold off on fixing this very minor issue until the DH_VehicleFactory class is updated.

    ps - I would suggest folding MDVs into DH_Vehicles and MDV teleporter classes into DH_LevelActors, then scrapping DH_MobileDeploy as a separate code package.

  2. Log in to comment