Commit f50221d6 authored by Gerhard Stein's avatar Gerhard Stein

Some Pointer fixups, finale now works partially

parent 1c5024a8
......@@ -14,9 +14,9 @@
#include "common/CMapLoader.h"
#include "common/Playerdefines.h"
CEndingEp1::CEndingEp1(CMap &map, std::vector<CPlayer> &Player,
CEndingEp1::CEndingEp1(const SmartPointer<CMap> &pMap, std::vector<CPlayer> &Player,
bool &hideobjects, std::vector<CObject*> &Object) :
CFinale(map, Object),
CFinale(pMap, Object),
m_Player(Player),
m_hideobjects(hideobjects)
{
......@@ -26,7 +26,7 @@ CEndingEp1::CEndingEp1(CMap &map, std::vector<CPlayer> &Player,
m_timepassed = 0;
m_mustsetup = true;
m_mustfinishgame = false;
mp_Textbox = NULL;
mpTextbox = NULL;
}
void CEndingEp1::process()
......@@ -51,7 +51,7 @@ void CEndingEp1::ReturnsToShip()
if(m_mustsetup)
{
//Initialization
mMap->gotoPos( 40, 540 );
mpMap->gotoPos( 40, 540 );
// draw keen next to his ship
m_Player[0].hideplayer = false;
......@@ -60,7 +60,7 @@ void CEndingEp1::ReturnsToShip()
m_Player[0].sprite = PMAPLEFTFRAME;
m_Player[0].processEvents();
mp_Textbox = new CMessageBoxVort(g_pBehaviorEngine->getString("EP1_ESEQ_PART1"), true);
mpTextbox = new CMessageBoxVort(g_pBehaviorEngine->getString("EP1_ESEQ_PART1"), true);
m_mustsetup = false;
}
......@@ -75,15 +75,14 @@ void CEndingEp1::ReturnsToShip()
if( m_timepassed<50000 && !g_pInput->getPressedAnyCommand() )
{
// perform a machine typing like dialog.
mp_Textbox->processLogic();
mpTextbox->processLogic();
}
else
{
// Shutdown code here!
m_step++;
m_mustsetup = true;
delete mp_Textbox;
mp_Textbox = NULL;
mpTextbox = NULL;
}
}
......@@ -92,56 +91,55 @@ void CEndingEp1::ShipFlyMarsToEarth()
if(m_mustsetup)
{
//Initialization
std::string path = mMap->m_gamepath;
CMapLoader MapLoader(mMap, &m_Player);
std::string path = mpMap->m_gamepath;
CMapLoader MapLoader(mpMap, &m_Player);
MapLoader.load(1, 81, path);
m_Player[0].hideplayer = false;
m_Player[0].moveTo(VectorD2<int>(6<<CSF, 5<<CSF));
mp_ShipFlySys = new CShipFlySys( m_Player[0], mMap.get(), SPR_SHIP_RIGHT, SPR_SHIP_LEFT);
mMap->gotoPos(0,0);
mp_ShipFlySys->addShipQueue(CMD_MOVE, 60, DUP);
mp_ShipFlySys->addShipQueue(CMD_WAIT, 12, 0);
mp_ShipFlySys->addShipQueue(CMD_MOVE, 673, DDOWNRIGHT);
mp_ShipFlySys->addShipQueue(CMD_WAIT, 25, 0);
mp_ShipFlySys->addShipQueue(CMD_MOVE, 120, DDOWN);
mp_ShipFlySys->addShipQueue(CMD_WAIT, 18, 0);
mp_ShipFlySys->addShipQueue(CMD_SPAWNSPR, 0, SPR_QUESTION);
mp_ShipFlySys->addShipQueue(CMD_DISABLESCROLLING, 0, 0);
mp_ShipFlySys->addShipQueue(CMD_WAIT, 88, 0);
mp_ShipFlySys->addShipQueue(CMD_REMOVESPR, 0, 0);
mp_ShipFlySys->addShipQueue(CMD_WAIT, 12, 0);
mp_ShipFlySys->addShipQueue(CMD_MOVE, 175, DLEFT);
mp_ShipFlySys->addShipQueue(CMD_WAIT, 38, 0);
mp_ShipFlySys->addShipQueue(CMD_SPAWNSPR, 0, SPR_EXCLAMATION);
mp_ShipFlySys->addShipQueue(CMD_WAIT, 125, 0);
mp_ShipFlySys->addShipQueue(CMD_REMOVESPR, 0, 0);
mp_ShipFlySys->addShipQueue(CMD_WAIT, 12, 0);
mp_ShipFlySys->addShipQueue(CMD_MOVE, 175, DRIGHT);
mp_ShipFlySys->addShipQueue(CMD_WAIT, 6, 0);
mp_ShipFlySys->addShipQueue(CMD_ENABLESCROLLING, 0, 0);
mp_ShipFlySys->addShipQueue(CMD_MOVE, 116, DDOWN);
mp_ShipFlySys->addShipQueue(CMD_FADEOUT, 0, 0);
mp_ShipFlySys->addShipQueue(CMD_MOVE, 25, DDOWN);
mp_ShipFlySys->addShipQueue(CMD_ENDOFQUEUE, 0, 0);
mMap->drawAll();
mp_ShipFlySys->m_ShipQueuePtr = 0;
mpShipFlySys = new CShipFlySys( m_Player[0], mpMap, SPR_SHIP_RIGHT, SPR_SHIP_LEFT);
mpMap->gotoPos(0,0);
mpShipFlySys->addShipQueue(CMD_MOVE, 60, DUP);
mpShipFlySys->addShipQueue(CMD_WAIT, 12, 0);
mpShipFlySys->addShipQueue(CMD_MOVE, 673, DDOWNRIGHT);
mpShipFlySys->addShipQueue(CMD_WAIT, 25, 0);
mpShipFlySys->addShipQueue(CMD_MOVE, 120, DDOWN);
mpShipFlySys->addShipQueue(CMD_WAIT, 18, 0);
mpShipFlySys->addShipQueue(CMD_SPAWNSPR, 0, SPR_QUESTION);
mpShipFlySys->addShipQueue(CMD_DISABLESCROLLING, 0, 0);
mpShipFlySys->addShipQueue(CMD_WAIT, 88, 0);
mpShipFlySys->addShipQueue(CMD_REMOVESPR, 0, 0);
mpShipFlySys->addShipQueue(CMD_WAIT, 12, 0);
mpShipFlySys->addShipQueue(CMD_MOVE, 175, DLEFT);
mpShipFlySys->addShipQueue(CMD_WAIT, 38, 0);
mpShipFlySys->addShipQueue(CMD_SPAWNSPR, 0, SPR_EXCLAMATION);
mpShipFlySys->addShipQueue(CMD_WAIT, 125, 0);
mpShipFlySys->addShipQueue(CMD_REMOVESPR, 0, 0);
mpShipFlySys->addShipQueue(CMD_WAIT, 12, 0);
mpShipFlySys->addShipQueue(CMD_MOVE, 175, DRIGHT);
mpShipFlySys->addShipQueue(CMD_WAIT, 6, 0);
mpShipFlySys->addShipQueue(CMD_ENABLESCROLLING, 0, 0);
mpShipFlySys->addShipQueue(CMD_MOVE, 116, DDOWN);
mpShipFlySys->addShipQueue(CMD_FADEOUT, 0, 0);
mpShipFlySys->addShipQueue(CMD_MOVE, 25, DDOWN);
mpShipFlySys->addShipQueue(CMD_ENDOFQUEUE, 0, 0);
mpMap->drawAll();
mpShipFlySys->m_ShipQueuePtr = 0;
m_mustsetup = false;
}
if( !mp_ShipFlySys->EndOfQueue() && !g_pInput->getPressedAnyCommand() )
if( !mpShipFlySys->EndOfQueue() && !g_pInput->getPressedAnyCommand() )
{
// process the normal ship flying level and do all the inited commands
mp_ShipFlySys->process();
mpShipFlySys->process();
}
else
{
// Shutdown code here!
delete mp_ShipFlySys;
mp_ShipFlySys = NULL;
mpShipFlySys = NULL;
m_step++;
m_mustsetup = true;
}
......@@ -153,38 +151,37 @@ void CEndingEp1::BackAtHome()
{
//Initialization
m_hideobjects = true;
mMap->gotoPos(0,0);
mMap->resetScrolls(); // The Scrollsurface must be (0,0) so the bitmap is correctly drawn
mMap->m_animation_enabled = false; // Needed, because the other map is still loaded
mpMap->gotoPos(0,0);
mpMap->resetScrolls(); // The Scrollsurface must be (0,0) so the bitmap is correctly drawn
mpMap->m_animation_enabled = false; // Needed, because the other map is still loaded
m_Player[0].hideplayer = true;
mp_FinaleStaticScene = new CFinaleStaticScene(mMap->m_gamepath, "finale.ck1");
mpFinaleStaticScene = new CFinaleStaticScene(mpMap->m_gamepath, "finale.ck1");
mp_FinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE1", 6000);
mp_FinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE2", 6000);
mp_FinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE3", 6000);
mp_FinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE4", 5000);
mp_FinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE5", 5000);
mp_FinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE6", 6000);
mp_FinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE7", 6000);
mp_FinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE8", 8000);
mpFinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE1", 6000);
mpFinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE2", 6000);
mpFinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE3", 6000);
mpFinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE4", 5000);
mpFinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE5", 5000);
mpFinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE6", 6000);
mpFinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE7", 6000);
mpFinaleStaticScene->push_string("EP1_ESEQ_PART2_PAGE8", 8000);
// The Bitmaps of the Window Lights on should drawn at Page 4
mp_FinaleStaticScene->showBitmapAt("WINDON", 2, 6, 80, 0);
mp_FinaleStaticScene->showBitmapAt("WINDOFF", 6, 8, 80, 0);
mpFinaleStaticScene->showBitmapAt("WINDON", 2, 6, 80, 0);
mpFinaleStaticScene->showBitmapAt("WINDOFF", 6, 8, 80, 0);
m_mustsetup = false;
}
if( !mp_FinaleStaticScene->mustclose() )
if( !mpFinaleStaticScene->mustclose() )
{
mp_FinaleStaticScene->process();
mpFinaleStaticScene->process();
}
else
{
// Shutdown code here!
delete mp_FinaleStaticScene;
mp_FinaleStaticScene = NULL;
mMap->m_animation_enabled = true;
mpFinaleStaticScene = NULL;
mpMap->m_animation_enabled = true;
m_step++;
m_mustsetup = true;
}
......@@ -196,8 +193,8 @@ void CEndingEp1::ShipFlyEarthToMShip()
{ //Initialization
int x, y;
m_hideobjects = false;
std::string path = mMap->m_gamepath;
CMapLoader MapLoader(mMap, &m_Player);
std::string path = mpMap->m_gamepath;
CMapLoader MapLoader(mpMap, &m_Player);
MapLoader.load(1, 81, path);
m_Player[0].hideplayer = false;
......@@ -205,34 +202,33 @@ void CEndingEp1::ShipFlyEarthToMShip()
y = 23<<CSF;
m_Player[0].moveTo(VectorD2<int>(x,y));
mMap->gotoPos((x>>STC)-100, (y>>STC)-160);
mpMap->gotoPos((x>>STC)-100, (y>>STC)-160);
mp_ShipFlySys = new CShipFlySys( m_Player[0], mMap.get(), SPR_SHIP_RIGHT, SPR_SHIP_LEFT);
mpShipFlySys = new CShipFlySys( m_Player[0], mpMap, SPR_SHIP_RIGHT, SPR_SHIP_LEFT);
mp_ShipFlySys->addShipQueue(CMD_MOVE, 58, DUP);
mp_ShipFlySys->addShipQueue(CMD_DISABLESCROLLING, 0, 0);
mp_ShipFlySys->addShipQueue(CMD_WAIT, 13, DUPLEFT);
mp_ShipFlySys->addShipQueue(CMD_MOVE, 208, DLEFT);
mp_ShipFlySys->addShipQueue(CMD_FADEOUT, 0, 0);
mp_ShipFlySys->addShipQueue(CMD_MOVE, 25, DDOWN);
mp_ShipFlySys->addShipQueue(CMD_ENDOFQUEUE, 0, 0);
mpShipFlySys->addShipQueue(CMD_MOVE, 58, DUP);
mpShipFlySys->addShipQueue(CMD_DISABLESCROLLING, 0, 0);
mpShipFlySys->addShipQueue(CMD_WAIT, 13, DUPLEFT);
mpShipFlySys->addShipQueue(CMD_MOVE, 208, DLEFT);
mpShipFlySys->addShipQueue(CMD_FADEOUT, 0, 0);
mpShipFlySys->addShipQueue(CMD_MOVE, 25, DDOWN);
mpShipFlySys->addShipQueue(CMD_ENDOFQUEUE, 0, 0);
mMap->drawAll();
mp_ShipFlySys->m_ShipQueuePtr = 0;
mpMap->drawAll();
mpShipFlySys->m_ShipQueuePtr = 0;
m_mustsetup = false;
}
if( !mp_ShipFlySys->EndOfQueue() && !g_pInput->getPressedAnyCommand() )
if( !mpShipFlySys->EndOfQueue() && !g_pInput->getPressedAnyCommand() )
{
// process the normal ship flying level and do all the inited commands
mp_ShipFlySys->process();
mpShipFlySys->process();
}
else
{
// Shutdown code here!
delete mp_ShipFlySys;
mp_ShipFlySys = NULL;
mpShipFlySys = NULL;
m_step++;
m_mustsetup = true;
}
......
......@@ -12,12 +12,13 @@
#include "common/CMap.h"
#include "common/CPlayer.h"
#include "engine/vorticon/dialog/CMessageBoxVort.h"
#include "SmartPointer.h"
#include <vector>
#include <SDL.h>
class CEndingEp1 : public CFinale {
public:
CEndingEp1(CMap &map, std::vector<CPlayer> &Player, bool &hideobjects, std::vector<CObject*> &Object);
CEndingEp1(const SmartPointer<CMap> &pMap, std::vector<CPlayer> &Player, bool &hideobjects, std::vector<CObject*> &Object);
void process();
void ReturnsToShip();
......@@ -31,9 +32,9 @@ private:
Uint32 m_timepassed;
std::vector<CPlayer> &m_Player;
CShipFlySys *mp_ShipFlySys;
CFinaleStaticScene *mp_FinaleStaticScene;
CMessageBoxVort *mp_Textbox;
SmartPointer<CShipFlySys> mpShipFlySys;
SmartPointer<CFinaleStaticScene> mpFinaleStaticScene;
SmartPointer<CMessageBoxVort> mpTextbox;
bool &m_hideobjects;
};
......
......@@ -17,8 +17,8 @@
const int LIMPSHOME_X = 0;
const int LIMPSHOME_Y = 300;
CEndingEp2::CEndingEp2(CMap &map, std::vector<CPlayer> &Player, std::vector<CObject*> &Object) :
CFinale(map, Object),
CEndingEp2::CEndingEp2(const SmartPointer<CMap> &pMap, std::vector<CPlayer> &Player, std::vector<CObject*> &Object) :
CFinale(pMap, Object),
m_Player(Player)
{
m_Episode = 2;
......@@ -51,26 +51,26 @@ void CEndingEp2::HeadsForEarth()
if(m_mustsetup)
{
//Initialization
std::string path = mMap->m_gamepath;
CMapLoader MapLoader(mMap, &m_Player);
std::string path = mpMap->m_gamepath;
CMapLoader MapLoader(mpMap, &m_Player);
MapLoader.load(2, 81, path);
m_Player[0].hideplayer = false;
m_Player[0].sprite = SPR_VORTICON_MOTHERSHIP;
m_Player[0].solid = false;
mp_ShipFlySys = new CShipFlySys( m_Player[0], mMap.get(), SPR_SHIP_RIGHT_EP2, SPR_SHIP_LEFT_EP2 );
mp_ShipFlySys = new CShipFlySys( m_Player[0], mpMap, SPR_SHIP_RIGHT_EP2, SPR_SHIP_LEFT_EP2 );
mMap->gotoPos(0, 0);
mpMap->gotoPos(0, 0);
mp_ShipFlySys->addShipQueue(CMD_WAIT, 10, 0);
mp_ShipFlySys->addShipQueue(CMD_MOVE, 672, DDOWNRIGHT);
mp_ShipFlySys->addShipQueue(CMD_MOVE, 150, DDOWN);
mp_ShipFlySys->addShipQueue(CMD_ENDOFQUEUE, 0, 0);
mMap->drawAll();
mpMap->drawAll();
mp_ShipFlySys->m_ShipQueuePtr = 0;
int x, y;
mMap->findTile(593, &x, &y);
mpMap->findTile(593, &x, &y);
m_Player[0].moveTo(VectorD2<int>(x<<CSF, y<<CSF));
mp_Textbox = new CMessageBoxVort(g_pBehaviorEngine->getString("EP2_ESEQ_PART1"), true);
......@@ -108,21 +108,21 @@ void CEndingEp2::LimpsHome()
{
if(m_mustsetup)
{ //Initialization
std::string path = mMap->m_gamepath;
CMapLoader MapLoader(mMap, &m_Player);
std::string path = mpMap->m_gamepath;
CMapLoader MapLoader(mpMap, &m_Player);
MapLoader.load(2, 81, path);
m_Player[0].hideplayer = false;
m_Player[0].moveTo(VectorD2<int>(8<<CSF, 26<<CSF));
m_Player[0].solid = false;
mp_ShipFlySys = new CShipFlySys( m_Player[0], mMap.get(), SPR_VORTICON_MOTHERSHIP, SPR_VORTICON_MOTHERSHIP );
mp_ShipFlySys = new CShipFlySys( m_Player[0], mpMap, SPR_VORTICON_MOTHERSHIP, SPR_VORTICON_MOTHERSHIP );
mMap->gotoPos(LIMPSHOME_X, LIMPSHOME_Y);
mpMap->gotoPos(LIMPSHOME_X, LIMPSHOME_Y);
mp_ShipFlySys->addShipQueue(CMD_WAIT, 10, 0);
mp_ShipFlySys->addShipQueue(CMD_MOVE, 80, DUPLEFT);
mp_ShipFlySys->addShipQueue(CMD_ENDOFQUEUE, 0, 0);
mMap->drawAll();
mpMap->drawAll();
mp_ShipFlySys->m_ShipQueuePtr = 0;
mp_Textbox = new CMessageBoxVort(g_pBehaviorEngine->getString("EP2_ESEQ_PART2"), true);
......@@ -162,11 +162,11 @@ void CEndingEp2::SnowedOutside()
if(m_mustsetup)
{
//Initialization
mMap->gotoPos(0,0);
mMap->resetScrolls(); // The Scrollsurface must be (0,0) so the bitmap is correctly drawn
mMap->m_animation_enabled = false; // Needed, because the other map is still loaded
mpMap->gotoPos(0,0);
mpMap->resetScrolls(); // The Scrollsurface must be (0,0) so the bitmap is correctly drawn
mpMap->m_animation_enabled = false; // Needed, because the other map is still loaded
m_Player[0].hideplayer = true;
mp_FinaleStaticScene = new CFinaleStaticScene(mMap->m_gamepath, "finale.ck2");
mp_FinaleStaticScene = new CFinaleStaticScene(mpMap->m_gamepath, "finale.ck2");
mp_FinaleStaticScene->push_string("EP2_ESEQ_PART3_PAGE1", 6000);
mp_FinaleStaticScene->push_string("EP2_ESEQ_PART3_PAGE2", 6000);
......@@ -185,7 +185,7 @@ void CEndingEp2::SnowedOutside()
// Shutdown code here!
delete mp_FinaleStaticScene;
mp_FinaleStaticScene = NULL;
mMap->m_animation_enabled = true;
mpMap->m_animation_enabled = true;
m_step++;
m_mustsetup = true;
}
......
......@@ -18,7 +18,7 @@
class CEndingEp2 : public CFinale
{
public:
CEndingEp2(CMap &map, std::vector<CPlayer> &Player, std::vector<CObject*> &Object);
CEndingEp2(const SmartPointer<CMap> &pMap, std::vector<CPlayer> &Player, std::vector<CObject*> &Object);
void process();
void HeadsForEarth();
......
......@@ -14,8 +14,8 @@
#include "common/CMapLoader.h"
#include "common/Playerdefines.h"
CEndingEp3::CEndingEp3(CMap &map, std::vector<CPlayer> &Player, std::vector<CObject*> &Object) :
CFinale(map, Object),
CEndingEp3::CEndingEp3(const SmartPointer<CMap> &pMap, std::vector<CPlayer> &Player, std::vector<CObject*> &Object) :
CFinale(pMap, Object),
m_Player(Player)
{
m_Episode = 3;
......@@ -47,27 +47,27 @@ void CEndingEp3::HonorScene()
if(m_mustsetup)
{
//Initialization
std::string path = mMap->m_gamepath;
CMapLoader MapLoader(mMap, &m_Player);
std::string path = mpMap->m_gamepath;
CMapLoader MapLoader(mpMap, &m_Player);
MapLoader.load(3, 81, path);
m_Player[0].hideplayer = false;
m_Player[0].moveTo(VectorD2<int>(244<<STC, 104<<STC));
m_Player[0].sprite = 0;
mMap->gotoPos(32, 32);
mMap->drawAll();
mpMap->gotoPos(32, 32);
mpMap->drawAll();
m_TextBoxes.push_back(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_ESEQ_PAGE1"), true));
m_TextBoxes.push_back(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_ESEQ_PAGE2"), true));
m_TextBoxes.push_back(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_ESEQ_PAGE3"), true));
m_TextBoxes.push_back(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_ESEQ_PAGE4"), true));
int newtile = mMap->at(2,12);
int newtile = mpMap->at(2,12);
for(int x=0 ; x<22 ; x++) // This changes to the Oh No! Tiles to normal Stone-Tiles
{
mMap->changeTile( x, 15, newtile);
mMap->changeTile( x, 16, newtile);
mpMap->changeTile( x, 15, newtile);
mpMap->changeTile( x, 16, newtile);
}
m_mustsetup = false;
......@@ -123,11 +123,11 @@ void CEndingEp3::AwardScene()
{
//Initialization
m_Player[0].hideplayer = true;
mMap->gotoPos(0,0);
mMap->resetScrolls(); // The Scrollsurface must be (0,0) so the bitmap is correctly drawn
mMap->m_animation_enabled = false; // Needed, because the other map is still loaded
mMap->drawAll();
mp_FinaleStaticScene = new CFinaleStaticScene(mMap->m_gamepath, "finale.ck3");
mpMap->gotoPos(0,0);
mpMap->resetScrolls(); // The Scrollsurface must be (0,0) so the bitmap is correctly drawn
mpMap->m_animation_enabled = false; // Needed, because the other map is still loaded
mpMap->drawAll();
mp_FinaleStaticScene = new CFinaleStaticScene(mpMap->m_gamepath, "finale.ck3");
mp_FinaleStaticScene->push_string("THE_END", 6000);
......@@ -143,7 +143,7 @@ void CEndingEp3::AwardScene()
// Shutdown code here!
delete mp_FinaleStaticScene;
mp_FinaleStaticScene = NULL;
mMap->m_animation_enabled = true;
mpMap->m_animation_enabled = true;
m_step++;
m_mustsetup = true;
}
......
......@@ -19,7 +19,7 @@
class CEndingEp3 : public CFinale {
public:
CEndingEp3(CMap &map, std::vector<CPlayer> &Player, std::vector<CObject*> &Object);
CEndingEp3(const SmartPointer<CMap> &pMap, std::vector<CPlayer> &Player, std::vector<CObject*> &Object);
void process();
void HonorScene();
......
......@@ -11,33 +11,26 @@
#include "FindFile.h"
#include <fstream>
CFinale::CFinale(CMap &map, std::vector<CObject*> &Object) :
CFinale::CFinale(const SmartPointer<CMap> &pMap, std::vector<CObject*> &Object) :
m_mustfinishgame(false),
mp_TextViewer(NULL),
mpMap(pMap),
m_Object(Object)
{
//mMap = new CMap(map);
}
{}
void CFinale::showEndingText()
{
if(!mp_TextViewer)
if(mpTextViewer.empty())
{
std::string text;
mp_TextViewer = new CTextViewer(0, 0, 320, 120);
mp_TextViewer->loadTextfromFile(mMap->m_gamepath + "endtext.ck" + itoa(m_Episode));
mpTextViewer = new CTextViewer(0, 0, 320, 120);
mpTextViewer->loadTextfromFile(mpMap->m_gamepath + "endtext.ck" + itoa(m_Episode));
}
mp_TextViewer->process();
mpTextViewer->process();
if(mp_TextViewer->hasClosed())
if(mpTextViewer->hasClosed())
{
delete mp_TextViewer;
mp_TextViewer = NULL;
mpTextViewer = NULL;
m_step++;
}
}
CFinale::~CFinale() {
if(mp_TextViewer) delete mp_TextViewer;
}
......@@ -12,26 +12,25 @@
#include "common/CMap.h"
#include "CShipFlySys.h"
#include "CFinaleStaticScene.h"
#include "SmartPointer.h"
#include <string>
class CFinale {
public:
CFinale(CMap &map, std::vector<CObject*> &Object);
CFinale(const SmartPointer<CMap> &pMap, std::vector<CObject*> &Object);
void showEndingText();
virtual void process() {}
bool getHasFinished() { return m_mustfinishgame; }
virtual ~CFinale();
protected:
char m_step;
bool m_mustfinishgame;
CTextViewer *mp_TextViewer; // Used for Epilogue
SmartPointer<CTextViewer> mpTextViewer; // Used for Epilogue
std::string m_epilogue_text;
int m_Episode;
SmartPointer<CMap> mMap;
SmartPointer<CMap> mpMap;
std::vector<CObject*> &m_Object;
};
......
......@@ -13,13 +13,13 @@
#include "CShipFlySys.h"
#include "../ai/CYorp.h"
CShipFlySys::CShipFlySys(CPlayer &Player, CMap *p_Map, int ship_rightsprite, int ship_leftsprite) :
m_player(Player) // in this case the player will be the ship flying home
CShipFlySys::CShipFlySys(CPlayer &Player, SmartPointer<CMap> &pMap, int ship_rightsprite, int ship_leftsprite) :
m_player(Player), // in this case the player will be the ship flying home
mpMap(pMap)
{
m_playsprite_right = ship_rightsprite;
m_playsprite_left = ship_leftsprite;
mp_Map = p_Map;
m_finished = false;
m_scrollingon = true;
m_ShipQueuePtr = 0;
......@@ -28,7 +28,7 @@ m_player(Player) // in this case the player will be the ship flying home
// Now, that everything is initialized, create a mark that will be used
// as ! or ? Sprite
// before it was yorp
CObject *mark = new CObject(mp_Map, 0,0, OBJ_YORP);
CObject *mark = new CObject(mpMap.get(), 0,0, OBJ_YORP);
mark->m_type = OBJ_YORP; // doesn't matter
mark->solid = false; // doesn't matter
mark->sprite = SPR_QUESTION;
......
......@@ -9,6 +9,7 @@
#define CSHIPFLYSYS_H_
#include "common/CPlayer.h"
#include "SmartPointer.h"
#define CMD_MOVE 0
#define CMD_WAIT 1
......@@ -54,7 +55,7 @@ typedef struct stShipQueue
class CShipFlySys {
public:
CShipFlySys(CPlayer &Player, CMap *p_Map, int ship_rightsprite, int ship_leftsprite);
CShipFlySys(CPlayer &Player, SmartPointer<CMap> &pMap, int ship_rightsprite, int ship_leftsprite);
void addShipQueue(int cmd, int time, int flag1);
bool EndOfQueue() { return m_finished; }
void process();
......@@ -68,7 +69,7 @@ private:
bool m_scrollingon;
CPlayer &m_player;
CObject *mp_mark;
CMap *mp_Map;
SmartPointer<CMap> mpMap;
int m_playsprite_left;
int m_playsprite_right;
};
......
......@@ -27,8 +27,8 @@ const int EARTHCHUNK_BIG_DN = 66;
const int EARTHCHUNK_SMALL_UP = 68;
const int EARTHCHUNK_SMALL_DN = 70;
CTantalusRay::CTantalusRay(CMap &Map, std::vector<CObject*> &vect_obj, CObjectAI &objectai) :
CFinale(Map, vect_obj),
CTantalusRay::CTantalusRay(const SmartPointer<CMap> &pMap, std::vector<CObject*> &vect_obj, CObjectAI &objectai) :
CFinale(pMap, vect_obj),
m_mustsetup(true),
m_alternate_sprite(0),
mp_MessageBox(new CMessageBoxVort("Uh-Oh")),
......@@ -62,8 +62,8 @@ void CTantalusRay::shootray()
{
if(m_mustsetup)
{
CMapLoader Maploader(mMap);
Maploader.load(2,81, mMap->m_gamepath, false);
CMapLoader Maploader(mpMap);
Maploader.load(2,81, mpMap->m_gamepath, false);
while(!m_Object.empty())
{
......@@ -71,9 +71,9 @@ void CTantalusRay::shootray()
m_Object.pop_back();
}
mMap->drawAll();
mpMap->drawAll();
CObject* ShootObject = new CRay(mMap.get(), 4<<CSF, 4<<CSF, RIGHT, OBJ_NONE, 0);
CObject* ShootObject = new CRay(mpMap.get(), 4<<CSF, 4<<CSF, RIGHT, OBJ_NONE, 0);
ShootObject->solid = false;
ShootObject->exists = ShootObject->onscreen = true;
m_Object.push_back(ShootObject);
......@@ -91,7 +91,7 @@ void CTantalusRay::shootray()
int x = (shot_x>>STC)-160;
int y = (shot_y>>STC)-100;
if( x>0 && y>0 )
mMap->gotoPos( x, y);
mpMap->gotoPos( x, y);
mp_ShootObject->sprite = TANTALUS_SPRITE + m_alternate_sprite;
m_alternate_sprite ^= 1;
......@@ -113,7 +113,7 @@ void CTantalusRay::explodeEarth()
if (m_step<16)
{
CEarthExplosion *EarthExplosion;
EarthExplosion = new CEarthExplosion(mMap.get(),shot_x+((rnd()%32)<<STC), shot_y+((rnd()%32)<<STC)-(8<<STC));
EarthExplosion = new CEarthExplosion(mpMap.get(),shot_x+((rnd()%32)<<STC), shot_y+((rnd()%32)<<STC)-(8<<STC));
EarthExplosion->solid = false;
m_Object.push_back(EarthExplosion);
}
......@@ -125,7 +125,7 @@ void CTantalusRay::explodeEarth()
case 5:
for(int i=0;i<=9;i++)
{
chunk = new CEarthChunk(mMap.get(),shot_x+(14<<STC), shot_y);
chunk = new CEarthChunk(mpMap.get(),shot_x+(14<<STC), shot_y);
chunk->m_Direction = EC_UPLEFTLEFT;
if (i > 4)
......@@ -135,36 +135,36 @@ void CTantalusRay::explodeEarth()
break;
case 6:
chunk = new CEarthChunk(mMap.get(),shot_x+(16<<STC), shot_y+(16<<STC));
chunk = new CEarthChunk(mpMap.get(),shot_x+(16<<STC), shot_y+(16<<STC));
m_Object.push_back(chunk);
break;
case 7:
chunk = new CEarthChunk(mMap.get(),shot_x+(24<<STC), shot_y-(8<<STC));
chunk = new CEarthChunk(mpMap.get(),shot_x+(24<<STC), shot_y-(8<<STC));
m_Object.push_back(chunk);
case 8:
chunk = new CEarthChunk(mMap.get(),shot_x+(16<<STC), shot_y+(4<<STC));
chunk = new CEarthChunk(mpMap.get(),shot_x+(16<<STC), shot_y+(4<<STC));
m_Object.push_back(chunk);
case 10:
// spawn four big fragments of the earth to go flying off
chunk = new CEarthChunk(mMap.get(),shot_x+(8<<STC), shot_y);
chunk = new CEarthChunk(mpMap.get(),shot_x+(8<<STC), shot_y);
chunk->m_Direction = EC_UPLEFT;
chunk->sprite = EARTHCHUNK_BIG_UP;
chunk->solid = false;
m_Object.push_back(chunk);