From 2484310b5c5241425d851f54da2bea4105251fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Mustoha?= Date: Sun, 13 Oct 2024 00:05:38 +0200 Subject: [PATCH] Simplified the world player class --- src/smw/ui/MI_World.cpp | 2 -- src/smw/world.cpp | 16 +++++----------- src/smw/world.h | 19 ++++++------------- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/smw/ui/MI_World.cpp b/src/smw/ui/MI_World.cpp index 07765203..81e4a6b4 100644 --- a/src/smw/ui/MI_World.cpp +++ b/src/smw/ui/MI_World.cpp @@ -61,8 +61,6 @@ void MI_World::Init() iAnimationFrame = 0; iDrawFullRefresh = 0; - g_worldmap.InitPlayer(); - iMapDrawOffsetCol = 0; iMapDrawOffsetRow = 0; diff --git a/src/smw/world.cpp b/src/smw/world.cpp index 795cd622..13166dbd 100644 --- a/src/smw/world.cpp +++ b/src/smw/world.cpp @@ -151,14 +151,12 @@ void WorldMovingObject::SetPosition(short iCol, short iRow) * WorldPlayer **********************************/ -WorldPlayer::WorldPlayer() : - WorldMovingObject() -{} - -WorldPlayer::~WorldPlayer() +WorldPlayer::WorldPlayer() + : WorldPlayer(0, 0) {} -void WorldPlayer::Init(short iCol, short iRow) +WorldPlayer::WorldPlayer(short iCol, short iRow) + : WorldMovingObject() { WorldMovingObject::Init(iCol, iRow, 0, 0, 32); } @@ -553,6 +551,7 @@ bool WorldMap::Load(short tilesize) if (tile.iType == 1) { iStartX = iMapTileReadCol; iStartY = iMapTileReadRow; + player.SetPosition(iStartX, iStartY); } tile.iCompleted = tile.iType <= 5 ? -1 : -2; @@ -1057,11 +1056,6 @@ void WorldMap::Resize(short w, short h) } } -void WorldMap::InitPlayer() -{ - player.Init(iStartX, iStartY); -} - bool WorldMap::Update(bool * fPlayerVehicleCollision) { bool fPlayMovingVehicleSound = false; diff --git a/src/smw/world.h b/src/smw/world.h index b862d31c..f5b6130d 100644 --- a/src/smw/world.h +++ b/src/smw/world.h @@ -49,7 +49,6 @@ class WorldMovingObject void Init(short iCol, short iRow, short iSprite, short iInitialDirection, short tilesize); virtual void Move(short iDirection); virtual bool Update(); - void Draw(short iWorldOffsetX, short iWorldOffsetY); void FaceDirection(short iDirection); void SetPosition(short iCol, short iRow); @@ -75,19 +74,13 @@ class WorldMovingObject friend void takescreenshot(); }; -class WorldPlayer : public WorldMovingObject -{ - public: - - WorldPlayer(); - ~WorldPlayer(); - - void Init(short iCol, short iRow); - - void SetSprite(short iPlayer); - void Draw(short iWorldOffsetX, short iWorldOffsetY) const; +class WorldPlayer : public WorldMovingObject { +public: + WorldPlayer(); + WorldPlayer(short iCol, short iRow); - friend class WorldMap; + void SetSprite(short iPlayer); + void Draw(short iWorldOffsetX, short iWorldOffsetY) const; }; class WorldVehicle : public WorldMovingObject