Commit fea48e01 authored by Gerhard Stein's avatar Gerhard Stein

Fixes, fixes

parent e503be68
......@@ -92,7 +92,7 @@ public:
void boostInertia(const int amt);
void Playerfalling();
void raygun();
void bump( CSpriteObject &theObject, direction_t direction );
void bump( direction_t direction );
void push( CSpriteObject &theObject );
void checkSolidDoors();
void SelectFrame();
......
......@@ -828,7 +828,7 @@ const int bumpamount = 160;
// yorp/scrub etc "bump".
// if solid = false, player can possibly force his way through.
// if solid = true, object acts like a solid "wall".
void CPlayer::bump( CSpriteObject &theObject, direction_t direction )
void CPlayer::bump( direction_t direction )
{
if( pjumping == PPREPAREJUMP || pjumping == PPREPAREPOGO || dead || level_done!=LEVEL_NOT_DONE )
return;
......
......@@ -338,7 +338,7 @@ void CPlayerBase::guideToTarget(const VectorD2<int> &speed)
const int MAX_WALKSOUNDTIMER = 20;
void CPlayerBase::makeWalkSound()
void CPlayerBase::playWalkSound()
{
const int time = m_walktimer % MAX_WALKSOUNDTIMER;
......@@ -352,7 +352,7 @@ void CPlayerBase::makeWalkSound()
}
void CPlayerBase::makeSwimSound()
void CPlayerBase::playSwimSound()
{
const int time = m_walktimer % MAX_WALKSOUNDTIMER;
......
......@@ -117,7 +117,7 @@ public:
* Produces the walking sound. To produce that sound correctly, it uses a special timer.
* That's the reason we need that aiding function
*/
void makeWalkSound();
void playWalkSound();
/**
......@@ -130,7 +130,7 @@ public:
/**
* Same here but with swimming
*/
void makeSwimSound();
void playSwimSound();
void processDead();
......
......@@ -193,9 +193,9 @@ void CPlayerLevel::processRunning()
handleInputOnGround();
return;
}
else
else if( !blockedl && !blockedr )
{
makeWalkSound();
playWalkSound();
}
......
......@@ -714,7 +714,7 @@ void CPlayerWM::performWalkingAnimation(bool walking)
{
m_animation_time = 5;
sprite += m_animation%3;
makeWalkSound();
playWalkSound();
}
else
sprite += 2;
......@@ -745,7 +745,7 @@ void CPlayerWM::performSwimmingAnimation()
m_animation_time = 5;
sprite += m_animation%2;
makeSwimSound();
playSwimSound();
}
}
......@@ -105,7 +105,9 @@ bool CVorticonSpriteObject::checkforScenario()
// Check if enemy is near enough. If he isn't, don't make him perform. Exception is on the map
if(!mp_Map->m_worldmap)
{
if(!calcVisibility()) return false;
}
onscreen = true;
......@@ -118,7 +120,7 @@ bool CVorticonSpriteObject::checkforScenario()
m_type == OBJ_SECTOREFFECTOR)
{
return true;
}
}
return false;
}
......
......@@ -74,12 +74,12 @@ void CButler::process()
}
}
void CButler::getTouchedBy(CSpriteObject &theObject)
void CButler::getTouchedBy(CVorticonSpriteObject &theObject)
{ // push keen
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
direction_t dir = xDirection<0 ? LEFT : RIGHT;
player->bump( *this, dir );
player->bump( dir );
}
}
......
......@@ -37,7 +37,7 @@ class CButler : public CVorticonSpriteObject
public:
CButler(CMap *pmap, Uint32 x, Uint32 y);
void process();
void getTouchedBy(CSpriteObject &theObject);
void getTouchedBy(CVorticonSpriteObject &theObject);
int checkSolidD( int x1, int x2, int y2, const bool push_mode=false );
......
......@@ -13,26 +13,33 @@ const int GUNFIRE_TIMER_EP1 = 64;
CIceCannon::CIceCannon(CMap *p_map, Uint32 x, Uint32 y,
int vector_x, int vector_y ) :
CVorticonSpriteObject(p_map,x,y, OBJ_ICECANNON)
CVorticonSpriteObject(p_map,x,y, OBJ_ICECANNON),
mTimer(0)
{
this->vector_x = vector_x;
this->vector_y = vector_y;
this->vector_x = vector_x;
this->vector_y = vector_y;
inhibitfall = true;
inhibitfall = true;
sprite = BLANKSPRITE;
blockedd = true;
}
// the ice cannon itself
void CIceCannon::process()
{
// keep spawner object invisible and properly positioned
if( (mp_Map->getAnimtiletimer()%GUNFIRE_TIMER_EP1) == 0 )
if( mTimer >= GUNFIRE_TIMER_EP1 )
{
int newpos_x = getXPosition();
int newpos_y = getYPosition();
if(vector_x > 0) newpos_x += 512;
CIceChunk *chunk = new CIceChunk(mp_Map, newpos_x, newpos_y,vector_x, vector_y);
g_pBehaviorEngine->EventList().spawnObj(chunk);
mTimer = 0;
}
else
{
mTimer++;
}
}
......@@ -53,44 +60,46 @@ vector_y(vy)
veloc_x = speed * vector_x;
veloc_y = speed * vector_y;
if(onscreen)
playSound(SOUND_CANNONFIRE);
{
playSound(SOUND_CANNONFIRE);
}
}
void CIceChunk::touchedBy(CSpriteObject &theObject)
void CIceChunk::getTouchedBy(CVorticonSpriteObject &theObject)
{
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
// freeze the player if it touches him
CPhysicsSettings &Physics = g_pBehaviorEngine->getPhysicsSettings();
// make him start sliding in the direction of the impact
if (vector_x > 0)
{
player->pDir.x = player->pShowDir.x = RIGHT;
player->xinertia = Physics.player.max_x_speed;
player->bump( *this, RIGHT );
}
else if (vector_x < 0)
{
player->pDir.x = player->pShowDir.x = LEFT;
player->xinertia = -Physics.player.max_x_speed;
player->bump( *this, LEFT );
}
else // perfectly vertical ice cannons
{
const int UPDNCANNON_PUSHAMT = 16;
if (player->xinertia < UPDNCANNON_PUSHAMT)
{
if (rnd()&1)
player->xinertia = UPDNCANNON_PUSHAMT;
else
player->xinertia = -UPDNCANNON_PUSHAMT;
}
}
player->freeze();
smash();
// freeze the player if it touches him
CPhysicsSettings &Physics = g_pBehaviorEngine->getPhysicsSettings();
// make him start sliding in the direction of the impact
if (vector_x > 0)
{
player->pDir.x = player->pShowDir.x = RIGHT;
player->xinertia = Physics.player.max_x_speed;
player->bump( RIGHT );
}
else if (vector_x < 0)
{
player->pDir.x = player->pShowDir.x = LEFT;
player->xinertia = -Physics.player.max_x_speed;
player->bump( LEFT );
}
else // perfectly vertical ice cannons
{
const int UPDNCANNON_PUSHAMT = 16;
if (player->xinertia < UPDNCANNON_PUSHAMT)
{
if (rnd()&1)
player->xinertia = UPDNCANNON_PUSHAMT;
else
player->xinertia = -UPDNCANNON_PUSHAMT;
}
}
player->freeze();
smash();
}
}
......
......@@ -23,13 +23,14 @@ public:
private:
int vector_x, vector_y;
int mTimer;
};
class CIceChunk : public CVorticonSpriteObject
{
public:
CIceChunk(CMap *p_map, Uint32 x, Uint32 y, Uint32 vx, Uint32 vy);
void touchedBy(CSpriteObject &theObject);
void getTouchedBy(CVorticonSpriteObject &theObject);
void process();
void smash();
private:
......
......@@ -171,8 +171,7 @@ void CRay::getTouchedBy(CVorticonSpriteObject &theObject)
if(theObject.canbezapped && state == RAY_STATE_FLY )
{
// Check, if it's not form the same object
CVorticonSpriteObject *theObjPtr = dynamic_cast<CVorticonSpriteObject*>(&theObject);
if(theObjPtr->m_type != owner.obj_type)
if(theObject.m_type != owner.obj_type)
{
state = RAY_STATE_SETZAPZOT;
canbezapped = false;
......
......@@ -107,7 +107,7 @@ void CRope::rope_movestone()
falldist++;
}
void CRope::getTouchedBy(CSpriteObject &theObject)
void CRope::getTouchedBy(CVorticonSpriteObject &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(CSpriteObject &theObject);
void getTouchedBy(CVorticonSpriteObject &theObject);
private:
ropestates state;
......
......@@ -153,7 +153,7 @@ void CTank::process()
if (movedir==RIGHT)
newobject = new CRay(mp_Map, getXMidPos(), getYUpPos()+height_top, RIGHT);
else
newobject = new CRay(mp_Map, getXMidPos(), getYUpPos()+height_top, LEFT);
newobject = new CRay(mp_Map, getXMidPos()-(1<<CSF), getYUpPos()+height_top, LEFT);
newobject->setOwner(OBJ_TANK, m_index);
newobject->setSpeed(108);
newobject->sprite = ENEMYRAY;
......@@ -199,7 +199,7 @@ void CTank::getTouchedBy(CSpriteObject &theObject)
{ // push keen
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
player->bump( *this, movedir );
player->bump( movedir );
}
}
......
......@@ -65,7 +65,6 @@ public:
void getTouchedBy(CVorticonSpriteObject &theObject);
void process();
void initiateJump();
void getTouchedBy(CSpriteObject &theObject);
protected:
int m_Level;
......
......@@ -30,9 +30,10 @@ m_dark(dark)
//////////////////
void CVorticonSpriteObjectAI::process()
{
for( size_t i=0 ; i < m_Objvect.size() ; i++ )
auto objectPtr = m_Objvect.begin();
for( ; objectPtr != m_Objvect.end() ; objectPtr++ )
{
CVorticonSpriteObject &object = *m_Objvect[i];
CVorticonSpriteObject &object = *(objectPtr->get());
if( object.checkforScenario() )
{
......@@ -64,7 +65,7 @@ void CVorticonSpriteObjectAI::process()
object.process();
auto theOther = m_Objvect.begin(); theOther++;
auto theOther = objectPtr; theOther++;
for( ; theOther != m_Objvect.end() ; theOther++ )
{
bool near = false;
......
......@@ -248,7 +248,7 @@ void CYorp::getTouchedBy(CVorticonSpriteObject &theObject)
// if yorp is moving, also push in direction he's moving
// in. this allows walking through a yorp if he is walking
// away from Keen
player->bump( *this, movedir );
player->bump( movedir );
}
}
}
......
......@@ -99,37 +99,37 @@ bool CPlayGameVorticon::loadGameState()
mSpriteObjectContainer.push_back(move(object));
}
std::unique_ptr<CVorticonSpriteObject> object = move(mSpriteObjectContainer.at(i));
CVorticonSpriteObject &object = *(mSpriteObjectContainer.at(i));
savedGame.decodeData(object->m_type);
savedGame.decodeData(object.m_type);
savedGame.decodeData(x);
savedGame.decodeData(y);
object->moveToForce(VectorD2<int>(x,y));
savedGame.decodeData(object->dead);
savedGame.decodeData(object->onscreen);
savedGame.decodeData(object->hasbeenonscreen);
savedGame.decodeData(object->exists);
savedGame.decodeData(object->blockedd);
savedGame.decodeData(object->blockedu);
savedGame.decodeData(object->blockedl);
savedGame.decodeData(object->blockedr);
savedGame.decodeData(object->mHealthPoints);
savedGame.decodeData(object->canbezapped);
savedGame.decodeData(object->cansupportplayer);
savedGame.decodeData(object->inhibitfall);
savedGame.decodeData(object->honorPriority);
savedGame.decodeData(object->sprite);
object->performCollisions();
if(object->m_type == OBJ_DOOR or
object->m_type == OBJ_RAY or
object->m_type == OBJ_SNDWAVE or
object->m_type == OBJ_FIREBALL or
object->m_type == OBJ_ICECHUNK or
object->m_type == OBJ_ICEBIT or
object->m_type == OBJ_GOTPOINTS or
object->m_type == OBJ_ANKHSHIELD) // Some objects are really not needed. So don't load them
object->exists = false;
object.moveToForce(VectorD2<int>(x,y));
savedGame.decodeData(object.dead);
savedGame.decodeData(object.onscreen);
savedGame.decodeData(object.hasbeenonscreen);
savedGame.decodeData(object.exists);
savedGame.decodeData(object.blockedd);
savedGame.decodeData(object.blockedu);
savedGame.decodeData(object.blockedl);
savedGame.decodeData(object.blockedr);
savedGame.decodeData(object.mHealthPoints);
savedGame.decodeData(object.canbezapped);
savedGame.decodeData(object.cansupportplayer);
savedGame.decodeData(object.inhibitfall);
savedGame.decodeData(object.honorPriority);
savedGame.decodeData(object.sprite);
object.performCollisions();
if(object.m_type == OBJ_DOOR or
object.m_type == OBJ_RAY or
object.m_type == OBJ_SNDWAVE or
object.m_type == OBJ_FIREBALL or
object.m_type == OBJ_ICECHUNK or
object.m_type == OBJ_ICEBIT or
object.m_type == OBJ_GOTPOINTS or
object.m_type == OBJ_ANKHSHIELD) // Some objects are really not needed. So don't load them
object.exists = false;
}
// TODO: An algorithm for comparing the number of players saved and we actually have need to be in sync
......
......@@ -542,10 +542,6 @@ void CPlayGameVorticon::drawAllElements()
// Draw masked tiles here!
g_pVideoDriver->mDrawTasks.add( new DrawForegroundTilesTask(*(mMap.get())) );
if(mp_option[OPT_HUD].value && mpFinale )
{ // Draw the HUD
mp_HUD->render();
}
for( short i=0 ; i<m_NumPlayers ; i++ )
{
......@@ -553,7 +549,6 @@ void CPlayGameVorticon::drawAllElements()
}
if(mpFinale) // Finale processing if it is opened
{
mpFinale->process();
......@@ -574,6 +569,13 @@ void CPlayGameVorticon::drawAllElements()
m_Player[0].processEvents();
}
else
{
if(mp_option[OPT_HUD].value )
{ // Draw the HUD
mp_HUD->render();
}
}
......@@ -604,10 +606,6 @@ void CPlayGameVorticon::drawAllElements()
////
void CPlayGameVorticon::cleanup()
{
mSpriteObjectContainer.clear();
}
CPlayGameVorticon::~CPlayGameVorticon()
{
m_Player.clear();
if(!mSpriteObjectContainer.empty())
mSpriteObjectContainer.clear();
}
......@@ -95,7 +95,6 @@ public:
void readTeleportDestCoordinatesEP3(int objectID, int &destx, int &desty);
void cleanup();
virtual ~CPlayGameVorticon();
private:
......
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