2011-01-20 16:56:30 +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
|
2011-01-20 16:56:30 +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
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
#ifndef _GLEST_GAME_UNIT_H_
|
|
|
|
#define _GLEST_GAME_UNIT_H_
|
|
|
|
|
2012-04-20 03:04:05 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <winsock.h>
|
|
|
|
#endif
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
#include "model.h"
|
|
|
|
#include "upgrade_type.h"
|
|
|
|
#include "particle.h"
|
|
|
|
#include "skill_type.h"
|
|
|
|
#include "game_constants.h"
|
|
|
|
#include "platform_common.h"
|
2011-06-25 10:53:53 +02:00
|
|
|
#include <vector>
|
2012-04-21 05:42:25 +02:00
|
|
|
#include "faction.h"
|
2011-01-20 16:56:30 +01:00
|
|
|
#include "leak_dumper.h"
|
|
|
|
|
2011-09-28 08:57:42 +02:00
|
|
|
//#define LEAK_CHECK_UNITS
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
namespace Glest { namespace Game {
|
|
|
|
|
|
|
|
using Shared::Graphics::ParticleSystem;
|
|
|
|
using Shared::Graphics::UnitParticleSystem;
|
|
|
|
using Shared::Graphics::Vec4f;
|
|
|
|
using Shared::Graphics::Vec2f;
|
|
|
|
using Shared::Graphics::Vec3f;
|
|
|
|
using Shared::Graphics::Vec2i;
|
|
|
|
using Shared::Graphics::Model;
|
|
|
|
using Shared::PlatformCommon::Chrono;
|
|
|
|
using Shared::PlatformCommon::ValueCheckerVault;
|
|
|
|
|
|
|
|
class Map;
|
2012-04-21 05:42:25 +02:00
|
|
|
//class Faction;
|
2011-01-20 16:56:30 +01:00
|
|
|
class Unit;
|
|
|
|
class Command;
|
|
|
|
class SkillType;
|
|
|
|
class ResourceType;
|
|
|
|
class CommandType;
|
|
|
|
class SkillType;
|
|
|
|
class UnitType;
|
|
|
|
class TotalUpgrade;
|
|
|
|
class UpgradeType;
|
|
|
|
class Level;
|
|
|
|
class MorphCommandType;
|
|
|
|
class Game;
|
2011-06-25 10:53:53 +02:00
|
|
|
class Unit;
|
2012-03-13 00:08:22 +01:00
|
|
|
class GameSettings;
|
|
|
|
class World;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2011-06-25 22:44:46 +02:00
|
|
|
enum CommandResult {
|
2011-01-20 16:56:30 +01:00
|
|
|
crSuccess,
|
|
|
|
crFailRes,
|
|
|
|
crFailReqs,
|
|
|
|
crFailUnitCount,
|
|
|
|
crFailUndefined,
|
|
|
|
crSomeFailed
|
|
|
|
};
|
|
|
|
|
2011-06-25 22:44:46 +02:00
|
|
|
enum InterestingUnitType {
|
2011-01-20 16:56:30 +01:00
|
|
|
iutIdleHarvester,
|
|
|
|
iutBuiltBuilding,
|
|
|
|
iutProducer,
|
|
|
|
iutDamaged,
|
|
|
|
iutStore
|
|
|
|
};
|
|
|
|
|
2011-11-16 22:38:12 +01:00
|
|
|
enum CauseOfDeathType {
|
|
|
|
ucodNone,
|
|
|
|
ucodAttacked,
|
|
|
|
ucodAttackBoost,
|
|
|
|
ucodStarvedResource,
|
|
|
|
ucodStarvedRegeneration
|
|
|
|
};
|
|
|
|
|
2012-06-22 15:30:15 +02:00
|
|
|
class UnitBuildInfo {
|
|
|
|
public:
|
|
|
|
UnitBuildInfo() {
|
|
|
|
unit = NULL;
|
|
|
|
//pos;
|
|
|
|
buildUnit = NULL;
|
|
|
|
}
|
|
|
|
const Unit *unit;
|
|
|
|
CardinalDir facing;
|
|
|
|
Vec2i pos;
|
|
|
|
const UnitType *buildUnit;
|
|
|
|
};
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
// =====================================================
|
|
|
|
// class UnitObserver
|
|
|
|
// =====================================================
|
|
|
|
|
2011-06-25 22:44:46 +02:00
|
|
|
class UnitObserver {
|
2011-01-20 16:56:30 +01:00
|
|
|
public:
|
|
|
|
enum Event{
|
|
|
|
eKill
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~UnitObserver() {}
|
|
|
|
virtual void unitEvent(Event event, const Unit *unit)=0;
|
2012-03-10 04:27:25 +01:00
|
|
|
|
|
|
|
virtual void saveGame(XmlNode *rootNode) const = 0;
|
2011-01-20 16:56:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class UnitReference
|
|
|
|
// =====================================================
|
|
|
|
|
2011-06-25 22:44:46 +02:00
|
|
|
class UnitReference {
|
2011-01-20 16:56:30 +01:00
|
|
|
private:
|
|
|
|
int id;
|
|
|
|
Faction *faction;
|
|
|
|
|
|
|
|
public:
|
|
|
|
UnitReference();
|
|
|
|
|
2011-09-01 03:11:23 +02:00
|
|
|
UnitReference & operator=(const Unit *unit);
|
2011-01-20 16:56:30 +01:00
|
|
|
Unit *getUnit() const;
|
|
|
|
|
|
|
|
int getUnitId() const { return id; }
|
|
|
|
Faction *getUnitFaction() const { return faction; }
|
2012-03-10 04:27:25 +01:00
|
|
|
|
|
|
|
void saveGame(XmlNode *rootNode);
|
2012-03-13 02:34:14 +01:00
|
|
|
void loadGame(const XmlNode *rootNode,World *world);
|
2011-01-20 16:56:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class UnitPathInterface {
|
|
|
|
|
|
|
|
public:
|
2011-09-28 08:57:42 +02:00
|
|
|
UnitPathInterface() {}
|
|
|
|
virtual ~UnitPathInterface() {}
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
virtual bool isBlocked() const = 0;
|
|
|
|
virtual bool isEmpty() const = 0;
|
|
|
|
virtual bool isStuck() const = 0;
|
|
|
|
|
|
|
|
virtual void clear() = 0;
|
|
|
|
virtual void clearBlockCount() = 0;
|
|
|
|
virtual void incBlockCount() = 0;
|
|
|
|
virtual void add(const Vec2i &path) = 0;
|
|
|
|
//virtual Vec2i pop() = 0;
|
|
|
|
virtual int getBlockCount() const = 0;
|
|
|
|
virtual int getQueueCount() const = 0;
|
|
|
|
|
|
|
|
virtual vector<Vec2i> getQueue() const = 0;
|
|
|
|
|
|
|
|
virtual std::string toString() const = 0;
|
2011-02-23 08:03:38 +01:00
|
|
|
|
|
|
|
virtual void setMap(Map *value) = 0;
|
|
|
|
virtual Map * getMap() = 0;
|
2012-03-10 04:27:25 +01:00
|
|
|
|
|
|
|
virtual void saveGame(XmlNode *rootNode) = 0;
|
2013-02-17 08:15:01 +01:00
|
|
|
virtual void loadGame(const XmlNode *rootNode) = 0;
|
|
|
|
|
|
|
|
virtual void clearCaches() = 0;
|
2013-10-17 08:36:28 +02:00
|
|
|
|
|
|
|
virtual Checksum getCRC() = 0;
|
2011-01-20 16:56:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class UnitPathBasic : public UnitPathInterface {
|
|
|
|
private:
|
|
|
|
static const int maxBlockCount;
|
2011-02-23 08:03:38 +01:00
|
|
|
Map *map;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2011-09-28 08:57:42 +02:00
|
|
|
#ifdef LEAK_CHECK_UNITS
|
|
|
|
static std::map<UnitPathBasic *,bool> mapMemoryList;
|
|
|
|
#endif
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
private:
|
|
|
|
int blockCount;
|
|
|
|
vector<Vec2i> pathQueue;
|
|
|
|
|
|
|
|
public:
|
|
|
|
UnitPathBasic();
|
2011-02-12 10:08:50 +01:00
|
|
|
virtual ~UnitPathBasic();
|
2011-09-28 08:57:42 +02:00
|
|
|
|
|
|
|
#ifdef LEAK_CHECK_UNITS
|
|
|
|
static void dumpMemoryList();
|
|
|
|
#endif
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
virtual bool isBlocked() const;
|
|
|
|
virtual bool isEmpty() const;
|
|
|
|
virtual bool isStuck() const;
|
|
|
|
|
|
|
|
virtual void clear();
|
|
|
|
virtual void clearBlockCount() { blockCount = 0; }
|
|
|
|
virtual void incBlockCount();
|
|
|
|
virtual void add(const Vec2i &path);
|
2011-03-18 04:53:06 +01:00
|
|
|
Vec2i pop(bool removeFrontPos=true);
|
2011-01-20 16:56:30 +01:00
|
|
|
virtual int getBlockCount() const { return blockCount; }
|
2013-11-02 12:04:52 +01:00
|
|
|
virtual int getQueueCount() const { return (int)pathQueue.size(); }
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
virtual vector<Vec2i> getQueue() const { return pathQueue; }
|
|
|
|
|
2011-02-23 08:03:38 +01:00
|
|
|
virtual void setMap(Map *value) { map = value; }
|
|
|
|
virtual Map * getMap() { return map; }
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
virtual std::string toString() const;
|
2012-03-10 04:27:25 +01:00
|
|
|
|
|
|
|
virtual void saveGame(XmlNode *rootNode);
|
2013-02-17 08:15:01 +01:00
|
|
|
virtual void loadGame(const XmlNode *rootNode);
|
|
|
|
virtual void clearCaches();
|
2013-10-17 08:36:28 +02:00
|
|
|
|
|
|
|
virtual Checksum getCRC();
|
2011-01-20 16:56:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// class UnitPath
|
|
|
|
// =====================================================
|
|
|
|
/** Holds the next cells of a Unit movement
|
|
|
|
* @extends std::list<Shared::Math::Vec2i>
|
|
|
|
*/
|
|
|
|
class UnitPath : public list<Vec2i>, public UnitPathInterface {
|
|
|
|
private:
|
|
|
|
static const int maxBlockCount = 10; /**< number of command updates to wait on a blocked path */
|
|
|
|
|
|
|
|
private:
|
|
|
|
int blockCount; /**< number of command updates this path has been blocked */
|
2011-02-23 08:03:38 +01:00
|
|
|
Map *map;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
public:
|
2011-09-28 08:57:42 +02:00
|
|
|
UnitPath() : UnitPathInterface(), blockCount(0), map(NULL) {} /**< Construct path object */
|
2013-02-17 08:15:01 +01:00
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
virtual bool isBlocked() const {return blockCount >= maxBlockCount;} /**< is this path blocked */
|
|
|
|
virtual bool isEmpty() const {return list<Vec2i>::empty();} /**< is path empty */
|
|
|
|
virtual bool isStuck() const {return false; }
|
|
|
|
|
2013-11-02 12:04:52 +01:00
|
|
|
int size() const {return (int)list<Vec2i>::size();} /**< size of path */
|
2011-01-20 16:56:30 +01:00
|
|
|
virtual void clear() {list<Vec2i>::clear(); blockCount = 0;} /**< clear the path */
|
|
|
|
virtual void clearBlockCount() { blockCount = 0; }
|
|
|
|
virtual void incBlockCount() {++blockCount;} /**< increment block counter */
|
|
|
|
virtual void push(Vec2i &pos) {push_front(pos);} /**< push onto front of path */
|
|
|
|
bool empty() const {return list<Vec2i>::empty();} /**< is path empty */
|
|
|
|
virtual void add(const Vec2i &pos) { push_front(pos);} /**< push onto front of path */
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
// old style, to work with original PathFinder
|
|
|
|
Vec2i peek() {return back();} /**< peek at the next position */
|
|
|
|
void pop() {this->pop_back();} /**< pop the next position off the path */
|
|
|
|
#else
|
2012-09-22 23:39:13 +02:00
|
|
|
// new style
|
2011-01-20 16:56:30 +01:00
|
|
|
Vec2i peek() {return front();} /**< peek at the next position */
|
|
|
|
//virtual Vec2i pop() { Vec2i p= front(); erase(begin()); return p; } /**< pop the next position off the path */
|
|
|
|
void pop() { erase(begin()); } /**< pop the next position off the path */
|
|
|
|
#endif
|
|
|
|
virtual int getBlockCount() const { return blockCount; }
|
|
|
|
virtual int getQueueCount() const { return this->size(); }
|
|
|
|
|
|
|
|
virtual vector<Vec2i> getQueue() const {
|
|
|
|
vector<Vec2i> result;
|
|
|
|
for(list<Vec2i>::const_iterator iter = this->begin(); iter != this->end(); ++iter) {
|
|
|
|
result.push_back(*iter);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-02-23 08:03:38 +01:00
|
|
|
virtual void setMap(Map *value) { map = value; }
|
|
|
|
virtual Map * getMap() { return map; }
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
virtual std::string toString() const;
|
2012-03-10 04:27:25 +01:00
|
|
|
|
|
|
|
virtual void saveGame(XmlNode *rootNode) {};
|
2013-02-17 08:15:01 +01:00
|
|
|
virtual void loadGame(const XmlNode *rootNode) {};
|
|
|
|
virtual void clearCaches() {};
|
2013-10-17 08:36:28 +02:00
|
|
|
|
|
|
|
virtual Checksum getCRC() { return Checksum(); };
|
2011-01-20 16:56:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class WaypointPath : public list<Vec2i> {
|
|
|
|
public:
|
|
|
|
WaypointPath() {}
|
|
|
|
void push(const Vec2i &pos) { push_front(pos); }
|
|
|
|
Vec2i peek() const {return front();}
|
|
|
|
void pop() {erase(begin());}
|
|
|
|
void condense();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
// class Unit
|
|
|
|
//
|
|
|
|
/// A game unit or building
|
|
|
|
// ===============================
|
|
|
|
|
2011-06-25 22:44:46 +02:00
|
|
|
class UnitAttackBoostEffect {
|
|
|
|
public:
|
|
|
|
|
|
|
|
UnitAttackBoostEffect();
|
2012-09-22 22:13:57 +02:00
|
|
|
virtual ~UnitAttackBoostEffect();
|
2011-06-25 22:44:46 +02:00
|
|
|
|
|
|
|
const AttackBoost *boost;
|
|
|
|
const Unit *source;
|
|
|
|
UnitParticleSystem *ups;
|
|
|
|
UnitParticleSystemType *upst;
|
|
|
|
|
2012-03-10 04:27:25 +01:00
|
|
|
virtual void saveGame(XmlNode *rootNode);
|
2011-06-25 22:44:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class UnitAttackBoostEffectOriginator {
|
|
|
|
public:
|
|
|
|
|
|
|
|
UnitAttackBoostEffectOriginator();
|
2012-09-22 22:13:57 +02:00
|
|
|
virtual ~UnitAttackBoostEffectOriginator();
|
2011-06-25 22:44:46 +02:00
|
|
|
|
|
|
|
const SkillType *skillType;
|
2011-07-06 07:16:25 +02:00
|
|
|
std::vector<int> currentAttackBoostUnits;
|
2011-06-25 22:44:46 +02:00
|
|
|
UnitAttackBoostEffect *currentAppliedEffect;
|
2012-03-10 04:27:25 +01:00
|
|
|
|
|
|
|
virtual void saveGame(XmlNode *rootNode);
|
2011-06-25 22:44:46 +02:00
|
|
|
};
|
|
|
|
|
2013-09-23 19:16:34 +02:00
|
|
|
class Unit : public BaseColorPickEntity, ValueCheckerVault, public ParticleOwner {
|
2011-01-20 16:56:30 +01:00
|
|
|
private:
|
|
|
|
typedef list<Command*> Commands;
|
|
|
|
typedef list<UnitObserver*> Observers;
|
|
|
|
typedef vector<UnitParticleSystem*> UnitParticleSystems;
|
|
|
|
|
2011-09-28 08:57:42 +02:00
|
|
|
#ifdef LEAK_CHECK_UNITS
|
|
|
|
static std::map<Unit *,bool> mapMemoryList;
|
|
|
|
#endif
|
|
|
|
|
2013-10-03 02:17:51 +02:00
|
|
|
static const float ANIMATION_SPEED_MULTIPLIER;
|
2013-09-18 02:46:30 +02:00
|
|
|
static const int64 PROGRESS_SPEED_MULTIPLIER;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
public:
|
2013-05-25 04:42:57 +02:00
|
|
|
static const int speedDivider;
|
2011-01-20 16:56:30 +01:00
|
|
|
static const int maxDeadCount;
|
|
|
|
static const int invalidId;
|
|
|
|
|
2011-09-28 08:57:42 +02:00
|
|
|
#ifdef LEAK_CHECK_UNITS
|
|
|
|
static std::map<UnitPathInterface *,int> mapMemoryList2;
|
|
|
|
static void dumpMemoryList();
|
|
|
|
#endif
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
private:
|
2013-09-12 05:33:43 +02:00
|
|
|
const int32 id;
|
|
|
|
int32 hp;
|
|
|
|
int32 ep;
|
|
|
|
int32 loadCount;
|
|
|
|
int32 deadCount;
|
2013-05-25 04:42:57 +02:00
|
|
|
//float progress; //between 0 and 1
|
2013-06-03 16:30:52 +02:00
|
|
|
int64 progress; //between 0 and 1
|
|
|
|
int64 lastAnimProgress; //between 0 and 1
|
|
|
|
int64 animProgress; //between 0 and 1
|
2013-10-02 22:22:10 +02:00
|
|
|
float highlight;
|
2013-09-12 05:33:43 +02:00
|
|
|
int32 progress2;
|
|
|
|
int32 kills;
|
|
|
|
int32 enemyKills;
|
2012-09-22 01:45:59 +02:00
|
|
|
bool morphFieldsBlocked;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
UnitReference targetRef;
|
|
|
|
|
|
|
|
Field currField;
|
|
|
|
Field targetField;
|
|
|
|
const Level *level;
|
|
|
|
|
|
|
|
Vec2i pos;
|
|
|
|
Vec2i lastPos;
|
|
|
|
Vec2i targetPos; //absolute target pos
|
2013-10-02 22:22:10 +02:00
|
|
|
Vec3f targetVec;
|
2011-01-20 16:56:30 +01:00
|
|
|
Vec2i meetingPos;
|
|
|
|
|
2013-10-02 22:22:10 +02:00
|
|
|
float lastRotation; //in degrees
|
|
|
|
float targetRotation;
|
|
|
|
float rotation;
|
|
|
|
float targetRotationZ;
|
|
|
|
float targetRotationX;
|
|
|
|
float rotationZ;
|
|
|
|
float rotationX;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2013-05-26 00:44:39 +02:00
|
|
|
const UnitType *preMorph_type;
|
2011-01-20 16:56:30 +01:00
|
|
|
const UnitType *type;
|
|
|
|
const ResourceType *loadType;
|
|
|
|
const SkillType *currSkill;
|
2013-09-12 05:33:43 +02:00
|
|
|
int32 lastModelIndexForCurrSkillType;
|
|
|
|
int32 animationRandomCycleCount;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
bool toBeUndertaken;
|
|
|
|
bool alive;
|
|
|
|
bool showUnitParticles;
|
|
|
|
|
|
|
|
Faction *faction;
|
|
|
|
ParticleSystem *fire;
|
|
|
|
TotalUpgrade totalUpgrade;
|
|
|
|
Map *map;
|
|
|
|
|
|
|
|
UnitPathInterface *unitPath;
|
|
|
|
WaypointPath waypointPath;
|
|
|
|
|
|
|
|
Commands commands;
|
|
|
|
Observers observers;
|
|
|
|
vector<UnitParticleSystem*> unitParticleSystems;
|
2011-08-27 08:52:17 +02:00
|
|
|
vector<UnitParticleSystemType*> queuedUnitParticleSystemTypes;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
UnitParticleSystems damageParticleSystems;
|
2011-07-01 23:47:54 +02:00
|
|
|
std::map<int, UnitParticleSystem *> damageParticleSystemsInUse;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
vector<ParticleSystem*> fireParticleSystems;
|
2011-07-04 17:55:13 +02:00
|
|
|
vector<UnitParticleSystem*> smokeParticleSystems;
|
2013-09-19 22:03:36 +02:00
|
|
|
vector<ParticleSystem*> attackParticleSystems;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
CardinalDir modelFacing;
|
|
|
|
|
|
|
|
std::string lastSynchDataString;
|
|
|
|
std::string lastFile;
|
2013-09-12 05:33:43 +02:00
|
|
|
int32 lastLine;
|
2011-01-20 16:56:30 +01:00
|
|
|
std::string lastSource;
|
2013-09-12 05:33:43 +02:00
|
|
|
int32 lastRenderFrame;
|
2011-01-20 16:56:30 +01:00
|
|
|
bool visible;
|
|
|
|
|
|
|
|
int retryCurrCommandCount;
|
|
|
|
|
|
|
|
Vec3f screenPos;
|
|
|
|
string currentUnitTitle;
|
|
|
|
|
|
|
|
bool inBailOutAttempt;
|
|
|
|
// This buffer stores a list of bad harvest cells, along with the start
|
|
|
|
// time of when it was detected. Typically this may be due to a unit
|
|
|
|
// constantly getting blocked from getting to the resource so this
|
|
|
|
// list may be used to tell areas of the game to ignore those cells for a
|
|
|
|
// period of time
|
|
|
|
//std::vector<std::pair<Vec2i,Chrono> > badHarvestPosList;
|
|
|
|
std::map<Vec2i,int> badHarvestPosList;
|
|
|
|
//time_t lastBadHarvestListPurge;
|
|
|
|
std::pair<Vec2i,int> lastHarvestResourceTarget;
|
|
|
|
|
2011-03-29 18:27:01 +02:00
|
|
|
//std::pair<Vec2i,std::vector<Vec2i> > currentTargetPathTaken;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
static Game *game;
|
|
|
|
|
2011-01-29 13:42:18 +01:00
|
|
|
bool ignoreCheckCommand;
|
|
|
|
|
2011-04-04 06:32:01 +02:00
|
|
|
uint32 lastStuckFrame;
|
|
|
|
Vec2i lastStuckPos;
|
|
|
|
|
2011-04-14 04:51:13 +02:00
|
|
|
uint32 lastPathfindFailedFrame;
|
|
|
|
Vec2i lastPathfindFailedPos;
|
|
|
|
bool usePathfinderExtendedMaxNodes;
|
2013-09-12 05:33:43 +02:00
|
|
|
int32 maxQueuedCommandDisplayCount;
|
2011-04-14 04:51:13 +02:00
|
|
|
|
2011-06-25 22:44:46 +02:00
|
|
|
UnitAttackBoostEffectOriginator currentAttackBoostOriginatorEffect;
|
|
|
|
|
2011-07-06 07:16:25 +02:00
|
|
|
std::vector<UnitAttackBoostEffect *> currentAttackBoostEffects;
|
2011-06-25 10:53:53 +02:00
|
|
|
|
2011-12-02 17:07:59 +01:00
|
|
|
Mutex *mutexCommands;
|
2011-07-05 17:43:39 +02:00
|
|
|
|
2011-09-25 06:07:59 +02:00
|
|
|
//static Mutex mutexDeletedUnits;
|
|
|
|
//static std::map<void *,bool> deletedUnits;
|
|
|
|
|
2011-10-28 02:22:03 +02:00
|
|
|
bool changedActiveCommand;
|
|
|
|
|
2013-09-12 05:33:43 +02:00
|
|
|
int32 lastAttackerUnitId;
|
|
|
|
int32 lastAttackedUnitId;
|
2011-11-16 22:38:12 +01:00
|
|
|
CauseOfDeathType causeOfDeath;
|
|
|
|
|
2012-04-29 06:45:51 +02:00
|
|
|
uint32 pathfindFailedConsecutiveFrameCount;
|
2012-05-04 16:57:59 +02:00
|
|
|
Vec2i currentPathFinderDesiredFinalPos;
|
2012-04-29 06:45:51 +02:00
|
|
|
|
2012-05-12 03:06:55 +02:00
|
|
|
RandomGen random;
|
2013-09-12 05:33:43 +02:00
|
|
|
int32 pathFindRefreshCellCount;
|
2012-05-12 03:06:55 +02:00
|
|
|
|
2013-01-04 19:00:51 +01:00
|
|
|
FowAlphaCellsLookupItem cachedFow;
|
2013-01-04 21:35:38 +01:00
|
|
|
Vec2i cachedFowPos;
|
2012-09-24 19:13:27 +02:00
|
|
|
|
2013-11-13 19:05:47 +01:00
|
|
|
ExploredCellsLookupItem cacheExploredCells;
|
|
|
|
std::pair<Vec2i, int> cacheExploredCellsKey;
|
|
|
|
|
2013-02-12 09:44:12 +01:00
|
|
|
Vec2i lastHarvestedResourcePos;
|
|
|
|
|
2013-09-18 01:52:27 +02:00
|
|
|
string networkCRCLogInfo;
|
2013-09-23 19:16:34 +02:00
|
|
|
string networkCRCParticleLogInfo;
|
|
|
|
vector<string> networkCRCDecHpList;
|
2013-10-19 23:12:08 +02:00
|
|
|
vector<string> networkCRCParticleInfoList;
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
public:
|
|
|
|
Unit(int id, UnitPathInterface *path, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing);
|
2012-09-22 22:13:57 +02:00
|
|
|
virtual ~Unit();
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2011-09-25 06:07:59 +02:00
|
|
|
//static bool isUnitDeleted(void *unit);
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
static void setGame(Game *value) { game=value;}
|
|
|
|
|
2012-05-12 03:06:55 +02:00
|
|
|
inline int getPathFindRefreshCellCount() const { return pathFindRefreshCellCount; }
|
|
|
|
|
2012-05-04 16:57:59 +02:00
|
|
|
void setCurrentPathFinderDesiredFinalPos(const Vec2i &finalPos) { currentPathFinderDesiredFinalPos = finalPos; }
|
|
|
|
Vec2i getCurrentPathFinderDesiredFinalPos() const { return currentPathFinderDesiredFinalPos; }
|
|
|
|
|
2011-06-25 22:44:46 +02:00
|
|
|
const UnitAttackBoostEffectOriginator & getAttackBoostOriginatorEffect() const { return currentAttackBoostOriginatorEffect; }
|
|
|
|
bool unitHasAttackBoost(const AttackBoost *boost, const Unit *source) const;
|
2011-06-25 16:18:53 +02:00
|
|
|
|
2012-04-29 06:45:51 +02:00
|
|
|
inline uint32 getPathfindFailedConsecutiveFrameCount() const { return pathfindFailedConsecutiveFrameCount; }
|
|
|
|
inline void incrementPathfindFailedConsecutiveFrameCount() { pathfindFailedConsecutiveFrameCount++; }
|
|
|
|
inline void resetPathfindFailedConsecutiveFrameCount() { pathfindFailedConsecutiveFrameCount=0; }
|
|
|
|
|
2013-01-04 19:00:51 +01:00
|
|
|
const FowAlphaCellsLookupItem & getCachedFow() const { return cachedFow; }
|
|
|
|
FowAlphaCellsLookupItem getFogOfWarRadius(bool useCache) const;
|
|
|
|
void calculateFogOfWarRadius();
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
//queries
|
2011-07-05 17:43:39 +02:00
|
|
|
Command *getCurrrentCommandThreadSafe();
|
2011-01-29 13:42:18 +01:00
|
|
|
void setIgnoreCheckCommand(bool value) { ignoreCheckCommand=value;}
|
2012-04-17 17:25:31 +02:00
|
|
|
inline bool getIgnoreCheckCommand() const {return ignoreCheckCommand;}
|
|
|
|
inline int getId() const {return id;}
|
|
|
|
inline Field getCurrField() const {return currField;}
|
|
|
|
inline int getLoadCount() const {return loadCount;}
|
2013-05-31 09:09:25 +02:00
|
|
|
|
|
|
|
//inline int getLastAnimProgress() const {return lastAnimProgress;}
|
|
|
|
//inline int getAnimProgress() const {return animProgress;}
|
2013-10-03 02:17:51 +02:00
|
|
|
inline float getLastAnimProgressAsFloat() const {return static_cast<float>(lastAnimProgress) / ANIMATION_SPEED_MULTIPLIER;}
|
|
|
|
inline float getAnimProgressAsFloat() const {return static_cast<float>(animProgress) / ANIMATION_SPEED_MULTIPLIER;}
|
2013-05-31 09:09:25 +02:00
|
|
|
|
2013-10-02 22:22:10 +02:00
|
|
|
inline float getHightlight() const {return highlight;}
|
2012-04-17 17:25:31 +02:00
|
|
|
inline int getProgress2() const {return progress2;}
|
2012-04-21 05:42:25 +02:00
|
|
|
inline int getFactionIndex() const {
|
|
|
|
return faction->getIndex();
|
|
|
|
}
|
|
|
|
inline int getTeam() const {
|
|
|
|
return faction->getTeam();
|
|
|
|
}
|
2012-04-17 17:25:31 +02:00
|
|
|
inline int getHp() const {return hp;}
|
|
|
|
inline int getEp() const {return ep;}
|
2011-01-20 16:56:30 +01:00
|
|
|
int getProductionPercent() const;
|
2013-10-03 02:17:51 +02:00
|
|
|
float getProgressRatio() const;
|
|
|
|
float getHpRatio() const;
|
|
|
|
float getEpRatio() const;
|
2012-04-17 17:25:31 +02:00
|
|
|
inline bool getToBeUndertaken() const {return toBeUndertaken;}
|
|
|
|
inline Vec2i getTargetPos() const {return targetPos;}
|
2013-10-02 22:22:10 +02:00
|
|
|
inline Vec3f getTargetVec() const {return targetVec;}
|
2012-04-17 17:25:31 +02:00
|
|
|
inline Field getTargetField() const {return targetField;}
|
|
|
|
inline Vec2i getMeetingPos() const {return meetingPos;}
|
|
|
|
inline Faction *getFaction() const {return faction;}
|
|
|
|
inline const ResourceType *getLoadType() const {return loadType;}
|
2013-11-11 09:28:15 +01:00
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline const UnitType *getType() const {return type;}
|
2013-11-11 09:28:15 +01:00
|
|
|
void setType(const UnitType *newType);
|
2013-05-26 00:44:39 +02:00
|
|
|
inline const UnitType *getPreMorphType() const {return preMorph_type;}
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline const SkillType *getCurrSkill() const {return currSkill;}
|
|
|
|
inline const TotalUpgrade *getTotalUpgrade() const {return &totalUpgrade;}
|
2013-10-02 22:22:10 +02:00
|
|
|
inline float getRotation() const {return rotation;}
|
|
|
|
float getRotationX() const;
|
|
|
|
float getRotationZ() const;
|
2013-02-09 07:57:05 +01:00
|
|
|
ParticleSystem *getFire() const;
|
2012-04-17 17:25:31 +02:00
|
|
|
inline int getKills() const {return kills;}
|
|
|
|
inline int getEnemyKills() const {return enemyKills;}
|
|
|
|
inline const Level *getLevel() const {return level;}
|
2011-01-20 16:56:30 +01:00
|
|
|
const Level *getNextLevel() const;
|
2013-06-13 10:55:48 +02:00
|
|
|
string getFullName(bool translatedValue) const;
|
2012-04-17 17:25:31 +02:00
|
|
|
inline const UnitPathInterface *getPath() const {return unitPath;}
|
|
|
|
inline UnitPathInterface *getPath() {return unitPath;}
|
|
|
|
inline WaypointPath *getWaypointPath() {return &waypointPath;}
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline int getLastAttackerUnitId() const { return lastAttackerUnitId; }
|
|
|
|
inline void setLastAttackerUnitId(int unitId) { lastAttackerUnitId = unitId; }
|
2011-11-16 22:38:12 +01:00
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline int getLastAttackedUnitId() const { return lastAttackedUnitId; }
|
|
|
|
inline void setLastAttackedUnitId(int unitId) { lastAttackedUnitId = unitId; }
|
2011-11-16 22:38:12 +01:00
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline CauseOfDeathType getCauseOfDeath() const { return causeOfDeath; }
|
|
|
|
inline void setCauseOfDeath(CauseOfDeathType cause) { causeOfDeath = cause; }
|
2011-11-16 22:38:12 +01:00
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
//pos
|
2013-02-04 09:30:43 +01:00
|
|
|
inline Vec2i getPosNotThreadSafe() const {return pos;}
|
|
|
|
Vec2i getPos();
|
2011-05-01 07:36:04 +02:00
|
|
|
Vec2i getPosWithCellMapSet() const;
|
2012-04-17 17:25:31 +02:00
|
|
|
inline Vec2i getLastPos() const {return lastPos;}
|
2011-01-20 16:56:30 +01:00
|
|
|
Vec2i getCenteredPos() const;
|
2013-10-02 22:22:10 +02:00
|
|
|
Vec2f getFloatCenteredPos() const;
|
2011-01-20 16:56:30 +01:00
|
|
|
Vec2i getCellPos() const;
|
|
|
|
|
|
|
|
//is
|
2012-04-17 17:25:31 +02:00
|
|
|
inline bool isHighlighted() const {return highlight>0.f;}
|
|
|
|
inline bool isDead() const {return !alive;}
|
|
|
|
inline bool isAlive() const {return alive;}
|
2011-01-20 16:56:30 +01:00
|
|
|
bool isOperative() const;
|
|
|
|
bool isBeingBuilt() const;
|
|
|
|
bool isBuilt() const;
|
2012-06-22 06:58:44 +02:00
|
|
|
bool isBuildCommandPending() const;
|
2012-06-22 15:30:15 +02:00
|
|
|
UnitBuildInfo getBuildCommandPendingInfo() const;
|
2012-06-22 06:58:44 +02:00
|
|
|
|
2011-07-08 01:02:46 +02:00
|
|
|
bool isAnimProgressBound() const;
|
2012-05-04 23:03:52 +02:00
|
|
|
bool isPutrefacting() const {
|
|
|
|
return deadCount!=0;
|
|
|
|
}
|
2011-01-20 16:56:30 +01:00
|
|
|
bool isAlly(const Unit *unit) const;
|
|
|
|
bool isDamaged() const;
|
|
|
|
bool isInteresting(InterestingUnitType iut) const;
|
|
|
|
|
|
|
|
//set
|
2013-05-28 02:59:44 +02:00
|
|
|
void setCurrField(Field currField);
|
2011-01-20 16:56:30 +01:00
|
|
|
void setCurrSkill(const SkillType *currSkill);
|
|
|
|
void setCurrSkill(SkillClass sc);
|
2012-09-22 01:45:59 +02:00
|
|
|
|
|
|
|
void setMorphFieldsBlocked ( bool value ) {this->morphFieldsBlocked=value;}
|
|
|
|
bool getMorphFieldsBlocked() const { return morphFieldsBlocked; }
|
|
|
|
|
2013-02-12 09:44:12 +01:00
|
|
|
inline void setLastHarvestedResourcePos(Vec2i pos) { this->lastHarvestedResourcePos = pos; }
|
|
|
|
inline Vec2i getLastHarvestedResourcePos() const { return this->lastHarvestedResourcePos; }
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline void setLoadCount(int loadCount) {this->loadCount= loadCount;}
|
|
|
|
inline void setLoadType(const ResourceType *loadType) {this->loadType= loadType;}
|
|
|
|
inline void setProgress2(int progress2) {this->progress2= progress2;}
|
2012-04-11 07:41:40 +02:00
|
|
|
void setPos(const Vec2i &pos,bool clearPathFinder=false);
|
2013-03-06 16:02:17 +01:00
|
|
|
void refreshPos();
|
2011-01-20 16:56:30 +01:00
|
|
|
void setTargetPos(const Vec2i &targetPos);
|
|
|
|
void setTarget(const Unit *unit);
|
2013-10-02 22:22:10 +02:00
|
|
|
void setTargetVec(const Vec3f &targetVec);
|
2011-01-20 16:56:30 +01:00
|
|
|
void setMeetingPos(const Vec2i &meetingPos);
|
|
|
|
void setVisible(const bool visible);
|
2012-04-17 17:25:31 +02:00
|
|
|
inline bool getVisible() const { return visible; }
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//render related
|
2011-06-25 09:31:01 +02:00
|
|
|
const Model *getCurrentModel();
|
|
|
|
Model *getCurrentModelPtr();
|
2013-10-02 22:22:10 +02:00
|
|
|
Vec3f getCurrVector() const;
|
|
|
|
Vec3f getCurrVectorFlat() const;
|
|
|
|
Vec3f getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const;
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//command related
|
|
|
|
bool anyCommand(bool validateCommandtype=false) const;
|
2012-04-21 05:42:25 +02:00
|
|
|
inline Command *getCurrCommand() const {
|
|
|
|
if(commands.empty() == false) {
|
|
|
|
return commands.front();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-01-20 16:56:30 +01:00
|
|
|
void replaceCurrCommand(Command *cmd);
|
|
|
|
int getCountOfProducedUnits(const UnitType *ut) const;
|
|
|
|
unsigned int getCommandSize() const;
|
2012-11-10 20:39:55 +01:00
|
|
|
std::pair<CommandResult,string> giveCommand(Command *command, bool tryQueue = false); //give a command
|
2011-01-20 16:56:30 +01:00
|
|
|
CommandResult finishCommand(); //command finished
|
|
|
|
CommandResult cancelCommand(); //cancel canceled
|
|
|
|
|
|
|
|
//lifecycle
|
|
|
|
void create(bool startingUnit= false);
|
2012-03-27 05:23:03 +02:00
|
|
|
void born(const CommandType *ct);
|
2011-01-20 16:56:30 +01:00
|
|
|
void kill();
|
|
|
|
void undertake();
|
|
|
|
|
|
|
|
//observers
|
|
|
|
void addObserver(UnitObserver *unitObserver) ;
|
|
|
|
void removeObserver(UnitObserver *unitObserver);
|
|
|
|
void notifyObservers(UnitObserver::Event event);
|
|
|
|
|
|
|
|
//other
|
|
|
|
void resetHighlight();
|
|
|
|
const CommandType *computeCommandType(const Vec2i &pos, const Unit *targetUnit= NULL) const;
|
2013-06-13 10:55:48 +02:00
|
|
|
string getDesc(bool translatedValue) const;
|
|
|
|
string getDescExtension(bool translatedValue) const;
|
2011-01-20 16:56:30 +01:00
|
|
|
bool computeEp();
|
2011-11-16 22:38:12 +01:00
|
|
|
//bool computeHp();
|
2011-01-20 16:56:30 +01:00
|
|
|
bool repair();
|
|
|
|
bool decHp(int i);
|
|
|
|
int update2();
|
|
|
|
bool update();
|
|
|
|
void tick();
|
2012-06-04 23:53:20 +02:00
|
|
|
RandomGen* getRandom() { return &random; }
|
2011-06-25 10:53:53 +02:00
|
|
|
|
2011-06-25 22:44:46 +02:00
|
|
|
bool applyAttackBoost(const AttackBoost *boost, const Unit *source);
|
2011-06-25 10:53:53 +02:00
|
|
|
void deapplyAttackBoost(const AttackBoost *boost, const Unit *source);
|
|
|
|
|
2011-01-20 16:56:30 +01:00
|
|
|
void applyUpgrade(const UpgradeType *upgradeType);
|
|
|
|
void computeTotalUpgrade();
|
2011-04-20 18:46:47 +02:00
|
|
|
void incKills(int team);
|
2011-01-20 16:56:30 +01:00
|
|
|
bool morph(const MorphCommandType *mct);
|
2012-11-10 20:39:55 +01:00
|
|
|
std::pair<CommandResult,string> checkCommand(Command *command) const;
|
2011-01-20 16:56:30 +01:00
|
|
|
void applyCommand(Command *command);
|
|
|
|
|
|
|
|
void setModelFacing(CardinalDir value);
|
2012-04-17 17:25:31 +02:00
|
|
|
inline CardinalDir getModelFacing() const { return modelFacing; }
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
bool isMeetingPointSettable() const;
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline int getLastRenderFrame() const { return lastRenderFrame; }
|
|
|
|
inline void setLastRenderFrame(int value) { lastRenderFrame = value; }
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline int getRetryCurrCommandCount() const { return retryCurrCommandCount; }
|
|
|
|
inline void setRetryCurrCommandCount(int value) { retryCurrCommandCount = value; }
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline Vec3f getScreenPos() const { return screenPos; }
|
2011-01-20 16:56:30 +01:00
|
|
|
void setScreenPos(Vec3f value) { screenPos = value; }
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline string getCurrentUnitTitle() const {return currentUnitTitle;}
|
2011-01-20 16:56:30 +01:00
|
|
|
void setCurrentUnitTitle(string value) { currentUnitTitle = value;}
|
|
|
|
|
|
|
|
void exploreCells();
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline bool getInBailOutAttempt() const { return inBailOutAttempt; }
|
|
|
|
inline void setInBailOutAttempt(bool value) { inBailOutAttempt = value; }
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
//std::vector<std::pair<Vec2i,Chrono> > getBadHarvestPosList() const { return badHarvestPosList; }
|
|
|
|
//void setBadHarvestPosList(std::vector<std::pair<Vec2i,Chrono> > value) { badHarvestPosList = value; }
|
|
|
|
void addBadHarvestPos(const Vec2i &value);
|
|
|
|
void removeBadHarvestPos(const Vec2i &value);
|
2012-04-21 05:42:25 +02:00
|
|
|
inline bool isBadHarvestPos(const Vec2i &value,bool checkPeerUnits=true) const {
|
|
|
|
bool result = false;
|
|
|
|
if(badHarvestPosList.empty() == true) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::map<Vec2i,int>::const_iterator iter = badHarvestPosList.find(value);
|
|
|
|
if(iter != badHarvestPosList.end()) {
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
else if(checkPeerUnits == true) {
|
|
|
|
// Check if any other units of similar type have this position tagged
|
|
|
|
// as bad?
|
|
|
|
for(int i = 0; i < this->getFaction()->getUnitCount(); ++i) {
|
|
|
|
Unit *peerUnit = this->getFaction()->getUnit(i);
|
|
|
|
if( peerUnit != NULL && peerUnit->getId() != this->getId() &&
|
|
|
|
peerUnit->getType()->hasCommandClass(ccHarvest) == true &&
|
|
|
|
peerUnit->getType()->getSize() <= this->getType()->getSize()) {
|
|
|
|
if(peerUnit->isBadHarvestPos(value,false) == true) {
|
|
|
|
result = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2011-01-20 16:56:30 +01:00
|
|
|
void cleanupOldBadHarvestPos();
|
|
|
|
|
|
|
|
void setLastHarvestResourceTarget(const Vec2i *pos);
|
2012-04-17 17:25:31 +02:00
|
|
|
inline std::pair<Vec2i,int> getLastHarvestResourceTarget() const { return lastHarvestResourceTarget;}
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2011-03-29 18:27:01 +02:00
|
|
|
//std::pair<Vec2i,std::vector<Vec2i> > getCurrentTargetPathTaken() const { return currentTargetPathTaken; }
|
|
|
|
//void addCurrentTargetPathTakenCell(const Vec2i &target,const Vec2i &cell);
|
2011-01-20 16:56:30 +01:00
|
|
|
|
|
|
|
void logSynchData(string file,int line,string source="");
|
2013-05-21 07:43:57 +02:00
|
|
|
void logSynchDataThreaded(string file,int line,string source="");
|
|
|
|
|
2013-09-17 02:43:14 +02:00
|
|
|
std::string toString(bool crcMode=false) const;
|
2011-03-18 04:53:06 +01:00
|
|
|
bool needToUpdate();
|
2013-10-03 02:17:51 +02:00
|
|
|
float getProgressAsFloat() const;
|
2013-06-03 16:30:52 +02:00
|
|
|
int64 getUpdateProgress();
|
|
|
|
int64 getDiagonalFactor();
|
2013-09-18 02:46:30 +02:00
|
|
|
int64 getHeightFactor(int64 speedMultiplier=PROGRESS_SPEED_MULTIPLIER);
|
2013-06-03 16:30:52 +02:00
|
|
|
int64 getSpeedDenominator(int64 updateFPS);
|
2013-05-24 06:06:30 +02:00
|
|
|
bool isChangedActiveCommand() const { return changedActiveCommand; }
|
2011-01-20 16:56:30 +01:00
|
|
|
|
2013-09-23 19:16:34 +02:00
|
|
|
bool isLastStuckFrameWithinCurrentFrameTolerance(bool evalMode);
|
2012-04-17 17:25:31 +02:00
|
|
|
inline uint32 getLastStuckFrame() const { return lastStuckFrame; }
|
2013-10-17 08:36:28 +02:00
|
|
|
//inline void setLastStuckFrame(uint32 value) { lastStuckFrame = value; }
|
2011-04-04 06:32:01 +02:00
|
|
|
void setLastStuckFrameToCurrentFrame();
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline Vec2i getLastStuckPos() const { return lastStuckPos; }
|
|
|
|
inline void setLastStuckPos(Vec2i pos) { lastStuckPos = pos; }
|
2011-04-04 06:32:01 +02:00
|
|
|
|
2011-04-14 04:51:13 +02:00
|
|
|
bool isLastPathfindFailedFrameWithinCurrentFrameTolerance() const;
|
2012-04-17 17:25:31 +02:00
|
|
|
inline uint32 getLastPathfindFailedFrame() const { return lastPathfindFailedFrame; }
|
|
|
|
inline void setLastPathfindFailedFrame(uint32 value) { lastPathfindFailedFrame = value; }
|
2011-04-14 04:51:13 +02:00
|
|
|
void setLastPathfindFailedFrameToCurrentFrame();
|
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline Vec2i getLastPathfindFailedPos() const { return lastPathfindFailedPos; }
|
|
|
|
inline void setLastPathfindFailedPos(Vec2i pos) { lastPathfindFailedPos = pos; }
|
2011-04-14 04:51:13 +02:00
|
|
|
|
2012-04-17 17:25:31 +02:00
|
|
|
inline bool getUsePathfinderExtendedMaxNodes() const { return usePathfinderExtendedMaxNodes; }
|
|
|
|
inline void setUsePathfinderExtendedMaxNodes(bool value) { usePathfinderExtendedMaxNodes = value; }
|
2011-04-14 04:51:13 +02:00
|
|
|
|
2011-08-27 08:52:17 +02:00
|
|
|
void updateTimedParticles();
|
2011-12-13 02:30:52 +01:00
|
|
|
|
|
|
|
virtual string getUniquePickName() const;
|
2012-03-10 04:27:25 +01:00
|
|
|
void saveGame(XmlNode *rootNode);
|
2012-03-13 00:08:22 +01:00
|
|
|
static Unit * loadGame(const XmlNode *rootNode,GameSettings *settings,Faction *faction, World *world);
|
2012-03-10 04:27:25 +01:00
|
|
|
|
2013-02-17 08:15:01 +01:00
|
|
|
void clearCaches();
|
2013-06-13 10:55:48 +02:00
|
|
|
bool showTranslatedTechTree() const;
|
2013-02-17 08:15:01 +01:00
|
|
|
|
2013-09-19 22:03:36 +02:00
|
|
|
void addAttackParticleSystem(ParticleSystem *ps);
|
|
|
|
|
2013-09-12 05:33:43 +02:00
|
|
|
Checksum getCRC();
|
|
|
|
|
2013-09-23 19:16:34 +02:00
|
|
|
virtual void end(ParticleSystem *particleSystem);
|
2013-10-19 23:12:08 +02:00
|
|
|
virtual void logParticleInfo(string info);
|
2013-10-20 22:06:19 +02:00
|
|
|
void setNetworkCRCParticleLogInfo(string networkCRCParticleLogInfo) { this->networkCRCParticleLogInfo = networkCRCParticleLogInfo; }
|
|
|
|
void clearParticleInfo();
|
|
|
|
void addNetworkCRCDecHp(string info);
|
|
|
|
void clearNetworkCRCDecHpList();
|
2013-10-06 08:59:15 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2013-10-20 22:06:19 +02:00
|
|
|
bool isNetworkCRCEnabled();
|
2013-09-23 19:16:34 +02:00
|
|
|
string getNetworkCRCDecHpList() const;
|
2013-10-20 22:06:19 +02:00
|
|
|
string getParticleInfo() const;
|
2013-09-23 19:16:34 +02:00
|
|
|
|
2013-10-02 22:22:10 +02:00
|
|
|
float computeHeight(const Vec2i &pos) const;
|
2011-07-12 01:59:16 +02:00
|
|
|
void calculateXZRotation();
|
2011-01-20 16:56:30 +01:00
|
|
|
void updateTarget();
|
|
|
|
void clearCommands();
|
|
|
|
void deleteQueuedCommand(Command *command);
|
|
|
|
CommandResult undoCommand(Command *command);
|
2011-07-01 23:47:54 +02:00
|
|
|
void stopDamageParticles(bool force);
|
2011-01-20 16:56:30 +01:00
|
|
|
void startDamageParticles();
|
|
|
|
|
2013-10-17 08:36:28 +02:00
|
|
|
uint32 getFrameCount() const;
|
2011-07-01 23:47:54 +02:00
|
|
|
void checkCustomizedParticleTriggers(bool force);
|
2012-03-24 19:30:49 +01:00
|
|
|
bool checkModelStateInfoForNewHpValue();
|
2012-03-25 22:38:05 +02:00
|
|
|
void checkUnitLevel();
|
2012-11-22 02:52:01 +01:00
|
|
|
|
|
|
|
void morphAttackBoosts(Unit *unit);
|
2013-05-21 07:43:57 +02:00
|
|
|
|
2013-06-03 16:30:52 +02:00
|
|
|
int64 getUpdatedProgress(int64 currentProgress, int64 updateFPS, int64 speed, int64 diagonalFactor, int64 heightFactor);
|
2013-05-24 06:06:30 +02:00
|
|
|
|
2013-05-21 07:43:57 +02:00
|
|
|
void logSynchDataCommon(string file,int line,string source="",bool threadedMode=false);
|
2013-06-02 00:21:04 +02:00
|
|
|
void updateAttackBoostProgress(const Game* game);
|
2013-11-11 09:28:15 +01:00
|
|
|
|
|
|
|
void setAlive(bool value);
|
2011-01-20 16:56:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}}// end namespace
|
|
|
|
|
|
|
|
#endif
|