Skip to content

Conversation

jerethk
Copy link
Contributor

@jerethk jerethk commented Oct 30, 2024

Externalise projectile and effect (explosions) data to JSONs

Data will be loaded from the Jsons when entering DF.
Mods can override by supplying their own Jsons.

@jerethk jerethk marked this pull request as draft October 30, 2024 06:09
@jerethk jerethk marked this pull request as ready for review October 30, 2024 06:10
@jerethk jerethk marked this pull request as draft October 30, 2024 06:11
@jerethk jerethk force-pushed the EXTERNALISE_DATA branch 3 times, most recently from ab877c9 to 2bcb5f5 Compare November 5, 2024 11:43
@jerethk jerethk marked this pull request as ready for review November 5, 2024 11:52
@jerethk jerethk marked this pull request as draft November 5, 2024 11:52
@jerethk jerethk marked this pull request as ready for review November 5, 2024 15:52
@jerethk
Copy link
Contributor Author

jerethk commented Nov 5, 2024

I wonder if you could take a look at this please @luciusDXL , @kevinfoley
I've double and triple-checked that I copied all the values across accurately...!

@jerethk jerethk changed the title Weapon data externalisation (DRAFT) Weapon data externalisation Nov 9, 2024
@luciusDXL luciusDXL merged commit 051e4df into luciusDXL:master Nov 19, 2024
1 check passed
@mlauss2
Copy link
Contributor

mlauss2 commented Nov 19, 2024

Ok On linux I have no projectiles; ExternalData/projectiles.json is available but:

024-Nov-19 13:49:19 - [MemoryRegion] Allocated new memory block in region 'game' - new size is 2 blocks, total size is '16777216'
2024-Nov-19 13:49:19 - [Error : readDirectory] opendir(/home/mano/games/tfme/logics/) failed with 2

2024-Nov-19 13:49:19 - [Error : readDirectory] opendir(/home/mano/games/tfme/LFD/logics/) failed with 2

2024-Nov-19 13:49:19 - [Error : readDirectory] opendir(/home/mano/.local/share/TheForceEngine/Mods/logics/) failed with 2

2024-Nov-19 13:49:19 - [Error : readDirectory] opendir(/home/mano/dev/sf-cvs/tfe-master.git/__build/Mods/logics/) failed with 2

2024-Nov-19 13:49:19 - [Error : readDirectory] opendir(/home/mano/dev/sf-cvs/tfe-master.git/__build/Mods/TFE/AdjustableHud/logics/) failed with 2

2024-Nov-19 13:49:19 - [LOGICS] Parsing logic JSON(s)
2024-Nov-19 13:49:19 - [EXTERNAL_DATA] Loading projectile data
2024-Nov-19 13:49:19 - [Error : EXTERNAL_DATA] Warning: Projectile data is incomplete. PROJECTILES.JSON may have been altered. Projectiles may not behave as expected.
2024-Nov-19 13:49:19 - [EXTERNAL_DATA] Loading effects data
2024-Nov-19 13:49:19 - [Error : EXTERNAL_DATA] Warning: Effect data is incomplete. EFFECTS.JSON may have been altered. Effects may not behave as expected.

i'll try to fix it..

@mlauss2
Copy link
Contributor

mlauss2 commented Nov 19, 2024

This is required to fix non-windows:

