Skip to content

Commit

Permalink
Add mod to multiply civilization bonuses. Refactor patches into multi…
Browse files Browse the repository at this point in the history
…ple source files. Refactor genieutils patching method to use a patchfile instead of sed
  • Loading branch information
FranciscoDA committed Jan 26, 2021
1 parent e47a6b7 commit 857db09
Show file tree
Hide file tree
Showing 26 changed files with 1,196 additions and 796 deletions.
1 change: 1 addition & 0 deletions .clang_complete
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-I./genieutils/include
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ build
*.exe
*.out
*.app

# vs code
.vscode
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++")
add_subdirectory(genieutils EXCLUDE_FROM_ALL)
include_directories(
"genieutils/include"
"."
)
add_executable(create-data-mod create-data-mod.cpp patches.cpp ids.h)
add_executable(
create-data-mod
create-data-mod.cpp
patches/community_games.cpp
patches/exploding_villagers.cpp
patches/flying_dutchman.cpp
patches/kidnap.cpp
patches/no_wall.cpp
patches/random_costs.cpp
patches/duplicate_techs.cpp
patches/duplicate_civ_bonuses.cpp
ids.h
)
set_property(TARGET create-data-mod PROPERTY CXX_STANDARD 17)
target_link_libraries(create-data-mod genieutils)
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Just install stuff until it stops complaining I guess, sorry.
```sh
git clone --recurse-submodules https://github.com/SiegeEngineers/auto-mods.git
cd auto-mods
./patchGenieutils.sh
patch -d genieutils <genieutils.patch
mkdir build
cd build
cmake ..
Expand Down Expand Up @@ -56,6 +56,8 @@ Where <mod-identifier> is one of the following, or multiple of the following joi
x3
x9
x256
x3-civ-bonus
x9-civ-bonus
```

For example, in order to patch the current dat file with the Flying Dutchman modifications, one might execute
Expand Down
20 changes: 19 additions & 1 deletion create-data-mod.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
#include "genie/dat/DatFile.h"
#include "patches.h"

#include "patches/community_games.h"
#include "patches/duplicate_civ_bonuses.h"
#include "patches/duplicate_techs.h"
#include "patches/exploding_villagers.h"
#include "patches/flying_dutchman.h"
#include "patches/kidnap.h"
#include "patches/no_wall.h"
#include "patches/random_costs.h"

#include <string>


using namespace std;
const char *const COMMUNITY_GAMES = "community-games";
const char *const EXPLODING_VILLAGERS = "exploding-villagers";
Expand All @@ -14,6 +24,8 @@ const char *const RANDOM_UNIT_COSTS = "random-unit-costs";
const char *const X_256_TECH = "x256";
const char *const X_3_TECH = "x3";
const char *const X_9_TECH = "x9";
const char *const X_3_CIV_BONUS = "x3-civ-bonus";
const char *const X_9_CIV_BONUS = "x9-civ-bonus";

vector<string> getModIdentifiers(char *const *argv);

Expand All @@ -38,6 +50,8 @@ int main(int argc, char **argv) {
cout << " " << X_3_TECH << endl;
cout << " " << X_9_TECH << endl;
cout << " " << X_256_TECH << endl;
cout << " " << X_3_CIV_BONUS << endl;
cout << " " << X_9_CIV_BONUS << endl;
return 1;
}

Expand Down Expand Up @@ -86,6 +100,10 @@ void applyModifications(genie::DatFile *df, const string &modIdentifier) {
duplicateTechs(df, 9);
} else if (X_256_TECH == modIdentifier) {
duplicateTechs(df, 256);
} else if (X_3_CIV_BONUS == modIdentifier) {
multiplyCivilizationBonuses(df, 3);
} else if (X_9_CIV_BONUS == modIdentifier) {
multiplyCivilizationBonuses(df, 9);
} else {
cout << "Unknown mod identifier: '" << modIdentifier << "'" << endl;
}
Expand Down
30 changes: 30 additions & 0 deletions genieutils.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b4b3abb..760a912 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,11 +12,11 @@ project(genieutils)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/)
#set(CMAKE_CXX_FLAGS "-std=gnu++0x")

