Skip to content

Commit

Permalink
Fix PVS-Studio warning №V802
Browse files Browse the repository at this point in the history
V802 On 64-bit platform, structure size can be reduced from 48 to 40
bytes by rearranging the fields according to their sizes in decreasing
order.

Also replace one LPCSTR to pcstr
  • Loading branch information
Xottab-DUTY committed Dec 24, 2017
1 parent 4fa8d8f commit c1e0f24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
9 changes: 5 additions & 4 deletions src/xrCore/LocatorAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class XRCORE_API CLocatorAPI
public:
struct file
{
LPCSTR name; // low-case name
pcstr name; // low-case name
u32 vfs; // 0xffffffff - standart file
u32 crc; // contents CRC
u32 ptr; // pointer inside vfs
Expand All @@ -55,12 +55,13 @@ class XRCORE_API CLocatorAPI

struct archive
{
u32 size;
u32 vfs_idx;
shared_str path;
void *hSrcFile, *hSrcMap;
u32 size;
CInifile* header;
u32 vfs_idx;
archive() : hSrcFile(nullptr), hSrcMap(nullptr), header(nullptr), size(0), vfs_idx(u32(-1)) {}

archive() : size(0), vfs_idx(u32(-1)), hSrcFile(nullptr), hSrcMap(nullptr), header(nullptr) {}
void open();
void close();
};
Expand Down
18 changes: 10 additions & 8 deletions src/xrGame/ai/monsters/ai_monster_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,16 @@ using AA_VECTOR = xr_vector<SAAParam>;

struct SCurrentAnimationInfo
{
shared_str name;

u8 index;

TTime time_started;
float speed_change_vel;

private:
EMotionAnim motion;

public:
shared_str name;
CBlend* blend;

struct
{
Expand All @@ -392,21 +397,18 @@ struct SCurrentAnimationInfo
{
target = v;
VERIFY2(_abs(v) < 1000, "_set_target(). monster speed is too big");

}
IC float _get_current() { return current; }
IC float _get_target() { return target; }

private:
float current;
float target;
} speed;

float speed_change_vel;
CBlend* blend;

void set_motion(EMotionAnim new_motion);
EMotionAnim get_motion() const { return motion; }
private:
EMotionAnim motion;
};

//////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit c1e0f24

Please sign in to comment.