Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TD rules.ini implementation part 2. #714

Open
wants to merge 4 commits into
base: vanilla
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion redalert/building.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5282,7 +5282,7 @@ bool BuildingClass::Can_Player_Move(void) const
assert(Buildings.ID(this) == ID);
assert(IsActive);

return (*this == STRUCT_CONST && (Mission == MISSION_GUARD) && Special.IsMCVDeploy);
return (*this == STRUCT_CONST && (Mission == MISSION_GUARD) && Is_MCV_Deploy());
}

/***********************************************************************************************
Expand Down
4 changes: 1 addition & 3 deletions redalert/cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2183,8 +2183,6 @@ int CellClass::Tiberium_Adjust(bool pregame)
return (0);
}

extern bool MPSuperWeaponDisable;

/***********************************************************************************************
* CellClass::Goodie_Check -- Performs crate discovery logic. *
* *
Expand Down Expand Up @@ -2319,7 +2317,7 @@ bool CellClass::Goodie_Check(FootClass* object)
case CRATE_SONAR:
if (Session.Type != GAME_NORMAL) {
#ifdef REMASTER_BUILD
if (MPSuperWeaponDisable) {
if (!Rule.AllowSuperWeapons) {
powerup = CRATE_MONEY;
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions redalert/dllinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ extern "C" __declspec(dllexport) bool __cdecl CNC_Set_Multiplayer_Data(int scena
Special.IsMCVDeploy = game_options.IsMCVDeploy;
Special.UseMCVDeploy = true;

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

// Session.Options.AIPlayers = WWGetPrivateProfileInt("Options", "AI", 0, buffer); //Number of AI players

Expand Down Expand Up @@ -8567,7 +8567,7 @@ bool DLLExportClass::Save(Pipe& pipe)
/*
** Special case for MPSuperWeaponDisable - store negated value so it defaults to enabled
*/
bool not_allow_super_weapons = !MPSuperWeaponDisable;
bool not_allow_super_weapons = !Rule.AllowSuperWeapons;
pipe.Put(&not_allow_super_weapons, sizeof(not_allow_super_weapons));

/*
Expand Down Expand Up @@ -8669,7 +8669,7 @@ bool DLLExportClass::Load(Straw& file)
if (file.Get(&not_allow_super_weapons, sizeof(not_allow_super_weapons)) != sizeof(not_allow_super_weapons)) {
return false;
}
MPSuperWeaponDisable = !not_allow_super_weapons;
Rule.AllowSuperWeapons = !not_allow_super_weapons;

unsigned char padding[4095];

Expand Down
3 changes: 1 addition & 2 deletions redalert/house.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,6 @@ void HouseClass::Init(void)

// Object selection list is switched with player context for GlyphX. ST - 8/7/2019 10:11AM
extern void Logic_Switch_Player_Context(HouseClass* house);
extern bool MPSuperWeaponDisable;

/***********************************************************************************************
* HouseClass::AI -- Process house logic. *
Expand Down Expand Up @@ -1223,7 +1222,7 @@ void HouseClass::AI(void)
** Process any super weapon logic required.
*/
#ifdef REMASTER_BUILD
if (Session.Type != GAME_GLYPHX_MULTIPLAYER || !MPSuperWeaponDisable) {
if (Session.Type != GAME_GLYPHX_MULTIPLAYER || Rule.AllowSuperWeapons) {
Super_Weapon_Handler();
}
#else
Expand Down
4 changes: 1 addition & 3 deletions redalert/infantry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,6 @@ void InfantryClass::Draw_It(int x, int y, WindowNumberType window) const
FootClass::Draw_It(x, y, window);
}

extern bool MPSuperWeaponDisable;

/***********************************************************************************************
* InfantryClass::Per_Cell_Process -- Handles special operations that occur once per cell. *
* *
Expand Down Expand Up @@ -704,7 +702,7 @@ void InfantryClass::Per_Cell_Process(PCPType why)
tech->House->RadarSpied |= housespy;
}
#ifdef REMASTER_BUILD
if (Session.Type == GAME_NORMAL || !MPSuperWeaponDisable) {
if (Session.Type == GAME_NORMAL || Rule.AllowSuperWeapons) {
#else
if (Session.Type == GAME_NORMAL) {
#endif
Expand Down
1 change: 1 addition & 0 deletions redalert/rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ RulesClass::RulesClass(void)
, TiberiumLongScan(0x2000)
, HealthBarDisplayMode(HB_SELECTED)
, ResourceBarDisplayMode(RB_SELECTED)
, AllowSuperWeapons(true)
{
#ifdef FIXIT_CSII // checked - ajw 9/28/98
NewUnitsEnabled = SecretUnitsEnabled = false;
Expand Down
5 changes: 5 additions & 0 deletions redalert/rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,11 @@ class RulesClass
RB_SELECTED = 0,
RB_ALWAYS,
} ResourceBarDisplayMode;

/*
** Are superweapons allowed?
*/
bool AllowSuperWeapons;
};

#endif
4 changes: 2 additions & 2 deletions tiberiandawn/bdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4536,7 +4536,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 @@ -4568,7 +4568,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 @@ -1689,7 +1689,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 @@ -3182,7 +3182,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 @@ -4101,7 +4101,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 @@ -4191,7 +4191,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 @@ -4517,10 +4517,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 @@ -5467,7 +5467,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
35 changes: 35 additions & 0 deletions tiberiandawn/conquer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3947,6 +3947,41 @@ void Blit_Hid_Page_To_Seen_Buff(void)
HidPage.Blit(SeenBuff);
}

/***********************************************************************************************
* Owner_From_Name -- Convert an owner name into a bitfield. *
* *
* This will take an owner specification and convert it into a bitfield that represents *
* it. Sometimes this will be just a single house bit, but other times it could be *
* all the allies or soviet house bits combined. *
* *
* INPUT: text -- Pointer to the text to convert into a house bitfield. *
* *
* OUTPUT: Returns with the houses specified. The value is in the form of a bit field with *
* one bit per house type. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 08/12/1996 JLB : Created. *
*=============================================================================================*/
int Owner_From_Name(char const* text)
{
int ownable = 0;
if (stricmp(text, "nod") == 0) {
ownable |= HOUSEF_BAD;
} else {
if (stricmp(text, "gdi") == 0) {
ownable |= HOUSEF_GOOD;
} else {
HousesType h = HouseTypeClass::From_Name(text);
if (h != HOUSE_NONE && (h < HOUSE_MULTI1 || h > HOUSE_MULTI6)) {
ownable |= (1 << h);
}
}
}
return (ownable);
}

/***********************************************************************************************
* Shake_The_Screen -- Dispatcher that shakes the screen. *
* *
Expand Down
3 changes: 3 additions & 0 deletions tiberiandawn/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,9 @@ typedef enum HousesType : signed char
#define HOUSEF_MULTI4 (1 << HOUSE_MULTI4)
#define HOUSEF_MULTI5 (1 << HOUSE_MULTI5)
#define HOUSEF_MULTI6 (1 << HOUSE_MULTI6)
#define HOUSEF_OTHERS \
(HOUSEF_NEUTRAL | HOUSEF_JP | HOUSEF_MULTI1 | HOUSEF_MULTI2 | HOUSEF_MULTI3 | HOUSEF_MULTI4 | HOUSEF_MULTI5 \
| HOUSEF_MULTI6)

typedef enum PlayerColorType : signed char
{
Expand Down
8 changes: 5 additions & 3 deletions tiberiandawn/dllinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,14 +721,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 @@ -737,6 +734,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
Loading