diff --git a/TheForceEngine/TFE_ExternalData/weaponExternal.cpp b/TheForceEngine/TFE_ExternalData/weaponExternal.cpp
index 2b396cd7..151b43c1 100644
--- a/TheForceEngine/TFE_ExternalData/weaponExternal.cpp
+++ b/TheForceEngine/TFE_ExternalData/weaponExternal.cpp
@@ -56,7 +56,7 @@ namespace TFE_ExternalData
        {
                const char* programDir = TFE_Paths::getPath(PATH_PROGRAM);
                char extDataFile[TFE_MAX_PATH];
-               sprintf(extDataFile, "%sExternalData\\projectiles.json", programDir);
+               sprintf(extDataFile, "%sExternalData/projectiles.json", programDir);
 
                TFE_System::logWrite(LOG_MSG, "EXTERNAL_DATA", "Loading projectile data");
                FileStream file;
@@ -148,7 +148,7 @@ namespace TFE_ExternalData
        {
                const char* programDir = TFE_Paths::getPath(PATH_PROGRAM);
                char extDataFile[TFE_MAX_PATH];
-               sprintf(extDataFile, "%sExternalData\\effects.json", programDir);
+               sprintf(extDataFile, "%sExternalData/effects.json", programDir);
 
                TFE_System::logWrite(LOG_MSG, "EXTERNAL_DATA", "Loading effects data");
                FileStream file;

@jerethk
Copy link
Contributor Author

jerethk commented Nov 19, 2024

This is required to fix non-windows:

diff --git a/TheForceEngine/TFE_ExternalData/weaponExternal.cpp b/TheForceEngine/TFE_ExternalData/weaponExternal.cpp
index 2b396cd7..151b43c1 100644
--- a/TheForceEngine/TFE_ExternalData/weaponExternal.cpp
+++ b/TheForceEngine/TFE_ExternalData/weaponExternal.cpp
@@ -56,7 +56,7 @@ namespace TFE_ExternalData
        {
                const char* programDir = TFE_Paths::getPath(PATH_PROGRAM);
                char extDataFile[TFE_MAX_PATH];
-               sprintf(extDataFile, "%sExternalData\\projectiles.json", programDir);
+               sprintf(extDataFile, "%sExternalData/projectiles.json", programDir);
 
                TFE_System::logWrite(LOG_MSG, "EXTERNAL_DATA", "Loading projectile data");
                FileStream file;
@@ -148,7 +148,7 @@ namespace TFE_ExternalData
        {
                const char* programDir = TFE_Paths::getPath(PATH_PROGRAM);
                char extDataFile[TFE_MAX_PATH];
-               sprintf(extDataFile, "%sExternalData\\effects.json", programDir);
+               sprintf(extDataFile, "%sExternalData/effects.json", programDir);
 
                TFE_System::logWrite(LOG_MSG, "EXTERNAL_DATA", "Loading effects data");
                FileStream file;

Thanks @mlauss2
Appreciate you finding these bugs and working out the solution!

@mlauss2
Copy link
Contributor

mlauss2 commented Nov 20, 2024

@luciusDXL , @jerethk : One last minor thing: Please add this so that the ExternalData/ directory is also installed on cmake targets:

index effc0519..2712616a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,6 +74,7 @@ if(ENABLE_TFE)
                # the necessary support file directories into the build env.
                execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Captions)
                execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Documentation)
+               execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/ExternalData)
                execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Fonts)
                execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Mods)
                execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Shaders)
@@ -130,6 +131,7 @@ if(ENABLE_TFE)
        install(DIRECTORY
                "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Captions"
                "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Documentation"
+               "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/ExternalData"
                "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/UI_Text"
                "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/UI_Images"
                "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/EditorDef"

Also I suggest you rename the files in ExternalData; prefix them with the game that they apply to, something like: tfe_df_projectiles.json tfe_df_effects.json so that it's clear is a tfe addon for df for example.

@jerethk
Copy link
Contributor Author

jerethk commented Nov 20, 2024

@luciusDXL , @jerethk : One last minor thing: Please add this so that the ExternalData/ directory is also installed on cmake targets:

index effc0519..2712616a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,6 +74,7 @@ if(ENABLE_TFE)
                # the necessary support file directories into the build env.
                execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Captions)
                execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Documentation)
+               execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/ExternalData)
                execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Fonts)
                execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Mods)
                execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Shaders)
@@ -130,6 +131,7 @@ if(ENABLE_TFE)
        install(DIRECTORY
                "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Captions"
                "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Documentation"
+               "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/ExternalData"
                "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/UI_Text"
                "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/UI_Images"
                "${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/EditorDef"

Also I suggest you rename the files in ExternalData; prefix them with the game that they apply to, something like: tfe_df_projectiles.json tfe_df_effects.json so that it's clear is a tfe addon for df for example.

thanks again @mlauss2
I might roll these changes into the next one I'm doing, which is to externalise the pickup items data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants