Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 2, 2006, 11:00:14 PM (19 years ago)
Author:
patrick
Message:

network: much more work on the StoryEntity functions and reimplementations of the DataTanks of each StoryEntity

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/story_entities/campaign.cc

    r6386 r6387  
    3838  assert( root != NULL);
    3939
    40   this->campaignData = new CampaignData();
     40  this->campaignData = new CampaignData(root);
    4141  this->loadParams(root);
     42
    4243}
    4344
     
    4748 */
    4849Campaign::~Campaign ()
    49 {}
     50{
     51  if( this->campaignData)
     52    delete this->campaignData;
     53}
    5054
    5155
     
    5862  static_cast<StoryEntity*>(this)->loadParams(root);
    5963
    60   LoadParamXML(root, "WorldList", this, Campaign, loadWorldListParams)
    61   .describe("A List of Worlds to be loaded in this Campaign");
    62 
    6364  PRINTF(4)("Loaded Campaign specific stuff\n");
    64 }
    65 
    66 
    67 /**
    68  *  loads a WorldList
    69  * @param root: the XML-element to load from
    70  */
    71 void Campaign::loadWorldListParams(const TiXmlElement* root)
    72 {
    73   if( root == NULL)
    74     return;
    75 
    76   LOAD_PARAM_START_CYCLE(root, element);
    77   {
    78     StoryEntity* created = (StoryEntity*) Factory::fabricate(element);
    79     if( created != NULL)
    80       this->campaignData->addStoryEntity(created);
    81   }
    82   LOAD_PARAM_END_CYCLE(element);
    83 
    84 }
    85 
    86 
    87 /**
    88  *  initializes the class
    89  */
    90 ErrorMessage Campaign::init()
    91 {
    92   this->isInit = true;
     65
    9366}
    9467
     
    9871 * @param storyID the id of the StoryEntity
    9972 */
    100 ErrorMessage Campaign::start()
     73bool Campaign::start()
    10174{
    10275  PRINTF(2)("Starting Campaign nr. %i\n", this->getStoryID());
    10376
     77  this->isRunning = true;
     78  this->run();
     79
     80  PRINTF(2)("There is no StoryEnity left to play, quitting\n");
     81}
     82
     83
     84/**
     85 *  pauses the campaign
     86 */
     87bool Campaign::pause()
     88{
     89  this->isPaused = true;
     90}
     91
     92
     93/**
     94 *  resumes the campaign after a pause
     95 */
     96bool Campaign::resume()
     97{
     98  PRINTF(4)("Resuming the current Campaign\n");
     99  this->isPaused = false;
     100}
     101
     102
     103/**
     104 *  stops the campaign
     105 */
     106bool Campaign::stop()
     107{
     108  PRINTF(4)("Stopping the current Campaign\n");
     109  this->isRunning = false;
     110  if( this->currentEntity != NULL)
     111  {
     112    this->currentEntity->stop();
     113  }
     114}
     115
     116
     117/**
     118 *  runs the campaign
     119 */
     120void Campaign::run()
     121{
    104122  ErrorMessage       errorCode;
    105123  int                storyID = WORLD_ID_0;
     
    116134    this->currentEntity->unloadData();
    117135  }
    118 
    119   PRINTF(2)("There is no StoryEnity left to play, quitting\n");
    120 }
    121 
    122 
    123 /**
    124  *  pauses the campaign
    125  */
    126 ErrorMessage Campaign::pause()
    127 {
    128   if( this->currentEntity != NULL)
    129     this->isPaused = true;
    130 }
    131 
    132 
    133 /**
    134  *  resumes the campaign after a pause
    135  */
    136 ErrorMessage Campaign::resume()
    137 {
    138   if( this->currentEntity != NULL)
    139     this->isPaused = false;
    140 }
    141 
    142 
    143 /**
    144  *  stops the campaign
    145  */
    146 ErrorMessage Campaign::stop()
    147 {
    148   this->isRunning = false;
    149   if( this->currentEntity != NULL)
    150   {
    151     this->currentEntity->stop();
    152   }
    153136}
    154137
     
    159142void Campaign::switchToNextLevel()
    160143{
    161   PRINTF(4)("Campaign:nextLevel()\n");
     144  PRINTF(4)("Switching to the next StoryEntity\n");
    162145  this->currentEntity->stop();
    163146}
     
    165148
    166149
    167 /* CampaignData */
     150/* ==========================================================================================================
     151   CampaignData
     152   ==========================================================================================================
     153*/
    168154
    169155/**
    170156 * constructor for CampaignData
    171157 */
    172 CampaignData::CampaignData()
     158CampaignData::CampaignData(const TiXmlElement* root)
    173159{
    174160  this->setClassID(CL_CAMPAIGN_DATA, "CampaignData");
    175161  this->currentEntity = NULL;
     162
     163  this->loadParams(root);
    176164}
    177165
     
    180168 * destructor for CampaignData
    181169 */
    182 CampaignData::~ CampaignData()
    183 {}
     170CampaignData::~CampaignData()
     171{
     172  PRINTF(0)("Deleting CampaignData\n");
     173  while( !this->storyEntities.empty())
     174  {
     175    StoryEntity* bo = this->storyEntities.front();
     176    PRINTF(0)("CampaignData is been deleted: nr %i\n", bo->getStoryID());
     177    delete bo;
     178  }
     179}
     180
     181
     182
     183/**
     184 *  loads the Parameters of a Campaign
     185 * @param root: The XML-element to load from
     186 */
     187void CampaignData::loadParams(const TiXmlElement* root)
     188{
     189  LoadParamXML(root, "WorldList", this, CampaignData, loadParamsWorldList)
     190      .describe("A List of Worlds to be loaded in this Campaign");
     191
     192}
     193
     194
     195/**
     196 *  loads a WorldList
     197 * @param root: the XML-element to load from
     198 */
     199void CampaignData::loadParamsWorldList(const TiXmlElement* root)
     200{
     201  if( root == NULL)
     202    return;
     203
     204  LOAD_PARAM_START_CYCLE(root, element);
     205  {
     206    StoryEntity* created = (StoryEntity*) Factory::fabricate(element);
     207    if( created != NULL)
     208      this->addStoryEntity(created);
     209  }
     210  LOAD_PARAM_END_CYCLE(element);
     211}
    184212
    185213
Note: See TracChangeset for help on using the changeset viewer.