Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 3, 2006, 11:04:50 PM (20 years ago)
Author:
patrick
Message:

network: more modularity for the GameWorld: data and process are now totaly separated from each other, as it should be. Now I will do some magic on the MultiPlayerWorld, see if it works :D

File:
1 edited

Legend:

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

    r6389 r6402  
    2121#include "load_param.h"
    2222
     23#include "campaign_data.h"
    2324
    2425using namespace std;
     
    6364
    6465  PRINTF(4)("Loaded Campaign specific stuff\n");
    65 
    6666}
    6767
     
    147147
    148148
    149 
    150 /* ==========================================================================================================
    151    CampaignData
    152    ==========================================================================================================
    153 */
    154 
    155 /**
    156  * constructor for CampaignData
    157  */
    158 CampaignData::CampaignData(const TiXmlElement* root)
    159 {
    160   this->setClassID(CL_CAMPAIGN_DATA, "CampaignData");
    161   this->currentEntity = NULL;
    162 
    163   this->loadParams(root);
    164 }
    165 
    166 
    167 /**
    168  * destructor for CampaignData
    169  */
    170 CampaignData::~CampaignData()
    171 {
    172   PRINTF(0)("Deleting CampaignData\n");
    173   while( !this->storyEntities.empty())
    174   {
    175     StoryEntity* bo = this->storyEntities.back();
    176     this->storyEntities.pop_back();
    177     PRINTF(0)("CampaignData is been deleted: nr %i\n", bo->getStoryID());
    178     delete bo;
    179   }
    180 }
    181 
    182 
    183 
    184 /**
    185  *  loads the Parameters of a Campaign
    186  * @param root: The XML-element to load from
    187  */
    188 void CampaignData::loadParams(const TiXmlElement* root)
    189 {
    190   LoadParamXML(root, "WorldList", this, CampaignData, loadParamsWorldList)
    191       .describe("A List of Worlds to be loaded in this Campaign");
    192 
    193 }
    194 
    195 
    196 /**
    197  *  loads a WorldList
    198  * @param root: the XML-element to load from
    199  */
    200 void CampaignData::loadParamsWorldList(const TiXmlElement* root)
    201 {
    202   if( root == NULL)
    203     return;
    204 
    205   LOAD_PARAM_START_CYCLE(root, element);
    206   {
    207     StoryEntity* created = (StoryEntity*) Factory::fabricate(element);
    208     if( created != NULL)
    209       this->addStoryEntity(created);
    210   }
    211   LOAD_PARAM_END_CYCLE(element);
    212 }
    213 
    214 
    215 /**
    216  *  add the StoryEntity to the campaign data tank
    217  * @param se the StoryEntity to add
    218  */
    219 void CampaignData::addStoryEntity(StoryEntity* se)
    220 {
    221   this->storyEntities.push_back(se);
    222 }
    223 
    224 
    225 /**
    226  *  switch to the next level in the list and return it
    227  */
    228 StoryEntity* CampaignData::getFirstLevel()
    229 {
    230   int                            nextStoryID;
    231   int                            storyID;
    232   list<StoryEntity*>::iterator   it;
    233 
    234   nextStoryID = 0;
    235   this->currentEntity = NULL;
    236   for( it = this->storyEntities.begin(); it != this->storyEntities.end(); it++)
    237   {
    238     storyID = (*it)->getStoryID();
    239     if( storyID == nextStoryID)
    240       this->currentEntity = (*it);
    241   }
    242   return this->currentEntity;
    243 }
    244 
    245 
    246 /**
    247  *  switch to the next level in the list and return it
    248  */
    249 StoryEntity* CampaignData::getNextLevel()
    250 {
    251   int                            nextStoryID;
    252   int                            storyID;
    253   list<StoryEntity*>::iterator   it;
    254 
    255   nextStoryID = this->currentEntity->getNextStoryID();
    256   this->currentEntity = NULL;
    257   for( it = this->storyEntities.begin(); it != this->storyEntities.end(); it++)
    258   {
    259     storyID = (*it)->getStoryID();
    260     if( storyID == nextStoryID)
    261       this->currentEntity = (*it);
    262   }
    263   return this->currentEntity;
    264 }
    265 
    266 
    267 
    268 
    269 
Note: See TracChangeset for help on using the changeset viewer.