Skip to content

Conversation

@ChrisLv-CN
Copy link

@ChrisLv-CN ChrisLv-CN commented Sep 8, 2023

Extension some function.

Summary by CodeRabbit

  • New Features

    • Added an additional way to look up super-weapons using a type object.
    • New targeting and weapon helpers (range checks, alternate fire paths, laser/electric effects, visual link drawing).
  • Enhancements

    • Renamed and standardized a public power-related field for clearer state.
    • Consolidated facing/rotation representation and renamed timer/selection flags for clearer behavior.
  • Bug Fixes

    • Improved targeting, facing and elevation logic for more reliable firing and range calculations.
  • Chores

    • Internal casting/type-check code refactored for safer and clearer behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2024

📝 Walkthrough

Walkthrough

Adds an overload to HouseClass::FindSuperWeapon, renames a HouseClass public field to PowerSurplus, updates TechnoClass public API/signatures and adds multiple targeting/fire helper methods, and refactors casting helpers in Helpers/Cast.h to support a SkipNullCheck template parameter and macro-generated specializations.

Changes

Cohort / File(s) Summary
HouseClass updates
src/HouseClass.h
Added SuperClass* FindSuperWeapon(SuperWeaponTypeClass* type) const; renamed public member DWORD unknown_power_160B4int PowerSurplus; added include/import for SuperWeaponTypeClass.
TechnoClass API & members
src/TechnoClass.h
Changed facing APIs from DirStruct*FacingClass*; updated parameter types accordingly; added forward EBolt; added methods InRange, Fire_IgnoreType, Electric_Zap, DrawALinkTo, GetElevationBonusDistance; changed CreateLaser target param from ObjectClass*AbstractClass*; renamed property DiskLaserTimerROFTimer and kept ROF int; renamed flag unknown_bool_432WasSelected. Review virtual signature changes and all overrides/usages.
Casting helpers refactor
src/Helpers/Cast.h
Introduced SkipNullCheck template parameter (default false) to specific_cast, generic_cast, abstract_cast overloads; added constexpr-based null-check branching; replaced many explicit specializations with macro-generated specializations (ABSTRACT_PARAM, GENERIC_CAST, RT_GENERIC_CAST, ABSTRACT_CAST, APPLY_* macros) to generate casts for AbstractClass*, ObjectClass*, MissionClass*, RadioClass*, TechnoClass*, FootClass*. Review template behavior, null-check semantics, and macro expansion impacts.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

"I'm a rabbit, sniffing header glades,
New zaps and facings change the shades.
Casts rewritten with a clever trick,
Surplus counted, weapons pick.
Hoppity-hop — a tidy patch parade! 🐰"

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Update' is vague and generic, providing no meaningful information about what is being updated or what the core changes are. Replace with a specific, descriptive title that highlights the main changes, such as 'Refactor casting helpers and update TechnoClass/HouseClass signatures' or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 11

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8346eec and 6a7ccac.
Files selected for processing (18)
  • BasicStructures.h (3 hunks)
  • CCINIClass.h (1 hunks)
  • CellClass.h (3 hunks)
  • Dir.h (5 hunks)
  • DisplayClass.h (2 hunks)
  • EBolt.h (1 hunks)
  • Facing.h (2 hunks)
  • HouseClass.h (2 hunks)
  • Kamikaze.h (1 hunks)
  • MessageListClass.h (1 hunks)
  • ObjectClass.h (2 hunks)
  • SpawnManagerClass.h (1 hunks)
  • StaticInits.cpp (1 hunks)
  • Surface.h (7 hunks)
  • TechnoClass.h (7 hunks)
  • TechnoTypeClass.h (1 hunks)
  • WeaponTypeClass.h (1 hunks)
  • YRMathVector.h (7 hunks)
Additional comments: 28
Kamikaze.h (1)
  • 16-16: Change to AbstractClass* for Cell member in KamikazeControl struct is approved. Enhances flexibility in target handling for kamikaze missions.
EBolt.h (2)
  • 8-8: Addition of include directive for ArrayClasses.h is approved. Prepares file for enhanced functionality.
  • 10-10: Declaration of TechnoClass is approved. Indicates interaction with game entities for electric bolts.
SpawnManagerClass.h (1)
  • 105-106: Renaming of members in SpawnManagerClass improves clarity. Target to Destination and NewTarget to Target make their roles more intuitive.
Facing.h (1)
  • 28-28: Removal of explicit specifier from FacingClass constructor and addition of clarifying comments are approved. Enhances usability and code clarity.
