Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/bsp_model/src/util/game_rules.cc @ 8383

Last change on this file since 8383 was 7488, checked in by patrick, 19 years ago

orxonox: mission manager less verbose and more secure now

File size: 1.8 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Patrick Boenzli
13*/
14
15#define DEBUG_MODULE_GAME_RULES
16
17#include "game_rules.h"
18
19#include "util/loading/load_param.h"
20#include "util/loading/factory.h"
21
22#include "util/mission_goal.h"
23
24
25
26using namespace std;
27
28
29/**
30 * constructor
31 */
32GameRules::GameRules(const TiXmlElement* root)
33{
34  this->setClassID(CL_GAME_RULES, "GameRules");
35}
36
37/**
38 * decontsructor
39 */
40GameRules::~GameRules()
41{}
42
43
44
45void GameRules::loadParams(const TiXmlElement* root)
46{
47  BaseObject::loadParams(root);
48
49  PRINTF(0)("GameRules::loadParams(...) hit me\n");
50  LoadParamXML(root, "MissionGoal", this, GameRules, loadMissionGoal)
51      .describe("an XML-Element to load the missions from");
52}
53
54
55
56void GameRules::loadMissionGoal(const TiXmlElement* root)
57{
58  PRINTF(0)("Trying to load MissionGoals\n");
59  const TiXmlElement* element = root->FirstChildElement();
60  while( element != NULL)
61  {
62    PRINTF(4)("============ MissionGoal\n");
63    PRINTF(4)("Adding Mission Goal:%s\n", element->Value());
64    BaseObject* created = Factory::fabricate(element);
65    if (created != NULL /*&& created->isA(CL_GAME_RULES)*/)
66    {
67      MissionGoal* mg = dynamic_cast<MissionGoal*>(created);
68      this->addMissionGoal(mg);
69      // if there is a valid game rule loaded, break because it is not thought to load multiple game rules
70      break;
71    }
72    else
73    {
74      PRINTF(1)("Could not create a %s\n", element->Value());
75      delete created;
76    }
77    element = element->NextSiblingElement();
78  }
79}
80
Note: See TracBrowser for help on using the repository browser.