Skip to content

Commit

Permalink
Removed the class friends from the object base
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Apr 14, 2024
1 parent f352cf8 commit 2f85d0e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 25 deletions.
6 changes: 6 additions & 0 deletions src/common/ObjectBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "GlobalConstants.h"
#include "map.h"
#include "gfx/gfxSprite.h"

extern CMap* g_map;

Expand Down Expand Up @@ -78,3 +79,8 @@ std::array<IO_Block*, 4> CObject::GetCollisionBlocks() const

return blocks;
}

bool CObject::GetWrap() const
{
return spr ? spr->GetWrap() : true;
}
30 changes: 7 additions & 23 deletions src/common/ObjectBase.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#pragma once

#include "gfx/gfxSprite.h"

#include <array>

class gfxSprite;
class CPlayer;
class IO_Block;
class IO_MovingObject;
Expand Down Expand Up @@ -61,44 +60,29 @@ class CObject {
fy = static_cast<float>(iy);
}

int iNetworkID;
short ix, iy;
short iw = 0, ih = 0;
float velx = 0.f, vely = 0.f;
int iNetworkID;

short collisionWidth;
short collisionHeight;
short collisionOffsetX = 0;
short collisionOffsetY = 0;

short GetState() const {
return state;
}
bool isDead() const {
return dead;
}
bool GetWrap() const {
return spr ? spr->GetWrap() : true;
}
short GetState() const { return state; }
bool isDead() const { return dead; }
bool GetWrap() const;

/// Returns the blocks touching each of the four corners,
std::array<IO_Block*, 4> GetCollisionBlocks() const;

protected:
ObjectType objectType = object_none;

short iw = 0, ih = 0;
float fx = 0.f, fy = 0.f;
float velx = 0.f, vely = 0.f;

gfxSprite* spr = nullptr;
short state = 0;
bool dead = false;

friend class CObjectContainer;
friend class CPlayer;
friend void RunGame();
friend void shakeScreen();
friend void handleP2ObjCollisions();
friend class CO_Shell;
friend class B_BreakableBlock;
friend class B_WeaponBreakableBlock;
};
2 changes: 1 addition & 1 deletion src/smw/ObjectContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void CObjectContainer::clean()
void CObjectContainer::cleanDeadObjects()
{
auto erase_from = std::remove_if(m_list.begin(), m_list.end(),
[](const std::unique_ptr<CObject>& obj) { return obj->dead; });
[](const std::unique_ptr<CObject>& obj) { return obj->isDead(); });
m_list.erase(erase_from, m_list.end());
}

Expand Down
2 changes: 1 addition & 1 deletion src/smw/objects/moving/MO_CarriedObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MO_CarriedObject : public IO_MovingObject {
virtual void Drop();
virtual void Kick();

bool HasOwner() { return owner != NULL; }
bool HasOwner() { return owner != nullptr; }
bool IsCarriedByKuriboShoe() { return fCarriedByKuriboShoe; }

protected:
Expand Down
1 change: 1 addition & 0 deletions src/smw/objects/moving/Powerup.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Powerup.h"

#include "GlobalConstants.h"
#include "gfx/gfxSprite.h"

//------------------------------------------------------------------------------
// class powerup
Expand Down

0 comments on commit 2f85d0e

Please sign in to comment.