From 396f58e94171e1f9e5a3a3b8d687258bfb3603e1 Mon Sep 17 00:00:00 2001
From: vbawol <vbawol@veteranbastards.com>
Date: Wed, 14 Oct 2015 16:27:09 -0500
Subject: [PATCH] fixes and less debug

---
 .../@epochhive/addons/a3_epoch_server.pbo     | Bin 360647 -> 361780 bytes
 .../sc/battleye/createvehicle.txt             |   2 +-
 .../epoch_bases/EPOCH_server_saveBuilding.sqf |   2 +-
 .../epoch_server/EPOCH_localCleanup.sqf       |  18 +-
 .../EPOCH_server_loadTraders.sqf              |   3 +-
 .../EPOCH_server_makeNPCTrade.sqf             |  43 ++++-
 .../epoch_vehicle/EPOCH_load_storage.sqf      |   4 +-
 .../epoch_vehicle/EPOCH_load_vehicles.sqf     |   3 +-
 .../epoch_vehicle/EPOCH_save_storage.sqf      |   2 +-
 .../EPOCH_server_lockStorage.sqf              |   6 +-
 .../EPOCH_server_packStorage.sqf              |   2 +-
 .../epoch_vehicle/EPOCH_spawn_vehicle.sqf     | 169 +++++++++---------
 .../epoch_vehicle/EPOCH_spawn_vehicles.sqf    | 168 +++++++++--------
 .../epoch_server/system/server_monitor.fsm    |   6 +-
 14 files changed, 229 insertions(+), 199 deletions(-)

