Remove legacy stream_location functions

These are no longer used for anything.
This commit is contained in:
ebaydayz
2016-04-17 21:23:25 -04:00
parent 4a32f34268
commit 2f45d46d05
8 changed files with 1 additions and 392 deletions

View File

@@ -370,207 +370,6 @@ fa_staywithus = {
}
};
// used only by fa_server_locationCheck
stream_locationFill = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\stream_locationFill.sqf";
dayz_locationsActive = [];
// used only by fa_smartlocation. Same as stream_locationCheck, but without any deletion.
fa_server_locationCheck = {
private ["_point","_rad","_config","_i","_location","_distCfg","_distAct"];
_point = _this select 0;
_rad = _this select 1;
_config = configFile >> "CfgTownGeneratorChernarus";
if (count _point >= 2) then {
for "_i" from (count _config -1) to 0 step -1 do {
_x = _config select _i;
_location = getArray (_x >> "position");
_distCfg = getNumber (_x >> "size");
_distAct = [_point select 0, _point select 1, 0] distance [_location select 0, _location select 1, 0];
if (!(_i in dayz_locationsActive)) then {
if (_distAct < _distCfg + _rad) then {
dayz_locationsActive set [count dayz_locationsActive,_i];
diag_log format ["%1::fa_server_locationCheck : creating %2 objects at '%3'", __FILE__, count _x, _location];
[_x, false] call stream_locationFill; // create wrecks & rubbish as local objects
};
};
};
};
};
// used only by fa_smartlocation
fa_smartlocation_commonTests = { // [_type, _pos, _minAltitude, _maxAltitude, _found]
private ["_found", "_point", "_worldspace"];
_found = false;
_point = _this select 1;
//diag_log(format["fa_smartlocation %1 %2", __LINE__, _this]);
_point set [2, 0];
_point = ATLtoASL _point;
if (((_point select 2) < _this select 3) AND {((_point select 2) > _this select 2)}) then {
if (count (_point nearEntities [["Air", "LandVehicle", "Ship"], _this select 4]) <= 0) then {
if (_this select 3 < 0) then { // boats
_found = surfaceisWater _point;
}
else { // not boats
_point set [2, 0];
_worldspace = [_this select 0, _point] call fn_niceSpot;
if (count _worldspace == 2) then {
_point = _worldspace select 1;
(_this select 1) set [0, _point select 0];
(_this select 1) set [1, _point select 1];
(_this select 1) set [2, 0];
_found = true;
};
};
};
};
// diag_log(format["fa_smartlocation %1 %2", __LINE__, _this]);
_found
};
// move vehicle to a safe position, respawn vehicle.
fa_smartlocation = {
private ["_type","_class","_dir","_oldpos","_action","_distance","_minAltitude","_maxAltitude","_tmpobject","_width","_found","_wp","_worldCenter","_worldRadius","_locations","_radius","_nearObjectTypes","_types","_pickedLocation","_o","_objects","_counter","_locpos","_loc","_y","_r","_deg","_veh","_size","_old", "_point"];
_type = _this select 0; // vehicle "typeOf"
_class = _type;
if (_type isKindOf "Air") then { _class = "Land_Ind_TankBig"; }; // for helis we take a big circular tank as a footprint
_dir = _this select 1;
_oldpos = +(_this select 2); // current vehicle position (from hive)
_action = _this select 3; // "OBJ"=> read from hive, keep position the best we can. Otherwise: choose a random position.
_distance = 500; // distance from other vehicles. decrease as soon as we can't find a spot
_minAltitude = getNumber(CONFIGBASE_VEHMAINTENANCE >> _type >> "minAltitude");
_maxAltitude = getNumber(CONFIGBASE_VEHMAINTENANCE >> _type >> "maxAltitude");
// workaround for sizeof bug -- do not remove
_tmpobject = _class createVehicleLocal (getMarkerPos "respawn_west");
sleep 0.01; // wait object loading
_width = (((boundingBox _tmpobject) select 1) select 0);
//diag_log(format["fa_smartlocation _this:%1 %2", _this, (sizeOf _class)]);
_point = [];
_found = false;
// try to place the object in a safe position near current position
if ((!(_action IN [ "CREATED", "SPAWNED"])) and {(count _oldpos>=2)}) then {
#ifdef VEH_MAINTENANCE_FIX_OUTOFMAP
// move object back on the map
_wp = [0, _oldpos] call fa_staywithus; // use ATL format
_point = +(_wp select 1);
if (count _point < 2) then { _point = _oldpos; };
#else
_point = +(_oldpos);
#endif
// find a safe position around current position for air vehicles
if (_type isKindOf "Air") then {
[_point, 20] call fa_server_locationCheck; // towngenerator around spawn point, to limit collisions
deleteVehicle _tmpobject;
_tmpobject = _class createVehicleLocal _point;
_point = getPosATL _tmpobject;
};
// check altitude
#ifdef VEH_MAINTENANCE_FIX_OUTOFMAP
if (count _point >= 2) then {
_point set [2, 0];
_point = ATLtoASL _point;
_found = (((_point select 2) < _maxAltitude) AND {((_point select 2) > _minAltitude)});
};
#else
_found = true;
#endif
/*diag_log(format["fa_smartlocation: Looking for a safe place near original position... _action:%1 _type:%2 suitable:%3 distance:%4",
_action,
_type,
_found,
if (_found) then { [_oldpos, _point] call BIS_fnc_distance2D } else { "" }
]);*/
}
else {
[_point, 20] call fa_server_locationCheck; // towngenerator around spawn point, to limit collisions
};
deleteVehicle _tmpobject;
sleep 0.01; // wait object destroy. nearEntities may return false info if not done.
#ifndef VEH_MAINTENANCE_DONT_BE_SMART
if (!_found) then { // we failed to find a suitable position around current one, so respawn vehicle
_worldCenter = getArray(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "center");
_worldRadius = getNumber(CONFIGBASE_VEHMAINTENANCE >> (worldName) >> "spawnRadius");
// if vehicle is not described in configFile, then locations is empty.
_locations = nearestLocations [
_worldCenter,
getArray(CONFIGBASE_VEHMAINTENANCE >> _type >> "localityTypes"),
_worldRadius
];
_radius = getNumber(CONFIGBASE_VEHMAINTENANCE >> _type >> "localityRadius");
_nearObjectTypes = getArray(CONFIGBASE_VEHMAINTENANCE >> _type >> "nearObjects");
// diag_log(format["fa_smartlocation: Getting choice logic: Altitude min:%1 max:%2 _radius:%3 _types=%4 countlocations:%5", _minAltitude, _maxAltitude, _radius, _nearObjectTypes, (count _locations) ]);
_pickedLocation = nil;
_o = nil;
_objects = nil;
_counter = 0;
_point = [];
while ({count _locations > 0 AND !_found}) do {
_pickedLocation = _locations call BIS_fnc_selectRandom;
_locpos = position _pickedLocation;
_locpos set [2,0];
_locpos = ATLtoASL _locpos;
// if location is in the sea, or on the ground and at the right altitude
if ((_maxAltitude<0) OR {(((_locpos select 2) < _maxAltitude+0.05*_radius) AND {((_locpos select 2) > _minAltitude-0.05*_radius)})}) then {
[_locpos, _radius] call fa_server_locationCheck;
if (count _nearObjectTypes > 0 ) then { // spawn close to an object
_objects = nearestObjects [_locpos, _nearObjectTypes, _radius];
//diag_log(format["fa_smartlocation: In locality loop _loc:%1 near objects count:%2 ", _pickedLocation, count _objects ]);
while ({count _objects > 0 AND !_found}) do {
_counter=_counter+0.0001;
_o = _objects call BIS_fnc_selectRandom;
// move spot in front of object, according to object length (its Y axis) and vehicle width (its X axis)
// vehicle should be located slightly in front object, twisted by a 90* angle
_point = _o modelToWorld [0,-(_width+(((boundingBox _o) select 1) select 1))/2,0];
_point set [2, 0];
_dir = (getDir _o)+90;
_found = [_class, _point, _minAltitude, _maxAltitude, _distance] call fa_smartlocation_commonTests;
//if (_found) then { diag_log(format["fa_smartlocation %1 %3 +--> %2", __LINE__, _point, _oldpos]); };
_objects = _objects - [_o];
_distance = _distance * 0.995;
};
}
else { // spawn anywhere on the location
for [{_y = _radius * _radius / 20000}, {(_y > 0 ) AND !_found}, {_y = _y - 1}] do {
_counter=_counter+0.0001;
_r = random(_radius*_radius)^0.5;
_deg = random 360;
_point = [(_locpos select 0) + sin(_deg) * _r, (_locpos select 1) + cos(_deg) * _r, 0];
_dir = _deg;
_found = [_class, _point, _minAltitude, _maxAltitude,_distance] call fa_smartlocation_commonTests;
//if (_found) then { diag_log(format["fa_smartlocation %1 %3 +--> %2", __LINE__, _point, _oldpos]); };
_distance = _distance * 0.995;
};
};
}; // was suitable altitude
_counter = _counter + 1;
_locations = _locations - [_pickedLocation];
}; // while suitable location
diag_log(format["fa_smartlocation: %2 _veh:%1 _size:%6 _old:%8 |--> _point:%3 _pickedLocation:%4 _counter=%5 badly near:%7",
_type,
if (_found) then {"ok"} else {"** FAILED **"},
_point,
if (!isNil "_pickedLocation") then {text(_pickedLocation)} else {""},
_counter, (sizeOf _class),
if (count _point >0) then { (_point nearEntities [["Air", "LandVehicle", "Ship"],_distance])-[_tmpobject] } else { "" },
_oldpos
]);
};
#endif
if (_found) then { [_dir, [_point select 0, _point select 1, 0]] } else { [] }
};
FNC_kindOf = {
_inherit = inheritsFrom _this;
_list = [configName _this];