@jtff/miztemplate-lib 3.1.1 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- env.info('*** MOOSE GITHUB Commit Hash ID: 2023-08-22T08:25:26.0000000Z-3e36e5f2b2d9e2665a04d14d683be2a517a71d48 ***')
1
+ env.info('*** MOOSE GITHUB Commit Hash ID: 2023-09-01T06:52:46.0000000Z-d7b87b63d8b9ec7fe737bc2aef7bd73817e7cea4 ***')
2
2
  env.info('*** MOOSE STATIC INCLUDE START *** ')
3
3
  ENUMS={}
4
4
  ENUMS.ROE={
@@ -30928,6 +30928,81 @@ self:E(self.lid..string.format("ERROR: Unknown liquid type %s",tostring(Type)))
30928
30928
  end
30929
30929
  return name
30930
30930
  end
30931
+ function STORAGE:AddAmount(Type,Amount)
30932
+ if type(Type)=="number"then
30933
+ self:AddLiquid(Type,Amount)
30934
+ else
30935
+ self:AddItem(Type,Amount)
30936
+ end
30937
+ return self
30938
+ end
30939
+ function STORAGE:RemoveAmount(Type,Amount)
30940
+ if type(Type)=="number"then
30941
+ self:RemoveLiquid(Type,Amount)
30942
+ else
30943
+ self:RemoveItem(Type,Amount)
30944
+ end
30945
+ return self
30946
+ end
30947
+ function STORAGE:SetAmount(Type,Amount)
30948
+ if type(Type)=="number"then
30949
+ self:SetLiquid(Type,Amount)
30950
+ else
30951
+ self:SetItem(Type,Amount)
30952
+ end
30953
+ return self
30954
+ end
30955
+ function STORAGE:GetAmount(Type)
30956
+ local N=0
30957
+ if type(Type)=="number"then
30958
+ N=self:GetLiquidAmount(Type)
30959
+ else
30960
+ N=self:GetItemAmount(Type)
30961
+ end
30962
+ return N
30963
+ end
30964
+ function STORAGE:IsUnlimited(Type)
30965
+ local N=self:GetAmount(Type)
30966
+ local unlimited=false
30967
+ if N>0 then
30968
+ self:RemoveAmount(Type,1)
30969
+ local n=self:GetAmount(Type)
30970
+ unlimited=n==N
30971
+ if not unlimited then
30972
+ self:AddAmount(Type,1)
30973
+ end
30974
+ self:I(self.lid..string.format("Type=%s: unlimited=%s (N=%d n=%d)",tostring(Type),tostring(unlimited),N,n))
30975
+ end
30976
+ return unlimited
30977
+ end
30978
+ function STORAGE:IsLimited(Type)
30979
+ local limited=not self:IsUnlimited(Type)
30980
+ return limited
30981
+ end
30982
+ function STORAGE:IsUnlimitedAircraft()
30983
+ local unlimited=self:IsUnlimited("A-10C")
30984
+ return unlimited
30985
+ end
30986
+ function STORAGE:IsUnlimitedLiquids()
30987
+ local unlimited=self:IsUnlimited(STORAGE.Liquid.DIESEL)
30988
+ return unlimited
30989
+ end
30990
+ function STORAGE:IsUnlimitedWeapons()
30991
+ local unlimited=self:IsUnlimited(ENUMS.Storage.weapons.bombs.Mk_82)
30992
+ return unlimited
30993
+ end
30994
+ function STORAGE:IsLimitedAircraft()
30995
+ local limited=self:IsLimited("A-10C")
30996
+ return limited
30997
+ end
30998
+ function STORAGE:IsLimitedLiquids()
30999
+ local limited=self:IsLimited(STORAGE.Liquid.DIESEL)
31000
+ return limited
31001
+ end
31002
+ function STORAGE:IsLimitedWeapons()
31003
+ local limited=self:IsLimited(ENUMS.Storage.weapons.bombs.Mk_82)
31004
+ return limited
31005
+ end
30931
31006
  function STORAGE:GetInventory(Item)
30932
31007
  local inventory=self.warehouse:getInventory(Item)
30933
31008
  return inventory.aircraft,inventory.liquids,inventory.weapon
@@ -41088,9 +41163,11 @@ MANTIS.SamDataCH={
41088
41163
  ["PGZ-09 CH"]={Range=4,Blindspot=0,Height=3,Type="Short",Radar="CH_PGZ09"},
41089
41164
  ["S350-9M100 CH"]={Range=15,Blindspot=1.5,Height=8,Type="Short",Radar="CH_S350_50P6_9M100"},
41090
41165
  ["S350-9M96D CH"]={Range=150,Blindspot=2.5,Height=30,Type="Long",Radar="CH_S350_50P6_9M96D"},
41166
+ ["LAV-AD CH"]={Range=8,Blindspot=0.2,Height=4.8,Type="Short",Radar="CH_LAVAD"},
41167
+ ["HQ-22 CH"]={Range=170,Blindspot=5,Height=27,Type="Long",Radar="CH_HQ22_LN"},
41091
41168
  }
41092
41169
  do
41093
- function MANTIS:New(name,samprefix,ewrprefix,hq,coalition,dynamic,awacs,EmOnOff,Padding)
41170
+ function MANTIS:New(name,samprefix,ewrprefix,hq,coalition,dynamic,awacs,EmOnOff,Padding,Zones)
41094
41171
  self.SAM_Templates_Prefix=samprefix or"Red SAM"
41095
41172
  self.EWR_Templates_Prefix=ewrprefix or"Red EWR"
41096
41173
  self.HQ_Template_CC=hq or nil
@@ -41140,6 +41217,7 @@ self.maxshortrange=2
41140
41217
  self.maxclassic=6
41141
41218
  self.autoshorad=true
41142
41219
  self.ShoradGroupSet=SET_GROUP:New()
41220
+ self.FilterZones=Zones
41143
41221
  self.UseEmOnOff=true
41144
41222
  if EmOnOff==false then
41145
41223
  self.UseEmOnOff=false
@@ -41173,17 +41251,22 @@ if self.advAwacs then
41173
41251
  table.insert(self.ewr_templates,awacs)
41174
41252
  end
41175
41253
  self:T({self.ewr_templates})
41254
+ self.SAM_Group=SET_GROUP:New():FilterPrefixes(self.SAM_Templates_Prefix):FilterCoalitions(self.Coalition)
41255
+ self.EWR_Group=SET_GROUP:New():FilterPrefixes(self.ewr_templates):FilterCoalitions(self.Coalition)
41256
+ if self.FilterZones then
41257
+ self.SAM_Group:FilterZones(self.FilterZones)
41258
+ end
41176
41259
  if self.dynamic then
41177
- self.SAM_Group=SET_GROUP:New():FilterPrefixes(self.SAM_Templates_Prefix):FilterCoalitions(self.Coalition):FilterStart()
41178
- self.EWR_Group=SET_GROUP:New():FilterPrefixes(self.ewr_templates):FilterCoalitions(self.Coalition):FilterStart()
41260
+ self.SAM_Group:FilterStart()
41261
+ self.EWR_Group:FilterStart()
41179
41262
  else
41180
- self.SAM_Group=SET_GROUP:New():FilterPrefixes(self.SAM_Templates_Prefix):FilterCoalitions(self.Coalition):FilterOnce()
41181
- self.EWR_Group=SET_GROUP:New():FilterPrefixes(self.ewr_templates):FilterCoalitions(self.Coalition):FilterOnce()
41263
+ self.SAM_Group:FilterOnce()
41264
+ self.EWR_Group:FilterOnce()
41182
41265
  end
41183
41266
  if self.HQ_Template_CC then
41184
41267
  self.HQ_CC=GROUP:FindByName(self.HQ_Template_CC)
41185
41268
  end
41186
- self.version="0.8.11"
41269
+ self.version="0.8.14"
41187
41270
  self:I(string.format("***** Starting MANTIS Version %s *****",self.version))
41188
41271
  self:SetStartState("Stopped")
41189
41272
  self:AddTransition("Stopped","Start","Running")
@@ -66871,7 +66954,8 @@ return mission
66871
66954
  end
66872
66955
  function AUFTRAG:NewCAP(ZoneCAP,Altitude,Speed,Coordinate,Heading,Leg,TargetTypes)
66873
66956
  TargetTypes=UTILS.EnsureTable(TargetTypes,true)
66874
- local mission=AUFTRAG:NewORBIT(Coordinate or ZoneCAP:GetCoordinate(),Altitude or 10000,Speed or 350,Heading,Leg)
66957
+ Altitude=Altitude or 10000
66958
+ local mission=AUFTRAG:NewORBIT(Coordinate or ZoneCAP:GetCoordinate(),Altitude,Speed or 350,Heading,Leg)
66875
66959
  mission.type=AUFTRAG.Type.CAP
66876
66960
  mission:_SetLogID()
66877
66961
  mission.engageZone=ZoneCAP
@@ -85215,6 +85299,20 @@ element.fuelrel=fuel
85215
85299
  end
85216
85300
  self:T(self.lid..string.format("Travelled ds=%.1f km dt=%.1f s ==> v=%.1f knots. Fuel left for %.1f min",self.traveldist/1000,dt,UTILS.MpsToKnots(v),TmaxFuel/60))
85217
85301
  end
85302
+ if false then
85303
+ for _,_element in pairs(self.elements)do
85304
+ local element=_element
85305
+ local unit=element.unit
85306
+ if unit and unit:IsAlive()then
85307
+ local vec3=unit:GetVec3()
85308
+ if vec3 and element.pos then
85309
+ local id=UTILS.GetMarkID()
85310
+ trigger.action.lineToAll(-1,id,vec3,element.pos,{1,1,1,0.5},1)
85311
+ end
85312
+ element.pos=vec3
85313
+ end
85314
+ end
85315
+ end
85218
85316
  if alive and self.group:IsAirborne(true)then
85219
85317
  local fuelmin=self:GetFuelMin()
85220
85318
  self:T2(self.lid..string.format("Fuel state=%d",fuelmin))
@@ -91959,18 +92057,20 @@ end
91959
92057
  end
91960
92058
  return self
91961
92059
  end
91962
- function OPSGROUP:SelfDestruction(Delay,ExplosionPower)
92060
+ function OPSGROUP:SelfDestruction(Delay,ExplosionPower,ElementName)
91963
92061
  if Delay and Delay>0 then
91964
- self:ScheduleOnce(Delay,OPSGROUP.SelfDestruction,self,0,ExplosionPower)
92062
+ self:ScheduleOnce(Delay,OPSGROUP.SelfDestruction,self,0,ExplosionPower,ElementName)
91965
92063
  else
91966
92064
  for i,_element in pairs(self.elements)do
91967
92065
  local element=_element
92066
+ if ElementName==nil or ElementName==element.name then
91968
92067
  local unit=element.unit
91969
92068
  if unit and unit:IsAlive()then
91970
92069
  unit:Explode(ExplosionPower or 100)
91971
92070
  end
91972
92071
  end
91973
92072
  end
92073
+ end
91974
92074
  return self
91975
92075
  end
91976
92076
  function OPSGROUP:SetSRS(PathToSRS,Gender,Culture,Voice,Port,PathToGoogleKey,Label,Volume)
@@ -93533,10 +93633,10 @@ end
93533
93633
  if self.isFlightgroup then
93534
93634
  if Mission.prohibitABExecute==true then
93535
93635
  self:SetProhibitAfterburner()
93536
- self:I("Set prohibit AB")
93636
+ self:T(self.lid.."Set prohibit AB")
93537
93637
  elseif Mission.prohibitABExecute==false then
93538
93638
  self:SetAllowAfterburner()
93539
- self:T2("Set allow AB")
93639
+ self:T2(self.lid.."Set allow AB")
93540
93640
  end
93541
93641
  end
93542
93642
  end
@@ -94452,18 +94552,30 @@ end
94452
94552
  end
94453
94553
  end
94454
94554
  for i=#Element.cargoBay,1,-1 do
94455
- local cargo=Element.cargoBay[i]
94456
- self:_DelCargobay(cargo.group)
94457
- if cargo.group and not(cargo.group:IsDead()or cargo.group:IsStopped())then
94458
- cargo.group:_RemoveMyCarrier()
94459
- if cargo.reserved then
94460
- cargo.group:_NewCargoStatus(OPSGROUP.CargoStatus.NOTCARGO)
94461
- else
94462
- for _,cargoelement in pairs(cargo.group.elements)do
94555
+ local mycargo=Element.cargoBay[i]
94556
+ if mycargo.group then
94557
+ self:_DelCargobay(mycargo.group)
94558
+ if mycargo.group and not(mycargo.group:IsDead()or mycargo.group:IsStopped())then
94559
+ mycargo.group:_RemoveMyCarrier()
94560
+ if mycargo.reserved then
94561
+ mycargo.group:_NewCargoStatus(OPSGROUP.CargoStatus.NOTCARGO)
94562
+ else
94563
+ for _,cargoelement in pairs(mycargo.group.elements)do
94463
94564
  self:T2(self.lid.."Cargo element dead "..cargoelement.name)
94464
- cargo.group:ElementDead(cargoelement)
94565
+ mycargo.group:ElementDead(cargoelement)
94566
+ end
94567
+ end
94568
+ end
94569
+ else
94570
+ if self.cargoTZC then
94571
+ for _,_cargo in pairs(self.cargoTZC.Cargos)do
94572
+ local cargo=_cargo
94573
+ if cargo.uid==mycargo.cargoUID then
94574
+ cargo.storage.cargoLost=cargo.storage.cargoLost+mycargo.storageAmount
94575
+ end
94465
94576
  end
94466
94577
  end
94578
+ self:_DelCargobayElement(Element,mycargo)
94467
94579
  end
94468
94580
  end
94469
94581
  end
@@ -94691,7 +94803,12 @@ for _,_element in pairs(self.elements)do
94691
94803
  local element=_element
94692
94804
  for _,_cargo in pairs(element.cargoBay)do
94693
94805
  local cargo=_cargo
94806
+ if cargo.group then
94694
94807
  text=text..string.format("\n- %s in carrier %s, reserved=%s",tostring(cargo.group:GetName()),tostring(element.name),tostring(cargo.reserved))
94808
+ else
94809
+ text=text..string.format("\n- storage %s=%d kg in carrier %s [UID=%s]",
94810
+ tostring(cargo.storageType),tostring(cargo.storageAmount*cargo.storageWeight),tostring(element.name),tostring(cargo.cargoUID))
94811
+ end
94695
94812
  end
94696
94813
  end
94697
94814
  if text==""then
@@ -94710,6 +94827,7 @@ local deployname=deployzone and deployzone:GetName()or"unknown"
94710
94827
  text=text..string.format("\n[%d] UID=%d Status=%s: %s --> %s",i,transport.uid,transport:GetState(),pickupname,deployname)
94711
94828
  for j,_cargo in pairs(transport:GetCargos())do
94712
94829
  local cargo=_cargo
94830
+ if cargo.type==OPSTRANSPORT.CargoType.OPSGROUP then
94713
94831
  local state=cargo.opsgroup:GetState()
94714
94832
  local status=cargo.opsgroup.cargoStatus
94715
94833
  local name=cargo.opsgroup.groupname
@@ -94717,6 +94835,8 @@ local carriergroup,carrierelement,reserved=cargo.opsgroup:_GetMyCarrier()
94717
94835
  local carrierGroupname=carriergroup and carriergroup.groupname or"none"
94718
94836
  local carrierElementname=carrierelement and carrierelement.name or"none"
94719
94837
  text=text..string.format("\n (%d) %s [%s]: %s, carrier=%s(%s), delivered=%s",j,name,state,status,carrierGroupname,carrierElementname,tostring(cargo.delivered))
94838
+ else
94839
+ end
94720
94840
  end
94721
94841
  end
94722
94842
  if text~=""then
@@ -94758,26 +94878,32 @@ self:T(self.lid..string.format("Picking up at %s [TZC UID=%d] for %s sec...",sel
94758
94878
  elseif self:IsLoading()then
94759
94879
  self.Tloading=self.Tloading or Time
94760
94880
  local tloading=Time-self.Tloading
94761
- self:T(self.lid..string.format("Loading at %s [TZC UID=%d] for %s sec...",self.cargoTZC.PickupZone and self.cargoTZC.PickupZone:GetName()or"unknown",self.cargoTZC.uid,tloading))
94881
+ self:T(self.lid..string.format("Loading at %s [TZC UID=%d] for %.1f sec...",self.cargoTZC.PickupZone and self.cargoTZC.PickupZone:GetName()or"unknown",self.cargoTZC.uid,tloading))
94762
94882
  local boarding=false
94763
94883
  local gotcargo=false
94764
94884
  for _,_cargo in pairs(self.cargoTZC.Cargos)do
94765
94885
  local cargo=_cargo
94766
- if cargo.opsgroup:IsBoarding(self.groupname)then
94886
+ if cargo.type==OPSTRANSPORT.CargoType.OPSTRANPORT then
94887
+ if cargo.opsgroup and cargo.opsgroup:IsBoarding(self.groupname)then
94767
94888
  boarding=true
94768
94889
  end
94769
- if cargo.opsgroup:IsLoaded(self.groupname)then
94890
+ if cargo.opsgroup and cargo.opsgroup:IsLoaded(self.groupname)then
94770
94891
  gotcargo=true
94771
94892
  end
94893
+ else
94894
+ local mycargo=self:_GetMyCargoBayFromUID(cargo.uid)
94895
+ if mycargo and mycargo.storageAmount>0 then
94896
+ gotcargo=true
94897
+ end
94898
+ end
94772
94899
  end
94773
94900
  if gotcargo and self.cargoTransport:_CheckRequiredCargos(self.cargoTZC,self)and not boarding then
94774
- self:T(self.lid.."Boarding finished ==> Loaded")
94901
+ self:T(self.lid.."Boarding/loading finished ==> Loaded")
94902
+ self.Tloading=nil
94775
94903
  self:LoadingDone()
94776
94904
  else
94777
94905
  self:Loading()
94778
94906
  end
94779
- if not gotcargo and not boarding then
94780
- end
94781
94907
  elseif self:IsTransporting()then
94782
94908
  self.Ttransporting=self.Ttransporting or Time
94783
94909
  local ttransporting=Time-self.Ttransporting
@@ -94789,11 +94915,19 @@ self:T(self.lid.."Unloading ==> Checking if all cargo was delivered")
94789
94915
  local delivered=true
94790
94916
  for _,_cargo in pairs(self.cargoTZC.Cargos)do
94791
94917
  local cargo=_cargo
94918
+ if cargo.type==OPSTRANSPORT.CargoType.OPSGROUP then
94792
94919
  local carrierGroup=cargo.opsgroup:_GetMyCarrierGroup()
94793
94920
  if(carrierGroup and carrierGroup:GetName()==self:GetName())and not cargo.delivered then
94794
94921
  delivered=false
94795
94922
  break
94796
94923
  end
94924
+ else
94925
+ local mycargo=self:_GetMyCargoBayFromUID(cargo.uid)
94926
+ if mycargo and not cargo.delivered then
94927
+ delivered=false
94928
+ break
94929
+ end
94930
+ end
94797
94931
  end
94798
94932
  if delivered then
94799
94933
  self:T(self.lid.."Unloading finished ==> UnloadingDone")
@@ -94810,6 +94944,7 @@ local deployname=deployzone and deployzone:GetName()or"unknown"
94810
94944
  local text=string.format("Carrier [%s]: %s --> %s",self.carrierStatus,pickupname,deployname)
94811
94945
  for _,_cargo in pairs(self.cargoTransport:GetCargos(self.cargoTZC))do
94812
94946
  local cargo=_cargo
94947
+ if cargo.type==OPSTRANSPORT.CargoType.OPSGROUP then
94813
94948
  local name=cargo.opsgroup:GetName()
94814
94949
  local gstatus=cargo.opsgroup:GetState()
94815
94950
  local cstatus=cargo.opsgroup.cargoStatus
@@ -94818,6 +94953,8 @@ local carriergroup,carrierelement,reserved=cargo.opsgroup:_GetMyCarrier()
94818
94953
  local carrierGroupname=carriergroup and carriergroup.groupname or"none"
94819
94954
  local carrierElementname=carrierelement and carrierelement.name or"none"
94820
94955
  text=text..string.format("\n- %s (%.1f kg) [%s]: %s, carrier=%s (%s), delivered=%s",name,weight,gstatus,cstatus,carrierElementname,carrierGroupname,tostring(cargo.delivered))
94956
+ else
94957
+ end
94821
94958
  end
94822
94959
  self:I(self.lid..text)
94823
94960
  end
@@ -94854,6 +94991,44 @@ self:AddWeightCargo(CarrierElement.name,weight)
94854
94991
  end
94855
94992
  return self
94856
94993
  end
94994
+ function OPSGROUP:_AddCargobayStorage(CarrierElement,CargoUID,StorageType,StorageAmount,StorageWeight)
94995
+ local MyCargo=self:_CreateMyCargo(CargoUID,nil,StorageType,StorageAmount,StorageWeight)
94996
+ self:_AddMyCargoBay(MyCargo,CarrierElement)
94997
+ end
94998
+ function OPSGROUP:_CreateMyCargo(CargoUID,OpsGroup,StorageType,StorageAmount,StorageWeight)
94999
+ local cargo={}
95000
+ cargo.cargoUID=CargoUID
95001
+ cargo.group=OpsGroup
95002
+ cargo.storageType=StorageType
95003
+ cargo.storageAmount=StorageAmount
95004
+ cargo.storageWeight=StorageWeight
95005
+ cargo.reserved=false
95006
+ return cargo
95007
+ end
95008
+ function OPSGROUP:_AddMyCargoBay(MyCargo,CarrierElement)
95009
+ table.insert(CarrierElement.cargoBay,MyCargo)
95010
+ if not MyCargo.reserved then
95011
+ local weight=0
95012
+ if MyCargo.group then
95013
+ weight=MyCargo.group:GetWeightTotal()
95014
+ else
95015
+ weight=MyCargo.storageAmount*MyCargo.storageWeight
95016
+ end
95017
+ self:AddWeightCargo(CarrierElement.name,weight)
95018
+ end
95019
+ end
95020
+ function OPSGROUP:_GetMyCargoBayFromUID(uid)
95021
+ for _,_element in pairs(self.elements)do
95022
+ local element=_element
95023
+ for i,_mycargo in pairs(element.cargoBay)do
95024
+ local mycargo=_mycargo
95025
+ if mycargo.cargoUID and mycargo.cargoUID==uid then
95026
+ return mycargo,element,i
95027
+ end
95028
+ end
95029
+ end
95030
+ return nil,nil,nil
95031
+ end
94857
95032
  function OPSGROUP:GetCargoGroups(CarrierName)
94858
95033
  local cargos={}
94859
95034
  for _,_element in pairs(self.elements)do
@@ -94884,6 +95059,31 @@ end
94884
95059
  end
94885
95060
  return nil,nil,nil
94886
95061
  end
95062
+ function OPSGROUP:_GetCargobayElement(Element,CargoUID)
95063
+ self:T3({Element=Element,CargoUID=CargoUID})
95064
+ for i,_mycargo in pairs(Element.cargoBay)do
95065
+ local mycargo=_mycargo
95066
+ if mycargo.cargoUID and mycargo.cargoUID==CargoUID then
95067
+ return mycargo
95068
+ end
95069
+ end
95070
+ return nil
95071
+ end
95072
+ function OPSGROUP:_DelCargobayElement(Element,MyCargo)
95073
+ for i,_mycargo in pairs(Element.cargoBay)do
95074
+ local mycargo=_mycargo
95075
+ if mycargo.cargoUID and MyCargo.cargoUID and mycargo.cargoUID==MyCargo.cargoUID then
95076
+ if MyCargo.group then
95077
+ self:RedWeightCargo(Element.name,MyCargo.group:GetWeightTotal())
95078
+ else
95079
+ self:RedWeightCargo(Element.name,MyCargo.storageAmount*MyCargo.storageWeight)
95080
+ end
95081
+ table.remove(Element.cargoBay,i)
95082
+ return true
95083
+ end
95084
+ end
95085
+ return false
95086
+ end
94887
95087
  function OPSGROUP:_DelCargobay(CargoGroup)
94888
95088
  if self.cargoBay[CargoGroup.groupname]then
94889
95089
  self.cargoBay[CargoGroup.groupname]=nil
@@ -94931,9 +95131,10 @@ function OPSGROUP:_CheckDelivered(CargoTransport)
94931
95131
  local done=true
94932
95132
  for _,_cargo in pairs(CargoTransport:GetCargos())do
94933
95133
  local cargo=_cargo
94934
- if self:CanCargo(cargo.opsgroup)then
95134
+ if self:CanCargo(cargo)then
94935
95135
  if cargo.delivered then
94936
- elseif cargo.opsgroup==nil or cargo.opsgroup:IsDead()or cargo.opsgroup:IsStopped()then
95136
+ elseif cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and cargo.opsgroup==nil then
95137
+ elseif cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and(cargo.opsgroup:IsDead()or cargo.opsgroup:IsStopped())then
94937
95138
  else
94938
95139
  done=false
94939
95140
  end
@@ -94947,10 +95148,10 @@ local done=true
94947
95148
  if CargoTransport then
94948
95149
  for _,_cargo in pairs(CargoTransport:GetCargos())do
94949
95150
  local cargo=_cargo
94950
- if self:CanCargo(cargo.opsgroup)then
95151
+ if self:CanCargo(cargo)then
94951
95152
  if cargo.delivered then
94952
- elseif cargo.opsgroup==nil or cargo.opsgroup:IsDead()or cargo.opsgroup:IsStopped()then
94953
- elseif cargo.opsgroup:IsLoaded(CargoTransport:_GetCarrierNames())then
95153
+ elseif cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and(cargo.opsgroup==nil or cargo.opsgroup:IsDead()or cargo.opsgroup:IsStopped())then
95154
+ elseif cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and(cargo.opsgroup:IsLoaded(CargoTransport:_GetCarrierNames()))then
94954
95155
  else
94955
95156
  done=false
94956
95157
  end
@@ -95054,8 +95255,11 @@ if(UnitName==nil or UnitName==element.name)and(element and element.status~=OPSGR
95054
95255
  for _,_cargo in pairs(element.cargoBay)do
95055
95256
  local cargo=_cargo
95056
95257
  if(not cargo.reserved)or(cargo.reserved==true and(IncludeReserved==true or IncludeReserved==nil))then
95057
- local cargoweight=cargo.group:GetWeightTotal()
95058
- gewicht=gewicht+cargoweight
95258
+ if cargo.group then
95259
+ gewicht=gewicht+cargo.group:GetWeightTotal()
95260
+ else
95261
+ gewicht=gewicht+cargo.storageAmount*cargo.storageWeight
95262
+ end
95059
95263
  end
95060
95264
  end
95061
95265
  end
@@ -95102,27 +95306,54 @@ function OPSGROUP:RedWeightCargo(UnitName,Weight)
95102
95306
  self:AddWeightCargo(UnitName,-Weight)
95103
95307
  return self
95104
95308
  end
95105
- function OPSGROUP:CanCargo(CargoGroup)
95106
- if CargoGroup then
95107
- local weight=CargoGroup:GetWeightTotal()
95309
+ function OPSGROUP:_GetWeightStorage(Storage,Total,Reserved,Amount)
95310
+ local weight=Storage.cargoAmount
95311
+ if not Total then
95312
+ weight=weight-Storage.cargoLost-Storage.cargoLoaded-Storage.cargoDelivered
95313
+ end
95314
+ if Reserved then
95315
+ weight=weight-Storage.cargoReserved
95316
+ end
95317
+ if not Amount then
95318
+ weight=weight*Storage.cargoWeight
95319
+ end
95320
+ return weight
95321
+ end
95322
+ function OPSGROUP:CanCargo(Cargo)
95323
+ if Cargo then
95324
+ local weight=math.huge
95325
+ if Cargo.type==OPSTRANSPORT.CargoType.OPSGROUP then
95326
+ local weight=Cargo.opsgroup:GetWeightTotal()
95108
95327
  for _,_element in pairs(self.elements)do
95109
95328
  local element=_element
95110
95329
  if element and element.status~=OPSGROUP.ElementStatus.DEAD and element.weightMaxCargo>=weight then
95111
95330
  return true
95112
95331
  end
95113
95332
  end
95333
+ else
95334
+ weight=Cargo.storage.cargoWeight
95335
+ end
95336
+ local bay=0
95337
+ for _,_element in pairs(self.elements)do
95338
+ local element=_element
95339
+ if element and element.status~=OPSGROUP.ElementStatus.DEAD then
95340
+ bay=bay+element.weightMaxCargo
95341
+ end
95342
+ end
95343
+ if bay>=weight then
95344
+ return true
95345
+ end
95114
95346
  end
95115
95347
  return false
95116
95348
  end
95117
- function OPSGROUP:FindCarrierForCargo(CargoGroup)
95118
- local weight=CargoGroup:GetWeightTotal()
95349
+ function OPSGROUP:FindCarrierForCargo(Weight)
95119
95350
  for _,_element in pairs(self.elements)do
95120
95351
  local element=_element
95121
95352
  local free=self:GetFreeCargobay(element.name)
95122
- if free>=weight then
95353
+ if free>=Weight then
95123
95354
  return element
95124
95355
  else
95125
- self:T3(self.lid..string.format("%s: Weight %d>%d free cargo bay",element.name,weight,free))
95356
+ self:T3(self.lid..string.format("%s: Weight %d>%d free cargo bay",element.name,Weight,free))
95126
95357
  end
95127
95358
  end
95128
95359
  return nil
@@ -95259,42 +95490,97 @@ self:__Cruise(-2,nil,Formation)
95259
95490
  end
95260
95491
  end
95261
95492
  end
95493
+ function OPSGROUP:_SortCargo(Cargos)
95494
+ local function _sort(a,b)
95495
+ local cargoA=a
95496
+ local cargoB=b
95497
+ local weightA=0
95498
+ local weightB=0
95499
+ if cargoA.opsgroup then
95500
+ weightA=cargoA.opsgroup:GetWeightTotal()
95501
+ else
95502
+ weightA=self:_GetWeightStorage(cargoA.storage)
95503
+ end
95504
+ if cargoB.opsgroup then
95505
+ weightB=cargoB.opsgroup:GetWeightTotal()
95506
+ else
95507
+ weightB=self:_GetWeightStorage(cargoB.storage)
95508
+ end
95509
+ return weightA>weightB
95510
+ end
95511
+ table.sort(Cargos,_sort)
95512
+ return Cargos
95513
+ end
95262
95514
  function OPSGROUP:onafterLoading(From,Event,To)
95263
95515
  self:_NewCarrierStatus(OPSGROUP.CarrierStatus.LOADING)
95264
- self.Tloading=timer.getAbsTime()
95265
95516
  local cargos={}
95266
95517
  for _,_cargo in pairs(self.cargoTZC.Cargos)do
95267
95518
  local cargo=_cargo
95268
- local canCargo=self:CanCargo(cargo.opsgroup)
95269
- local isCarrier=cargo.opsgroup:IsPickingup()or cargo.opsgroup:IsLoading()or cargo.opsgroup:IsTransporting()or cargo.opsgroup:IsUnloading()
95270
- local isNotCargo=cargo.opsgroup:IsNotCargo(true)
95271
- local isHolding=cargo.opsgroup:IsHolding()or cargo.opsgroup:IsLoaded()
95272
- local inZone=cargo.opsgroup:IsInZone(self.cargoTZC.EmbarkZone)or cargo.opsgroup:IsInUtero()
95273
- local isOnMission=cargo.opsgroup:IsOnMission()
95519
+ local canCargo=self:CanCargo(cargo)
95520
+ local isCarrier=false
95521
+ local isNotCargo=true
95522
+ local isHolding=cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and(cargo.opsgroup:IsHolding()or cargo.opsgroup:IsLoaded())or true
95523
+ local inZone=cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and(cargo.opsgroup:IsInZone(self.cargoTZC.EmbarkZone)or cargo.opsgroup:IsInUtero())or true
95524
+ local isOnMission=cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and cargo.opsgroup:IsOnMission()or false
95274
95525
  if isOnMission then
95275
95526
  local mission=cargo.opsgroup:GetMissionCurrent()
95276
95527
  if mission and((mission.opstransport and mission.opstransport.uid==self.cargoTransport.uid)or mission.type==AUFTRAG.Type.NOTHING)then
95277
95528
  isOnMission=not isHolding
95278
95529
  end
95279
95530
  end
95531
+ local isAvail=true
95532
+ if cargo.type==OPSTRANSPORT.CargoType.STORAGE then
95533
+ local nAvail=cargo.storage.storageFrom:GetAmount(cargo.storage.cargoType)
95534
+ if nAvail>0 then
95535
+ isAvail=true
95536
+ else
95537
+ isAvail=false
95538
+ end
95539
+ else
95540
+ isCarrier=cargo.opsgroup:IsPickingup()or cargo.opsgroup:IsLoading()or cargo.opsgroup:IsTransporting()or cargo.opsgroup:IsUnloading()
95541
+ isNotCargo=cargo.opsgroup:IsNotCargo(true)
95542
+ end
95543
+ local isDead=cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and cargo.opsgroup:IsDead()or false
95280
95544
  self:T(self.lid..string.format("Loading: canCargo=%s, isCarrier=%s, isNotCargo=%s, isHolding=%s, isOnMission=%s",
95281
95545
  tostring(canCargo),tostring(isCarrier),tostring(isNotCargo),tostring(isHolding),tostring(isOnMission)))
95282
- if canCargo and inZone and isNotCargo and isHolding and(not(cargo.delivered or cargo.opsgroup:IsDead()or isCarrier or isOnMission))then
95546
+ if canCargo and inZone and isNotCargo and isHolding and isAvail and(not(cargo.delivered or isDead or isCarrier or isOnMission))then
95283
95547
  table.insert(cargos,cargo)
95284
95548
  end
95285
95549
  end
95286
- local function _sort(a,b)
95287
- local cargoA=a
95288
- local cargoB=b
95289
- return cargoA.opsgroup:GetWeightTotal()>cargoB.opsgroup:GetWeightTotal()
95290
- end
95291
- table.sort(cargos,_sort)
95550
+ self:_SortCargo(cargos)
95292
95551
  for _,_cargo in pairs(cargos)do
95293
95552
  local cargo=_cargo
95294
- local carrier=self:FindCarrierForCargo(cargo.opsgroup)
95553
+ local weight=nil
95554
+ if cargo.type==OPSTRANSPORT.CargoType.OPSGROUP then
95555
+ weight=cargo.opsgroup:GetWeightTotal()
95556
+ local carrier=self:FindCarrierForCargo(weight)
95295
95557
  if carrier then
95296
95558
  cargo.opsgroup:Board(self,carrier)
95297
95559
  end
95560
+ else
95561
+ weight=self:_GetWeightStorage(cargo.storage,false)
95562
+ local Amount=cargo.storage.storageFrom:GetAmount(cargo.storage.cargoType)
95563
+ local Weight=Amount*cargo.storage.cargoWeight
95564
+ weight=math.min(weight,Weight)
95565
+ self:T(self.lid..string.format("Loading storage weight=%d kg (warehouse has %d kg)!",weight,Weight))
95566
+ for _,_element in pairs(self.elements)do
95567
+ local element=_element
95568
+ local free=self:GetFreeCargobay(element.name)
95569
+ local w=math.min(weight,free)
95570
+ if w>=cargo.storage.cargoWeight then
95571
+ local amount=math.floor(w/cargo.storage.cargoWeight)
95572
+ cargo.storage.storageFrom:RemoveAmount(cargo.storage.cargoType,amount)
95573
+ cargo.storage.cargoLoaded=cargo.storage.cargoLoaded+amount
95574
+ self:_AddCargobayStorage(element,cargo.uid,cargo.storage.cargoType,amount,cargo.storage.cargoWeight)
95575
+ weight=weight-amount*cargo.storage.cargoWeight
95576
+ local text=string.format("Element %s: loaded amount=%d (weight=%d) ==> left=%d kg",element.name,amount,amount*cargo.storage.cargoWeight,weight)
95577
+ self:T(self.lid..text)
95578
+ if weight<=0 then
95579
+ break
95580
+ end
95581
+ end
95582
+ end
95583
+ end
95298
95584
  end
95299
95585
  end
95300
95586
  function OPSGROUP:_NewCargoStatus(Status)
@@ -95318,7 +95604,8 @@ function OPSGROUP:onafterLoad(From,Event,To,CargoGroup,Carrier)
95318
95604
  self:T(self.lid..string.format("Loading group %s",tostring(CargoGroup.groupname)))
95319
95605
  local carrier=Carrier or CargoGroup:_GetMyCarrierElement()
95320
95606
  if not carrier then
95321
- carrier=self:FindCarrierForCargo(CargoGroup)
95607
+ local weight=CargoGroup:GetWeightTotal()
95608
+ carrier=self:FindCarrierForCargo(weight)
95322
95609
  end
95323
95610
  if carrier then
95324
95611
  CargoGroup:_NewCargoStatus(OPSGROUP.CargoStatus.LOADED)
@@ -95447,6 +95734,7 @@ self:T(self.lid.."Unloading..")
95447
95734
  local zone=self.cargoTZC.DisembarkZone or self.cargoTZC.DeployZone
95448
95735
  for _,_cargo in pairs(self.cargoTZC.Cargos)do
95449
95736
  local cargo=_cargo
95737
+ if cargo.type==OPSTRANSPORT.CargoType.OPSGROUP then
95450
95738
  if cargo.opsgroup:IsLoaded(self.groupname)and not cargo.opsgroup:IsDead()then
95451
95739
  local carrier=nil
95452
95740
  local carrierGroup=nil
@@ -95506,6 +95794,31 @@ self:T(self.lid.."Cargo needs carrier but no carrier is avaiable (yet)!")
95506
95794
  end
95507
95795
  else
95508
95796
  end
95797
+ else
95798
+ if not cargo.delivered then
95799
+ for _,_element in pairs(self.elements)do
95800
+ local element=_element
95801
+ local mycargo=self:_GetCargobayElement(element,cargo.uid)
95802
+ if mycargo then
95803
+ cargo.storage.storageTo:AddAmount(mycargo.storageType,mycargo.storageAmount)
95804
+ cargo.storage.cargoDelivered=cargo.storage.cargoDelivered+mycargo.storageAmount
95805
+ cargo.storage.cargoLoaded=cargo.storage.cargoLoaded-mycargo.storageAmount
95806
+ self:_DelCargobayElement(element,mycargo)
95807
+ self:T2(self.lid..string.format("Cargo loaded=%d, delivered=%d, lost=%d",cargo.storage.cargoLoaded,cargo.storage.cargoDelivered,cargo.storage.cargoLost))
95808
+ end
95809
+ end
95810
+ local amountToDeliver=self:_GetWeightStorage(cargo.storage,false,false,true)
95811
+ local amountTotal=self:_GetWeightStorage(cargo.storage,true,false,true)
95812
+ local text=string.format("Amount delivered=%d, total=%d",amountToDeliver,amountTotal)
95813
+ self:T(self.lid..text)
95814
+ if amountToDeliver<=0 then
95815
+ cargo.delivered=true
95816
+ self.cargoTransport.Ndelivered=self.cargoTransport.Ndelivered+1
95817
+ local text=string.format("Ndelivered=%d delivered=%s",self.cargoTransport.Ndelivered,tostring(cargo.delivered))
95818
+ self:T(self.lid..text)
95819
+ end
95820
+ end
95821
+ end
95509
95822
  end
95510
95823
  end
95511
95824
  function OPSGROUP:onbeforeUnload(From,Event,To,OpsGroup,Coordinate,Heading)
@@ -97485,6 +97798,7 @@ assets={},
97485
97798
  legions={},
97486
97799
  statusLegion={},
97487
97800
  requestID={},
97801
+ cargocounter=0,
97488
97802
  }
97489
97803
  OPSTRANSPORT.Status={
97490
97804
  PLANNED="planned",
@@ -97497,8 +97811,12 @@ CANCELLED="cancelled",
97497
97811
  SUCCESS="success",
97498
97812
  FAILED="failed",
97499
97813
  }
97814
+ OPSTRANSPORT.CargoType={
97815
+ OPSGROUP="OPSGROUP",
97816
+ STORAGE="STORAGE",
97817
+ }
97500
97818
  _OPSTRANSPORTID=0
97501
- OPSTRANSPORT.version="0.7.0"
97819
+ OPSTRANSPORT.version="0.8.0"
97502
97820
  function OPSTRANSPORT:New(CargoGroups,PickupZone,DeployZone)
97503
97821
  local self=BASE:Inherit(self,FSM:New())
97504
97822
  _OPSTRANSPORTID=_OPSTRANSPORTID+1
@@ -97585,6 +97903,14 @@ self:I(self.lid..text)
97585
97903
  end
97586
97904
  return self
97587
97905
  end
97906
+ function OPSTRANSPORT:AddCargoStorage(StorageFrom,StorageTo,CargoType,CargoAmount,CargoWeight,TransportZoneCombo)
97907
+ TransportZoneCombo=TransportZoneCombo or self.tzcDefault
97908
+ local cargo=self:_CreateCargoStorage(StorageFrom,StorageTo,CargoType,CargoAmount,CargoWeight,TransportZoneCombo)
97909
+ if cargo then
97910
+ self.Ncargo=self.Ncargo+1
97911
+ table.insert(TransportZoneCombo.Cargos,cargo)
97912
+ end
97913
+ end
97588
97914
  function OPSTRANSPORT:SetPickupZone(PickupZone,TransportZoneCombo)
97589
97915
  TransportZoneCombo=TransportZoneCombo or self.tzcDefault
97590
97916
  TransportZoneCombo.PickupZone=PickupZone
@@ -97787,36 +98113,71 @@ end
97787
98113
  return names
97788
98114
  end
97789
98115
  function OPSTRANSPORT:GetCargoOpsGroups(Delivered,Carrier,TransportZoneCombo)
97790
- local cargos=self:GetCargos(TransportZoneCombo)
98116
+ local cargos=self:GetCargos(TransportZoneCombo,Carrier,Delivered)
97791
98117
  local opsgroups={}
97792
98118
  for _,_cargo in pairs(cargos)do
97793
98119
  local cargo=_cargo
97794
- if Delivered==nil or cargo.delivered==Delivered then
98120
+ if cargo.type=="OPSGROUP"then
97795
98121
  if cargo.opsgroup and not(cargo.opsgroup:IsDead()or cargo.opsgroup:IsStopped())then
97796
- if Carrier==nil or Carrier:CanCargo(cargo.opsgroup)then
97797
98122
  table.insert(opsgroups,cargo.opsgroup)
97798
98123
  end
97799
98124
  end
97800
98125
  end
98126
+ return opsgroups
98127
+ end
98128
+ function OPSTRANSPORT:GetCargoStorages(Delivered,Carrier,TransportZoneCombo)
98129
+ local cargos=self:GetCargos(TransportZoneCombo,Carrier,Delivered)
98130
+ local opsgroups={}
98131
+ for _,_cargo in pairs(cargos)do
98132
+ local cargo=_cargo
98133
+ if cargo.type=="STORAGE"then
98134
+ table.insert(opsgroups,cargo.storage)
98135
+ end
97801
98136
  end
97802
98137
  return opsgroups
97803
98138
  end
97804
98139
  function OPSTRANSPORT:GetCarriers()
97805
98140
  return self.carriers
97806
98141
  end
97807
- function OPSTRANSPORT:GetCargos(TransportZoneCombo)
98142
+ function OPSTRANSPORT:GetCargos(TransportZoneCombo,Carrier,Delivered)
98143
+ local tczs=self.tzCombos
97808
98144
  if TransportZoneCombo then
97809
- return TransportZoneCombo.Cargos
97810
- else
98145
+ tczs={TransportZoneCombo}
98146
+ end
97811
98147
  local cargos={}
97812
- for _,_tzc in pairs(self.tzCombos)do
97813
- local tzc=_tzc
97814
- for _,cargo in pairs(tzc.Cargos)do
98148
+ for _,_tcz in pairs(tczs)do
98149
+ local tcz=_tcz
98150
+ for _,_cargo in pairs(tcz.Cargos)do
98151
+ local cargo=_cargo
98152
+ if Delivered==nil or cargo.delivered==Delivered then
98153
+ if Carrier==nil or Carrier:CanCargo(cargo)then
97815
98154
  table.insert(cargos,cargo)
97816
98155
  end
97817
98156
  end
98157
+ end
98158
+ end
97818
98159
  return cargos
97819
98160
  end
98161
+ function OPSTRANSPORT:GetCargoTotalWeight(Cargo,IncludeReserved)
98162
+ local weight=0
98163
+ if Cargo.type==OPSTRANSPORT.CargoType.OPSGROUP then
98164
+ weight=Cargo.opsgroup:GetWeightTotal(nil,IncludeReserved)
98165
+ else
98166
+ if type(Cargo.storage.cargoType)=="number"then
98167
+ if IncludeReserved then
98168
+ return Cargo.storage.cargoAmount+Cargo.storage.cargoReserved
98169
+ else
98170
+ return Cargo.storage.cargoAmount
98171
+ end
98172
+ else
98173
+ if IncludeReserved then
98174
+ return Cargo.storage.cargoAmount*100
98175
+ else
98176
+ return(Cargo.storage.cargoAmount+Cargo.storage.cargoReserved)*100
98177
+ end
98178
+ end
98179
+ end
98180
+ return weight
97820
98181
  end
97821
98182
  function OPSTRANSPORT:SetTime(ClockStart,ClockStop)
97822
98183
  local Tnow=timer.getAbsTime()
@@ -98071,11 +98432,17 @@ if self.verbose>=3 then
98071
98432
  text=text..string.format("\nCargos:")
98072
98433
  for _,_cargo in pairs(self:GetCargos())do
98073
98434
  local cargo=_cargo
98435
+ if cargo.type==OPSTRANSPORT.CargoType.OPSGROUP then
98074
98436
  local carrier=cargo.opsgroup:_GetMyCarrierElement()
98075
98437
  local name=carrier and carrier.name or"none"
98076
98438
  local cstate=carrier and carrier.status or"N/A"
98077
98439
  text=text..string.format("\n- %s: %s [%s], weight=%d kg, carrier=%s [%s], delivered=%s [UID=%s]",
98078
98440
  cargo.opsgroup:GetName(),cargo.opsgroup.cargoStatus:upper(),cargo.opsgroup:GetState(),cargo.opsgroup:GetWeightTotal(),name,cstate,tostring(cargo.delivered),tostring(cargo.opsgroup.cargoTransportUID))
98441
+ else
98442
+ local storage=cargo.storage
98443
+ text=text..string.format("\n- storage type=%s: amount: total=%d loaded=%d, lost=%d, delivered=%d, delivered=%s [UID=%s]",
98444
+ storage.cargoType,storage.cargoAmount,storage.cargoLoaded,storage.cargoLost,storage.cargoDelivered,tostring(cargo.delivered),tostring(cargo.uid))
98445
+ end
98079
98446
  end
98080
98447
  text=text..string.format("\nCarriers:")
98081
98448
  for _,_carrier in pairs(self.carriers)do
@@ -98193,11 +98560,11 @@ for _,_cargo in pairs(self:GetCargos())do
98193
98560
  local cargo=_cargo
98194
98561
  if cargo.delivered then
98195
98562
  dead=false
98196
- elseif cargo.opsgroup==nil then
98563
+ elseif cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and cargo.opsgroup==nil then
98197
98564
  dead=false
98198
- elseif cargo.opsgroup:IsDestroyed()then
98199
- elseif cargo.opsgroup:IsDead()then
98200
- elseif cargo.opsgroup:IsStopped()then
98565
+ elseif cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and cargo.opsgroup:IsDestroyed()then
98566
+ elseif cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and cargo.opsgroup:IsDead()then
98567
+ elseif cargo.type==OPSTRANSPORT.CargoType.OPSGROUP and cargo.opsgroup:IsStopped()then
98201
98568
  dead=false
98202
98569
  else
98203
98570
  done=false
@@ -98290,7 +98657,10 @@ if cargo.opsgroup.groupname==opsgroup.groupname then
98290
98657
  return nil
98291
98658
  end
98292
98659
  end
98660
+ self.cargocounter=self.cargocounter+1
98293
98661
  local cargo={}
98662
+ cargo.uid=self.cargocounter
98663
+ cargo.type="OPSGROUP"
98294
98664
  cargo.opsgroup=opsgroup
98295
98665
  cargo.delivered=false
98296
98666
  cargo.status="Unknown"
@@ -98302,8 +98672,32 @@ self:_AddDisembarkCarriers(DisembarkCarriers,cargo.disembarkCarriers)
98302
98672
  end
98303
98673
  return cargo
98304
98674
  end
98675
+ function OPSTRANSPORT:_CreateCargoStorage(StorageFrom,StorageTo,CargoType,CargoAmount,CargoWeight,TransportZoneCombo)
98676
+ local storage={}
98677
+ storage.storageFrom=StorageFrom
98678
+ storage.storageTo=StorageTo
98679
+ storage.cargoType=CargoType
98680
+ storage.cargoAmount=CargoAmount
98681
+ storage.cargoDelivered=0
98682
+ storage.cargoLost=0
98683
+ storage.cargoReserved=0
98684
+ storage.cargoLoaded=0
98685
+ storage.cargoWeight=CargoWeight or 1
98686
+ self.cargocounter=self.cargocounter+1
98687
+ local cargo={}
98688
+ cargo.uid=self.cargocounter
98689
+ cargo.type="STORAGE"
98690
+ cargo.opsgroup=nil
98691
+ cargo.storage=storage
98692
+ cargo.delivered=false
98693
+ cargo.status="Unknown"
98694
+ cargo.tzcUID=TransportZoneCombo
98695
+ cargo.disembarkZone=nil
98696
+ cargo.disembarkCarriers=nil
98697
+ return cargo
98698
+ end
98305
98699
  function OPSTRANSPORT:_CountCargosInZone(Zone,Delivered,Carrier,TransportZoneCombo)
98306
- local cargos=self:GetCargoOpsGroups(Delivered,Carrier,TransportZoneCombo)
98700
+ local cargos=self:GetCargos(TransportZoneCombo,Carrier,Delivered)
98307
98701
  local function iscarrier(_cargo)
98308
98702
  local cargo=_cargo
98309
98703
  local mycarrier=cargo:_GetMyCarrierGroup()
@@ -98334,13 +98728,19 @@ end
98334
98728
  local N=0
98335
98729
  for _,_cargo in pairs(cargos)do
98336
98730
  local cargo=_cargo
98337
- local isNotCargo=cargo:IsNotCargo(true)
98731
+ local isNotCargo=true
98732
+ local isInZone=true
98733
+ local isInUtero=true
98734
+ if cargo.type==OPSTRANSPORT.CargoType.OPSGROUP then
98735
+ local opsgroup=cargo.opsgroup
98736
+ isNotCargo=opsgroup:IsNotCargo(true)
98338
98737
  if not isNotCargo then
98339
- isNotCargo=iscarrier(cargo)
98738
+ isNotCargo=iscarrier(opsgroup)
98739
+ end
98740
+ isInZone=opsgroup:IsInZone(Zone)
98741
+ isInUtero=opsgroup:IsInUtero()
98742
+ self:T(self.lid..string.format("Cargo=%s: notcargo=%s, iscarrier=%s inzone=%s, inutero=%s",opsgroup:GetName(),tostring(opsgroup:IsNotCargo(true)),tostring(iscarrier(opsgroup)),tostring(isInZone),tostring(isInUtero)))
98340
98743
  end
98341
- local isInZone=cargo:IsInZone(Zone)
98342
- local isInUtero=cargo:IsInUtero()
98343
- self:T(self.lid..string.format("Cargo=%s: notcargo=%s, iscarrier=%s inzone=%s, inutero=%s",cargo:GetName(),tostring(cargo:IsNotCargo(true)),tostring(iscarrier(cargo)),tostring(isInZone),tostring(isInUtero)))
98344
98744
  if isNotCargo and(isInZone or isInUtero)then
98345
98745
  N=N+1
98346
98746
  end
@@ -114883,6 +115283,16 @@ self:T("MSRS execute VBS command="..runvbs)
114883
115283
  res=os.execute(runvbs)
114884
115284
  timer.scheduleFunction(os.remove,filename,timer.getTime()+1)
114885
115285
  timer.scheduleFunction(os.remove,filenvbs,timer.getTime()+1)
115286
+ elseif false then
115287
+ local filenvbs=os.getenv('TMP').."\\MSRS-"..STTS.uuid()..".vbs"
115288
+ local script=io.open(filenvbs,"w+")
115289
+ script:write(string.format('Set oShell = CreateObject ("Wscript.Shell")\n'))
115290
+ script:write(string.format('Dim strArgs\n'))
115291
+ script:write(string.format('strArgs = "cmd /c %s"\n',filename))
115292
+ script:write(string.format('oShell.Run strArgs, 0, false'))
115293
+ script:close()
115294
+ local runvbs=string.format('cscript.exe //Nologo //B "%s"',filenvbs)
115295
+ res=os.execute(runvbs)
114886
115296
  else
114887
115297
  self:T("MSRS execute command="..command)
114888
115298
  res=os.execute(command)