Skip to content

Commit

Permalink
Adds collection of patches to remove hardcoded properties from game t…
Browse files Browse the repository at this point in the history
…ypes.
  • Loading branch information
CCHyper committed Nov 24, 2022
1 parent af648a5 commit 41f9d81
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions src/vinifera/vinifera_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,81 @@
#include "asserthandler.h"
#include <string>

#include "hooker.h"
#include "hooker_macros.h"


static DynamicVectorClass<Wstring> ViniferaSearchPaths;


/**
* Should certain hardcoded properties for game types be removed?
*/
static bool Vinifera_RemoveHardcodedTypeProperties = false;


/**
* This function patches out various hardcoded properties for game types.
*
* @author: CCHyper
*/
static void Vinifera_Remove_Hardcoded_Type_Properties()
{
/**
* Removes hardcoded "Strength=1200" from ObjectType with the name "HMEC".
*/
Patch_Byte_Range(0x00588C5F, 0x90, 6);
Patch_Jump(0x00588C6B, 0x00588C7E);

/**
* Removes hardcoded values;
* "GuardRange=5"
* "Cost=250"
*
* from TechnoTypes with the names "GAFSDF", "GAWALL" and/or "NAWALL"
*/
Patch_Jump(0x0063BAC8, 0x0063BB6E);
Patch_Jump(0x0063C8E2, 0x0063C988);

/**
* Removes hardcoded "Explodes=yes" from TechnoType with the name "E2".
*/
Patch_Byte_Range(0x0063BB82, 0x90, 6);
Patch_Jump(0x0063BB8E, 0x0063BBA1);

/**
* Removes hardcoded "BaseNormal=no" from BuildingTypes with the names "NAFNCE" and/or "NAPOST"
*/
Patch_Byte_Range(0x00440C38, 0x90, 6);
Patch_Jump(0x00440C44, 0x00440C69);

/**
* Removes hardcoded values;
* "ProneDamage=0.3"
* "Verses=0.4, 0.85, 0.68, 0.35, 0.35"
*
* from WarheadType with the name "ARTYHE". These hardcoded properties
* only applied to multiplayer games, and not the singleplayer campaign.
*/
Patch_Jump(0x0066F4C6, 0x0066F566);

/**
* Removes hardcoded values;
* "ROF=150"
* "Damage=115"
*
* from WeaponType with the name "155mm". These hardcoded properties
* only applied to multiplayer games, and not the singleplayer campaign.
*/
Patch_Jump(0x00681250, 0x0068129D);

/**
* Removes hardcoded "Power=17" from TiberiumType "Vinifera".
*/
Patch_Jump(0x00644DB8, 0x00644DD4);
}


/**
* Load any Vinifera settings that provide overrides.
*
Expand Down Expand Up @@ -121,6 +192,12 @@ bool Vinifera_Load_INI()
}
}

/**
* The following are just various values loaded that effect the initialisation
* of the game and Vinifera.
*/
Vinifera_RemoveHardcodedTypeProperties = ini.Get_Bool("General", "RemoveHardcodedTypeProperties", Vinifera_RemoveHardcodedTypeProperties);

return true;
}

Expand Down Expand Up @@ -591,6 +668,16 @@ bool Vinifera_Startup()
//CnCNet5::IsActive = true; // Enable when new Client system is implemented.
#endif

/**
* Patching these is a little awkward. Ideally this should be done before the
* game intialises, but we need to do it after the search paths have been set
* otherwise we won't be able to support TS Client setups with Vinifera.ini
* placed in a additional search path.
*/
if (Vinifera_RemoveHardcodedTypeProperties) {
Vinifera_Remove_Hardcoded_Type_Properties();
}

return true;
}

Expand Down

0 comments on commit 41f9d81

Please sign in to comment.