Thanks to visit codestin.com
Credit goes to github.com

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.
  • Enhancements

    • Renamed and standardized a public power-related field to improve state clarity.
  • Bug Fixes

    • Updated super-weapon targeting/lookup logic for more reliable 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 of HouseClass::FindSuperWeapon accepting a SuperWeaponTypeClass*, renames a public field unknown_power_160B4 to PowerSurplus (type changed to int), and includes SuperWeaponTypeClass in HouseClass.h.

Changes

Cohort / File(s) Summary
HouseClass updates
src/HouseClass.h
Added SuperClass* FindSuperWeapon(SuperWeaponTypeClass* type) const; renamed public member DWORD unknown_power_160B4 -> int PowerSurplus; added include for SuperWeaponTypeClass. Review callers and ABI/public API usage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

"I am a rabbit, nibbling code at night,
A new helper added, and a field set right.
FindSuperWeapon now knows a newer key,
PowerSurplus counts what once could not be.
Hoppity hops — compile and delight! 🐇✨"

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Update' is vague and generic, providing no meaningful information about the specific changes made to the codebase. Replace with a more descriptive title that captures the main changes, such as 'Add FindSuperWeapon overload and rename PowerSurplus in HouseClass' or 'Extend HouseClass with SuperWeapon type lookup and power tracking.'
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 08bcef4 and 6bbaa01.
Files selected for processing (1)
  • ObjectClass.h (3 hunks)
Additional comments: 3
ObjectClass.h (3)
  • 11-11: The addition of #include <RulesClass.h> is appropriate for the new functionality introduced in this file, specifically for accessing RulesClass::Instance->C4Warhead in the overloaded TakeDamage method. This change ensures that the file has access to necessary game rules and configurations.
  • 271-274: The first TakeDamage method added to ObjectClass includes parameters for specifying a WarheadTypeClass. This method correctly forwards these parameters to ReceiveDamage and handles the crewed and ignoreDefenses flags as per the previous review comments. Ensure that the logic for handling these flags is thoroughly tested, especially the inversion of the crewed flag to !crewed for the PreventPassengerEscape parameter in ReceiveDamage, as this could have nuanced effects on game mechanics.
  • 276-279: The second TakeDamage method simplifies damage application by using a default warhead type from RulesClass. This method correctly forwards parameters to the first TakeDamage method, ensuring consistency in how damage is applied. Confirm that the default warhead type (C4Warhead) is appropriate for all use cases where this method might be called. This approach simplifies the method's usage for common damage scenarios but requires careful consideration of the default warhead's impact across different object types.

Comment on lines +200 to +201
DirStruct Direction(AbstractClass* pTarget)
{ JMP_THIS(0x5F3DB0); }
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The verification process reveals that the DistanceFrom method is still referenced in various parts of the codebase, indicating that it has not been entirely replaced by the Direction method. The Direction method is indeed present in ObjectClass.h, but the continued presence of DistanceFrom suggests that either the replacement process is incomplete or both methods are intended to coexist, serving different functionalities. It's important to review the specific use cases of both methods to ensure they are correctly integrated and used where appropriate.

Analysis chain

The method DirStruct Direction(AbstractClass* pTarget) replaces the previous DistanceFrom method. This change shifts the functionality from calculating distance to determining direction, which could be more relevant for certain game mechanics. Ensure that all calls to the old DistanceFrom method are updated to use the new Direction method where appropriate. This change might require a thorough search through the codebase to update method calls and verify that the new method's return type and usage align with the existing logic.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for old `DistanceFrom` method usage. Expecting no results.
ast-grep --lang cpp --pattern $'DistanceFrom($_)'
# Search for new `Direction` method usage to validate integration. Expecting list of locations.
ast-grep --lang cpp --pattern $'Direction($_)'

Length of output: 98



Script:

#!/bin/bash
# Search for references to the old `DistanceFrom` method in the entire codebase.
rg 'DistanceFrom' --type cpp
# Search for references to the new `Direction` method in the entire codebase.
rg 'Direction' --type cpp

Length of output: 1238

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 6bbaa01 and 78531b1.
Files selected for processing (2)
  • FootClass.h (2 hunks)
  • TechnoClass.h (8 hunks)
Additional comments: 12
FootClass.h (2)
  • 154-154: The introduction of the PlayingMovingSound property is a good enhancement for managing the state of moving sounds. Ensure that this property is properly updated in all relevant methods where the movement state of the unit changes. This might include starting movement, stopping movement, or any other state changes that could affect whether the unit should be playing a moving sound.
  • 155-155: The addition of the MovingSoundDelay property is a thoughtful improvement for controlling the timing of moving sounds. It's crucial to ensure that this delay is utilized effectively in the logic that handles sound playing to avoid sound spamming or delays that are too long, which could lead to a lack of audio feedback for the player. Consider adding validation or constraints to ensure the delay value is within a reasonable range.
TechnoClass.h (10)
  • 26-26: The addition of the EBolt class forward declaration is appropriate and aligns with the introduction of new electric attack functionalities like Electric_Zap.
  • 194-194: Changing the method signature from DirStruct* to FacingClass* for TurretFacing likely enhances the handling of facing directions, aligning with the overall improvements in direction and facing handling mentioned in the summary.
  • 218-218: The method signature change from DirStruct* to FacingClass* for GetRealFacing is consistent with other updates in the file, likely offering improved direction handling capabilities.
  • 370-370: Changing the parameter type from ObjectClass* to AbstractClass* in CreateLaser method increases the flexibility in what can be targeted, aligning with the objective of enhancing functionality.
  • 354-356: The addition of the InRange method enhances combat dynamics by allowing checks for whether a target is within range of a weapon, aligning with the system's objectives to refine combat and interaction capabilities.
  • 358-360: The Fire_IgnoreType method introduces a significant enhancement in combat flexibility by allowing units to fire weapons regardless of the unit type, contributing to more strategic gameplay options.
  • 373-375: The addition of the Electric_Zap method diversifies combat strategies by introducing electric-based attacks, aligning with the system's objectives to refine and expand combat capabilities.
  • 376-378: The DrawALinkTo method contributes to visual enhancements by potentially allowing the drawing of visual effects or connections between two points, improving game clarity and immersion.
  • 632-632: Renaming DiskLaserTimer to ROFTimer improves clarity and maintainability by indicating a broader use case for the variable, likely applicable to various weapons' rate of fire.
  • 706-706: Renaming unknown_bool_432 to WasSelected significantly improves code readability and maintainability by clearly indicating the variable's purpose, likely related to UI or selection mechanics.

virtual void vt_entry_540(DWORD dwUnk) RX;
virtual void SetSpeedPercentage(double percentage) RX;
virtual void vt_entry_548() RX;
virtual void vt_entry_548() RX; // StopMoving?
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 the virtual method vt_entry_548 is noted, which is commented as potentially related to stopping movement. It's important to ensure that this method is properly overridden in derived classes if they have specific behaviors related to stopping movement. Additionally, consider providing a more descriptive method name or detailed comments to clarify its purpose and usage within the class hierarchy.

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.

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