Commit 145899a0 authored by Gerhard Stein's avatar Gerhard Stein

Pointer removals

parent 39e1bfab
......@@ -38,6 +38,12 @@ public:
template<typename T> T* occurredEvent();
void pop_Event() { m_EventList.pop_front(); }
// Spawning Event for the Foes
void spawnObj(const CSpriteObject *obj)
{
add(new EventSpawnObject( obj ));
}
private:
std::deque< std::shared_ptr<CEvent> > m_EventList;
};
......
......@@ -22,7 +22,6 @@
#include "graphics/CGfxEngine.h"
#include "common/CSpriteObject.h"
#include "common/CMap.h"
#include "SmartPointer.h"
class CTitle
{
......
......@@ -5,6 +5,8 @@
* Author: gerstrong
*/
#include <memory>
#include "CLevelPlay.h"
#include "ep4/CMapLoaderGalaxyEp4.h"
#include "ep5/CMapLoaderGalaxyEp5.h"
......@@ -29,12 +31,12 @@ CMapPlayGalaxy(ExeFile, Inventory, Cheatmode)
void CLevelPlay::loadMap(const int level)
{
// Load the World map level.
SmartPointer<CMapLoaderGalaxy> MapLoader;
std::unique_ptr<CMapLoaderGalaxy> MapLoader;
if(g_pBehaviorEngine->getEpisode() == 4)
MapLoader = new CMapLoaderGalaxyEp4(mExeFile, mObjectPtr, mInventory, mCheatmode);
MapLoader.reset(new CMapLoaderGalaxyEp4(mExeFile, mObjectPtr, mInventory, mCheatmode));
else if(g_pBehaviorEngine->getEpisode() == 5)
MapLoader = new CMapLoaderGalaxyEp5(mExeFile, mObjectPtr, mInventory, mCheatmode);
MapLoader.reset(new CMapLoaderGalaxyEp5(mExeFile, mObjectPtr, mInventory, mCheatmode));
MapLoader->loadMap( mMap, level );
......
......@@ -403,14 +403,14 @@ CGalaxySpriteObject* CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, siz
if( foe == i )
{
const Uint32 newsprite = 103+2*(i-61);
p_newfoe = new galaxy::CSpriteItem(&Map, foe, x, y, m_ObjectPtr, newsprite);
p_newfoe = new galaxy::CSpriteItem(&Map, foe, x, y, newsprite);
}
}
// Neuronal-stunner
if( foe == 68 )
{
p_newfoe = new galaxy::CSpriteItem(&Map, foe, x, y, m_ObjectPtr, 127);
p_newfoe = new galaxy::CSpriteItem(&Map, foe, x, y, 127);
}
// Gems
......@@ -419,7 +419,7 @@ CGalaxySpriteObject* CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, siz
if( foe == i )
{
const Uint32 newsprite = 118+2*(i-57);
p_newfoe = new galaxy::CSpriteItem(&Map, foe, x, y, m_ObjectPtr, newsprite);
p_newfoe = new galaxy::CSpriteItem(&Map, foe, x, y, newsprite);
}
}
......
......@@ -110,7 +110,6 @@ CPlayerBase::CPlayerBase(
const Uint16 foeID,
Uint32 x,
Uint32 y,
std::vector< SmartPointer<CGalaxySpriteObject> >& ObjectPtrs,
direction_t facedir,
CInventory &l_Inventory,
stCheat &Cheatmode) :
......@@ -118,7 +117,6 @@ CGalaxySpriteObject(pmap, foeID, x, y),
m_Inventory(l_Inventory),
m_camera(pmap,x,y,this),
mPlayerNum(0),
m_ObjectPtrs(ObjectPtrs),
m_Cheatmode(Cheatmode),
mp_processState(NULL)
{
......@@ -140,7 +138,10 @@ void CPlayerBase::getAnotherLife(const int lc_x, const int lc_y, const bool disp
m_Inventory.Item.m_lifes++;
g_pSound->playSound( SOUND_EXTRA_LIFE );
if(display)
m_ObjectPtrs.push_back(new CItemEffect(mp_Map, 0, lc_x<<CSF, lc_y<<CSF, got_sprite_item_pics[10], FADEOUT));
{
CItemEffect *lifeUp = new CItemEffect(mp_Map, 0, lc_x<<CSF, lc_y<<CSF, got_sprite_item_pics[10], FADEOUT);
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( lifeUp ) );
}
}
......@@ -259,7 +260,8 @@ void CPlayerBase::processLevelMiscFlagsCheck()
const int lc_x = l_x>>CSF;
const int lc_y = l_y>>CSF;
mp_Map->setTile( lc_x, lc_y, 0, true, 1 );
m_ObjectPtrs.push_back(new CItemEffect(mp_Map, 0, lc_x<<CSF, lc_y<<CSF, 215, ANIMATE));
CItemEffect *iEffect = new CItemEffect(mp_Map, 0, lc_x<<CSF, lc_y<<CSF, 215, ANIMATE);
g_pBehaviorEngine->m_EventList.spawnObj( iEffect );
m_Item.m_drops++;
if(m_Item.m_drops >= 100)
......@@ -280,8 +282,7 @@ void CPlayerBase::processLevelMiscFlagsCheck()
const int lc_x = l_x>>CSF;
const int lc_y = l_y>>CSF;
mp_Map->setTile( lc_x, lc_y, 0, true, 1 );
m_ObjectPtrs.push_back(new CItemEffect(mp_Map, 0, lc_x<<CSF, lc_y<<CSF, got_sprite_item_pics[4+i-21], FADEOUT));
g_pBehaviorEngine->m_EventList.spawnObj( new CItemEffect(mp_Map, 0, lc_x<<CSF, lc_y<<CSF, got_sprite_item_pics[4+i-21], FADEOUT) );
switch(i)
{
case 21: m_Item.m_points += 100; g_pSound->playSound( SOUND_GET_BONUS ); break;
......
......@@ -82,7 +82,6 @@ public:
const Uint16 foeID,
Uint32 x,
Uint32 y,
std::vector< SmartPointer<CGalaxySpriteObject> >& ObjectPtrs,
direction_t facedir,
CInventory &l_Inventory,
stCheat &Cheatmode);
......@@ -159,9 +158,7 @@ protected:
bool checkMapBoundaryR(const int x2);
bool checkMapBoundaryU(const int y1);
unsigned short mPlayerNum;
std::vector< SmartPointer<CGalaxySpriteObject> >& m_ObjectPtrs;
unsigned short mPlayerNum;
Sint16 m_playcontrol[PA_MAX_ACTIONS];
int m_timer;
......
......@@ -47,10 +47,11 @@ CPlayerLevel::CPlayerLevel(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y,
std::vector< SmartPointer<CGalaxySpriteObject> > &ObjectPtrs, direction_t facedir,
CInventory &l_Inventory, stCheat &Cheatmode,
const size_t offset) :
CPlayerBase(pmap, foeID, x, y, ObjectPtrs, facedir, l_Inventory, Cheatmode),
CPlayerBase(pmap, foeID, x, y, facedir, l_Inventory, Cheatmode),
m_jumpdownfromobject(false),
mPlacingGem(false),
mPoleGrabTime(0)
mPoleGrabTime(0),
mObjectPtrs(ObjectPtrs)
{
mActionMap[A_KEEN_STAND] = (void (CPlayerBase::*)()) &CPlayerLevel::processStanding;
mActionMap[A_KEEN_ON_PLAT] = (void (CPlayerBase::*)()) &CPlayerLevel::processStanding;
......@@ -527,18 +528,19 @@ void CPlayerLevel::processLookingDown()
// This special code is important, so platforms in all cases will catch Keen when he is falling on them
void CPlayerLevel::processMoveBitDown()
{
for( size_t i = 0 ; i<m_ObjectPtrs.size() ; i++ )
{
if(m_ObjectPtrs[i]->hitdetect(*this))
{
if( CPlatform *platform = dynamic_cast<CPlatform*>(m_ObjectPtrs[i].get()) )
{
platform->getTouchedBy(*this);
}
}
auto obj = mObjectPtrs.begin();
for( ; obj != mObjectPtrs.end() ; obj++ )
{
if( CPlatform *platform = dynamic_cast<CPlatform*>(obj->get()) )
{
if(platform->hitdetect(*this))
{
platform->getTouchedBy(*this);
}
}
}
CSpriteObject::processMoveBitDown();
CSpriteObject::processMoveBitDown();
}
......@@ -571,7 +573,7 @@ void CPlayerLevel::tryToShoot( const VectorD2<int> &pos, const int xDir, const i
{
if(m_Inventory.Item.m_bullets > 0)
{
m_ObjectPtrs.push_back(new CBullet(mp_Map, 0, pos.x, pos.y, xDir, yDir));
g_pBehaviorEngine->m_EventList.spawnObj(new CBullet(mp_Map, 0, pos.x, pos.y, xDir, yDir));
m_Inventory.Item.m_bullets--;
}
else
......
......@@ -272,7 +272,8 @@ private:
bool m_hanging;
int mPoleGrabTime;
int mClimbSpeedX;
std::vector< SmartPointer<CGalaxySpriteObject> > &mObjectPtrs;
};
}
......
......@@ -20,12 +20,10 @@ CPlayerWM::CPlayerWM(CMap *pmap,
const Uint16 foeID,
Uint32 x,
Uint32 y,
std::vector< SmartPointer<CGalaxySpriteObject> > &ObjectPtrs,
CInventory &l_Inventory,
stCheat &Cheatmode,
const unsigned int actionoffset):
CPlayerBase(pmap, foeID, x, y,
ObjectPtrs,
LEFT,
l_Inventory,
Cheatmode),
......@@ -621,8 +619,8 @@ void CPlayerWM::finishLevel(Uint16 object)
VectorD2<Uint32> dst(csfX, csfY);
CFlag *pFlag = new CFlag(mp_Map, src, dst);
m_ObjectPtrs.push_back(pFlag);
CFlag *pFlag = new CFlag(mp_Map, src, dst);
g_pBehaviorEngine->m_EventList.spawnObj(pFlag);
g_pSound->playSound( SOUND_FLAG_APPEAR );
// Mark the tileinfo on the map as marked!!
......@@ -634,9 +632,9 @@ void CPlayerWM::finishLevel(Uint16 object)
* This is the function will switch between swim and walk mode
* Those are the tileproperties to check for
* 11 Enter water from top Keen 4
* 12 Enter water from right Keen 4
* 12 Enter water from right Keen 4
* 13 Enter water from bottom Keen 4
* 14 Enter water from left Keen 4
* 14 Enter water from left Keen 4
*/
void CPlayerWM::checkforSwimming(bool &bleft, bool &bright, bool &bup, bool &bdown)
{
......
......@@ -19,7 +19,6 @@ public:
const Uint16 foeID,
Uint32 x,
Uint32 y,
std::vector< SmartPointer<CGalaxySpriteObject> > &ObjectPtrs,
CInventory &l_Inventory,
stCheat &Cheatmode,
const unsigned int actionoffset);
......
......@@ -15,10 +15,8 @@ namespace galaxy {
const int MAX_ANIMATION_TIMER = 20;
CSpriteItem::CSpriteItem(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y,
std::vector< SmartPointer<CGalaxySpriteObject> > &ObjectPtrs, Uint32 sprite) :
CGalaxySpriteObject(pmap, foeID, x, y),
m_ObjectPtrs(ObjectPtrs)
CSpriteItem::CSpriteItem(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y, Uint32 sprite) :
CGalaxySpriteObject(pmap, foeID, x, y)
{
m_basesprite = sprite;
m_timer = (y*256+x)%MAX_ANIMATION_TIMER;
......@@ -75,7 +73,8 @@ void CSpriteItem::getTouchedBy(CSpriteObject &theObject)
g_pSound->playSound( SOUND_GET_AMMO );
}
m_ObjectPtrs.push_back(new CItemEffect(mp_Map, 0, getXPosition(), getYPosition(), newanimsprite, FADEOUT));
g_pBehaviorEngine->m_EventList.spawnObj(new CItemEffect(mp_Map, 0, getXPosition(), getYPosition(), newanimsprite, FADEOUT));
// Now add the stuff to the inventory
......
......@@ -21,15 +21,13 @@ namespace galaxy {
class CSpriteItem : public CGalaxySpriteObject
{
public:
CSpriteItem(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y,
std::vector< SmartPointer<CGalaxySpriteObject> > &ObjectPtrs, Uint32 sprite);
CSpriteItem(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y, Uint32 sprite);
void process();
void getTouchedBy(CSpriteObject &theObject);
private:
int m_timer;
Uint32 m_basesprite;
std::vector< SmartPointer<CGalaxySpriteObject> > &m_ObjectPtrs;
};
}
......
......@@ -19,12 +19,10 @@ CPlayerDive::CPlayerDive(CMap *pmap,
const Uint16 foeID,
Uint32 x,
Uint32 y,
std::vector< SmartPointer<CGalaxySpriteObject> > &ObjectPtrs,
direction_t facedir,
CInventory &l_Inventory,
stCheat &Cheatmode) :
CPlayerBase(pmap, foeID, x, y,
ObjectPtrs,
facedir,
l_Inventory,
Cheatmode),
......
......@@ -19,7 +19,6 @@ public:
const Uint16 foeID,
Uint32 x,
Uint32 y,
std::vector< SmartPointer<CGalaxySpriteObject> > &ObjectPtrs,
direction_t facedir,
CInventory &l_Inventory,
stCheat &Cheatmode);
......
......@@ -95,7 +95,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp4::addFoe(CMap &Map, word foe, size_t x,
case 3:
// This is the player on the world map
// Add the Camera into the game scene and attach it to this player
p_newfoe = new galaxy::CPlayerWM(&Map, foe, x, y, m_ObjectPtr, m_Inventory, m_Cheatmode, 0x15C2);
p_newfoe = new galaxy::CPlayerWM(&Map, foe, x, y, m_Inventory, m_Cheatmode, 0x15C2);
break;
......@@ -208,7 +208,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp4::addFoe(CMap &Map, word foe, size_t x,
// Place a gun in case Keen is missing bullets
if(m_Inventory.Item.m_bullets < 5)
{
p_newfoe = new galaxy::CSpriteItem(&Map, foe, x, y, m_ObjectPtr, 127);
p_newfoe = new galaxy::CSpriteItem(&Map, foe, x, y, 127);
}
break;
......@@ -219,7 +219,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp4::addFoe(CMap &Map, word foe, size_t x,
case 42:
// This is Keen in the swimming suit
p_newfoe = new galaxy::CPlayerDive(&Map, foe, x, y, m_ObjectPtr,
p_newfoe = new galaxy::CPlayerDive(&Map, foe, x, y,
RIGHT, m_Inventory, m_Cheatmode);
break;
......
......@@ -68,9 +68,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp5::addFoe(CMap &Map, word foe, size_t x,
case 3:
// This is the player on the world map
// Add the Camera into the game scene and attach it to this player
p_newfoe = new galaxy::CPlayerWM(&Map,
foe, x, y, m_ObjectPtr,
m_Inventory, m_Cheatmode, 0x146e );
p_newfoe = new galaxy::CPlayerWM(&Map,foe, x, y, m_Inventory, m_Cheatmode, 0x146e );
break;
......
......@@ -17,7 +17,6 @@
#include <memory>
#include "CEffects.h"
#include "SmartPointer.h"
#include "graphics/CBitmap.h"
#include "sdl/CTimer.h"
......
......@@ -28,7 +28,7 @@ void CVibrate::process()
else { m_dir_x = 0; m_dir_y = 0; }
// then erase the entire old surface ...
mpVibSfc = SDL_DisplayFormat(sfc);
mpVibSfc.reset( SDL_DisplayFormat(sfc), &SDL_FreeSurface );
SDL_FillRect(sfc, &gamerect, SDL_MapRGB(sfc->format, 0,0,0));
// ... and create that moved to some direction;
......
......@@ -8,9 +8,10 @@
#ifndef CVIBRATE_H_
#define CVIBRATE_H_
#include <memory>
#include "CEffects.h"
#include "sdl/CTimer.h"
#include "SmartPointer.h"
class CVibrate : public CEffects
{
......@@ -25,7 +26,7 @@ private:
char m_dir_x, m_dir_y;
SmartPointer<SDL_Surface> mpVibSfc;
std::shared_ptr<SDL_Surface> mpVibSfc;
};
#endif /* CVIBRATE_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment