~ubuntu-branches/ubuntu/saucy/lordsawar/saucy

« back to all changes in this revision

Viewing changes to src/herotemplates.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Barry deFreese
  • Date: 2008-12-20 13:52:12 UTC
  • mfrom: (1.1.6 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20081220135212-noeb2w3y98ebo7o9
Tags: 0.1.4-1
[ Barry deFreese ]
* New upstream release.
* Move 0.0.8-2.1 changelog entry to correct point in changelog.
* Make lordsawar-data suggest lordsawar.
* Update my e-mail address.
* Add build-depends on intltool, uuid-dev, and libboost-dev.
* Don't install locales since there are no translations currently.
* Add simple man page for new lordsawar-pbm binary.
* Drop gcc4.3 patches as they have been fixed upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "herotemplates.h"
20
20
 
21
21
#include "File.h"
22
 
#include "defs.h"
23
22
#include "armysetlist.h"
24
23
#include "playerlist.h"
25
24
#include "hero.h"
 
25
#include "heroproto.h"
26
26
 
27
27
HeroTemplates* HeroTemplates::d_instance = 0;
28
28
 
51
51
HeroTemplates::~HeroTemplates()
52
52
{
53
53
  for (unsigned int i = 0; i < MAX_PLAYERS; ++i)
54
 
    for (std::vector<Hero *>::iterator j = d_herotemplates[i].begin();
 
54
    for (std::vector<HeroProto *>::iterator j = d_herotemplates[i].begin();
55
55
           j != d_herotemplates[i].end(); ++j)
56
56
      delete *j;
57
57
}
58
58
 
59
 
Hero *HeroTemplates::getRandomHero(int player_id)
 
59
HeroProto *HeroTemplates::getRandomHero(int player_id)
60
60
{
61
61
  int num = rand() % d_herotemplates[player_id].size();
62
62
  return d_herotemplates[player_id][num];
74
74
  size_t bytesread = 0;
75
75
  char *tmp;
76
76
  const Armysetlist* al = Armysetlist::getInstance();
77
 
  const Army* herotype;
 
77
  const ArmyProto* herotype;
78
78
 
79
79
  // list all the army types that are heroes.
80
 
  std::vector<const Army*> heroes;
 
80
  std::vector<const ArmyProto*> heroes;
81
81
  Player *p = Playerlist::getInstance()->getNeutral();
82
82
  for (unsigned int j = 0; j < al->getSize(p->getArmyset()); j++)
83
83
    {
84
 
      const Army *a = al->getArmy (p->getArmyset(), j);
 
84
      const ArmyProto *a = al->getArmy (p->getArmyset(), j);
85
85
      if (a->isHero())
86
86
        heroes.push_back(a);
87
87
    }
114
114
        }
115
115
 
116
116
      herotype = heroes[rand() % heroes.size()];
117
 
      Hero *newhero = new Hero (*herotype, "", NULL, true);
 
117
      HeroProto *newhero = new HeroProto (*herotype);
118
118
      if (gender)
119
119
        newhero->setGender(Hero::MALE);
120
120
      else