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 Oct 13, 2022
1 parent 45db835 commit 9067861
Show file tree
Hide file tree
Showing 17 changed files with 243 additions and 151 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 (Scen.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 @@ -1684,7 +1684,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 @@ -3177,7 +3177,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 @@ -4096,7 +4096,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 @@ -4186,7 +4186,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 @@ -4512,10 +4512,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 @@ -5462,7 +5462,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

Scen.Scenario = scenario_index;
MPlayerCount = 0;

Expand Down
38 changes: 19 additions & 19 deletions tiberiandawn/drive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void DriveClass::Do_Turn(DirType dir)
** Special rotation track is needed for units that
** cannot rotate in place.
*/
if (Special.IsThreePoint && TrackNumber == -1 && Class->Speed == SPEED_WHEEL) {
if (Rule.IsThreePoint && TrackNumber == -1 && Class->Speed == SPEED_WHEEL) {
int facediff; // Signed difference between current and desired facing.
FacingType face; // Current facing (ordinal value).

Expand Down 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
|| Scen.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 Expand Up @@ -1319,7 +1319,7 @@ void DriveClass::AI(void)
** For tracked units that are rotating in place, perform the rotation now.
*/
if ((Class->Speed == SPEED_FLOAT || Class->Speed == SPEED_HOVER || Class->Speed == SPEED_TRACK
|| (Class->Speed == SPEED_WHEEL && !Special.IsThreePoint))
|| (Class->Speed == SPEED_WHEEL && !Rule.IsThreePoint))
&& PrimaryFacing.Is_Rotating()) {
if (PrimaryFacing.Rotation_Adjust((int)Class->ROT * House->GroundspeedBias)) {
Mark(MARK_CHANGE);
Expand Down Expand Up @@ -1408,7 +1408,7 @@ void DriveClass::Fixup_Path(PathType* path)
/*
** Only wheeled vehicles need a path fixup -- to avoid 3 point turns.
*/
if (!Special.IsThreePoint || Class->Speed != SPEED_WHEEL) {
if (!Rule.IsThreePoint || Class->Speed != SPEED_WHEEL) {
return;
}

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
Loading

0 comments on commit 9067861

Please sign in to comment.