fn_collectGarbage.sqf 717 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. _cleanAll = false;
  2. if (count _this < 1) then
  3. {
  4. _cleanAll = true;
  5. }
  6. else
  7. {
  8. {
  9. _type = typeName _x;
  10. switch (_type) do
  11. {
  12. case "OBJECT": { if (!isNull _x && !isPlayer _x) then { deleteVehicle _x; }; };
  13. case "GROUP":
  14. {
  15. _units = units _x;
  16. {
  17. if (!isNull _x && !isPlayer _x) then { deleteVehicle _x; };
  18. } forEach _units;
  19. deleteGroup _x;
  20. };
  21. };
  22. } forEach _this;
  23. };
  24. if (!_cleanAll) exitWith {};
  25. {
  26. if (!isNull _x && !isPlayer _x) then { deleteVehicle _x; };
  27. } forEach allDead;
  28. {
  29. _canDeleteGroup = true;
  30. {
  31. if (!isNull _x && alive _x) exitWith { _canDeleteGroup = false; };
  32. } forEach units _x;
  33. if (_canDeleteGroup && !isNull _x) then { deleteGroup _x; };
  34. } forEach allGroups;