Commit a0a6314a authored by gerstrong@gmail.com's avatar gerstrong@gmail.com

Fixed broken virtualisations between classes. Now the enemies in galaxy games...

Fixed broken virtualisations between classes. Now the enemies in galaxy games behaviour correctly again.
parent 56d1b066
......@@ -265,7 +265,7 @@ Requirements:
Build Tools. Works best with GNU Compiler and Clang
which supports at least C++14.
CMake 3.12 or later. If you use an older version if CMake you will have to
CMake 3.12 or later. If you use an older version of CMake you will have to
disable Python Support (cmake -DUSE_PYTHON3=0).
SDL2, SDL2_Image and SDL2_mixer. There is support for SDL1.2
......
......@@ -23,16 +23,11 @@ int CSpriteObject::m_number_of_objects = 0; // The current number of total objec
// Initialization Routine
///
CSpriteObject::CSpriteObject(CMap *pmap,
Uint32 x, Uint32 y,
const int x, const int y,
const int spriteVar) :
m_index(m_number_of_objects),
mHealthPoints(1),
mSpriteIdx(BLANKSPRITE),
m_jumpdownfromobject(false),
mpMap(pmap),
m_blinktime(0),
m_Pos(x,y),
transluceny(0),
mSprVar(spriteVar)
{
m_number_of_objects++;
......
......@@ -112,19 +112,22 @@ void spawnObj(const CSpriteObject *obj);
class CSpriteObject
{
public:
CSpriteObject(CMap *pmap, Uint32 x, Uint32 y, const int spriteVar);
CSpriteObject(CMap *pmap,
const int x,
const int y,
const int spriteVar);
unsigned int m_index; // Like an ID for some objects that need this implementation
int m_index; // Like an ID for some objects that need this implementation
unsigned int mHealthPoints; // episode 1 style four-shots-to-kill
unsigned int mHealthPoints = 1; // episode 1 style four-shots-to-kill
bool mTurnAroundOnCliff = false; // Can enemy turn around if there is a cliff
bool mEndGameOnDefeat = false; // End game if enemy is defeated. Useful for the last boss in some mods
bool exists;
bool onscreen; // true=(scrx,scry) position is visible onscreen
bool hasbeenonscreen;
int mSpriteIdx; // which sprite should this object be drawn with
int mSpriteIdx = -1; // which sprite should this object be drawn with
int xDirection; // the direction to where the object is looking/heading to
int yDirection; // same for vertical
......@@ -157,7 +160,7 @@ class CSpriteObject
bool mIsDead, dying;
bool m_jumpdownfromobject;
bool m_jumpdownfromobject = false;
......@@ -412,7 +415,7 @@ class CSpriteObject
CMap *mpMap;
Uint16 m_blinktime;
Uint16 m_blinktime = 0;
bool mInvincible = false; /** Shot might hit the object but it has no effect at all */
bool mRecoverFromStun = false; /** If foe get shot they might be able to recover at later time */
bool mNeverStop = false; /** This will make foe continue walking and never change actions (Keen 9 - Cybloog) */
......@@ -429,7 +432,7 @@ class CSpriteObject
// Action Format related stuff
ActionFormatType m_Action;
Uint8 transluceny;
Uint8 transluceny = 0;
protected:
......
......@@ -13,14 +13,13 @@ public:
AutoShot(CMap *pmap, const Uint32 foeID, const Uint32 x, const Uint32 y,
direction_t horDir, direction_t vertDir, int basesprite, const int sprVar);
void process();
void process() override;
void getTouchedBy(CSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject) override;
void deserialize(boost::property_tree::ptree &node) override;
void deserialize(boost::property_tree::ptree &node);
void serialize(boost::property_tree::ptree &node);
void serialize(boost::property_tree::ptree &node) override;
private:
......
......@@ -13,7 +13,7 @@ namespace galaxy
const int A_SLUGPOISON_NORMAL = 0;
const int A_SLUGPOISON_FADE = 1;
//const int A_SLUGPOISON_FADE = 1;
const int POISON_TIME = 1;
CSlugSlime::CSlugSlime(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y, const int sprVar) :
......
......@@ -10,8 +10,8 @@
CVorticonSpriteObject::CVorticonSpriteObject(CMap *pmap,
Uint32 x, Uint32 y,
object_t type, const int sprVar) :
const int x, const int y,
const object_t type, const int sprVar) :
CSpriteObject(pmap, x, y, sprVar),
m_type(type),
touchPlayer(0),
......
......@@ -14,16 +14,17 @@
class CVorticonSpriteObject : public CSpriteObject
{
public:
CVorticonSpriteObject(CMap *pmap, Uint32 x, Uint32 y, object_t type, const int sprVar=0);
CVorticonSpriteObject(CMap *pmap, const int x, const int y,
const object_t type, const int sprVar=0);
void setupObjectType(const int Episode);
bool checkforScenario();
bool calcVisibility();
bool calcVisibility() override;
//virtual bool isNearby(CVorticonSpriteObject &) { return true; }
virtual bool isNearby(CSpriteObject &) override { return true; }
//virtual void getTouchedBy(CVorticonSpriteObject &) {}
virtual void getTouchedBy(CSpriteObject &) override {}
object_t m_type; // yorp, vorticon, etc.
......
......@@ -26,7 +26,7 @@ mGunTimer(0)
}
bool CAutoRay::isNearby(CVorticonSpriteObject &theObject)
bool CAutoRay::isNearby(CSpriteObject &theObject)
{
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......
......@@ -18,7 +18,7 @@ class CAutoRay : public CVorticonSpriteObject
public:
enum stRayAlignment{ VERTICAL, HORIZONTAL };
CAutoRay(CMap *pmap, Uint32 x, Uint32 y, stRayAlignment type);
bool isNearby(CVorticonSpriteObject &theObject);
bool isNearby(CSpriteObject &theObject);
void process();
......
......@@ -34,7 +34,7 @@ CVorticonSpriteObject(pmap, x, y, type)
performCollisions();
}
void CBallJack::getTouchedBy(CVorticonSpriteObject &theObject)
void CBallJack::getTouchedBy(CSpriteObject &theObject)
{
if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
{
......
......@@ -16,7 +16,7 @@ class CBallJack : public CVorticonSpriteObject
{
public:
CBallJack(CMap *pmap, Uint32 x, Uint32 y, object_t type);
void getTouchedBy(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
void process();
void getShotByRay(object_t &obj_type);
......
......@@ -85,7 +85,7 @@ void CButler::process()
}
}
void CButler::getTouchedBy(CVorticonSpriteObject &theObject)
void CButler::getTouchedBy(CSpriteObject &theObject)
{ // push keen
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......
......@@ -37,7 +37,7 @@ class CButler : public CVorticonSpriteObject
public:
CButler(CMap *pmap, Uint32 x, Uint32 y);
void process();
void getTouchedBy(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
int checkSolidD( int x1, int x2, int y2, const bool push_mode=false );
......
......@@ -5,7 +5,7 @@ CCarrier::CCarrier(CMap* pmap, Uint32 x, Uint32 y, object_t type) :
CVorticonSpriteObject(pmap, x, y, type, 0)
{}
void CCarrier::getTouchedBy(CVorticonSpriteObject& theObject)
void CCarrier::getTouchedBy(CSpriteObject& theObject)
{
if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
{
......
......@@ -11,7 +11,7 @@ class CCarrier : public CVorticonSpriteObject
public:
CCarrier(CMap* pmap, Uint32 x, Uint32 y, object_t type);
virtual void getTouchedBy(CVorticonSpriteObject& theObject);
virtual void getTouchedBy(CSpriteObject& theObject);
virtual void process() = 0;
......
......@@ -2,7 +2,7 @@
#include "sdl/audio/Audio.h"
#include "graphics/GsGraphics.h"
CFoob::CFoob(CMap *p_map, Uint32 x, Uint32 y):
CFoob::CFoob(CMap *p_map, const int x, const int y):
CVorticonSpriteObject(p_map,x,y, OBJ_FOOB),
onsamelevel(false)
{
......@@ -172,7 +172,7 @@ void CFoob::process()
}
}
bool CFoob::isNearby(CVorticonSpriteObject &theObject)
bool CFoob::isNearby(CSpriteObject &theObject)
{
if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
{
......@@ -212,7 +212,7 @@ bool CFoob::isNearby(CVorticonSpriteObject &theObject)
return true;
}
void CFoob::getTouchedBy(CVorticonSpriteObject &theObject)
void CFoob::getTouchedBy(CSpriteObject &theObject)
{
if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
{
......
......@@ -38,10 +38,10 @@ const int FOOB_DEAD_FRAME = 101;
class CFoob : public CVorticonSpriteObject
{
public:
CFoob(CMap *p_map, Uint32 x, Uint32 y);
void process();
bool isNearby(CVorticonSpriteObject &theObject);
void getTouchedBy(CVorticonSpriteObject &theObject);
CFoob(CMap *p_map, const int x, const int y);
void process() override;
bool isNearby(CSpriteObject &theObject) override;
void getTouchedBy(CSpriteObject &theObject) override;
private:
enum FOOB_ACTIONS
......
......@@ -39,7 +39,7 @@ m_hardmode(gBehaviorEngine.mDifficulty==HARD)
}
}
bool CGarg::isNearby(CVorticonSpriteObject &theObject)
bool CGarg::isNearby(CSpriteObject &theObject)
{
if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
{
......@@ -82,7 +82,7 @@ bool CGarg::isNearby(CVorticonSpriteObject &theObject)
}
void CGarg::getTouchedBy(CVorticonSpriteObject &theObject)
void CGarg::getTouchedBy(CSpriteObject &theObject)
{
if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
{
......
......@@ -45,8 +45,8 @@ class CGarg : public CVorticonSpriteObject
public:
CGarg(CMap *p_map, Uint32 x, Uint32 y);
void process();
bool isNearby(CVorticonSpriteObject &theObject);
void getTouchedBy(CVorticonSpriteObject &theObject);
bool isNearby(CSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
void charge();
private:
......
......@@ -208,7 +208,7 @@ void CGuardRobot::guard_fire()
pausetime = FIRE_PAUSE_TIME;
}
void CGuardRobot::getTouchedBy(CVorticonSpriteObject &theObject)
void CGuardRobot::getTouchedBy(CSpriteObject &theObject)
{
if ( gBehaviorEngine.mDifficulty>=NORMAL )
{
......
......@@ -20,7 +20,7 @@ public:
CGuardRobot(CMap *p_map, Uint32 x, Uint32 y);
void process();
void guard_fire();
void getTouchedBy(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
private:
......
......@@ -28,7 +28,7 @@ silent(false)
blockedd = true;
}
bool CIceCannon::isNearby(CVorticonSpriteObject &theObject)
bool CIceCannon::isNearby(CSpriteObject &theObject)
{
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......@@ -95,7 +95,7 @@ silent(true)
void CIceChunk::getTouchedBy(CVorticonSpriteObject &theObject)
void CIceChunk::getTouchedBy(CSpriteObject &theObject)
{
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......@@ -162,7 +162,7 @@ void CIceChunk::process()
moveYDir(veloc_y);
}
bool CIceChunk::isNearby(CVorticonSpriteObject &theObject)
bool CIceChunk::isNearby(CSpriteObject &theObject)
{
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......
......@@ -19,7 +19,7 @@ class CIceCannon : public CVorticonSpriteObject
public:
CIceCannon(CMap *p_map, Uint32 x, Uint32 y,
int vector_x, int vector_y );
bool isNearby(CVorticonSpriteObject &theObject);
bool isNearby(CSpriteObject &theObject);
void process();
private:
......@@ -32,9 +32,9 @@ class CIceChunk : public CVorticonSpriteObject
{
public:
CIceChunk(CMap *p_map, Uint32 x, Uint32 y, Uint32 vx, Uint32 vy);
void getTouchedBy(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
void process();
bool isNearby(CVorticonSpriteObject &theObject);
bool isNearby(CSpriteObject &theObject);
void smash();
private:
int vector_x, vector_y;
......
......@@ -146,7 +146,7 @@ void CManglingMachine::process()
}
void CManglingMachine::getTouchedBy(CVorticonSpriteObject &theObject)
void CManglingMachine::getTouchedBy(CSpriteObject &theObject)
{
bool it_is_mortimer_machine = false;
......@@ -173,7 +173,7 @@ void CManglingMachine::getTouchedBy(CVorticonSpriteObject &theObject)
}
}
bool CManglingMachine::isNearby(CVorticonSpriteObject &theObject)
bool CManglingMachine::isNearby(CSpriteObject &theObject)
{
if(setype == SE_MORTIMER_SPARK && state == MSPARK_IDLE)
{
......
......@@ -29,8 +29,8 @@ class CManglingMachine : public CVorticonSpriteObject
public:
CManglingMachine(CMap *p_map, Uint32 x, Uint32 y, unsigned int se_type);
~CManglingMachine();
void getTouchedBy(CVorticonSpriteObject &theObject);
bool isNearby(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
bool isNearby(CSpriteObject &theObject);
void process();
void se_mortimer_arm();
void se_mortimer_spark();
......
......@@ -58,7 +58,7 @@ CVorticonSpriteObject(p_map,x,y, OBJ_MEEP)
}
bool CMeep::isNearby(CVorticonSpriteObject &theObject)
bool CMeep::isNearby(CSpriteObject &theObject)
{
if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
{
......@@ -87,7 +87,7 @@ bool CMeep::isNearby(CVorticonSpriteObject &theObject)
}
void CMeep::getTouchedBy(CVorticonSpriteObject &theObject)
void CMeep::getTouchedBy(CSpriteObject &theObject)
{
if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
{
......
......@@ -16,8 +16,8 @@ class CMeep : public CVorticonSpriteObject
public:
CMeep(CMap *p_map, Uint32 x, Uint32 y);
bool isNearby(CVorticonSpriteObject &theObject);
void getTouchedBy(CVorticonSpriteObject &theObject);
bool isNearby(CSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
void process();
private:
......
......@@ -33,10 +33,10 @@ public:
void getTouchedBy(CSpriteObject &theObject) override;
bool tryMounting(CPlayer &player);
bool tryToUnmount();
void process();
void process() override;
void move_nessie();
void nessie_find_next_checkpoint();
void processFalling() {}
void processFalling() override {}
private:
char state;
......
......@@ -5,8 +5,8 @@
* Author: gerstrong
*/
#ifndef CPLAYER_H_
#define CPLAYER_H_
#ifndef CPLAYER_H
#define CPLAYER_H
#include <base/GsEvent.h>
#include <SDL.h>
......@@ -90,9 +90,10 @@ public:
void touchedExit(int mpx);
void walkbehindexitdoor();
void kill(const bool force);
void kill();
void dieanim();
void kill(const bool force = false,
const bool noDieProcess = false) override;
void dieanim();
void setDir();
void getgoodies();
void keencicle();
......@@ -108,7 +109,7 @@ public:
void checkSolidDoors();
void SelectFrame();
LEVEL_TRIGGER pollLevelTrigger();
void getShotByRay(object_t &obj_type);
void getShotByRay(object_t &obj_type) override;
void processStatusScreen();
bool checkMapBoundaryL(const int x1) override;
......
......@@ -137,12 +137,8 @@ void CPlayer::walkbehindexitdoor()
}
}
void CPlayer::kill()
{
kill(false);
}
void CPlayer::kill(const bool force)
void CPlayer::kill(const bool force,
const bool noDieProcess)
{
if(!force) // force can happens for example, when player leaves the map to the most lower-side
{
......
......@@ -156,8 +156,11 @@ void CRay::moveinAir()
}
}
void CRay::getTouchedBy(CVorticonSpriteObject &theObject)
void CRay::getTouchedBy(CSpriteObject &neutralObject)
{
CVorticonSpriteObject &theObject =
dynamic_cast<CVorticonSpriteObject&>(neutralObject);
if( !theObject.mIsDead && !theObject.dying )
{
if(theObject.canbezapped && state == RAY_STATE_FLY )
......
......@@ -28,7 +28,7 @@ public:
void moveinAir();
void setOwner(object_t type, unsigned int index);
void setSpeed(size_t speed);
void getTouchedBy(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &neutralObject);
void getShotByRay(object_t &obj_type);
bool isFlying();
void setZapped();
......
......@@ -107,7 +107,7 @@ void CRope::rope_movestone()
falldist++;
}
void CRope::getTouchedBy(CVorticonSpriteObject &theObject)
void CRope::getTouchedBy(CSpriteObject &theObject)
{
if( state == ROPE_DROPSTONE && m_type==OBJ_ROPE )
{
......
......@@ -21,7 +21,7 @@ public:
void process();
void getShotByRay(object_t &obj_type);
void rope_movestone();
void getTouchedBy(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
private:
ropestates state;
......
......@@ -105,7 +105,7 @@ void CScrub::process()
}
}
void CScrub::getTouchedBy(CVorticonSpriteObject& theObject)
void CScrub::getTouchedBy(CSpriteObject& theObject)
{
CCarrier::getTouchedBy(theObject);
}
......
......@@ -17,7 +17,7 @@ public:
void process();
virtual void getTouchedBy(CVorticonSpriteObject& theObject);
virtual void getTouchedBy(CSpriteObject& theObject);
private:
......
......@@ -31,7 +31,7 @@ CVorticonSpriteObject(p_map, x, y, objtype, 0)
}
bool CTank::isNearby(CVorticonSpriteObject &theObject)
bool CTank::isNearby(CSpriteObject &theObject)
{
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......@@ -205,7 +205,7 @@ void CTank::process()
}
}
void CTank::getTouchedBy(CVorticonSpriteObject &theObject)
void CTank::getTouchedBy(CSpriteObject &theObject)
{ // push keen
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......
......@@ -58,8 +58,8 @@ public:
CTank(CMap *p_map, Uint32 x, Uint32 y,object_t objtype=OBJ_TANK);
virtual void process();
void getTouchedBy(CVorticonSpriteObject &theObject);
bool isNearby(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
bool isNearby(CSpriteObject &theObject);
int checkSolidD( int x1, int x2, int y2, const bool push_mode=false );
......
......@@ -20,7 +20,7 @@ class CVortikid : public CVorticonSpriteObject
{
public:
CVortikid( CMap *p_map, Uint32 x, Uint32 y );
void getTouchedBy(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
void process();
void baby_jump(int big);
private:
......
......@@ -44,7 +44,7 @@ CVorticonSpriteObject(p_map, x, y, OBJ_MOTHER)
bool CVortiMom::isNearby(CVorticonSpriteObject &theObject)
bool CVortiMom::isNearby(CSpriteObject &theObject)
{
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......@@ -69,7 +69,7 @@ bool CVortiMom::isNearby(CVorticonSpriteObject &theObject)
}
void CVortiMom::getTouchedBy(CVorticonSpriteObject &theObject)
void CVortiMom::getTouchedBy(CSpriteObject &theObject)
{
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......
......@@ -43,8 +43,8 @@ class CVortiMom : public CVorticonSpriteObject
{
public:
CVortiMom(CMap *p_map, Uint32 x, Uint32 y);
bool isNearby(CVorticonSpriteObject &theObject);
void getTouchedBy(CVorticonSpriteObject &theObject);
bool isNearby(CSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
void process();
void getShotByRay(object_t &obj_type);
......
......@@ -43,7 +43,7 @@ void CVortiNinja::init()
}
bool CVortiNinja::isNearby(CVorticonSpriteObject &theObject)
bool CVortiNinja::isNearby(CSpriteObject &theObject)
{
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......@@ -75,7 +75,7 @@ bool CVortiNinja::isNearby(CVorticonSpriteObject &theObject)
}
void CVortiNinja::getTouchedBy(CVorticonSpriteObject &theObject)
void CVortiNinja::getTouchedBy(CSpriteObject &theObject)
{
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......
......@@ -21,8 +21,8 @@ class CVortiNinja : public CVorticonSpriteObject
public:
CVortiNinja(CMap *p_map, Uint32 x, Uint32 y);
void init();
bool isNearby(CVorticonSpriteObject &theObject);
void getTouchedBy(CVorticonSpriteObject &theObject);
bool isNearby(CSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
void process();
private:
ninja_actions state;
......
......@@ -78,7 +78,7 @@ CVorticon::CVorticon(CMap *p_map, Uint32 x, Uint32 y, char hp, object_t objtype)
const int VORTICON_PLAYER_MIN_DIST = 8<<CSF;
bool CVorticon::isNearby(CVorticonSpriteObject &theObject)
bool CVorticon::isNearby(CSpriteObject &theObject)
{
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......@@ -124,7 +124,7 @@ bool CVorticon::isNearby(CVorticonSpriteObject &theObject)
}
void CVorticon::getTouchedBy(CVorticonSpriteObject &theObject)
void CVorticon::getTouchedBy(CSpriteObject &theObject)
{
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......
......@@ -61,8 +61,8 @@ class CVorticon : public CVorticonSpriteObject
{
public:
CVorticon( CMap *p_map, Uint32 x, Uint32 y, char hp=1, object_t objtype=OBJ_VORT);
virtual bool isNearby(CVorticonSpriteObject &theObject);
void getTouchedBy(CVorticonSpriteObject &theObject);
virtual bool isNearby(CSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
void process();
void initiateJump();
......
......@@ -90,7 +90,7 @@ CVorticon(p_map, x, y, 4, OBJ_VORTELITE)
}
bool CVorticonElite::isNearby(CVorticonSpriteObject &theObject)
bool CVorticonElite::isNearby(CSpriteObject &theObject)
{
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
......
......@@ -23,7 +23,7 @@ class CVorticonElite : public CVorticon
{
public:
CVorticonElite( CMap *p_map, Uint32 x, Uint32 y );
bool isNearby(CVorticonSpriteObject &theObject);
bool isNearby(CSpriteObject &theObject);
void process();