2010-03-18 22:26:40 +01:00
// ==============================================================
// This file is part of Glest (www.glest.org)
//
2011-12-14 08:40:48 +01:00
// Copyright (C) 2001-2008 Martiño Figueroa
2010-03-18 22:26:40 +01:00
//
// 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 "command_type.h"
# include <algorithm>
# include <cassert>
# include "upgrade_type.h"
# include "unit_type.h"
# include "sound.h"
# include "util.h"
# include "leak_dumper.h"
# include "graphics_interface.h"
# include "tech_tree.h"
# include "faction_type.h"
# include "unit_updater.h"
# include "renderer.h"
# include "leak_dumper.h"
# include "socket.h"
using namespace Shared : : Util ;
namespace Glest { namespace Game {
// =====================================================
// class CommandType
// =====================================================
//get
CommandClass CommandType : : getClass ( ) const {
assert ( this ! = NULL ) ;
return commandTypeClass ;
}
2011-03-15 16:30:28 +01:00
void CommandType : : load ( int id , const XmlNode * n , const string & dir ,
const TechTree * tt , const FactionType * ft , const UnitType & ut ,
2011-05-06 09:47:31 +02:00
std : : map < string , vector < pair < string , string > > > & loadedFileList ,
2011-05-05 22:18:38 +02:00
string parentLoader ) {
2011-03-28 05:54:23 +02:00
if ( SystemFlags : : getSystemSettingType ( SystemFlags : : debugSystem ) . enabled ) SystemFlags : : OutputDebug ( SystemFlags : : debugSystem , " In [%s::%s Line: %d] \n " , __FILE__ , __FUNCTION__ , __LINE__ ) ;
2010-05-01 12:46:56 +02:00
2010-03-18 22:26:40 +01:00
this - > id = id ;
name = n - > getChild ( " name " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
//image
const XmlNode * imageNode = n - > getChild ( " image " ) ;
image = Renderer : : getInstance ( ) . newTexture2D ( rsGame ) ;
2011-03-13 09:23:43 +01:00
string currentPath = dir ;
endPathWithSlash ( currentPath ) ;
2011-09-27 07:29:57 +02:00
if ( image ) {
image - > load ( imageNode - > getAttribute ( " path " ) - > getRestrictedValue ( currentPath ) ) ;
}
2011-05-06 09:47:31 +02:00
loadedFileList [ imageNode - > getAttribute ( " path " ) - > getRestrictedValue ( currentPath ) ] . push_back ( make_pair ( parentLoader , imageNode - > getAttribute ( " path " ) - > getRestrictedValue ( ) ) ) ;
2010-03-18 22:26:40 +01:00
//unit requirements
const XmlNode * unitRequirementsNode = n - > getChild ( " unit-requirements " ) ;
2011-03-15 16:30:28 +01:00
for ( int i = 0 ; i < unitRequirementsNode - > getChildCount ( ) ; + + i ) {
2010-03-18 22:26:40 +01:00
const XmlNode * unitNode = unitRequirementsNode - > getChild ( " unit " , i ) ;
string name = unitNode - > getAttribute ( " name " ) - > getRestrictedValue ( ) ;
unitReqs . push_back ( ft - > getUnitType ( name ) ) ;
}
//upgrade requirements
const XmlNode * upgradeRequirementsNode = n - > getChild ( " upgrade-requirements " ) ;
2011-03-15 16:30:28 +01:00
for ( int i = 0 ; i < upgradeRequirementsNode - > getChildCount ( ) ; + + i ) {
2010-03-18 22:26:40 +01:00
const XmlNode * upgradeReqNode = upgradeRequirementsNode - > getChild ( " upgrade " , i ) ;
string name = upgradeReqNode - > getAttribute ( " name " ) - > getRestrictedValue ( ) ;
upgradeReqs . push_back ( ft - > getUpgradeType ( name ) ) ;
}
2010-05-01 12:46:56 +02:00
2013-01-11 19:18:58 +01:00
//fog of war
if ( n - > hasChild ( " fog-of-war-skill " ) = = true ) {
string skillName = n - > getChild ( " fog-of-war-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
fogOfWarSkillType = static_cast < const FogOfWarSkillType * > ( ut . getSkillType ( skillName , scFogOfWar ) ) ;
2013-01-11 19:40:47 +01:00
string skillAttachmentNames = n - > getChild ( " fog-of-war-skill " ) - > getAttribute ( " skill-attachments " ) - > getValue ( ) ;
2013-01-11 19:18:58 +01:00
std : : vector < std : : string > skillList ;
Tokenize ( skillAttachmentNames , skillList , " , " ) ;
for ( unsigned int i = 0 ; i < skillList . size ( ) ; + + i ) {
string skillAttachName = skillList [ i ] ;
fogOfWarSkillAttachments [ skillAttachName ] = true ;
}
}
2011-03-28 05:54:23 +02:00
if ( SystemFlags : : getSystemSettingType ( SystemFlags : : debugSystem ) . enabled ) SystemFlags : : OutputDebug ( SystemFlags : : debugSystem , " In [%s::%s Line: %d] \n " , __FILE__ , __FUNCTION__ , __LINE__ ) ;
2010-03-18 22:26:40 +01:00
}
2013-01-11 19:18:58 +01:00
bool CommandType : : hasFogOfWarSkillType ( string name ) const {
std : : map < string , bool > : : const_iterator iterFind = fogOfWarSkillAttachments . find ( name ) ;
bool result = ( iterFind ! = fogOfWarSkillAttachments . end ( ) ) ;
return result ;
}
2010-03-18 22:26:40 +01:00
// =====================================================
// class StopCommandType
// =====================================================
//varios
StopCommandType : : StopCommandType ( ) {
commandTypeClass = ccStop ;
clicks = cOne ;
2011-09-01 03:11:23 +02:00
stopSkillType = NULL ;
2010-03-18 22:26:40 +01:00
}
2011-03-18 04:53:06 +01:00
void StopCommandType : : update ( UnitUpdater * unitUpdater , Unit * unit , int frameIndex ) const {
unitUpdater - > updateStop ( unit , frameIndex ) ;
2010-03-18 22:26:40 +01:00
}
string StopCommandType : : getDesc ( const TotalUpgrade * totalUpgrade ) const {
string str ;
Lang & lang = Lang : : getInstance ( ) ;
2013-01-16 22:16:59 +01:00
str = getName ( true ) + " \n " ;
2010-03-18 22:26:40 +01:00
str + = lang . get ( " ReactionSpeed " ) + " : " + intToStr ( stopSkillType - > getSpeed ( ) ) + " \n " ;
if ( stopSkillType - > getEpCost ( ) ! = 0 )
str + = lang . get ( " EpCost " ) + " : " + intToStr ( stopSkillType - > getEpCost ( ) ) + " \n " ;
2011-02-06 19:33:49 +01:00
if ( stopSkillType - > getHpCost ( ) ! = 0 )
str + = lang . get ( " HpCost " ) + " : " + intToStr ( stopSkillType - > getHpCost ( ) ) + " \n " ;
2012-02-19 03:40:13 +01:00
str + = stopSkillType - > getBoostDesc ( ) ;
2010-03-18 22:26:40 +01:00
return str ;
}
string StopCommandType : : toString ( ) const {
Lang & lang = Lang : : getInstance ( ) ;
return lang . get ( " Stop " ) ;
}
2011-03-15 16:30:28 +01:00
void StopCommandType : : load ( int id , const XmlNode * n , const string & dir ,
const TechTree * tt , const FactionType * ft , const UnitType & ut ,
2011-05-06 09:47:31 +02:00
std : : map < string , vector < pair < string , string > > > & loadedFileList , string parentLoader ) {
2011-05-05 22:18:38 +02:00
CommandType : : load ( id , n , dir , tt , ft , ut , loadedFileList , parentLoader ) ;
2010-03-18 22:26:40 +01:00
//stop
string skillName = n - > getChild ( " stop-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
stopSkillType = static_cast < const StopSkillType * > ( ut . getSkillType ( skillName , scStop ) ) ;
}
// =====================================================
// class MoveCommandType
// =====================================================
//varios
MoveCommandType : : MoveCommandType ( ) {
commandTypeClass = ccMove ;
clicks = cTwo ;
2011-09-01 03:11:23 +02:00
moveSkillType = NULL ;
2010-03-18 22:26:40 +01:00
}
2011-03-18 04:53:06 +01:00
void MoveCommandType : : update ( UnitUpdater * unitUpdater , Unit * unit , int frameIndex ) const {
unitUpdater - > updateMove ( unit , frameIndex ) ;
2010-03-18 22:26:40 +01:00
}
2011-03-15 16:30:28 +01:00
void MoveCommandType : : load ( int id , const XmlNode * n , const string & dir ,
const TechTree * tt , const FactionType * ft , const UnitType & ut ,
2011-05-06 09:47:31 +02:00
std : : map < string , vector < pair < string , string > > > & loadedFileList ,
2011-05-05 22:18:38 +02:00
string parentLoader ) {
CommandType : : load ( id , n , dir , tt , ft , ut , loadedFileList , parentLoader ) ;
2010-03-18 22:26:40 +01:00
//move
string skillName = n - > getChild ( " move-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
moveSkillType = static_cast < const MoveSkillType * > ( ut . getSkillType ( skillName , scMove ) ) ;
}
string MoveCommandType : : getDesc ( const TotalUpgrade * totalUpgrade ) const {
string str ;
Lang & lang = Lang : : getInstance ( ) ;
2013-01-16 22:16:59 +01:00
str = getName ( true ) + " \n " ;
2010-03-18 22:26:40 +01:00
str + = lang . get ( " WalkSpeed " ) + " : " + intToStr ( moveSkillType - > getSpeed ( ) ) ;
2011-06-26 09:06:32 +02:00
if ( totalUpgrade - > getMoveSpeed ( moveSkillType ) ! = 0 ) {
str + = " + " + intToStr ( totalUpgrade - > getMoveSpeed ( moveSkillType ) ) ;
2010-03-18 22:26:40 +01:00
}
str + = " \n " ;
if ( moveSkillType - > getEpCost ( ) ! = 0 ) {
str + = lang . get ( " EpCost " ) + " : " + intToStr ( moveSkillType - > getEpCost ( ) ) + " \n " ;
2011-02-06 19:33:49 +01:00
}
if ( moveSkillType - > getHpCost ( ) ! = 0 ) {
str + = lang . get ( " HpCost " ) + " : " + intToStr ( moveSkillType - > getHpCost ( ) ) + " \n " ;
2010-03-18 22:26:40 +01:00
}
2012-02-19 03:40:13 +01:00
str + = moveSkillType - > getBoostDesc ( ) ;
2010-03-18 22:26:40 +01:00
return str ;
}
string MoveCommandType : : toString ( ) const {
Lang & lang = Lang : : getInstance ( ) ;
return lang . get ( " Move " ) ;
}
// =====================================================
// class AttackCommandType
// =====================================================
//varios
AttackCommandType : : AttackCommandType ( ) {
commandTypeClass = ccAttack ;
clicks = cTwo ;
2011-09-01 03:11:23 +02:00
moveSkillType = NULL ;
attackSkillType = NULL ;
2010-03-18 22:26:40 +01:00
}
2011-03-18 04:53:06 +01:00
void AttackCommandType : : update ( UnitUpdater * unitUpdater , Unit * unit , int frameIndex ) const {
unitUpdater - > updateAttack ( unit , frameIndex ) ;
2010-03-18 22:26:40 +01:00
}
2011-03-15 16:30:28 +01:00
void AttackCommandType : : load ( int id , const XmlNode * n , const string & dir ,
const TechTree * tt , const FactionType * ft , const UnitType & ut ,
2011-05-06 09:47:31 +02:00
std : : map < string , vector < pair < string , string > > > & loadedFileList ,
2011-05-05 22:18:38 +02:00
string parentLoader ) {
CommandType : : load ( id , n , dir , tt , ft , ut , loadedFileList , parentLoader ) ;
2010-03-18 22:26:40 +01:00
//move
string skillName = n - > getChild ( " move-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
moveSkillType = static_cast < const MoveSkillType * > ( ut . getSkillType ( skillName , scMove ) ) ;
//attack
skillName = n - > getChild ( " attack-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
attackSkillType = static_cast < const AttackSkillType * > ( ut . getSkillType ( skillName , scAttack ) ) ;
}
string AttackCommandType : : getDesc ( const TotalUpgrade * totalUpgrade ) const {
string str ;
Lang & lang = Lang : : getInstance ( ) ;
2013-01-16 22:16:59 +01:00
str = getName ( true ) + " \n " ;
2010-03-18 22:26:40 +01:00
if ( attackSkillType - > getEpCost ( ) ! = 0 ) {
str + = lang . get ( " EpCost " ) + " : " + intToStr ( attackSkillType - > getEpCost ( ) ) + " \n " ;
2011-02-06 19:33:49 +01:00
}
if ( attackSkillType - > getHpCost ( ) ! = 0 ) {
str + = lang . get ( " HpCost " ) + " : " + intToStr ( attackSkillType - > getHpCost ( ) ) + " \n " ;
2010-03-18 22:26:40 +01:00
}
//attack strength
str + = lang . get ( " AttackStrenght " ) + " : " ;
str + = intToStr ( attackSkillType - > getAttackStrength ( ) - attackSkillType - > getAttackVar ( ) ) ;
str + = " ... " ;
str + = intToStr ( attackSkillType - > getAttackStrength ( ) + attackSkillType - > getAttackVar ( ) ) ;
2011-06-26 09:06:32 +02:00
if ( totalUpgrade - > getAttackStrength ( attackSkillType ) ! = 0 ) {
str + = " + " + intToStr ( totalUpgrade - > getAttackStrength ( attackSkillType ) ) ;
2010-03-18 22:26:40 +01:00
}
2013-01-16 22:16:59 +01:00
str + = " ( " + attackSkillType - > getAttackType ( ) - > getName ( true ) + " ) " ;
2010-03-18 22:26:40 +01:00
str + = " \n " ;
//splash radius
if ( attackSkillType - > getSplashRadius ( ) ! = 0 ) {
str + = lang . get ( " SplashRadius " ) + " : " + intToStr ( attackSkillType - > getSplashRadius ( ) ) + " \n " ;
}
//attack distance
str + = lang . get ( " AttackDistance " ) + " : " + intToStr ( attackSkillType - > getAttackRange ( ) ) ;
2011-06-26 09:06:32 +02:00
if ( totalUpgrade - > getAttackRange ( attackSkillType ) ! = 0 ) {
str + = " + " + intToStr ( totalUpgrade - > getAttackRange ( attackSkillType ) ! = 0 ) ;
2010-03-18 22:26:40 +01:00
}
str + = " \n " ;
//attack fields
str + = lang . get ( " Fields " ) + " : " ;
for ( int i = 0 ; i < fieldCount ; i + + ) {
Field field = static_cast < Field > ( i ) ;
if ( attackSkillType - > getAttackField ( field ) )
{
str + = SkillType : : fieldToStr ( field ) + " " ;
}
}
str + = " \n " ;
//movement speed
str + = lang . get ( " WalkSpeed " ) + " : " + intToStr ( moveSkillType - > getSpeed ( ) ) ;
2011-06-26 09:06:32 +02:00
if ( totalUpgrade - > getMoveSpeed ( moveSkillType ) ! = 0 ) {
str + = " + " + intToStr ( totalUpgrade - > getMoveSpeed ( moveSkillType ) ) ;
2010-03-18 22:26:40 +01:00
}
str + = " \n " ;
str + = lang . get ( " AttackSpeed " ) + " : " + intToStr ( attackSkillType - > getSpeed ( ) ) + " \n " ;
2012-02-19 03:40:13 +01:00
str + = attackSkillType - > getBoostDesc ( ) ;
2010-03-18 22:26:40 +01:00
return str ;
}
string AttackCommandType : : toString ( ) const {
Lang & lang = Lang : : getInstance ( ) ;
return lang . get ( " Attack " ) ;
}
// =====================================================
// class AttackStoppedCommandType
// =====================================================
//varios
AttackStoppedCommandType : : AttackStoppedCommandType ( ) {
commandTypeClass = ccAttackStopped ;
clicks = cOne ;
2011-09-01 03:11:23 +02:00
stopSkillType = NULL ;
attackSkillType = NULL ;
2010-03-18 22:26:40 +01:00
}
2011-03-18 04:53:06 +01:00
void AttackStoppedCommandType : : update ( UnitUpdater * unitUpdater , Unit * unit , int frameIndex ) const {
unitUpdater - > updateAttackStopped ( unit , frameIndex ) ;
2010-03-18 22:26:40 +01:00
}
2011-03-15 16:30:28 +01:00
void AttackStoppedCommandType : : load ( int id , const XmlNode * n , const string & dir ,
const TechTree * tt , const FactionType * ft , const UnitType & ut ,
2011-05-06 09:47:31 +02:00
std : : map < string , vector < pair < string , string > > > & loadedFileList , string parentLoader ) {
2011-05-05 22:18:38 +02:00
CommandType : : load ( id , n , dir , tt , ft , ut , loadedFileList , parentLoader ) ;
2010-03-18 22:26:40 +01:00
//stop
string skillName = n - > getChild ( " stop-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
stopSkillType = static_cast < const StopSkillType * > ( ut . getSkillType ( skillName , scStop ) ) ;
//attack
skillName = n - > getChild ( " attack-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
attackSkillType = static_cast < const AttackSkillType * > ( ut . getSkillType ( skillName , scAttack ) ) ;
}
string AttackStoppedCommandType : : getDesc ( const TotalUpgrade * totalUpgrade ) const {
Lang & lang = Lang : : getInstance ( ) ;
string str ;
2013-01-16 22:16:59 +01:00
str = getName ( true ) + " \n " ;
2010-03-18 22:26:40 +01:00
if ( attackSkillType - > getEpCost ( ) ! = 0 ) {
str + = lang . get ( " EpCost " ) + " : " + intToStr ( attackSkillType - > getEpCost ( ) ) + " \n " ;
2011-02-06 19:33:49 +01:00
}
if ( attackSkillType - > getHpCost ( ) ! = 0 ) {
str + = lang . get ( " HpCost " ) + " : " + intToStr ( attackSkillType - > getHpCost ( ) ) + " \n " ;
2010-03-18 22:26:40 +01:00
}
//attack strength
str + = lang . get ( " AttackStrenght " ) + " : " ;
str + = intToStr ( attackSkillType - > getAttackStrength ( ) - attackSkillType - > getAttackVar ( ) ) ;
str + = " ... " ;
str + = intToStr ( attackSkillType - > getAttackStrength ( ) + attackSkillType - > getAttackVar ( ) ) ;
2011-06-26 09:06:32 +02:00
if ( totalUpgrade - > getAttackStrength ( attackSkillType ) ! = 0 )
str + = " + " + intToStr ( totalUpgrade - > getAttackStrength ( attackSkillType ) ) ;
2013-01-16 22:16:59 +01:00
str + = " ( " + attackSkillType - > getAttackType ( ) - > getName ( true ) + " ) " ;
2010-03-18 22:26:40 +01:00
str + = " \n " ;
//splash radius
if ( attackSkillType - > getSplashRadius ( ) ! = 0 ) {
str + = lang . get ( " SplashRadius " ) + " : " + intToStr ( attackSkillType - > getSplashRadius ( ) ) + " \n " ;
}
//attack distance
2010-04-27 22:38:34 +02:00
str + = lang . get ( " AttackDistance " ) + " : " + intToStr ( attackSkillType - > getAttackRange ( ) ) ;
2011-06-26 09:06:32 +02:00
if ( totalUpgrade - > getAttackRange ( attackSkillType ) ! = 0 ) {
str + = " + " + intToStr ( totalUpgrade - > getAttackRange ( attackSkillType ) ! = 0 ) ;
2010-03-18 22:26:40 +01:00
}
str + = " \n " ;
//attack fields
str + = lang . get ( " Fields " ) + " : " ;
for ( int i = 0 ; i < fieldCount ; i + + ) {
Field field = static_cast < Field > ( i ) ;
if ( attackSkillType - > getAttackField ( field ) )
{
str + = SkillType : : fieldToStr ( field ) + " " ;
}
}
str + = " \n " ;
2012-02-19 03:40:13 +01:00
str + = attackSkillType - > getBoostDesc ( ) ;
2010-03-18 22:26:40 +01:00
return str ;
}
2011-01-08 22:53:05 +01:00
string AttackStoppedCommandType : : toString ( ) const {
2010-03-18 22:26:40 +01:00
Lang & lang = Lang : : getInstance ( ) ;
return lang . get ( " AttackStopped " ) ;
}
// =====================================================
// class BuildCommandType
// =====================================================
//varios
2011-01-08 22:53:05 +01:00
BuildCommandType : : BuildCommandType ( ) {
2010-03-18 22:26:40 +01:00
commandTypeClass = ccBuild ;
clicks = cTwo ;
2011-09-01 03:11:23 +02:00
moveSkillType = NULL ;
buildSkillType = NULL ;
2010-03-18 22:26:40 +01:00
}
2011-01-08 22:53:05 +01:00
BuildCommandType : : ~ BuildCommandType ( ) {
2010-03-18 22:26:40 +01:00
deleteValues ( builtSounds . getSounds ( ) . begin ( ) , builtSounds . getSounds ( ) . end ( ) ) ;
deleteValues ( startSounds . getSounds ( ) . begin ( ) , startSounds . getSounds ( ) . end ( ) ) ;
}
2011-03-18 04:53:06 +01:00
void BuildCommandType : : update ( UnitUpdater * unitUpdater , Unit * unit , int frameIndex ) const {
unitUpdater - > updateBuild ( unit , frameIndex ) ;
2010-03-18 22:26:40 +01:00
}
2011-03-15 16:30:28 +01:00
void BuildCommandType : : load ( int id , const XmlNode * n , const string & dir ,
const TechTree * tt , const FactionType * ft , const UnitType & ut ,
2011-05-06 09:47:31 +02:00
std : : map < string , vector < pair < string , string > > > & loadedFileList , string parentLoader ) {
2011-05-05 22:18:38 +02:00
CommandType : : load ( id , n , dir , tt , ft , ut , loadedFileList , parentLoader ) ;
2010-03-18 22:26:40 +01:00
//move
string skillName = n - > getChild ( " move-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
moveSkillType = static_cast < const MoveSkillType * > ( ut . getSkillType ( skillName , scMove ) ) ;
//build
skillName = n - > getChild ( " build-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
buildSkillType = static_cast < const BuildSkillType * > ( ut . getSkillType ( skillName , scBuild ) ) ;
//buildings built
const XmlNode * buildingsNode = n - > getChild ( " buildings " ) ;
for ( int i = 0 ; i < buildingsNode - > getChildCount ( ) ; + + i ) {
const XmlNode * buildingNode = buildingsNode - > getChild ( " building " , i ) ;
string name = buildingNode - > getAttribute ( " name " ) - > getRestrictedValue ( ) ;
buildings . push_back ( ft - > getUnitType ( name ) ) ;
}
//start sound
const XmlNode * startSoundNode = n - > getChild ( " start-sound " ) ;
if ( startSoundNode - > getAttribute ( " enabled " ) - > getBoolValue ( ) ) {
startSounds . resize ( startSoundNode - > getChildCount ( ) ) ;
for ( int i = 0 ; i < startSoundNode - > getChildCount ( ) ; + + i ) {
const XmlNode * soundFileNode = startSoundNode - > getChild ( " sound-file " , i ) ;
2011-05-05 09:15:12 +02:00
string currentPath = dir ;
endPathWithSlash ( currentPath ) ;
string path = soundFileNode - > getAttribute ( " path " ) - > getRestrictedValue ( currentPath , true ) ;
2011-03-15 16:30:28 +01:00
2010-03-18 22:26:40 +01:00
StaticSound * sound = new StaticSound ( ) ;
2011-03-13 09:23:43 +01:00
2011-05-05 09:15:12 +02:00
sound - > load ( path ) ;
2011-05-06 09:47:31 +02:00
loadedFileList [ path ] . push_back ( make_pair ( parentLoader , soundFileNode - > getAttribute ( " path " ) - > getRestrictedValue ( ) ) ) ;
2010-03-18 22:26:40 +01:00
startSounds [ i ] = sound ;
}
}
//built sound
const XmlNode * builtSoundNode = n - > getChild ( " built-sound " ) ;
if ( builtSoundNode - > getAttribute ( " enabled " ) - > getBoolValue ( ) ) {
builtSounds . resize ( builtSoundNode - > getChildCount ( ) ) ;
for ( int i = 0 ; i < builtSoundNode - > getChildCount ( ) ; + + i ) {
const XmlNode * soundFileNode = builtSoundNode - > getChild ( " sound-file " , i ) ;
2011-05-05 09:15:12 +02:00
string currentPath = dir ;
endPathWithSlash ( currentPath ) ;
string path = soundFileNode - > getAttribute ( " path " ) - > getRestrictedValue ( currentPath , true ) ;
2011-03-15 16:30:28 +01:00
2010-03-18 22:26:40 +01:00
StaticSound * sound = new StaticSound ( ) ;
2011-03-13 09:23:43 +01:00
2011-05-05 09:15:12 +02:00
sound - > load ( path ) ;
2011-05-06 09:47:31 +02:00
loadedFileList [ path ] . push_back ( make_pair ( parentLoader , soundFileNode - > getAttribute ( " path " ) - > getRestrictedValue ( ) ) ) ;
2010-03-18 22:26:40 +01:00
builtSounds [ i ] = sound ;
}
}
2010-05-01 12:46:56 +02:00
2011-03-28 05:54:23 +02:00
if ( SystemFlags : : getSystemSettingType ( SystemFlags : : debugSystem ) . enabled ) SystemFlags : : OutputDebug ( SystemFlags : : debugSystem , " In [%s::%s Line: %d] \n " , __FILE__ , __FUNCTION__ , __LINE__ ) ;
2010-03-18 22:26:40 +01:00
}
string BuildCommandType : : getDesc ( const TotalUpgrade * totalUpgrade ) const {
string str ;
Lang & lang = Lang : : getInstance ( ) ;
2013-01-16 22:16:59 +01:00
str = getName ( true ) + " \n " ;
2010-03-18 22:26:40 +01:00
str + = lang . get ( " BuildSpeed " ) + " : " + intToStr ( buildSkillType - > getSpeed ( ) ) + " \n " ;
if ( buildSkillType - > getEpCost ( ) ! = 0 ) {
str + = lang . get ( " EpCost " ) + " : " + intToStr ( buildSkillType - > getEpCost ( ) ) + " \n " ;
2011-02-06 19:33:49 +01:00
}
if ( buildSkillType - > getHpCost ( ) ! = 0 ) {
str + = lang . get ( " HpCost " ) + " : " + intToStr ( buildSkillType - > getHpCost ( ) ) + " \n " ;
2010-03-18 22:26:40 +01:00
}
2012-02-19 03:40:13 +01:00
str + = buildSkillType - > getBoostDesc ( ) ;
2010-03-18 22:26:40 +01:00
return str ;
}
string BuildCommandType : : toString ( ) const {
Lang & lang = Lang : : getInstance ( ) ;
return lang . get ( " Build " ) ;
}
// =====================================================
// class HarvestCommandType
// =====================================================
//varios
HarvestCommandType : : HarvestCommandType ( ) {
commandTypeClass = ccHarvest ;
clicks = cTwo ;
2011-09-01 03:11:23 +02:00
moveSkillType = NULL ;
moveLoadedSkillType = NULL ;
harvestSkillType = NULL ;
stopLoadedSkillType = NULL ;
maxLoad = 0 ;
hitsPerUnit = 0 ;
2010-03-18 22:26:40 +01:00
}
2011-03-18 04:53:06 +01:00
void HarvestCommandType : : update ( UnitUpdater * unitUpdater , Unit * unit , int frameIndex ) const {
unitUpdater - > updateHarvest ( unit , frameIndex ) ;
2010-03-18 22:26:40 +01:00
}
2011-03-15 16:30:28 +01:00
void HarvestCommandType : : load ( int id , const XmlNode * n , const string & dir ,
const TechTree * tt , const FactionType * ft , const UnitType & ut ,
2011-05-06 09:47:31 +02:00
std : : map < string , vector < pair < string , string > > > & loadedFileList , string parentLoader ) {
2011-05-05 22:18:38 +02:00
CommandType : : load ( id , n , dir , tt , ft , ut , loadedFileList , parentLoader ) ;
2010-03-18 22:26:40 +01:00
//move
string skillName = n - > getChild ( " move-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
moveSkillType = static_cast < const MoveSkillType * > ( ut . getSkillType ( skillName , scMove ) ) ;
//harvest
skillName = n - > getChild ( " harvest-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
harvestSkillType = static_cast < const HarvestSkillType * > ( ut . getSkillType ( skillName , scHarvest ) ) ;
//stop loaded
skillName = n - > getChild ( " stop-loaded-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
stopLoadedSkillType = static_cast < const StopSkillType * > ( ut . getSkillType ( skillName , scStop ) ) ;
//move loaded
skillName = n - > getChild ( " move-loaded-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
moveLoadedSkillType = static_cast < const MoveSkillType * > ( ut . getSkillType ( skillName , scMove ) ) ;
//resources can harvest
const XmlNode * resourcesNode = n - > getChild ( " harvested-resources " ) ;
for ( int i = 0 ; i < resourcesNode - > getChildCount ( ) ; + + i ) {
const XmlNode * resourceNode = resourcesNode - > getChild ( " resource " , i ) ;
harvestedResources . push_back ( tt - > getResourceType ( resourceNode - > getAttribute ( " name " ) - > getRestrictedValue ( ) ) ) ;
}
maxLoad = n - > getChild ( " max-load " ) - > getAttribute ( " value " ) - > getIntValue ( ) ;
hitsPerUnit = n - > getChild ( " hits-per-unit " ) - > getAttribute ( " value " ) - > getIntValue ( ) ;
}
string HarvestCommandType : : getDesc ( const TotalUpgrade * totalUpgrade ) const {
Lang & lang = Lang : : getInstance ( ) ;
string str ;
2013-01-16 22:16:59 +01:00
str = getName ( true ) + " \n " ;
2010-03-18 22:26:40 +01:00
str + = lang . get ( " HarvestSpeed " ) + " : " + intToStr ( harvestSkillType - > getSpeed ( ) / hitsPerUnit ) + " \n " ;
str + = lang . get ( " MaxLoad " ) + " : " + intToStr ( maxLoad ) + " \n " ;
str + = lang . get ( " LoadedSpeed " ) + " : " + intToStr ( moveLoadedSkillType - > getSpeed ( ) ) + " \n " ;
if ( harvestSkillType - > getEpCost ( ) ! = 0 ) {
str + = lang . get ( " EpCost " ) + " : " + intToStr ( harvestSkillType - > getEpCost ( ) ) + " \n " ;
}
2011-02-06 19:33:49 +01:00
if ( harvestSkillType - > getHpCost ( ) ! = 0 ) {
str + = lang . get ( " HpCost " ) + " : " + intToStr ( harvestSkillType - > getHpCost ( ) ) + " \n " ;
}
2010-03-18 22:26:40 +01:00
str + = lang . get ( " Resources " ) + " : \n " ;
for ( int i = 0 ; i < getHarvestedResourceCount ( ) ; + + i ) {
2012-05-02 22:46:47 +02:00
str + = getHarvestedResource ( i ) - > getName ( true ) + " \n " ;
2010-03-18 22:26:40 +01:00
}
2012-02-19 03:40:13 +01:00
str + = harvestSkillType - > getBoostDesc ( ) ;
2010-03-18 22:26:40 +01:00
return str ;
}
string HarvestCommandType : : toString ( ) const {
Lang & lang = Lang : : getInstance ( ) ;
return lang . get ( " Harvest " ) ;
}
bool HarvestCommandType : : canHarvest ( const ResourceType * resourceType ) const {
return find ( harvestedResources . begin ( ) , harvestedResources . end ( ) , resourceType ) ! = harvestedResources . end ( ) ;
}
2013-02-12 09:44:12 +01:00
// =====================================================
// class HarvestCommandType
// =====================================================
//varios
HarvestEmergencyReturnCommandType : : HarvestEmergencyReturnCommandType ( ) {
commandTypeClass = ccHarvestEmergencyReturn ;
clicks = cTwo ;
this - > id = - 10 ;
}
void HarvestEmergencyReturnCommandType : : update ( UnitUpdater * unitUpdater , Unit * unit , int frameIndex ) const {
unitUpdater - > updateHarvestEmergencyReturn ( unit , frameIndex ) ;
}
void HarvestEmergencyReturnCommandType : : load ( int id , const XmlNode * n , const string & dir ,
const TechTree * tt , const FactionType * ft , const UnitType & ut ,
std : : map < string , vector < pair < string , string > > > & loadedFileList , string parentLoader ) {
// CommandType::load(id, n, dir, tt, ft, ut, loadedFileList, parentLoader);
}
string HarvestEmergencyReturnCommandType : : getDesc ( const TotalUpgrade * totalUpgrade ) const {
Lang & lang = Lang : : getInstance ( ) ;
string str ;
str = getName ( true ) + " \n " ;
return str ;
}
string HarvestEmergencyReturnCommandType : : toString ( ) const {
Lang & lang = Lang : : getInstance ( ) ;
return lang . get ( " Harvest " ) ;
}
2010-03-18 22:26:40 +01:00
// =====================================================
// class RepairCommandType
// =====================================================
//varios
RepairCommandType : : RepairCommandType ( ) {
commandTypeClass = ccRepair ;
clicks = cTwo ;
2011-09-01 03:11:23 +02:00
moveSkillType = NULL ;
repairSkillType = NULL ;
2010-03-18 22:26:40 +01:00
}
RepairCommandType : : ~ RepairCommandType ( ) {
}
2011-03-18 04:53:06 +01:00
void RepairCommandType : : update ( UnitUpdater * unitUpdater , Unit * unit , int frameIndex ) const {
unitUpdater - > updateRepair ( unit , frameIndex ) ;
2010-03-18 22:26:40 +01:00
}
2011-03-15 16:30:28 +01:00
void RepairCommandType : : load ( int id , const XmlNode * n , const string & dir ,
const TechTree * tt , const FactionType * ft , const UnitType & ut ,
2011-05-06 09:47:31 +02:00
std : : map < string , vector < pair < string , string > > > & loadedFileList , string parentLoader ) {
2011-05-05 22:18:38 +02:00
CommandType : : load ( id , n , dir , tt , ft , ut , loadedFileList , parentLoader ) ;
2010-03-18 22:26:40 +01:00
2011-10-28 07:22:41 +02:00
// move skill (no longer required by means unit must already be beside unit to repair)
// for example a hospital
if ( n - > hasChild ( " move-skill " ) = = true ) {
string skillName = n - > getChild ( " move-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
moveSkillType = static_cast < const MoveSkillType * > ( ut . getSkillType ( skillName , scMove ) ) ;
}
2010-03-18 22:26:40 +01:00
//repair
2011-10-28 07:22:41 +02:00
string skillName = n - > getChild ( " repair-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
2010-03-18 22:26:40 +01:00
repairSkillType = static_cast < const RepairSkillType * > ( ut . getSkillType ( skillName , scRepair ) ) ;
//repaired units
const XmlNode * unitsNode = n - > getChild ( " repaired-units " ) ;
for ( int i = 0 ; i < unitsNode - > getChildCount ( ) ; + + i ) {
const XmlNode * unitNode = unitsNode - > getChild ( " unit " , i ) ;
repairableUnits . push_back ( ft - > getUnitType ( unitNode - > getAttribute ( " name " ) - > getRestrictedValue ( ) ) ) ;
}
2010-05-01 12:46:56 +02:00
2011-03-28 05:54:23 +02:00
if ( SystemFlags : : getSystemSettingType ( SystemFlags : : debugSystem ) . enabled ) SystemFlags : : OutputDebug ( SystemFlags : : debugSystem , " In [%s::%s Line: %d] \n " , __FILE__ , __FUNCTION__ , __LINE__ ) ;
2010-03-18 22:26:40 +01:00
}
string RepairCommandType : : getDesc ( const TotalUpgrade * totalUpgrade ) const {
Lang & lang = Lang : : getInstance ( ) ;
string str ;
2013-01-16 22:16:59 +01:00
str = getName ( true ) + " \n " ;
2010-03-18 22:26:40 +01:00
str + = lang . get ( " RepairSpeed " ) + " : " + intToStr ( repairSkillType - > getSpeed ( ) ) + " \n " ;
if ( repairSkillType - > getEpCost ( ) ! = 0 ) {
str + = lang . get ( " EpCost " ) + " : " + intToStr ( repairSkillType - > getEpCost ( ) ) + " \n " ;
}
2011-02-06 19:33:49 +01:00
if ( repairSkillType - > getHpCost ( ) ! = 0 ) {
str + = lang . get ( " HpCost " ) + " : " + intToStr ( repairSkillType - > getHpCost ( ) ) + " \n " ;
}
2010-03-18 22:26:40 +01:00
str + = " \n " + lang . get ( " CanRepair " ) + " : \n " ;
for ( int i = 0 ; i < repairableUnits . size ( ) ; + + i ) {
2012-05-02 22:46:47 +02:00
str + = ( static_cast < const UnitType * > ( repairableUnits [ i ] ) ) - > getName ( true ) + " \n " ;
2010-03-18 22:26:40 +01:00
}
2012-02-19 03:40:13 +01:00
str + = repairSkillType - > getBoostDesc ( ) ;
2010-03-18 22:26:40 +01:00
return str ;
}
string RepairCommandType : : toString ( ) const {
Lang & lang = Lang : : getInstance ( ) ;
return lang . get ( " Repair " ) ;
}
//get
2010-10-30 10:54:00 +02:00
bool RepairCommandType : : isRepairableUnitType ( const UnitType * unitType ) const {
for ( int i = 0 ; i < repairableUnits . size ( ) ; + + i ) {
const UnitType * curUnitType = static_cast < const UnitType * > ( repairableUnits [ i ] ) ;
2011-06-30 06:45:17 +02:00
//printf("Lookup index = %d Can repair unittype [%s][%p] looking for [%s][%p] lookup found result = %d\n",i,curUnitType->getName().c_str(),curUnitType,unitType->getName().c_str(),unitType,(curUnitType == unitType));
2010-10-30 10:54:00 +02:00
if ( curUnitType = = unitType ) {
2010-03-18 22:26:40 +01:00
return true ;
}
}
return false ;
}
// =====================================================
// class ProduceCommandType
// =====================================================
//varios
ProduceCommandType : : ProduceCommandType ( ) {
commandTypeClass = ccProduce ;
clicks = cOne ;
2011-09-01 03:11:23 +02:00
produceSkillType = NULL ;
producedUnit = NULL ;
2010-03-18 22:26:40 +01:00
}
2011-03-18 04:53:06 +01:00
void ProduceCommandType : : update ( UnitUpdater * unitUpdater , Unit * unit , int frameIndex ) const {
unitUpdater - > updateProduce ( unit , frameIndex ) ;
2010-03-18 22:26:40 +01:00
}
2011-03-15 16:30:28 +01:00
void ProduceCommandType : : load ( int id , const XmlNode * n , const string & dir ,
const TechTree * tt , const FactionType * ft , const UnitType & ut ,
2011-05-06 09:47:31 +02:00
std : : map < string , vector < pair < string , string > > > & loadedFileList , string parentLoader ) {
2011-05-05 22:18:38 +02:00
CommandType : : load ( id , n , dir , tt , ft , ut , loadedFileList , parentLoader ) ;
2010-03-18 22:26:40 +01:00
//produce
string skillName = n - > getChild ( " produce-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
produceSkillType = static_cast < const ProduceSkillType * > ( ut . getSkillType ( skillName , scProduce ) ) ;
string producedUnitName = n - > getChild ( " produced-unit " ) - > getAttribute ( " name " ) - > getRestrictedValue ( ) ;
producedUnit = ft - > getUnitType ( producedUnitName ) ;
2010-05-01 12:46:56 +02:00
2011-03-28 05:54:23 +02:00
if ( SystemFlags : : getSystemSettingType ( SystemFlags : : debugSystem ) . enabled ) SystemFlags : : OutputDebug ( SystemFlags : : debugSystem , " In [%s::%s Line: %d] \n " , __FILE__ , __FUNCTION__ , __LINE__ ) ;
2010-03-18 22:26:40 +01:00
}
string ProduceCommandType : : getDesc ( const TotalUpgrade * totalUpgrade ) const {
2013-01-16 22:16:59 +01:00
string str = getName ( true ) + " \n " ;
2010-03-18 22:26:40 +01:00
Lang & lang = Lang : : getInstance ( ) ;
//prod speed
str + = lang . get ( " ProductionSpeed " ) + " : " + intToStr ( produceSkillType - > getSpeed ( ) ) ;
2011-06-26 09:06:32 +02:00
if ( totalUpgrade - > getProdSpeed ( produceSkillType ) ! = 0 ) {
str + = " + " + intToStr ( totalUpgrade - > getProdSpeed ( produceSkillType ) ) ;
2010-03-18 22:26:40 +01:00
}
str + = " \n " ;
//mpcost
if ( produceSkillType - > getEpCost ( ) ! = 0 ) {
str + = lang . get ( " EpCost " ) + " : " + intToStr ( produceSkillType - > getEpCost ( ) ) + " \n " ;
}
2011-02-06 19:33:49 +01:00
if ( produceSkillType - > getHpCost ( ) ! = 0 ) {
str + = lang . get ( " hpCost " ) + " : " + intToStr ( produceSkillType - > getHpCost ( ) ) + " \n " ;
}
2010-03-18 22:26:40 +01:00
str + = " \n " + getProducedUnit ( ) - > getReqDesc ( ) ;
2012-02-19 03:40:13 +01:00
str + = produceSkillType - > getBoostDesc ( ) ;
2010-03-18 22:26:40 +01:00
return str ;
}
string ProduceCommandType : : toString ( ) const {
Lang & lang = Lang : : getInstance ( ) ;
return lang . get ( " Produce " ) ;
}
string ProduceCommandType : : getReqDesc ( ) const {
return RequirableType : : getReqDesc ( ) + " \n " + getProducedUnit ( ) - > getReqDesc ( ) ;
}
const ProducibleType * ProduceCommandType : : getProduced ( ) const {
return producedUnit ;
}
// =====================================================
// class UpgradeCommandType
// =====================================================
//varios
UpgradeCommandType : : UpgradeCommandType ( ) {
commandTypeClass = ccUpgrade ;
clicks = cOne ;
2011-09-01 03:11:23 +02:00
upgradeSkillType = NULL ;
producedUpgrade = NULL ;
2010-03-18 22:26:40 +01:00
}
2011-03-18 04:53:06 +01:00
void UpgradeCommandType : : update ( UnitUpdater * unitUpdater , Unit * unit , int frameIndex ) const {
unitUpdater - > updateUpgrade ( unit , frameIndex ) ;
2010-03-18 22:26:40 +01:00
}
2011-03-15 16:30:28 +01:00
void UpgradeCommandType : : load ( int id , const XmlNode * n , const string & dir ,
const TechTree * tt , const FactionType * ft , const UnitType & ut ,
2011-05-06 09:47:31 +02:00
std : : map < string , vector < pair < string , string > > > & loadedFileList , string parentLoader ) {
2010-03-18 22:26:40 +01:00
2011-05-05 22:18:38 +02:00
CommandType : : load ( id , n , dir , tt , ft , ut , loadedFileList , parentLoader ) ;
2010-03-18 22:26:40 +01:00
//upgrade
string skillName = n - > getChild ( " upgrade-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
upgradeSkillType = static_cast < const UpgradeSkillType * > ( ut . getSkillType ( skillName , scUpgrade ) ) ;
string producedUpgradeName = n - > getChild ( " produced-upgrade " ) - > getAttribute ( " name " ) - > getRestrictedValue ( ) ;
producedUpgrade = ft - > getUpgradeType ( producedUpgradeName ) ;
}
string UpgradeCommandType : : getDesc ( const TotalUpgrade * totalUpgrade ) const {
string str ;
Lang & lang = Lang : : getInstance ( ) ;
2013-01-16 22:16:59 +01:00
str = getName ( true ) + " \n " ;
2010-03-18 22:26:40 +01:00
str + = lang . get ( " UpgradeSpeed " ) + " : " + intToStr ( upgradeSkillType - > getSpeed ( ) ) + " \n " ;
if ( upgradeSkillType - > getEpCost ( ) ! = 0 )
str + = lang . get ( " EpCost " ) + " : " + intToStr ( upgradeSkillType - > getEpCost ( ) ) + " \n " ;
2011-02-06 19:33:49 +01:00
if ( upgradeSkillType - > getHpCost ( ) ! = 0 )
str + = lang . get ( " HpCost " ) + " : " + intToStr ( upgradeSkillType - > getHpCost ( ) ) + " \n " ;
2010-03-18 22:26:40 +01:00
str + = " \n " + getProducedUpgrade ( ) - > getReqDesc ( ) ;
2012-02-19 03:40:13 +01:00
str + = upgradeSkillType - > getBoostDesc ( ) ;
2010-03-18 22:26:40 +01:00
return str ;
}
string UpgradeCommandType : : toString ( ) const {
Lang & lang = Lang : : getInstance ( ) ;
return lang . get ( " Upgrade " ) ;
}
string UpgradeCommandType : : getReqDesc ( ) const {
return RequirableType : : getReqDesc ( ) + " \n " + getProducedUpgrade ( ) - > getReqDesc ( ) ;
}
const ProducibleType * UpgradeCommandType : : getProduced ( ) const {
return producedUpgrade ;
}
// =====================================================
// class MorphCommandType
// =====================================================
//varios
MorphCommandType : : MorphCommandType ( ) {
commandTypeClass = ccMorph ;
clicks = cOne ;
2011-09-01 03:11:23 +02:00
morphSkillType = NULL ;
morphUnit = NULL ;
discount = 0 ;
2012-03-27 05:23:03 +02:00
ignoreResourceRequirements = false ;
2010-03-18 22:26:40 +01:00
}
2011-03-18 04:53:06 +01:00
void MorphCommandType : : update ( UnitUpdater * unitUpdater , Unit * unit , int frameIndex ) const {
unitUpdater - > updateMorph ( unit , frameIndex ) ;
2010-03-18 22:26:40 +01:00
}
2011-03-15 16:30:28 +01:00
void MorphCommandType : : load ( int id , const XmlNode * n , const string & dir ,
const TechTree * tt , const FactionType * ft , const UnitType & ut ,
2011-05-06 09:47:31 +02:00
std : : map < string , vector < pair < string , string > > > & loadedFileList , string parentLoader ) {
2011-05-05 22:18:38 +02:00
CommandType : : load ( id , n , dir , tt , ft , ut , loadedFileList , parentLoader ) ;
2010-03-18 22:26:40 +01:00
//morph skill
string skillName = n - > getChild ( " morph-skill " ) - > getAttribute ( " value " ) - > getRestrictedValue ( ) ;
morphSkillType = static_cast < const MorphSkillType * > ( ut . getSkillType ( skillName , scMorph ) ) ;
//morph unit
string morphUnitName = n - > getChild ( " morph-unit " ) - > getAttribute ( " name " ) - > getRestrictedValue ( ) ;
morphUnit = ft - > getUnitType ( morphUnitName ) ;
//discount
discount = n - > getChild ( " discount " ) - > getAttribute ( " value " ) - > getIntValue ( ) ;
2010-05-01 12:46:56 +02:00
2012-03-27 05:23:03 +02:00
ignoreResourceRequirements = false ;
if ( n - > hasChild ( " ignore-resource-requirements " ) = = true ) {
ignoreResourceRequirements = n - > getChild ( " ignore-resource-requirements " ) - > getAttribute ( " value " ) - > getBoolValue ( ) ;
//printf("ignoreResourceRequirements = %d\n",ignoreResourceRequirements);
}
2011-03-28 05:54:23 +02:00
if ( SystemFlags : : getSystemSettingType ( SystemFlags : : debugSystem ) . enabled ) SystemFlags : : OutputDebug ( SystemFlags : : debugSystem , " In [%s::%s Line: %d] \n " , __FILE__ , __FUNCTION__ , __LINE__ ) ;
2010-03-18 22:26:40 +01:00
}
string MorphCommandType : : getDesc ( const TotalUpgrade * totalUpgrade ) const {
2013-01-16 22:16:59 +01:00
string str = getName ( true ) + " \n " ;
2010-03-18 22:26:40 +01:00
Lang & lang = Lang : : getInstance ( ) ;
//prod speed
str + = lang . get ( " MorphSpeed " ) + " : " + intToStr ( morphSkillType - > getSpeed ( ) ) + " \n " ;
//mpcost
if ( morphSkillType - > getEpCost ( ) ! = 0 ) {
str + = lang . get ( " EpCost " ) + " : " + intToStr ( morphSkillType - > getEpCost ( ) ) + " \n " ;
2011-02-06 19:33:49 +01:00
}
if ( morphSkillType - > getHpCost ( ) ! = 0 ) {
str + = lang . get ( " HpCost " ) + " : " + intToStr ( morphSkillType - > getHpCost ( ) ) + " \n " ;
2010-03-18 22:26:40 +01:00
}
//discount
if ( discount ! = 0 ) {
str + = lang . get ( " Discount " ) + " : " + intToStr ( discount ) + " % \n " ;
}
2012-03-27 05:23:03 +02:00
str + = " \n " + getProduced ( ) - > getReqDesc ( ignoreResourceRequirements ) ;
2012-02-19 03:40:13 +01:00
str + = morphSkillType - > getBoostDesc ( ) ;
2012-03-27 05:23:03 +02:00
2010-03-18 22:26:40 +01:00
return str ;
}
string MorphCommandType : : toString ( ) const {
Lang & lang = Lang : : getInstance ( ) ;
return lang . get ( " Morph " ) ;
}
string MorphCommandType : : getReqDesc ( ) const {
return RequirableType : : getReqDesc ( ) + " \n " + getProduced ( ) - > getReqDesc ( ) ;
}
const ProducibleType * MorphCommandType : : getProduced ( ) const {
return morphUnit ;
}
2011-09-21 08:51:28 +02:00
// =====================================================
// class SwitchTeamCommandType
// =====================================================
//varios
SwitchTeamCommandType : : SwitchTeamCommandType ( ) {
commandTypeClass = ccSwitchTeam ;
clicks = cOne ;
}
void SwitchTeamCommandType : : update ( UnitUpdater * unitUpdater , Unit * unit , int frameIndex ) const {
unitUpdater - > updateSwitchTeam ( unit , frameIndex ) ;
}
void SwitchTeamCommandType : : load ( int id , const XmlNode * n , const string & dir ,
const TechTree * tt , const FactionType * ft , const UnitType & ut ,
std : : map < string , vector < pair < string , string > > > & loadedFileList , string parentLoader ) {
CommandType : : load ( id , n , dir , tt , ft , ut , loadedFileList , parentLoader ) ;
//morph skill
//string skillName= n->getChild("morph-skill")->getAttribute("value")->getRestrictedValue();
//morphSkillType= static_cast<const MorphSkillType*>(ut.getSkillType(skillName, scMorph));
if ( SystemFlags : : getSystemSettingType ( SystemFlags : : debugSystem ) . enabled ) SystemFlags : : OutputDebug ( SystemFlags : : debugSystem , " In [%s::%s Line: %d] \n " , __FILE__ , __FUNCTION__ , __LINE__ ) ;
}
string SwitchTeamCommandType : : getDesc ( const TotalUpgrade * totalUpgrade ) const {
2013-01-16 22:16:59 +01:00
string str = getName ( true ) + " \n " ;
2011-12-02 17:07:59 +01:00
//Lang &lang= Lang::getInstance();
2011-09-21 08:51:28 +02:00
//prod speed
//str+= lang.get("MorphSpeed")+": "+ intToStr(morphSkillType->getSpeed())+"\n";
//mpcost
// if(morphSkillType->getEpCost()!=0){
// str+= lang.get("EpCost")+": "+intToStr(morphSkillType->getEpCost())+"\n";
// }
// if(morphSkillType->getHpCost()!=0){
// str+= lang.get("HpCost")+": "+intToStr(morphSkillType->getHpCost())+"\n";
// }
//
// //discount
// if(discount!=0){
// str+= lang.get("Discount")+": "+intToStr(discount)+"%\n";
// }
//
// str+= "\n"+getProduced()->getReqDesc();
return str ;
}
string SwitchTeamCommandType : : toString ( ) const {
Lang & lang = Lang : : getInstance ( ) ;
return lang . get ( " SwitchTeam " ) ;
}
2010-03-18 22:26:40 +01:00
// =====================================================
// class CommandFactory
// =====================================================
CommandTypeFactory : : CommandTypeFactory ( ) {
registerClass < StopCommandType > ( " stop " ) ;
registerClass < MoveCommandType > ( " move " ) ;
registerClass < AttackCommandType > ( " attack " ) ;
registerClass < AttackStoppedCommandType > ( " attack_stopped " ) ;
registerClass < BuildCommandType > ( " build " ) ;
registerClass < HarvestCommandType > ( " harvest " ) ;
registerClass < RepairCommandType > ( " repair " ) ;
registerClass < ProduceCommandType > ( " produce " ) ;
registerClass < UpgradeCommandType > ( " upgrade " ) ;
registerClass < MorphCommandType > ( " morph " ) ;
2011-09-21 08:51:28 +02:00
registerClass < SwitchTeamCommandType > ( " switch_team " ) ;
2013-02-12 09:44:12 +01:00
registerClass < HarvestEmergencyReturnCommandType > ( " harvest_return " ) ;
2010-03-18 22:26:40 +01:00
}
CommandTypeFactory & CommandTypeFactory : : getInstance ( ) {
static CommandTypeFactory ctf ;
return ctf ;
}
} } //end namespace