diff --git a/Server_Install_Pack/@epochhive/addons/a3_epoch_server.pbo b/Server_Install_Pack/@epochhive/addons/a3_epoch_server.pbo
index 488401bfbde647a38f510f82a3c8887cee7df641..20dee4069579a2759aadb96d30627cf7705bb795 100644
GIT binary patch
delta 3823
zcmb7HdvKFg7WdwKNlDVQNs~5xrnhNR`+}Ah2c^mwX@L%<6v3!;OZZ5>wvjK7CMj63
zJQOJ7V^_T3#T68hb=~nTtKW)>6d5YWitg+TGs?QMvootRK5)nNv7qj`_e&wW|7~WP
zd+#~FbIv`_n@(;i`u)8{556lsI^YTHJhND=l%PMGIHAx^&l{@Q#^-PzZNxS~J8TuS
z=(E_uE<B4R8pk$WYBTl=1S{YO+G5D1-(rX9U%&MP?w%r58@b+PbPKLw&pnUx>3xQC
zLa1aK2o<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k`ym;(c7u<fEaq@GJA>hF$WY2Q
z!D<~2?qsOLJ7N2R9Bpc?@>K`hM0O9@q{%5<Go`GH$x@`HT?$2FWwIFb<rGYs@bWI0
z>0#4ul`kN&8xd4*Dw|+;5z3Zl;5i+VtuO<#cEbt`ZG%jwdL+UewWcLfC#$pM2SPqJ
z?}idowt-h|>L0d&Kzfv+-S9Ps;a4FM-y48y`1W>az?b&2q;qzF182Mj>AX5@dy4U7
zo!+ffy$0I}zHWdroc{vMq`xR^#8<l6N5fSl(9t{-qx{W&NGHn17h&NHeL+#-1NZkG
zI|%HjQ;r?vDy#6Z`T9gUyw;#tuW`TA(P+qpY-dw$+~g|L)o+6;8kDC}^rynkhdz#e
WYRRqgZ5bwienE0Qv2lFGrT+m}_Aj~s

diff --git a/Server_Install_Pack/sc/battleye/createvehicle.txt b/Server_Install_Pack/sc/battleye/createvehicle.txt
index ad2aa766..ceed5d65 100644
--- a/Server_Install_Pack/sc/battleye/createvehicle.txt
+++ b/Server_Install_Pack/sc/battleye/createvehicle.txt
@@ -1,3 +1,3 @@
-5 "" !="I_UAV_01_F" !="(I|B|O)_UAV_AI" !"_EPOCH" !="B_65x39_Minigun_Caseless_Red_splash" !="B_762x51_Minigun_Tracer_Yellow_splash" !="B_(Swing|Stick)" !"^SmokeShell" !"^G_40mm_" !"^F_40mm_" !"Sub_F_" !"^F_Signal_" !="mini_Grenade" !="GrenadeHand" !="LaserTarget(C|W|E)" !"^Chemlight_" !="(ClaymoreDirectionalMine|DemoCharge|SatchelCharge)_Remote_Ammo" !="SLAMDirectionalMine_Wire_Ammo"  !="(CMflare_Chaff|Sapper_Charge|SapperB_Charge|ATMine_Range)_Ammo" !="APERS(TripMine_Wire|BoundingMine_Range|Mine_Range)_Ammo" !="Epoch_(Sapper|SapperB|Cloak)_F" !="GreatWhite_F" !="groundWeaponHolder" !="WeaponHolderSimulated" !="Epoch_(Male|Female)_F" !"Supply[0-9]" !"Steerable_Parachute_F" !="Epoch_Female_CamoRed_F" !="Land_Cages_F" !="(O|I|B)_UAV_01_backpack_F" !="I_(helipilot|helicrew)_F"
+5 "" !="I_UAV_01_F" !="(I|B|O)_UAV_AI" !"_EPOCH" !="B_65x39_Minigun_Caseless_Red_splash" !="B_762x51_Minigun_Tracer_Yellow_splash" !="B_(Swing|Stick)" !"^SmokeShell" !"^G_40mm_" !"^F_40mm_" !"Sub_F_" !"^F_Signal_" !="mini_Grenade" !="GrenadeHand" !="LaserTarget(C|W|E)" !"^Chemlight_" !="(ClaymoreDirectionalMine|DemoCharge|SatchelCharge)_Remote_Ammo" !="SLAMDirectionalMine_Wire_Ammo"  !="(CMflare_Chaff|Sapper_Charge|SapperB_Charge|ATMine_Range)_Ammo" !="APERS(TripMine_Wire|BoundingMine_Range|Mine_Range)_Ammo" !="Epoch_(Sapper|SapperB|Cloak)_F" !="GreatWhite_F" !="groundWeaponHolder" !="WeaponHolderSimulated" !="Epoch_(Male|Female)_F" !"Supply[0-9]" !"Steerable_Parachute_F" !="Epoch_Female_CamoRed_F" !="Land_Cages_F" !="(O|I|B)_UAV_01_backpack_F" !="I_(helipilot|helicrew)_F" !="#smokesource"
 5 "_EPOCH" !="(SapperHead|Jack|SolarGen)_SIM_EPOCH" !="Wood(Floor|LargeWall|Stairs|Ramp|Foundation|Ladder|Tower)_EPOCH" !="(Tipi|Workbench|StorageShelf|CinderWallHalf|Foundation|Wood(Floor|LargeWall|Stairs|Ramp|Foundation|Ladder|Tower))_Ghost_EPOCH" !="(Tipi|StorageShelf|Safe|LockBox|FirePlace|FirePlaceOn|PlotPole|SolarGen|Jack|Freezer|Tarp|CinderWallHalf|Bobber)_EPOCH" !="I_(Soldier[1-3]|Soldier)_EPOCH" !="(Bed|locker|Filing|Chair|ChairRed|wardrobe|cooker|Couch|Table|Pelican|Fridge|Shelf|ToolRack|Shoebox|Bunk|Rabbit|Cabinet)_EPOCH"  !="(Sheep|Goat|Snake|Snake2|Hen|Cock|Fin|Alsatian)_random_EPOCH" !="(Safe|Workbench|LockBox|CinderWall|CinderWallGarage|CinderWallHalf|PlotPole|Tipi|StorageShelf|Fireplace)_SIM_EPOCH" !="Wood(Floor|LargeWall|LargeWallCor|LargeWallDoor|LargeWallDoorL|LargeWallDoorway|Stairs|Stairs2|Ramp|Ladder|Tower)_SIM_EPOCH" !="(WoodFoundation|Foundation)_EPOCH" !="WoodWall[1-4](_SIM|_Ghost|)_EPOCH"
 5 SeaGull
diff --git a/Sources/epoch_server/compile/epoch_bases/EPOCH_server_saveBuilding.sqf b/Sources/epoch_server/compile/epoch_bases/EPOCH_server_saveBuilding.sqf
index ff96ee45..a03b1340 100644
--- a/Sources/epoch_server/compile/epoch_bases/EPOCH_server_saveBuilding.sqf
+++ b/Sources/epoch_server/compile/epoch_bases/EPOCH_server_saveBuilding.sqf
@@ -91,7 +91,7 @@ if (isText _config) then {
 
 					if (!isNull _newVehicle) then {
 
-						diag_log format["building lockbox !isnull %1", _newVehicle];
+						//diag_log format["building lockbox !isnull %1", _newVehicle];
 
 						if !(EPOCH_StorageSlots isEqualTo []) then {
 
diff --git a/Sources/epoch_server/compile/epoch_server/EPOCH_localCleanup.sqf b/Sources/epoch_server/compile/epoch_server/EPOCH_localCleanup.sqf
index 92f2c599..e13bc562 100644
--- a/Sources/epoch_server/compile/epoch_server/EPOCH_localCleanup.sqf
+++ b/Sources/epoch_server/compile/epoch_server/EPOCH_localCleanup.sqf
@@ -8,14 +8,16 @@ if (typename _this != "ARRAY") then {
 			if (_this select 1) then {
 				private "_unit";
 				_unit = _this select 0;
-				{
-					_unit removeAllMPEventHandlers _x;
-				}forEach ["mpkilled","mphit","mprespawn"];
-				{
-					_unit removeAllEventHandlers _x;
-				}forEach ["FiredNear","HandleDamage","Killed","Fired","GetOut","GetIn","Local"];
-				deleteVehicle _unit;
-				deleteGroup (group _unit);
+				if (!isNull _unit) then{
+					{
+						_unit removeAllMPEventHandlers _x;
+					}forEach["mpkilled", "mphit", "mprespawn"];
+					{
+						_unit removeAllEventHandlers _x;
+					}forEach["FiredNear", "HandleDamage", "Killed", "Fired", "GetOut", "GetIn", "Local"];
+					deleteVehicle _unit;
+					deleteGroup(group _unit);
+				};
 			};
 		}];
 	};
diff --git a/Sources/epoch_server/compile/epoch_traders/EPOCH_server_loadTraders.sqf b/Sources/epoch_server/compile/epoch_traders/EPOCH_server_loadTraders.sqf
index a0ef0934..ef5ca42e 100644
--- a/Sources/epoch_server/compile/epoch_traders/EPOCH_server_loadTraders.sqf
+++ b/Sources/epoch_server/compile/epoch_traders/EPOCH_server_loadTraders.sqf
@@ -61,12 +61,13 @@ for "_i" from 0 to _this do {
 			// count vehicles
 			{
 				_limit = ["CfgTraderLimits", _x, 100] call EPOCH_fnc_returnConfigEntryV2;
+				_currentStock = (_arr select 1) param[_forEachIndex, 0];
 				if (_limit == 0) then {
 					// mark for removal since limit is 0
 					_toBeRemoved pushBack _forEachIndex;
+					_currentStock = 0;
 				} else {
 					// lower to limit current qty is over limit
-					_currentStock = (_arr select 1) select _forEachIndex;
 					if (_currentStock > _limit) then {
 						(_arr select 1) set [_forEachIndex,_limit];
 						_currentStock = _limit;
diff --git a/Sources/epoch_server/compile/epoch_trading/EPOCH_server_makeNPCTrade.sqf b/Sources/epoch_server/compile/epoch_trading/EPOCH_server_makeNPCTrade.sqf
index 83abc489..703a3ba8 100644
--- a/Sources/epoch_server/compile/epoch_trading/EPOCH_server_makeNPCTrade.sqf
+++ b/Sources/epoch_server/compile/epoch_trading/EPOCH_server_makeNPCTrade.sqf
@@ -15,6 +15,7 @@ _vehicleBought = false;
 
 _returnIn = [];
 _returnOut = [];
+_final_location = [];
 
 if (isNull _trader) exitWith{};
 if !([_plyr,_this select 4] call EPOCH_server_getPToken) exitWith {};
@@ -34,7 +35,7 @@ if (_slot != -1) then {
 	_current_crypto = _vars select _cIndex;
 	_current_cryptoRaw = _current_crypto;
 
-	// diag_log format["_current_crypto: %1 _cIndex:%2", _current_crypto, _cIndex];
+	//diag_log format["_current_crypto: %1 _cIndex:%2 %3", _current_crypto, _cIndex, _this];
 
 	// SELL ITEMS TO TRADER
 	_aiItems = _trader getVariable["AI_ITEMS", [[], []]];
@@ -113,14 +114,14 @@ if (_slot != -1) then {
 		_item = _x;
 		_itemQty = 1;
 
-		// diag_log format["_item: %1", _item];
+		 //diag_log format["_item: %1", _item];
 		if (isClass (_config >> _item)) then{
 			_itemWorth = getNumber(_config >> _item >> "price");
 			_itemTax = getNumber(_config >> _item >> "tax");
 			_tax = _itemWorth * (EPOCH_taxRate + _itemTax);
 			_itemWorth = ceil(_itemWorth + _tax);
 
-			// diag_log format["_itemWorth: %1", _itemWorth];
+			//diag_log format["_itemWorth: %1", _itemWorth];
 
 			_qtyIndex = _itemClasses find _item;
 			// add items to array
@@ -128,7 +129,7 @@ if (_slot != -1) then {
 
 				_currQty = _itemQtys select _qtyIndex;
 
-				// diag_log format["_currQty: %1 >= %2", _currQty, _itemQty];
+				//diag_log format["_currQty: %1 >= %2", _currQty, _itemQty];
 
 				if (_currQty >= _itemQty) then {
 
@@ -142,14 +143,30 @@ if (_slot != -1) then {
 									_position = getPosATL _plyr;
 
 									_helipad = nearestObjects[_position, ["Land_HelipadEmpty_F", "Land_HelipadCircle_F"], 100];
+									_helipads = [];
 									_smoke = nearestObject[_position, "SmokeShell"];
 									if (!isNull _smoke) then {
 										_helipad pushBack _smoke;
 									};
 
+									// water check 
+									if (_item isKindOf "Ship") then {
+										{
+											if (surfaceIsWater (getposATL _x)) then {
+												_helipads pushBack _x;
+											}
+										} forEach _helipad;
+									} else {
+										{
+											if !(surfaceIsWater (getposATL _x)) then {
+												_helipads pushBack _x;
+											}
+										} forEach _helipad;
+									};
+
 									// diag_log format["DEBUG: helipad: %1", _helipad];
 
-									if !(_helipad isEqualTo[]) then {
+									if !(_helipads isEqualTo[]) then {
 
 										_foundSmoke = false;
 										{
@@ -168,9 +185,9 @@ if (_slot != -1) then {
 												};
 											};
 											if (_foundSmoke) exitWith {};
-										} forEach _helipad;
+										} forEach _helipads;
 										if !(_foundSmoke) then {
-											_position = getPosATL (_helipad select 0);
+											_position = getPosATL (_helipads select 0);
 										};
 									} else {
 										_tmpposition = [];
@@ -181,6 +198,10 @@ if (_slot != -1) then {
 											_tmpposition = [_position, 20, 120, 20, 0, 2000, 0] call BIS_fnc_findSafePos;
 										};
 										if ((count _tmpposition) == 2) then {
+											_tmpposition set [2, 0];
+											if (surfaceIsWater _tmpposition) then {
+												_tmpposition = ATLtoASL _tmpposition;
+											};
 											_position = _tmpposition;
 										};
 									};
@@ -204,7 +225,11 @@ if (_slot != -1) then {
 									};
 
 									_vehObj = [_item,_position,random 360,true,_vehslot,_lockOwner,"NONE",false] call EPOCH_fnc_spawn_vehicle;
-
+									_final_location = getPosATL _vehObj;
+									
+									_group = group _plyr;
+									_wp = _group addWaypoint [_final_location, 0];
+									deleteWaypoint [_group, 0];
 
 									_returnOut pushBack _item;
 
@@ -212,6 +237,8 @@ if (_slot != -1) then {
 									_tradeTotal = _tradeTotal - _itemWorth;
 									_current_crypto = _current_crypto - _itemWorth;
 									_tradeQtyTotal = _tradeQtyTotal + _itemQty;
+								} else {
+									diag_log "DEBUG: no slots found to spawn vehicle";
 								};
 							};
 						} else {
diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_storage.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_storage.sqf
index 45a05357..787d1674 100644
--- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_storage.sqf
+++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_storage.sqf
@@ -31,7 +31,7 @@ for "_i" from 1 to _this do {
 
 			_worldspace = _arr select 1;
 			_wsCount = count _worldspace;
-			diag_log format ["DEBUG: _wsCount %1 _worldspace %2", _wsCount, _worldspace];
+			//diag_log format ["DEBUG: _wsCount %1 _worldspace %2", _wsCount, _worldspace];
 
 			// new worldspace format
 			if (_wsCount == 3) then {
@@ -94,7 +94,7 @@ for "_i" from 1 to _this do {
 
 			// missionNamespace setVariable [format ["EPOCH_STORAGE_%1", _i], _vehicle];
 
-			diag_log format ["STORAGE: created storage %1 at %2", _class, _location];
+			// diag_log format ["STORAGE: created storage %1 at %2", _class, _location];
 
 			_vehicle call EPOCH_server_storageInit;
 
diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf
index dabf1199..9161472b 100644
--- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf
+++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf
@@ -248,7 +248,6 @@ if (_immuneVehicleSpawn) then{
 
 addToRemainsCollector _allVehicles;
 
-diag_log format ["VEH SPAWN TIMER %1", diag_tickTime - _diag];
-// diag_log (EPOCH_VehicleSlots);
+diag_log format ["VEH SPAWN TIMER %1, LOADED 2% VEHICLES", diag_tickTime - _diag, count _allVehicles];
 
 true
diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_save_storage.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_save_storage.sqf
index 588a0d3a..67bb62e5 100644
--- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_save_storage.sqf
+++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_save_storage.sqf
@@ -67,7 +67,7 @@ if (!isNull _this) then {
 		["Storage", _vehHiveKey, EPOCH_expiresBuilding, _VAL] call EPOCH_fnc_server_hiveSETEX;
 		//["Storage", _vehHiveKey, _VAL] call EPOCH_fnc_server_hiveSET;
 
-		diag_log format["STORAGE: saved to hive %1 Pos %2 Owners %3 Parent %4 Locked %5", _class, _worldspace, _storageOwners, _storageParent, _locked];
+		diag_log format["STORAGE: saved to hive %1 Pos %2 Owners %3 Locked %4", _class, _worldspace, _storageOwners, _locked];
 	};
 
 };
diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_lockStorage.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_lockStorage.sqf
index 9274994c..6ace542a 100644
--- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_lockStorage.sqf
+++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_lockStorage.sqf
@@ -36,7 +36,7 @@ if (getNumber(configFile >> "CfgVehicles" >> _type >> "isSecureStorage") == 1) t
 	if (_type isKindOf "Secure_Storage_Proxy") then {
 
 		_owners = _unit getVariable["STORAGE_OWNERS", []];
-		diag_log format["_owners2 %1", _owners];
+		//diag_log format["_owners2 %1", _owners];
 
 		// allow group members and owner access
 		if (_plyrGroup != "") then {
@@ -68,11 +68,11 @@ if (getNumber(configFile >> "CfgVehicles" >> _type >> "isSecureStorage") == 1) t
 	} else {
 
 		_weaponHolder = _unit getVariable["EPOCH_secStorParent", objNull];
-		diag_log format["DEBUG: SecStor _weaponHolder %1", _weaponHolder];
+		//diag_log format["DEBUG: SecStor _weaponHolder %1", _weaponHolder];
 
 		if (!isNull _weaponHolder) then {
 			_owners = _weaponHolder getVariable["STORAGE_OWNERS", []];
-			diag_log format["_owners %1", _owners];
+			//diag_log format["_owners %1", _owners];
 
 			// allow group members and owner access
 			if (_plyrGroup != "") then {
diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_packStorage.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_packStorage.sqf
index 6b1de866..6d44f5bd 100644
--- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_packStorage.sqf
+++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_packStorage.sqf
@@ -9,7 +9,7 @@ _class = typeOf _unit;
 if (_class isKindOf 'Constructions_lockedstatic_F') then{
 
 	_weaponHolder = _unit getVariable["EPOCH_secStorParent", objNull];
-	diag_log format["DEBUG: Pack _weaponHolder %1", _weaponHolder];
+	//diag_log format["DEBUG: Pack _weaponHolder %1", _weaponHolder];
 
 	if (!isNull _weaponHolder) then {
 		_owners = _weaponHolder getVariable["STORAGE_OWNERS", []];
diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicle.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicle.sqf
index 68180c8e..6dcd706d 100644
--- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicle.sqf
+++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicle.sqf
@@ -12,92 +12,99 @@ _lockOwner  =  param [5, ""];
 _can_collide = param [6, "CAN_COLLIDE"];
 _spawnLoot = param [7, false];
 
-
+//diag_log format["DEBUG: spawn_vehicle %1", _this];
 
 //place vehicle
 _vehObj = createVehicle[_vehClass, _position, [], 0, _can_collide];
-_vehObj call EPOCH_server_setVToken;
 
-// Set Direction
-if (typeName _direction == "ARRAY") then{
-  _vehObj setVectorDirAndUp _direction;
+if !(isNull _vehObj) then{
+
+	_vehObj call EPOCH_server_setVToken;
+
+	// Set Direction
+	if (typeName _direction == "ARRAY") then{
+	  _vehObj setVectorDirAndUp _direction;
+	} else {
+	  _vehObj setdir _direction;
+	};
+	// Set Position
+	_vehObj setposATL _position;
+
+	// Normalize vehicle inventory
+	clearWeaponCargoGlobal    _vehObj;
+	clearMagazineCargoGlobal  _vehObj;
+	clearBackpackCargoGlobal  _vehObj;
+	clearItemCargoGlobal	  _vehObj;
+
+	// Disable Termal Equipment
+	_vehObj disableTIEquipment true;
+
+	// Vehicle Lock
+	_vehObj lock _locked;
+
+	// randomize fuel TODO push min max to config
+	_vehObj setFuel ((random 1 max 0.1) min 0.9);
+
+	// get colors from config
+	_config = (configFile >> "CfgVehicles" >> _vehClass >> "availableColors");
+
+	if (isArray(_config)) then{
+
+	  _textureSelectionIndex = configFile >> "CfgVehicles" >> _vehClass >> "textureSelectionIndex";
+	  _selections = if (isArray(_textureSelectionIndex)) then{ getArray(_textureSelectionIndex) } else { [0] };
+	  _colors = getArray(_config);
+	  _textures = _colors select 0;
+	  _color = floor(random(count _textures));
+	  _count = (count _colors) - 1;
+	  {
+		if (_count >= _forEachIndex) then{
+		  _textures = _colors select _forEachIndex;
+		};
+		_vehObj setObjectTextureGlobal[_x, (_textures select _color)];
+	  } forEach _selections;
+	  _vehObj setVariable["VEHICLE_TEXTURE", _color];
+	};
+
+	// add random loots
+	if (_spawnLoot) then {
+	  if (_vehClass isKindOf "Ship") then{
+		[_vehObj, "VehicleBoat"] call EPOCH_serverLootObject;
+	  } else {
+		[_vehObj, "Vehicle"] call EPOCH_serverLootObject;
+	  };
+	};
+
+	// Set slot used by vehicle
+	_vehObj setVariable["VEHICLE_SLOT", _slot, true];
+
+	// Lock vehicle for owner
+	if (_locked && _lockOwner != "") then {
+	  _vehLockHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot];
+	  ["VehicleLock", _vehLockHiveKey, EPOCH_vehicleLockTime, [_lockOwner]] call EPOCH_fnc_server_hiveSETEX;
+	} else {
+	  _vehLockHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot];
+	  ["VehicleLock", _vehLockHiveKey] call EPOCH_fnc_server_hiveDEL;
+	};
+
+	// SAVE VEHICLE
+	_vehObj call EPOCH_server_save_vehicle;
+
+	// Event Handlers
+	_vehObj call EPOCH_server_vehicleInit;
+
+	// Markers
+	if (EPOCH_DEBUG_VEH) then{
+	  _marker = createMarker[str(_position), _position];
+	  _marker setMarkerShape "ICON";
+	  _marker setMarkerType "mil_dot";
+	  _marker setMarkerText _vehClass;
+	};
+
+	// Add to A3 remains collector
+	addToRemainsCollector[_vehObj];
+
 } else {
-  _vehObj setdir _direction;
+	diag_log format["DEBUG: Failed to create vehicle: %1", _this];
 };
-// Set Position
-_vehObj setposATL _position;
-
-// Normalize vehicle inventory
-clearWeaponCargoGlobal    _vehObj;
-clearMagazineCargoGlobal  _vehObj;
-clearBackpackCargoGlobal  _vehObj;
-clearItemCargoGlobal	  _vehObj;
-
-// Disable Termal Equipment
-_vehObj disableTIEquipment true;
-
-// Vehicle Lock
-_vehObj lock _locked;
-
-// randomize fuel TODO push min max to config
-_vehObj setFuel ((random 1 max 0.1) min 0.9);
-
-// get colors from config
-_config = (configFile >> "CfgVehicles" >> _vehClass >> "availableColors");
-
-if (isArray(_config)) then{
-
-  _textureSelectionIndex = configFile >> "CfgVehicles" >> _vehClass >> "textureSelectionIndex";
-  _selections = if (isArray(_textureSelectionIndex)) then{ getArray(_textureSelectionIndex) } else { [0] };
-  _colors = getArray(_config);
-  _textures = _colors select 0;
-  _color = floor(random(count _textures));
-  _count = (count _colors) - 1;
-  {
-    if (_count >= _forEachIndex) then{
-      _textures = _colors select _forEachIndex;
-    };
-    _vehObj setObjectTextureGlobal[_x, (_textures select _color)];
-  } forEach _selections;
-  _vehObj setVariable["VEHICLE_TEXTURE", _color];
-};
-
-// add random loots
-if (_spawnLoot) then {
-  if (_vehClass isKindOf "Ship") then{
-    [_vehObj, "VehicleBoat"] call EPOCH_serverLootObject;
-  } else {
-    [_vehObj, "Vehicle"] call EPOCH_serverLootObject;
-  };
-};
-
-// Set slot used by vehicle
-_vehObj setVariable["VEHICLE_SLOT", _slot, true];
-
-// Lock vehicle for owner
-if (_locked && _lockOwner != "") then {
-  _vehLockHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot];
-  ["VehicleLock", _vehLockHiveKey, EPOCH_vehicleLockTime, [_lockOwner]] call EPOCH_fnc_server_hiveSETEX;
-} else {
-  _vehLockHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot];
-  ["VehicleLock", _vehLockHiveKey] call EPOCH_fnc_server_hiveDEL;
-};
-
-// SAVE VEHICLE
-_vehObj call EPOCH_server_save_vehicle;
-
-// Event Handlers
-_vehObj call EPOCH_server_vehicleInit;
-
-// Markers
-if (EPOCH_DEBUG_VEH) then{
-  _marker = createMarker[str(_position), _position];
-  _marker setMarkerShape "ICON";
-  _marker setMarkerType "mil_dot";
-  _marker setMarkerText _vehClass;
-};
-
-// Add to A3 remains collector
-addToRemainsCollector[_vehObj];
 
 _vehObj
diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicles.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicles.sqf
index 495aaaca..1c362a34 100644
--- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicles.sqf
+++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicles.sqf
@@ -24,17 +24,17 @@ if (_allowedVehiclesList isEqualTo []) exitWith {
 };
 
 _spawnPositionSizeDefaults = [
-      ["FlatAreaCity",1],
-      ["FlatAreaCitySmall",1],
-      ["NameCity",2],
-      ["NameVillage",1],
-      ["NameCityCapital",4],
-      ["Airport",5],
-			["NameLocal",2],
-			["StrongpointArea",1],
-			["VegetationBroadleaf",1],
-			["VegetationFir",1],
-			["ViewPoint",1]
+	["FlatAreaCity",1],
+	["FlatAreaCitySmall",1],
+	["NameCity",2],
+	["NameVillage",1],
+	["NameCityCapital",4],
+	["Airport",5],
+	["NameLocal",2],
+	["StrongpointArea",1],
+	["VegetationBroadleaf",1],
+	["VegetationFir",1],
+	["ViewPoint",1]
 ];
 _serverMapConfig = configFile >> "CfgEpoch" >> worldName;
 _spawnPositionSize = [_serverMapConfig, "vehicleSpawnTypes", _spawnPositionSizeDefaults] call EPOCH_fnc_returnConfigEntry;
@@ -61,93 +61,87 @@ _allCitysDync = [];
     };
 } forEach _allCitys;
 
-
 _position = [0,0,0];
 
+_spawnCount = (count EPOCH_VehicleSlots - EPOCH_storedVehicleCount) - 1;
 
-{
-  if (count EPOCH_VehicleSlots <= EPOCH_storedVehicleCount) exitWith{};
+diag_log format["DEBUG: count EPOCH_VehicleSlots: %1 EPOCH_storedVehicleCount: %2 _spawnCount %3", (count EPOCH_VehicleSlots), EPOCH_storedVehicleCount, _spawnCount];
 
-  _vehCount = count _allowedVehiclesList;
-  if (_vehCount <= 0) exitWith{};
+for "_i" from 1 to _spawnCount do {
 
-  _vehClass = _allowedVehiclesList deleteAt(floor(random(_vehCount)));
-  if (isNil "_vehClass") exitWith{};
+	_slot = EPOCH_VehicleSlots deleteAt 0;
 
-  _direction = random 360;
-  _position = [0,0,0];
-  _getRandomPos = true;
+	_vehCount = count _allowedVehiclesList;
+	_vehClass = _allowedVehiclesList deleteAt(floor(random(_vehCount)));
+	if (isNil "_vehClass") exitWith{diag_log "DEBUG: Failed to find vehicle class"};
 
+	_direction = random 360;
+	_position = [0,0,0];
+	_getRandomPos = true;
 
-  _preferedPos = getArray(configFile >> "CfgEpoch" >> worldname >> "whitelistedVehiclePos" >> _vehClass);
-  if !(_preferedPos isEqualTo []) then{
-    _newPosition = _preferedPos select(floor(random(count _preferedPos)));
-    if ((nearestObjects[(_newPosition select 0), ["LandVehicle", "Ship", "Air", "Tank"], 50]) isEqualTo []) then{
-      _position = _newPosition select 0;
-      _direction = _newPosition select 1;
-      _getRandomPos = false;
-    };
-  };
-
-
-  if (_getRandomPos) then{
-    _isShip = _vehClass isKindOf "Ship";
-    if (_isShip || (_vehClass isKindOf "Air")) then{
-      if (_isShip) then{
-        _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 4000, 1] call BIS_fnc_findSafePos;
-        _position = [_position, 0, 100, 10, 2, 4000, 0] call BIS_fnc_findSafePos;
-      } else {
-        _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 1000, 0] call BIS_fnc_findSafePos;
-      };
-    } else {
-
-      if (_allCitysDync isEqualTo []) then {
-        _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 1000, 0] call BIS_fnc_findSafePos;
-      } else {
-        _selectedCity = _allCitysDync deleteAt (floor random(count _allCitysDync));
-        _cityPos = getArray(_selectedCity >> "position");
-        _range = getNumber(_selectedCity >> "radiusA") * 1.3;
-
-        _roads = _cityPos nearRoads _range;
-				if !(_roads isEqualTo []) then {
-					_road = _roads select(floor random(count _roads));
-	        _position = getPosATL _road;
-	        _position deleteAt 2;
-				};
-      };
-    };
-  };
-
-  if ((count _position == 2 && _getRandomPos) || !_getRandomPos) then{
-
-
-			_collide = "CAN_COLLIDE";
-			if (_getRandomPos) then{
-				_collide = "NONE";
-				_position set[2, 0];
-				if (surfaceIsWater _position) then{
-					_position = ASLToATL _position;
-				};
-			};
-
-			_vehObj = [_vehClass,_position,_direction,true,_x,"",_collide,true] call EPOCH_fnc_spawn_vehicle;
-
-
-			if (EPOCH_DEBUG_VEH) then {
-				_marker = createMarker [str(_position) , _position];
-				_marker setMarkerShape "ICON";
-				_marker setMarkerType "mil_dot";
-				_marker setMarkerText _vehClass;
-				_marker setMarkerColor "ColorBlue";
-			};
-
-
-			EPOCH_VehicleSlots set[_forEachIndex, "REM"];
+	_preferedPos = getArray(configFile >> "CfgEpoch" >> worldname >> "whitelistedVehiclePos" >> _vehClass);
+	if !(_preferedPos isEqualTo []) then{
+		_newPosition = _preferedPos select(floor(random(count _preferedPos)));
+		if ((nearestObjects[(_newPosition select 0), ["LandVehicle", "Ship", "Air", "Tank"], 50]) isEqualTo []) then{
+			_position = _newPosition select 0;
+			_direction = _newPosition select 1;
+			_getRandomPos = false;
+		};
 	};
 
-} forEach EPOCH_VehicleSlots;
 
-EPOCH_VehicleSlots = EPOCH_VehicleSlots - ["REM"];
+	if (_getRandomPos) then{
+		_isShip = _vehClass isKindOf "Ship";
+		if (_isShip || (_vehClass isKindOf "Air")) then{
+			if (_isShip) then{
+			_position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 4000, 1] call BIS_fnc_findSafePos;
+			_position = [_position, 0, 100, 10, 2, 4000, 0] call BIS_fnc_findSafePos;
+			} else {
+			_position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 1000, 0] call BIS_fnc_findSafePos;
+			};
+		} else {
+
+			if (_allCitysDync isEqualTo []) then {
+				_position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 1000, 0] call BIS_fnc_findSafePos;
+			} else {
+				_selectedCity = _allCitysDync deleteAt (floor random(count _allCitysDync));
+				_cityPos = getArray(_selectedCity >> "position");
+				_range = getNumber(_selectedCity >> "radiusA") * 1.3;
+
+				_roads = _cityPos nearRoads _range;
+				if !(_roads isEqualTo []) then {
+					_road = _roads select(floor random(count _roads));
+					_position = getPosATL _road;
+					_position deleteAt 2;
+				};
+			};
+		};
+	};
+
+	if ((count _position == 2 && _getRandomPos) || !_getRandomPos) then{
+
+		_collide = "CAN_COLLIDE";
+		if (_getRandomPos) then{
+			_collide = "NONE";
+			_position set[2, 0];
+			if (surfaceIsWater _position) then{
+				_position = ASLToATL _position;
+			};
+		};
+
+		_vehObj = [_vehClass,_position,_direction,true,_slot,"",_collide,true] call EPOCH_fnc_spawn_vehicle;
+
+		if (EPOCH_DEBUG_VEH) then {
+			_marker = createMarker [str(_position) , _position];
+			_marker setMarkerShape "ICON";
+			_marker setMarkerType "mil_dot";
+			_marker setMarkerText _vehClass;
+			_marker setMarkerColor "ColorBlue";
+		};
+
+	};
+
+};
 
 EPOCH_VehicleSlotCount = count EPOCH_VehicleSlots;
 publicVariable "EPOCH_VehicleSlotCount";
diff --git a/Sources/epoch_server/system/server_monitor.fsm b/Sources/epoch_server/system/server_monitor.fsm
index 812de4dc..5ffa508c 100644
--- a/Sources/epoch_server/system/server_monitor.fsm
+++ b/Sources/epoch_server/system/server_monitor.fsm
@@ -126,7 +126,7 @@ class FSM
        "			_list = _this nearEntities[[""Epoch_Male_F"", ""Epoch_Female_F"", ""LandVehicle"", ""Ship"", ""Air"", ""Tank""], 45];" \n
        "			if ({ isPlayer _x }count _list == 0) then {" \n
        "				_this setVariable [""LAST_CHECK"",nil];" \n
-       "				diag_log format[""DEBUG: _cleanIT del %1"", _this];" \n
+       "				//diag_log format[""DEBUG: _cleanIT del %1"", _this];" \n
        "				deleteVehicle _this;" \n
        "" \n
        "			};" \n
@@ -149,7 +149,7 @@ class FSM
        "					deleteVehicle _x;" \n
        "				}forEach nearestObjects[_this, [""WeaponHolder""], 2];" \n
        "				_this setVariable [""LAST_CHECK"",nil];" \n
-       "								diag_log format[""DEBUG: _cleanIT2 del %1"", _this];" \n
+       "				//diag_log format[""DEBUG: _cleanIT2 del %1"", _this];" \n
        "				deleteVehicle _this;" \n
        "				_removed = true;" \n
        "			};" \n
@@ -328,7 +328,7 @@ class FSM
            "							_activeVehicles pushBack _x;" \n
            "						};" \n
            "					} else {" \n
-		   "						diag_log format[""DEBUG: vtoken del %1"",_x];" \n
+		   "						//diag_log format[""DEBUG: vtoken del %1"",_x];" \n
            "						deleteVehicle _x;" \n
            "					};" \n
            "				};" \n