Skip to content

Commit

Permalink
[scenario_20] Work around custom ships missing from database (#1869)
Browse files Browse the repository at this point in the history
Exuari transports, freighters, and shuttles use custom ship type
names, which breaks DB links from the Science radar. (#1686)

Work around this by adding a function that copies the base ship
template's data to a new entry with the same ship type name.
  • Loading branch information
oznogon authored Apr 12, 2023
1 parent 9b4e050 commit 4136de8
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions scripts/scenario_20_training1.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,37 @@ function createExuariWeakInterceptor()
return CpuShip():setFaction("Exuari"):setTemplate("Dagger"):setBeamWeapon(0, 0, 0, 0, 0.1, 0.1)
end

function copyShipDBEntry(base_ship_template,new_ship)
ship_db = queryScienceDatabase("Ships")

-- Search each Ships class's entry for the base ship
for k,entry in ipairs(ship_db:getEntries())
do
base_ship_entry = entry:getEntryByName(base_ship_template)
if base_ship_entry ~= nil
then
break;
end
end

-- Create a new Exuari DB entry for the new ship
exuari_ship_db = ship_db:getEntryByName("Exuari")
new_ship_entry = exuari_ship_db:addEntry(new_ship:getTypeName())

-- Copy base ship data to the new entry
for k,v in pairs(base_ship_entry:getKeyValues())
do
new_ship_entry:setKeyValue(k,v)
end

new_ship_entry:setImage(base_ship_entry:getImage())
new_ship_entry:setLongDescription(base_ship_entry:getLongDescription())
-- Impossible without a getModelName() function
-- new_ship_entry:setModelName(base_ship_entry:getModelName())

return new_ship_entry
end

function createExuariWeakBomber()
return CpuShip():setFaction("Exuari"):setTemplate("Gunner"):setWeaponTubeCount(0):setWeaponStorageMax("HVLI", 0):setWeaponStorage("HVLI", 0):setBeamWeapon(0, 0, 0, 0, 0.1, 0.1)
end
Expand All @@ -36,14 +67,34 @@ function createExuariTransport()
return CpuShip():setFaction("Exuari"):setTemplate("Personnel Freighter 1"):setTypeName("Exuari transport")
end

-- Create a dummy ship to populate the ScienceDatabase entry, then destroy it
init_transport = createExuariTransport()
init_transport_entry = copyShipDBEntry("Personnel Freighter 1", init_transport)
-- init_transport_entry:setLongDescription("The Exuari transport transports Exuari")
init_transport_entry:setModelDataName("transport_1_1") -- manually entered from finding Personnel Freighter in shiptemplates
init_transport:destroy()

function createExuariFreighter()
return CpuShip():setFaction("Exuari"):setTemplate("Goods Freighter 5"):setTypeName("Exuari freighter")
end

-- Create a dummy ship to populate the ScienceDatabase entry, then destroy it
init_transport = createExuariFreighter()
init_transport_entry = copyShipDBEntry("Goods Freighter 5", init_transport)
-- init_transport_entry:setLongDescription("The Exuari transport transports Exuari")
init_transport_entry:setModelDataName("transport_2_5") -- manually entered from finding Goods Freighter in shiptemplates
init_transport:destroy()

function createExuariShuttle()
return CpuShip():setFaction("Exuari"):setTemplate("Racer"):setTypeName("Exuari shuttle"):setWarpDrive(false):setBeamWeapon(0, 0, 355, 0, 0.1, 0.1):setBeamWeapon(1, 0, 355, 0, 0.1, 0.1)
end

-- Create a dummy ship to populate the ScienceDatabase entry, then destroy it
init_transport = createExuariShuttle()
init_transport_entry = copyShipDBEntry("Racer", init_transport)
-- init_transport_entry:setLongDescription("The Exuari transport transports Exuari")
init_transport_entry:setModelDataName("small_frigate_1") -- manually entered from finding Racer in shiptemplates
init_transport:destroy()

-- init
function init()
Expand Down

2 comments on commit 4136de8

@daid-tinyci
Copy link

@daid-tinyci daid-tinyci bot commented on 4136de8 Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TinyCI build failure:

[cmake .. -G Ninja -DSERIOUS_PROTON_DIR=../../SeriousProton -DCMAKE_TOOLCHAIN_FILE=../cmake/android.toolchain -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI=arm64-v8a] returned [1]:

  Could not find toolchain file:

  /data/tinyci_build/daid/EmptyEpsilon/cmake/android/sdk/ndk/23.2.8568313/build/cmake/android.toolchain.cmake

Call Stack (most recent call first):

  CMakeLists.txt:6 (project)





CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage

CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

-- Configuring incomplete, errors occurred!

No such file or directory

CMake Error: Generator: execution of make failed. Make command was: "" "install"

CMake Error at cmake/android.toolchain:193 (include):

  include could not find load file:



    /data/tinyci_build/daid/EmptyEpsilon/cmake/android/sdk/ndk/23.2.8568313/build/cmake/android.toolchain.cmake

Call Stack (most recent call first):

  _build_android64/CMakeFiles/3.13.4/CMakeSystem.cmake:6 (include)

  CMakeLists.txt:36 (project)





-- The CXX compiler identification is GNU 8.3.0

-- The C compiler identification is GNU 8.3.0

-- Check for working CXX compiler: /usr/bin/c++

Warning: Failed to read or create install properties file.

CMake Error at /data/tinyci_build/daid/EmptyEpsilon/cmake/android.toolchain:40 (message):

  Failed to execute:

  COMMAND;/data/tinyci_build/daid/EmptyEpsilon/cmake/android/sdk/cmdline-tools/bin/sdkmanager;--sdk_root=/data/tinyci_build/daid/EmptyEpsilon/cmake/android/sdk;ndk\;23.2.8568313

Call Stack (most recent call first):

  /data/tinyci_build/daid/EmptyEpsilon/cmake/android.toolchain:66 (execute_process_ex)

  /data/tinyci_build/daid/EmptyEpsilon/_build_android64/CMakeFiles/3.13.4/CMakeSystem.cmake:6 (include)

  /data/tinyci_build/daid/EmptyEpsilon/_build_android64/CMakeFiles/CMakeTmp/CMakeLists.txt:3 (project)





CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

CMake Error at /usr/share/cmake-3.13/Modules/CMakeTestCXXCompiler.cmake:30 (try_compile):

  Failed to configure test project build system.

Call Stack (most recent call first):

  CMakeLists.txt:36 (project)





Loading package information...                                                  
Loading local repository...                                                     
[                                       ] 3% Loading local repository...        
[                                       ] 3% Fetch remote repository...         
[=                                      ] 3% Fetch remote repository...         
[=                                      ] 4% Fetch remote repository...         
[=                                      ] 5% Fetch remote repository...         
[==                                     ] 5% Fetch remote repository...         
[==                                     ] 6% Fetch remote repository...         
[==                                     ] 7% Fetch remote repository...         
[==                                     ] 7% Computing updates...               
[===                                    ] 8% Computing updates...               
[===                                    ] 10% Computing updates...              
[===                                    ] 10% Installing NDK (Side by side) 23.2
                                                                                
[===                                    ] 10% Installing NDK (Side by side) 23.2
-- Configuring incomplete, errors occurred!

See also "/data/tinyci_build/daid/EmptyEpsilon/_build_android64/CMakeFiles/CMakeOutput.log".

@daid-tinyci
Copy link

@daid-tinyci daid-tinyci bot commented on 4136de8 Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TinyCI build failure:

[ninja -j 2 package] returned [1]:


[2/168] Building CXX object CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o

FAILED: CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o 

/usr/bin/c++   -I../src -Iinclude -I/data/tinyci_build/daid/SeriousProton/src -ISeriousProton/include -I/usr/include/SDL2 -I/usr/include/freetype2 -I/data/tinyci_build/daid/SeriousProton/libs/Box2D/.. -I/data/tinyci_build/daid/SeriousProton/libs/glad -I/data/tinyci_build/daid/SeriousProton/libs/lua/.. -I_deps/glm-src/glm/.. -I_deps/basis-src -I/data/tinyci_build/daid/SeriousProton/libs/libopus/include -I_deps/meshoptimizer-src/src -O2 -g -DNDEBUG   -fdiagnostics-color -g1 -O3 -flto -funsafe-math-optimizations -Wall -Wextra -Woverloaded-virtual -Wdouble-promotion -Wsuggest-override -Werror=return-type -Wno-unused-parameter -Wno-unused-but-set-parameter -std=gnu++17 -MD -MT CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o -MF CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o.d -o CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o -c ../src/gui/hotkeyConfig.cpp

In file included from ../src/shipTemplate.h:13,

                 from ../src/gui/hotkeyConfig.cpp:4:

../src/missileWeaponData.h:25:41: error: expected constructor, destructor, or type conversion before ‘;’ token

 REGISTER_MULTIPLAYER_ENUM(EMissileSizes);

                                         ^

In file included from ../src/gui/hotkeyConfig.cpp:4:

../src/shipTemplate.h:209:35: error: expected constructor, destructor, or type conversion before ‘;’ token

 REGISTER_MULTIPLAYER_ENUM(ESystem);

                                   ^

[3/168] Building CXX object CMakeFiles/EE_GuiLIB.dir/src/gui/debugRenderer.cpp.o

ninja: build stopped: subcommand failed.

Please sign in to comment.