WeaponTypeClass.h (1)
  • 41-52: Addition of new methods for calculating speed and a static method for speed calculation in WeaponTypeClass is approved. Enhances flexibility and accuracy of weapon interactions.
MessageListClass.h (1)
  • 86-88: Addition of a new PrintMessage method with a pLabel parameter and adjustments to existing methods in MessageListClass is approved. Improves messaging system flexibility and UI.
BasicStructures.h (3)
  • 44-48: Addition of a boolean operator to ColorStruct is approved. Simplifies truthiness checks.
  • 53-62: Introduction of a Colors namespace with predefined color constants is approved. Enhances usability and readability.
  • 176-179: Addition of an IsEmpty() method to RectangleStruct is approved. Provides a straightforward way to check for default-initialized instances.
Dir.h (2)
  • 14-15: Refinement of DirStruct constructors and methods in Dir.h is approved. Improves precision and flexibility of direction handling.
  • 55-72: Introduction of new functions for value manipulation in DirStruct is approved. Provides additional tools for working with direction values.
DisplayClass.h (1)
  • 7-20: Addition of new declarations and methods related to proximity checks and marking foundations in DisplayClass is approved. Enhances building placement and interaction mechanics.
StaticInits.cpp (1)
  • 119-127: Addition of HouseClass::FindSuperWeapon(SuperWeaponTypeClass* const type) method and bug fix in IsIonCannonEligibleTarget method in StaticInits.cpp is approved. Enhances super weapon handling and target eligibility checks.
YRMathVector.h (3)
  • 19-24: Addition of new assignment operators for type conversions in Vector2D and Vector3D classes is approved. Enhances usability and functionality.
  • 81-85: Addition of comparison operators for map keys in Vector2D and Vector3D classes is approved. Allows use as map keys.
  • 125-129: Addition of an IsEmpty method to Vector2D and Vector3D classes is approved. Provides a straightforward way to check for empty vectors.
CellClass.h (2)
  • 27-49: The TileType enum introduces hardcoded values for tile types. Ensure these values match expected game engine or documentation values, as hardcoded values can lead to maintenance issues if the underlying assumptions change.
  • 221-227: The overloaded IsClearToMove method introduces default parameter values and calls the other overloaded version internally. Verify that the default value for level (-1) and the logic to determine isBridge using ContainsBridge() align with the game's movement and terrain rules.
TechnoClass.h (7)
  • 26-26: The addition of class EBolt suggests new functionality related to electric attacks or effects. Ensure that its implementation is fully integrated with the rest of the TechnoClass methods and that it adheres to the game's mechanics for electric-based abilities or attacks.
  • 191-197: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [194-218]

The method signatures for TurretFacing and GetRealFacing have been changed to use FacingClass* instead of DirStruct*. Confirm that all calls to these methods throughout the codebase have been updated to reflect this change, and verify that FacingClass provides the necessary functionality that DirStruct previously offered.

  • 354-360: The method Fire_IgnoreType suggests a specific behavior for firing mechanics, potentially overriding default type checks. Ensure this behavior is documented and justified within the game's logic, especially regarding how it interacts with different target types and weapon systems.
  • 370-374: The CreateLaser and Electric_Zap methods introduce new attack or effect types. Verify these methods are correctly implemented according to the game's specifications for laser and electric attacks, including proper handling of target types, damage calculations, and visual effects.
  • 376-378: The DrawALinkTo method adds functionality for drawing visual links between points. Ensure this method is used consistently and appropriately within the game's visual effect system, and that it does not introduce performance issues when rendering multiple links in a scene.
  • 632-633: The addition of the ROFTimer property and modification of the ROF property suggest changes to the rate of fire mechanics. Confirm that these changes are consistent with the intended gameplay balance and that the ROFTimer is correctly utilized in weapon firing logic.
  • 503-511: The non-virtual methods TurretFacing and GetRealFacing provide convenience wrappers for their virtual counterparts. Ensure that these methods are used in contexts where the facing direction is required without modifying the underlying object, and that they correctly handle all possible states of turret and body facing.
HouseClass.h (2)
  • 14-14: Addition of #include <SuperWeaponTypeClass.h> is appropriate for the new method signature that uses SuperWeaponTypeClass*. Ensure this new dependency is justified and used elsewhere in the file if possible to avoid unnecessary includes.
  • 508-509: Modification of FindSuperWeapon method to take a SuperWeaponTypeClass* instead of SuperWeaponType improves type safety and clarity. Verify that all calls to this method have been updated accordingly across the codebase.

