2009-04-18 19:00:33 +02:00
|
|
|
/* Copyright (C) 2009 Wildfire Games.
|
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it 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.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2006-04-24 01:14:18 +02:00
|
|
|
//This class loads all the formation data needs to create an instance of a particular formation.
|
|
|
|
|
2007-05-07 18:33:24 +02:00
|
|
|
#ifndef INCLUDED_FORMATION
|
|
|
|
#define INCLUDED_FORMATION
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "ps/XML/Xeromyces.h"
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
class CStr;
|
|
|
|
|
2006-06-10 01:07:11 +02:00
|
|
|
class CFormation
|
2006-04-24 01:14:18 +02:00
|
|
|
{
|
2008-10-13 23:06:15 +02:00
|
|
|
friend class CFormationManager;
|
|
|
|
friend class CFormationCollection;
|
|
|
|
friend class CEntityFormation;
|
|
|
|
|
|
|
|
struct FormationSlot
|
|
|
|
{
|
|
|
|
float fileOff; //Distance between files of this slot and the formation's center
|
|
|
|
float rankOff;
|
|
|
|
std::vector<CStr> category;
|
|
|
|
};
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
public:
|
2006-06-10 01:07:11 +02:00
|
|
|
CFormation();
|
|
|
|
~CFormation(){}
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2006-07-20 16:37:58 +02:00
|
|
|
const CStr& GetBonus(){ return m_bonus; }
|
|
|
|
const CStr& GetBonusBase(){ return m_bonusBase; }
|
|
|
|
const CStr& GetBonusType(){ return m_bonusType; }
|
2006-04-24 01:14:18 +02:00
|
|
|
float GetBonusVal(){ return m_bonusVal; }
|
|
|
|
|
2006-07-20 16:37:58 +02:00
|
|
|
const CStr& GetPenalty(){ return m_penalty; }
|
|
|
|
const CStr& GetPenaltyBase(){ return m_penaltyBase; }
|
|
|
|
const CStr& GetPenaltyType(){ return m_penaltyType; }
|
2006-04-24 01:14:18 +02:00
|
|
|
float GetPenaltyVal(){ return m_penaltyVal; }
|
|
|
|
|
2006-07-20 16:37:58 +02:00
|
|
|
const CStr& GetAnglePenalty(){ return m_anglePenalty; }
|
|
|
|
const CStr& GetAnglePenaltyType(){ return m_anglePenaltyType; }
|
2006-04-24 01:14:18 +02:00
|
|
|
int GetAnglePenaltyDivs(){ return m_anglePenaltyDivs; }
|
|
|
|
float GetAnglePenaltyVal(){ return m_anglePenaltyVal; }
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
CStr m_tag;
|
|
|
|
CStr m_bonus;
|
2006-05-04 06:14:48 +02:00
|
|
|
CStr m_bonusBase;
|
2006-04-24 01:14:18 +02:00
|
|
|
CStr m_bonusType;
|
|
|
|
float m_bonusVal;
|
|
|
|
|
|
|
|
CStr m_penalty;
|
2006-05-04 06:14:48 +02:00
|
|
|
CStr m_penaltyBase;
|
2006-04-24 01:14:18 +02:00
|
|
|
CStr m_penaltyType;
|
|
|
|
float m_penaltyVal;
|
|
|
|
|
|
|
|
CStr m_anglePenalty;
|
|
|
|
int m_anglePenaltyDivs;
|
|
|
|
CStr m_anglePenaltyType;
|
|
|
|
float m_anglePenaltyVal;
|
|
|
|
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
size_t m_required;
|
2006-04-24 01:14:18 +02:00
|
|
|
CStr m_next;
|
|
|
|
CStr m_prior;
|
|
|
|
CStr m_movement;
|
|
|
|
float m_fileSpacing;
|
|
|
|
float m_rankSpacing;
|
|
|
|
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
size_t m_numSlots; //how many possible slots in this formation
|
|
|
|
size_t m_numRanks;
|
|
|
|
size_t m_numFiles;
|
2006-04-24 01:14:18 +02:00
|
|
|
|
|
|
|
//The key is the "order" of the slot
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 20:48:32 +02:00
|
|
|
std::map<size_t, FormationSlot> m_slots;
|
2006-04-24 01:14:18 +02:00
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
bool LoadXml(const CStr& filename);
|
2008-07-17 19:00:00 +02:00
|
|
|
void AssignCategory(size_t order, const CStr& category); //takes care of formatting strings
|
2006-04-24 01:14:18 +02:00
|
|
|
};
|
|
|
|
#endif
|