#plugin Complete Surface Map Generator #author DHL #desc Generates a surface map for every Terrestrial and Gas Giant body in a sector file. (v1.05) '*******************************************Declarations*********************************************** 'Globals DIM gintCompleted 'As integer DIM gbCancel 'As Boolean DIM gintTotalSecBodies 'As Integer 'Benchmarking DIM gtPassStart 'As Time DIM gtPassStop 'As Time DIM gtPassTime 'As Time DIM gtAve 'As Time DIM gtTotal 'As Time '*******************************************Script Setup*********************************************** 'Setup default Globals for RunTime gintCompleted = 0 gbCancel = False gintTotalSecBodies = 0 'Benchmark gtTotal = 0 '*******************************************Script Start*********************************************** 'Start Main DoMainSub '*******************************************Script Stop*********************************************** '*******************************************Functions & Subs*********************************************** Sub FindTerrBodiesOuter DIM secSector 'As Sector DIM bodBody 'As Body DIM intSysCnt 'As Integer DIM i 'As Integer Dim nKey 'As String secSector = GetCurrentSector() intSysCnt = secSector.SystemCount 'iterate through all the systems on a map For i = 1 to intSysCnt 'check if Esc key pressed & cancel nKey = GetKey() If nKey = 27 Then gbCancel = True If gbCancel = true then Exit For 'Get the Body from the system bodBody = secSector.GetSystem(i - 1) 'process the sector FindTerrBodiesInner bodBody, secSector Next End Sub Sub FindTerrBodiesInner(bodPBody, secSector) DIM chiChild 'As Body DIM intChildCount 'As integer DIM k 'As Integer DIM nKey 'As String secSector.DynaLoad bodPBody intChildCount = bodPBody.ChildrenCount() For k = 1 to intChildCount 'check if Esc key pressed & cancel nKey = GetKey() If nKey = 27 Then gbCancel = True If gbCancel = true then Exit Sub 'Get the Body from the system chiChild = bodPBody.GetChild(k-1) 'make it recursive if chiChild.ChildrenCount() > 0 then FindTerrBodiesInner chiChild, secSector if ((chiChild.typeid = 100) or(chiChild.typeid = 101)) then 'Terrestrial or GasGiant gintTotalSecBodies = gintTotalSecBodies + 1 end if Next End Sub Sub DoMainSub DIM strAstroPath 'As String DIM secSector 'As Sector DIM bodBody 'As Body DIM intSysCnt 'As Integer DIM i 'As Integer Dim nKey 'As String DIM bUnload 'As Boolean strAstroPath = AstroDirectory() secSector = GetCurrentSector() intSysCnt = secSector.SystemCount 'Get a count of the TERRESTRIAL bodies, not ALL bodies. FindTerrBodiesOuter 'give user ONE last chance :) if msgbox ("There are " & gintTotalSecBodies & " bodies that will have maps generated. Are you sure you want to continue?" , (4 + 32), "Continue?") = vbNo then EXIT SUB 'iterate through all the systems on a map For i = 1 to intSysCnt 'check if Esc key pressed & cancel nKey = GetKey() If nKey = 27 Then gbCancel = True If gbCancel = true then Exit For bodBody = secSector.GetSystem(i - 1) secSector.RenderMessageBig = "System:" & CStr( i) & " of " & CStr( intSysCnt) & " SystemName: " & bodBody.Name RefreshScene if bodBody.Loaded = false Then secSector.DynaLoad bodBody 'process the sector HeirarchyLoop bodBody, secSector 'Save the sector secSector.SaveToFile secSector.FileName, false if bodBody.Loaded = true Then secSector.DynaunLoad bodBody Next Msgbox "Finished " & gintCompleted & " bodies in " & round(gintTotalSecBodies * gtAve , 1) & " sec(s).", , "Finished" End Sub Sub HeirarchyLoop(bodPBody, secSector) DIM chiChild 'As Body DIM intChildCount 'As integer DIM k 'As Integer DIM nKey 'As String DIM strMessage 'As string intChildCount = bodPBody.ChildrenCount() For k = 1 to intChildCount 'check if Esc key pressed & cancel nKey = GetKey() If nKey = 27 Then gbCancel = True If gbCancel = true then Exit Sub chiChild = bodPBody.GetChild(k-1) 'make it recursive if chiChild.ChildrenCount() > 0 then HeirarchyLoop chiChild, secSector if ((chiChild.typeid = 100) or(chiChild.typeid = 101)) then strMessage = "Creating Surface Map for " & chiChild.Name & ". to cancel " ' Append to render message and Calc time. if ((gtPassStart > 0) and (gtPassStop > 0)) then gtPassTime = Round((gtPassStop - gtPassStart), 2) 'msgbox "1) " & gtPassStop & vbcrlf & "2) " & gtPassStart & vbcrlf & "3) " & gtPassTime if gintCompleted = 1 then gtAve = gtPassTime else gtAve = round((gtPassTime + gtAve) / 2, 2) end if gtTotal = gtTotal + gtAve strMessage = strMessage & "(Last Time: " & gtPassTime & " sec(s). Avg: " & gtAve & " sec(s). " strMessage = strMessage & "Est. Time Remaining: " strMessage = strMessage & Round(((gintTotalSecBodies - gintCompleted) * gtAve), 2) strMessage = strMessage & " sec(s).)" end if gtPassStart = timer() secSector.RenderMessageSmall = strMessage RefreshScene fc = DefaultAstroColorGroup() DerivePlanetColors chiChild, fc 'work the WinMSGQueue baby! ProcessMessages 'make the map bodyMap = GenerateFWESurfaceMap( secSector, chiChild, false, fc) 'free the color group object from memory FreeObject fc gintCompleted = gintCompleted + 1 gtPassStop = timer() end if Next End Sub