diff --git a/data/lang/lore/en.json b/data/lang/lore/en.json new file mode 100644 index 00000000000..d3928e04d80 --- /dev/null +++ b/data/lang/lore/en.json @@ -0,0 +1,30 @@ +{ + "" : { + "description" : "", + "message" : "" + }, + "SOL_EARTH_LONDON" : { + "description" : "", + "message" : "Traditional center of civilization. Has recovered quite well after last centurys flooding disasters, although many of the cultural landmarks will never be restored to their former glory." + }, + "SOL_EARTH_MOSCOW" : { + "description" : "", + "message" : "Moscow Spaceflight museum is a must see! See how it all started, including an actual moon lander recovered from the moon! Beware of hawkers selling moon rocks for souvenirs, often buying a ticket to the moon is cheaper." + }, + "SOL_EARTH_SHANGHAI" : { + "description" : "", + "message" : "Industrial powerhouse of Earth. Dont forget your hazmat suit if you want to venture outside." + }, + "SOL_MARS_CYDONIA" : { + "description" : "", + "message" : "Home of the core systems champion gravball team, the Little Green Men." + }, + "SOL_MARS_OLYMPUS" : { + "description" : "", + "message" : "Dont forget to enjoy the longest ski slope within a hundred lightyears!" + }, + "SOL_MERCURY_CALORIS" : { + "description" : "", + "message" : "Located in Caloris Planitia, one of the largest impact craters in the system. Mercury being so close to the sun has lead to most things around here being named accordingly, 'Calor' even means 'heat' in latin and here there is a surplus of it. The almost unlimited solar power has been put to good use in the recycling business." + } +} \ No newline at end of file diff --git a/data/lang/ui-core/en.json b/data/lang/ui-core/en.json index 8e8ce3328d6..71d58d2b60c 100644 --- a/data/lang/ui-core/en.json +++ b/data/lang/ui-core/en.json @@ -1893,7 +1893,7 @@ }, "STATION_DOCKS": { "description": "Information shown in the station lobby, for total number of docking pads", - "message": "Our total capacity is {total_docking_pads} docking pads." + "message": "Your ship is docked on pad {shipbay} out of {bays} docking pads." }, "STATION_LOCAL_GRAVITY": { "description": "", @@ -1925,7 +1925,7 @@ }, "TECH_CERTIFIED_MILITARY": { "description": "Lobby screen shows the tech level of the station", - "message": "This installation holds a military technology clearance." + "message": "This installation holds a military technology certificate." }, "TEXTURE_COMPRESSION": { "description": "", diff --git a/data/libs/SpaceStation.lua b/data/libs/SpaceStation.lua index c219b082740..f28f6411f08 100644 --- a/data/libs/SpaceStation.lua +++ b/data/libs/SpaceStation.lua @@ -25,14 +25,28 @@ local l = Lang.GetResource("ui-core") function SpaceStation:Constructor() -- Use a variation of the space station seed itself to ensure consistency - local rand = Rand.New(self.seed .. '-techLevel') + local rand = Rand.New(self.seed .. 'techLevel') local techLevel = rand:Integer(1, 6) + rand:Integer(0,6) - if Game.system.faction ~= nil and Game.system.faction.hasHomeworld and Game.system.faction.homeworld == self.path:GetSystemBody().parent.path then + local isHomeworld = 0 + if Game.system.faction ~= nil and Game.system.faction.hasHomeworld and self.path:IsSameSystem(Game.system.faction.homeworld) then techLevel = math.max(techLevel, 6) -- bump it upto at least 6 if it's a homeworld like Earth + isHomeworld = 1 end -- cap the techlevel lower end based on the planets population techLevel = math.max(techLevel, math.min(math.floor(self.path:GetSystemBody().parent.population * 0.5), 11)) self:setprop("techLevel", techLevel) + self:setprop("isHomeworld", isHomeworld) + local props = self:GetPropertyDefaults() + if props == nil then return end + for k,v in pairs(props) do + if k and v then + self:setprop(k, v) + end + end + if self.techModifier then + local tmp = self.techLevel + self.techModifier + self:setprop("techLevel", (tmp <= 10) and tmp or 10) -- maximum adjusted level: 10 + end end local equipmentStock = {} @@ -49,18 +63,22 @@ local function updateEquipmentStock (station) if e == hydrogen then equipmentStock[station][e] = math.floor(rn/2 + Engine.rand:Integer(0,rn)) --always stock hydrogen else - local pricemod = Game.system:GetCommodityBasePriceAlterations(key) - local stock = (Engine.rand:Integer(0,rn) + Engine.rand:Integer(0,rn)) / 2 -- normal 0-100% stock - if pricemod > 10 then --major import, low stock - stock = stock - (rn*0.10) -- shifting .10 = 2% chance of 0 stock - elseif pricemod > 4 then --minor import - stock = stock - (rn*0.07) -- shifting .07 = 1% chance of 0 stock - elseif pricemod < -10 then --major export - stock = stock + (rn*0.8) - elseif pricemod < -4 then --minor export - stock = stock + (rn*0.3) + if station.noCargoForSale then + equipmentStock[station][e] = 0 + else + local pricemod = Game.system:GetCommodityBasePriceAlterations(key) + local stock = (Engine.rand:Integer(0,rn) + Engine.rand:Integer(0,rn)) / 2 -- normal 0-100% stock + if pricemod > 10 then --major import, low stock + stock = stock - (rn*0.10) -- shifting .10 = 2% chance of 0 stock + elseif pricemod > 4 then --minor import + stock = stock - (rn*0.07) -- shifting .07 = 1% chance of 0 stock + elseif pricemod < -10 then --major export + stock = stock + (rn*0.8) + elseif pricemod < -4 then --minor export + stock = stock + (rn*0.3) + end + equipmentStock[station][e] = math.floor(stock >=0 and stock or 0) end - equipmentStock[station][e] = math.floor(stock >=0 and stock or 0) end else equipmentStock[station][e] = 0 -- commodity that cant be bought @@ -141,6 +159,10 @@ end -- function SpaceStation:GetEquipmentStock (e) assert(self:exists()) + if not equipmentStock or not equipmentStock[self] or not equipmentStock[self][e] then + print("equipmentStock is incomplete/missing") + return 0 + end return equipmentStock[self][e] or 0 end diff --git a/data/pigui/modules/station-view/01-lobby.lua b/data/pigui/modules/station-view/01-lobby.lua index 1d18489d99b..be46652d2f3 100644 --- a/data/pigui/modules/station-view/01-lobby.lua +++ b/data/pigui/modules/station-view/01-lobby.lua @@ -228,28 +228,24 @@ end local function drawPlayerInfo() local station = Game.player:GetDockedWith() + if not station or not shipDef then return end - if(not (station and shipDef)) then return end - - local tech_certified - - if station.techLevel == 11 then - tech_certified = l.TECH_CERTIFIED_MILITARY - else - tech_certified = string.interp(l.TECH_CERTIFIED, { tech_level = station.techLevel}) - end - - local station_docks = string.interp(l.STATION_DOCKS, { total_docking_pads = string.format("%d", station.numDocks),}) + local substrings = { shipbay = station:GetAssignedBayNumber(Game.player) + 1, + bays = string.format("%d", station.numDocks), + tech_level = station.techLevel } + local tech_certified = (station.techLevel >= 11) and l.TECH_CERTIFIED_MILITARY or string.interp(l.TECH_CERTIFIED, substrings) + local station_docks = string.interp(l.STATION_DOCKS, substrings) local orbit_period = station.path:GetSystemBody().orbitPeriod - local station_frameBody = Space.GetBody(station.path:GetSystemBody().parent.index) - local local_gravity_pressure = "" - if station.type == "STARPORT_SURFACE" then - if station.path:GetSystemBody().parent.hasAtmosphere then - local_gravity_pressure = string.format(l.STATION_LOCAL_GRAVITY_PRESSURE, (station.path:GetSystemBody().parent.gravity/9.8), station_frameBody:GetAtmosphericState(station)) + local local_conditions = "" + if station.isGroundStation then + local myBody = station.path:GetSystemBody() + if myBody.parent.hasAtmosphere then + local parentBody = Space.GetBody(myBody.parent.index) + local_conditions = string.format(l.STATION_LOCAL_GRAVITY_PRESSURE, (myBody.parent.gravity/9.8), parentBody:GetAtmosphericState(station)) else - local_gravity_pressure = string.format(l.STATION_LOCAL_GRAVITY, (station.path:GetSystemBody().parent.gravity/9.8)) + local_conditions = string.format(l.STATION_LOCAL_GRAVITY, (myBody.parent.gravity/9.8)) end end @@ -266,16 +262,38 @@ local function drawPlayerInfo() local infoColumnWidth = conReg.x - widgetSizes.faceSize.x - widgetSizes.windowPadding.x*3 local lobbyMenuHeight = widgetSizes.buttonSizeBase.y*3 + widgetSizes.itemSpacing.y*3 + widgetSizes.windowPadding.y*2 local lobbyMenuAtBottom = (conReg.y - widgetSizes.faceSize.y > lobbyMenuHeight + widgetSizes.windowPadding.x*2) - + local tabLines = { { tech_certified, "" }, { station_docks, "" } } + if station_orbit_info ~= "" then + table.insert(tabLines, { station_orbit_info, "" }) + end + if local_conditions ~= "" then + table.insert(tabLines, { local_conditions, "" }) + end ui.child("Wrapper", Vector2(0, lobbyMenuAtBottom and -lobbyMenuHeight or 0), {}, function() ui.child("PlayerShipFuel", Vector2(infoColumnWidth, 0), {"AlwaysUseWindowPadding"}, function() local curPos = ui.getCursorPos() - textTable.withHeading(station.label, orbiteer.xlarge, { - { tech_certified, "" }, - { station_docks, "" }, - { station_orbit_info, "" }, - { local_gravity_pressure, ""}, - }) + --tabLines contain basic station information + textTable.withHeading(station.label, orbiteer.xlarge, tabLines ) + + -- lore text for this station, if any + local loretext = station.nolanglore or nil + if loretext == nil and station.lore ~= nil then + local lorelang = Lang.GetResource("lore") + loretext = lorelang[station.lore] + end + if loretext ~= nil then + ui.separator() + ui.pushTextWrapPos(infoColumnWidth) + ui.textWrapped(loretext) + ui.popTextWrapPos() + end + + if station.visualID ~= nil then + local licensetext = "Station License: "..station.visualID + local lXY = ui.calcTextSize(licensetext) + ui.setCursorPos(Vector2(infoColumnWidth - lXY.x - 6, curPos.y)) + ui.text(licensetext) + end if not lobbyMenuAtBottom then lobbyMenu(Vector2(curPos.x, conReg.y - lobbyMenuHeight)) diff --git a/data/pigui/views/mainmenu.lua b/data/pigui/views/mainmenu.lua index 0d63a96cd5f..7560bb28dba 100644 --- a/data/pigui/views/mainmenu.lua +++ b/data/pigui/views/mainmenu.lua @@ -42,7 +42,7 @@ local max_flavours = 22 local startLocations = { {['name']=lui.START_AT_MARS, ['desc']=lui.START_AT_MARS_DESC, - ['location']=SystemPath.New(0,0,0,0,18), + ['location']=SystemPath.New(0,0,0,0,22), ['logmsg']=lui.START_LOG_ENTRY_1, ['shipType']='sinonatrix',['money']=100,['hyperdrive']=true, ['equipment']={ diff --git a/data/world/WORLD.txt b/data/world/WORLD.txt new file mode 100644 index 00000000000..bc5900ff36c --- /dev/null +++ b/data/world/WORLD.txt @@ -0,0 +1,50 @@ +world/factions/<##_name>.lua + + Contains properties of factions + + ## determines order of precedence when loading + Name filename only. faction name is determined by contents of the file + +world/systems/<##_Name>.lua + + Contains manually created layouts of star systems + + ## determines order of precedence when loading + Name filename only. faction name is determined by contents of the file + +world/stations/.json +world/stations/.json +world/stations/.json +world/stations//.json + + Contains patch properties for individual stations. + Faction is the first to be loaded, then system, then both (or either) system+station files. + Any attribute in earlier files that reoccur in later loaded files will be overridden by the + last loaded. For example, faction values can be overridden by specific station files. + + Stations Json format: + { + "" : { + "value" : "" + }, + ... + } + + Properties are passed to station:setprop(, ) for all properties + in SpaceStation:Constructor() (libs/SpaceStation.lua). + If PropertyName contains other keys than "value", those are ignored. + Safe to use "comment" for example. + + Recognized PropertyName's: + + techLevel Override stations randomly generated techLevel + + techModifier Alter the randomly generated techLevel by this number, up to a max of 10 or a minimum of 1 + + lore Use this key, translated from lang/lore/*.json, as station lore text + + nolanglore Use this text as-is, as station lore text + overrides lore + + noCargoForSale (true/false) if present and not false, sets all cargo stocks except hydrogen + to zero. cargo can still be sold. \ No newline at end of file diff --git a/data/factions/000_Independent.lua b/data/world/factions/000_Independent.lua similarity index 100% rename from data/factions/000_Independent.lua rename to data/world/factions/000_Independent.lua diff --git a/data/factions/001_Solar_Federation.lua b/data/world/factions/001_Solar_Federation.lua similarity index 100% rename from data/factions/001_Solar_Federation.lua rename to data/world/factions/001_Solar_Federation.lua diff --git a/data/factions/002_Commonwealth_of_Independent_Worlds.lua b/data/world/factions/002_Commonwealth_of_Independent_Worlds.lua similarity index 100% rename from data/factions/002_Commonwealth_of_Independent_Worlds.lua rename to data/world/factions/002_Commonwealth_of_Independent_Worlds.lua diff --git a/data/factions/003_Haber_Corporation.lua b/data/world/factions/003_Haber_Corporation.lua similarity index 100% rename from data/factions/003_Haber_Corporation.lua rename to data/world/factions/003_Haber_Corporation.lua diff --git a/data/factions/004_Rim_Alliance.lua b/data/world/factions/004_Rim_Alliance.lua similarity index 100% rename from data/factions/004_Rim_Alliance.lua rename to data/world/factions/004_Rim_Alliance.lua diff --git a/data/factions/005_Rim_Faction.lua b/data/world/factions/005_Rim_Faction.lua similarity index 100% rename from data/factions/005_Rim_Faction.lua rename to data/world/factions/005_Rim_Faction.lua diff --git a/data/factions/006_Rim_League.lua b/data/world/factions/006_Rim_League.lua similarity index 100% rename from data/factions/006_Rim_League.lua rename to data/world/factions/006_Rim_League.lua diff --git a/data/factions/007_Rim_Systems.lua b/data/world/factions/007_Rim_Systems.lua similarity index 100% rename from data/factions/007_Rim_Systems.lua rename to data/world/factions/007_Rim_Systems.lua diff --git a/data/factions/008_Rim_Council.lua b/data/world/factions/008_Rim_Council.lua similarity index 100% rename from data/factions/008_Rim_Council.lua rename to data/world/factions/008_Rim_Council.lua diff --git a/data/factions/009_Rim_Worlds.lua b/data/world/factions/009_Rim_Worlds.lua similarity index 100% rename from data/factions/009_Rim_Worlds.lua rename to data/world/factions/009_Rim_Worlds.lua diff --git a/data/factions/010_Rim_Commonwealth.lua b/data/world/factions/010_Rim_Commonwealth.lua similarity index 100% rename from data/factions/010_Rim_Commonwealth.lua rename to data/world/factions/010_Rim_Commonwealth.lua diff --git a/data/factions/011_Rim_Territories.lua b/data/world/factions/011_Rim_Territories.lua similarity index 100% rename from data/factions/011_Rim_Territories.lua rename to data/world/factions/011_Rim_Territories.lua diff --git a/data/factions/012_Obsidian_Alliance.lua b/data/world/factions/012_Obsidian_Alliance.lua similarity index 100% rename from data/factions/012_Obsidian_Alliance.lua rename to data/world/factions/012_Obsidian_Alliance.lua diff --git a/data/factions/013_Obsidian_Union.lua b/data/world/factions/013_Obsidian_Union.lua similarity index 100% rename from data/factions/013_Obsidian_Union.lua rename to data/world/factions/013_Obsidian_Union.lua diff --git a/data/factions/014_Obsidian_Horde.lua b/data/world/factions/014_Obsidian_Horde.lua similarity index 100% rename from data/factions/014_Obsidian_Horde.lua rename to data/world/factions/014_Obsidian_Horde.lua diff --git a/data/factions/015_Obsidian_Systems.lua b/data/world/factions/015_Obsidian_Systems.lua similarity index 100% rename from data/factions/015_Obsidian_Systems.lua rename to data/world/factions/015_Obsidian_Systems.lua diff --git a/data/factions/016_Obsidian_Worlds.lua b/data/world/factions/016_Obsidian_Worlds.lua similarity index 100% rename from data/factions/016_Obsidian_Worlds.lua rename to data/world/factions/016_Obsidian_Worlds.lua diff --git a/data/factions/017_Obsidian_Commonwealth.lua b/data/world/factions/017_Obsidian_Commonwealth.lua similarity index 100% rename from data/factions/017_Obsidian_Commonwealth.lua rename to data/world/factions/017_Obsidian_Commonwealth.lua diff --git a/data/factions/018_United_Alliance.lua b/data/world/factions/018_United_Alliance.lua similarity index 100% rename from data/factions/018_United_Alliance.lua rename to data/world/factions/018_United_Alliance.lua diff --git a/data/factions/019_United_Union.lua b/data/world/factions/019_United_Union.lua similarity index 100% rename from data/factions/019_United_Union.lua rename to data/world/factions/019_United_Union.lua diff --git a/data/factions/020_United_Network.lua b/data/world/factions/020_United_Network.lua similarity index 100% rename from data/factions/020_United_Network.lua rename to data/world/factions/020_United_Network.lua diff --git a/data/factions/021_United_League.lua b/data/world/factions/021_United_League.lua similarity index 100% rename from data/factions/021_United_League.lua rename to data/world/factions/021_United_League.lua diff --git a/data/factions/022_United_Kingdoms.lua b/data/world/factions/022_United_Kingdoms.lua similarity index 100% rename from data/factions/022_United_Kingdoms.lua rename to data/world/factions/022_United_Kingdoms.lua diff --git a/data/factions/023_United_Systems.lua b/data/world/factions/023_United_Systems.lua similarity index 100% rename from data/factions/023_United_Systems.lua rename to data/world/factions/023_United_Systems.lua diff --git a/data/factions/024_United_Council.lua b/data/world/factions/024_United_Council.lua similarity index 100% rename from data/factions/024_United_Council.lua rename to data/world/factions/024_United_Council.lua diff --git a/data/factions/025_United_Commonwealth.lua b/data/world/factions/025_United_Commonwealth.lua similarity index 100% rename from data/factions/025_United_Commonwealth.lua rename to data/world/factions/025_United_Commonwealth.lua diff --git a/data/factions/026_United_Republic.lua b/data/world/factions/026_United_Republic.lua similarity index 100% rename from data/factions/026_United_Republic.lua rename to data/world/factions/026_United_Republic.lua diff --git a/data/factions/027_Shattered_Network.lua b/data/world/factions/027_Shattered_Network.lua similarity index 100% rename from data/factions/027_Shattered_Network.lua rename to data/world/factions/027_Shattered_Network.lua diff --git a/data/factions/028_Shattered_Empire.lua b/data/world/factions/028_Shattered_Empire.lua similarity index 100% rename from data/factions/028_Shattered_Empire.lua rename to data/world/factions/028_Shattered_Empire.lua diff --git a/data/factions/029_Shattered_Systems.lua b/data/world/factions/029_Shattered_Systems.lua similarity index 100% rename from data/factions/029_Shattered_Systems.lua rename to data/world/factions/029_Shattered_Systems.lua diff --git a/data/factions/030_Shattered_Worlds.lua b/data/world/factions/030_Shattered_Worlds.lua similarity index 100% rename from data/factions/030_Shattered_Worlds.lua rename to data/world/factions/030_Shattered_Worlds.lua diff --git a/data/factions/031_Stellar_Union.lua b/data/world/factions/031_Stellar_Union.lua similarity index 100% rename from data/factions/031_Stellar_Union.lua rename to data/world/factions/031_Stellar_Union.lua diff --git a/data/factions/032_Stellar_Horde.lua b/data/world/factions/032_Stellar_Horde.lua similarity index 100% rename from data/factions/032_Stellar_Horde.lua rename to data/world/factions/032_Stellar_Horde.lua diff --git a/data/factions/033_Stellar_Network.lua b/data/world/factions/033_Stellar_Network.lua similarity index 100% rename from data/factions/033_Stellar_Network.lua rename to data/world/factions/033_Stellar_Network.lua diff --git a/data/factions/034_Stellar_Territories.lua b/data/world/factions/034_Stellar_Territories.lua similarity index 100% rename from data/factions/034_Stellar_Territories.lua rename to data/world/factions/034_Stellar_Territories.lua diff --git a/data/factions/035_Stellar_Republic.lua b/data/world/factions/035_Stellar_Republic.lua similarity index 100% rename from data/factions/035_Stellar_Republic.lua rename to data/world/factions/035_Stellar_Republic.lua diff --git a/data/factions/036_Free_Alliance.lua b/data/world/factions/036_Free_Alliance.lua similarity index 100% rename from data/factions/036_Free_Alliance.lua rename to data/world/factions/036_Free_Alliance.lua diff --git a/data/factions/037_Free_Horde.lua b/data/world/factions/037_Free_Horde.lua similarity index 100% rename from data/factions/037_Free_Horde.lua rename to data/world/factions/037_Free_Horde.lua diff --git a/data/factions/038_Free_Kingdoms.lua b/data/world/factions/038_Free_Kingdoms.lua similarity index 100% rename from data/factions/038_Free_Kingdoms.lua rename to data/world/factions/038_Free_Kingdoms.lua diff --git a/data/factions/039_Free_Systems.lua b/data/world/factions/039_Free_Systems.lua similarity index 100% rename from data/factions/039_Free_Systems.lua rename to data/world/factions/039_Free_Systems.lua diff --git a/data/factions/040_Free_Republic.lua b/data/world/factions/040_Free_Republic.lua similarity index 100% rename from data/factions/040_Free_Republic.lua rename to data/world/factions/040_Free_Republic.lua diff --git a/data/factions/041_Blood_Expanse.lua b/data/world/factions/041_Blood_Expanse.lua similarity index 100% rename from data/factions/041_Blood_Expanse.lua rename to data/world/factions/041_Blood_Expanse.lua diff --git a/data/factions/042_Blood_Faction.lua b/data/world/factions/042_Blood_Faction.lua similarity index 100% rename from data/factions/042_Blood_Faction.lua rename to data/world/factions/042_Blood_Faction.lua diff --git a/data/factions/043_Blood_League.lua b/data/world/factions/043_Blood_League.lua similarity index 100% rename from data/factions/043_Blood_League.lua rename to data/world/factions/043_Blood_League.lua diff --git a/data/factions/044_Blood_Empire.lua b/data/world/factions/044_Blood_Empire.lua similarity index 100% rename from data/factions/044_Blood_Empire.lua rename to data/world/factions/044_Blood_Empire.lua diff --git a/data/factions/045_Blood_Kingdoms.lua b/data/world/factions/045_Blood_Kingdoms.lua similarity index 100% rename from data/factions/045_Blood_Kingdoms.lua rename to data/world/factions/045_Blood_Kingdoms.lua diff --git a/data/factions/046_Blood_Council.lua b/data/world/factions/046_Blood_Council.lua similarity index 100% rename from data/factions/046_Blood_Council.lua rename to data/world/factions/046_Blood_Council.lua diff --git a/data/factions/047_Blood_Worlds.lua b/data/world/factions/047_Blood_Worlds.lua similarity index 100% rename from data/factions/047_Blood_Worlds.lua rename to data/world/factions/047_Blood_Worlds.lua diff --git a/data/factions/048_Blood_Territories.lua b/data/world/factions/048_Blood_Territories.lua similarity index 100% rename from data/factions/048_Blood_Territories.lua rename to data/world/factions/048_Blood_Territories.lua diff --git a/data/factions/049_True_Expanse.lua b/data/world/factions/049_True_Expanse.lua similarity index 100% rename from data/factions/049_True_Expanse.lua rename to data/world/factions/049_True_Expanse.lua diff --git a/data/factions/050_True_League.lua b/data/world/factions/050_True_League.lua similarity index 100% rename from data/factions/050_True_League.lua rename to data/world/factions/050_True_League.lua diff --git a/data/factions/051_True_Empire.lua b/data/world/factions/051_True_Empire.lua similarity index 100% rename from data/factions/051_True_Empire.lua rename to data/world/factions/051_True_Empire.lua diff --git a/data/factions/052_True_Systems.lua b/data/world/factions/052_True_Systems.lua similarity index 100% rename from data/factions/052_True_Systems.lua rename to data/world/factions/052_True_Systems.lua diff --git a/data/factions/053_True_Council.lua b/data/world/factions/053_True_Council.lua similarity index 100% rename from data/factions/053_True_Council.lua rename to data/world/factions/053_True_Council.lua diff --git a/data/factions/054_True_Worlds.lua b/data/world/factions/054_True_Worlds.lua similarity index 100% rename from data/factions/054_True_Worlds.lua rename to data/world/factions/054_True_Worlds.lua diff --git a/data/factions/055_True_Commonwealth.lua b/data/world/factions/055_True_Commonwealth.lua similarity index 100% rename from data/factions/055_True_Commonwealth.lua rename to data/world/factions/055_True_Commonwealth.lua diff --git a/data/factions/056_True_Territories.lua b/data/world/factions/056_True_Territories.lua similarity index 100% rename from data/factions/056_True_Territories.lua rename to data/world/factions/056_True_Territories.lua diff --git a/data/factions/057_True_Republic.lua b/data/world/factions/057_True_Republic.lua similarity index 100% rename from data/factions/057_True_Republic.lua rename to data/world/factions/057_True_Republic.lua diff --git a/data/factions/058_Far_Horde.lua b/data/world/factions/058_Far_Horde.lua similarity index 100% rename from data/factions/058_Far_Horde.lua rename to data/world/factions/058_Far_Horde.lua diff --git a/data/factions/059_Far_Faction.lua b/data/world/factions/059_Far_Faction.lua similarity index 100% rename from data/factions/059_Far_Faction.lua rename to data/world/factions/059_Far_Faction.lua diff --git a/data/factions/060_Far_Republic.lua b/data/world/factions/060_Far_Republic.lua similarity index 100% rename from data/factions/060_Far_Republic.lua rename to data/world/factions/060_Far_Republic.lua diff --git a/data/factions/061_Dagger_Union.lua b/data/world/factions/061_Dagger_Union.lua similarity index 100% rename from data/factions/061_Dagger_Union.lua rename to data/world/factions/061_Dagger_Union.lua diff --git a/data/factions/062_Dagger_Expanse.lua b/data/world/factions/062_Dagger_Expanse.lua similarity index 100% rename from data/factions/062_Dagger_Expanse.lua rename to data/world/factions/062_Dagger_Expanse.lua diff --git a/data/factions/063_Dagger_Kingdoms.lua b/data/world/factions/063_Dagger_Kingdoms.lua similarity index 100% rename from data/factions/063_Dagger_Kingdoms.lua rename to data/world/factions/063_Dagger_Kingdoms.lua diff --git a/data/factions/064_Dagger_Systems.lua b/data/world/factions/064_Dagger_Systems.lua similarity index 100% rename from data/factions/064_Dagger_Systems.lua rename to data/world/factions/064_Dagger_Systems.lua diff --git a/data/factions/065_Dagger_Council.lua b/data/world/factions/065_Dagger_Council.lua similarity index 100% rename from data/factions/065_Dagger_Council.lua rename to data/world/factions/065_Dagger_Council.lua diff --git a/data/factions/066_Dagger_Worlds.lua b/data/world/factions/066_Dagger_Worlds.lua similarity index 100% rename from data/factions/066_Dagger_Worlds.lua rename to data/world/factions/066_Dagger_Worlds.lua diff --git a/data/factions/067_Liberation_Union.lua b/data/world/factions/067_Liberation_Union.lua similarity index 100% rename from data/factions/067_Liberation_Union.lua rename to data/world/factions/067_Liberation_Union.lua diff --git a/data/factions/068_Liberation_Horde.lua b/data/world/factions/068_Liberation_Horde.lua similarity index 100% rename from data/factions/068_Liberation_Horde.lua rename to data/world/factions/068_Liberation_Horde.lua diff --git a/data/factions/069_Liberation_Faction.lua b/data/world/factions/069_Liberation_Faction.lua similarity index 100% rename from data/factions/069_Liberation_Faction.lua rename to data/world/factions/069_Liberation_Faction.lua diff --git a/data/factions/070_Provisional_Expanse.lua b/data/world/factions/070_Provisional_Expanse.lua similarity index 100% rename from data/factions/070_Provisional_Expanse.lua rename to data/world/factions/070_Provisional_Expanse.lua diff --git a/data/factions/071_Provisional_Faction.lua b/data/world/factions/071_Provisional_Faction.lua similarity index 100% rename from data/factions/071_Provisional_Faction.lua rename to data/world/factions/071_Provisional_Faction.lua diff --git a/data/factions/072_Provisional_Empire.lua b/data/world/factions/072_Provisional_Empire.lua similarity index 100% rename from data/factions/072_Provisional_Empire.lua rename to data/world/factions/072_Provisional_Empire.lua diff --git a/data/factions/073_Provisional_Kingdoms.lua b/data/world/factions/073_Provisional_Kingdoms.lua similarity index 100% rename from data/factions/073_Provisional_Kingdoms.lua rename to data/world/factions/073_Provisional_Kingdoms.lua diff --git a/data/factions/074_Provisional_Systems.lua b/data/world/factions/074_Provisional_Systems.lua similarity index 100% rename from data/factions/074_Provisional_Systems.lua rename to data/world/factions/074_Provisional_Systems.lua diff --git a/data/factions/075_Provisional_Commonwealth.lua b/data/world/factions/075_Provisional_Commonwealth.lua similarity index 100% rename from data/factions/075_Provisional_Commonwealth.lua rename to data/world/factions/075_Provisional_Commonwealth.lua diff --git a/data/factions/076_Continuity_Alliance.lua b/data/world/factions/076_Continuity_Alliance.lua similarity index 100% rename from data/factions/076_Continuity_Alliance.lua rename to data/world/factions/076_Continuity_Alliance.lua diff --git a/data/factions/077_Continuity_Horde.lua b/data/world/factions/077_Continuity_Horde.lua similarity index 100% rename from data/factions/077_Continuity_Horde.lua rename to data/world/factions/077_Continuity_Horde.lua diff --git a/data/factions/078_Continuity_Network.lua b/data/world/factions/078_Continuity_Network.lua similarity index 100% rename from data/factions/078_Continuity_Network.lua rename to data/world/factions/078_Continuity_Network.lua diff --git a/data/factions/079_Continuity_Empire.lua b/data/world/factions/079_Continuity_Empire.lua similarity index 100% rename from data/factions/079_Continuity_Empire.lua rename to data/world/factions/079_Continuity_Empire.lua diff --git a/data/factions/080_Continuity_Council.lua b/data/world/factions/080_Continuity_Council.lua similarity index 100% rename from data/factions/080_Continuity_Council.lua rename to data/world/factions/080_Continuity_Council.lua diff --git a/data/factions/081_Continuity_Worlds.lua b/data/world/factions/081_Continuity_Worlds.lua similarity index 100% rename from data/factions/081_Continuity_Worlds.lua rename to data/world/factions/081_Continuity_Worlds.lua diff --git a/data/factions/082_Independent_Union.lua b/data/world/factions/082_Independent_Union.lua similarity index 100% rename from data/factions/082_Independent_Union.lua rename to data/world/factions/082_Independent_Union.lua diff --git a/data/factions/083_Independent_Expanse.lua b/data/world/factions/083_Independent_Expanse.lua similarity index 100% rename from data/factions/083_Independent_Expanse.lua rename to data/world/factions/083_Independent_Expanse.lua diff --git a/data/factions/084_Independent_Faction.lua b/data/world/factions/084_Independent_Faction.lua similarity index 100% rename from data/factions/084_Independent_Faction.lua rename to data/world/factions/084_Independent_Faction.lua diff --git a/data/factions/085_Independent_Network.lua b/data/world/factions/085_Independent_Network.lua similarity index 100% rename from data/factions/085_Independent_Network.lua rename to data/world/factions/085_Independent_Network.lua diff --git a/data/factions/086_Independent_League.lua b/data/world/factions/086_Independent_League.lua similarity index 100% rename from data/factions/086_Independent_League.lua rename to data/world/factions/086_Independent_League.lua diff --git a/data/factions/087_Independent_Commonwealth.lua b/data/world/factions/087_Independent_Commonwealth.lua similarity index 100% rename from data/factions/087_Independent_Commonwealth.lua rename to data/world/factions/087_Independent_Commonwealth.lua diff --git a/data/factions/088_Independent_Territories.lua b/data/world/factions/088_Independent_Territories.lua similarity index 100% rename from data/factions/088_Independent_Territories.lua rename to data/world/factions/088_Independent_Territories.lua diff --git a/data/factions/089_Independent_Republic.lua b/data/world/factions/089_Independent_Republic.lua similarity index 100% rename from data/factions/089_Independent_Republic.lua rename to data/world/factions/089_Independent_Republic.lua diff --git a/data/factions/090_Inner_Expanse.lua b/data/world/factions/090_Inner_Expanse.lua similarity index 100% rename from data/factions/090_Inner_Expanse.lua rename to data/world/factions/090_Inner_Expanse.lua diff --git a/data/factions/091_Inner_Horde.lua b/data/world/factions/091_Inner_Horde.lua similarity index 100% rename from data/factions/091_Inner_Horde.lua rename to data/world/factions/091_Inner_Horde.lua diff --git a/data/factions/092_Inner_Faction.lua b/data/world/factions/092_Inner_Faction.lua similarity index 100% rename from data/factions/092_Inner_Faction.lua rename to data/world/factions/092_Inner_Faction.lua diff --git a/data/factions/093_Inner_Kingdoms.lua b/data/world/factions/093_Inner_Kingdoms.lua similarity index 100% rename from data/factions/093_Inner_Kingdoms.lua rename to data/world/factions/093_Inner_Kingdoms.lua diff --git a/data/factions/094_Inner_Systems.lua b/data/world/factions/094_Inner_Systems.lua similarity index 100% rename from data/factions/094_Inner_Systems.lua rename to data/world/factions/094_Inner_Systems.lua diff --git a/data/factions/095_Inner_Council.lua b/data/world/factions/095_Inner_Council.lua similarity index 100% rename from data/factions/095_Inner_Council.lua rename to data/world/factions/095_Inner_Council.lua diff --git a/data/factions/096_Inner_Territories.lua b/data/world/factions/096_Inner_Territories.lua similarity index 100% rename from data/factions/096_Inner_Territories.lua rename to data/world/factions/096_Inner_Territories.lua diff --git a/data/factions/097_Outer_Expanse.lua b/data/world/factions/097_Outer_Expanse.lua similarity index 100% rename from data/factions/097_Outer_Expanse.lua rename to data/world/factions/097_Outer_Expanse.lua diff --git a/data/factions/098_Outer_League.lua b/data/world/factions/098_Outer_League.lua similarity index 100% rename from data/factions/098_Outer_League.lua rename to data/world/factions/098_Outer_League.lua diff --git a/data/factions/099_Outer_Kingdoms.lua b/data/world/factions/099_Outer_Kingdoms.lua similarity index 100% rename from data/factions/099_Outer_Kingdoms.lua rename to data/world/factions/099_Outer_Kingdoms.lua diff --git a/data/factions/100_Outer_Systems.lua b/data/world/factions/100_Outer_Systems.lua similarity index 100% rename from data/factions/100_Outer_Systems.lua rename to data/world/factions/100_Outer_Systems.lua diff --git a/data/factions/101_Outer_Worlds.lua b/data/world/factions/101_Outer_Worlds.lua similarity index 100% rename from data/factions/101_Outer_Worlds.lua rename to data/world/factions/101_Outer_Worlds.lua diff --git a/data/factions/102_Outer_Republic.lua b/data/world/factions/102_Outer_Republic.lua similarity index 100% rename from data/factions/102_Outer_Republic.lua rename to data/world/factions/102_Outer_Republic.lua diff --git a/data/factions/XX_AutoGenerate.OLD b/data/world/factions/XX_AutoGenerate.OLD similarity index 100% rename from data/factions/XX_AutoGenerate.OLD rename to data/world/factions/XX_AutoGenerate.OLD diff --git a/data/world/stations/00000000-Sol/Caloris.json b/data/world/stations/00000000-Sol/Caloris.json new file mode 100644 index 00000000000..b5b175e4c35 --- /dev/null +++ b/data/world/stations/00000000-Sol/Caloris.json @@ -0,0 +1,8 @@ +{ + "techLevel" : { + "value" : "10" + }, + "lore" : { + "value" : "SOL_MERCURY_CYDONIA" + } +} \ No newline at end of file diff --git a/data/world/stations/00000000-Sol/Cydonia.json b/data/world/stations/00000000-Sol/Cydonia.json new file mode 100644 index 00000000000..999d36d323c --- /dev/null +++ b/data/world/stations/00000000-Sol/Cydonia.json @@ -0,0 +1,8 @@ +{ + "techLevel" : { + "value" : "10" + }, + "lore" : { + "value" : "SOL_MARS_CYDONIA" + } +} \ No newline at end of file diff --git a/data/world/stations/00000000-Sol/London.json b/data/world/stations/00000000-Sol/London.json new file mode 100644 index 00000000000..5fc92190cc2 --- /dev/null +++ b/data/world/stations/00000000-Sol/London.json @@ -0,0 +1,5 @@ +{ + "lore" : { + "value" : "SOL_EARTH_LONDON" + } +} \ No newline at end of file diff --git a/data/world/stations/00000000-Sol/Moscow.json b/data/world/stations/00000000-Sol/Moscow.json new file mode 100644 index 00000000000..2b4f5df866a --- /dev/null +++ b/data/world/stations/00000000-Sol/Moscow.json @@ -0,0 +1,5 @@ +{ + "lore" : { + "value" : "SOL_EARTH_MOSCOW" + } +} \ No newline at end of file diff --git a/data/world/stations/00000000-Sol/OlympusMons.json b/data/world/stations/00000000-Sol/OlympusMons.json new file mode 100644 index 00000000000..91806a9e445 --- /dev/null +++ b/data/world/stations/00000000-Sol/OlympusMons.json @@ -0,0 +1,5 @@ +{ + "lore" : { + "value" : "SOL_MARS_OLYMPUS" + } +} \ No newline at end of file diff --git a/data/world/stations/00000000-Sol/Shanghai.json b/data/world/stations/00000000-Sol/Shanghai.json new file mode 100644 index 00000000000..4a6ffdb81f9 --- /dev/null +++ b/data/world/stations/00000000-Sol/Shanghai.json @@ -0,0 +1,5 @@ +{ + "lore" : { + "value" : "SOL_EARTH_SHANGHAI" + } +} \ No newline at end of file diff --git a/data/world/stations/SolarFederation.json b/data/world/stations/SolarFederation.json new file mode 100644 index 00000000000..7f5d34f18c3 --- /dev/null +++ b/data/world/stations/SolarFederation.json @@ -0,0 +1,6 @@ +{ + "techModifier" : { + "comment" : "added to the techLevel of all Solar Federation stations, up to 10 max", + "value" : "1" + } +} \ No newline at end of file diff --git a/data/systems/00_sol.lua b/data/world/systems/00_sol.lua similarity index 96% rename from data/systems/00_sol.lua rename to data/world/systems/00_sol.lua index 0bbb74e976f..1d635384fdb 100644 --- a/data/systems/00_sol.lua +++ b/data/world/systems/00_sol.lua @@ -32,6 +32,20 @@ local mercury = CustomSystemBody:new('Mercury', 'PLANET_TERRESTRIAL') :orbital_phase_at_start(fixed.deg2rad(f(286,1))) :rings(false) +local mercury_starports = { + CustomSystemBody:new('Furiosa', 'STARPORT_SURFACE') + :latitude(math.deg2rad(89)) + :longitude(5), + CustomSystemBody:new('Caloris', 'STARPORT_SURFACE') + :latitude(math.deg2rad(189)) + :longitude(30), + CustomSystemBody:new('Fenix', 'STARPORT_ORBITAL') + -- can orbital station be made to stay in sun synchronous orbit? + :seed(666) + :semi_major_axis(f(1,25680)) + :inclination(math.deg2rad(90)) +} + local venus = CustomSystemBody:new('Venus', 'PLANET_TERRESTRIAL') :radius(f(95,100)) :mass(f(815,1000)) @@ -51,6 +65,13 @@ local venus = CustomSystemBody:new('Venus', 'PLANET_TERRESTRIAL') :orbital_phase_at_start(fixed.deg2rad(f(248,1))) :rings(false) +local venus_starports = { + CustomSystemBody:new('Cloud Nine', 'STARPORT_ORBITAL') + :seed(6734) + :semi_major_axis(f(100,100000)) + :rotation_period(f(1,24*60*3)) +} + local earth = CustomSystemBody:new('Earth', 'PLANET_TERRESTRIAL') :radius(f(1,1)) :mass(f(1,1)) @@ -92,15 +113,15 @@ local earth_starports = { :latitude(math.deg2rad(34)) :longitude(math.deg2rad(118)), CustomSystemBody:new('Gates Spaceport', 'STARPORT_ORBITAL') - :seed(1) + :seed(8088) :semi_major_axis(f(100,100000)) :rotation_period(f(1,24*60*3)), CustomSystemBody:new('Jobs Pad', 'STARPORT_ORBITAL') - :seed(13) + :seed(6502) :semi_major_axis(f(100,100000)) :rotation_period(f(1,24*60*3)), CustomSystemBody:new('Torvalds Platform', 'STARPORT_ORBITAL') - :seed(0) + :seed(80386) :semi_major_axis(f(5.0,100000)) :rotation_period(f(1,24*60*3)) :orbital_phase_at_start(fixed.deg2rad(f(0,1))) @@ -170,6 +191,10 @@ local mars_starports = { CustomSystemBody:new('Mars High', 'STARPORT_ORBITAL') :semi_major_axis(f(5068,100000000)) :rotation_period(f(11,24)), + CustomSystemBody:new("Musk's Meme-Mansion", 'STARPORT_ORBITAL') + :seed(2024) + :semi_major_axis(f(1, 10000)) + :inclination(math.deg2rad(25)) } local mars_moons = { @@ -724,7 +749,9 @@ local charon = { s:bodies(sol, { mercury, + mercury_starports, venus, + venus_starports, earth, earth_starports, moon, diff --git a/data/systems/01_epsilon_eridani.lua b/data/world/systems/01_epsilon_eridani.lua similarity index 100% rename from data/systems/01_epsilon_eridani.lua rename to data/world/systems/01_epsilon_eridani.lua diff --git a/data/systems/02_local_stars.lua b/data/world/systems/02_local_stars.lua similarity index 100% rename from data/systems/02_local_stars.lua rename to data/world/systems/02_local_stars.lua diff --git a/data/systems/03_bright_stars.lua b/data/world/systems/03_bright_stars.lua similarity index 100% rename from data/systems/03_bright_stars.lua rename to data/world/systems/03_bright_stars.lua diff --git a/data/systems/custom/00_barnard_s_star.lua b/data/world/systems/custom/00_barnard_s_star.lua similarity index 100% rename from data/systems/custom/00_barnard_s_star.lua rename to data/world/systems/custom/00_barnard_s_star.lua diff --git a/data/systems/custom/01_werribee.lua b/data/world/systems/custom/01_werribee.lua similarity index 100% rename from data/systems/custom/01_werribee.lua rename to data/world/systems/custom/01_werribee.lua diff --git a/data/systems/custom/02_black_hole.lua b/data/world/systems/custom/02_black_hole.lua similarity index 100% rename from data/systems/custom/02_black_hole.lua rename to data/world/systems/custom/02_black_hole.lua diff --git a/data/systems/custom/03_achernar.lua b/data/world/systems/custom/03_achernar.lua similarity index 100% rename from data/systems/custom/03_achernar.lua rename to data/world/systems/custom/03_achernar.lua diff --git a/data/systems/custom/04_rondel.lua b/data/world/systems/custom/04_rondel.lua similarity index 100% rename from data/systems/custom/04_rondel.lua rename to data/world/systems/custom/04_rondel.lua diff --git a/data/systems/custom/05_trappist-1.lua b/data/world/systems/custom/05_trappist-1.lua similarity index 100% rename from data/systems/custom/05_trappist-1.lua rename to data/world/systems/custom/05_trappist-1.lua diff --git a/data/systems/custom/06_61virginis.lua b/data/world/systems/custom/06_61virginis.lua similarity index 100% rename from data/systems/custom/06_61virginis.lua rename to data/world/systems/custom/06_61virginis.lua diff --git a/data/systems/custom/07_1orionis.lua b/data/world/systems/custom/07_1orionis.lua similarity index 100% rename from data/systems/custom/07_1orionis.lua rename to data/world/systems/custom/07_1orionis.lua diff --git a/data/systems/custom/08_61cygni.lua b/data/world/systems/custom/08_61cygni.lua similarity index 100% rename from data/systems/custom/08_61cygni.lua rename to data/world/systems/custom/08_61cygni.lua diff --git a/data/systems/custom/09_delta_eridani.lua b/data/world/systems/custom/09_delta_eridani.lua similarity index 100% rename from data/systems/custom/09_delta_eridani.lua rename to data/world/systems/custom/09_delta_eridani.lua diff --git a/data/systems/custom/10_ayizan_lacaille8760.lua b/data/world/systems/custom/10_ayizan_lacaille8760.lua similarity index 100% rename from data/systems/custom/10_ayizan_lacaille8760.lua rename to data/world/systems/custom/10_ayizan_lacaille8760.lua diff --git a/data/systems/custom/11_noril_wolf1061.lua b/data/world/systems/custom/11_noril_wolf1061.lua similarity index 100% rename from data/systems/custom/11_noril_wolf1061.lua rename to data/world/systems/custom/11_noril_wolf1061.lua diff --git a/data/systems/custom/12_tau_ceti.lua b/data/world/systems/custom/12_tau_ceti.lua similarity index 100% rename from data/systems/custom/12_tau_ceti.lua rename to data/world/systems/custom/12_tau_ceti.lua diff --git a/data/systems/custom/13_fomalhaut.lua b/data/world/systems/custom/13_fomalhaut.lua similarity index 100% rename from data/systems/custom/13_fomalhaut.lua rename to data/world/systems/custom/13_fomalhaut.lua diff --git a/data/systems/custom/14_sirius.lua b/data/world/systems/custom/14_sirius.lua similarity index 100% rename from data/systems/custom/14_sirius.lua rename to data/world/systems/custom/14_sirius.lua diff --git a/data/systems/custom/15_ross154.lua b/data/world/systems/custom/15_ross154.lua similarity index 100% rename from data/systems/custom/15_ross154.lua rename to data/world/systems/custom/15_ross154.lua diff --git a/data/systems/custom/16_bathlight_55cancri.lua b/data/world/systems/custom/16_bathlight_55cancri.lua similarity index 100% rename from data/systems/custom/16_bathlight_55cancri.lua rename to data/world/systems/custom/16_bathlight_55cancri.lua diff --git a/data/systems/custom/17_delta_pavonis.lua b/data/world/systems/custom/17_delta_pavonis.lua similarity index 100% rename from data/systems/custom/17_delta_pavonis.lua rename to data/world/systems/custom/17_delta_pavonis.lua diff --git a/data/systems/custom/18_wolf359.lua b/data/world/systems/custom/18_wolf359.lua similarity index 100% rename from data/systems/custom/18_wolf359.lua rename to data/world/systems/custom/18_wolf359.lua diff --git a/data/systems/custom/19_starsend.lua b/data/world/systems/custom/19_starsend.lua similarity index 100% rename from data/systems/custom/19_starsend.lua rename to data/world/systems/custom/19_starsend.lua diff --git a/src/galaxy/GalaxyGenerator.cpp b/src/galaxy/GalaxyGenerator.cpp index 5cb015220f7..7b34690a065 100644 --- a/src/galaxy/GalaxyGenerator.cpp +++ b/src/galaxy/GalaxyGenerator.cpp @@ -73,7 +73,7 @@ RefCountedPtr GalaxyGenerator::Create(const std::string &name, Version v assert(name == "legacy"); // Once whe have have more, this will become an if switch // NB : The galaxy density image MUST be in BMP format due to OSX failing to load pngs the same as Linux/Windows - s_galaxy = RefCountedPtr(new DensityMapGalaxy(galgen, "galaxy_dense.bmp", 50000.0, 25000.0, 0.0, "factions", "systems")); + s_galaxy = RefCountedPtr(new DensityMapGalaxy(galgen, "galaxy_dense.bmp", 50000.0, 25000.0, 0.0, "world/factions", "world/systems")); s_galaxy->Init(); return s_galaxy; } else { diff --git a/src/lua/LuaSpaceStation.cpp b/src/lua/LuaSpaceStation.cpp index 3256acd76fc..47e5aa78117 100644 --- a/src/lua/LuaSpaceStation.cpp +++ b/src/lua/LuaSpaceStation.cpp @@ -1,11 +1,15 @@ // Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt +#include "Game.h" +#include "Json.h" #include "LuaConstants.h" #include "LuaObject.h" #include "LuaUtils.h" +#include "Pi.h" #include "Ship.h" #include "SpaceStation.h" +#include "galaxy/SystemBody.h" /* * Class: SpaceStation @@ -149,6 +153,118 @@ static int l_spacestation_get_nearby_traffic(lua_State *l) return 1; } +/* + * Method: GetPropertyDefaults + * + * Set properties that should exist for spacestations to defaults or + * values loaded from json files + * + * > station:GetPropertyDefaults() + * + * Returns: + * table of properties + * + * Availability: + * + * Sept 2021 + * + * Status: + * + * experimental + */ +static void storeprops(const char *propFile, std::map &keyvalues) +{ + Json preset; + preset = JsonUtils::LoadJsonDataFile(propFile); + if (preset.is_null()) + return; + + for (Json::iterator prop = preset.begin(); prop != preset.end(); ++prop) { + const std::string token = prop.key(); + if (token.empty()) { + continue; + } + /* if (!valid_token(token)) { continue; } */ + + Json val = prop.value()["value"]; + if (val.is_null() || val.is_string() == false) { + continue; + } + + // will overwrite existing keys + keyvalues[token] = val; + } +} + +static inline void stripnonalpha(const char *src, char *dst, const char *end) +{ + for (; *src && dst < end; src++) { + if ((*src >= 'A' && *src <= 'Z') || (*src >= 'a' && *src <= 'z')) + *dst++ = *src; + } + *dst = '\0'; +} + +// try to load attributes from world station predefinitions +// values from json may override default values +static int l_spacestation_get_property_defaults(lua_State *l) +{ + SpaceStation *station = static_cast(LuaObject::CheckFromLua(1)); + const SystemBody *body = station->GetSystemBody(); + const SystemPath sp = body->GetPath(); + std::map keyvalues; + + char propFile[100]; + char stationname[100]; + char sysname[100]; + char stationID[20]; // No known (or licensed) human settlements further out than 100 sectors outwards, + // a single byte (-128..127, or hex FF) for each dimension is enough for a license number + char sysstr[10]; + std::snprintf(stationID, 20, "SCC%02X%02X%02X%02X%02X", sp.sectorX, sp.sectorY, sp.sectorZ, sp.systemIndex, sp.bodyIndex); + std::strncpy(sysstr, &stationID[3], 9); + sysstr[8] = 0; + + keyvalues["stationID"] = stationID; + keyvalues["visualID"] = stationID; + + const char *stationlabel = station->GetLabel().c_str(); + stripnonalpha(stationlabel, stationname, &stationname[99]); + + RefCountedPtr s = Pi::game->GetGalaxy()->GetStarSystem(sp); + stripnonalpha(s->GetName().c_str(), sysname, &sysname[99]); + + if (s->GetFaction()->IsValid()) { + char facname[100]; + + stripnonalpha(s->GetFaction()->name.c_str(), facname, &facname[99]); + + std::snprintf(propFile, 100, "world/stations/%s.json", facname); + Output("Looking for station presets for '%s' in '%s'\n", stationlabel, propFile); + storeprops(propFile, keyvalues); + } + + // settings for the whole system + std::snprintf(propFile, 100, "world/stations/%s-%s.json", sysstr, sysname); + Output("Looking for station presets for '%s' in '%s'\n", stationlabel, propFile); + storeprops(propFile, keyvalues); + + // in the system specific directory, station names are unique enough + std::snprintf(propFile, 100, "world/stations/%s-%s/%s.json", sysstr, sysname, stationname); + Output("Looking for station presets for '%s' in '%s'\n", stationlabel, propFile); + storeprops(propFile, keyvalues); + + std::snprintf(&propFile[0], 100, "world/stations/%s-%s.json", stationID, stationname); + Output("Looking for station presets for '%s' in '%s'\n", stationlabel, propFile); + storeprops(propFile, keyvalues); + + // push whatever we collected into a lua table and return it + lua_newtable(l); + for (auto kv : keyvalues) { + pi_lua_settable(l, kv.first.c_str(), kv.second.c_str()); + } + return 1; +} + /* * Attribute: numDocks * @@ -218,17 +334,18 @@ void LuaObject::RegisterClass() const char *l_parent = "ModelBody"; static const luaL_Reg l_methods[] = { - { "GetGroundPosition", l_spacestation_get_ground_position }, - { "RequestDockingClearance", l_spacestation_request_docking_clearance }, { "GetAssignedBayNumber", l_spacestation_get_assigned_bay_number }, + { "GetGroundPosition", l_spacestation_get_ground_position }, { "GetNearbyTraffic", l_spacestation_get_nearby_traffic }, + { "GetPropertyDefaults", l_spacestation_get_property_defaults }, + { "RequestDockingClearance", l_spacestation_request_docking_clearance }, { 0, 0 } }; static luaL_Reg l_attrs[] = { - { "numDocks", l_spacestation_attr_num_docks }, { "isGroundStation", l_spacestation_attr_is_ground_station }, + { "numDocks", l_spacestation_attr_num_docks }, { "numShipsDocked", l_spacestation_attr_num_ships_docked }, { 0, 0 }