Skip to content

Commit

Permalink
[TD] Implements initial [General] rules.ini support.
Browse files Browse the repository at this point in the history
Implements features previously controlled by SpecialClass that RA has in rules.ini.
Attempts to match changes to RA that implement remaster MP options.
  • Loading branch information
OmniBlade committed Dec 17, 2021
1 parent acecf63 commit 8ffc5ce
Show file tree
Hide file tree
Showing 17 changed files with 204 additions and 94 deletions.
4 changes: 2 additions & 2 deletions tiberiandawn/bdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4535,7 +4535,7 @@ int BuildingTypeClass::Full_Name(void) const
if (::Scenario == 3 && Type == STRUCT_MISSION) {
return (TXT_PRISON);
}
if (!IsNominal || Special.IsNamed || IsWall || Debug_Map || Type == STRUCT_V23 || Type == STRUCT_V30
if (!IsNominal || Rule.IsNamed || IsWall || Debug_Map || Type == STRUCT_V23 || Type == STRUCT_V30
|| Type == STRUCT_MISSION || Type == STRUCT_BIO_LAB) {
return (TechnoTypeClass::Full_Name());
}
Expand Down Expand Up @@ -4567,7 +4567,7 @@ int BuildingTypeClass::Raw_Cost(void) const

int BuildingTypeClass::Cost_Of(void) const
{
if (Special.IsSeparate && Type == STRUCT_HELIPAD) {
if (Rule.IsSeparate && Type == STRUCT_HELIPAD) {
return (Raw_Cost());
}

Expand Down
18 changes: 9 additions & 9 deletions tiberiandawn/building.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ void BuildingClass::AI(void)
** the loop.
*/
if (Fetch_Stage() == ctrl->Start + ctrl->Count - 1
|| (Special.IsMCVDeploy && *this == STRUCT_CONST && Mission == MISSION_DECONSTRUCTION
|| (Is_MCV_Deploy() && *this == STRUCT_CONST && Mission == MISSION_DECONSTRUCTION
&& Fetch_Stage() == (42 - 19))) {
IsReadyToCommence = true;
}
Expand Down Expand Up @@ -1672,7 +1672,7 @@ ResultType BuildingClass::Take_Damage(int& damage, int distance, WarheadType war
if (*this != STRUCT_SAM && !House->Is_Ally(source) && Class->Primary != WEAPON_NONE
&& (!Target_Legal(TarCom) || !In_Range(TarCom))) {

if (source->What_Am_I() != RTTI_AIRCRAFT && (!House->IsHuman || Special.IsSmartDefense)) {
if (source->What_Am_I() != RTTI_AIRCRAFT && (!House->IsHuman || Rule.IsSmartDefense)) {
Assign_Target(source->As_Target());
} else {

Expand Down Expand Up @@ -3160,7 +3160,7 @@ ActionType BuildingClass::What_Action(CELL cell) const
Validate();
ActionType action = TechnoClass::What_Action(cell);

if (action == ACTION_MOVE && (*this != STRUCT_CONST || !Special.IsMCVDeploy)) {
if (action == ACTION_MOVE && (*this != STRUCT_CONST || !Is_MCV_Deploy())) {
action = ACTION_NONE;
}

Expand Down Expand Up @@ -4079,7 +4079,7 @@ int BuildingClass::Mission_Deconstruction(void)
** members leaving is equal to the unrecovered cost of the building
** divided by 100 (the typical cost of a minigunner infantryman).
*/
if (!Target_Legal(ArchiveTarget) || !Special.IsMCVDeploy || *this != STRUCT_CONST) {
if (!Target_Legal(ArchiveTarget) || !Is_MCV_Deploy() || *this != STRUCT_CONST) {
int divisor = 200;
if (IsCaptured)
divisor *= 2;
Expand Down Expand Up @@ -4169,7 +4169,7 @@ int BuildingClass::Mission_Deconstruction(void)
** Construction yards that deconstruct, really just revert back
** to an MCV.
*/
if (Target_Legal(ArchiveTarget) && Special.IsMCVDeploy && *this == STRUCT_CONST && House->IsHuman) {
if (Target_Legal(ArchiveTarget) && Is_MCV_Deploy() && *this == STRUCT_CONST && House->IsHuman) {
ScenarioInit++;
UnitClass* unit = new UnitClass(UNIT_MCV, House->Class->House);
ScenarioInit--;
Expand Down Expand Up @@ -4495,10 +4495,10 @@ int BuildingClass::Mission_Harvest(void)
/*
** Force any bib squaters to scatter.
*/
bool old = Special.IsScatter;
Special.IsScatter = true;
bool old = Rule.IsScatter;
Rule.IsScatter = true;
Map[Adjacent_Cell(Coord_Cell(Center_Coord()), DIR_SW)].Incoming(0, true);
Special.IsScatter = old;
Rule.IsScatter = old;

FootClass* techno = Attached_Object();
if (techno) {
Expand Down Expand Up @@ -5444,7 +5444,7 @@ CELL BuildingClass::Find_Exit_Cell(TechnoClass const* techno) const
bool BuildingClass::Can_Player_Move(void) const
{
Validate();
return (*this == STRUCT_CONST && (Mission == MISSION_GUARD) && Special.IsMCVDeploy);
return (*this == STRUCT_CONST && (Mission == MISSION_GUARD) && Is_MCV_Deploy());
}

/***********************************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion tiberiandawn/cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ void CellClass::Incoming(COORDINATE threat, bool forced, bool nokidding)
/*
** Special check to make sure that friendly units never scatter.
*/
if (nokidding || Special.IsScatter || (object->Is_Techno() && !((TechnoClass*)object)->House->IsHuman)) {
if (nokidding || Rule.IsScatter || (object->Is_Techno() && !((TechnoClass*)object)->House->IsHuman)) {
if (object->What_Am_I() == RTTI_INFANTRY) {
object->Scatter(threat, forced, nokidding);
} else {
Expand Down
8 changes: 5 additions & 3 deletions tiberiandawn/dllinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,14 +724,11 @@ extern "C" __declspec(dllexport) bool __cdecl CNC_Set_Multiplayer_Data(int scena
MPlayerSolo = game_options.MPlayerSolo; // 1 = allows a single-player net game
MPlayerUnitCount = game_options.MPlayerUnitCount; // # units for non-base multiplayer scenarios

Special.IsMCVDeploy = game_options.IsMCVDeploy;
Special.IsVisceroids = game_options.SpawnVisceroids;
Special.IsCaptureTheFlag = game_options.CaptureTheFlag;
Special.IsEarlyWin = game_options.DestroyStructures;
Special.ModernBalance = game_options.ModernBalance;

Rule.AllowSuperWeapons = game_options.EnableSuperweapons; // Are superweapons available

if (MPlayerTiberium) {
Special.IsTGrowth = 1;
Special.IsTSpread = 1;
Expand All @@ -740,6 +737,11 @@ extern "C" __declspec(dllexport) bool __cdecl CNC_Set_Multiplayer_Data(int scena
Special.IsTSpread = 0;
}

Special.IsMCVDeploy = game_options.IsMCVDeploy;
Special.UseMCVDeploy = true;

Rule.AllowSuperWeapons = game_options.EnableSuperweapons; // Are superweapons available

Scenario = scenario_index;
MPlayerCount = 0;

Expand Down
32 changes: 16 additions & 16 deletions tiberiandawn/drive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void DriveClass::Overrun_Square(CELL cell, bool threaten)
/*
** Scattering is controlled by the game difficulty level.
*/
if (((GameToPlay == GAME_NORMAL && PlayerPtr->Difficulty == DIFF_HARD) || Special.IsScatter
if (((GameToPlay == GAME_NORMAL && PlayerPtr->Difficulty == DIFF_HARD) || Rule.IsScatter
|| Scenario > 8)
&& !(GameToPlay == GAME_NORMAL && PlayerPtr->Difficulty == DIFF_EASY)) {
cellptr->Incoming(0, true);
Expand Down Expand Up @@ -708,10 +708,10 @@ bool DriveClass::While_Moving(void)

case MOVE_TEMP:
if (*this == UNIT_HARVESTER || !House->IsHuman) {
bool old = Special.IsScatter;
Special.IsScatter = true;
bool old = Rule.IsScatter;
Rule.IsScatter = true;
Map[Coord_Cell(c)].Incoming(0, true);
Special.IsScatter = old;
Rule.IsScatter = old;
}
break;
}
Expand Down Expand Up @@ -975,10 +975,10 @@ bool DriveClass::Start_Of_Move(void)
CellClass* cellptr = &Map[cell];
TechnoClass* blockage = cellptr->Cell_Techno();
if (blockage && House->Is_Ally(blockage)) {
bool old = Special.IsScatter;
Special.IsScatter = true;
bool old = Rule.IsScatter;
Rule.IsScatter = true;
cellptr->Incoming(0, true);
Special.IsScatter = old;
Rule.IsScatter = old;
}
}
}
Expand Down Expand Up @@ -1009,10 +1009,10 @@ bool DriveClass::Start_Of_Move(void)
CellClass* cellptr = &Map[cell];
TechnoClass* blockage = cellptr->Cell_Techno();
if (blockage && House->Is_Ally(blockage)) {
bool old = Special.IsScatter;
Special.IsScatter = true;
bool old = Rule.IsScatter;
Rule.IsScatter = true;
cellptr->Incoming(0, true);
Special.IsScatter = old;
Rule.IsScatter = old;
}
}
}
Expand Down Expand Up @@ -1079,10 +1079,10 @@ bool DriveClass::Start_Of_Move(void)
** get out of the way.
*/
if (cando == MOVE_TEMP) {
bool old = Special.IsScatter;
Special.IsScatter = true;
bool old = Rule.IsScatter;
Rule.IsScatter = true;
Map[destcell].Incoming(0, true);
Special.IsScatter = old;
Rule.IsScatter = old;
}

/*
Expand Down Expand Up @@ -1210,10 +1210,10 @@ bool DriveClass::Start_Of_Move(void)
** get out of the way.
*/
if (cando == MOVE_TEMP) {
bool old = Special.IsScatter;
Special.IsScatter = true;
bool old = Rule.IsScatter;
Rule.IsScatter = true;
Map[destcell].Incoming(0, true);
Special.IsScatter = old;
Rule.IsScatter = old;
}

/*
Expand Down
6 changes: 3 additions & 3 deletions tiberiandawn/foot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ ResultType FootClass::Take_Damage(int& damage, int distance, WarheadType warhead
&& (source->What_Am_I() != RTTI_AIRCRAFT
|| BulletTypeClass::As_Reference(Weapons[Techno_Type_Class()->Primary].Fires).IsAntiAircraft)
&& (!Target_Legal(TarCom)
|| ((!House->IsHuman || Special.IsSmartDefense) && (!tweap || !In_Range(TarCom))))
|| ((!House->IsHuman || Rule.IsSmartDefense) && (!tweap || !In_Range(TarCom))))
&&
// !Target_Legal(NavCom) &&
(Mission == MISSION_AMBUSH || Mission == MISSION_GUARD || Mission == MISSION_RESCUE
Expand Down Expand Up @@ -1208,7 +1208,7 @@ ResultType FootClass::Take_Damage(int& damage, int distance, WarheadType warhead
** Simple retaliation cannot occur because the source of the damage
** is too far away. If scatter logic is enabled, then scatter now.
*/
if (Special.IsScatter) {
if (Rule.IsScatter) {
Scatter(0, true);
}
}
Expand All @@ -1218,7 +1218,7 @@ ResultType FootClass::Take_Damage(int& damage, int distance, WarheadType warhead
/*
** If this object isn't doing anything important, then scatter.
*/
if (!IsDriving && !Target_Legal(TarCom) && !Target_Legal(NavCom) && Special.IsScatter
if (!IsDriving && !Target_Legal(TarCom) && !Target_Legal(NavCom) && Rule.IsScatter
&& What_Am_I() != RTTI_AIRCRAFT) {
Scatter(0, true);
}
Expand Down
2 changes: 1 addition & 1 deletion tiberiandawn/idata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,7 @@ BuildingClass* InfantryTypeClass::Who_Can_Build_Me(bool intheory, bool legal, Ho
*=============================================================================================*/
int InfantryTypeClass::Full_Name(void) const
{
if (Debug_Map || !IsNominal || Special.IsNamed || Type == INFANTRY_C10 || Type == INFANTRY_DELPHI
if (Debug_Map || !IsNominal || Rule.IsNamed || Type == INFANTRY_C10 || Type == INFANTRY_DELPHI
|| Type == INFANTRY_MOEBIUS) {
return (TechnoTypeClass::Full_Name());
}
Expand Down
8 changes: 4 additions & 4 deletions tiberiandawn/infantry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,20 +716,20 @@ void InfantryClass::Per_Cell_Process(bool center)
if (center && Mission == MISSION_SABOTAGE) {
BuildingClass* building = cellptr->Cell_Building();
if (building && building->As_Target() == NavCom) {
int temp = Special.IsScatter;
int temp = Rule.IsScatter;

building->IsGoingToBlow = true;
building->Clicked_As_Target(PlayerPtr->Class->House,
20); // 2019/09/20 JAS - Added record of who clicked on the object
building->Clicked_As_Target(building->Owner(), 20);
building->CountDown.Set(20);
building->WhomToRepay = As_Target();
Special.IsScatter = true;
Rule.IsScatter = true;
NavCom = TARGET_NONE;
Do_Uncloak();
Arm = Rearm_Delay(true);
Scatter(building->Center_Coord(), true); // RUN AWAY!
Special.IsScatter = temp;
Rule.IsScatter = temp;
return;
}
}
Expand Down Expand Up @@ -2102,7 +2102,7 @@ void InfantryClass::Scatter(COORDINATE threat, bool forced, bool nokidding)
** For human players, don't scatter the infantry, if the special
** flag has not been enabled that allows infantry scatter.
*/
if (!Special.IsScatter && !nokidding && House->IsHuman && !forced && !Team)
if (!Rule.IsScatter && !nokidding && House->IsHuman && !forced && !Team)
return;

if (forced || Class->IsFraidyCat /*|| !(Random_Pick(1, 4) == 1)*/) {
Expand Down
6 changes: 3 additions & 3 deletions tiberiandawn/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ void MapClass::Logic(void)
/*
** Bail early if there is no allowed growth or spread of Tiberium.
*/
if (!Special.IsTGrowth && !Special.IsTSpread)
if (!Rule.IsTGrowth && !Rule.IsTSpread)
return;

/*
Expand All @@ -1384,7 +1384,7 @@ void MapClass::Logic(void)
cell = (MAP_CELL_TOTAL - 1) - index;
CellClass* ptr = &(*this)[cell];

if (Special.IsTGrowth && ptr->Land_Type() == LAND_TIBERIUM && ptr->OverlayData < 11) {
if (Rule.IsTGrowth && ptr->Land_Type() == LAND_TIBERIUM && ptr->OverlayData < 11) {
if (TiberiumGrowthCount < sizeof(TiberiumGrowth) / sizeof(TiberiumGrowth[0])) {
TiberiumGrowth[TiberiumGrowthCount++] = cell;
} else {
Expand All @@ -1396,7 +1396,7 @@ void MapClass::Logic(void)
** Heavy Tiberium growth can spread.
*/
TerrainClass* terrain = ptr->Cell_Terrain();
if (Special.IsTSpread && (ptr->Land_Type() == LAND_TIBERIUM && ptr->OverlayData > 6)
if (Rule.IsTSpread && (ptr->Land_Type() == LAND_TIBERIUM && ptr->OverlayData > 6)
|| (terrain && terrain->Class->IsTiberiumSpawn)) {

int tries = 1;
Expand Down
1 change: 1 addition & 0 deletions tiberiandawn/netdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4406,6 +4406,7 @@ static int Net_Fake_New_Dialog(void)
........................................................................*/
Special.IsTGrowth = MPlayerTiberium;
Special.IsTSpread = MPlayerTiberium;
Rule.IsTSpread = Special.IsTSpread;
transmit = 0;

/*........................................................................
Expand Down
43 changes: 0 additions & 43 deletions tiberiandawn/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,14 +681,6 @@ void OptionsClass::Load_Settings(void)

char workbuf[128];

/*
** Check for and possible enable true object names.
*/
ini.Get_String(OPTIONS, "TrueNames", "", workbuf, sizeof(workbuf));
if (Obfuscate(workbuf) == PARM_TRUENAME) {
Special.IsNamed = true;
}

/*
** Enable 6 player games if special flag is detected.
*/
Expand All @@ -705,22 +697,6 @@ void OptionsClass::Load_Settings(void)
Special.IsThreePoint = true;
}

/*
** Allow purchase of the helipad separately from the helicopter.
*/
ini.Get_String(OPTIONS, "Helipad", "", workbuf, sizeof(workbuf));
if (Obfuscate(workbuf) == PARM_HELIPAD) {
Special.IsSeparate = true;
}

/*
** Allow the MCV to undeploy rather than sell.
*/
ini.Get_String(OPTIONS, "MCV", "", workbuf, sizeof(workbuf));
if (Obfuscate(workbuf) == PARM_MCV) {
Special.IsMCVDeploy = true;
}

/*
** Allow disabling of building bibs so that tigher building packing can occur.
*/
Expand All @@ -729,14 +705,6 @@ void OptionsClass::Load_Settings(void)
Special.IsRoad = true;
}

/*
** Allow targeting of trees without having to hold down the shift key.
*/
ini.Get_String(OPTIONS, "TreeTarget", "", workbuf, sizeof(workbuf));
if (Obfuscate(workbuf) == PARM_TREETARGET) {
Special.IsTreeTarget = true;
}

/*
** Allow infantry to fire while moving. Attacker gets advantage with this flag.
*/
Expand All @@ -753,17 +721,6 @@ void OptionsClass::Load_Settings(void)
Special.IsVariation = true;
}

/*
** Smarter self defense logic. Tanks will try to run over adjacent infantry. Buildings
** will automatically return fire if they are fired upon. Infantry will run from an
** incoming explosive (grenade or napalm) or damage that can't be directly addressed.
*/
ini.Get_String(OPTIONS, "CombatIQ", "", workbuf, sizeof(workbuf));
if (Obfuscate(workbuf) == PARM_IQ) {
Special.IsSmartDefense = true;
Special.IsScatter = true;
}

/*
** Enable the infantry squish marks when run over by a vehicle.
*/
Expand Down
Loading

0 comments on commit 8ffc5ce

Please sign in to comment.