-#set(Boost_USE_STATIC_LIBS ON)
+set(Boost_USE_STATIC_LIBS ON)
#set(Boost_USE_STATIC_RUNTIME ON)
set(Boost_USE_MULTITHREADED ON)

-find_library(iconv REQUIRED)
+find_library(iconv iconv REQUIRED)

# dependencies:

@@ -158,9 +158,9 @@ set(BINCOMP_SRC src/tools/bincompare/bincomp.cpp
# Executeable:
#------------------------------------------------------------------------------#

-add_library(${Genieutils_LIBRARY} SHARED ${FILE_SRC} ${LANG_SRC} ${DAT_SRC}
+add_library(${Genieutils_LIBRARY} STATIC ${FILE_SRC} ${LANG_SRC} ${DAT_SRC}
${RESOURCE_SRC} ${UTIL_SRC} ${SCRIPT_SRC} )
-target_link_libraries(${Genieutils_LIBRARY} ${ZLIB_LIBRARIES} ${Boost_LIBRARIES} ${ICONV_LIBRARIES})
+target_link_libraries(${Genieutils_LIBRARY} ${Boost_LIBRARIES} ${ZLIB_LIBRARIES} ${ICONV_LIBRARIES})

#add_executable(main main.cpp)
#target_link_libraries(main ${Genieutils_LIBRARY})
33 changes: 33 additions & 0 deletions ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,45 @@ static const int TYPE_FOOD = 0;
static const int TYPE_WOOD = 1;
static const int TYPE_STONE = 2;
static const int TYPE_GOLD = 3;
static const int TYPE_RESEARCH_COST_MODIFIER = 85;
static const int TYPE_RESEARCH_TIME_MODIFIER = 86;
static const int TYPE_GOLD_MINING_PRODUCTIVITY = 47;
static const int TYPE_STONE_MINING_PRODUCTIVITY = 79;
static const int TYPE_WOOD_CHOPPING_PRODUCTIVITY = 189;
static const int TYPE_FOOD_GATHERING_PRODUCTIVITY = 190;
static const int TYPE_FOOD_HERDING_PRODUCTIVITY = 216;

static const int ID_SCOUT = 448;
static const int ID_EAGLE_SCOUT = 751;
static const int ID_MADARASH_MONK = 412;
static const int ACTION_KIDNAP_UNIT = 135;
static const int ACTION_LOOT = 122;
static const int CLASS_CIVILIAN = 4;
static const int CLASS_BUILDING = 3;

static const int ID_EMPTY_TC_ANNEX = 890;

static const int EFFECT_ID_HUNS_100_WOOD = 214;
static const int EFFECT_ID_PERSIANS_TC_HITPOINTS = 340;
static const int EFFECT_ID_PERSIANS_DOCK_HITPOINTS = 347;
static const int EFFECT_ID_PERSIANS_KAMANDARAN = 547;
static const int EFFECT_ID_BYZANTINE_BUILDING_BONUS_HP_DARK = 283;
static const int EFFECT_ID_BYZANTINE_BUILDING_BONUS_HP_FEUDAL = 429;
static const int EFFECT_ID_BYZANTINE_BUILDING_BONUS_HP_CASTLE = 430;
static const int EFFECT_ID_BYZANTINE_BUILDING_BONUS_HP_IMPERIAL = 431;
static const int EFFECT_ID_MAYAN_TECH_TREE = 449;
static const int EFFECT_ID_SARACEN_MARKET_BONUS = 354;
static const int EFFECT_ID_SARACEN_MADARASH = 545;


static const int COMMAND_RESOURCE_MODIFIER = 1;
static const int COMMAND_UPGRADE_UNIT = 3;
static const int COMMAND_ATTRIBUTE_MODIFIER = 4;
static const int COMMAND_ATTRIBUTE_MULTIPLIER = 5;
static const int COMMAND_TEAM_ATTRIBUTE_MODIFIER = 10;
static const int COMMAND_TECH_COST_MODIFIER = 101;
static const int COMMAND_DISABLE_TECH = 102;
static const int COMMAND_TECH_TIME_MODIFIER = 103;


#endif //CREATE_DATA_MOD_IDS_H
5 changes: 0 additions & 5 deletions patchGenieutils.sh

This file was deleted.

Loading

0 comments on commit 857db09

Please sign in to comment.