2010-03-12 08:42:55 +01:00
|
|
|
|
// ==============================================================
|
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
|
|
|
|
//
|
|
|
|
|
// You can redistribute this code and/or modify it under
|
|
|
|
|
// the terms of the GNU General Public License as published
|
|
|
|
|
// by the Free Software Foundation; either version 2 of the
|
|
|
|
|
// License, or (at your option) any later version
|
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
|
|
#include "unit_type.h"
|
|
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
|
#include "upgrade_type.h"
|
|
|
|
|
#include "resource_type.h"
|
|
|
|
|
#include "sound.h"
|
|
|
|
|
#include "logger.h"
|
|
|
|
|
#include "xml_parser.h"
|
|
|
|
|
#include "tech_tree.h"
|
|
|
|
|
#include "resource.h"
|
|
|
|
|
#include "renderer.h"
|
|
|
|
|
#include "game_util.h"
|
|
|
|
|
#include "unit_particle_type.h"
|
2010-10-02 03:11:59 +02:00
|
|
|
|
#include "faction.h"
|
2010-09-07 07:25:40 +02:00
|
|
|
|
#include "leak_dumper.h"
|
2010-03-12 08:42:55 +01:00
|
|
|
|
|
|
|
|
|
using namespace Shared::Xml;
|
|
|
|
|
using namespace Shared::Graphics;
|
|
|
|
|
using namespace Shared::Util;
|
|
|
|
|
|
|
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class Level
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
void Level::init(string name, int kills){
|
|
|
|
|
this->name= name;
|
|
|
|
|
this->kills= kills;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
|
// class UnitType
|
|
|
|
|
// =====================================================
|
|
|
|
|
|
|
|
|
|
// ===================== PUBLIC ========================
|
|
|
|
|
|
|
|
|
|
const char *UnitType::propertyNames[]= {"burnable", "rotated_climb"};
|
|
|
|
|
|
|
|
|
|
// ==================== creation and loading ====================
|
|
|
|
|
|
2011-01-15 00:51:15 +01:00
|
|
|
|
UnitType::UnitType() : ProducibleType() {
|
2010-03-12 08:42:55 +01:00
|
|
|
|
|
2010-10-28 02:51:25 +02:00
|
|
|
|
meetingPointImage = NULL;
|
2010-03-12 08:42:55 +01:00
|
|
|
|
lightColor= Vec3f(0.f);
|
|
|
|
|
light= false;
|
|
|
|
|
multiSelect= false;
|
|
|
|
|
armorType= NULL;
|
2010-09-07 23:01:22 +02:00
|
|
|
|
rotatedBuildPos=0;
|
2010-03-12 08:42:55 +01:00
|
|
|
|
|
2010-05-01 11:27:08 +02:00
|
|
|
|
for(int i=0; i<ccCount; ++i){
|
|
|
|
|
firstCommandTypeOfClass[i]= NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<scCount; ++i){
|
|
|
|
|
firstSkillTypeOfClass[i] = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-12 08:42:55 +01:00
|
|
|
|
for(int i=0; i<pCount; ++i){
|
|
|
|
|
properties[i]= false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<fieldCount; ++i){
|
|
|
|
|
fields[i]= false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cellMap= NULL;
|
2010-10-30 10:54:00 +02:00
|
|
|
|
allowEmptyCellMap=false;
|
2010-03-12 08:42:55 +01:00
|
|
|
|
hpRegeneration= 0;
|
|
|
|
|
epRegeneration= 0;
|
2010-08-22 23:09:35 +02:00
|
|
|
|
maxUnitCount= 0;
|
2011-01-15 00:51:15 +01:00
|
|
|
|
maxHp=0;
|
|
|
|
|
maxEp=0;
|
|
|
|
|
armor=0;
|
|
|
|
|
sight=0;
|
|
|
|
|
size=0;
|
|
|
|
|
height=0;
|
|
|
|
|
|
|
|
|
|
addItemToVault(&(this->maxHp),this->maxHp);
|
|
|
|
|
addItemToVault(&(this->hpRegeneration),this->hpRegeneration);
|
|
|
|
|
addItemToVault(&(this->maxEp),this->maxEp);
|
|
|
|
|
addItemToVault(&(this->epRegeneration),this->epRegeneration);
|
|
|
|
|
addItemToVault(&(this->maxUnitCount),this->maxUnitCount);
|
|
|
|
|
addItemToVault(&(this->armor),this->armor);
|
|
|
|
|
addItemToVault(&(this->sight),this->sight);
|
|
|
|
|
addItemToVault(&(this->size),this->size);
|
|
|
|
|
addItemToVault(&(this->height),this->height);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnitType::~UnitType(){
|
|
|
|
|
deleteValues(commandTypes.begin(), commandTypes.end());
|
|
|
|
|
deleteValues(skillTypes.begin(), skillTypes.end());
|
|
|
|
|
deleteValues(selectionSounds.getSounds().begin(), selectionSounds.getSounds().end());
|
|
|
|
|
deleteValues(commandSounds.getSounds().begin(), commandSounds.getSounds().end());
|
|
|
|
|
delete [] cellMap;
|
|
|
|
|
//remove damageParticleSystemTypes
|
|
|
|
|
while(!damageParticleSystemTypes.empty()){
|
|
|
|
|
delete damageParticleSystemTypes.back();
|
|
|
|
|
damageParticleSystemTypes.pop_back();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UnitType::preLoad(const string &dir){
|
|
|
|
|
name= lastDir(dir);
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-09 05:49:21 +01:00
|
|
|
|
void UnitType::load(int id,const string &dir, const TechTree *techTree, const FactionType *factionType, Checksum* checksum,Checksum* techtreeChecksum) {
|
2010-03-12 08:42:55 +01:00
|
|
|
|
|
2010-05-01 12:46:56 +02:00
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
|
2010-05-03 08:25:54 +02:00
|
|
|
|
string path = dir + "/" + name + ".xml";
|
|
|
|
|
|
2010-03-12 08:42:55 +01:00
|
|
|
|
this->id= id;
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
Logger::getInstance().add("Unit type: " + formatString(name), true);
|
|
|
|
|
|
|
|
|
|
//file load
|
2011-01-09 05:49:21 +01:00
|
|
|
|
checksum->addFile(path);
|
|
|
|
|
techtreeChecksum->addFile(path);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
|
|
|
|
|
XmlTree xmlTree;
|
|
|
|
|
xmlTree.load(path);
|
|
|
|
|
const XmlNode *unitNode= xmlTree.getRootNode();
|
|
|
|
|
|
|
|
|
|
const XmlNode *parametersNode= unitNode->getChild("parameters");
|
|
|
|
|
|
|
|
|
|
//size
|
2011-01-15 00:51:15 +01:00
|
|
|
|
//checkItemInVault(&(this->size),this->size);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
size= parametersNode->getChild("size")->getAttribute("value")->getIntValue();
|
2011-01-15 00:51:15 +01:00
|
|
|
|
addItemToVault(&(this->size),this->size);
|
|
|
|
|
|
2010-03-12 08:42:55 +01:00
|
|
|
|
//height
|
2011-01-15 00:51:15 +01:00
|
|
|
|
//checkItemInVault(&(this->height),this->height);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
height= parametersNode->getChild("height")->getAttribute("value")->getIntValue();
|
2011-01-15 00:51:15 +01:00
|
|
|
|
addItemToVault(&(this->height),this->height);
|
|
|
|
|
|
2010-03-12 08:42:55 +01:00
|
|
|
|
//maxHp
|
2011-01-15 00:51:15 +01:00
|
|
|
|
//checkItemInVault(&(this->maxHp),this->maxHp);
|
|
|
|
|
maxHp = parametersNode->getChild("max-hp")->getAttribute("value")->getIntValue();
|
|
|
|
|
addItemToVault(&(this->maxHp),this->maxHp);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
|
|
|
|
|
//hpRegeneration
|
2011-01-15 00:51:15 +01:00
|
|
|
|
//checkItemInVault(&(this->hpRegeneration),this->hpRegeneration);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
hpRegeneration= parametersNode->getChild("max-hp")->getAttribute("regeneration")->getIntValue();
|
2011-01-15 00:51:15 +01:00
|
|
|
|
addItemToVault(&(this->hpRegeneration),this->hpRegeneration);
|
|
|
|
|
|
2010-03-12 08:42:55 +01:00
|
|
|
|
//maxEp
|
2011-01-15 00:51:15 +01:00
|
|
|
|
//checkItemInVault(&(this->maxEp),this->maxEp);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
maxEp= parametersNode->getChild("max-ep")->getAttribute("value")->getIntValue();
|
2011-01-15 00:51:15 +01:00
|
|
|
|
addItemToVault(&(this->maxEp),this->maxEp);
|
|
|
|
|
|
|
|
|
|
if(maxEp != 0) {
|
|
|
|
|
//epRegeneration
|
|
|
|
|
//checkItemInVault(&(this->epRegeneration),this->epRegeneration);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
epRegeneration= parametersNode->getChild("max-ep")->getAttribute("regeneration")->getIntValue();
|
|
|
|
|
}
|
2011-01-15 00:51:15 +01:00
|
|
|
|
addItemToVault(&(this->epRegeneration),this->epRegeneration);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
|
2010-08-22 23:09:35 +02:00
|
|
|
|
//maxUnitCount
|
2011-01-15 00:51:15 +01:00
|
|
|
|
if(parametersNode->hasChild("max-unit-count")) {
|
|
|
|
|
//checkItemInVault(&(this->maxUnitCount),this->maxUnitCount);
|
2010-08-22 23:09:35 +02:00
|
|
|
|
maxUnitCount= parametersNode->getChild("max-unit-count")->getAttribute("value")->getIntValue();
|
|
|
|
|
}
|
2011-01-15 00:51:15 +01:00
|
|
|
|
addItemToVault(&(this->maxUnitCount),this->maxUnitCount);
|
2011-01-09 05:49:21 +01:00
|
|
|
|
|
2010-03-12 08:42:55 +01:00
|
|
|
|
//armor
|
2011-01-15 00:51:15 +01:00
|
|
|
|
//checkItemInVault(&(this->armor),this->armor);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
armor= parametersNode->getChild("armor")->getAttribute("value")->getIntValue();
|
2011-01-15 00:51:15 +01:00
|
|
|
|
addItemToVault(&(this->armor),this->armor);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
|
|
|
|
|
//armor type string
|
|
|
|
|
string armorTypeName= parametersNode->getChild("armor-type")->getAttribute("value")->getRestrictedValue();
|
|
|
|
|
armorType= techTree->getArmorType(armorTypeName);
|
|
|
|
|
|
|
|
|
|
//sight
|
2011-01-15 00:51:15 +01:00
|
|
|
|
//checkItemInVault(&(this->sight),this->sight);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
sight= parametersNode->getChild("sight")->getAttribute("value")->getIntValue();
|
2011-01-15 00:51:15 +01:00
|
|
|
|
addItemToVault(&(this->sight),this->sight);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
|
|
|
|
|
//prod time
|
|
|
|
|
productionTime= parametersNode->getChild("time")->getAttribute("value")->getIntValue();
|
|
|
|
|
|
|
|
|
|
//multi selection
|
|
|
|
|
multiSelect= parametersNode->getChild("multi-selection")->getAttribute("value")->getBoolValue();
|
|
|
|
|
|
|
|
|
|
//cellmap
|
2010-10-30 10:54:00 +02:00
|
|
|
|
allowEmptyCellMap = false;
|
2010-03-12 08:42:55 +01:00
|
|
|
|
const XmlNode *cellMapNode= parametersNode->getChild("cellmap");
|
|
|
|
|
bool hasCellMap= cellMapNode->getAttribute("value")->getBoolValue();
|
2010-10-30 10:54:00 +02:00
|
|
|
|
if(hasCellMap == true) {
|
|
|
|
|
if(cellMapNode->getAttribute("allowEmpty",false) != NULL) {
|
|
|
|
|
allowEmptyCellMap = cellMapNode->getAttribute("allowEmpty")->getBoolValue();
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-12 08:42:55 +01:00
|
|
|
|
cellMap= new bool[size*size];
|
|
|
|
|
for(int i=0; i<size; ++i){
|
|
|
|
|
const XmlNode *rowNode= cellMapNode->getChild("row", i);
|
|
|
|
|
string row= rowNode->getAttribute("value")->getRestrictedValue();
|
|
|
|
|
if(row.size()!=size){
|
|
|
|
|
throw runtime_error("Cellmap row has not the same length as unit size");
|
|
|
|
|
}
|
|
|
|
|
for(int j=0; j<row.size(); ++j){
|
|
|
|
|
cellMap[i*size+j]= row[j]=='0'? false: true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//levels
|
|
|
|
|
const XmlNode *levelsNode= parametersNode->getChild("levels");
|
|
|
|
|
levels.resize(levelsNode->getChildCount());
|
|
|
|
|
for(int i=0; i<levels.size(); ++i){
|
|
|
|
|
const XmlNode *levelNode= levelsNode->getChild("level", i);
|
|
|
|
|
levels[i].init(
|
|
|
|
|
levelNode->getAttribute("name")->getRestrictedValue(),
|
|
|
|
|
levelNode->getAttribute("kills")->getIntValue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//fields
|
|
|
|
|
const XmlNode *fieldsNode= parametersNode->getChild("fields");
|
|
|
|
|
for(int i=0; i<fieldsNode->getChildCount(); ++i){
|
|
|
|
|
const XmlNode *fieldNode= fieldsNode->getChild("field", i);
|
|
|
|
|
string fieldName= fieldNode->getAttribute("value")->getRestrictedValue();
|
|
|
|
|
if(fieldName=="land"){
|
|
|
|
|
fields[fLand]= true;
|
|
|
|
|
}
|
|
|
|
|
else if(fieldName=="air"){
|
|
|
|
|
fields[fAir]= true;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
throw runtime_error("Not a valid field: "+fieldName+": "+ path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-11 20:31:02 +02:00
|
|
|
|
if (fields[fLand]) {
|
|
|
|
|
field = fLand;
|
|
|
|
|
} else if (fields[fAir]) {
|
|
|
|
|
field = fAir;
|
|
|
|
|
} else {
|
|
|
|
|
throw runtime_error("Unit has no field: " + path);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-12 08:42:55 +01:00
|
|
|
|
//properties
|
|
|
|
|
const XmlNode *propertiesNode= parametersNode->getChild("properties");
|
|
|
|
|
for(int i=0; i<propertiesNode->getChildCount(); ++i){
|
|
|
|
|
const XmlNode *propertyNode= propertiesNode->getChild("property", i);
|
|
|
|
|
string propertyName= propertyNode->getAttribute("value")->getRestrictedValue();
|
|
|
|
|
bool found= false;
|
|
|
|
|
for(int i=0; i<pCount; ++i){
|
|
|
|
|
if(propertyName==propertyNames[i]){
|
|
|
|
|
properties[i]= true;
|
|
|
|
|
found= true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!found){
|
|
|
|
|
throw runtime_error("Unknown property: " + propertyName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//damage-particles
|
|
|
|
|
if(parametersNode->hasChild("damage-particles")){
|
|
|
|
|
const XmlNode *particleNode= parametersNode->getChild("damage-particles");
|
|
|
|
|
bool particleEnabled= particleNode->getAttribute("value")->getBoolValue();
|
|
|
|
|
if(particleEnabled){
|
|
|
|
|
for(int i=0; i<particleNode->getChildCount(); ++i){
|
|
|
|
|
const XmlNode *particleFileNode= particleNode->getChild("particle-file", i);
|
|
|
|
|
string path= particleFileNode->getAttribute("path")->getRestrictedValue();
|
|
|
|
|
UnitParticleSystemType *unitParticleSystemType= new UnitParticleSystemType();
|
2010-05-25 20:06:42 +02:00
|
|
|
|
|
2010-06-24 12:52:58 +02:00
|
|
|
|
//Texture2D *newTexture = Renderer::getInstance().newTexture2D(rsGame);
|
|
|
|
|
Texture2D *newTexture = NULL;
|
|
|
|
|
|
|
|
|
|
unitParticleSystemType->load(dir, dir + "/" + path, &Renderer::getInstance());
|
|
|
|
|
if(unitParticleSystemType->hasTexture() == false) {
|
|
|
|
|
//Renderer::getInstance().endLastTexture(rsGame,true);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-12 08:42:55 +01:00
|
|
|
|
damageParticleSystemTypes.push_back(unitParticleSystemType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//light
|
|
|
|
|
const XmlNode *lightNode= parametersNode->getChild("light");
|
|
|
|
|
light= lightNode->getAttribute("enabled")->getBoolValue();
|
|
|
|
|
if(light){
|
|
|
|
|
lightColor.x= lightNode->getAttribute("red")->getFloatValue(0.f, 1.f);
|
|
|
|
|
lightColor.y= lightNode->getAttribute("green")->getFloatValue(0.f, 1.f);
|
|
|
|
|
lightColor.z= lightNode->getAttribute("blue")->getFloatValue(0.f, 1.f);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-27 04:09:11 +01:00
|
|
|
|
//rotationAllowed
|
|
|
|
|
if(parametersNode->hasChild("rotationAllowed")){
|
|
|
|
|
const XmlNode *rotationAllowedNode= parametersNode->getChild("rotationAllowed");
|
|
|
|
|
rotationAllowed= rotationAllowedNode->getAttribute("value")->getBoolValue();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rotationAllowed=true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-03-12 08:42:55 +01:00
|
|
|
|
//unit requirements
|
|
|
|
|
const XmlNode *unitRequirementsNode= parametersNode->getChild("unit-requirements");
|
|
|
|
|
for(int i=0; i<unitRequirementsNode->getChildCount(); ++i){
|
|
|
|
|
const XmlNode *unitNode= unitRequirementsNode->getChild("unit", i);
|
|
|
|
|
string name= unitNode->getAttribute("name")->getRestrictedValue();
|
|
|
|
|
unitReqs.push_back(factionType->getUnitType(name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//upgrade requirements
|
|
|
|
|
const XmlNode *upgradeRequirementsNode= parametersNode->getChild("upgrade-requirements");
|
|
|
|
|
for(int i=0; i<upgradeRequirementsNode->getChildCount(); ++i){
|
|
|
|
|
const XmlNode *upgradeReqNode= upgradeRequirementsNode->getChild("upgrade", i);
|
|
|
|
|
string name= upgradeReqNode->getAttribute("name")->getRestrictedValue();
|
|
|
|
|
upgradeReqs.push_back(factionType->getUpgradeType(name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//resource requirements
|
|
|
|
|
const XmlNode *resourceRequirementsNode= parametersNode->getChild("resource-requirements");
|
|
|
|
|
costs.resize(resourceRequirementsNode->getChildCount());
|
|
|
|
|
for(int i=0; i<costs.size(); ++i){
|
|
|
|
|
const XmlNode *resourceNode= resourceRequirementsNode->getChild("resource", i);
|
|
|
|
|
string name= resourceNode->getAttribute("name")->getRestrictedValue();
|
|
|
|
|
int amount= resourceNode->getAttribute("amount")->getIntValue();
|
|
|
|
|
costs[i].init(techTree->getResourceType(name), amount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//resources stored
|
|
|
|
|
const XmlNode *resourcesStoredNode= parametersNode->getChild("resources-stored");
|
|
|
|
|
storedResources.resize(resourcesStoredNode->getChildCount());
|
|
|
|
|
for(int i=0; i<storedResources.size(); ++i){
|
|
|
|
|
const XmlNode *resourceNode= resourcesStoredNode->getChild("resource", i);
|
|
|
|
|
string name= resourceNode->getAttribute("name")->getRestrictedValue();
|
|
|
|
|
int amount= resourceNode->getAttribute("amount")->getIntValue();
|
|
|
|
|
storedResources[i].init(techTree->getResourceType(name), amount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//image
|
|
|
|
|
const XmlNode *imageNode= parametersNode->getChild("image");
|
|
|
|
|
image= Renderer::getInstance().newTexture2D(rsGame);
|
|
|
|
|
image->load(dir+"/"+imageNode->getAttribute("path")->getRestrictedValue());
|
|
|
|
|
|
|
|
|
|
//image cancel
|
|
|
|
|
const XmlNode *imageCancelNode= parametersNode->getChild("image-cancel");
|
|
|
|
|
cancelImage= Renderer::getInstance().newTexture2D(rsGame);
|
|
|
|
|
cancelImage->load(dir+"/"+imageCancelNode->getAttribute("path")->getRestrictedValue());
|
|
|
|
|
|
|
|
|
|
//meeting point
|
|
|
|
|
const XmlNode *meetingPointNode= parametersNode->getChild("meeting-point");
|
|
|
|
|
meetingPoint= meetingPointNode->getAttribute("value")->getBoolValue();
|
|
|
|
|
if(meetingPoint){
|
|
|
|
|
meetingPointImage= Renderer::getInstance().newTexture2D(rsGame);
|
|
|
|
|
meetingPointImage->load(dir+"/"+meetingPointNode->getAttribute("image-path")->getRestrictedValue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//selection sounds
|
|
|
|
|
const XmlNode *selectionSoundNode= parametersNode->getChild("selection-sounds");
|
|
|
|
|
if(selectionSoundNode->getAttribute("enabled")->getBoolValue()){
|
|
|
|
|
selectionSounds.resize(selectionSoundNode->getChildCount());
|
|
|
|
|
for(int i=0; i<selectionSounds.getSounds().size(); ++i){
|
|
|
|
|
const XmlNode *soundNode= selectionSoundNode->getChild("sound", i);
|
|
|
|
|
string path= soundNode->getAttribute("path")->getRestrictedValue();
|
|
|
|
|
StaticSound *sound= new StaticSound();
|
|
|
|
|
sound->load(dir + "/" + path);
|
|
|
|
|
selectionSounds[i]= sound;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//command sounds
|
|
|
|
|
const XmlNode *commandSoundNode= parametersNode->getChild("command-sounds");
|
|
|
|
|
if(commandSoundNode->getAttribute("enabled")->getBoolValue()){
|
|
|
|
|
commandSounds.resize(commandSoundNode->getChildCount());
|
|
|
|
|
for(int i=0; i<commandSoundNode->getChildCount(); ++i){
|
|
|
|
|
const XmlNode *soundNode= commandSoundNode->getChild("sound", i);
|
|
|
|
|
string path= soundNode->getAttribute("path")->getRestrictedValue();
|
|
|
|
|
StaticSound *sound= new StaticSound();
|
|
|
|
|
sound->load(dir + "/" + path);
|
|
|
|
|
commandSounds[i]= sound;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//skills
|
|
|
|
|
const XmlNode *skillsNode= unitNode->getChild("skills");
|
|
|
|
|
skillTypes.resize(skillsNode->getChildCount());
|
|
|
|
|
for(int i=0; i<skillTypes.size(); ++i){
|
|
|
|
|
const XmlNode *sn= skillsNode->getChild("skill", i);
|
|
|
|
|
const XmlNode *typeNode= sn->getChild("type");
|
|
|
|
|
string classId= typeNode->getAttribute("value")->getRestrictedValue();
|
|
|
|
|
SkillType *skillType= SkillTypeFactory::getInstance().newInstance(classId);
|
|
|
|
|
skillType->load(sn, dir, techTree, factionType);
|
|
|
|
|
skillTypes[i]= skillType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//commands
|
|
|
|
|
const XmlNode *commandsNode= unitNode->getChild("commands");
|
|
|
|
|
commandTypes.resize(commandsNode->getChildCount());
|
|
|
|
|
for(int i=0; i<commandTypes.size(); ++i){
|
|
|
|
|
const XmlNode *commandNode= commandsNode->getChild("command", i);
|
|
|
|
|
const XmlNode *typeNode= commandNode->getChild("type");
|
|
|
|
|
string classId= typeNode->getAttribute("value")->getRestrictedValue();
|
|
|
|
|
CommandType *commandType= CommandTypeFactory::getInstance().newInstance(classId);
|
|
|
|
|
commandType->load(i, commandNode, dir, techTree, factionType, *this);
|
|
|
|
|
commandTypes[i]= commandType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
computeFirstStOfClass();
|
|
|
|
|
computeFirstCtOfClass();
|
|
|
|
|
|
|
|
|
|
if(getFirstStOfClass(scStop)==NULL){
|
|
|
|
|
throw runtime_error("Every unit must have at least one stop skill: "+ path);
|
|
|
|
|
}
|
|
|
|
|
if(getFirstStOfClass(scDie)==NULL){
|
|
|
|
|
throw runtime_error("Every unit must have at least one die skill: "+ path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//Exception handling (conversions and so on);
|
|
|
|
|
catch(const exception &e){
|
2010-10-06 22:22:06 +02:00
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
2010-03-12 08:42:55 +01:00
|
|
|
|
throw runtime_error("Error loading UnitType: " + path + "\n" + e.what());
|
|
|
|
|
}
|
2010-05-01 12:46:56 +02:00
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== get ====================
|
|
|
|
|
|
|
|
|
|
const CommandType *UnitType::getFirstCtOfClass(CommandClass commandClass) const{
|
2010-05-01 11:27:08 +02:00
|
|
|
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
if(firstCommandTypeOfClass[commandClass] == NULL) {
|
2010-05-01 23:07:17 +02:00
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] commandClass = %d\n",__FILE__,__FUNCTION__,__LINE__,commandClass);
|
2010-05-01 11:27:08 +02:00
|
|
|
|
|
2010-05-01 23:07:17 +02:00
|
|
|
|
/*
|
2010-05-01 11:27:08 +02:00
|
|
|
|
for(int j=0; j<ccCount; ++j){
|
|
|
|
|
for(int i=0; i<commandTypes.size(); ++i){
|
|
|
|
|
if(commandTypes[i]->getClass()== CommandClass(j)){
|
|
|
|
|
return commandTypes[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-01 23:07:17 +02:00
|
|
|
|
*/
|
2010-05-01 11:27:08 +02:00
|
|
|
|
|
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
}
|
2010-03-12 08:42:55 +01:00
|
|
|
|
return firstCommandTypeOfClass[commandClass];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const SkillType *UnitType::getFirstStOfClass(SkillClass skillClass) const{
|
2010-05-01 11:27:08 +02:00
|
|
|
|
if(firstSkillTypeOfClass[skillClass] == NULL) {
|
2010-05-14 09:02:17 +02:00
|
|
|
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] skillClass = %d\n",__FILE__,__FUNCTION__,__LINE__,skillClass);
|
2010-05-01 11:27:08 +02:00
|
|
|
|
|
2010-05-01 23:07:17 +02:00
|
|
|
|
/*
|
2010-05-01 11:27:08 +02:00
|
|
|
|
for(int j= 0; j<scCount; ++j){
|
|
|
|
|
for(int i= 0; i<skillTypes.size(); ++i){
|
|
|
|
|
if(skillTypes[i]->getClass()== SkillClass(j)){
|
|
|
|
|
return skillTypes[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-01 23:07:17 +02:00
|
|
|
|
*/
|
2010-05-14 09:02:17 +02:00
|
|
|
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
2010-05-01 11:27:08 +02:00
|
|
|
|
}
|
2010-03-12 08:42:55 +01:00
|
|
|
|
return firstSkillTypeOfClass[skillClass];
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-02 03:11:59 +02:00
|
|
|
|
const HarvestCommandType *UnitType::getFirstHarvestCommand(const ResourceType *resourceType, const Faction *faction) const {
|
|
|
|
|
for(int i = 0; i < commandTypes.size(); ++i) {
|
|
|
|
|
if(commandTypes[i]->getClass() == ccHarvest) {
|
|
|
|
|
const HarvestCommandType *hct = static_cast<const HarvestCommandType*>(commandTypes[i]);
|
|
|
|
|
|
|
|
|
|
if (faction->reqsOk(hct) == false) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(hct->canHarvest(resourceType)) {
|
2010-03-12 08:42:55 +01:00
|
|
|
|
return hct;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const AttackCommandType *UnitType::getFirstAttackCommand(Field field) const{
|
|
|
|
|
for(int i=0; i<commandTypes.size(); ++i){
|
|
|
|
|
if(commandTypes[i]->getClass()== ccAttack){
|
|
|
|
|
const AttackCommandType *act= static_cast<const AttackCommandType*>(commandTypes[i]);
|
|
|
|
|
if(act->getAttackSkillType()->getAttackField(field)){
|
|
|
|
|
return act;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const RepairCommandType *UnitType::getFirstRepairCommand(const UnitType *repaired) const{
|
|
|
|
|
for(int i=0; i<commandTypes.size(); ++i){
|
|
|
|
|
if(commandTypes[i]->getClass()== ccRepair){
|
|
|
|
|
const RepairCommandType *rct= static_cast<const RepairCommandType*>(commandTypes[i]);
|
|
|
|
|
if(rct->isRepairableUnitType(repaired)){
|
|
|
|
|
return rct;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 10:54:00 +02:00
|
|
|
|
bool UnitType::hasEmptyCellMap() const {
|
2011-01-15 05:13:15 +01:00
|
|
|
|
//checkItemInVault(&(this->size),this->size);
|
2010-10-30 10:54:00 +02:00
|
|
|
|
bool result = (size > 0);
|
2010-11-07 03:37:00 +01:00
|
|
|
|
for(int i = 0; result == true && i < size; ++i) {
|
2010-10-30 10:54:00 +02:00
|
|
|
|
for(int j = 0; j < size; ++j){
|
|
|
|
|
if(cellMap[i*size+j] == true) {
|
|
|
|
|
result = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-25 13:15:10 +01:00
|
|
|
|
bool UnitType::getCellMapCell(int x, int y, CardinalDir facing) const {
|
|
|
|
|
assert(cellMap);
|
2010-10-30 10:54:00 +02:00
|
|
|
|
if(cellMap == NULL) {
|
|
|
|
|
throw runtime_error("cellMap == NULL");
|
|
|
|
|
}
|
2011-01-15 00:51:15 +01:00
|
|
|
|
|
2011-01-15 05:13:15 +01:00
|
|
|
|
//checkItemInVault(&(this->size),this->size);
|
2010-11-09 10:06:52 +01:00
|
|
|
|
int tmp=0;
|
2010-03-25 13:15:10 +01:00
|
|
|
|
switch (facing) {
|
|
|
|
|
case CardinalDir::EAST:
|
|
|
|
|
tmp = y;
|
|
|
|
|
y = x;
|
|
|
|
|
x = size - tmp - 1;
|
|
|
|
|
break;
|
|
|
|
|
case CardinalDir::SOUTH:
|
|
|
|
|
x = size - x - 1;
|
|
|
|
|
y = size - y - 1;
|
|
|
|
|
break;
|
|
|
|
|
case CardinalDir::WEST:
|
|
|
|
|
tmp = x;
|
|
|
|
|
x = y;
|
|
|
|
|
y = size - tmp - 1;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return cellMap[y * size + x];
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-12 08:42:55 +01:00
|
|
|
|
int UnitType::getStore(const ResourceType *rt) const{
|
|
|
|
|
for(int i=0; i<storedResources.size(); ++i){
|
|
|
|
|
if(storedResources[i].getType()==rt){
|
|
|
|
|
return storedResources[i].getAmount();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const SkillType *UnitType::getSkillType(const string &skillName, SkillClass skillClass) const{
|
|
|
|
|
for(int i=0; i<skillTypes.size(); ++i){
|
|
|
|
|
if(skillTypes[i]->getName()==skillName){
|
|
|
|
|
if(skillTypes[i]->getClass()==skillClass){
|
|
|
|
|
return skillTypes[i];
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
throw runtime_error("Skill \""+skillName+"\" is not of class \""+SkillType::skillClassToStr(skillClass));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw runtime_error("No skill named \""+skillName+"\"");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== totals ====================
|
|
|
|
|
|
2011-01-15 05:13:15 +01:00
|
|
|
|
int UnitType::getTotalMaxHp(const TotalUpgrade *totalUpgrade) const {
|
2011-01-15 00:51:15 +01:00
|
|
|
|
checkItemInVault(&(this->maxHp),this->maxHp);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
return maxHp + totalUpgrade->getMaxHp();
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-15 05:13:15 +01:00
|
|
|
|
int UnitType::getTotalMaxEp(const TotalUpgrade *totalUpgrade) const {
|
2011-01-15 00:51:15 +01:00
|
|
|
|
checkItemInVault(&(this->maxEp),this->maxEp);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
return maxEp + totalUpgrade->getMaxEp();
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-15 00:51:15 +01:00
|
|
|
|
int UnitType::getTotalArmor(const TotalUpgrade *totalUpgrade) const {
|
|
|
|
|
checkItemInVault(&(this->armor),this->armor);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
return armor + totalUpgrade->getArmor();
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-15 05:13:15 +01:00
|
|
|
|
int UnitType::getTotalSight(const TotalUpgrade *totalUpgrade) const {
|
2011-01-15 00:51:15 +01:00
|
|
|
|
checkItemInVault(&(this->sight),this->sight);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
return sight + totalUpgrade->getSight();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== has ====================
|
|
|
|
|
|
2011-01-15 00:51:15 +01:00
|
|
|
|
bool UnitType::hasSkillClass(SkillClass skillClass) const {
|
2010-03-12 08:42:55 +01:00
|
|
|
|
return firstSkillTypeOfClass[skillClass]!=NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-15 00:51:15 +01:00
|
|
|
|
bool UnitType::hasCommandType(const CommandType *commandType) const {
|
2010-03-12 08:42:55 +01:00
|
|
|
|
assert(commandType!=NULL);
|
2011-01-15 00:51:15 +01:00
|
|
|
|
for(int i=0; i<commandTypes.size(); ++i) {
|
|
|
|
|
if(commandTypes[i]==commandType) {
|
2010-03-12 08:42:55 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-15 00:51:15 +01:00
|
|
|
|
bool UnitType::hasCommandClass(CommandClass commandClass) const {
|
2010-03-12 08:42:55 +01:00
|
|
|
|
return firstCommandTypeOfClass[commandClass]!=NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-15 00:51:15 +01:00
|
|
|
|
bool UnitType::hasSkillType(const SkillType *skillType) const {
|
2010-03-12 08:42:55 +01:00
|
|
|
|
assert(skillType!=NULL);
|
2011-01-15 00:51:15 +01:00
|
|
|
|
for(int i=0; i<skillTypes.size(); ++i) {
|
|
|
|
|
if(skillTypes[i]==skillType) {
|
2010-03-12 08:42:55 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool UnitType::isOfClass(UnitClass uc) const{
|
|
|
|
|
switch(uc){
|
|
|
|
|
case ucWarrior:
|
|
|
|
|
return hasSkillClass(scAttack) && !hasSkillClass(scHarvest);
|
|
|
|
|
case ucWorker:
|
2010-05-29 02:14:00 +02:00
|
|
|
|
return hasSkillClass(scBuild) || hasSkillClass(scRepair)|| hasSkillClass(scHarvest);
|
2010-03-12 08:42:55 +01:00
|
|
|
|
case ucBuilding:
|
|
|
|
|
return hasSkillClass(scBeBuilt);
|
|
|
|
|
default:
|
|
|
|
|
assert(false);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== PRIVATE ====================
|
|
|
|
|
|
2011-01-15 00:51:15 +01:00
|
|
|
|
void UnitType::computeFirstStOfClass() {
|
|
|
|
|
for(int j= 0; j < scCount; ++j) {
|
2010-03-12 08:42:55 +01:00
|
|
|
|
firstSkillTypeOfClass[j]= NULL;
|
2011-01-15 00:51:15 +01:00
|
|
|
|
for(int i= 0; i < skillTypes.size(); ++i) {
|
|
|
|
|
if(skillTypes[i]->getClass()== SkillClass(j)) {
|
2010-03-12 08:42:55 +01:00
|
|
|
|
firstSkillTypeOfClass[j]= skillTypes[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-18 22:26:40 +01:00
|
|
|
|
void UnitType::computeFirstCtOfClass(){
|
2010-05-01 11:27:08 +02:00
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] \n",__FILE__,__FUNCTION__,__LINE__);
|
2010-03-18 22:26:40 +01:00
|
|
|
|
|
2011-01-15 00:51:15 +01:00
|
|
|
|
for(int j=0; j<ccCount; ++j) {
|
2010-03-12 08:42:55 +01:00
|
|
|
|
firstCommandTypeOfClass[j]= NULL;
|
2011-01-15 00:51:15 +01:00
|
|
|
|
for(int i=0; i < commandTypes.size(); ++i) {
|
|
|
|
|
if(commandTypes[i]->getClass()== CommandClass(j)) {
|
2010-03-12 08:42:55 +01:00
|
|
|
|
firstCommandTypeOfClass[j]= commandTypes[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CommandType* UnitType::findCommandTypeById(int id) const{
|
|
|
|
|
for(int i=0; i<getCommandTypeCount(); ++i){
|
|
|
|
|
const CommandType* commandType= getCommandType(i);
|
|
|
|
|
if(commandType->getId()==id){
|
|
|
|
|
return commandType;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-08 09:40:32 +02:00
|
|
|
|
const CommandType *UnitType::getCommandType(int i) const {
|
|
|
|
|
if(i >= commandTypes.size()) {
|
|
|
|
|
char szBuf[1024]="";
|
2010-07-17 08:59:18 +02:00
|
|
|
|
sprintf(szBuf,"In [%s::%s Line: %d] i >= commandTypes.size(), i = %d, commandTypes.size() = %lu",__FILE__,__FUNCTION__,__LINE__,i,(unsigned long)commandTypes.size());
|
2010-06-08 09:40:32 +02:00
|
|
|
|
throw runtime_error(szBuf);
|
|
|
|
|
}
|
|
|
|
|
return commandTypes[i];
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-20 04:19:37 +02:00
|
|
|
|
string UnitType::getCommandTypeListDesc() const {
|
|
|
|
|
string desc = "Commands: ";
|
|
|
|
|
for(int i=0; i<getCommandTypeCount(); ++i){
|
|
|
|
|
const CommandType* commandType= getCommandType(i);
|
|
|
|
|
desc += " id = " + intToStr(commandType->getId()); + " toString: " + commandType->toString();
|
|
|
|
|
}
|
|
|
|
|
return desc;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-22 23:09:35 +02:00
|
|
|
|
string UnitType::getReqDesc() const{
|
|
|
|
|
Lang &lang= Lang::getInstance();
|
|
|
|
|
string desc = "Limits: ";
|
|
|
|
|
string resultTxt="";
|
2011-01-15 00:51:15 +01:00
|
|
|
|
|
|
|
|
|
checkItemInVault(&(this->maxUnitCount),this->maxUnitCount);
|
|
|
|
|
if(getMaxUnitCount() > 0) {
|
2011-01-15 05:13:15 +01:00
|
|
|
|
resultTxt += "\n" + lang.get("MaxUnitCount") + " " + intToStr(getMaxUnitCount());
|
2010-08-22 23:09:35 +02:00
|
|
|
|
}
|
2011-01-15 05:13:15 +01:00
|
|
|
|
if(resultTxt == "")
|
2010-08-23 19:11:07 +02:00
|
|
|
|
return ProducibleType::getReqDesc();
|
2010-08-22 23:09:35 +02:00
|
|
|
|
else
|
2010-08-23 19:11:07 +02:00
|
|
|
|
return ProducibleType::getReqDesc()+"\nLimits: "+resultTxt;
|
2011-01-09 05:49:21 +01:00
|
|
|
|
}
|
2010-08-22 23:09:35 +02:00
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
|
std::string UnitType::toString() const {
|
|
|
|
|
std::string result = "";
|
|
|
|
|
|
|
|
|
|
result = "Unit Name: [" + name + "] id = " + intToStr(id);
|
|
|
|
|
result += " maxHp = " + intToStr(maxHp);
|
|
|
|
|
result += " hpRegeneration = " + intToStr(hpRegeneration);
|
|
|
|
|
result += " maxEp = " + intToStr(maxEp);
|
|
|
|
|
result += " epRegeneration = " + intToStr(epRegeneration);
|
2010-08-22 23:09:35 +02:00
|
|
|
|
result += " maxUnitCount = " + intToStr(getMaxUnitCount());
|
2011-01-09 05:49:21 +01:00
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
|
|
|
|
|
|
for(int i = 0; i < fieldCount; i++) {
|
|
|
|
|
result += " fields index = " + intToStr(i) + " value = " + intToStr(fields[i]);
|
|
|
|
|
}
|
|
|
|
|
for(int i = 0; i < pCount; i++) {
|
|
|
|
|
result += " properties index = " + intToStr(i) + " value = " + intToStr(properties[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result += " armor = " + intToStr(armor);
|
|
|
|
|
|
|
|
|
|
if(armorType != NULL) {
|
|
|
|
|
result += " armorType Name: [" + armorType->getName() + " id = " + intToStr(armorType->getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result += " light = " + intToStr(light);
|
|
|
|
|
result += " lightColor = " + lightColor.getString();
|
|
|
|
|
result += " multiSelect = " + intToStr(multiSelect);
|
|
|
|
|
result += " sight = " + intToStr(sight);
|
|
|
|
|
result += " size = " + intToStr(size);
|
|
|
|
|
result += " height = " + intToStr(height);
|
|
|
|
|
result += " rotatedBuildPos = " + floatToStr(rotatedBuildPos);
|
|
|
|
|
result += " rotationAllowed = " + intToStr(rotationAllowed);
|
|
|
|
|
|
|
|
|
|
if(cellMap != NULL) {
|
|
|
|
|
result += " cellMap:";
|
|
|
|
|
for(int i = 0; i < size; ++i) {
|
|
|
|
|
for(int j = 0; j < size; ++j){
|
|
|
|
|
result += " i = " + intToStr(i) + " j = " + intToStr(j) + " value = " + intToStr(cellMap[i*size+j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result += " skillTypes:";
|
|
|
|
|
for(int i = 0; i < skillTypes.size(); ++i) {
|
|
|
|
|
result += " i = " + intToStr(i) + " " + skillTypes[i]->toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result += " commandTypes:";
|
|
|
|
|
for(int i = 0; i < commandTypes.size(); ++i) {
|
|
|
|
|
result += " i = " + intToStr(i) + " " + commandTypes[i]->toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result += " storedResources:";
|
|
|
|
|
for(int i = 0; i < storedResources.size(); ++i) {
|
|
|
|
|
result += " i = " + intToStr(i) + " " + storedResources[i].getDescription();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result += " levels:";
|
|
|
|
|
for(int i = 0; i < levels.size(); ++i) {
|
|
|
|
|
result += " i = " + intToStr(i) + " " + levels[i].getName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result += " meetingPoint = " + intToStr(meetingPoint);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-12 08:42:55 +01:00
|
|
|
|
}}//end namespace
|