class NOVTABLE Surface
{
public:
static constexpr reference<bool*, 0x84310Cu> const Pattern{};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Pattern constant is added to the Surface class. Ensure its usage is properly documented and consider if access modifiers (e.g., public, protected) are appropriate for its intended use.

Comment on lines +113 to +114
static bool __fastcall ClipLine(Point2D& point1, Point2D& point2, RectangleStruct& Bounds)
{ JMP_STD(0x7BC2B0); }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ClipLine method is added to the Surface class. Verify the correctness of the JMP_STD macro usage and ensure the method's parameters and return type align with its implementation requirements.

Comment on lines +124 to +127
bool DrawDashedLine(Point2D* pStart, Point2D* pEnd, int nColor, int nOffset)
{
return DrawDashedLine(pStart, pEnd, nColor, Pattern.get(), nOffset);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DrawDashedLine method is added to the Surface class. Confirm that the Pattern constant is correctly utilized here and check for potential off-by-one errors in the handling of the nOffset parameter.

RectangleStruct GetRect()
{
RectangleStruct ret;
RectangleStruct ret{ 0, 0, 0, 0 };
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initialization of ret in the GetRect method of the Surface class has been modified. Ensure that the new initialization values are correct and consider if they might affect existing functionality.

Comment on lines +228 to +240
void DrawSHP(ConvertClass* Palette, SHPStruct* SHP, int FrameIndex,
const Point2D* const Position, const RectangleStruct* const Bounds,
BlitterFlags Flags = (BlitterFlags)0x600,
int Brightness = 1000,
int TintColor = 0)
{
DrawSHP(Palette, SHP, FrameIndex, Position, Bounds, Flags, 0,
0,
ZGradient::Ground,
Brightness,
TintColor, nullptr, 0, 0, 0
);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DrawSHP method overrides added to the DSurface class introduce new default parameter values. Confirm that these defaults are appropriate and do not inadvertently change the behavior of existing code that relies on this method.

Comment on lines +342 to +344
static constexpr reference<BYTE[], 0x826260u> const INI_Rules_FileName{};
static constexpr reference<BYTE[], 0x82621Cu> const INI_AI_FileName{};
static constexpr reference<BYTE[], 0x826254u> const INI_Art_FileName{};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The declarations for INI_Rules_FileName, INI_AI_FileName, and INI_Art_FileName as static constexpr reference<BYTE[]> constants are added. Verify that the memory addresses these constants point to are correctly assigned and that the data types are appropriate for their usage.

Comment on lines +269 to +272
DamageState TakeDamage(int damage, WarheadTypeClass* pWH, bool crewed, bool ignoreDefenses = true, ObjectClass* pAttacker = nullptr, HouseClass* pAttackingHouse = nullptr)
{
return ReceiveDamage(&damage, 0, pWH, pAttacker, ignoreDefenses, !crewed, pAttackingHouse);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first TakeDamage method added to ObjectClass includes parameters for specifying a WarheadTypeClass. Ensure that the method correctly forwards these parameters to ReceiveDamage and that the logic for handling crewed and ignoreDefenses flags is correct.

Comment on lines +274 to +277
DamageState TakeDamage(int damage, bool crewed, bool ignoreDefenses = true, ObjectClass* pAttacker = nullptr, HouseClass* pAttackingHouse = nullptr)
{
return TakeDamage(damage, RulesClass::Instance->C4Warhead, crewed, ignoreDefenses, pAttacker, pAttackingHouse);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second TakeDamage method simplifies damage application by using a default warhead type from RulesClass. Confirm that the default warhead type is appropriate for all use cases where this method might be called and that the forwarding of parameters to the first TakeDamage method is correct.

int GuardRange;
int MinDebris;
int MaxDebris;
int MinDebris;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of MinDebris and MaxDebris variables in TechnoTypeClass has been altered. Verify that this change does not affect serialization or memory layout in a way that could lead to compatibility issues with saved games or external tools that rely on the class's structure.

Comment on lines +328 to +351
TileType GetTileType()
{
if (Tile_Is_Tunnel()) return TileType::Tunnel;
if (Tile_Is_Water()) return TileType::Water;
if (Tile_Is_Blank()) return TileType::Blank;
if (Tile_Is_Ramp()) return TileType::Ramp;
if (Tile_Is_Cliff()) return TileType::Cliff;
if (Tile_Is_Shore()) return TileType::Shore;
if (Tile_Is_Wet()) return TileType::Wet;
if (Tile_Is_MiscPave()) return TileType::MiscPave;
if (Tile_Is_Pave()) return TileType::Pave;
if (Tile_Is_DirtRoad()) return TileType::DirtRoad;
if (Tile_Is_PavedRoad()) return TileType::PavedRoad;
if (Tile_Is_PavedRoadEnd()) return TileType::PavedRoadEnd;
if (Tile_Is_PavedRoadSlope()) return TileType::PavedRoadSlope;
if (Tile_Is_Median()) return TileType::Median;
if (Tile_Is_Bridge()) return TileType::Bridge;
if (Tile_Is_WoodBridge()) return TileType::WoodBridge;
if (Tile_Is_ClearToSandLAT()) return TileType::ClearToSandLAT;
if (Tile_Is_Green()) return TileType::Green;
if (Tile_Is_NotWater()) return TileType::NotWater;
if (Tile_Is_DestroyableCliff()) return TileType::DestroyableCliff;
return TileType::Unknown;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GetTileType method uses a series of conditional checks to return the tile type. This approach is straightforward but consider if a more efficient mapping or querying mechanism is available, especially if this method is called frequently in performance-critical paths.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6a7ccac and 0c1798d.
Files selected for processing (1)
  • BuildingClass.h (1 hunks)
Additional comments: 1
BuildingClass.h (1)
  • 258-259: Changing BState and QueueBState from int to BStateType improves type safety and clarity. Ensure all usages of these variables are updated to handle the new enum type correctly.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 78531b1 and 70f854d.
Files selected for processing (1)
  • Surface.h (7 hunks)
Additional comments: 9
Surface.h (9)
  • 15-15: The addition of the Pattern constant to the Surface class is a good practice for defining reusable patterns. However, ensure that its usage is properly documented, especially since it's a public member. Consider adding comments to explain its purpose and how it should be used in drawing operations.
  • 113-114: The ClipLine method uses the JMP_STD macro for its implementation. Ensure that the macro correctly handles the logic for clipping lines within the specified bounds. It's also important to verify that the method's parameters (point1, point2, and Bounds) are correctly used and that the method is tested thoroughly for edge cases.
  • 119-119: The modification in the initialization of ret in the GetRect method to { 0, 0, 0, 0 } is a clear way to initialize structures. Ensure that this change does not affect any existing functionality where GetRect is used, especially if previous default values were different or if uninitialized values were relied upon.
  • 124-127: The DrawDashedLine method correctly utilizes the Pattern constant. Ensure that the method is thoroughly tested, particularly for the handling of the nOffset parameter, to avoid potential off-by-one errors or incorrect pattern rendering.
  • 152-154: The addition of the VoxelSurface constant and the constructor for BSurface are well-implemented. Ensure that the Buffer initialization in the constructor takes into account the correct calculation for the buffer size based on Width, Height, and BytesPerPixel. Also, verify that the virtual table address (0x7E2070) is correctly set for BSurface instances.
  • 216-218: The DrawLineBlit method in the DSurface class is a good addition for drawing lines with blitting. Ensure that the parameters (pRect, pStart, pEnd, pStartColor, mult, start_z, end_z) are correctly used within the method and that the method is tested for various scenarios, including edge cases.
  • 232-244: The overloaded DrawSHP method introduces new default parameter values. Confirm that these defaults (Flags = (BlitterFlags)0x600, Brightness = 1000, TintColor = 0) are appropriate and do not inadvertently change the behavior of existing code that relies on this method. It's crucial to ensure compatibility with all calls to DrawSHP.
  • 246-251: The second overloaded DrawSHP method simplifies drawing by automatically determining the bounds. Ensure that the automatic bounds calculation (this->GetRect()) works correctly in all scenarios and does not introduce unexpected behavior, especially in edge cases where specific bounds are expected.
  • 229-257: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [254-266]

The DrawText methods provide flexibility in drawing text with different parameters. Ensure that the default values for BackColor and Flag in the overloaded methods are sensible and that all variations of DrawText are tested for correct text rendering, especially in cases with different background colors and shadow types.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 70f854d and eea4966.
Files selected for processing (1)
  • TechnoClass.h (9 hunks)
Files skipped from review as they are similar to previous changes (1)
  • TechnoClass.h

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between eea4966 and e2dd825.
Files selected for processing (1)
  • CellClass.h (3 hunks)
Additional comments: 2
CellClass.h (2)
  • 27-49: The addition of the TileType enum class introduces a structured way to represent different types of tiles within the game. This is a positive change as it enhances code readability and maintainability by replacing magic numbers or strings with a strongly-typed enumeration. However, it's important to ensure that the values assigned to each enum member (e.g., Tunnel = 0x484AB0) are correct and meaningful within the context of the game's logic. If these values are intended to be memory addresses or function pointers (which seems unusual), this should be clearly documented to avoid confusion.
  • 328-351: The GetTileType method implementation is straightforward and aligns with the newly introduced TileType enum, providing a way to determine the tile type based on specific conditions. This method is a good example of encapsulating game logic related to tile types within the CellClass. However, as previously mentioned in the comments from the outdated commits, consider if there's a more efficient way to map or query these tile types, especially if this method is called frequently in performance-critical paths. If performance is not a concern or if the current approach is the most suitable given the game's architecture, then this implementation is acceptable.

Comment on lines +220 to +227
// pass
bool IsClearToMove(SpeedType speedType, bool ignoreInfantry, bool ignoreVehicles, ZoneType zone, MovementZone movementZone, int level, bool alt)
{ JMP_THIS(0x4834A0); }

bool IsClearToMove(SpeedType speedType, MovementZone movementZone, bool ignoreInfantry = false, bool ignoreVehicles = false, int level = -1)
{
return IsClearToMove(speedType, ignoreInfantry, ignoreInfantry, ZoneType::None, movementZone, level, (bool)(this->Flags & CellFlags::CenterRevealed));
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overloaded IsClearToMove functions provide flexibility in determining whether a cell is clear for movement based on various parameters. This is a useful addition for handling different movement scenarios. However, there's a potential issue in the second overload (lines 224-227) where ignoreInfantry is passed twice instead of passing ignoreVehicles as the third argument to the first overload. This looks like a copy-paste error and should be corrected to ensure the function behaves as intended.

- return IsClearToMove(speedType, ignoreInfantry, ignoreInfantry, ZoneType::None, movementZone, level, (bool)(this->Flags & CellFlags::CenterRevealed));
+ return IsClearToMove(speedType, ignoreInfantry, ignoreVehicles, ZoneType::None, movementZone, level, (bool)(this->Flags & CellFlags::CenterRevealed));

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
// pass
bool IsClearToMove(SpeedType speedType, bool ignoreInfantry, bool ignoreVehicles, ZoneType zone, MovementZone movementZone, int level, bool alt)
{ JMP_THIS(0x4834A0); }
bool IsClearToMove(SpeedType speedType, MovementZone movementZone, bool ignoreInfantry = false, bool ignoreVehicles = false, int level = -1)
{
return IsClearToMove(speedType, ignoreInfantry, ignoreInfantry, ZoneType::None, movementZone, level, (bool)(this->Flags & CellFlags::CenterRevealed));
}
// pass
bool IsClearToMove(SpeedType speedType, bool ignoreInfantry, bool ignoreVehicles, ZoneType zone, MovementZone movementZone, int level, bool alt)
{ JMP_THIS(0x4834A0); }
bool IsClearToMove(SpeedType speedType, MovementZone movementZone, bool ignoreInfantry = false, bool ignoreVehicles = false, int level = -1)
{
return IsClearToMove(speedType, ignoreInfantry, ignoreVehicles, ZoneType::None, movementZone, level, (bool)(this->Flags & CellFlags::CenterRevealed));
}

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e2dd825 and 629df44.
Files selected for processing (1)
  • AircraftTrackerClass.h (1 hunks)
Additional comments: 4
AircraftTrackerClass.h (4)
  • 21-21: The use of constant_ptr for Instance is an interesting choice, ensuring type safety and const correctness. However, it's crucial to ensure that the memory address 0x887888u is correctly mapped and does not lead to any potential issues such as memory leaks or access violations.
  • 24-24: The explicit declaration of a destructor with RX is noted. Ensure that the destructor properly cleans up any dynamically allocated resources to prevent memory leaks. This is particularly important in a class that manages a collection of pointers.
  • 26-36: The methods Add_Entry, Remove_Entry, Update_Entry, and Search_Entry use the JMP_THIS macro for their implementations. This approach is specific to hooking or patching compiled binaries and is not common in standard C++ development. Ensure that this technique is consistent with the project's coding standards and that it does not introduce any security or stability issues.
  • 47-48: The properties Technos and Current are declared using DECLARE_PROPERTY. This macro likely simplifies the declaration of getters and setters for these properties. Ensure that the macro correctly handles memory management and thread safety, especially since DynamicVectorClass<TechnoClass*> involves pointers to objects that may be modified or deleted elsewhere in the code.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 629df44 and b1134e3.
Files selected for processing (1)
  • AircraftClass.h (1 hunks)
Additional comments: 2
AircraftClass.h (2)
  • 64-64: Renamed unknown_bool_6C8 to LoseAmmo for clarity.

This renaming improves code readability by providing a meaningful name for the variable. Ensure that all references to this variable in the codebase have been updated accordingly.

  • 70-72: Added IsLocked, ParadropsLeft, and IsCarrayall boolean flags.

These additions seem to enhance the functionality and state management of the AircraftClass. It's important to ensure that these new flags are properly initialized in the class constructor and handled correctly throughout the codebase.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b1134e3 and 6119e87.
Files selected for processing (1)
  • InfantryClass.h (1 hunks)

Comment on lines +38 to +39
int UpdateDeplory()
{ JMP_THIS(0x521320); }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method name UpdateDeplory appears to be a typo and should likely be UpdateDeploy for clarity and consistency.

-	int UpdateDeplory()
+	int UpdateDeploy()

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
int UpdateDeplory()
{ JMP_THIS(0x521320); }
int UpdateDeploy()
{ JMP_THIS(0x521320); }

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6119e87 and dc04da1.
Files selected for processing (1)
  • ObjectTypeClass.h (1 hunks)

Comment on lines +54 to +56
void DestroyVoxelShadowCache()
{ JMP_STD(0x5F99E0); }

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of DestroyVoxelShadowCache() is a straightforward enhancement for managing the voxel shadow cache. It's a good practice to include a brief comment above the function declaration to explain its purpose and any potential side effects or considerations for its use, enhancing code maintainability and readability.

+	// Destroys the voxel shadow cache to manage memory and rendering performance.
	void DestroyVoxelShadowCache()
		{ JMP_STD(0x5F99E0); }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
void DestroyVoxelShadowCache()
{ JMP_STD(0x5F99E0); }
// Destroys the voxel shadow cache to manage memory and rendering performance.
void DestroyVoxelShadowCache()
{ JMP_STD(0x5F99E0); }

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between dc04da1 and 9e75ed4.
Files selected for processing (3)
  • CellClass.h (5 hunks)
  • JumpjetLocomotionClass.h (1 hunks)
  • MissionClass.h (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • CellClass.h
Additional comments: 2
JumpjetLocomotionClass.h (1)
  • 62-63: Consider adding documentation for the GetZBalloonHover method to explain its purpose and how it integrates with the rest of the class's functionality. This will improve maintainability and understandability of the code.
MissionClass.h (1)
  • 92-93: Consider adding documentation for the Mission_Move_Carryall function to explain its specific use case for AircraftClass. Additionally, implementing type safety or checks to ensure it's only used with AircraftClass could prevent potential misuse and improve code safety.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9e75ed4 and 70dd0be.
Files selected for processing (1)
  • TacticalClass.h (1 hunks)
Additional comments: 1
TacticalClass.h (1)
  • 36-40: The addition of the CoordsToClient method is a good enhancement for simplifying the usage of converting coordinates to client space. It encapsulates the buffer handling internally, making the API cleaner for callers.

However, consider adding a brief comment above the method to explain its purpose and usage, especially since it overloads an existing method. This will improve code readability and maintainability.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 70dd0be and 9694f78.
Files selected for processing (1)
  • JumpjetLocomotionClass.h (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • JumpjetLocomotionClass.h

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9694f78 and 36aee93.
Files selected for processing (1)
  • JumpjetLocomotionClass.h (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • JumpjetLocomotionClass.h

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 36aee93 and 70ffa73.
Files selected for processing (1)
  • ShipLocomotionClass.h (1 hunks)
Additional Context Used
Additional comments not posted (1)
ShipLocomotionClass.h (1)

31-32: Renaming Ramp1 and Ramp2 to PreviousRamp and CurrentRamp improves the semantic clarity of these variables. This change likely enhances the readability and maintainability of the code by making the purpose of these variables more explicit. Ensure that all references to these variables throughout the codebase have been updated accordingly to reflect the new names.

Verification successful

The renaming of Ramp1 and Ramp2 to PreviousRamp and CurrentRamp has been successfully verified in the ShipLocomotionClass.h file, and no references to the old variable names were found. Additionally, it was discovered that similar changes were applied to the DriveLocomotionClass.h file, indicating a broader scope of the renaming effort than initially reviewed. This broader application of the changes should be noted, but it does not affect the approval of the changes made to ShipLocomotionClass.h. All references to these variables throughout the codebase appear to have been updated accordingly to reflect the new names.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search to find files that might reference the old ramp variables. Expecting no results.
rg --type cpp $'Ramp1|Ramp2'
# Search new variable names to validate usage. Expecting list of locations where the new names are used.
rg --type cpp $'PreviousRamp|CurrentRamp'

Length of output: 244

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
HouseClass.h (1)

14-14: LGTM! Consider forward declaration as an optimization.

The include is necessary for the new FindSuperWeapon overload. However, as an optional optimization, you could use a forward declaration instead of including the full header to reduce compilation dependencies, since you're only using a pointer type.

♻️ Optional: Use forward declaration instead

If compilation time becomes a concern, you could forward declare instead of including:

-#include <SuperWeaponTypeClass.h>

And add to the forward declarations section:

 //forward declarations
 class AnimClass;
 class BulletClass;
 class CellClass;
 class FactoryClass;
 class ObjectClass;
 class SuperClass;
+class SuperWeaponTypeClass;
 class TagClass;
 class WaypointPathClass;
 class WaypointClass;
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70ffa73 and 671847d.

📒 Files selected for processing (1)
  • HouseClass.h
🔇 Additional comments (2)
HouseClass.h (2)

508-509: Implementation verified and properly handles null pointers.

The new overload at StaticInits.cpp:119-127 correctly implements the declaration. When a null pointer is passed, the loop safely returns nullptr without finding a match, which is the appropriate behavior.


1017-1017: No action required—the type change from DWORD to int is correct and consistent with the codebase.

The power system throughout YRpp (PowerOutput, PowerDrain, and related fields in HouseClass, BuildingTypeClass, and PowerClass) consistently uses int (signed 32-bit), not DWORD. PowerSurplus as int aligns with the existing design and supports the logical use case of representing power surplus/deficit (which can be negative). All power comparisons and calculations already assume signed integer semantics.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
TechnoClass.h (2)

354-355: Consider parameter consistency, though likely intentional for binary compatibility.

The first parameter CoordStruct* pLocation uses a pointer, while other methods in this file typically pass CoordStruct by const reference (e.g., lines 262, 294, 370, 373). Since this is a thunk to existing game code, this inconsistency is likely required for binary compatibility with the original function at address 0x6F7220.


357-359: Fix typo and consider clarifying the comment.

The comment has a typo: "diffrent" → "different". Additionally, the comment could be more precise about what "IgnoreType" means in the method name.

📝 Suggested improvement
-	// Unit and Infantry fire logic is diffrent, this function for help to fire custom weapon, force use Unit's fire logic
+	// Unit and Infantry have different fire logic. This function forces the use of Unit's fire logic regardless of the actual type, useful for firing custom weapons.
 	BulletClass* Fire_IgnoreType(AbstractClass* pTarget, int idxWeapon)
 		{ JMP_THIS(0x6FDD50); }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 671847d and 5d6759c.

📒 Files selected for processing (1)
  • TechnoClass.h
🧰 Additional context used
🧬 Code graph analysis (1)
TechnoClass.h (2)
EBolt.h (1)
  • EBolt (13-61)
Facing.h (3)
  • FacingClass (13-16)
  • FacingClass (18-21)
  • FacingClass (23-26)
🔇 Additional comments (8)
TechnoClass.h (8)

26-26: LGTM!

The forward declaration is correctly added to support the new Electric_Zap method introduced later in the file.


509-520: LGTM!

The helper methods correctly updated to return FacingClass instead of DirStruct, maintaining consistency with the virtual method signature changes. The implementation pattern remains sound.


373-377: LGTM!

Both new methods are well-defined:

  • Electric_Zap correctly uses const reference for CoordStruct
  • DrawALinkTo appropriately passes small POD structs by value

The method signatures are consistent with existing patterns in the codebase.


455-456: LGTM!

The new methods GetElevationBonusDistance and TryNextPlanningTokenNode are straightforward additions with clear signatures. They integrate well with the existing codebase structure.

Also applies to: 495-496


638-639: LGTM! Good naming improvement.

Renaming DiskLaserTimer to ROFTimer (Rate Of Fire) is a positive change that improves code clarity and makes the purpose more general. The separation between the timer (ROFTimer) and the rate value (ROF) is logical and clear.


712-712: LGTM! Good naming improvement.

Renaming unknown_bool_432 to WasSelected clarifies the purpose of this boolean member, improving code readability and maintainability.


194-194: Virtual method signatures have been properly updated; no derived class overrides exist in this codebase.

The virtual method signatures for TurretFacing and GetRealFacing in TechnoClass have been correctly changed to use FacingClass* parameters, and the corresponding helper methods at lines 509–520 have been appropriately updated to match. No derived classes within this wrapper library override these methods, so no additional updates are required.


370-371: Parameter type change requires verification of external callers and game code function signature.

The first parameter type changed from ObjectClass* to AbstractClass*. While this type widening is valid in the inheritance hierarchy (ObjectClass derives from AbstractClass), verification is limited because:

  • No internal callers exist in this repository
  • The actual function signature at address 0x6FD210 (external game code) cannot be verified
  • External code consuming this API would be affected by this change

Ensure that the game function at 0x6FD210 actually accepts AbstractClass* and review any external call sites that might be affected.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Helpers/Cast.h (1)

89-91: Typo: "suppored" should be "supported".

✏️ Proposed fix
 	static_assert(!std::is_base_of<AbstractTypeClass, Base>::value
 		|| !std::is_abstract<Base>::value,
-		"abstract_cast: Abstract types (not fully implemented classes) derived from AbstractTypeClass are not suppored.");
+		"abstract_cast: Abstract types (not fully implemented classes) derived from AbstractTypeClass are not supported.");
🧹 Nitpick comments (3)
Helpers/Cast.h (3)

36-42: Document the precondition for SkipNullCheck=true.

When SkipNullCheck is true, the null check is bypassed but pAbstract->WhatAmI() is still called unconditionally on line 42. This is a valid optimization pattern, but callers must guarantee pAbstract != nullptr when using SkipNullCheck=true, otherwise undefined behavior (null pointer dereference) occurs.

Consider adding a comment or assert to document this precondition:

📝 Suggested documentation
 	if constexpr (!SkipNullCheck)
 	{
 		if (!pAbstract)
 			return nullptr;
 	}
+	else
+	{
+		// Caller guarantees pAbstract != nullptr when SkipNullCheck is true
+	}
 
 	return pAbstract->WhatAmI() == Base::AbsID ? static_cast<T>(pAbstract) : nullptr;

63-69: Same null-dereference risk as specific_cast.

Line 69 accesses pAbstract->AbstractFlags unconditionally after the conditional null check. When SkipNullCheck=true, callers must ensure pAbstract is non-null.


96-119: Consider adding a brief comment explaining the macro strategy.

The macros effectively reduce boilerplate for generating 4 specializations per type (const/non-const × SkipNullCheck true/false). However, macro-heavy code can be difficult to debug and navigate. A brief comment explaining the pattern would help maintainability.

📝 Suggested documentation
+// Macros to generate abstract_cast specializations for each type.
+// Each APPLY_* macro generates 4 specializations:
+//   - non-const, SkipNullCheck=true
+//   - non-const, SkipNullCheck=false  
+//   - const, SkipNullCheck=true
+//   - const, SkipNullCheck=false
+// APPLY_ABSTRACT_CAST: returns pAbstract directly (identity cast)
+// APPLY_GC_ABSTRACT_CAST: uses generic_cast for ObjectClass hierarchy
+// APPLY_RT_ABSTRACT_CAST: uses reinterpret_cast via TechnoClass for MissionClass/RadioClass
 `#define` ABSTRACT_PARAM pAbstract
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d6759c and 4d329fb.

📒 Files selected for processing (1)
  • Helpers/Cast.h
🔇 Additional comments (4)
Helpers/Cast.h (4)

16-21: LGTM!

The non-const overload correctly forwards to the const version, preserving the SkipNullCheck parameter through the call chain.


99-100: reinterpret_cast bypasses type safety for MissionClass* and RadioClass*.

RT_GENERIC_CAST first validates via generic_cast<TechnoClass*>, then uses reinterpret_cast to convert to the target type. This assumes MissionClass and RadioClass are bases of TechnoClass with compatible memory layouts. While this may be correct for this codebase's class hierarchy, reinterpret_cast provides no compile-time or runtime validation.

If the inheritance hierarchy is MissionClass -> RadioClass -> TechnoClass, consider using static_cast instead, which would provide compile-time verification:

-#define RT_GENERIC_CAST(TypePointer, ConstQual, SkipNullCheck) \
-	reinterpret_cast<ConstQual TypePointer>(GENERIC_CAST(TechnoClass*, ConstQual, SkipNullCheck))
+#define RT_GENERIC_CAST(TypePointer, ConstQual, SkipNullCheck) \
+	static_cast<ConstQual TypePointer>(GENERIC_CAST(TechnoClass*, ConstQual, SkipNullCheck))

Please verify whether static_cast works with your class hierarchy, or document why reinterpret_cast is necessary.


121-126: LGTM on the macro applications.

The specialization coverage is complete:

  • AbstractClass* - identity cast
  • ObjectClass*, TechnoClass*, FootClass* - use generic_cast (flag-based validation)
  • MissionClass*, RadioClass* - use reinterpret via TechnoClass

128-134: Good practice: cleaning up macros after use.

Undefining the macros prevents pollution of the global namespace and potential conflicts in files that include this header.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant