forked from 0ad/0ad
# SwEng
. the massive renaming undertaking: camelCase functions -> PascalCase. . add some cppdoc. . minor additional renaming improvements: e.g. GetIsClosed -> IsClosed . in entity code, replace constructs like "pvec = new vector; return pvec; use *pvec; delete pvec" with a simple stack variable passed as output parameter (avoid unnecessary dynamic allocs) . timer: simpler handling of raw ticks vs normal timer (less #if) This was SVN commit r5017.
This commit is contained in:
parent
b86ea0a1b5
commit
73683b6109
@ -21,7 +21,7 @@ typedef CVector4D RGBAColor;
|
||||
// one of several implementations depending on CPU caps.
|
||||
extern u32 (*ConvertRGBColorTo4ub)(const RGBColor& src);
|
||||
|
||||
// call once ia32_init has run; detects CPU caps and activates the best
|
||||
// call once ia32_Init has run; detects CPU caps and activates the best
|
||||
// possible codepath.
|
||||
extern void ColorActivateFastImpl();
|
||||
|
||||
|
@ -12,18 +12,19 @@
|
||||
|
||||
CDefaultEmitter::CDefaultEmitter(const int MAX_PARTICLES, const int lifetime) : CEmitter(MAX_PARTICLES, lifetime)
|
||||
{
|
||||
setupEmitter();
|
||||
Setup();
|
||||
}
|
||||
|
||||
CDefaultEmitter::~CDefaultEmitter(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool CDefaultEmitter::setupEmitter()
|
||||
bool CDefaultEmitter::Setup()
|
||||
{
|
||||
pos.x = 0.0f; // XYZ Position
|
||||
pos.y = 20.0f; // XYZ Position
|
||||
pos.z = 0.0f; // XYZ Position
|
||||
// XYZ Position
|
||||
pos.X = 0.0f;
|
||||
pos.Y = 20.0f;
|
||||
pos.Z = 0.0f;
|
||||
|
||||
yaw = DEGTORAD(0.0f);
|
||||
yawVar = DEGTORAD(360.0f);
|
||||
@ -51,13 +52,13 @@ bool CDefaultEmitter::setupEmitter()
|
||||
endColorVar.g = 15;
|
||||
endColorVar.b = 15;
|
||||
|
||||
force.x = 0.000f;
|
||||
force.y = -0.001f;
|
||||
force.z = 0.0f;
|
||||
force.X = 0.000f;
|
||||
force.Y = -0.001f;
|
||||
force.Z = 0.0f;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDefaultEmitter::updateEmitter()
|
||||
bool CDefaultEmitter::Update()
|
||||
{
|
||||
int emits;
|
||||
// walk through the used list, and update each of the particles
|
||||
@ -70,14 +71,14 @@ bool CDefaultEmitter::updateEmitter()
|
||||
{
|
||||
// update the particle
|
||||
// Calculate the new pos
|
||||
tempParticle->pos.x += tempParticle->dir.x;
|
||||
tempParticle->pos.y += tempParticle->dir.y;
|
||||
tempParticle->pos.z += tempParticle->dir.z;
|
||||
tempParticle->pos.X += tempParticle->dir.X;
|
||||
tempParticle->pos.Y += tempParticle->dir.Y;
|
||||
tempParticle->pos.Z += tempParticle->dir.Z;
|
||||
|
||||
// Add global force to direction
|
||||
tempParticle->dir.x += force.x;
|
||||
tempParticle->dir.y += force.y;
|
||||
tempParticle->dir.z += force.z;
|
||||
tempParticle->dir.X += force.X;
|
||||
tempParticle->dir.Y += force.Y;
|
||||
tempParticle->dir.Z += force.Z;
|
||||
|
||||
// Get the new color
|
||||
tempParticle->color.r += tempParticle->deltaColor.r;
|
||||
@ -139,7 +140,7 @@ bool CDefaultEmitter::updateEmitter()
|
||||
emitterLife--;
|
||||
|
||||
for(int i = 0; i < emits; i++)
|
||||
addParticle();
|
||||
AddParticle();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -14,25 +14,12 @@ class CDefaultEmitter : public CEmitter
|
||||
{
|
||||
public:
|
||||
CDefaultEmitter(const int MAX_PARTICLES = 4000, const int lifetime = -1);
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: setupEmitter
|
||||
//Date: 7/19/05
|
||||
//Author: Will Dull
|
||||
//Notes: Sets up emitter to the default particle
|
||||
// effect.
|
||||
//////////////////////////////////////////////////////////////
|
||||
virtual bool setupEmitter();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: updateEmitter
|
||||
//Date: 7/19/05
|
||||
//Author: Will Dull
|
||||
//Notes: Updates emitter.
|
||||
//////////////////////////////////////////////////////////////
|
||||
virtual bool updateEmitter();
|
||||
|
||||
virtual ~CDefaultEmitter(void);
|
||||
|
||||
// Sets up emitter to the default particle effect.
|
||||
virtual bool Setup();
|
||||
|
||||
virtual bool Update();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -188,9 +188,9 @@ CGameView::CGameView(CGame *pGame):
|
||||
|
||||
CGameView::~CGameView()
|
||||
{
|
||||
g_Selection.clearSelection();
|
||||
g_Mouseover.clear();
|
||||
g_BuildingPlacer.deactivate();
|
||||
g_Selection.ClearSelection();
|
||||
g_Mouseover.Clear();
|
||||
g_BuildingPlacer.Deactivate();
|
||||
UnloadResources();
|
||||
|
||||
delete m;
|
||||
@ -332,7 +332,7 @@ void CGameView::EnumerateObjects(const CFrustum& frustum, SceneCollector* c)
|
||||
const std::vector<CUnit*>& units = unitMan.GetUnits();
|
||||
for (uint i=0;i<units.size();++i)
|
||||
{
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
CEntity* ent = units[i]->GetEntity();
|
||||
if( ent && !ent->m_visible )
|
||||
@ -396,7 +396,7 @@ void CGameView::CameraLock(const CVector3D& Trans, bool smooth)
|
||||
void CGameView::CameraLock(float x, float y, float z, bool smooth)
|
||||
{
|
||||
CTerrain* pTerrain = m->Game->GetWorld()->GetTerrain();
|
||||
float height = pTerrain->getExactGroundLevel(
|
||||
float height = pTerrain->GetExactGroundLevel(
|
||||
m->ViewCamera.m_Orientation._14 + x, m->ViewCamera.m_Orientation._34 + z) +
|
||||
g_YMinOffset;
|
||||
//is requested position within limits?
|
||||
|
@ -60,7 +60,7 @@ void CMapReader::LoadMap(const char* filename, CTerrain *pTerrain_,
|
||||
}
|
||||
|
||||
// delete all existing entities
|
||||
g_EntityManager.deleteAll();
|
||||
g_EntityManager.DeleteAll();
|
||||
// delete all remaining non-entity units
|
||||
pUnitMan->DeleteAll();
|
||||
pUnitMan->SetNextID(0);
|
||||
@ -214,7 +214,7 @@ int CMapReader::ApplyData()
|
||||
if (unpacker.GetVersion() < 3)
|
||||
{
|
||||
debug_warn("Old unsupported map version - objects will be missing");
|
||||
// (getTemplateByActor doesn't work, since entity templates are now
|
||||
// (GetTemplateByActor doesn't work, since entity templates are now
|
||||
// loaded on demand)
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ int CMapReader::ApplyData()
|
||||
}
|
||||
}
|
||||
//Make units start out conforming correctly
|
||||
g_EntityManager.conformAll();
|
||||
g_EntityManager.ConformAll();
|
||||
|
||||
if (unpacker.GetVersion() >= 2)
|
||||
{
|
||||
@ -305,8 +305,8 @@ void CXMLReader::Init(const CStr& xml_filename)
|
||||
// so we don't need to do lots of string construction and comparison when
|
||||
// reading the data.
|
||||
// (Needs to be synchronised with the list in CXMLReader - ugh)
|
||||
#define EL(x) el_##x = xmb_file.getElementID(#x)
|
||||
#define AT(x) at_##x = xmb_file.getAttributeID(#x)
|
||||
#define EL(x) el_##x = xmb_file.GetElementID(#x)
|
||||
#define AT(x) at_##x = xmb_file.GetAttributeID(#x)
|
||||
EL(entity);
|
||||
EL(tracks);
|
||||
EL(template);
|
||||
@ -321,23 +321,23 @@ void CXMLReader::Init(const CStr& xml_filename)
|
||||
#undef AT
|
||||
#undef EL
|
||||
|
||||
XMBElement root = xmb_file.getRoot();
|
||||
debug_assert(xmb_file.getElementString(root.getNodeName()) == "Scenario");
|
||||
nodes = root.getChildNodes();
|
||||
XMBElement root = xmb_file.GetRoot();
|
||||
debug_assert(xmb_file.GetElementString(root.GetNodeName()) == "Scenario");
|
||||
nodes = root.GetChildNodes();
|
||||
|
||||
// find out total number of entities+nonentities
|
||||
// (used when calculating progress)
|
||||
completed_jobs = 0;
|
||||
total_jobs = 0;
|
||||
for (int i = 0; i < nodes.Count; i++)
|
||||
total_jobs += nodes.item(i).getChildNodes().Count;
|
||||
total_jobs += nodes.Item(i).GetChildNodes().Count;
|
||||
}
|
||||
|
||||
|
||||
void CXMLReader::ReadEnvironment(XMBElement parent)
|
||||
{
|
||||
#define EL(x) int el_##x = xmb_file.getElementID(#x)
|
||||
#define AT(x) int at_##x = xmb_file.getAttributeID(#x)
|
||||
#define EL(x) int el_##x = xmb_file.GetElementID(#x)
|
||||
#define AT(x) int at_##x = xmb_file.GetAttributeID(#x)
|
||||
EL(skyset);
|
||||
EL(suncolour);
|
||||
EL(sunelevation);
|
||||
@ -362,55 +362,55 @@ void CXMLReader::ReadEnvironment(XMBElement parent)
|
||||
|
||||
XERO_ITER_EL(parent, element)
|
||||
{
|
||||
int element_name = element.getNodeName();
|
||||
int element_name = element.GetNodeName();
|
||||
|
||||
XMBAttributeList attrs = element.getAttributes();
|
||||
XMBAttributeList attrs = element.GetAttributes();
|
||||
|
||||
if (element_name == el_skyset)
|
||||
{
|
||||
m_MapReader.pSkyMan->SetSkySet(element.getText());
|
||||
m_MapReader.pSkyMan->SetSkySet(element.GetText());
|
||||
}
|
||||
else if (element_name == el_suncolour)
|
||||
{
|
||||
m_MapReader.m_LightEnv.m_SunColor = RGBColor(
|
||||
CStr(attrs.getNamedItem(at_r)).ToFloat(),
|
||||
CStr(attrs.getNamedItem(at_g)).ToFloat(),
|
||||
CStr(attrs.getNamedItem(at_b)).ToFloat());
|
||||
CStr(attrs.GetNamedItem(at_r)).ToFloat(),
|
||||
CStr(attrs.GetNamedItem(at_g)).ToFloat(),
|
||||
CStr(attrs.GetNamedItem(at_b)).ToFloat());
|
||||
}
|
||||
else if (element_name == el_sunelevation)
|
||||
{
|
||||
m_MapReader.m_LightEnv.m_Elevation = CStr(attrs.getNamedItem(at_angle)).ToFloat();
|
||||
m_MapReader.m_LightEnv.m_Elevation = CStr(attrs.GetNamedItem(at_angle)).ToFloat();
|
||||
}
|
||||
else if (element_name == el_sunrotation)
|
||||
{
|
||||
m_MapReader.m_LightEnv.m_Rotation = CStr(attrs.getNamedItem(at_angle)).ToFloat();
|
||||
m_MapReader.m_LightEnv.m_Rotation = CStr(attrs.GetNamedItem(at_angle)).ToFloat();
|
||||
}
|
||||
else if (element_name == el_terrainambientcolour)
|
||||
{
|
||||
m_MapReader.m_LightEnv.m_TerrainAmbientColor = RGBColor(
|
||||
CStr(attrs.getNamedItem(at_r)).ToFloat(),
|
||||
CStr(attrs.getNamedItem(at_g)).ToFloat(),
|
||||
CStr(attrs.getNamedItem(at_b)).ToFloat());
|
||||
CStr(attrs.GetNamedItem(at_r)).ToFloat(),
|
||||
CStr(attrs.GetNamedItem(at_g)).ToFloat(),
|
||||
CStr(attrs.GetNamedItem(at_b)).ToFloat());
|
||||
}
|
||||
else if (element_name == el_unitsambientcolour)
|
||||
{
|
||||
m_MapReader.m_LightEnv.m_UnitsAmbientColor = RGBColor(
|
||||
CStr(attrs.getNamedItem(at_r)).ToFloat(),
|
||||
CStr(attrs.getNamedItem(at_g)).ToFloat(),
|
||||
CStr(attrs.getNamedItem(at_b)).ToFloat());
|
||||
CStr(attrs.GetNamedItem(at_r)).ToFloat(),
|
||||
CStr(attrs.GetNamedItem(at_g)).ToFloat(),
|
||||
CStr(attrs.GetNamedItem(at_b)).ToFloat());
|
||||
}
|
||||
else if (element_name == el_terrainshadowtransparency)
|
||||
{
|
||||
m_MapReader.m_LightEnv.SetTerrainShadowTransparency(CStr(element.getText()).ToFloat());
|
||||
m_MapReader.m_LightEnv.SetTerrainShadowTransparency(CStr(element.GetText()).ToFloat());
|
||||
}
|
||||
else if (element_name == el_water)
|
||||
{
|
||||
XERO_ITER_EL(element, waterbody)
|
||||
{
|
||||
debug_assert(waterbody.getNodeName() == el_waterbody);
|
||||
debug_assert(waterbody.GetNodeName() == el_waterbody);
|
||||
XERO_ITER_EL(waterbody, waterelement)
|
||||
{
|
||||
int element_name = waterelement.getNodeName();
|
||||
int element_name = waterelement.GetNodeName();
|
||||
if (element_name == el_type)
|
||||
{
|
||||
// TODO: implement this, when WaterManager supports it
|
||||
@ -419,18 +419,18 @@ void CXMLReader::ReadEnvironment(XMBElement parent)
|
||||
#define READ_COLOUR(el, out) \
|
||||
else if (element_name == el) \
|
||||
{ \
|
||||
XMBAttributeList attrs = waterelement.getAttributes(); \
|
||||
XMBAttributeList attrs = waterelement.GetAttributes(); \
|
||||
out = CColor( \
|
||||
CStr(attrs.getNamedItem(at_r)).ToFloat(), \
|
||||
CStr(attrs.getNamedItem(at_g)).ToFloat(), \
|
||||
CStr(attrs.getNamedItem(at_b)).ToFloat(), \
|
||||
CStr(attrs.GetNamedItem(at_r)).ToFloat(), \
|
||||
CStr(attrs.GetNamedItem(at_g)).ToFloat(), \
|
||||
CStr(attrs.GetNamedItem(at_b)).ToFloat(), \
|
||||
1.f); \
|
||||
}
|
||||
|
||||
#define READ_FLOAT(el, out) \
|
||||
else if (element_name == el) \
|
||||
{ \
|
||||
out = CStr(waterelement.getText()).ToFloat(); \
|
||||
out = CStr(waterelement.GetText()).ToFloat(); \
|
||||
} \
|
||||
|
||||
READ_COLOUR(el_colour, m_MapReader.pWaterMan->m_WaterColor)
|
||||
@ -460,8 +460,8 @@ void CXMLReader::ReadEnvironment(XMBElement parent)
|
||||
|
||||
void CXMLReader::ReadCamera(XMBElement parent)
|
||||
{
|
||||
#define EL(x) int el_##x = xmb_file.getElementID(#x)
|
||||
#define AT(x) int at_##x = xmb_file.getAttributeID(#x)
|
||||
#define EL(x) int el_##x = xmb_file.GetElementID(#x)
|
||||
#define AT(x) int at_##x = xmb_file.GetAttributeID(#x)
|
||||
EL(declination);
|
||||
EL(rotation);
|
||||
EL(position);
|
||||
@ -475,23 +475,23 @@ void CXMLReader::ReadCamera(XMBElement parent)
|
||||
|
||||
XERO_ITER_EL(parent, element)
|
||||
{
|
||||
int element_name = element.getNodeName();
|
||||
int element_name = element.GetNodeName();
|
||||
|
||||
XMBAttributeList attrs = element.getAttributes();
|
||||
XMBAttributeList attrs = element.GetAttributes();
|
||||
if (element_name == el_declination)
|
||||
{
|
||||
declination = CStr(attrs.getNamedItem(at_angle)).ToFloat();
|
||||
declination = CStr(attrs.GetNamedItem(at_angle)).ToFloat();
|
||||
}
|
||||
else if (element_name == el_rotation)
|
||||
{
|
||||
rotation = CStr(attrs.getNamedItem(at_angle)).ToFloat();
|
||||
rotation = CStr(attrs.GetNamedItem(at_angle)).ToFloat();
|
||||
}
|
||||
else if (element_name == el_position)
|
||||
{
|
||||
translation = CVector3D(
|
||||
CStr(attrs.getNamedItem(at_x)).ToFloat(),
|
||||
CStr(attrs.getNamedItem(at_y)).ToFloat(),
|
||||
CStr(attrs.getNamedItem(at_z)).ToFloat());
|
||||
CStr(attrs.GetNamedItem(at_x)).ToFloat(),
|
||||
CStr(attrs.GetNamedItem(at_y)).ToFloat(),
|
||||
CStr(attrs.GetNamedItem(at_z)).ToFloat());
|
||||
}
|
||||
else
|
||||
debug_warn("Invalid map XML data");
|
||||
@ -505,8 +505,8 @@ void CXMLReader::ReadCamera(XMBElement parent)
|
||||
|
||||
void CXMLReader::ReadCinema(XMBElement parent)
|
||||
{
|
||||
#define EL(x) int el_##x = xmb_file.getElementID(#x)
|
||||
#define AT(x) int at_##x = xmb_file.getAttributeID(#x)
|
||||
#define EL(x) int el_##x = xmb_file.GetElementID(#x)
|
||||
#define AT(x) int at_##x = xmb_file.GetAttributeID(#x)
|
||||
|
||||
EL(path);
|
||||
EL(rotation);
|
||||
@ -530,29 +530,29 @@ void CXMLReader::ReadCinema(XMBElement parent)
|
||||
std::map<CStrW, CCinemaPath> pathList;
|
||||
XERO_ITER_EL(parent, element)
|
||||
{
|
||||
int elementName = element.getNodeName();
|
||||
int elementName = element.GetNodeName();
|
||||
|
||||
if ( elementName == el_path )
|
||||
{
|
||||
XMBAttributeList attrs = element.getAttributes();
|
||||
CStrW name( CStr(attrs.getNamedItem(at_name)) );
|
||||
float timescale = CStr(attrs.getNamedItem(at_timescale)).ToFloat();
|
||||
XMBAttributeList attrs = element.GetAttributes();
|
||||
CStrW name( CStr(attrs.GetNamedItem(at_name)) );
|
||||
float timescale = CStr(attrs.GetNamedItem(at_timescale)).ToFloat();
|
||||
CCinemaData pathData;
|
||||
pathData.m_Timescale = timescale;
|
||||
TNSpline spline, backwardSpline;
|
||||
|
||||
XERO_ITER_EL(element, pathChild)
|
||||
{
|
||||
elementName = pathChild.getNodeName();
|
||||
attrs = pathChild.getAttributes();
|
||||
elementName = pathChild.GetNodeName();
|
||||
attrs = pathChild.GetAttributes();
|
||||
|
||||
//Load distortion attributes
|
||||
if ( elementName == el_distortion )
|
||||
{
|
||||
pathData.m_Mode = CStr(attrs.getNamedItem(at_mode)).ToInt();
|
||||
pathData.m_Style = CStr(attrs.getNamedItem(at_style)).ToInt();
|
||||
pathData.m_Growth = CStr(attrs.getNamedItem(at_growth)).ToInt();
|
||||
pathData.m_Switch = CStr(attrs.getNamedItem(at_switch)).ToInt();
|
||||
pathData.m_Mode = CStr(attrs.GetNamedItem(at_mode)).ToInt();
|
||||
pathData.m_Style = CStr(attrs.GetNamedItem(at_style)).ToInt();
|
||||
pathData.m_Growth = CStr(attrs.GetNamedItem(at_growth)).ToInt();
|
||||
pathData.m_Switch = CStr(attrs.GetNamedItem(at_switch)).ToInt();
|
||||
}
|
||||
|
||||
//Load node data used for spline
|
||||
@ -561,26 +561,26 @@ void CXMLReader::ReadCinema(XMBElement parent)
|
||||
SplineData data;
|
||||
XERO_ITER_EL(pathChild, nodeChild)
|
||||
{
|
||||
elementName = nodeChild.getNodeName();
|
||||
attrs = nodeChild.getAttributes();
|
||||
elementName = nodeChild.GetNodeName();
|
||||
attrs = nodeChild.GetAttributes();
|
||||
|
||||
//Fix?: assumes that time is last element
|
||||
if ( elementName == el_position )
|
||||
{
|
||||
data.Position.X = CStr(attrs.getNamedItem(at_x)).ToFloat();
|
||||
data.Position.Y = CStr(attrs.getNamedItem(at_y)).ToFloat();
|
||||
data.Position.Z = CStr(attrs.getNamedItem(at_z)).ToFloat();
|
||||
data.Position.X = CStr(attrs.GetNamedItem(at_x)).ToFloat();
|
||||
data.Position.Y = CStr(attrs.GetNamedItem(at_y)).ToFloat();
|
||||
data.Position.Z = CStr(attrs.GetNamedItem(at_z)).ToFloat();
|
||||
continue;
|
||||
}
|
||||
else if ( elementName == el_rotation )
|
||||
{
|
||||
data.Rotation.X = CStr(attrs.getNamedItem(at_x)).ToFloat();
|
||||
data.Rotation.Y = CStr(attrs.getNamedItem(at_y)).ToFloat();
|
||||
data.Rotation.Z = CStr(attrs.getNamedItem(at_z)).ToFloat();
|
||||
data.Rotation.X = CStr(attrs.GetNamedItem(at_x)).ToFloat();
|
||||
data.Rotation.Y = CStr(attrs.GetNamedItem(at_y)).ToFloat();
|
||||
data.Rotation.Z = CStr(attrs.GetNamedItem(at_z)).ToFloat();
|
||||
continue;
|
||||
}
|
||||
else if ( elementName == el_time )
|
||||
data.Distance = CStr( nodeChild.getText() ).ToFloat();
|
||||
data.Distance = CStr( nodeChild.GetText() ).ToFloat();
|
||||
else
|
||||
debug_warn("Invalid cinematic element for node child");
|
||||
|
||||
@ -626,8 +626,8 @@ void CXMLReader::ReadTriggers(XMBElement parent)
|
||||
|
||||
void CXMLReader::ReadTriggerGroup(XMBElement parent, MapTriggerGroup& group)
|
||||
{
|
||||
#define EL(x) int el_##x = xmb_file.getElementID(#x)
|
||||
#define AT(x) int at_##x = xmb_file.getAttributeID(#x)
|
||||
#define EL(x) int el_##x = xmb_file.GetElementID(#x)
|
||||
#define AT(x) int at_##x = xmb_file.GetAttributeID(#x)
|
||||
|
||||
EL(group);
|
||||
EL(trigger);
|
||||
@ -653,7 +653,7 @@ void CXMLReader::ReadTriggerGroup(XMBElement parent, MapTriggerGroup& group)
|
||||
#undef EL
|
||||
#undef AT
|
||||
|
||||
CStrW name = parent.getAttributes().getNamedItem(at_name), parentName = group.parentName;
|
||||
CStrW name = parent.GetAttributes().GetNamedItem(at_name), parentName = group.parentName;
|
||||
if ( group.name == L"Triggers" )
|
||||
name = group.name;
|
||||
|
||||
@ -661,63 +661,63 @@ void CXMLReader::ReadTriggerGroup(XMBElement parent, MapTriggerGroup& group)
|
||||
|
||||
XERO_ITER_EL(parent, groupChild)
|
||||
{
|
||||
int elementName = groupChild.getNodeName();
|
||||
int elementName = groupChild.GetNodeName();
|
||||
if ( elementName == el_group )
|
||||
ReadTriggerGroup(groupChild, mapGroup);
|
||||
|
||||
else if ( elementName == el_trigger )
|
||||
{
|
||||
MapTrigger mapTrigger;
|
||||
mapTrigger.name = CStrW( groupChild.getAttributes().getNamedItem(at_name) );
|
||||
mapTrigger.name = CStrW( groupChild.GetAttributes().GetNamedItem(at_name) );
|
||||
|
||||
//Read everything in this trigger
|
||||
XERO_ITER_EL(groupChild, triggerChild)
|
||||
{
|
||||
elementName = triggerChild.getNodeName();
|
||||
elementName = triggerChild.GetNodeName();
|
||||
if ( elementName == el_active )
|
||||
{
|
||||
if ( CStr("false") == CStr( triggerChild.getText() ) )
|
||||
if ( CStr("false") == CStr( triggerChild.GetText() ) )
|
||||
mapTrigger.active = false;
|
||||
else
|
||||
mapTrigger.active = true;
|
||||
}
|
||||
|
||||
else if ( elementName == el_maxruncount )
|
||||
mapTrigger.maxRunCount = CStr( triggerChild.getText() ).ToInt();
|
||||
mapTrigger.maxRunCount = CStr( triggerChild.GetText() ).ToInt();
|
||||
else if ( elementName == el_delay )
|
||||
mapTrigger.timeValue = CStr( triggerChild.getText() ).ToFloat();
|
||||
mapTrigger.timeValue = CStr( triggerChild.GetText() ).ToFloat();
|
||||
|
||||
else if ( elementName == el_conditions )
|
||||
{
|
||||
//Read in all conditions for this trigger
|
||||
XERO_ITER_EL(triggerChild, condition)
|
||||
{
|
||||
elementName = condition.getNodeName();
|
||||
elementName = condition.GetNodeName();
|
||||
if ( elementName == el_condition )
|
||||
{
|
||||
MapTriggerCondition mapCondition;
|
||||
mapCondition.name = condition.getAttributes().getNamedItem(at_name);
|
||||
mapCondition.functionName = condition.getAttributes().getNamedItem(at_function);
|
||||
mapCondition.displayName = condition.getAttributes().getNamedItem(at_display);
|
||||
mapCondition.name = condition.GetAttributes().GetNamedItem(at_name);
|
||||
mapCondition.functionName = condition.GetAttributes().GetNamedItem(at_function);
|
||||
mapCondition.displayName = condition.GetAttributes().GetNamedItem(at_display);
|
||||
|
||||
CStr notAtt(condition.getAttributes().getNamedItem(at_not));
|
||||
CStr notAtt(condition.GetAttributes().GetNamedItem(at_not));
|
||||
if ( notAtt == CStr("true") )
|
||||
mapCondition.negated = true;
|
||||
|
||||
//Read in each condition child
|
||||
XERO_ITER_EL(condition, conditionChild)
|
||||
{
|
||||
elementName = conditionChild.getNodeName();
|
||||
elementName = conditionChild.GetNodeName();
|
||||
|
||||
if ( elementName == el_function )
|
||||
mapCondition.functionName = CStrW(conditionChild.getText());
|
||||
mapCondition.functionName = CStrW(conditionChild.GetText());
|
||||
else if ( elementName == el_display )
|
||||
mapCondition.displayName = CStrW(conditionChild.getText());
|
||||
mapCondition.displayName = CStrW(conditionChild.GetText());
|
||||
else if ( elementName == el_parameter )
|
||||
mapCondition.parameters.push_back( conditionChild.getText() );
|
||||
mapCondition.parameters.push_back( conditionChild.GetText() );
|
||||
else if ( elementName == el_linklogic )
|
||||
{
|
||||
CStr logic = conditionChild.getText();
|
||||
CStr logic = conditionChild.GetText();
|
||||
if ( logic == CStr("AND") )
|
||||
mapCondition.linkLogic = 1;
|
||||
else
|
||||
@ -729,7 +729,7 @@ void CXMLReader::ReadTriggerGroup(XMBElement parent, MapTriggerGroup& group)
|
||||
|
||||
else if ( elementName == el_logicblock)
|
||||
{
|
||||
if ( CStr(condition.getAttributes().getNamedItem(at_not)) == CStr("true") )
|
||||
if ( CStr(condition.GetAttributes().GetNamedItem(at_not)) == CStr("true") )
|
||||
mapTrigger.AddLogicBlock(true);
|
||||
else
|
||||
mapTrigger.AddLogicBlock(false);
|
||||
@ -745,24 +745,24 @@ void CXMLReader::ReadTriggerGroup(XMBElement parent, MapTriggerGroup& group)
|
||||
//Read all effects
|
||||
XERO_ITER_EL(triggerChild, effect)
|
||||
{
|
||||
if ( effect.getNodeName() != el_effect )
|
||||
if ( effect.GetNodeName() != el_effect )
|
||||
{
|
||||
debug_warn("Invalid effect tag in trigger XML file");
|
||||
return;
|
||||
}
|
||||
MapTriggerEffect mapEffect;
|
||||
mapEffect.name = effect.getAttributes().getNamedItem(at_name);
|
||||
mapEffect.name = effect.GetAttributes().GetNamedItem(at_name);
|
||||
|
||||
//Read parameters
|
||||
XERO_ITER_EL(effect, effectChild)
|
||||
{
|
||||
elementName = effectChild.getNodeName();
|
||||
elementName = effectChild.GetNodeName();
|
||||
if ( elementName == el_function )
|
||||
mapEffect.functionName = effectChild.getText();
|
||||
mapEffect.functionName = effectChild.GetText();
|
||||
else if ( elementName == el_display )
|
||||
mapEffect.displayName = effectChild.getText();
|
||||
mapEffect.displayName = effectChild.GetText();
|
||||
else if ( elementName == el_parameter )
|
||||
mapEffect.parameters.push_back( effectChild.getText() );
|
||||
mapEffect.parameters.push_back( effectChild.GetText() );
|
||||
else
|
||||
{
|
||||
debug_warn("Invalid parameter tag in trigger XML file");
|
||||
@ -787,7 +787,7 @@ void CXMLReader::ReadTriggerGroup(XMBElement parent, MapTriggerGroup& group)
|
||||
|
||||
int CXMLReader::ReadEntities(XMBElement parent, double end_time)
|
||||
{
|
||||
XMBElementList entities = parent.getChildNodes();
|
||||
XMBElementList entities = parent.GetChildNodes();
|
||||
|
||||
// If this is the first time in ReadEntities, find the next free ID number
|
||||
// in case we need to allocate new ones in the future
|
||||
@ -797,10 +797,10 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
|
||||
|
||||
XERO_ITER_EL(parent, entity)
|
||||
{
|
||||
debug_assert(entity.getNodeName() == el_entity);
|
||||
debug_assert(entity.GetNodeName() == el_entity);
|
||||
|
||||
XMBAttributeList attrs = entity.getAttributes();
|
||||
utf16string uid = attrs.getNamedItem(at_uid);
|
||||
XMBAttributeList attrs = entity.GetAttributes();
|
||||
utf16string uid = attrs.GetNamedItem(at_uid);
|
||||
int unitId = uid.empty() ? -1 : CStr(uid).ToInt();
|
||||
maxUnitID = std::max(maxUnitID, unitId);
|
||||
}
|
||||
@ -813,11 +813,11 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
|
||||
// all new state at this scope and below doesn't need to be
|
||||
// wrapped, since we only yield after a complete iteration.
|
||||
|
||||
XMBElement entity = entities.item(entity_idx++);
|
||||
debug_assert(entity.getNodeName() == el_entity);
|
||||
XMBElement entity = entities.Item(entity_idx++);
|
||||
debug_assert(entity.GetNodeName() == el_entity);
|
||||
|
||||
XMBAttributeList attrs = entity.getAttributes();
|
||||
utf16string uid = attrs.getNamedItem(at_uid);
|
||||
XMBAttributeList attrs = entity.GetAttributes();
|
||||
utf16string uid = attrs.GetNamedItem(at_uid);
|
||||
int unitId = uid.empty() ? -1 : CStr(uid).ToInt();
|
||||
|
||||
CStrW TemplateName;
|
||||
@ -827,45 +827,45 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
|
||||
|
||||
XERO_ITER_EL(entity, setting)
|
||||
{
|
||||
int element_name = setting.getNodeName();
|
||||
int element_name = setting.GetNodeName();
|
||||
|
||||
// <template>
|
||||
if (element_name == el_template)
|
||||
{
|
||||
TemplateName = setting.getText();
|
||||
TemplateName = setting.GetText();
|
||||
}
|
||||
// <player>
|
||||
else if (element_name == el_player)
|
||||
{
|
||||
PlayerID = CStr(setting.getText()).ToInt();
|
||||
PlayerID = CStr(setting.GetText()).ToInt();
|
||||
}
|
||||
// <position>
|
||||
else if (element_name == el_position)
|
||||
{
|
||||
XMBAttributeList attrs = setting.getAttributes();
|
||||
XMBAttributeList attrs = setting.GetAttributes();
|
||||
Position = CVector3D(
|
||||
CStr(attrs.getNamedItem(at_x)).ToFloat(),
|
||||
CStr(attrs.getNamedItem(at_y)).ToFloat(),
|
||||
CStr(attrs.getNamedItem(at_z)).ToFloat());
|
||||
CStr(attrs.GetNamedItem(at_x)).ToFloat(),
|
||||
CStr(attrs.GetNamedItem(at_y)).ToFloat(),
|
||||
CStr(attrs.GetNamedItem(at_z)).ToFloat());
|
||||
}
|
||||
// <orientation>
|
||||
else if (element_name == el_orientation)
|
||||
{
|
||||
XMBAttributeList attrs = setting.getAttributes();
|
||||
Orientation = CStr(attrs.getNamedItem(at_angle)).ToFloat();
|
||||
XMBAttributeList attrs = setting.GetAttributes();
|
||||
Orientation = CStr(attrs.GetNamedItem(at_angle)).ToFloat();
|
||||
}
|
||||
else
|
||||
debug_warn("Invalid map XML data");
|
||||
}
|
||||
|
||||
CEntityTemplate* base = g_EntityTemplateCollection.getTemplate(TemplateName, g_Game->GetPlayer(PlayerID));
|
||||
CEntityTemplate* base = g_EntityTemplateCollection.GetTemplate(TemplateName, g_Game->GetPlayer(PlayerID));
|
||||
if (! base)
|
||||
LOG(ERROR, LOG_CATEGORY, "Failed to load entity template '%ls'", TemplateName.c_str());
|
||||
else
|
||||
{
|
||||
std::set<CStr> selections; // TODO: read from file
|
||||
|
||||
HEntity ent = g_EntityManager.create(base, Position, Orientation, selections);
|
||||
HEntity ent = g_EntityManager.Create(base, Position, Orientation, selections);
|
||||
|
||||
if (! ent)
|
||||
LOG(ERROR, LOG_CATEGORY, "Failed to create entity of type '%ls'", TemplateName.c_str());
|
||||
@ -891,14 +891,14 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
|
||||
|
||||
int CXMLReader::ReadNonEntities(XMBElement parent, double end_time)
|
||||
{
|
||||
XMBElementList nonentities = parent.getChildNodes();
|
||||
XMBElementList nonentities = parent.GetChildNodes();
|
||||
while (nonentity_idx < nonentities.Count)
|
||||
{
|
||||
// all new state at this scope and below doesn't need to be
|
||||
// wrapped, since we only yield after a complete iteration.
|
||||
|
||||
XMBElement nonentity = nonentities.item(nonentity_idx++);
|
||||
debug_assert(nonentity.getNodeName() == el_nonentity);
|
||||
XMBElement nonentity = nonentities.Item(nonentity_idx++);
|
||||
debug_assert(nonentity.GetNodeName() == el_nonentity);
|
||||
|
||||
CStr ActorName;
|
||||
CVector3D Position;
|
||||
@ -906,27 +906,27 @@ int CXMLReader::ReadNonEntities(XMBElement parent, double end_time)
|
||||
|
||||
XERO_ITER_EL(nonentity, setting)
|
||||
{
|
||||
int element_name = setting.getNodeName();
|
||||
int element_name = setting.GetNodeName();
|
||||
|
||||
// <actor>
|
||||
if (element_name == el_actor)
|
||||
{
|
||||
ActorName = setting.getText();
|
||||
ActorName = setting.GetText();
|
||||
}
|
||||
// <position>
|
||||
else if (element_name == el_position)
|
||||
{
|
||||
XMBAttributeList attrs = setting.getAttributes();
|
||||
XMBAttributeList attrs = setting.GetAttributes();
|
||||
Position = CVector3D(
|
||||
CStr(attrs.getNamedItem(at_x)).ToFloat(),
|
||||
CStr(attrs.getNamedItem(at_y)).ToFloat(),
|
||||
CStr(attrs.getNamedItem(at_z)).ToFloat());
|
||||
CStr(attrs.GetNamedItem(at_x)).ToFloat(),
|
||||
CStr(attrs.GetNamedItem(at_y)).ToFloat(),
|
||||
CStr(attrs.GetNamedItem(at_z)).ToFloat());
|
||||
}
|
||||
// <orientation>
|
||||
else if (element_name == el_orientation)
|
||||
{
|
||||
XMBAttributeList attrs = setting.getAttributes();
|
||||
Orientation = CStr(attrs.getNamedItem(at_angle)).ToFloat();
|
||||
XMBAttributeList attrs = setting.GetAttributes();
|
||||
Orientation = CStr(attrs.GetNamedItem(at_angle)).ToFloat();
|
||||
}
|
||||
else
|
||||
debug_warn("Invalid map XML data");
|
||||
@ -966,8 +966,8 @@ int CXMLReader::ProgressiveRead()
|
||||
|
||||
while (node_idx < nodes.Count)
|
||||
{
|
||||
XMBElement node = nodes.item(node_idx);
|
||||
CStr name = xmb_file.getElementString(node.getNodeName());
|
||||
XMBElement node = nodes.Item(node_idx);
|
||||
CStr name = xmb_file.GetElementString(node.GetNodeName());
|
||||
if (name == "Environment")
|
||||
{
|
||||
ReadEnvironment(node);
|
||||
|
@ -393,7 +393,7 @@ void CMapWriter::WriteXML(const char* filename,
|
||||
}
|
||||
else
|
||||
{
|
||||
std::for_each(rootChildren.begin(), rootChildren.end(), copyIfRootChild(rootChildren));
|
||||
std::for_each(rootChildren.begin(), rootChildren.end(), CopyIfRootChild(rootChildren));
|
||||
|
||||
XML_Element("Triggers");
|
||||
for ( std::list<MapTriggerGroup>::const_iterator it = rootChildren.begin();
|
||||
|
@ -87,7 +87,7 @@ void CMaterial::Bind()
|
||||
glMaterialfv(GL_FRONT, GL_SPECULAR, &m_Specular.r);
|
||||
glMaterialfv(GL_FRONT, GL_EMISSION, &m_Emissive.r);
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
}
|
||||
|
||||
void CMaterial::Unbind()
|
||||
|
@ -182,8 +182,8 @@ CMaterial &CMaterialManager::LoadMaterial(const char *file)
|
||||
if(xeroFile.Load(file) != PSRETURN_OK)
|
||||
return NullMaterial;
|
||||
|
||||
#define EL(x) int el_##x = xeroFile.getElementID(#x)
|
||||
#define AT(x) int at_##x = xeroFile.getAttributeID(#x)
|
||||
#define EL(x) int el_##x = xeroFile.GetElementID(#x)
|
||||
#define AT(x) int at_##x = xeroFile.GetAttributeID(#x)
|
||||
EL(texture);
|
||||
EL(vertexprogram);
|
||||
EL(fragmentprogram);
|
||||
@ -204,52 +204,52 @@ CMaterial &CMaterialManager::LoadMaterial(const char *file)
|
||||
CMaterial *material = NULL;
|
||||
try
|
||||
{
|
||||
XMBElement root = xeroFile.getRoot();
|
||||
XMBElementList childNodes = root.getChildNodes();
|
||||
XMBElement root = xeroFile.GetRoot();
|
||||
XMBElementList childNodes = root.GetChildNodes();
|
||||
material = new CMaterial();
|
||||
|
||||
for(int i = 0; i < childNodes.Count; i++)
|
||||
{
|
||||
XMBElement node = childNodes.item(i);
|
||||
int token = node.getNodeName();
|
||||
XMBAttributeList attrs = node.getAttributes();
|
||||
XMBElement node = childNodes.Item(i);
|
||||
int token = node.GetNodeName();
|
||||
XMBAttributeList attrs = node.GetAttributes();
|
||||
CStr temp;
|
||||
if(token == el_texture)
|
||||
{
|
||||
CStr value(node.getText());
|
||||
CStr value(node.GetText());
|
||||
material->SetTexture(value);
|
||||
}
|
||||
else if(token == el_vertexprogram)
|
||||
{
|
||||
CStr value(node.getText());
|
||||
CStr value(node.GetText());
|
||||
material->SetVertexProgram(value);
|
||||
}
|
||||
else if(token == el_fragmentprogram)
|
||||
{
|
||||
CStr value(node.getText());
|
||||
CStr value(node.GetText());
|
||||
material->SetFragmentProgram(value);
|
||||
}
|
||||
else if(token == el_colors)
|
||||
{
|
||||
temp = (CStr)attrs.getNamedItem(at_diffuse);
|
||||
temp = (CStr)attrs.GetNamedItem(at_diffuse);
|
||||
if(! temp.empty())
|
||||
material->SetDiffuse(ParseColor(temp));
|
||||
|
||||
temp = (CStr)attrs.getNamedItem(at_ambient);
|
||||
temp = (CStr)attrs.GetNamedItem(at_ambient);
|
||||
if(! temp.empty())
|
||||
material->SetAmbient(ParseColor(temp));
|
||||
|
||||
temp = (CStr)attrs.getNamedItem(at_specular);
|
||||
temp = (CStr)attrs.GetNamedItem(at_specular);
|
||||
if(! temp.empty())
|
||||
material->SetSpecular(ParseColor(temp));
|
||||
|
||||
temp = (CStr)attrs.getNamedItem(at_specularpower);
|
||||
temp = (CStr)attrs.GetNamedItem(at_specularpower);
|
||||
if(! temp.empty())
|
||||
material->SetSpecularPower(ClampFloat(temp.ToFloat(), 0.0f, 1.0f));
|
||||
}
|
||||
else if(token == el_alpha)
|
||||
{
|
||||
temp = (CStr)attrs.getNamedItem(at_usage);
|
||||
temp = (CStr)attrs.GetNamedItem(at_usage);
|
||||
|
||||
// Determine whether the alpha is used for basic transparency or player color
|
||||
if (temp == "playercolor")
|
||||
|
@ -38,8 +38,8 @@ bool CObjectBase::Load(const char* filename)
|
||||
m_ShortName = CStr(filename).AfterLast("/").BeforeLast(".xml");
|
||||
|
||||
// Define all the elements used in the XML file
|
||||
#define EL(x) int el_##x = XeroFile.getElementID(#x)
|
||||
#define AT(x) int at_##x = XeroFile.getAttributeID(#x)
|
||||
#define EL(x) int el_##x = XeroFile.GetElementID(#x)
|
||||
#define AT(x) int at_##x = XeroFile.GetAttributeID(#x)
|
||||
EL(actor);
|
||||
EL(castshadow);
|
||||
EL(float);
|
||||
@ -64,11 +64,11 @@ bool CObjectBase::Load(const char* filename)
|
||||
#undef AT
|
||||
#undef EL
|
||||
|
||||
XMBElement root = XeroFile.getRoot();
|
||||
XMBElement root = XeroFile.GetRoot();
|
||||
|
||||
if (root.getNodeName() != el_actor)
|
||||
if (root.GetNodeName() != el_actor)
|
||||
{
|
||||
LOG(ERROR, LOG_CATEGORY, "Invalid actor format (unrecognised root element '%s')", XeroFile.getElementString(root.getNodeName()).c_str());
|
||||
LOG(ERROR, LOG_CATEGORY, "Invalid actor format (unrecognised root element '%s')", XeroFile.GetElementString(root.GetNodeName()).c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -80,9 +80,9 @@ bool CObjectBase::Load(const char* filename)
|
||||
std::vector<int> variantGroupSizes;
|
||||
XERO_ITER_EL(root, child)
|
||||
{
|
||||
if (child.getNodeName() == el_group)
|
||||
if (child.GetNodeName() == el_group)
|
||||
{
|
||||
variantGroupSizes.push_back(child.getChildNodes().Count);
|
||||
variantGroupSizes.push_back(child.GetChildNodes().Count);
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,14 +99,14 @@ bool CObjectBase::Load(const char* filename)
|
||||
|
||||
XERO_ITER_EL(root, child)
|
||||
{
|
||||
int child_name = child.getNodeName();
|
||||
int child_name = child.GetNodeName();
|
||||
|
||||
if (child_name == el_group)
|
||||
{
|
||||
std::vector<Variant>::iterator currentVariant = currentGroup->begin();
|
||||
XERO_ITER_EL(child, variant)
|
||||
{
|
||||
debug_assert(variant.getNodeName() == el_variant);
|
||||
debug_assert(variant.GetNodeName() == el_variant);
|
||||
XERO_ITER_ATTR(variant, attr)
|
||||
{
|
||||
if (attr.Name == at_name)
|
||||
@ -119,22 +119,22 @@ bool CObjectBase::Load(const char* filename)
|
||||
|
||||
XERO_ITER_EL(variant, option)
|
||||
{
|
||||
int option_name = option.getNodeName();
|
||||
int option_name = option.GetNodeName();
|
||||
|
||||
if (option_name == el_mesh)
|
||||
currentVariant->m_ModelFilename = "art/meshes/" + CStr(option.getText());
|
||||
currentVariant->m_ModelFilename = "art/meshes/" + CStr(option.GetText());
|
||||
|
||||
else if (option_name == el_texture)
|
||||
currentVariant->m_TextureFilename = "art/textures/skins/" + CStr(option.getText());
|
||||
currentVariant->m_TextureFilename = "art/textures/skins/" + CStr(option.GetText());
|
||||
|
||||
else if (option_name == el_colour)
|
||||
currentVariant->m_Color = option.getText();
|
||||
currentVariant->m_Color = option.GetText();
|
||||
|
||||
else if (option_name == el_animations)
|
||||
{
|
||||
XERO_ITER_EL(option, anim_element)
|
||||
{
|
||||
debug_assert(anim_element.getNodeName() == el_animation);
|
||||
debug_assert(anim_element.GetNodeName() == el_animation);
|
||||
|
||||
Anim anim;
|
||||
XERO_ITER_ATTR(anim_element, ae)
|
||||
@ -173,7 +173,7 @@ bool CObjectBase::Load(const char* filename)
|
||||
{
|
||||
XERO_ITER_EL(option, prop_element)
|
||||
{
|
||||
debug_assert(prop_element.getNodeName() == el_prop);
|
||||
debug_assert(prop_element.GetNodeName() == el_prop);
|
||||
|
||||
Prop prop;
|
||||
XERO_ITER_ATTR(prop_element, pe)
|
||||
@ -212,7 +212,7 @@ bool CObjectBase::Load(const char* filename)
|
||||
}
|
||||
else if (child_name == el_material)
|
||||
{
|
||||
m_Material = "art/materials/" + CStr(child.getText());
|
||||
m_Material = "art/materials/" + CStr(child.GetText());
|
||||
}
|
||||
else
|
||||
; // unrecognised element
|
||||
|
@ -19,7 +19,7 @@ CEmitter::CEmitter(const int MAX_PARTICLES, const int lifetime, int UNUSED(textu
|
||||
emitterLife = lifetime;
|
||||
decrementLife = true;
|
||||
decrementAlpha = true;
|
||||
renderParticles = true;
|
||||
RenderParticles = true;
|
||||
isFinished = false;
|
||||
updateSpeed = 0.02f;
|
||||
blend_mode = 1;
|
||||
@ -45,7 +45,7 @@ CEmitter::~CEmitter(void)
|
||||
delete [] heap;
|
||||
}
|
||||
|
||||
bool CEmitter::addParticle()
|
||||
bool CEmitter::AddParticle()
|
||||
{
|
||||
tColor start, end;
|
||||
float fYaw, fPitch, fSpeed;
|
||||
@ -59,9 +59,9 @@ bool CEmitter::addParticle()
|
||||
tParticle *particle = openList;
|
||||
|
||||
// set it's initial position to the emitter's position
|
||||
particle->pos.x = pos.x;
|
||||
particle->pos.y = pos.y;
|
||||
particle->pos.z = pos.z;
|
||||
particle->pos.X = pos.X;
|
||||
particle->pos.Y = pos.Y;
|
||||
particle->pos.Z = pos.Z;
|
||||
|
||||
// Calculate the starting direction vector
|
||||
fYaw = yaw + (yawVar * RandomNum());
|
||||
@ -72,9 +72,9 @@ bool CEmitter::addParticle()
|
||||
|
||||
// Multiply in the speed factor
|
||||
fSpeed = speed + (speedVar * RandomNum());
|
||||
particle->dir.x *= fSpeed;
|
||||
particle->dir.y *= fSpeed;
|
||||
particle->dir.z *= fSpeed;
|
||||
particle->dir.X *= fSpeed;
|
||||
particle->dir.Y *= fSpeed;
|
||||
particle->dir.Z *= fSpeed;
|
||||
|
||||
// Calculate the life span
|
||||
particle->life = life + (int)((float)lifeVar * RandomNum());
|
||||
@ -115,9 +115,9 @@ bool CEmitter::addParticle()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CEmitter::renderEmitter()
|
||||
bool CEmitter::Render()
|
||||
{
|
||||
if(renderParticles)
|
||||
if(RenderParticles)
|
||||
{
|
||||
switch(blend_mode)
|
||||
{
|
||||
@ -148,14 +148,14 @@ bool CEmitter::renderEmitter()
|
||||
tColor *pColor = &(tempParticle->color);
|
||||
glColor4ub(pColor->r,pColor->g, pColor->b, (GLubyte)tempParticle->alpha);
|
||||
glTexCoord2d(0.0, 0.0);
|
||||
tVector *pPos = &(tempParticle->pos);
|
||||
glVertex3f(pPos->x - size, pPos->y + size, pPos->z);
|
||||
CVector3D *pPos = &(tempParticle->pos);
|
||||
glVertex3f(pPos->X - size, pPos->Y + size, pPos->Z);
|
||||
glTexCoord2d(0.0, 1.0);
|
||||
glVertex3f(pPos->x - size, pPos->y - size, pPos->z);
|
||||
glVertex3f(pPos->X - size, pPos->Y - size, pPos->Z);
|
||||
glTexCoord2d(1.0, 1.0);
|
||||
glVertex3f(pPos->x + size, pPos->y - size, pPos->z);
|
||||
glVertex3f(pPos->X + size, pPos->Y - size, pPos->Z);
|
||||
glTexCoord2d(1.0, 0.0);
|
||||
glVertex3f(pPos->x + size, pPos->y + size, pPos->z);
|
||||
glVertex3f(pPos->X + size, pPos->Y + size, pPos->Z);
|
||||
tempParticle = tempParticle->next;
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,9 @@
|
||||
#ifndef _PARTICLEEMITTER_H_
|
||||
#define _PARTICLEEMITTER_H_
|
||||
|
||||
class CTexture;
|
||||
#include "maths/Vector3D.h"
|
||||
|
||||
struct tVector
|
||||
{
|
||||
float x,y,z;
|
||||
};
|
||||
class CTexture;
|
||||
|
||||
class CEmitter
|
||||
{
|
||||
@ -29,8 +26,8 @@ public:
|
||||
struct tParticle
|
||||
{
|
||||
// base stuff
|
||||
tVector pos; // Current position 12
|
||||
tVector dir; // Current direction with speed 12
|
||||
CVector3D pos; // Current position 12
|
||||
CVector3D dir; // Current direction with speed 12
|
||||
float alpha; // Fade value 4
|
||||
float alphaDelta; // Change of fade 4
|
||||
tColor color; // Current color of particle 3
|
||||
@ -38,7 +35,7 @@ public:
|
||||
short life; // How long it will last 2
|
||||
|
||||
// particle text stuff
|
||||
tVector endPos; // For particle texture 12
|
||||
CVector3D endPos; // For particle texture 12
|
||||
bool inPos; // 1
|
||||
|
||||
tParticle* next; // pointer for link lists 4
|
||||
@ -60,8 +57,8 @@ protected:
|
||||
bool isFinished; // tells the engine it's ready to be deleted
|
||||
|
||||
// Transformation Info
|
||||
tVector pos; // XYZ Position
|
||||
tVector finalPos; // Final position of the particles (IF IMPLOSION)
|
||||
CVector3D pos; // XYZ Position
|
||||
CVector3D finalPos; // Final position of the particles (IF IMPLOSION)
|
||||
float yaw, yawVar; // Yaw and variation
|
||||
float pitch, pitchVar; // Pitch and variation
|
||||
float speed, speedVar; // Speed and variation
|
||||
@ -82,56 +79,28 @@ protected:
|
||||
int emitterLife; // Life of the emitter
|
||||
bool decrementLife; // Controls whether or not the particles life is decremented every update.
|
||||
bool decrementAlpha; // Controls whether or not the particles alpha is decremented every update.
|
||||
bool renderParticles; // Controls the rendering of the particles.
|
||||
bool RenderParticles; // Controls the rendering of the particles.
|
||||
tColor startColor, startColorVar; // Current color of particle
|
||||
tColor endColor, endColorVar; // Current color of particle
|
||||
|
||||
// Physics
|
||||
tVector force; // Forces that affect the particles
|
||||
CVector3D force; // Forces that affect the particles
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
CEmitter(const int MAX_PARTICLES = 4000, const int lifetime = -1, int textureID = 0);
|
||||
virtual ~CEmitter(void);
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: setupEmitter
|
||||
//Date: 9/18/05
|
||||
//Author: Will Dull
|
||||
//Notes: Setup emitter. Setup so that a derived class can
|
||||
// overload this function to suit the specific particles
|
||||
// needs.
|
||||
//////////////////////////////////////////////////////////////
|
||||
virtual bool setupEmitter() { return false;}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: addParticle
|
||||
//Date: 9/18/05
|
||||
//Author: Will Dull
|
||||
//Notes: Sets up and adds a particle to an emitter. Setup so
|
||||
// that a derived class can overload this function to
|
||||
// suit the specific particles needs.
|
||||
//////////////////////////////////////////////////////////////
|
||||
virtual bool addParticle();
|
||||
// note: functions are virtual and overridable so as to suit the
|
||||
// specific particle needs.
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: updateEmitter
|
||||
//Date: 9/18/05
|
||||
//Author: Will Dull
|
||||
//Notes: Updates emitter. Setup so that a derived class can
|
||||
// overload this function to suit the specific particles
|
||||
// needs.
|
||||
//////////////////////////////////////////////////////////////
|
||||
virtual bool updateEmitter() { return false; }
|
||||
virtual bool Setup() { return false; }
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: renderEmitter
|
||||
//Date: 9/18/05
|
||||
//Author: Will Dull
|
||||
//Notes: Renders emitter. Setup so that a derived class can
|
||||
// overload this function to suit the specific particles
|
||||
// needs.
|
||||
//////////////////////////////////////////////////////////////
|
||||
virtual bool renderEmitter();
|
||||
virtual bool AddParticle();
|
||||
|
||||
virtual bool Update() { return false; }
|
||||
|
||||
virtual bool Render();
|
||||
|
||||
inline float RandomNum()
|
||||
{
|
||||
@ -145,11 +114,11 @@ public:
|
||||
return (unsigned char)(rand() >> 24);
|
||||
}
|
||||
|
||||
inline void RotationToDirection(float pitch, float yaw, tVector *direction)
|
||||
inline void RotationToDirection(float pitch, float yaw, CVector3D* direction)
|
||||
{
|
||||
direction->x = (float)(-sin(yaw) * cos(pitch));
|
||||
direction->y = (float)sin(pitch);
|
||||
direction->z = (float)(cos(pitch) * cos(yaw));
|
||||
direction->X = (float)(-sin(yaw)* cos(pitch));
|
||||
direction->Y = (float)sin(pitch);
|
||||
direction->Z = (float)(cos(pitch)* cos(yaw));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
@ -157,37 +126,37 @@ public:
|
||||
// Accessors
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////
|
||||
float getPosX() { return pos.x; }
|
||||
float getPosY() { return pos.y; }
|
||||
float getPosZ() { return pos.z; }
|
||||
tVector getPosVec() { return pos; }
|
||||
float getFinalPosX() { return finalPos.x; }
|
||||
float getFinalPosY() { return finalPos.y; }
|
||||
float getFinalPosZ() { return finalPos.z; }
|
||||
bool getIsFinished(void) { return isFinished; }
|
||||
int getEmitterLife() { return emitterLife; }
|
||||
int getParticleCount() { return particleCount; }
|
||||
float getUpdateSpeed() { return updateSpeed; }
|
||||
int getMaxParticles(void) { return max_particles; }
|
||||
tColor getStartColor(void) { return startColor; }
|
||||
tColor getStartColorVar(void) { return startColorVar; }
|
||||
tColor getEndColor(void) { return endColor; }
|
||||
tColor getEndColorVar(void) { return endColorVar; }
|
||||
int getBlendMode(void) { return blend_mode; }
|
||||
float getSize(void) { return size; }
|
||||
float getYaw(void) { return yaw; }
|
||||
float getYawVar(void) { return yawVar; }
|
||||
float getPitch(void) { return pitch; }
|
||||
float getPitchVar(void) { return pitchVar; }
|
||||
float getSpeed(void) { return speed; }
|
||||
float getSpeedVar(void) { return speedVar; }
|
||||
int getEmitsPerFrame(void) { return emitsPerFrame; }
|
||||
int getEmitVar(void) { return emitVar; }
|
||||
int getLife(void) { return life; }
|
||||
int getLifeVar(void) { return lifeVar; }
|
||||
float getForceX(void) { return force.x; }
|
||||
float getForceY(void) { return force.y; }
|
||||
float getForceZ(void) { return force.z; }
|
||||
float GetPosX() { return pos.X; }
|
||||
float GetPosY() { return pos.Y; }
|
||||
float GetPosZ() { return pos.Z; }
|
||||
CVector3D GetPosVec() { return pos; }
|
||||
float GetFinalPosX() { return finalPos.X; }
|
||||
float GetFinalPosY() { return finalPos.Y; }
|
||||
float GetFinalPosZ() { return finalPos.Z; }
|
||||
bool IsFinished(void) { return isFinished; }
|
||||
int GetEmitterLife() { return emitterLife; }
|
||||
int GetParticleCount() { return particleCount; }
|
||||
float GetUpdateSpeed() { return updateSpeed; }
|
||||
int GetMaxParticles(void) { return max_particles; }
|
||||
tColor GetStartColor(void) { return startColor; }
|
||||
tColor GetStartColorVar(void) { return startColorVar; }
|
||||
tColor GetEndColor(void) { return endColor; }
|
||||
tColor GetEndColorVar(void) { return endColorVar; }
|
||||
int GetBlendMode(void) { return blend_mode; }
|
||||
float GetSize(void) { return size; }
|
||||
float GetYaw(void) { return yaw; }
|
||||
float GetYawVar(void) { return yawVar; }
|
||||
float GetPitch(void) { return pitch; }
|
||||
float GetPitchVar(void) { return pitchVar; }
|
||||
float GetSpeed(void) { return speed; }
|
||||
float GetSpeedVar(void) { return speedVar; }
|
||||
int GetEmitsPerFrame(void) { return emitsPerFrame; }
|
||||
int GetEmitVar(void) { return emitVar; }
|
||||
int GetLife(void) { return life; }
|
||||
int GetLifeVar(void) { return lifeVar; }
|
||||
float GetForceX(void) { return force.X; }
|
||||
float GetForceY(void) { return force.Y; }
|
||||
float GetForceZ(void) { return force.Z; }
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
@ -195,64 +164,58 @@ public:
|
||||
// Mutators
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void setPosX(float posX) { pos.x = posX; }
|
||||
void setPosY(float posY) { pos.y = posY; }
|
||||
void setPosZ(float posZ) { pos.z = posZ; }
|
||||
inline void setPosVec(tVector newPos)
|
||||
void SetPosX(float posX) { pos.X = posX; }
|
||||
void SetPosY(float posY) { pos.Y = posY; }
|
||||
void SetPosZ(float posZ) { pos.Z = posZ; }
|
||||
inline void SetPosVec(const CVector3D& newPos)
|
||||
{
|
||||
pos.x = newPos.x;
|
||||
pos.y = newPos.y;
|
||||
pos.z = newPos.z;
|
||||
pos = newPos;
|
||||
}
|
||||
void setFinalPosX(float finalposX) { finalPos.x = finalposX; }
|
||||
void setFinalPosY(float finalposY) { finalPos.y = finalposY; }
|
||||
void setFinalPosZ(float finalposZ) { finalPos.z = finalposZ; }
|
||||
void setTexture(CTexture *id) { texture = id; }
|
||||
void setIsFinished(bool finished) { isFinished = finished; }
|
||||
void setEmitterLife(int life) { emitterLife = life; }
|
||||
void setUpdateSpeed(float speed) { updateSpeed = speed; }
|
||||
void setLife(int newlife) { life = newlife; }
|
||||
void setLifeVar(int newlifevar) { lifeVar = newlifevar; }
|
||||
void setSpeed(float newspeed) { speed = newspeed; }
|
||||
void setSpeedVar(float newspeedvar) { speedVar = newspeedvar; }
|
||||
void setYaw(float newyaw) { yaw = newyaw; }
|
||||
void setYawVar(float newyawvar) { yawVar = newyawvar; }
|
||||
void setPitch(float newpitch) { pitch = newpitch; }
|
||||
void setPitchVar(float newpitchvar) { pitchVar = newpitchvar; }
|
||||
void setStartColor(tColor newColor) { startColor = newColor; }
|
||||
void setStartColorVar(tColor newColorVar) { startColorVar = newColorVar; }
|
||||
void setEndColor(tColor newColor) { endColor = newColor; }
|
||||
void setEndColorVar(tColor newColorVar) { endColorVar = newColorVar; }
|
||||
void setStartColorR(int newColorR) { startColor.r = newColorR; }
|
||||
void setStartColorG(int newColorG) { startColor.g = newColorG; }
|
||||
void setStartColorB(int newColorB) { startColor.b = newColorB; }
|
||||
void setStartColorVarR(int newColorVarR) { startColorVar.r = newColorVarR; }
|
||||
void setStartColorVarG(int newColorVarG) { startColorVar.g = newColorVarG; }
|
||||
void setStartColorVarB(int newColorVarB) { startColorVar.b = newColorVarB; }
|
||||
void setEndColorR(int newColorR) { endColor.r = newColorR; }
|
||||
void setEndColorG(int newColorG) { endColor.g = newColorG; }
|
||||
void setEndColorB(int newColorB) { endColor.b = newColorB; }
|
||||
void setEndColorVarR(int newColorVarR) { endColorVar.r = newColorVarR; }
|
||||
void setEndColorVarG(int newColorVarG) { endColorVar.g = newColorVarG; }
|
||||
void setEndColorVarB(int newColorVarB) { endColorVar.b = newColorVarB; }
|
||||
inline void setBlendMode(int blendmode)
|
||||
void SetFinalPosX(float finalposX) { finalPos.X = finalposX; }
|
||||
void SetFinalPosY(float finalposY) { finalPos.Y = finalposY; }
|
||||
void SetFinalPosZ(float finalposZ) { finalPos.Z = finalposZ; }
|
||||
void SetTexture(CTexture* id) { texture = id; }
|
||||
void SetIsFinished(bool finished) { isFinished = finished; }
|
||||
void SetEmitterLife(int life) { emitterLife = life; }
|
||||
void SetUpdateSpeed(float speed) { updateSpeed = speed; }
|
||||
void SetLife(int newlife) { life = newlife; }
|
||||
void SetLifeVar(int newlifevar) { lifeVar = newlifevar; }
|
||||
void SetSpeed(float newspeed) { speed = newspeed; }
|
||||
void SetSpeedVar(float newspeedvar) { speedVar = newspeedvar; }
|
||||
void SetYaw(float newyaw) { yaw = newyaw; }
|
||||
void SetYawVar(float newyawvar) { yawVar = newyawvar; }
|
||||
void SetPitch(float newpitch) { pitch = newpitch; }
|
||||
void SetPitchVar(float newpitchvar) { pitchVar = newpitchvar; }
|
||||
void SetStartColor(tColor newColor) { startColor = newColor; }
|
||||
void SetStartColorVar(tColor newColorVar) { startColorVar = newColorVar; }
|
||||
void SetEndColor(tColor newColor) { endColor = newColor; }
|
||||
void SetEndColorVar(tColor newColorVar) { endColorVar = newColorVar; }
|
||||
void SetStartColorR(int newColorR) { startColor.r = newColorR; }
|
||||
void SetStartColorG(int newColorG) { startColor.g = newColorG; }
|
||||
void SetStartColorB(int newColorB) { startColor.b = newColorB; }
|
||||
void SetStartColorVarR(int newColorVarR) { startColorVar.r = newColorVarR; }
|
||||
void SetStartColorVarG(int newColorVarG) { startColorVar.g = newColorVarG; }
|
||||
void SetStartColorVarB(int newColorVarB) { startColorVar.b = newColorVarB; }
|
||||
void SetEndColorR(int newColorR) { endColor.r = newColorR; }
|
||||
void SetEndColorG(int newColorG) { endColor.g = newColorG; }
|
||||
void SetEndColorB(int newColorB) { endColor.b = newColorB; }
|
||||
void SetEndColorVarR(int newColorVarR) { endColorVar.r = newColorVarR; }
|
||||
void SetEndColorVarG(int newColorVarG) { endColorVar.g = newColorVarG; }
|
||||
void SetEndColorVarB(int newColorVarB) { endColorVar.b = newColorVarB; }
|
||||
inline void SetBlendMode(int blendmode)
|
||||
{
|
||||
if(blendmode >= 1 && blendmode <= 4)
|
||||
blend_mode = blendmode;
|
||||
else
|
||||
blend_mode = 1;
|
||||
}
|
||||
void setEmitsPerFrame(int emitsperframe) { emitsPerFrame = emitsperframe; }
|
||||
void setEmitVar(int emitvar) { emitVar = emitvar; }
|
||||
void setForceX(float forceX) { force.x = forceX; }
|
||||
void setForceY(float forceY) { force.y = forceY; }
|
||||
void setForceZ(float forceZ) { force.z = forceZ; }
|
||||
void setSize(float newSize) { size = newSize; }
|
||||
void setRenderParticles(bool render) { renderParticles = render; }
|
||||
|
||||
|
||||
// Destructor
|
||||
virtual ~CEmitter(void);
|
||||
void SetEmitsPerFrame(int emitsperframe) { emitsPerFrame = emitsperframe; }
|
||||
void SetEmitVar(int emitvar) { emitVar = emitvar; }
|
||||
void SetForceX(float forceX) { force.X = forceX; }
|
||||
void SetForceY(float forceY) { force.Y = forceY; }
|
||||
void SetForceZ(float forceZ) { force.Z = forceZ; }
|
||||
void SetSize(float newSize) { size = newSize; }
|
||||
void SetRenderParticles(bool render) { RenderParticles = render; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -20,7 +20,7 @@ CParticleEngine::~CParticleEngine(void)
|
||||
{
|
||||
}
|
||||
|
||||
void CParticleEngine::cleanup()
|
||||
void CParticleEngine::Cleanup()
|
||||
{
|
||||
tEmitterNode *temp = m_pHead;
|
||||
totalParticles = 0;
|
||||
@ -60,7 +60,7 @@ void CParticleEngine::DeleteInstance()
|
||||
m_pInstance = 0;
|
||||
}
|
||||
|
||||
bool CParticleEngine::initParticleSystem()
|
||||
bool CParticleEngine::InitParticleSystem()
|
||||
{
|
||||
// Texture Loading
|
||||
CTexture pTex;
|
||||
@ -86,9 +86,9 @@ bool CParticleEngine::initParticleSystem()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CParticleEngine::addEmitter(CEmitter *emitter, int type, int ID)
|
||||
bool CParticleEngine::AddEmitter(CEmitter *emitter, int type, int ID)
|
||||
{
|
||||
emitter->setTexture(&idTexture[type]);
|
||||
emitter->SetTexture(&idTexture[type]);
|
||||
if(m_pHead == NULL)
|
||||
{
|
||||
tEmitterNode *temp = new tEmitterNode;
|
||||
@ -112,7 +112,7 @@ bool CParticleEngine::addEmitter(CEmitter *emitter, int type, int ID)
|
||||
}
|
||||
}
|
||||
|
||||
CEmitter* CParticleEngine::findEmitter(int ID)
|
||||
CEmitter* CParticleEngine::FindEmitter(int ID)
|
||||
{
|
||||
tEmitterNode *temp = m_pHead;
|
||||
while(temp)
|
||||
@ -140,14 +140,14 @@ CEmitter* CParticleEngine::findEmitter(int ID)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CParticleEngine::updateEmitters()
|
||||
void CParticleEngine::UpdateEmitters()
|
||||
{
|
||||
tEmitterNode *temp = m_pHead;
|
||||
totalParticles = 0;
|
||||
while(temp)
|
||||
{
|
||||
// are we ready for deletion?
|
||||
if(temp->pEmitter->getIsFinished())
|
||||
if(temp->pEmitter->IsFinished())
|
||||
{
|
||||
// store a pointer to the next node
|
||||
tEmitterNode *pTemp = temp->next;
|
||||
@ -170,37 +170,37 @@ void CParticleEngine::updateEmitters()
|
||||
}
|
||||
else
|
||||
{
|
||||
temp->pEmitter->updateEmitter();
|
||||
temp->pEmitter->Update();
|
||||
|
||||
// Add current emitter to particle count
|
||||
totalParticles += temp->pEmitter->getParticleCount();
|
||||
totalParticles += temp->pEmitter->GetParticleCount();
|
||||
temp = temp->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CParticleEngine::renderParticles()
|
||||
void CParticleEngine::RenderParticles()
|
||||
{
|
||||
EnterParticleContext();
|
||||
|
||||
tEmitterNode *temp = m_pHead;
|
||||
while(temp)
|
||||
{
|
||||
temp->pEmitter->renderEmitter();
|
||||
temp->pEmitter->Render();
|
||||
temp = temp->next;
|
||||
}
|
||||
|
||||
LeaveParticleContext();
|
||||
}
|
||||
|
||||
void CParticleEngine::destroyAllEmitters(bool fade)
|
||||
void CParticleEngine::DestroyAllEmitters(bool fade)
|
||||
{
|
||||
tEmitterNode *temp = m_pHead;
|
||||
while(temp)
|
||||
{
|
||||
if(fade)
|
||||
{
|
||||
temp->pEmitter->setEmitterLife(0);
|
||||
temp->pEmitter->SetEmitterLife(0);
|
||||
temp = temp->next;
|
||||
}
|
||||
else
|
||||
@ -226,7 +226,7 @@ void CParticleEngine::destroyAllEmitters(bool fade)
|
||||
}
|
||||
}
|
||||
m_pHead = NULL;
|
||||
updateEmitters();
|
||||
UpdateEmitters();
|
||||
}
|
||||
|
||||
void CParticleEngine::EnterParticleContext(void)
|
||||
|
@ -33,94 +33,47 @@ public:
|
||||
virtual ~CParticleEngine(void);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: GetInstance
|
||||
//Date: 8/1/05
|
||||
//Author: Will Dull
|
||||
//Purpose: returns the instance of the singleton class
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// @return instance of the singleton class
|
||||
static CParticleEngine* GetInstance();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: DeleteInstance
|
||||
//Date: 8/1/05
|
||||
//Author: Will Dull
|
||||
//Purpose: deletes the instance of the singleton class
|
||||
//////////////////////////////////////////////////////////////
|
||||
/// delete the instance of the singleton class
|
||||
static void DeleteInstance();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: initParticleSystem
|
||||
//Date: 6/29/05
|
||||
//Author: Will Dull
|
||||
//Out: True if particle system initialized correctly,
|
||||
// false otherwise
|
||||
//Purpose: inits particle system.
|
||||
//////////////////////////////////////////////////////////////
|
||||
bool initParticleSystem(void);
|
||||
/// @return true on success, false on failure
|
||||
bool InitParticleSystem(void);
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: addEmitter
|
||||
//Date: 7/20/05
|
||||
//Author: Will Dull
|
||||
//In: emitter to add, texture type, id of emitter
|
||||
//Out: True if emitter added correctly,
|
||||
// false otherwise
|
||||
//Purpose: adds the emitter to the engines list
|
||||
//////////////////////////////////////////////////////////////
|
||||
bool addEmitter(CEmitter *emitter, int type = DEFAULTTEXT, int ID = DEFAULTEMIT);
|
||||
/**
|
||||
* add the emitter to the engine's list.
|
||||
* @return indicator of success.
|
||||
**/
|
||||
bool AddEmitter(CEmitter *emitter, int type = DEFAULTTEXT, int ID = DEFAULTEMIT);
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: findEmitter
|
||||
//Date: 7/21/05
|
||||
//Author: Will Dull
|
||||
//In: id of emitter to find
|
||||
//Out: the emitter if found,
|
||||
// NULL otherwise
|
||||
//Purpose: finds the emitter using its ID
|
||||
//////////////////////////////////////////////////////////////
|
||||
CEmitter* findEmitter(int ID);
|
||||
/// @return emitter with the given ID or 0 if not found.
|
||||
CEmitter* FindEmitter(int ID);
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: updateEmitters
|
||||
//Date: 7/20/05
|
||||
//Author: Will Dull
|
||||
//Purpose: Checks if the emitter is ready to be deleted
|
||||
// and removed. If not it calls the emitters update
|
||||
// function.
|
||||
//////////////////////////////////////////////////////////////
|
||||
void updateEmitters();
|
||||
/**
|
||||
* Check if the emitters are ready to be deleted and removed.
|
||||
* If not, call Update() on them.
|
||||
**/
|
||||
void UpdateEmitters();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: renderParticles
|
||||
//Date: 7/20/05
|
||||
//Author: Will Dull
|
||||
//Purpose: Renders the emitter and all it's particles
|
||||
//////////////////////////////////////////////////////////////
|
||||
void renderParticles();
|
||||
/// render each emitter and their particles
|
||||
void RenderParticles();
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: destroyAllEmitters
|
||||
//Date: 8/1/05
|
||||
//Author: Will Dull
|
||||
//In: fade - if true, will allow the emitter to fade itself out
|
||||
// if false, emitter and particles will disappear instantly
|
||||
//Purpose: Destroys every active emitter on screen.
|
||||
//////////////////////////////////////////////////////////////
|
||||
void destroyAllEmitters(bool fade = true);
|
||||
/**
|
||||
* destroy all active emitters on screen.
|
||||
* @param fade if true, allows emitters to fade out. if false,
|
||||
* they disappear instantly.
|
||||
**/
|
||||
void DestroyAllEmitters(bool fade = true);
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//Func Name: cleanup
|
||||
//Date: 8/3/05
|
||||
//Author: Will Dull
|
||||
//Purpose: Any cleanup not done in the destructor.
|
||||
//////////////////////////////////////////////////////////////
|
||||
void cleanup();
|
||||
/// do cleanup that's not done in the destructor.
|
||||
void Cleanup();
|
||||
|
||||
void EnterParticleContext(void);
|
||||
void LeaveParticleContext(void);
|
||||
|
||||
int getTotalParticles() { return totalParticles; }
|
||||
int GetTotalParticles() { return totalParticles; }
|
||||
void SetTotalParticles(int particles) { totalParticles = particles; }
|
||||
void AddToTotalParticles(int addAmount) { totalParticles += addAmount; }
|
||||
void SubToTotalParticles(int subAmount) { totalParticles -= subAmount; }
|
||||
|
@ -82,17 +82,17 @@ bool CTerrain::Initialize(u32 size,const u16* data)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float CTerrain::getExactGroundLevel(const CVector2D& v) const
|
||||
float CTerrain::GetExactGroundLevel(const CVector2D& v) const
|
||||
{
|
||||
return getExactGroundLevel(v.x, v.y);
|
||||
return GetExactGroundLevel(v.x, v.y);
|
||||
}
|
||||
|
||||
bool CTerrain::isOnMap(const CVector2D& v) const
|
||||
bool CTerrain::IsOnMap(const CVector2D& v) const
|
||||
{
|
||||
return isOnMap(v.x, v.y);
|
||||
return IsOnMap(v.x, v.y);
|
||||
}
|
||||
|
||||
bool CTerrain::isPassable(const CVector2D &loc/*tile space*/, HEntity entity) const
|
||||
bool CTerrain::IsPassable(const CVector2D &loc/*tile space*/, HEntity entity) const
|
||||
{
|
||||
CMiniPatch *pTile = GetTile(loc.x, loc.y);
|
||||
if(!pTile->Tex1)
|
||||
@ -162,7 +162,7 @@ void CTerrain::CalcNormal(u32 i, u32 j, CVector3D& normal) const
|
||||
CVector3D n3 = right.Cross(up);
|
||||
|
||||
normal = n0 + n1 + n2 + n3;
|
||||
float nlen=normal.GetLength();
|
||||
float nlen=normal.Length();
|
||||
if (nlen>0.00001f) normal*=1.0f/nlen;
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ CMiniPatch* CTerrain::GetTile(i32 i, i32 j) const
|
||||
return &patch->m_MiniPatches[j%PATCH_SIZE][i%PATCH_SIZE];
|
||||
}
|
||||
|
||||
float CTerrain::getVertexGroundLevel(int i, int j) const
|
||||
float CTerrain::GetVertexGroundLevel(int i, int j) const
|
||||
{
|
||||
if (i < 0)
|
||||
i = 0;
|
||||
@ -208,7 +208,7 @@ float CTerrain::getVertexGroundLevel(int i, int j) const
|
||||
return HEIGHT_SCALE * m_Heightmap[j*m_MapSize + i];
|
||||
}
|
||||
|
||||
float CTerrain::getSlope(float x, float z) const
|
||||
float CTerrain::GetSlope(float x, float z) const
|
||||
{
|
||||
x /= (float)CELL_SIZE;
|
||||
z /= (float)CELL_SIZE;
|
||||
@ -216,8 +216,8 @@ float CTerrain::getSlope(float x, float z) const
|
||||
int xi = (int)floor(x);
|
||||
int zi = (int)floor(z);
|
||||
|
||||
clampCoordToMap(xi);
|
||||
clampCoordToMap(zi);
|
||||
ClampCoordToMap(xi);
|
||||
ClampCoordToMap(zi);
|
||||
|
||||
float h00 = m_Heightmap[zi*m_MapSize + xi];
|
||||
float h01 = m_Heightmap[zi*m_MapSize + xi + m_MapSize];
|
||||
@ -228,7 +228,7 @@ float CTerrain::getSlope(float x, float z) const
|
||||
return std::max(std::max(h00, h01), std::max(h10, h11)) -
|
||||
std::min(std::min(h00, h01), std::min(h10, h11));
|
||||
}
|
||||
CVector2D CTerrain::getSlopeAngleFace( CEntity* entity ) const
|
||||
CVector2D CTerrain::GetSlopeAngleFace( CEntity* entity ) const
|
||||
{
|
||||
CVector2D ret;
|
||||
|
||||
@ -237,19 +237,19 @@ CVector2D CTerrain::getSlopeAngleFace( CEntity* entity ) const
|
||||
float z = entity->m_position.Z;
|
||||
|
||||
// Get forward slope and use it as the x angle
|
||||
CVector2D d = entity->m_ahead.normalize() * D;
|
||||
float dy = getExactGroundLevel(x+d.x, z+d.y) - getExactGroundLevel(x-d.x, z-d.y);
|
||||
CVector2D d = entity->m_ahead.Normalize() * D;
|
||||
float dy = GetExactGroundLevel(x+d.x, z+d.y) - GetExactGroundLevel(x-d.x, z-d.y);
|
||||
ret.x = atan2(dy, 2*D);
|
||||
|
||||
// Get sideways slope and use it as the y angle
|
||||
CVector2D d2(-d.y, d.x);
|
||||
float dy2 = getExactGroundLevel(x+d2.x, z+d2.y) - getExactGroundLevel(x-d2.x, z-d2.y);
|
||||
float dy2 = GetExactGroundLevel(x+d2.x, z+d2.y) - GetExactGroundLevel(x-d2.x, z-d2.y);
|
||||
ret.y = atan2(dy2, 2*D);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
float CTerrain::getExactGroundLevel(float x, float z) const
|
||||
float CTerrain::GetExactGroundLevel(float x, float z) const
|
||||
{
|
||||
x /= (float)CELL_SIZE;
|
||||
z /= (float)CELL_SIZE;
|
||||
|
@ -51,17 +51,17 @@ public:
|
||||
// return number of patches along edge of the terrain
|
||||
u32 GetPatchesPerSide() const { return m_MapSizePatches; }
|
||||
|
||||
bool isOnMap(float x, float z) const
|
||||
bool IsOnMap(float x, float z) const
|
||||
{
|
||||
return ((x >= 0.0f) && (x < (float)((m_MapSize-1) * CELL_SIZE))
|
||||
&& (z >= 0.0f) && (z < (float)((m_MapSize-1) * CELL_SIZE)));
|
||||
}
|
||||
|
||||
bool isOnMap(const CVector2D& v) const;
|
||||
bool IsOnMap(const CVector2D& v) const;
|
||||
|
||||
bool isPassable(const CVector2D& tileSpaceLoc, HEntity entity) const;
|
||||
bool IsPassable(const CVector2D& tileSpaceLoc, HEntity entity) const;
|
||||
|
||||
void clampCoordToMap(int& index) const
|
||||
void ClampCoordToMap(int& index) const
|
||||
{
|
||||
if(index < 0)
|
||||
index = 0;
|
||||
@ -69,13 +69,13 @@ public:
|
||||
index = m_MapSize - 2;
|
||||
}
|
||||
|
||||
float getVertexGroundLevel(int i, int j) const;
|
||||
float getExactGroundLevel(float x, float z) const;
|
||||
float getExactGroundLevel(const CVector2D& v) const;
|
||||
float GetVertexGroundLevel(int i, int j) const;
|
||||
float GetExactGroundLevel(float x, float z) const;
|
||||
float GetExactGroundLevel(const CVector2D& v) const;
|
||||
|
||||
float getSlope(float x, float z) const ;
|
||||
float GetSlope(float x, float z) const ;
|
||||
//Find the slope of in X and Z axes depending on the way the entity is facing
|
||||
CVector2D getSlopeAngleFace(CEntity* entity) const;
|
||||
CVector2D GetSlopeAngleFace(CEntity* entity) const;
|
||||
// resize this terrain such that each side has given number of patches
|
||||
void Resize(u32 size);
|
||||
|
||||
@ -96,14 +96,14 @@ public:
|
||||
// calculate the vertex under a given position (rounding down coordinates)
|
||||
static void CalcFromPosition(const CVector3D& pos, i32& i, i32& j)
|
||||
{
|
||||
i = cpu_i32_from_float(pos.X/CELL_SIZE);
|
||||
j = cpu_i32_from_float(pos.Z/CELL_SIZE);
|
||||
i = cpu_i32FromFloat(pos.X/CELL_SIZE);
|
||||
j = cpu_i32FromFloat(pos.Z/CELL_SIZE);
|
||||
}
|
||||
// calculate the vertex under a given position (rounding down coordinates)
|
||||
static void CalcFromPosition(float x, float z, i32& i, i32& j)
|
||||
{
|
||||
i = cpu_i32_from_float(x/CELL_SIZE);
|
||||
j = cpu_i32_from_float(z/CELL_SIZE);
|
||||
i = cpu_i32FromFloat(x/CELL_SIZE);
|
||||
j = cpu_i32FromFloat(z/CELL_SIZE);
|
||||
}
|
||||
// calculate the normal at a given vertex
|
||||
void CalcNormal(u32 i, u32 j, CVector3D& normal) const;
|
||||
|
@ -33,8 +33,8 @@ CTerrainPropertiesPtr CTerrainProperties::FromXML(CTerrainPropertiesPtr parent,
|
||||
if (XeroFile.Load(path) != PSRETURN_OK)
|
||||
return CTerrainPropertiesPtr();
|
||||
|
||||
XMBElement root = XeroFile.getRoot();
|
||||
CStr rootName = XeroFile.getElementString(root.getNodeName());
|
||||
XMBElement root = XeroFile.GetRoot();
|
||||
CStr rootName = XeroFile.GetElementString(root.GetNodeName());
|
||||
|
||||
// Check that we've got the right kind of xml document
|
||||
if (rootName != "Terrains")
|
||||
@ -47,8 +47,8 @@ CTerrainPropertiesPtr CTerrainProperties::FromXML(CTerrainPropertiesPtr parent,
|
||||
return CTerrainPropertiesPtr();
|
||||
}
|
||||
|
||||
#define ELMT(x) int el_##x = XeroFile.getElementID(#x)
|
||||
#define ATTR(x) int at_##x = XeroFile.getAttributeID(#x)
|
||||
#define ELMT(x) int el_##x = XeroFile.GetElementID(#x)
|
||||
#define ATTR(x) int at_##x = XeroFile.GetAttributeID(#x)
|
||||
ELMT(terrain);
|
||||
#undef ELMT
|
||||
#undef ATTR
|
||||
@ -57,16 +57,16 @@ CTerrainPropertiesPtr CTerrainProperties::FromXML(CTerrainPropertiesPtr parent,
|
||||
// returning it.
|
||||
// Really, we only expect there to be one child and it to be of the right
|
||||
// type, though.
|
||||
XMBElementList children = root.getChildNodes();
|
||||
XMBElementList children = root.GetChildNodes();
|
||||
for (int i=0; i<children.Count; ++i)
|
||||
{
|
||||
//debug_printf("Object %d\n", i);
|
||||
XMBElement child = children.item(i);
|
||||
XMBElement child = children.Item(i);
|
||||
|
||||
if (child.getNodeName() == el_terrain)
|
||||
if (child.GetNodeName() == el_terrain)
|
||||
{
|
||||
CTerrainPropertiesPtr ret (new CTerrainProperties(parent));
|
||||
ret->LoadXML(child, &XeroFile, path);
|
||||
ret->LoadXml(child, &XeroFile, path);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
@ -74,7 +74,7 @@ CTerrainPropertiesPtr CTerrainProperties::FromXML(CTerrainPropertiesPtr parent,
|
||||
LOG(WARNING, LOG_CATEGORY,
|
||||
"TerrainProperties: Loading %s: Unexpected node %s\n",
|
||||
path,
|
||||
XeroFile.getElementString(child.getNodeName()).c_str());
|
||||
XeroFile.GetElementString(child.GetNodeName()).c_str());
|
||||
// Keep reading - typos shouldn't be showstoppers
|
||||
}
|
||||
}
|
||||
@ -82,10 +82,10 @@ CTerrainPropertiesPtr CTerrainProperties::FromXML(CTerrainPropertiesPtr parent,
|
||||
return CTerrainPropertiesPtr();
|
||||
}
|
||||
|
||||
void CTerrainProperties::LoadXML(XMBElement node, CXeromyces *pFile, const char *path)
|
||||
void CTerrainProperties::LoadXml(XMBElement node, CXeromyces *pFile, const char *path)
|
||||
{
|
||||
#define ELMT(x) int elmt_##x = pFile->getElementID(#x)
|
||||
#define ATTR(x) int attr_##x = pFile->getAttributeID(#x)
|
||||
#define ELMT(x) int elmt_##x = pFile->GetElementID(#x)
|
||||
#define ATTR(x) int attr_##x = pFile->GetAttributeID(#x)
|
||||
ELMT(doodad);
|
||||
ELMT(passable);
|
||||
ELMT(impassable);
|
||||
@ -110,10 +110,10 @@ void CTerrainProperties::LoadXML(XMBElement node, CXeromyces *pFile, const char
|
||||
UNUSED2(elmt_passable);
|
||||
UNUSED2(elmt_doodad);
|
||||
|
||||
XMBAttributeList attribs = node.getAttributes();
|
||||
XMBAttributeList attribs = node.GetAttributes();
|
||||
for (int i=0;i<attribs.Count;i++)
|
||||
{
|
||||
XMBAttribute attr = attribs.item(i);
|
||||
XMBAttribute attr = attribs.Item(i);
|
||||
|
||||
if (attr.Name == attr_groups)
|
||||
{
|
||||
@ -155,16 +155,16 @@ void CTerrainProperties::LoadXML(XMBElement node, CXeromyces *pFile, const char
|
||||
}
|
||||
}
|
||||
|
||||
XMBElementList children = node.getChildNodes();
|
||||
XMBElementList children = node.GetChildNodes();
|
||||
for (int i=0; i<children.Count; ++i)
|
||||
{
|
||||
XMBElement child = children.item(i);
|
||||
XMBElement child = children.Item(i);
|
||||
|
||||
if (child.getNodeName() == elmt_passable)
|
||||
if (child.GetNodeName() == elmt_passable)
|
||||
{
|
||||
ReadPassability(true, child, pFile, path);
|
||||
}
|
||||
else if (child.getNodeName() == elmt_impassable)
|
||||
else if (child.GetNodeName() == elmt_impassable)
|
||||
{
|
||||
ReadPassability(false, child, pFile, path);
|
||||
}
|
||||
@ -174,7 +174,7 @@ void CTerrainProperties::LoadXML(XMBElement node, CXeromyces *pFile, const char
|
||||
|
||||
void CTerrainProperties::ReadPassability(bool passable, XMBElement node, CXeromyces *pFile, const char *UNUSED(path))
|
||||
{
|
||||
#define ATTR(x) int attr_##x = pFile->getAttributeID(#x)
|
||||
#define ATTR(x) int attr_##x = pFile->GetAttributeID(#x)
|
||||
// Passable Attribs
|
||||
ATTR(type);
|
||||
ATTR(speed);
|
||||
@ -185,10 +185,10 @@ void CTerrainProperties::ReadPassability(bool passable, XMBElement node, CXeromy
|
||||
STerrainPassability pass(passable);
|
||||
bool hasType = false;
|
||||
bool hasSpeed;
|
||||
XMBAttributeList attribs = node.getAttributes();
|
||||
XMBAttributeList attribs = node.GetAttributes();
|
||||
for (int i=0;i<attribs.Count;i++)
|
||||
{
|
||||
XMBAttribute attr = attribs.item(i);
|
||||
XMBAttribute attr = attribs.Item(i);
|
||||
|
||||
if (attr.Name == attr_type)
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ private:
|
||||
std::vector<STerrainPassability> m_Passabilities;
|
||||
|
||||
void ReadPassability(bool passable, XMBElement node, CXeromyces *pFile, const char *path);
|
||||
void LoadXML(XMBElement node, CXeromyces *pFile, const char *path);
|
||||
void LoadXml(XMBElement node, CXeromyces *pFile, const char *path);
|
||||
|
||||
public:
|
||||
CTerrainProperties(CTerrainPropertiesPtr parent);
|
||||
|
@ -112,7 +112,7 @@ CUnit* CUnitManager::PickUnit(const CVector3D& origin, const CVector3D& dir, boo
|
||||
CVector3D closest = origin + dir * distance;
|
||||
CVector3D offset = obj - closest;
|
||||
|
||||
float rel = offset.GetLength();
|
||||
float rel = offset.Length();
|
||||
if (rel < minrel) {
|
||||
hit = unit;
|
||||
dist = tmin;
|
||||
|
@ -1040,7 +1040,7 @@ void CGUI::ReportParseError(const char *str, ...)
|
||||
/**
|
||||
* @callgraph
|
||||
*/
|
||||
void CGUI::LoadXMLFile(const string &Filename)
|
||||
void CGUI::LoadXmlFile(const string &Filename)
|
||||
{
|
||||
// Reset parse error
|
||||
// we can later check if this has increased
|
||||
@ -1051,11 +1051,11 @@ void CGUI::LoadXMLFile(const string &Filename)
|
||||
// Fail silently
|
||||
return;
|
||||
|
||||
XMBElement node = XeroFile.getRoot();
|
||||
XMBElement node = XeroFile.GetRoot();
|
||||
|
||||
// Check root element's (node) name so we know what kind of
|
||||
// data we'll be expecting
|
||||
CStr root_name (XeroFile.getElementString(node.getNodeName()));
|
||||
CStr root_name (XeroFile.GetElementString(node.GetNodeName()));
|
||||
|
||||
try
|
||||
{
|
||||
@ -1084,7 +1084,7 @@ void CGUI::LoadXMLFile(const string &Filename)
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_warn("CGUI::LoadXMLFile error");
|
||||
debug_warn("CGUI::LoadXmlFile error");
|
||||
// TODO Gee: Output in log
|
||||
}
|
||||
}
|
||||
@ -1108,17 +1108,17 @@ void CGUI::LoadXMLFile(const string &Filename)
|
||||
|
||||
void CGUI::Xeromyces_ReadRootObjects(XMBElement Element, CXeromyces* pFile)
|
||||
{
|
||||
int el_script = pFile->getElementID("script");
|
||||
int el_script = pFile->GetElementID("script");
|
||||
|
||||
// Iterate main children
|
||||
// they should all be <object> or <script> elements
|
||||
XMBElementList children = Element.getChildNodes();
|
||||
XMBElementList children = Element.GetChildNodes();
|
||||
for (int i=0; i<children.Count; ++i)
|
||||
{
|
||||
//debug_printf("Object %d\n", i);
|
||||
XMBElement child = children.item(i);
|
||||
XMBElement child = children.Item(i);
|
||||
|
||||
if (child.getNodeName() == el_script)
|
||||
if (child.GetNodeName() == el_script)
|
||||
// Execute the inline script
|
||||
Xeromyces_ReadScript(child, pFile);
|
||||
else
|
||||
@ -1131,10 +1131,10 @@ void CGUI::Xeromyces_ReadRootSprites(XMBElement Element, CXeromyces* pFile)
|
||||
{
|
||||
// Iterate main children
|
||||
// they should all be <sprite> elements
|
||||
XMBElementList children = Element.getChildNodes();
|
||||
XMBElementList children = Element.GetChildNodes();
|
||||
for (int i=0; i<children.Count; ++i)
|
||||
{
|
||||
XMBElement child = children.item(i);
|
||||
XMBElement child = children.Item(i);
|
||||
|
||||
// Read in this whole object into the GUI
|
||||
Xeromyces_ReadSprite(child, pFile);
|
||||
@ -1145,10 +1145,10 @@ void CGUI::Xeromyces_ReadRootStyles(XMBElement Element, CXeromyces* pFile)
|
||||
{
|
||||
// Iterate main children
|
||||
// they should all be <styles> elements
|
||||
XMBElementList children = Element.getChildNodes();
|
||||
XMBElementList children = Element.GetChildNodes();
|
||||
for (int i=0; i<children.Count; ++i)
|
||||
{
|
||||
XMBElement child = children.item(i);
|
||||
XMBElement child = children.Item(i);
|
||||
|
||||
// Read in this whole object into the GUI
|
||||
Xeromyces_ReadStyle(child, pFile);
|
||||
@ -1159,14 +1159,14 @@ void CGUI::Xeromyces_ReadRootSetup(XMBElement Element, CXeromyces* pFile)
|
||||
{
|
||||
// Iterate main children
|
||||
// they should all be <icon>, <scrollbar> or <tooltip>.
|
||||
XMBElementList children = Element.getChildNodes();
|
||||
XMBElementList children = Element.GetChildNodes();
|
||||
for (int i=0; i<children.Count; ++i)
|
||||
{
|
||||
XMBElement child = children.item(i);
|
||||
XMBElement child = children.Item(i);
|
||||
|
||||
// Read in this whole object into the GUI
|
||||
|
||||
CStr name (pFile->getElementString(child.getNodeName()));
|
||||
CStr name (pFile->GetElementString(child.GetNodeName()));
|
||||
|
||||
if (name == "scrollbar")
|
||||
{
|
||||
@ -1202,10 +1202,10 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
// Our object we are going to create
|
||||
IGUIObject *object = NULL;
|
||||
|
||||
XMBAttributeList attributes = Element.getAttributes();
|
||||
XMBAttributeList attributes = Element.GetAttributes();
|
||||
|
||||
// Well first of all we need to determine the type
|
||||
CStr type (attributes.getNamedItem(pFile->getAttributeID("type")));
|
||||
CStr type (attributes.GetNamedItem(pFile->GetAttributeID("type")));
|
||||
|
||||
// Construct object from specified type
|
||||
// henceforth, we need to do a rollback before aborting.
|
||||
@ -1220,8 +1220,8 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
}
|
||||
|
||||
// Cache some IDs for element attribute names, to avoid string comparisons
|
||||
#define ELMT(x) int elmt_##x = pFile->getElementID(#x)
|
||||
#define ATTR(x) int attr_##x = pFile->getAttributeID(#x)
|
||||
#define ELMT(x) int elmt_##x = pFile->GetElementID(#x)
|
||||
#define ATTR(x) int attr_##x = pFile->GetAttributeID(#x)
|
||||
ELMT(object);
|
||||
ELMT(action);
|
||||
ATTR(style);
|
||||
@ -1239,7 +1239,7 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
//
|
||||
// Always load default (if it's available) first!
|
||||
//
|
||||
CStr argStyle (attributes.getNamedItem(attr_style));
|
||||
CStr argStyle (attributes.GetNamedItem(attr_style));
|
||||
|
||||
if (m_Styles.count("default") == 1)
|
||||
object->LoadStyle(*this, "default");
|
||||
@ -1267,7 +1267,7 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
// Now we can iterate all attributes and store
|
||||
for (i=0; i<attributes.Count; ++i)
|
||||
{
|
||||
XMBAttribute attr = attributes.item(i);
|
||||
XMBAttribute attr = attributes.Item(i);
|
||||
|
||||
// If value is "null", then it is equivalent as never being entered
|
||||
if ((CStr)attr.Value == "null")
|
||||
@ -1293,9 +1293,9 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
ManuallySetZ = true;
|
||||
|
||||
// Try setting the value
|
||||
if (object->SetSetting(pFile->getAttributeString(attr.Name), (CStr)attr.Value, true) != PS_OK)
|
||||
if (object->SetSetting(pFile->GetAttributeString(attr.Name), (CStr)attr.Value, true) != PS_OK)
|
||||
{
|
||||
ReportParseError("(object: %s) Can't set \"%s\" to \"%s\"", object->GetPresentableName().c_str(), pFile->getAttributeString(attr.Name).c_str(), CStr(attr.Value).c_str());
|
||||
ReportParseError("(object: %s) Can't set \"%s\" to \"%s\"", object->GetPresentableName().c_str(), pFile->GetAttributeString(attr.Name).c_str(), CStr(attr.Value).c_str());
|
||||
|
||||
// This is not a fatal error
|
||||
}
|
||||
@ -1310,9 +1310,9 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
|
||||
// Attempt to register the hotkey tag, if one was provided
|
||||
if (! hotkeyTag.empty())
|
||||
hotkeyRegisterGUIObject(object->GetName(), hotkeyTag);
|
||||
HotkeyRegisterGuiObject(object->GetName(), hotkeyTag);
|
||||
|
||||
CStrW caption (Element.getText());
|
||||
CStrW caption (Element.GetText());
|
||||
if (! caption.empty())
|
||||
{
|
||||
// Set the setting caption to this
|
||||
@ -1327,15 +1327,15 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
//
|
||||
|
||||
// Iterate children
|
||||
XMBElementList children = Element.getChildNodes();
|
||||
XMBElementList children = Element.GetChildNodes();
|
||||
|
||||
for (i=0; i<children.Count; ++i)
|
||||
{
|
||||
// Get node
|
||||
XMBElement child = children.item(i);
|
||||
XMBElement child = children.Item(i);
|
||||
|
||||
// Check what name the elements got
|
||||
int element_name = child.getNodeName();
|
||||
int element_name = child.GetNodeName();
|
||||
|
||||
if (element_name == elmt_object)
|
||||
{
|
||||
@ -1347,7 +1347,7 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
// Scripted <action> element
|
||||
|
||||
// Check for a 'file' parameter
|
||||
CStr file (child.getAttributes().getNamedItem(attr_file));
|
||||
CStr file (child.GetAttributes().GetNamedItem(attr_file));
|
||||
|
||||
CStr code;
|
||||
|
||||
@ -1365,9 +1365,9 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
}
|
||||
|
||||
// Read the inline code (concatenating to the file code, if both are specified)
|
||||
code += (CStr)child.getText();
|
||||
code += (CStr)child.GetText();
|
||||
|
||||
CStr action = (CStr)child.getAttributes().getNamedItem(attr_on);
|
||||
CStr action = (CStr)child.GetAttributes().GetNamedItem(attr_on);
|
||||
object->RegisterScriptHandler(action.LowerCase(), code, this);
|
||||
}
|
||||
else
|
||||
@ -1432,16 +1432,16 @@ void CGUI::Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile)
|
||||
{
|
||||
|
||||
// Check for a 'file' parameter
|
||||
CStr file (Element.getAttributes().getNamedItem( pFile->getAttributeID("file") ));
|
||||
CStr file (Element.GetAttributes().GetNamedItem( pFile->GetAttributeID("file") ));
|
||||
|
||||
// If there is a file specified, open and execute it
|
||||
if (! file.empty())
|
||||
g_ScriptingHost.RunScript(file, m_ScriptObject);
|
||||
|
||||
// Execute inline scripts
|
||||
CStr code (Element.getText());
|
||||
CStr code (Element.GetText());
|
||||
if (! code.empty())
|
||||
g_ScriptingHost.RunMemScript(code.c_str(), code.length(), "Some XML file", Element.getLineNumber(), m_ScriptObject);
|
||||
g_ScriptingHost.RunMemScript(code.c_str(), code.length(), "Some XML file", Element.GetLineNumber(), m_ScriptObject);
|
||||
}
|
||||
|
||||
void CGUI::Xeromyces_ReadSprite(XMBElement Element, CXeromyces* pFile)
|
||||
@ -1457,7 +1457,7 @@ void CGUI::Xeromyces_ReadSprite(XMBElement Element, CXeromyces* pFile)
|
||||
//
|
||||
|
||||
// Get name, we know it exists because of DTD requirements
|
||||
name = Element.getAttributes().getNamedItem( pFile->getAttributeID("name") );
|
||||
name = Element.GetAttributes().GetNamedItem( pFile->GetAttributeID("name") );
|
||||
|
||||
if (m_Sprites.find(name) != m_Sprites.end())
|
||||
LOG(WARNING, LOG_CATEGORY, "Sprite name '%s' used more than once; first definition will be discarded", (const char*)name);
|
||||
@ -1469,14 +1469,14 @@ void CGUI::Xeromyces_ReadSprite(XMBElement Element, CXeromyces* pFile)
|
||||
SGUIImageEffects* effects = NULL;
|
||||
|
||||
// Iterate children
|
||||
XMBElementList children = Element.getChildNodes();
|
||||
XMBElementList children = Element.GetChildNodes();
|
||||
|
||||
for (int i=0; i<children.Count; ++i)
|
||||
{
|
||||
// Get node
|
||||
XMBElement child = children.item(i);
|
||||
XMBElement child = children.Item(i);
|
||||
|
||||
CStr ElementName (pFile->getElementString(child.getNodeName()));
|
||||
CStr ElementName (pFile->GetElementString(child.GetNodeName()));
|
||||
|
||||
if (ElementName == "image")
|
||||
{
|
||||
@ -1527,11 +1527,11 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite
|
||||
//
|
||||
|
||||
// Now we can iterate all attributes and store
|
||||
XMBAttributeList attributes = Element.getAttributes();
|
||||
XMBAttributeList attributes = Element.GetAttributes();
|
||||
for (int i=0; i<attributes.Count; ++i)
|
||||
{
|
||||
XMBAttribute attr = attributes.item(i);
|
||||
CStr attr_name (pFile->getAttributeString(attr.Name));
|
||||
XMBAttribute attr = attributes.Item(i);
|
||||
CStr attr_name (pFile->GetAttributeString(attr.Name));
|
||||
CStr attr_value (attr.Value);
|
||||
|
||||
if (attr_name == "texture")
|
||||
@ -1612,11 +1612,11 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite
|
||||
}
|
||||
|
||||
// Look for effects
|
||||
XMBElementList children = Element.getChildNodes();
|
||||
XMBElementList children = Element.GetChildNodes();
|
||||
for (int i=0; i<children.Count; ++i)
|
||||
{
|
||||
XMBElement child = children.item(i);
|
||||
CStr ElementName (pFile->getElementString(child.getNodeName()));
|
||||
XMBElement child = children.Item(i);
|
||||
CStr ElementName (pFile->GetElementString(child.GetNodeName()));
|
||||
if (ElementName == "effect")
|
||||
{
|
||||
debug_assert(! image.m_Effects); // DTD should only allow one effect per sprite
|
||||
@ -1638,11 +1638,11 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite
|
||||
|
||||
void CGUI::Xeromyces_ReadEffects(XMBElement Element, CXeromyces* pFile, SGUIImageEffects &effects)
|
||||
{
|
||||
XMBAttributeList attributes = Element.getAttributes();
|
||||
XMBAttributeList attributes = Element.GetAttributes();
|
||||
for (int i=0; i<attributes.Count; ++i)
|
||||
{
|
||||
XMBAttribute attr = attributes.item(i);
|
||||
CStr attr_name (pFile->getAttributeString(attr.Name));
|
||||
XMBAttribute attr = attributes.Item(i);
|
||||
CStr attr_name (pFile->GetAttributeString(attr.Name));
|
||||
CStr attr_value (attr.Value);
|
||||
|
||||
#define COLOR(xml, mem, alpha) \
|
||||
@ -1684,11 +1684,11 @@ void CGUI::Xeromyces_ReadStyle(XMBElement Element, CXeromyces* pFile)
|
||||
//
|
||||
|
||||
// Now we can iterate all attributes and store
|
||||
XMBAttributeList attributes = Element.getAttributes();
|
||||
XMBAttributeList attributes = Element.GetAttributes();
|
||||
for (int i=0; i<attributes.Count; ++i)
|
||||
{
|
||||
XMBAttribute attr = attributes.item(i);
|
||||
CStr attr_name (pFile->getAttributeString(attr.Name));
|
||||
XMBAttribute attr = attributes.Item(i);
|
||||
CStr attr_name (pFile->GetAttributeString(attr.Name));
|
||||
CStr attr_value (attr.Value);
|
||||
|
||||
// The "name" setting is actually the name of the style
|
||||
@ -1717,11 +1717,11 @@ void CGUI::Xeromyces_ReadScrollBarStyle(XMBElement Element, CXeromyces* pFile)
|
||||
//
|
||||
|
||||
// Now we can iterate all attributes and store
|
||||
XMBAttributeList attributes = Element.getAttributes();
|
||||
XMBAttributeList attributes = Element.GetAttributes();
|
||||
for (int i=0; i<attributes.Count; ++i)
|
||||
{
|
||||
XMBAttribute attr = attributes.item(i);
|
||||
CStr attr_name = pFile->getAttributeString(attr.Name);
|
||||
XMBAttribute attr = attributes.Item(i);
|
||||
CStr attr_name = pFile->GetAttributeString(attr.Name);
|
||||
CStr attr_value (attr.Value);
|
||||
|
||||
if (attr_value == "null")
|
||||
@ -1800,11 +1800,11 @@ void CGUI::Xeromyces_ReadIcon(XMBElement Element, CXeromyces* pFile)
|
||||
SGUIIcon icon;
|
||||
CStr name;
|
||||
|
||||
XMBAttributeList attributes = Element.getAttributes();
|
||||
XMBAttributeList attributes = Element.GetAttributes();
|
||||
for (int i=0; i<attributes.Count; ++i)
|
||||
{
|
||||
XMBAttribute attr = attributes.item(i);
|
||||
CStr attr_name (pFile->getAttributeString(attr.Name));
|
||||
XMBAttribute attr = attributes.Item(i);
|
||||
CStr attr_name (pFile->GetAttributeString(attr.Name));
|
||||
CStr attr_value (attr.Value);
|
||||
|
||||
if (attr_value == "null")
|
||||
@ -1846,11 +1846,11 @@ void CGUI::Xeromyces_ReadTooltip(XMBElement Element, CXeromyces* pFile)
|
||||
|
||||
IGUIObject* object = new CTooltip;
|
||||
|
||||
XMBAttributeList attributes = Element.getAttributes();
|
||||
XMBAttributeList attributes = Element.GetAttributes();
|
||||
for (int i=0; i<attributes.Count; ++i)
|
||||
{
|
||||
XMBAttribute attr = attributes.item(i);
|
||||
CStr attr_name (pFile->getAttributeString(attr.Name));
|
||||
XMBAttribute attr = attributes.Item(i);
|
||||
CStr attr_name (pFile->GetAttributeString(attr.Name));
|
||||
CStr attr_value (attr.Value);
|
||||
|
||||
if (attr_name == "name")
|
||||
@ -1871,14 +1871,14 @@ void CGUI::Xeromyces_ReadColor(XMBElement Element, CXeromyces* pFile)
|
||||
{
|
||||
// Read the color and stor in m_PreDefinedColors
|
||||
|
||||
XMBAttributeList attributes = Element.getAttributes();
|
||||
XMBAttributeList attributes = Element.GetAttributes();
|
||||
|
||||
//IGUIObject* object = new CTooltip;
|
||||
CColor color;
|
||||
CStr name = attributes.getNamedItem(pFile->getAttributeID("name"));
|
||||
CStr name = attributes.GetNamedItem(pFile->GetAttributeID("name"));
|
||||
|
||||
// Try parsing value
|
||||
CStr value (Element.getText());
|
||||
CStr value (Element.GetText());
|
||||
if (! value.empty())
|
||||
{
|
||||
// Try setting color to value
|
||||
|
@ -172,7 +172,7 @@ public:
|
||||
*
|
||||
* @param Filename Name of file
|
||||
*/
|
||||
void LoadXMLFile(const std::string &Filename);
|
||||
void LoadXmlFile(const std::string &Filename);
|
||||
|
||||
/**
|
||||
* Checks if object exists and return true or false accordingly
|
||||
@ -371,7 +371,7 @@ private:
|
||||
* the objects-tag.
|
||||
* @param pFile The Xeromyces object for the file being read
|
||||
*
|
||||
* @see LoadXMLFile()
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadRootObjects(XMBElement Element, CXeromyces* pFile);
|
||||
|
||||
@ -382,7 +382,7 @@ private:
|
||||
* the sprites-tag.
|
||||
* @param pFile The Xeromyces object for the file being read
|
||||
*
|
||||
* @see LoadXMLFile()
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadRootSprites(XMBElement Element, CXeromyces* pFile);
|
||||
|
||||
@ -393,7 +393,7 @@ private:
|
||||
* the styles-tag.
|
||||
* @param pFile The Xeromyces object for the file being read
|
||||
*
|
||||
* @see LoadXMLFile()
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadRootStyles(XMBElement Element, CXeromyces* pFile);
|
||||
|
||||
@ -404,7 +404,7 @@ private:
|
||||
* the setup-tag.
|
||||
* @param pFile The Xeromyces object for the file being read
|
||||
*
|
||||
* @see LoadXMLFile()
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadRootSetup(XMBElement Element, CXeromyces* pFile);
|
||||
|
||||
@ -428,7 +428,7 @@ private:
|
||||
* @param pFile The Xeromyces object for the file being read
|
||||
* @param pParent Parent to add this object as child in.
|
||||
*
|
||||
* @see LoadXMLFile()
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent);
|
||||
|
||||
@ -440,7 +440,7 @@ private:
|
||||
* the sprite-tag.
|
||||
* @param pFile The Xeromyces object for the file being read
|
||||
*
|
||||
* @see LoadXMLFile()
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile);
|
||||
|
||||
@ -452,7 +452,7 @@ private:
|
||||
* the sprite-tag.
|
||||
* @param pFile The Xeromyces object for the file being read
|
||||
*
|
||||
* @see LoadXMLFile()
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadSprite(XMBElement Element, CXeromyces* pFile);
|
||||
|
||||
@ -465,7 +465,7 @@ private:
|
||||
* @param pFile The Xeromyces object for the file being read
|
||||
* @param parent Parent sprite.
|
||||
*
|
||||
* @see LoadXMLFile()
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite &parent);
|
||||
|
||||
@ -480,7 +480,7 @@ private:
|
||||
* the style-tag.
|
||||
* @param pFile The Xeromyces object for the file being read
|
||||
*
|
||||
* @see LoadXMLFile()
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadStyle(XMBElement Element, CXeromyces* pFile);
|
||||
|
||||
@ -492,7 +492,7 @@ private:
|
||||
* the scrollbar-tag.
|
||||
* @param pFile The Xeromyces object for the file being read
|
||||
*
|
||||
* @see LoadXMLFile()
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadScrollBarStyle(XMBElement Element, CXeromyces* pFile);
|
||||
|
||||
@ -504,7 +504,7 @@ private:
|
||||
* the scrollbar-tag.
|
||||
* @param pFile The Xeromyces object for the file being read
|
||||
*
|
||||
* @see LoadXMLFile()
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadIcon(XMBElement Element, CXeromyces* pFile);
|
||||
|
||||
@ -516,7 +516,7 @@ private:
|
||||
* the scrollbar-tag.
|
||||
* @param pFile The Xeromyces object for the file being read
|
||||
*
|
||||
* @see LoadXMLFile()
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadTooltip(XMBElement Element, CXeromyces* pFile);
|
||||
|
||||
@ -528,7 +528,7 @@ private:
|
||||
* the scrollbar-tag.
|
||||
* @param pFile The Xeromyces object for the file being read
|
||||
*
|
||||
* @see LoadXMLFile()
|
||||
* @see LoadXmlFile()
|
||||
*/
|
||||
void Xeromyces_ReadColor(XMBElement Element, CXeromyces* pFile);
|
||||
|
||||
|
@ -415,11 +415,11 @@ void CList::AddItem(const CStr& str)
|
||||
|
||||
bool CList::HandleAdditionalChildren(const XMBElement& child, CXeromyces* pFile)
|
||||
{
|
||||
int elmt_item = pFile->getElementID("item");
|
||||
int elmt_item = pFile->GetElementID("item");
|
||||
|
||||
if (child.getNodeName() == elmt_item)
|
||||
if (child.GetNodeName() == elmt_item)
|
||||
{
|
||||
AddItem((CStr)child.getText());
|
||||
AddItem((CStr)child.GetText());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ public:
|
||||
// OpenGL error that's raised if they aren't actually present.
|
||||
// Note: higher-level code checks for this extension, but
|
||||
// allows users the choice of continuing even if not present.
|
||||
oglSquelchError(GL_INVALID_ENUM);
|
||||
ogl_SquelchError(GL_INVALID_ENUM);
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||
|
||||
|
@ -141,7 +141,7 @@ void CMiniMap::SetCameraPos()
|
||||
m_Camera->m_Orientation._34+=TransVector.Z;
|
||||
|
||||
//Lock Y coord. No risk of zoom exceeding limit-Y does not increase
|
||||
float Height=MMTerrain->getExactGroundLevel(
|
||||
float Height=MMTerrain->GetExactGroundLevel(
|
||||
m_Camera->m_Orientation._14, m_Camera->m_Orientation._34) + g_YMinOffset;
|
||||
|
||||
if (m_Camera->m_Orientation._24 < Height)
|
||||
@ -400,9 +400,9 @@ void CMiniMap::Draw()
|
||||
if(type==L"Unit" || type==L"Structure" || type==L"Hero") {
|
||||
// Use the player colour
|
||||
const SPlayerColour& colour = entity->GetPlayer()->GetColour();
|
||||
v.r = cpu_i32_from_float(colour.r*255.f);
|
||||
v.g = cpu_i32_from_float(colour.g*255.f);
|
||||
v.b = cpu_i32_from_float(colour.b*255.f);
|
||||
v.r = cpu_i32FromFloat(colour.r*255.f);
|
||||
v.g = cpu_i32FromFloat(colour.g*255.f);
|
||||
v.b = cpu_i32FromFloat(colour.b*255.f);
|
||||
v.a = 255;
|
||||
}
|
||||
else {
|
||||
@ -494,10 +494,10 @@ void CMiniMap::RebuildTerrainTexture()
|
||||
u32 *dataPtr = m_TerrainData + ((y + j) * (m_MapSize - 1)) + x;
|
||||
for(u32 i = 0; i < w; i++)
|
||||
{
|
||||
float avgHeight = ( m_Terrain->getVertexGroundLevel((int)i, (int)j)
|
||||
+ m_Terrain->getVertexGroundLevel((int)i+1, (int)j)
|
||||
+ m_Terrain->getVertexGroundLevel((int)i, (int)j+1)
|
||||
+ m_Terrain->getVertexGroundLevel((int)i+1, (int)j+1)
|
||||
float avgHeight = ( m_Terrain->GetVertexGroundLevel((int)i, (int)j)
|
||||
+ m_Terrain->GetVertexGroundLevel((int)i+1, (int)j)
|
||||
+ m_Terrain->GetVertexGroundLevel((int)i, (int)j+1)
|
||||
+ m_Terrain->GetVertexGroundLevel((int)i+1, (int)j+1)
|
||||
) / 4.0f;
|
||||
|
||||
if(avgHeight < waterHeight)
|
||||
|
@ -55,6 +55,12 @@
|
||||
# define CONFIG_RETURN64_EDX_EAX 1
|
||||
#endif
|
||||
|
||||
// allow use of RDTSC for raw tick counts (otherwise, the slower but
|
||||
// more reliable on MP systems wall-clock will be used).
|
||||
#ifndef CONFIG_TIMER_ALLOW_RDTSC
|
||||
# define CONFIG_TIMER_ALLOW_RDTSC 1
|
||||
#endif
|
||||
|
||||
// this enables/disables the actual checking done by OverrunProtector-s
|
||||
// (quite slow, entailing mprotect() before/after each access).
|
||||
// define to 1 here or in the relevant module if you suspect mem corruption.
|
||||
|
@ -174,7 +174,7 @@ static Descriptor* DescAlloc()
|
||||
{
|
||||
desc = (Descriptor*)AllocNewSB(DESCSBSIZE);
|
||||
// organize descriptors in a linked list
|
||||
cpu_mfence();
|
||||
cpu_MemoryFence();
|
||||
if(CAS(&DescAvail, 0, desc->next))
|
||||
break;
|
||||
FreeSB((u8*)desc);
|
||||
@ -190,7 +190,7 @@ static void DescRetire(Descriptor* desc)
|
||||
{
|
||||
old_head = DescAvail;
|
||||
desc->next = old_head;
|
||||
cpu_mfence();
|
||||
cpu_MemoryFence();
|
||||
}
|
||||
while(!CAS(&DescAvail, old_head, desc));
|
||||
}
|
||||
@ -385,7 +385,7 @@ static void* MallocFromNewSB(ProcHeap* heap)
|
||||
new_active.credits = MIN(desc->maxcount-1, MAX_CREDITS)-1;
|
||||
desc->anchor.count = (desc->maxcount-1)-(new_active.credits+1);
|
||||
desc->anchor.state = ACTIVE;
|
||||
cpu_mfence();
|
||||
cpu_MemoryFence();
|
||||
if(!CAS(&heap->active, 0, new_active))
|
||||
{
|
||||
FreeSB(desc->sb);
|
||||
@ -464,7 +464,7 @@ void lf_free(void* p_)
|
||||
}
|
||||
else
|
||||
new_anchor.count++;
|
||||
cpu_mfence();
|
||||
cpu_MemoryFence();
|
||||
}
|
||||
while(!CAS(&desc->anchor, old_anchor, new_anchor));
|
||||
if(new_anchor.state == EMPTY)
|
||||
|
@ -64,11 +64,11 @@ static const size_t MAX_RETIRED = 11;
|
||||
|
||||
|
||||
// used to allocate a flat array of all hazard pointers.
|
||||
// changed via cpu_atomic_add by TLS when a thread first calls us / exits.
|
||||
// changed via cpu_AtomicAdd by TLS when a thread first calls us / exits.
|
||||
static intptr_t active_threads;
|
||||
|
||||
// basically module refcount; we can't shut down before it's 0.
|
||||
// changed via cpu_atomic_add by each data structure's init/free.
|
||||
// changed via cpu_AtomicAdd by each data structure's init/free.
|
||||
static intptr_t active_data_structures;
|
||||
|
||||
|
||||
@ -143,7 +143,7 @@ static void tls_retire(void* tls_)
|
||||
// successfully marked as unused (must only decrement once)
|
||||
if(CAS(&tls->active, 1, 0))
|
||||
{
|
||||
cpu_atomic_add(&active_threads, -1);
|
||||
cpu_AtomicAdd(&active_threads, -1);
|
||||
debug_assert(active_threads >= 0);
|
||||
}
|
||||
}
|
||||
@ -224,7 +224,7 @@ static TLS* tls_alloc()
|
||||
|
||||
|
||||
have_tls:
|
||||
cpu_atomic_add(&active_threads, 1);
|
||||
cpu_AtomicAdd(&active_threads, 1);
|
||||
|
||||
WARN_ERR(pthread_setspecific(tls_key, tls));
|
||||
return tls;
|
||||
@ -460,7 +460,7 @@ LibError lfl_init(LFList* list)
|
||||
}
|
||||
|
||||
list->head = 0;
|
||||
cpu_atomic_add(&active_data_structures, 1);
|
||||
cpu_AtomicAdd(&active_data_structures, 1);
|
||||
return INFO::OK;
|
||||
}
|
||||
|
||||
@ -479,7 +479,7 @@ void lfl_free(LFList* list)
|
||||
cur = next;
|
||||
}
|
||||
|
||||
cpu_atomic_add(&active_data_structures, -1);
|
||||
cpu_AtomicAdd(&active_data_structures, -1);
|
||||
debug_assert(active_data_structures >= 0);
|
||||
smr_try_shutdown();
|
||||
}
|
||||
|
@ -64,9 +64,9 @@ static bool have_20, have_14, have_13, have_12;
|
||||
// return a C string of unspecified length containing a space-separated
|
||||
// list of all extensions the OpenGL implementation advertises.
|
||||
// (useful for crash logs).
|
||||
const char* oglExtList()
|
||||
const char* ogl_ExtensionString()
|
||||
{
|
||||
debug_assert(exts && "call oglInit before using this function");
|
||||
debug_assert(exts && "call ogl_Init before using this function");
|
||||
return exts;
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ const char* oglExtList()
|
||||
// paranoia: newer drivers may forget to advertise an extension
|
||||
// indicating support for something that has been folded into the core.
|
||||
// we therefore check for all extensions known to be offered by the
|
||||
// GL implementation present on the user's system; oglHaveExtension will
|
||||
// GL implementation present on the user's system; ogl_HaveExtension will
|
||||
// take this into account.
|
||||
// the app can therefore just ask for extensions and not worry about this.
|
||||
static bool isImplementedInCore(const char* ext)
|
||||
@ -140,9 +140,9 @@ static bool isImplementedInCore(const char* ext)
|
||||
|
||||
// check if the extension <ext> is supported by the OpenGL implementation.
|
||||
// takes subsequently added core support for some extensions into account.
|
||||
bool oglHaveExtension(const char* ext)
|
||||
bool ogl_HaveExtension(const char* ext)
|
||||
{
|
||||
debug_assert(exts && "call oglInit before using this function");
|
||||
debug_assert(exts && "call ogl_Init before using this function");
|
||||
|
||||
if(isImplementedInCore(ext))
|
||||
return true;
|
||||
@ -172,7 +172,7 @@ bool oglHaveExtension(const char* ext)
|
||||
|
||||
// check if the OpenGL implementation is at least at <version>.
|
||||
// (format: "%d.%d" major minor)
|
||||
bool oglHaveVersion(const char* desired_version)
|
||||
bool ogl_HaveVersion(const char* desired_version)
|
||||
{
|
||||
int desired_major, desired_minor;
|
||||
if(sscanf(desired_version, "%d.%d", &desired_major, &desired_minor) != 2)
|
||||
@ -196,7 +196,7 @@ bool oglHaveVersion(const char* desired_version)
|
||||
|
||||
// check if all given extension strings (passed as const char* parameters,
|
||||
// terminated by a 0 pointer) are supported by the OpenGL implementation,
|
||||
// as determined by oglHaveExtension.
|
||||
// as determined by ogl_HaveExtension.
|
||||
// returns 0 if all are present; otherwise, the first extension in the
|
||||
// list that's not supported (useful for reporting errors).
|
||||
//
|
||||
@ -204,7 +204,7 @@ bool oglHaveVersion(const char* desired_version)
|
||||
//
|
||||
//
|
||||
// rationale: this interface is more convenient than individual
|
||||
// oglHaveExtension calls and allows reporting which extension is missing.
|
||||
// ogl_HaveExtension calls and allows reporting which extension is missing.
|
||||
//
|
||||
// one disadvantage is that there is no way to indicate that either one
|
||||
// of 2 extensions would be acceptable, e.g. (ARB|EXT)_texture_env_dot3.
|
||||
@ -212,7 +212,7 @@ bool oglHaveVersion(const char* desired_version)
|
||||
// if there weren't non-trivial changes between them. for that reason,
|
||||
// we refrain from equivalence checks (which would boil down to
|
||||
// string-matching known extensions to their equivalents).
|
||||
const char* oglHaveExtensions(int dummy, ...)
|
||||
const char* ogl_HaveExtensions(int dummy, ...)
|
||||
{
|
||||
const char* ext;
|
||||
|
||||
@ -226,7 +226,7 @@ const char* oglHaveExtensions(int dummy, ...)
|
||||
break;
|
||||
|
||||
// not found => return name of missing extension.
|
||||
if(!oglHaveExtension(ext))
|
||||
if(!ogl_HaveExtension(ext))
|
||||
break;
|
||||
}
|
||||
va_end(args);
|
||||
@ -240,12 +240,12 @@ static void importExtensionFunctions()
|
||||
// It should be safe to load the ARB function pointers even if the
|
||||
// extension isn't advertised, since we won't actually use them without
|
||||
// checking for the extension.
|
||||
// (TODO: this calls oglHaveVersion far more times than is necessary -
|
||||
// (TODO: this calls ogl_HaveVersion far more times than is necessary -
|
||||
// we should probably use the have_* variables instead)
|
||||
#define FUNC(ret, name, params) *(void**)&p##name = SDL_GL_GetProcAddress(#name);
|
||||
#define FUNC2(ret, nameARB, nameCore, version, params) \
|
||||
p##nameARB = NULL; \
|
||||
if(oglHaveVersion(version)) \
|
||||
if(ogl_HaveVersion(version)) \
|
||||
*(void**)&p##nameARB = SDL_GL_GetProcAddress(#nameCore); \
|
||||
if(!p##nameARB) /* use the ARB name if the driver lied about what version it supports */ \
|
||||
*(void**)&p##nameARB = SDL_GL_GetProcAddress(#nameARB);
|
||||
@ -275,9 +275,9 @@ static void dump_gl_error(GLenum err)
|
||||
#undef E
|
||||
}
|
||||
|
||||
#ifndef oglCheck
|
||||
#ifndef ogl_WarnIfError
|
||||
// don't include this function if it has been defined (in ogl.h) as a no-op
|
||||
void oglCheck()
|
||||
void ogl_WarnIfError()
|
||||
{
|
||||
// glGetError may return multiple errors, so we poll it in a loop.
|
||||
// the debug_warn should only happen once (if this is set), though.
|
||||
@ -308,12 +308,12 @@ void oglCheck()
|
||||
|
||||
|
||||
// ignore and reset the specified error (as returned by glGetError).
|
||||
// any other errors that have occurred are reported as oglCheck would.
|
||||
// any other errors that have occurred are reported as ogl_WarnIfError would.
|
||||
//
|
||||
// this is useful for suppressing annoying error messages, e.g.
|
||||
// "invalid enum" for GL_CLAMP_TO_EDGE even though we've already
|
||||
// warned the user that their OpenGL implementation is too old.
|
||||
void oglSquelchError(GLenum err_to_ignore)
|
||||
void ogl_SquelchError(GLenum err_to_ignore)
|
||||
{
|
||||
// glGetError may return multiple errors, so we poll it in a loop.
|
||||
// the debug_warn should only happen once (if this is set), though.
|
||||
@ -378,7 +378,7 @@ LibError ogl_get_gfx_info()
|
||||
|
||||
// call after each video mode change, since thereafter extension functions
|
||||
// may have changed [address].
|
||||
void oglInit()
|
||||
void ogl_Init()
|
||||
{
|
||||
// cache extension list and versions for oglHave*.
|
||||
// note: this is less about performance (since the above are not
|
||||
@ -386,10 +386,10 @@ void oglInit()
|
||||
exts = (const char*)glGetString(GL_EXTENSIONS);
|
||||
if(!exts)
|
||||
debug_warn("called before OpenGL is ready for use");
|
||||
have_12 = oglHaveVersion("1.2");
|
||||
have_13 = oglHaveVersion("1.3");
|
||||
have_14 = oglHaveVersion("1.4");
|
||||
have_20 = oglHaveVersion("2.0");
|
||||
have_12 = ogl_HaveVersion("1.2");
|
||||
have_13 = ogl_HaveVersion("1.3");
|
||||
have_14 = ogl_HaveVersion("1.4");
|
||||
have_20 = ogl_HaveVersion("2.0");
|
||||
|
||||
importExtensionFunctions();
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef __OGL_H__
|
||||
#define __OGL_H__
|
||||
#ifndef INCLUDED_OGL
|
||||
#define INCLUDED_OGL
|
||||
|
||||
#if OS_WIN
|
||||
// wgl.h is a private header and should only be included from here.
|
||||
@ -67,9 +67,16 @@
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
/**
|
||||
* initialization: import extension function pointers and do feature detect.
|
||||
* call before using any other function, and after each video mode change.
|
||||
* fails if OpenGL not ready for use.
|
||||
**/
|
||||
extern void ogl_Init(void);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// extensions
|
||||
//
|
||||
|
||||
/**
|
||||
* check if an extension is supported by the OpenGL implementation.
|
||||
@ -80,7 +87,7 @@
|
||||
* @param ext extension string; exact case.
|
||||
* @return bool.
|
||||
**/
|
||||
extern bool oglHaveExtension(const char* ext);
|
||||
extern bool ogl_HaveExtension(const char* ext);
|
||||
|
||||
/**
|
||||
* make sure the OpenGL implementation version matches or is newer than
|
||||
@ -89,11 +96,11 @@ extern bool oglHaveExtension(const char* ext);
|
||||
* @param version version string; format: ("%d.%d", major, minor).
|
||||
* example: "1.2".
|
||||
**/
|
||||
extern bool oglHaveVersion(const char* version);
|
||||
extern bool ogl_HaveVersion(const char* version);
|
||||
|
||||
/**
|
||||
* check if a list of extensions are all supported (as determined by
|
||||
* oglHaveExtension).
|
||||
* ogl_HaveExtension).
|
||||
*
|
||||
* @param dummy value ignored; varargs requires a placeholder.
|
||||
* follow it by a list of const char* extension string parameters,
|
||||
@ -101,7 +108,7 @@ extern bool oglHaveVersion(const char* version);
|
||||
* @return 0 if all are present; otherwise, the first extension in the
|
||||
* list that's not supported (useful for reporting errors).
|
||||
**/
|
||||
extern const char* oglHaveExtensions(int dummy, ...);
|
||||
extern const char* ogl_HaveExtensions(int dummy, ...);
|
||||
|
||||
/**
|
||||
* get a list of all supported extensions.
|
||||
@ -111,8 +118,7 @@ extern const char* oglHaveExtensions(int dummy, ...);
|
||||
* @return read-only C string of unspecified length containing all
|
||||
* advertised extension names, separated by space.
|
||||
**/
|
||||
extern const char* oglExtList(void);
|
||||
|
||||
extern const char* ogl_ExtensionString(void);
|
||||
|
||||
// declare extension function pointers
|
||||
#if OS_WIN
|
||||
@ -128,27 +134,8 @@ extern const char* oglExtList(void);
|
||||
// leave CALL_CONV defined for ogl.cpp
|
||||
|
||||
|
||||
//
|
||||
// implementation limits / feature detect
|
||||
//
|
||||
|
||||
extern GLint ogl_max_tex_size; /// [pixels]
|
||||
extern GLint ogl_max_tex_units; /// limit on GL_TEXTUREn
|
||||
|
||||
/**
|
||||
* set sysdep/gfx.h gfx_card and gfx_drv_ver. called by gfx_detect.
|
||||
*
|
||||
* fails if OpenGL not ready for use.
|
||||
* gfx_card and gfx_drv_ver are unchanged on failure.
|
||||
*
|
||||
* @return LibError
|
||||
**/
|
||||
extern LibError ogl_get_gfx_info(void);
|
||||
|
||||
|
||||
//
|
||||
// misc
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// errors
|
||||
|
||||
/**
|
||||
* raise a warning (break into the debugger) if an OpenGL error is pending.
|
||||
@ -162,9 +149,9 @@ extern LibError ogl_get_gfx_info(void);
|
||||
*
|
||||
* disabled in release mode for efficiency and to avoid annoying errors.
|
||||
**/
|
||||
extern void oglCheck(void);
|
||||
extern void ogl_WarnIfError(void);
|
||||
#ifdef NDEBUG
|
||||
# define oglCheck()
|
||||
# define ogl_WarnIfError()
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -179,14 +166,23 @@ extern void oglCheck(void);
|
||||
*
|
||||
* @param err_to_ignore: one of the glGetError enums.
|
||||
**/
|
||||
extern void oglSquelchError(GLenum err_to_ignore);
|
||||
extern void ogl_SquelchError(GLenum err_to_ignore);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// implementation limits / feature detect
|
||||
|
||||
extern GLint ogl_max_tex_size; /// [pixels]
|
||||
extern GLint ogl_max_tex_units; /// limit on GL_TEXTUREn
|
||||
|
||||
/**
|
||||
* initialization: import extension function pointers and do feature detect.
|
||||
* call before using any of the above, and after each video mode change.
|
||||
* set sysdep/gfx.h gfx_card and gfx_drv_ver. called by gfx_detect.
|
||||
*
|
||||
* fails if OpenGL not ready for use.
|
||||
* gfx_card and gfx_drv_ver are unchanged on failure.
|
||||
*
|
||||
* @return LibError
|
||||
**/
|
||||
extern void oglInit(void);
|
||||
extern LibError ogl_get_gfx_info(void);
|
||||
|
||||
#endif // #ifndef __OGL_H__
|
||||
#endif // #ifndef INCLUDED_OGL
|
||||
|
@ -105,7 +105,7 @@ static LibError Ogl_Shader_reload(Ogl_Shader* shdr, const char* filename, Handle
|
||||
|
||||
RETURN_ERR(vfs_load(filename, file, file_size));
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
shdr->id = pglCreateShaderObjectARB(shdr->type);
|
||||
if (!shdr->id)
|
||||
@ -113,7 +113,7 @@ static LibError Ogl_Shader_reload(Ogl_Shader* shdr, const char* filename, Handle
|
||||
// May be out of memory, but bad shdr->type is also possible.
|
||||
// In any case, checking OpenGL error state will help spot
|
||||
// bad code.
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
err = ERR::SHDR_CREATE;
|
||||
goto fail_fileloaded;
|
||||
@ -145,7 +145,7 @@ static LibError Ogl_Shader_reload(Ogl_Shader* shdr, const char* filename, Handle
|
||||
// errors at the GLSL level does not set OpenGL error state
|
||||
// according to the spec, but this might still prove to be
|
||||
// useful some time.
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
char typenamebuf[32];
|
||||
debug_printf("Failed to compile shader %hs (type %hs)\n",
|
||||
@ -251,11 +251,11 @@ static LibError do_load_shader(
|
||||
Ogl_Program* p, const char* filename, Handle UNUSED(h),
|
||||
const CXeromyces& XeroFile, const XMBElement& Shader)
|
||||
{
|
||||
#define AT(x) int at_##x = XeroFile.getAttributeID(#x)
|
||||
#define AT(x) int at_##x = XeroFile.GetAttributeID(#x)
|
||||
AT(type);
|
||||
#undef AT
|
||||
|
||||
CStr Type = Shader.getAttributes().getNamedItem(at_type);
|
||||
CStr Type = Shader.GetAttributes().GetNamedItem(at_type);
|
||||
|
||||
if (Type.empty())
|
||||
{
|
||||
@ -273,7 +273,7 @@ static LibError do_load_shader(
|
||||
WARN_RETURN(ERR::CORRUPTED);
|
||||
}
|
||||
|
||||
CStr Name = Shader.getText();
|
||||
CStr Name = Shader.GetText();
|
||||
|
||||
if (Name.empty())
|
||||
{
|
||||
@ -302,14 +302,14 @@ static LibError Ogl_Program_reload(Ogl_Program* p, const char* filename, Handle
|
||||
if (p->id)
|
||||
return INFO::OK;
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
p->id = pglCreateProgramObjectARB();
|
||||
if (!p->id)
|
||||
{
|
||||
// The spec doesn't mention any error state that can be set
|
||||
// here, but it may still help spot bad code.
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
WARN_RETURN(ERR::SHDR_CREATE);
|
||||
}
|
||||
@ -319,36 +319,36 @@ static LibError Ogl_Program_reload(Ogl_Program* p, const char* filename, Handle
|
||||
WARN_RETURN(ERR::CORRUPTED); // more informative error message?
|
||||
|
||||
// Define all the elements and attributes used in the XML file
|
||||
#define EL(x) int el_##x = XeroFile.getElementID(#x)
|
||||
#define EL(x) int el_##x = XeroFile.GetElementID(#x)
|
||||
EL(program);
|
||||
EL(shaders);
|
||||
EL(shader);
|
||||
#undef EL
|
||||
|
||||
XMBElement Root = XeroFile.getRoot();
|
||||
XMBElement Root = XeroFile.GetRoot();
|
||||
|
||||
if (Root.getNodeName() != el_program)
|
||||
if (Root.GetNodeName() != el_program)
|
||||
{
|
||||
LOG(ERROR, LOG_CATEGORY, "%hs: XML root was not \"Program\".", filename);
|
||||
WARN_RETURN(ERR::CORRUPTED);
|
||||
}
|
||||
|
||||
XMBElementList RootChildren = Root.getChildNodes();
|
||||
XMBElementList RootChildren = Root.GetChildNodes();
|
||||
|
||||
for(int i = 0; i < RootChildren.Count; ++i)
|
||||
{
|
||||
XMBElement Child = RootChildren.item(i);
|
||||
XMBElement Child = RootChildren.Item(i);
|
||||
|
||||
int ChildName = Child.getNodeName();
|
||||
int ChildName = Child.GetNodeName();
|
||||
if (ChildName == el_shaders)
|
||||
{
|
||||
XMBElementList Shaders = Child.getChildNodes();
|
||||
XMBElementList Shaders = Child.GetChildNodes();
|
||||
|
||||
for(int j = 0; j < Shaders.Count; ++j)
|
||||
{
|
||||
XMBElement Shader = Shaders.item(j);
|
||||
XMBElement Shader = Shaders.Item(j);
|
||||
|
||||
if (Shader.getNodeName() != el_shader)
|
||||
if (Shader.GetNodeName() != el_shader)
|
||||
{
|
||||
LOG(ERROR, LOG_CATEGORY, "%hs: Only \"Shader\" may be child of \"Shaders\".",
|
||||
filename);
|
||||
|
@ -299,7 +299,7 @@ static void state_latch(OglTexState* ots)
|
||||
// if we're using one of the others, we squelch the error that
|
||||
// may have resulted if this GL implementation is old.
|
||||
if(wrap != GL_CLAMP && wrap != GL_REPEAT)
|
||||
oglSquelchError(GL_INVALID_ENUM);
|
||||
ogl_SquelchError(GL_INVALID_ENUM);
|
||||
}
|
||||
|
||||
|
||||
@ -441,7 +441,7 @@ static LibError OglTex_validate(const OglTex* ot)
|
||||
if(w == 0 || h == 0)
|
||||
WARN_RETURN(ERR::_11);
|
||||
// .. greater than max supported tex dimension.
|
||||
// no-op if oglInit not yet called
|
||||
// no-op if ogl_Init not yet called
|
||||
if(w > (GLsizei)ogl_max_tex_size || h > (GLsizei)ogl_max_tex_size)
|
||||
WARN_RETURN(ERR::_12);
|
||||
// .. not power-of-2.
|
||||
@ -658,13 +658,13 @@ static void detect_gl_upload_caps()
|
||||
// "undecided" (if overrides were set before this, they must remain).
|
||||
if(have_auto_mipmap_gen == -1)
|
||||
{
|
||||
have_auto_mipmap_gen = oglHaveExtension("GL_SGIS_generate_mipmap");
|
||||
have_auto_mipmap_gen = ogl_HaveExtension("GL_SGIS_generate_mipmap");
|
||||
}
|
||||
if(have_s3tc == -1)
|
||||
{
|
||||
// note: we don't bother checking for GL_S3_s3tc - it is incompatible
|
||||
// and irrelevant (was never widespread).
|
||||
have_s3tc = oglHaveExtensions(0, "GL_ARB_texture_compression", "GL_EXT_texture_compression_s3tc", 0) == 0;
|
||||
have_s3tc = ogl_HaveExtensions(0, "GL_ARB_texture_compression", "GL_EXT_texture_compression_s3tc", 0) == 0;
|
||||
}
|
||||
|
||||
// allow app hook to make ogl_tex_override calls
|
||||
@ -843,7 +843,7 @@ LibError ogl_tex_upload(const Handle ht, GLenum fmt_ovr, uint q_flags_ovr, GLint
|
||||
if(int_fmt_ovr) ot->int_fmt = int_fmt_ovr;
|
||||
|
||||
// now actually send to OpenGL:
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
{
|
||||
// (note: we know ht is valid due to H_DEREF, but ogl_tex_bind can
|
||||
// fail in debug builds if OglTex.id isn't a valid texture name)
|
||||
@ -857,7 +857,7 @@ LibError ogl_tex_upload(const Handle ht, GLenum fmt_ovr, uint q_flags_ovr, GLint
|
||||
state_latch(&ot->state);
|
||||
upload_impl(t, ot->fmt, ot->int_fmt, levels_to_skip);
|
||||
}
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
ot->flags |= OT_NEED_AUTO_UPLOAD|OT_IS_UPLOADED;
|
||||
|
||||
|
@ -53,55 +53,55 @@ static ModuleInitState module_init_state = MODULE_BEFORE_INIT;
|
||||
#pragma region Accessor functions
|
||||
// prevent other modules from changing the underlying data.
|
||||
|
||||
bool cpu_isModuleInitialized()
|
||||
bool cpu_IsModuleInitialized()
|
||||
{
|
||||
return module_init_state == MODULE_INITIALIZED;
|
||||
}
|
||||
|
||||
const char* cpu_identifierString()
|
||||
const char* cpu_IdentifierString()
|
||||
{
|
||||
#if CPU_IA32
|
||||
return ia32_identifierString();
|
||||
return ia32_IdentifierString();
|
||||
#endif
|
||||
}
|
||||
|
||||
double cpu_clockFrequency()
|
||||
double cpu_ClockFrequency()
|
||||
{
|
||||
#if CPU_IA32
|
||||
return ia32_clockFrequency(); // authoritative, precise
|
||||
return ia32_ClockFrequency(); // authoritative, precise
|
||||
#endif
|
||||
}
|
||||
|
||||
int cpu_numPackages()
|
||||
uint cpu_NumPackages()
|
||||
{
|
||||
#if CPU_IA32
|
||||
return ia32_numPackages();
|
||||
return ia32_NumPackages();
|
||||
#endif
|
||||
}
|
||||
|
||||
int cpu_coresPerPackage()
|
||||
uint cpu_CoresPerPackage()
|
||||
{
|
||||
#if CPU_IA32
|
||||
return ia32_coresPerPackage();
|
||||
return ia32_CoresPerPackage();
|
||||
#endif
|
||||
}
|
||||
|
||||
int cpu_logicalPerCore()
|
||||
uint cpu_LogicalPerCore()
|
||||
{
|
||||
#if CPU_IA32
|
||||
return ia32_logicalPerCore();
|
||||
return ia32_LogicalPerCore();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool cpu_isThrottlingPossible()
|
||||
bool cpu_IsThrottlingPossible()
|
||||
{
|
||||
#if CPU_IA32
|
||||
if(ia32_isThrottlingPossible() == 1)
|
||||
if(ia32_IsThrottlingPossible() == 1)
|
||||
return true;
|
||||
#endif
|
||||
#if OS_WIN
|
||||
if(wcpu_isThrottlingPossible() == 1)
|
||||
if(wcpu_IsThrottlingPossible() == 1)
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
@ -112,13 +112,13 @@ bool cpu_isThrottlingPossible()
|
||||
// memory
|
||||
|
||||
static size_t cpu_page_size = 0;
|
||||
// determined during cpu_init; cleaned up and given in MiB
|
||||
// determined during cpu_Init; cleaned up and given in MiB
|
||||
static size_t cpu_memory_total_mib = 0;
|
||||
|
||||
// System V derived (GNU/Linux, Solaris)
|
||||
#if defined(_SC_AVPHYS_PAGES)
|
||||
|
||||
static int sysconfFromMemType(CpuMemoryIndicators mem_type)
|
||||
static int SysconfFromMemType(CpuMemoryIndicators mem_type)
|
||||
{
|
||||
switch(mem_type)
|
||||
{
|
||||
@ -132,23 +132,23 @@ static int sysconfFromMemType(CpuMemoryIndicators mem_type)
|
||||
|
||||
#endif
|
||||
|
||||
size_t cpu_memorySize(CpuMemoryIndicators mem_type)
|
||||
size_t cpu_MemorySize(CpuMemoryIndicators mem_type)
|
||||
{
|
||||
// quasi-POSIX
|
||||
#if defined(_SC_AVPHYS_PAGES)
|
||||
const int sc_name = sysconfFromMemType(mem_type);
|
||||
const int sc_name = SysconfFromMemType(mem_type);
|
||||
const size_t memory_size = sysconf(sc_name) * cpu_page_size;
|
||||
return memory_size;
|
||||
// BSD / Mac OS X
|
||||
#else
|
||||
return bsd_memorySize(mem_type);
|
||||
return bsd_MemorySize(mem_type);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static size_t calcMemoryTotalMiB()
|
||||
static size_t DetermineMemoryTotalMiB()
|
||||
{
|
||||
size_t memory_total = cpu_memorySize(CPU_MEM_TOTAL);
|
||||
size_t memory_total = cpu_MemorySize(CPU_MEM_TOTAL);
|
||||
const size_t memory_total_pow2 = (size_t)round_up_to_pow2((uint)memory_total);
|
||||
// .. difference too great, just round up to 1 MiB
|
||||
if(memory_total_pow2 - memory_total > 3*MiB)
|
||||
@ -160,7 +160,7 @@ static size_t calcMemoryTotalMiB()
|
||||
return memory_total_mib;
|
||||
}
|
||||
|
||||
size_t cpu_memoryTotalMiB()
|
||||
size_t cpu_MemoryTotalMiB()
|
||||
{
|
||||
return cpu_memory_total_mib;
|
||||
}
|
||||
@ -170,9 +170,9 @@ size_t cpu_memoryTotalMiB()
|
||||
|
||||
#if CPU_IA32
|
||||
|
||||
static void initAndConfigureIA32()
|
||||
static void InitAndConfigureIA32()
|
||||
{
|
||||
ia32_init(); // must come before any use of ia32*
|
||||
ia32_Init(); // must come before any use of ia32*
|
||||
|
||||
ia32_memcpy_init();
|
||||
|
||||
@ -198,18 +198,18 @@ static void initAndConfigureIA32()
|
||||
|
||||
#endif
|
||||
|
||||
void cpu_init()
|
||||
void cpu_Init()
|
||||
{
|
||||
#if CPU_IA32
|
||||
initAndConfigureIA32();
|
||||
InitAndConfigureIA32();
|
||||
#endif
|
||||
|
||||
// memory
|
||||
cpu_page_size = (size_t)sysconf(_SC_PAGESIZE);
|
||||
cpu_memory_total_mib = calcMemoryTotalMiB();
|
||||
cpu_memory_total_mib = DetermineMemoryTotalMiB();
|
||||
|
||||
// must be set before wtime_reset_impl since it queries this flag via
|
||||
// cpu_isModuleInitialized.
|
||||
// cpu_IsModuleInitialized.
|
||||
module_init_state = MODULE_INITIALIZED;
|
||||
|
||||
// HACK: on Windows, the HRT makes its final implementation choice
|
||||
@ -232,24 +232,24 @@ bool cpu_CAS(uintptr_t* location, uintptr_t expected, uintptr_t new_value)
|
||||
#endif
|
||||
}
|
||||
|
||||
void cpu_atomic_add(intptr_t* location, intptr_t increment)
|
||||
void cpu_AtomicAdd(intptr_t* location, intptr_t increment)
|
||||
{
|
||||
#if CPU_IA32
|
||||
return ia32_asm_atomic_add(location, increment);
|
||||
return ia32_asm_AtomicAdd(location, increment);
|
||||
#endif
|
||||
}
|
||||
|
||||
void cpu_mfence()
|
||||
void cpu_MemoryFence()
|
||||
{
|
||||
#if CPU_IA32
|
||||
return ia32_mfence();
|
||||
return ia32_MemoryFence();
|
||||
#endif
|
||||
}
|
||||
|
||||
void cpu_serialize()
|
||||
void cpu_Serialize()
|
||||
{
|
||||
#if CPU_IA32
|
||||
return ia32_serialize();
|
||||
return ia32_Serialize();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -262,36 +262,36 @@ void* cpu_memcpy(void* RESTRICT dst, const void* RESTRICT src, size_t nbytes)
|
||||
#endif
|
||||
}
|
||||
|
||||
LibError cpu_callByEachCPU(CpuCallback cb, void* param)
|
||||
LibError cpu_CallByEachCPU(CpuCallback cb, void* param)
|
||||
{
|
||||
#if OS_WIN
|
||||
return wcpu_callByEachCPU(cb, param);
|
||||
return wcpu_CallByEachCPU(cb, param);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
i32 cpu_i32_from_float(float f)
|
||||
i32 cpu_i32FromFloat(float f)
|
||||
{
|
||||
#if USE_IA32_FLOAT_TO_INT
|
||||
return ia32_asm_i32_from_float(f);
|
||||
return ia32_asm_i32FromFloat(f);
|
||||
#else
|
||||
return (i32)f;
|
||||
#endif
|
||||
}
|
||||
|
||||
i32 cpu_i32_from_double(double d)
|
||||
i32 cpu_i32FromDouble(double d)
|
||||
{
|
||||
#if USE_IA32_FLOAT_TO_INT
|
||||
return ia32_asm_i32_from_double(d);
|
||||
return ia32_asm_i32FromDouble(d);
|
||||
#else
|
||||
return (i32)d;
|
||||
#endif
|
||||
}
|
||||
|
||||
i64 cpu_i64_from_double(double d)
|
||||
i64 cpu_i64FromDouble(double d)
|
||||
{
|
||||
#if USE_IA32_FLOAT_TO_INT
|
||||
return ia32_asm_i64_from_double(d);
|
||||
return ia32_asm_i64FromDouble(d);
|
||||
#else
|
||||
return (i64)d;
|
||||
#endif
|
||||
|
@ -20,8 +20,8 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef CPU_H__
|
||||
#define CPU_H__
|
||||
#ifndef INCLUDED_CPU
|
||||
#define INCLUDED_CPU
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -37,17 +37,17 @@ namespace ERR
|
||||
|
||||
|
||||
// must be called before any of the below accessors.
|
||||
extern void cpu_init(void);
|
||||
extern void cpu_Init(void);
|
||||
|
||||
extern bool cpu_isModuleInitialized();
|
||||
extern bool cpu_IsModuleInitialized();
|
||||
|
||||
|
||||
extern const char* cpu_identifierString();
|
||||
extern double cpu_clockFrequency();
|
||||
extern int cpu_numPackages(); // i.e. sockets
|
||||
extern int cpu_coresPerPackage();
|
||||
extern int cpu_logicalPerCore();
|
||||
extern bool cpu_isThrottlingPossible();
|
||||
extern const char* cpu_IdentifierString();
|
||||
extern double cpu_ClockFrequency();
|
||||
extern uint cpu_NumPackages(); // i.e. sockets
|
||||
extern uint cpu_CoresPerPackage();
|
||||
extern uint cpu_LogicalPerCore();
|
||||
extern bool cpu_IsThrottlingPossible();
|
||||
|
||||
|
||||
//
|
||||
@ -59,11 +59,11 @@ enum CpuMemoryIndicators
|
||||
CPU_MEM_TOTAL, CPU_MEM_AVAILABLE
|
||||
};
|
||||
|
||||
extern size_t cpu_memorySize(CpuMemoryIndicators mem_type);
|
||||
extern size_t cpu_MemorySize(CpuMemoryIndicators mem_type);
|
||||
|
||||
// faster than cpu_memorySize (caches total size determined during init),
|
||||
// faster than cpu_MemorySize (caches total size determined during init),
|
||||
// returns #Mebibytes (cleaned up to account e.g. for nonpaged pool)
|
||||
extern size_t cpu_memoryTotalMiB();
|
||||
extern size_t cpu_MemoryTotalMiB();
|
||||
|
||||
|
||||
//
|
||||
@ -85,12 +85,12 @@ extern bool cpu_CAS(uintptr_t* location, uintptr_t expected, uintptr_t new_value
|
||||
* add a signed value to a variable without the possibility of interference
|
||||
* from other threads/CPUs.
|
||||
**/
|
||||
extern void cpu_atomic_add(intptr_t* location, intptr_t increment);
|
||||
extern void cpu_AtomicAdd(intptr_t* location, intptr_t increment);
|
||||
|
||||
// enforce strong memory ordering.
|
||||
extern void cpu_mfence();
|
||||
extern void cpu_MemoryFence();
|
||||
|
||||
extern void cpu_serialize();
|
||||
extern void cpu_Serialize();
|
||||
|
||||
|
||||
// drop-in replacement for libc memcpy(). only requires CPU support for
|
||||
@ -110,14 +110,14 @@ extern void* cpu_memcpy(void* RESTRICT dst, const void* RESTRICT src, size_t siz
|
||||
// called from ia32.cpp get_cpu_count.
|
||||
|
||||
typedef void (*CpuCallback)(void* param);
|
||||
extern LibError cpu_callByEachCPU(CpuCallback cb, void* param);
|
||||
extern LibError cpu_CallByEachCPU(CpuCallback cb, void* param);
|
||||
|
||||
|
||||
// convert float to int much faster than _ftol2, which would normally be
|
||||
// used by (int) casts.
|
||||
extern i32 cpu_i32_from_float(float f);
|
||||
extern i32 cpu_i32_from_double(double d);
|
||||
extern i64 cpu_i64_from_double(double d);
|
||||
extern i32 cpu_i32FromFloat(float f);
|
||||
extern i32 cpu_i32FromDouble(double d);
|
||||
extern i64 cpu_i64FromDouble(double d);
|
||||
|
||||
|
||||
|
||||
@ -138,4 +138,4 @@ extern i64 cpu_i64_from_double(double d);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // #ifndef CPU_H__
|
||||
#endif // #ifndef INCLUDED_CPU
|
||||
|
@ -82,7 +82,7 @@ static enum Vendor
|
||||
}
|
||||
vendor = UNKNOWN;
|
||||
|
||||
static void detectVendor()
|
||||
static void DetectVendor()
|
||||
{
|
||||
u32 regs[4];
|
||||
if(!ia32_asm_cpuid(0, regs))
|
||||
@ -139,7 +139,7 @@ __asm
|
||||
}
|
||||
|
||||
|
||||
void ia32_debug_break()
|
||||
void ia32_DebugBreak()
|
||||
{
|
||||
#if HAVE_MS_ASM
|
||||
__asm int 3
|
||||
@ -157,7 +157,7 @@ void ia32_debug_break()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// enforce strong memory ordering.
|
||||
void ia32_mfence()
|
||||
void ia32_MemoryFence()
|
||||
{
|
||||
// Pentium IV
|
||||
if(ia32_cap(IA32_CAP_SSE2))
|
||||
@ -168,7 +168,7 @@ void ia32_mfence()
|
||||
#endif
|
||||
}
|
||||
|
||||
void ia32_serialize()
|
||||
void ia32_Serialize()
|
||||
{
|
||||
#if HAVE_MS_ASM
|
||||
__asm cpuid
|
||||
@ -189,7 +189,7 @@ enum AmdPowerNowFlags
|
||||
};
|
||||
|
||||
|
||||
const char* ia32_identifierString()
|
||||
const char* ia32_IdentifierString()
|
||||
{
|
||||
// 3 calls x 4 registers x 4 bytes = 48
|
||||
static char identifier_string[48+1] = "";
|
||||
@ -276,7 +276,7 @@ const char* ia32_identifierString()
|
||||
}
|
||||
|
||||
|
||||
int ia32_isThrottlingPossible()
|
||||
int ia32_IsThrottlingPossible()
|
||||
{
|
||||
if(vendor == INTEL)
|
||||
{
|
||||
@ -296,7 +296,8 @@ int ia32_isThrottlingPossible()
|
||||
return 0; // pretty much authoritative, so don't return -1.
|
||||
}
|
||||
|
||||
double ia32_clockFrequency()
|
||||
|
||||
double ia32_ClockFrequency()
|
||||
{
|
||||
double clock_frequency = 0.0;
|
||||
|
||||
@ -393,10 +394,10 @@ double ia32_clockFrequency()
|
||||
// OSes report hyperthreading units and cores as "processors". we need to
|
||||
// drill down and find out the exact counts (for thread pool dimensioning
|
||||
// and cache sharing considerations).
|
||||
// note: Intel Appnote 485 (CPUID) assures uniformity of coresPerPackage and
|
||||
// logicalPerCore.
|
||||
// note: Intel Appnote 485 (CPUID) assures uniformity of CoresPerPackage and
|
||||
// LogicalPerCore.
|
||||
|
||||
static uint coresPerPackage()
|
||||
static uint CoresPerPackage()
|
||||
{
|
||||
static uint cores_per_package = 0;
|
||||
if(cores_per_package == 0)
|
||||
@ -411,7 +412,7 @@ static uint coresPerPackage()
|
||||
return cores_per_package;
|
||||
}
|
||||
|
||||
static uint logicalPerCore()
|
||||
static uint LogicalPerCore()
|
||||
{
|
||||
static uint logical_per_core = 0;
|
||||
if(logical_per_core == 0)
|
||||
@ -423,8 +424,8 @@ static uint logicalPerCore()
|
||||
DEBUG_WARN_ERR(ERR::CPU_FEATURE_MISSING);
|
||||
const uint logical_per_package = bits(regs[EBX], 16, 23);
|
||||
// cores ought to be uniform WRT # logical processors
|
||||
debug_assert(logical_per_package % coresPerPackage() == 0);
|
||||
logical_per_core = logical_per_package / coresPerPackage();
|
||||
debug_assert(logical_per_package % CoresPerPackage() == 0);
|
||||
logical_per_core = logical_per_package / CoresPerPackage();
|
||||
}
|
||||
else
|
||||
logical_per_core = 1; // not Hyperthreading capable
|
||||
@ -440,7 +441,7 @@ static uint logicalPerCore()
|
||||
// (according to the number of cores/logical units present) allows
|
||||
// determining the exact topology as well as number of packages.
|
||||
|
||||
// these are set by detectProcessorTopology, called from ia32_init.
|
||||
// these are set by DetectProcessorTopology, called from ia32_Init.
|
||||
static uint num_packages = 0; // i.e. sockets; > 1 => true SMP system
|
||||
static uint enabled_cores_per_package = 0;
|
||||
static uint enabled_logical_per_core = 0; // hyperthreading units
|
||||
@ -449,7 +450,7 @@ typedef std::vector<u8> Ids;
|
||||
typedef std::set<u8> IdSet;
|
||||
|
||||
// add the currently running processor's APIC ID to a list of IDs.
|
||||
static void storeApicId(void* param)
|
||||
static void StoreApicId(void* param)
|
||||
{
|
||||
u32 regs[4];
|
||||
if(!ia32_asm_cpuid(1, regs))
|
||||
@ -465,7 +466,7 @@ static void storeApicId(void* param)
|
||||
// for each id in apic_ids: extract the value of the field at offset bit_pos
|
||||
// and insert it into ids. afterwards, adjust bit_pos to the next field.
|
||||
// used to gather e.g. all core IDs from all APIC IDs.
|
||||
static void extractFieldsIntoSet(const Ids& apic_ids, uint& bit_pos, uint num_values, IdSet& ids)
|
||||
static void ExtractFieldsIntoSet(const Ids& apic_ids, uint& bit_pos, uint num_values, IdSet& ids)
|
||||
{
|
||||
const uint id_bits = log2(num_values); // (rounded up)
|
||||
if(id_bits == 0)
|
||||
@ -484,26 +485,26 @@ static void extractFieldsIntoSet(const Ids& apic_ids, uint& bit_pos, uint num_va
|
||||
}
|
||||
|
||||
|
||||
// determine how many coresPerPackage and logicalPerCore are
|
||||
// determine how many CoresPerPackage and LogicalPerCore are
|
||||
// actually enabled and also count numPackages.
|
||||
// (scans the APIC IDs, which requires OS support for thread affinity)
|
||||
static void detectProcessorTopology()
|
||||
static void DetectProcessorTopology()
|
||||
{
|
||||
Ids apic_ids;
|
||||
if(cpu_callByEachCPU(storeApicId, &apic_ids) != INFO::OK)
|
||||
if(cpu_CallByEachCPU(StoreApicId, &apic_ids) != INFO::OK)
|
||||
return;
|
||||
// .. if they're not unique, cpu_callByEachCPU is broken.
|
||||
// .. if they're not unique, cpu_CallByEachCPU is broken.
|
||||
std::sort(apic_ids.begin(), apic_ids.end());
|
||||
debug_assert(std::unique(apic_ids.begin(), apic_ids.end()) == apic_ids.end());
|
||||
|
||||
// extract values from all 3 ID bitfields into separate sets
|
||||
uint bit_pos = 0;
|
||||
IdSet logical_ids;
|
||||
extractFieldsIntoSet(apic_ids, bit_pos, logicalPerCore(), logical_ids);
|
||||
ExtractFieldsIntoSet(apic_ids, bit_pos, LogicalPerCore(), logical_ids);
|
||||
IdSet core_ids;
|
||||
extractFieldsIntoSet(apic_ids, bit_pos, coresPerPackage(), core_ids);
|
||||
ExtractFieldsIntoSet(apic_ids, bit_pos, CoresPerPackage(), core_ids);
|
||||
IdSet package_ids;
|
||||
extractFieldsIntoSet(apic_ids, bit_pos, 0xFF, package_ids);
|
||||
ExtractFieldsIntoSet(apic_ids, bit_pos, 0xFF, package_ids);
|
||||
|
||||
// (the set cardinality is representative of all packages/cores since
|
||||
// they are uniform.)
|
||||
@ -517,7 +518,7 @@ static void detectProcessorTopology()
|
||||
}
|
||||
|
||||
|
||||
uint ia32_numPackages()
|
||||
uint ia32_NumPackages()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
debug_assert(num_packages != 0);
|
||||
@ -525,7 +526,7 @@ uint ia32_numPackages()
|
||||
return (uint)num_packages;
|
||||
}
|
||||
|
||||
uint ia32_coresPerPackage()
|
||||
uint ia32_CoresPerPackage()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
debug_assert(enabled_cores_per_package != 0);
|
||||
@ -533,7 +534,7 @@ uint ia32_coresPerPackage()
|
||||
return (uint)enabled_cores_per_package;
|
||||
}
|
||||
|
||||
uint ia32_logicalPerCore()
|
||||
uint ia32_LogicalPerCore()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
debug_assert(enabled_logical_per_core != 0);
|
||||
@ -552,7 +553,7 @@ uint ia32_logicalPerCore()
|
||||
// target, which is otherwise 0.
|
||||
//
|
||||
// this is useful for walking the stack manually.
|
||||
LibError ia32_get_call_target(void* ret_addr, void** target)
|
||||
LibError ia32_GetCallTarget(void* ret_addr, void** target)
|
||||
{
|
||||
*target = 0;
|
||||
|
||||
@ -610,13 +611,13 @@ LibError ia32_get_call_target(void* ret_addr, void** target)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ia32_init()
|
||||
void ia32_Init()
|
||||
{
|
||||
ia32_asm_cpuid_init();
|
||||
|
||||
ia32_cap_init();
|
||||
|
||||
detectVendor();
|
||||
DetectVendor();
|
||||
|
||||
detectProcessorTopology();
|
||||
DetectProcessorTopology();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
/**
|
||||
* must be called exactly once before any of the following functions.
|
||||
**/
|
||||
extern void ia32_init();
|
||||
extern void ia32_Init();
|
||||
|
||||
/// fpclassify return values
|
||||
#define IA32_FP_NAN 0x0100
|
||||
@ -115,7 +115,7 @@ extern bool ia32_cap(IA32Cap cap);
|
||||
*
|
||||
* this function is used for walking the call stack.
|
||||
**/
|
||||
extern LibError ia32_get_call_target(void* ret_addr, void** target);
|
||||
extern LibError ia32_GetCallTarget(void* ret_addr, void** target);
|
||||
|
||||
|
||||
/// safe but slow inline-asm version
|
||||
@ -136,7 +136,7 @@ extern u64 ia32_rdtsc(); // only for CppDoc's benefit
|
||||
/**
|
||||
* trigger a breakpoint inside this function when it is called.
|
||||
**/
|
||||
extern void ia32_debug_break(void);
|
||||
extern void ia32_DebugBreak(void);
|
||||
|
||||
|
||||
// CPU detection
|
||||
@ -145,44 +145,44 @@ extern void ia32_debug_break(void);
|
||||
* @return string identifying the CPU (usually a cleaned-up version of the
|
||||
* brand string)
|
||||
**/
|
||||
extern const char* ia32_identifierString();
|
||||
extern const char* ia32_IdentifierString();
|
||||
|
||||
/**
|
||||
* @return whether CPU frequency throttling is possible or
|
||||
* may potentially happen (if so, using RDTSC is unsafe).
|
||||
**/
|
||||
extern int ia32_isThrottlingPossible();
|
||||
extern int ia32_IsThrottlingPossible();
|
||||
|
||||
/**
|
||||
* @return the cached result of a precise measurement of the
|
||||
* CPU frequency.
|
||||
**/
|
||||
extern double ia32_clockFrequency();
|
||||
extern double ia32_ClockFrequency();
|
||||
|
||||
/**
|
||||
* @return number of *enabled* CPU packages / sockets.
|
||||
**/
|
||||
extern uint ia32_numPackages();
|
||||
extern uint ia32_NumPackages();
|
||||
|
||||
/**
|
||||
* @return number of *enabled* CPU cores per package.
|
||||
* (2 on dual-core systems)
|
||||
**/
|
||||
extern uint ia32_coresPerPackage();
|
||||
extern uint ia32_CoresPerPackage();
|
||||
|
||||
/**
|
||||
* @return number of *enabled* hyperthreading units per core.
|
||||
* (2 on P4 EE)
|
||||
**/
|
||||
extern uint ia32_logicalPerCore();
|
||||
extern uint ia32_LogicalPerCore();
|
||||
|
||||
|
||||
// implementations of the cpu.h interface
|
||||
|
||||
/// see cpu_mfence
|
||||
extern void ia32_mfence();
|
||||
/// see cpu_MemoryFence
|
||||
extern void ia32_MemoryFence();
|
||||
|
||||
// see cpu_serialize
|
||||
extern void ia32_serialize();
|
||||
// see cpu_Serialize
|
||||
extern void ia32_Serialize();
|
||||
|
||||
#endif // #ifndef INCLUDED_IA32
|
||||
|
@ -112,9 +112,9 @@ sym(ia32_asm_cpuid):
|
||||
; lock-free support routines
|
||||
;-------------------------------------------------------------------------------
|
||||
|
||||
; extern "C" void __cdecl ia32_asm_atomic_add(intptr_t* location, intptr_t increment);
|
||||
global sym(ia32_asm_atomic_add)
|
||||
sym(ia32_asm_atomic_add):
|
||||
; extern "C" void __cdecl ia32_asm_AtomicAdd(intptr_t* location, intptr_t increment);
|
||||
global sym(ia32_asm_AtomicAdd)
|
||||
sym(ia32_asm_AtomicAdd):
|
||||
mov edx, [esp+4] ; location
|
||||
mov eax, [esp+8] ; increment
|
||||
db 0xf0 ; LOCK prefix
|
||||
@ -251,9 +251,9 @@ sym(ia32_asm_fmaxf):
|
||||
ret
|
||||
|
||||
|
||||
; extern "C" i32 __cdecl ia32_asm_i32_from_float(float f)
|
||||
global sym(ia32_asm_i32_from_float)
|
||||
sym(ia32_asm_i32_from_float):
|
||||
; extern "C" i32 __cdecl ia32_asm_i32FromFloat(float f)
|
||||
global sym(ia32_asm_i32FromFloat)
|
||||
sym(ia32_asm_i32FromFloat):
|
||||
push eax
|
||||
fld dword [esp+8]
|
||||
fsub dword [round_bias]
|
||||
@ -261,9 +261,9 @@ sym(ia32_asm_i32_from_float):
|
||||
pop eax
|
||||
ret
|
||||
|
||||
; extern "C" i32 __cdecl ia32_asm_i32_from_double(double d)
|
||||
global sym(ia32_asm_i32_from_double)
|
||||
sym(ia32_asm_i32_from_double):
|
||||
; extern "C" i32 __cdecl ia32_asm_i32FromDouble(double d)
|
||||
global sym(ia32_asm_i32FromDouble)
|
||||
sym(ia32_asm_i32FromDouble):
|
||||
push eax
|
||||
fld qword [esp+8]
|
||||
fsub dword [round_bias]
|
||||
@ -271,9 +271,9 @@ sym(ia32_asm_i32_from_double):
|
||||
pop eax
|
||||
ret
|
||||
|
||||
; extern "C" i64 __cdecl ia32_asm_i64_from_double(double d)
|
||||
global sym(ia32_asm_i64_from_double)
|
||||
sym(ia32_asm_i64_from_double):
|
||||
; extern "C" i64 __cdecl ia32_asm_i64FromDouble(double d)
|
||||
global sym(ia32_asm_i64FromDouble)
|
||||
sym(ia32_asm_i64FromDouble):
|
||||
push edx
|
||||
push eax
|
||||
fld qword [esp+12]
|
||||
@ -312,9 +312,9 @@ sym(ia32_asm_rdtsc_edx_eax):
|
||||
; optimized for size; this must be straight asm because ; extern "C"
|
||||
; is compiler-specific and compiler-generated prolog code inserted before
|
||||
; inline asm trashes EBP and ESP (unacceptable).
|
||||
; extern "C" void ia32_asm_get_current_context(void* pcontext)
|
||||
global sym(ia32_asm_get_current_context)
|
||||
sym(ia32_asm_get_current_context):
|
||||
; extern "C" void ia32_asm_GetCurrentContext(void* pcontext)
|
||||
global sym(ia32_asm_GetCurrentContext)
|
||||
sym(ia32_asm_GetCurrentContext):
|
||||
pushad
|
||||
pushfd
|
||||
mov edi, [esp+4+32+4] ; pcontext
|
||||
|
@ -7,7 +7,7 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* prepare ia32_asm_cpuid for use (detects which CPUID functions are
|
||||
* available). called by ia32_init.
|
||||
* available). called by ia32_Init.
|
||||
**/
|
||||
extern void ia32_asm_cpuid_init();
|
||||
|
||||
@ -36,21 +36,21 @@ extern u64 ia32_asm_rdtsc_edx_eax(void);
|
||||
* write the current execution state (e.g. all register values) into
|
||||
* (Win32::CONTEXT*)pcontext (defined as void* to avoid dependency).
|
||||
**/
|
||||
extern void ia32_asm_get_current_context(void* pcontext);
|
||||
extern void ia32_asm_GetCurrentContext(void* pcontext);
|
||||
|
||||
|
||||
// implementations of the cpu.h interface
|
||||
|
||||
/// see cpu_atomic_add
|
||||
extern void ia32_asm_atomic_add(intptr_t* location, intptr_t increment);
|
||||
/// see cpu_AtomicAdd
|
||||
extern void ia32_asm_AtomicAdd(intptr_t* location, intptr_t increment);
|
||||
|
||||
/// see cpu_CAS
|
||||
extern bool ia32_asm_CAS(uintptr_t* location, uintptr_t expected, uintptr_t new_value);
|
||||
|
||||
/// see cpu_i32_from_float
|
||||
extern i32 ia32_asm_i32_from_float(float f);
|
||||
extern i32 ia32_asm_i32_from_double(double d);
|
||||
extern i64 ia32_asm_i64_from_double(double d);
|
||||
/// see cpu_i32FromFloat
|
||||
extern i32 ia32_asm_i32FromFloat(float f);
|
||||
extern i32 ia32_asm_i32FromDouble(double d);
|
||||
extern i64 ia32_asm_i64FromDouble(double d);
|
||||
|
||||
|
||||
// backends for POSIX/SUS functions
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#if OS_BSD
|
||||
|
||||
static int sysctlFromMemType(CpuMemoryIndicators mem_type)
|
||||
static int SysctlFromMemType(CpuMemoryIndicators mem_type)
|
||||
{
|
||||
switch(mem_type)
|
||||
{
|
||||
@ -15,11 +15,11 @@ static int sysctlFromMemType(CpuMemoryIndicators mem_type)
|
||||
UNREACHABLE;
|
||||
}
|
||||
|
||||
size_t bsd_memorySize(CpuMemoryIndicators mem_type)
|
||||
size_t bsd_MemorySize(CpuMemoryIndicators mem_type)
|
||||
{
|
||||
size_t memory_size = 0;
|
||||
size_t len = sizeof(memory_size);
|
||||
const int mib[2] = { CTL_HW, sysctlFromMemType(mem_type) };
|
||||
const int mib[2] = { CTL_HW, SysctlFromMemType(mem_type) };
|
||||
sysctl(mib, 2, &memory_size, &len, 0, 0);
|
||||
return memory_size;
|
||||
}
|
||||
|
@ -3,6 +3,6 @@
|
||||
|
||||
#include "../cpu.h"
|
||||
|
||||
extern size_t bsd_memorySize(CpuMemoryIndicators mem_type);
|
||||
extern size_t bsd_MemorySize(CpuMemoryIndicators mem_type);
|
||||
|
||||
#endif // #ifndef INCLUDED_BSD
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
#include "ucpu.h"
|
||||
|
||||
int ucpu_isThrottlingPossible()
|
||||
int ucpu_IsThrottlingPossible()
|
||||
{
|
||||
return -1; // don't know
|
||||
}
|
||||
|
||||
int ucpu_numPackages()
|
||||
int ucpu_NumPackages()
|
||||
{
|
||||
long res = sysconf(_SC_NPROCESSORS_CONF);
|
||||
if (res == -1)
|
||||
@ -16,7 +16,7 @@ int ucpu_numPackages()
|
||||
return (int)res;
|
||||
}
|
||||
|
||||
double ucpu_clockFrequency()
|
||||
double ucpu_ClockFrequency()
|
||||
{
|
||||
return -1; // don't know
|
||||
}
|
||||
@ -24,7 +24,7 @@ double ucpu_clockFrequency()
|
||||
|
||||
// apparently not possible on non-Windows OSes because they seem to lack
|
||||
// a CPU affinity API. see sysdep.h comment.
|
||||
LibError ucpu_callByEachCPU(CpuCallback cb, void* param)
|
||||
LibError ucpu_CallByEachCPU(CpuCallback cb, void* param)
|
||||
{
|
||||
UNUSED2(cb);
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
#include "lib/sysdep/cpu.h"
|
||||
|
||||
extern int ucpu_isThrottlingPossible();
|
||||
extern int ucpu_numPackages();
|
||||
extern double ucpu_clockFrequency();
|
||||
extern LibError ucpu_callByEachCPU(CpuCallback cb, void* param);
|
||||
extern int ucpu_IsThrottlingPossible();
|
||||
extern int ucpu_NumPackages();
|
||||
extern double ucpu_ClockFrequency();
|
||||
extern LibError ucpu_CallByEachCPU(CpuCallback cb, void* param);
|
||||
|
||||
#endif // #ifndef INCLUDED_UCPU
|
||||
|
@ -30,21 +30,20 @@
|
||||
|
||||
// limit allows statically allocated per-CPU structures (for simplicity).
|
||||
// WinAPI only supports max. 32 CPUs anyway (due to DWORD bitfields).
|
||||
// signed int because num_cpus is tri-state.
|
||||
static const int MAX_CPUS = 32;
|
||||
static const uint MAX_CPUS = 32;
|
||||
|
||||
|
||||
int wcpu_numProcessors()
|
||||
/// get number of CPUs (can't fail)
|
||||
uint wcpu_NumProcessors()
|
||||
{
|
||||
// get number of CPUs (can't fail)
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
const int num_processors = (int)si.dwNumberOfProcessors;
|
||||
const uint num_processors = (uint)si.dwNumberOfProcessors;
|
||||
return num_processors;
|
||||
}
|
||||
|
||||
|
||||
int wcpu_isThrottlingPossible()
|
||||
int wcpu_IsThrottlingPossible()
|
||||
{
|
||||
WIN_SAVE_LAST_ERROR;
|
||||
int is_throttling_possible = -1;
|
||||
@ -80,7 +79,7 @@ int wcpu_isThrottlingPossible()
|
||||
if(pCNPI(ProcessorInformation, 0,0, ppi,sizeof(ppi)) == STATUS_SUCCESS)
|
||||
{
|
||||
const PROCESSOR_POWER_INFORMATION* p = ppi;
|
||||
for(int i = 0; i < MIN(wcpu_numProcessors(), MAX_CPUS); i++, p++)
|
||||
for(uint i = 0; i < std::min(wcpu_NumProcessors(), MAX_CPUS); i++, p++)
|
||||
{
|
||||
if(p->MhzLimit != p->MaxMhz || p->CurrentMhz != p->MaxMhz)
|
||||
{
|
||||
@ -126,7 +125,7 @@ int wcpu_isThrottlingPossible()
|
||||
//
|
||||
// may fail if e.g. OS is preventing us from running on some CPUs.
|
||||
// called from ia32.cpp get_cpu_count.
|
||||
LibError wcpu_callByEachCPU(CpuCallback cb, void* param)
|
||||
LibError wcpu_CallByEachCPU(CpuCallback cb, void* param)
|
||||
{
|
||||
const HANDLE hProcess = GetCurrentProcess();
|
||||
DWORD process_affinity, system_affinity;
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
#include "lib/sysdep/cpu.h"
|
||||
|
||||
extern int wcpu_numProcessors();
|
||||
extern int wcpu_isThrottlingPossible();
|
||||
extern double wcpu_clockFrequency();
|
||||
extern LibError wcpu_callByEachCPU(CpuCallback cb, void* param);
|
||||
extern uint wcpu_NumProcessors();
|
||||
extern int wcpu_IsThrottlingPossible();
|
||||
extern double wcpu_ClockFrequency();
|
||||
extern LibError wcpu_CallByEachCPU(CpuCallback cb, void* param);
|
||||
|
||||
#endif // #ifndef INCLUDED_WCPU
|
||||
|
@ -304,7 +304,7 @@ static LibError ia32_walk_stack(STACKFRAME64* sf)
|
||||
WARN_RETURN(ERR::_15);
|
||||
|
||||
void* target;
|
||||
LibError err = ia32_get_call_target(ret_addr, &target);
|
||||
LibError err = ia32_GetCallTarget(ret_addr, &target);
|
||||
RETURN_ERR(err);
|
||||
if(target) // were able to determine it from the call instruction
|
||||
debug_assert(debug_is_code_ptr(target));
|
||||
@ -369,7 +369,7 @@ static LibError walk_stack(StackFrameCallback cb, void* user_arg = 0, uint skip
|
||||
// compiler-generated prolog code trashes some registers.
|
||||
|
||||
#if CPU_IA32
|
||||
ia32_asm_get_current_context(&context);
|
||||
ia32_asm_GetCurrentContext(&context);
|
||||
#else
|
||||
// preferred implementation (was imported during module init)
|
||||
if(pRtlCaptureContext)
|
||||
|
@ -77,7 +77,7 @@ AT_STARTUP(\
|
||||
// (default values for HRT_NONE impl)
|
||||
|
||||
// initial measurement of the time source's tick rate. not necessarily
|
||||
// correct (e.g. when using TSC; cpu_clockFrequency isn't exact).
|
||||
// correct (e.g. when using TSC; cpu_ClockFrequency isn't exact).
|
||||
static double hrt_nominal_freq = -1.0;
|
||||
|
||||
// actual resolution of the time source (may differ from hrt_nominal_freq
|
||||
@ -199,14 +199,14 @@ static LibError choose_impl()
|
||||
// will do this as well (if not to save power, for heat reasons).
|
||||
// frequency changes are too often and drastic to correct,
|
||||
// and we don't want to mess with the system power settings => unsafe.
|
||||
if(cpu_isModuleInitialized() && cpu_clockFrequency() > 0.0 && ia32_cap(IA32_CAP_TSC))
|
||||
if(cpu_IsModuleInitialized() && cpu_ClockFrequency() > 0.0 && ia32_cap(IA32_CAP_TSC))
|
||||
{
|
||||
safe = (cpu_coresPerPackage() == 1 && cpu_numPackages() == 1 && cpu_isThrottlingPossible() == 0);
|
||||
safe = (cpu_CoresPerPackage() == 1 && cpu_NumPackages() == 1 && cpu_IsThrottlingPossible() == 0);
|
||||
SAFETY_OVERRIDE(HRT_TSC);
|
||||
if(safe)
|
||||
{
|
||||
hrt_impl = HRT_TSC;
|
||||
hrt_nominal_freq = cpu_clockFrequency();
|
||||
hrt_nominal_freq = cpu_ClockFrequency();
|
||||
hrt_res = (1.0 / hrt_nominal_freq);
|
||||
return INFO::OK;
|
||||
}
|
||||
@ -249,13 +249,13 @@ static LibError choose_impl()
|
||||
else
|
||||
{
|
||||
// can't decide yet - assume unsafe
|
||||
if(!cpu_isModuleInitialized())
|
||||
if(!cpu_IsModuleInitialized())
|
||||
safe = false;
|
||||
else
|
||||
{
|
||||
// compare QPC freq to CPU clock freq - can't rule out HPET,
|
||||
// because its frequency isn't known (it's at least 10 MHz).
|
||||
double freq_dist = fabs(cpu_clockFrequency()/qpc_freq - 1.0);
|
||||
double freq_dist = fabs(cpu_ClockFrequency()/qpc_freq - 1.0);
|
||||
safe = freq_dist > 0.05;
|
||||
// safe if freqs not within 5% (i.e. it doesn't use TSC)
|
||||
}
|
||||
@ -711,7 +711,7 @@ static i64 time_ns()
|
||||
}
|
||||
|
||||
const double dt = hrt_time() - hrt_start_time;
|
||||
const i64 ns = st_start + cpu_i64_from_double(dt * _1e9);
|
||||
const i64 ns = st_start + cpu_i64FromDouble(dt * _1e9);
|
||||
return ns;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "adts.h"
|
||||
#include "lib/sysdep/cpu.h"
|
||||
|
||||
#if TIMER_USE_RDTSC
|
||||
#if CPU_IA32
|
||||
# include "lib/sysdep/ia32/ia32.h"
|
||||
#endif
|
||||
|
||||
@ -311,7 +311,7 @@ void timer_display_client_totals()
|
||||
double sum;
|
||||
#if TIMER_USE_RAW_TICKS
|
||||
# if CPU_IA32
|
||||
sum = tc->sum / cpu_clockFrequency();
|
||||
sum = tc->sum / cpu_ClockFrequency();
|
||||
# else
|
||||
# error "port"
|
||||
# endif
|
||||
@ -334,7 +334,7 @@ void timer_display_client_totals()
|
||||
}
|
||||
|
||||
|
||||
#if TIMER_USE_RDTSC
|
||||
#if CPU_IA32
|
||||
|
||||
TimerRdtsc::unit TimerRdtsc::get_timestamp() const
|
||||
{
|
||||
|
@ -46,37 +46,62 @@ extern float spf; // for time-since-last-frame use
|
||||
extern void calc_fps(void);
|
||||
|
||||
|
||||
//
|
||||
// cumulative timer API
|
||||
//
|
||||
|
||||
// this supplements in-game profiling by providing low-overhead,
|
||||
// high resolution time accounting.
|
||||
//-----------------------------------------------------------------------------
|
||||
// timestamp sources
|
||||
|
||||
// since TIMER_ACCRUE et al. are called so often, we try to keep
|
||||
// overhead to an absolute minimum. this flag allows storing
|
||||
// raw tick counts (e.g. CPU cycles returned by ia32_rdtsc) instead of
|
||||
// absolute time. there are two benefits:
|
||||
// overhead to an absolute minimum. storing raw tick counts (e.g. CPU cycles
|
||||
// returned by ia32_rdtsc) instead of absolute time has two benefits:
|
||||
// - no need to convert from raw->time on every call
|
||||
// (instead, it's only done once when displaying the totals)
|
||||
// - possibly less overhead to querying the time itself
|
||||
// (get_time may be using slower time sources with ~3us overhead)
|
||||
//
|
||||
// however, the cycle count is not necessarily a measure of wall-clock time.
|
||||
// therefore, on systems with SpeedStep active, measurements of
|
||||
// I/O or other non-CPU bound activity may be skewed. this is ok because
|
||||
// the timer is only used for profiling; just be aware of the issue.
|
||||
// if it's a problem or no raw tick source is available, disable this.
|
||||
// therefore, on systems with SpeedStep active, measurements of I/O or other
|
||||
// non-CPU bound activity may be skewed. this is ok because the timer is
|
||||
// only used for profiling; just be aware of the issue.
|
||||
// if this is a problem, disable CONFIG_TIMER_ALLOW_RDTSC.
|
||||
//
|
||||
// note that overflow isn't an issue either way (63 bit cycle counts
|
||||
// at 10 GHz cover intervals of 29 years).
|
||||
|
||||
#if CPU_IA32
|
||||
# define TIMER_USE_RDTSC 1
|
||||
typedef i64 TimerUnit;
|
||||
|
||||
// fast, not usable as wall-clock (http://www.gamedev.net/reference/programming/features/timing)
|
||||
class TimerRdtsc
|
||||
{
|
||||
public:
|
||||
typedef i64 unit;
|
||||
unit get_timestamp() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
class TimerSafe
|
||||
{
|
||||
public:
|
||||
typedef double unit;
|
||||
unit get_timestamp() const
|
||||
{
|
||||
return get_time();
|
||||
}
|
||||
};
|
||||
|
||||
#if CPU_IA32 && TIMER_ALLOW_RDTSC
|
||||
typedef TimerRdtsc Timer;
|
||||
#else
|
||||
# define TIMER_USE_RDTSC 0
|
||||
typedef double TimerUnit;
|
||||
#endif // #if CPU_IA32
|
||||
typedef TimerSafe Timer;
|
||||
#endif
|
||||
|
||||
typedef Timer::unit TimerUnit; // convenience
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// cumulative timer API
|
||||
|
||||
// this supplements in-game profiling by providing low-overhead,
|
||||
// high resolution time accounting.
|
||||
|
||||
// opaque - do not access its fields!
|
||||
// note: must be defined here because clients instantiate them;
|
||||
@ -115,6 +140,8 @@ extern void timer_bill_client(TimerClient* tc, TimerUnit dt);
|
||||
extern void timer_display_client_totals();
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// scoped-based timers
|
||||
|
||||
// used via TIMER* macros below.
|
||||
class ScopeTimer
|
||||
@ -193,33 +220,8 @@ Example usage:
|
||||
#define TIMER_END(description) }
|
||||
|
||||
|
||||
#if TIMER_USE_RDTSC
|
||||
|
||||
// fast, not usable as wall-clock (http://www.gamedev.net/reference/programming/features/timing)
|
||||
class TimerRdtsc
|
||||
{
|
||||
public:
|
||||
typedef i64 unit;
|
||||
unit get_timestamp() const;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
class TimerNormal
|
||||
{
|
||||
public:
|
||||
typedef double unit;
|
||||
unit get_timestamp() const
|
||||
{
|
||||
return get_time();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // TIMER_USE_RDTSC
|
||||
|
||||
|
||||
// used via TIMER_ACCRUE
|
||||
template<class TimerImpl = TimerRdtsc> class ScopeTimerAccrue
|
||||
template<class TimerImpl = Timer> class ScopeTimerAccrue
|
||||
{
|
||||
TimerImpl impl;
|
||||
typename TimerImpl::unit t0;
|
||||
|
@ -161,7 +161,7 @@ CMusicPlayer music_player;
|
||||
static void Frame()
|
||||
{
|
||||
MICROLOG(L"Frame");
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
// get elapsed time
|
||||
calc_fps();
|
||||
@ -211,7 +211,7 @@ static void Frame()
|
||||
|
||||
|
||||
PROFILE_START( "update music" );
|
||||
music_player.update();
|
||||
music_player.Update();
|
||||
PROFILE_END( "update music" );
|
||||
|
||||
bool is_building_archive; // must come before PROFILE_START's {
|
||||
@ -244,7 +244,7 @@ static void Frame()
|
||||
g_SessionManager.Poll();
|
||||
PROFILE_END("input");
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
PROFILE_START("gui tick");
|
||||
MICROLOG(L"gui tick");
|
||||
@ -253,7 +253,7 @@ static void Frame()
|
||||
#endif
|
||||
PROFILE_END("gui tick");
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
PROFILE_START( "game logic" );
|
||||
if (g_Game && g_Game->IsGameStarted() && need_update)
|
||||
@ -270,9 +270,9 @@ static void Frame()
|
||||
|
||||
PROFILE_START( "selection and interaction ui" );
|
||||
// TODO Where does GameView end and other things begin?
|
||||
g_Mouseover.update( TimeSinceLastFrame );
|
||||
g_Selection.update();
|
||||
g_BuildingPlacer.update( TimeSinceLastFrame );
|
||||
g_Mouseover.Update( TimeSinceLastFrame );
|
||||
g_Selection.Update();
|
||||
g_BuildingPlacer.Update( TimeSinceLastFrame );
|
||||
PROFILE_END( "selection and interaction ui" );
|
||||
|
||||
PROFILE_START( "sound update" );
|
||||
@ -291,7 +291,7 @@ static void Frame()
|
||||
// CSimulation would do this with the proper turn length if we were in
|
||||
// a game. This is basically just to keep script timers running.
|
||||
uint ms_elapsed = (uint)(TimeSinceLastFrame*1000);
|
||||
g_Scheduler.update(ms_elapsed);
|
||||
g_Scheduler.Update(ms_elapsed);
|
||||
if(snd_update(0, 0, 0) < 0)
|
||||
debug_printf("snd_update (pos=0 version) failed\n");
|
||||
}
|
||||
@ -302,7 +302,7 @@ static void Frame()
|
||||
PROFILE_END( "update console" );
|
||||
|
||||
PROFILE_START("render");
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
if(need_render)
|
||||
{
|
||||
MICROLOG(L"render");
|
||||
@ -312,7 +312,7 @@ static void Frame()
|
||||
SDL_GL_SwapBuffers();
|
||||
PROFILE_END( "swap buffers" );
|
||||
}
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
PROFILE_END("render");
|
||||
|
||||
g_Profiler.Frame();
|
||||
@ -344,7 +344,7 @@ static void MainControllerInit()
|
||||
|
||||
static void MainControllerShutdown()
|
||||
{
|
||||
music_player.release();
|
||||
music_player.Release();
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@ void RNSpline::AddNode(const CVector3D &pos)
|
||||
MaxDistance = 0.f;
|
||||
else
|
||||
{
|
||||
Node[NodeCount-1].Distance = (Node[NodeCount-1].Position - pos).GetLength();
|
||||
Node[NodeCount-1].Distance = (Node[NodeCount-1].Position - pos).Length();
|
||||
MaxDistance += Node[NodeCount-1].Distance;
|
||||
}
|
||||
SplineData temp;
|
||||
@ -226,8 +226,8 @@ void TNSpline::Constrain()
|
||||
for (int i = 1; i<NodeCount-1; i++)
|
||||
{
|
||||
// Equation 13
|
||||
float r0 = (Node[i].Position-Node[i-1].Position).GetLength() / Node[i-1].Distance;
|
||||
float r1 = (Node[i+1].Position - Node[i].Position).GetLength() / Node[i].Distance;
|
||||
float r0 = (Node[i].Position-Node[i-1].Position).Length() / Node[i-1].Distance;
|
||||
float r1 = (Node[i+1].Position - Node[i].Position).Length() / Node[i].Distance;
|
||||
Node[i].Velocity *= 4.0f*r0*r1/((r0+r1)*(r0+r1));
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ void CPlane::Normalize ()
|
||||
{
|
||||
float Scale;
|
||||
|
||||
Scale = 1.0f/m_Norm.GetLength ();
|
||||
Scale = 1.0f/m_Norm.Length ();
|
||||
|
||||
m_Norm.X *= Scale;
|
||||
m_Norm.Y *= Scale;
|
||||
|
@ -123,14 +123,14 @@ float CVector3D::LengthSquared () const
|
||||
return ( SQR(X) + SQR(Y) + SQR(Z) );
|
||||
}
|
||||
|
||||
float CVector3D::GetLength () const
|
||||
float CVector3D::Length () const
|
||||
{
|
||||
return sqrtf ( LengthSquared() );
|
||||
}
|
||||
|
||||
void CVector3D::Normalize ()
|
||||
{
|
||||
float scale = 1.0f/GetLength ();
|
||||
float scale = 1.0f/Length ();
|
||||
|
||||
X *= scale;
|
||||
Y *= scale;
|
||||
|
@ -58,7 +58,7 @@ class CVector3D
|
||||
CVector3D Cross (const CVector3D &vector) const;
|
||||
|
||||
//Returns length of the vector
|
||||
float GetLength () const;
|
||||
float Length () const;
|
||||
float LengthSquared () const;
|
||||
void Normalize ();
|
||||
|
||||
|
@ -25,80 +25,97 @@ public:
|
||||
CVector4D(float x,float y,float z,float w) { m_X=x; m_Y=y; m_Z=z; m_W=w; }
|
||||
CVector4D(const CVector4D& p) { m_X=p.m_X; m_Y=p.m_Y; m_Z=p.m_Z; m_W=p.m_W; }
|
||||
|
||||
operator float*() {
|
||||
operator float*()
|
||||
{
|
||||
return &m_X;
|
||||
}
|
||||
|
||||
operator const float*() const {
|
||||
operator const float*() const
|
||||
{
|
||||
return &m_X;
|
||||
}
|
||||
|
||||
CVector4D operator-() const {
|
||||
CVector4D operator-() const
|
||||
{
|
||||
return CVector4D(-m_X,-m_Y,-m_Z,-m_W);
|
||||
}
|
||||
|
||||
CVector4D operator+(const CVector4D& t) const {
|
||||
CVector4D operator+(const CVector4D& t) const
|
||||
{
|
||||
return CVector4D(m_X+t.m_X,m_Y+t.m_Y,m_Z+t.m_Z,m_W+t.m_W);
|
||||
}
|
||||
|
||||
CVector4D operator-(const CVector4D& t) const {
|
||||
CVector4D operator-(const CVector4D& t) const
|
||||
{
|
||||
return CVector4D(m_X-t.m_X,m_Y-t.m_Y,m_Z-t.m_Z,m_W-t.m_W);
|
||||
}
|
||||
|
||||
CVector4D operator*(const CVector4D& t) const {
|
||||
CVector4D operator*(const CVector4D& t) const
|
||||
{
|
||||
return CVector4D(m_X*t.m_X,m_Y*t.m_Y,m_Z*t.m_Z,m_W*t.m_W);
|
||||
}
|
||||
|
||||
CVector4D operator*(float f) const {
|
||||
CVector4D operator*(float f) const
|
||||
{
|
||||
return CVector4D(m_X*f,m_Y*f,m_Z*f,m_W*f);
|
||||
}
|
||||
|
||||
CVector4D operator/(float f) const {
|
||||
float inv=1.0f/f;
|
||||
return CVector4D(m_X*inv,m_Y*inv,m_Z*inv,m_W*inv);
|
||||
CVector4D operator/(float f) const
|
||||
{
|
||||
float inv_f = 1.0f/f;
|
||||
return CVector4D(m_X*inv_f,m_Y*inv_f,m_Z*inv_f,m_W*inv_f);
|
||||
}
|
||||
|
||||
CVector4D& operator+=(const CVector4D& t) {
|
||||
CVector4D& operator+=(const CVector4D& t)
|
||||
{
|
||||
m_X += t.m_X; m_Y += t.m_Y; m_Z += t.m_Z; m_W += t.m_W;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CVector4D& operator-=(const CVector4D& t) {
|
||||
CVector4D& operator-=(const CVector4D& t)
|
||||
{
|
||||
m_X -= t.m_X; m_Y -= t.m_Y; m_Z -= t.m_Z; m_W -= t.m_W;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CVector4D& operator*=(const CVector4D& t) {
|
||||
CVector4D& operator*=(const CVector4D& t)
|
||||
{
|
||||
m_X *= t.m_X; m_Y *= t.m_Y; m_Z *= t.m_Z; m_W *= t.m_W;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CVector4D& operator*=(float f) {
|
||||
CVector4D& operator*=(float f)
|
||||
{
|
||||
m_X *= f; m_Y *= f; m_Z *= f; m_W *= f;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CVector4D& operator/=(float f) {
|
||||
float invf=1.0f/f;
|
||||
m_X*=invf; m_Y*=invf; m_Z*=invf; m_W*=invf;
|
||||
CVector4D& operator/=(float f)
|
||||
{
|
||||
float inv_f = 1.0f / f;
|
||||
m_X *= inv_f; m_Y *= inv_f; m_Z *= inv_f; m_W *= inv_f;
|
||||
return *this;
|
||||
}
|
||||
|
||||
float dot(const CVector4D& a) const {
|
||||
float Dot(const CVector4D& a) const
|
||||
{
|
||||
return m_X*a.m_X + m_Y*a.m_Y + m_Z*a.m_Z + m_W*a.m_W;
|
||||
}
|
||||
|
||||
float lengthSquared() const {
|
||||
return dot(*this);
|
||||
float LengthSquared() const
|
||||
{
|
||||
return Dot(*this);
|
||||
}
|
||||
|
||||
float length() const {
|
||||
return (float) sqrt(lengthSquared());
|
||||
float Length() const
|
||||
{
|
||||
return sqrtf(LengthSquared());
|
||||
}
|
||||
|
||||
void normalize() {
|
||||
float mag=length();
|
||||
m_X/=mag; m_Y/=mag; m_Z/=mag; m_W/=mag;
|
||||
void Normalize()
|
||||
{
|
||||
const float inv_mag = 1.0f / Length();
|
||||
m_X *= inv_mag; m_Y *= inv_mag; m_Z *= inv_mag; m_W *= inv_mag;
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -318,7 +318,7 @@ JSBool JSI_Vector3D::length( JSContext* cx, JSObject* obj,
|
||||
if(!v)
|
||||
return( JS_TRUE );
|
||||
|
||||
*rval = ToJSVal( v->GetLength() );
|
||||
*rval = ToJSVal( v->Length() );
|
||||
return( JS_TRUE );
|
||||
}
|
||||
|
||||
|
@ -91,16 +91,16 @@ CStr8 CStrW::ToUTF8() const
|
||||
* Test for valid UTF-8 string
|
||||
*
|
||||
* @param const unsigned char * source pointer to string to test.
|
||||
* @param int length of string to test.
|
||||
* @param int Length of string to test.
|
||||
* @return bool true if source string is legal UTF-8,
|
||||
* false if not.
|
||||
**/
|
||||
static bool isLegalUTF8(const unsigned char *source, int length)
|
||||
static bool isLegalUTF8(const unsigned char *source, int Length)
|
||||
{
|
||||
unsigned char a;
|
||||
const unsigned char *srcptr = source+length;
|
||||
const unsigned char *srcptr = source+Length;
|
||||
|
||||
switch (length) {
|
||||
switch (Length) {
|
||||
default: return false;
|
||||
case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
|
||||
case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
|
||||
|
@ -248,7 +248,7 @@ void CGame::UpdateGameStatus()
|
||||
|
||||
for (int i=0; i<MAX_HANDLES; i++)
|
||||
{
|
||||
CHandle *handle = m_World->GetEntityManager().getHandle(i);
|
||||
CHandle *handle = m_World->GetEntityManager().GetHandle(i);
|
||||
if ( !handle )
|
||||
continue;
|
||||
CPlayer *tmpPlayer = handle->m_entity->GetPlayer();
|
||||
|
@ -228,18 +228,18 @@ CGameAttributes::CGameAttributes():
|
||||
}
|
||||
else
|
||||
{
|
||||
int at_name = XeroFile.getAttributeID("name");
|
||||
int at_rgb = XeroFile.getAttributeID("rgb");
|
||||
int at_name = XeroFile.GetAttributeID("name");
|
||||
int at_rgb = XeroFile.GetAttributeID("rgb");
|
||||
|
||||
XMBElement root = XeroFile.getRoot();
|
||||
XMBElement root = XeroFile.GetRoot();
|
||||
XERO_ITER_EL(root, player)
|
||||
{
|
||||
XMBAttributeList attr = player.getAttributes();
|
||||
XMBAttributeList attr = player.GetAttributes();
|
||||
m_Players.push_back(new CPlayer((int)m_Players.size()));
|
||||
m_Players.back()->SetName(attr.getNamedItem(at_name));
|
||||
m_Players.back()->SetName(attr.GetNamedItem(at_name));
|
||||
|
||||
std::stringstream str;
|
||||
str << (CStr)attr.getNamedItem(at_rgb);
|
||||
str << (CStr)attr.GetNamedItem(at_rgb);
|
||||
int r, g, b;
|
||||
if (str >> r >> g >> b)
|
||||
m_Players.back()->SetColour(SPlayerColour(r/255.0f, g/255.0f, b/255.0f));
|
||||
|
@ -125,7 +125,7 @@ static int SetVideoMode(int w, int h, int bpp, bool fullscreen)
|
||||
g_GUI.UpdateResolution();
|
||||
#endif
|
||||
|
||||
oglInit(); // required after each mode change
|
||||
ogl_Init(); // required after each mode change
|
||||
|
||||
if(SDL_SetGamma(g_Gamma, g_Gamma, g_Gamma) < 0)
|
||||
debug_warn("SDL_SetGamma failed");
|
||||
@ -204,11 +204,11 @@ void GUI_Init()
|
||||
g_GUI.Initialize();}
|
||||
|
||||
{TIMER("ps_gui_setup_xml");
|
||||
g_GUI.LoadXMLFile("gui/test/setup.xml");}
|
||||
g_GUI.LoadXmlFile("gui/test/setup.xml");}
|
||||
{TIMER("ps_gui_styles_xml");
|
||||
g_GUI.LoadXMLFile("gui/test/styles.xml");}
|
||||
g_GUI.LoadXmlFile("gui/test/styles.xml");}
|
||||
{TIMER("ps_gui_sprite1_xml");
|
||||
g_GUI.LoadXMLFile("gui/test/sprite1.xml");}
|
||||
g_GUI.LoadXmlFile("gui/test/sprite1.xml");}
|
||||
|
||||
// Atlas is running, we won't need these GUI pages (for now!
|
||||
// what if Atlas switches to in-game mode?!)
|
||||
@ -217,23 +217,23 @@ void GUI_Init()
|
||||
// return;
|
||||
|
||||
{TIMER("ps_gui_1");
|
||||
g_GUI.LoadXMLFile("gui/test/1_init.xml");}
|
||||
g_GUI.LoadXmlFile("gui/test/1_init.xml");}
|
||||
{TIMER("ps_gui_2");
|
||||
g_GUI.LoadXMLFile("gui/test/2_mainmenu.xml");}
|
||||
g_GUI.LoadXmlFile("gui/test/2_mainmenu.xml");}
|
||||
{TIMER("ps_gui_3");
|
||||
g_GUI.LoadXMLFile("gui/test/3_loading.xml");}
|
||||
g_GUI.LoadXmlFile("gui/test/3_loading.xml");}
|
||||
{TIMER("ps_gui_4");
|
||||
g_GUI.LoadXMLFile("gui/test/4_session.xml");}
|
||||
g_GUI.LoadXmlFile("gui/test/4_session.xml");}
|
||||
{TIMER("ps_gui_6");
|
||||
g_GUI.LoadXMLFile("gui/test/6_subwindows.xml");}
|
||||
g_GUI.LoadXmlFile("gui/test/6_subwindows.xml");}
|
||||
{TIMER("ps_gui_6_1");
|
||||
g_GUI.LoadXMLFile("gui/test/6_1_manual.xml");}
|
||||
g_GUI.LoadXmlFile("gui/test/6_1_manual.xml");}
|
||||
{TIMER("ps_gui_6_2");
|
||||
g_GUI.LoadXMLFile("gui/test/6_2_jukebox.xml");}
|
||||
g_GUI.LoadXmlFile("gui/test/6_2_jukebox.xml");}
|
||||
{TIMER("ps_gui_7");
|
||||
g_GUI.LoadXMLFile("gui/test/7_atlas.xml");}
|
||||
g_GUI.LoadXmlFile("gui/test/7_atlas.xml");}
|
||||
{TIMER("ps_gui_9");
|
||||
g_GUI.LoadXMLFile("gui/test/9_global.xml");}
|
||||
g_GUI.LoadXmlFile("gui/test/9_global.xml");}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ void Render()
|
||||
{
|
||||
MICROLOG(L"begin frame");
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
#ifndef NO_GUI // HACK: because colour-parsing requires the GUI
|
||||
CStr skystring = "61 193 255";
|
||||
@ -284,7 +284,7 @@ void Render()
|
||||
// start new frame
|
||||
g_Renderer.BeginFrame();
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
if (g_Game && g_Game->IsGameStarted())
|
||||
{
|
||||
@ -299,19 +299,19 @@ void Render()
|
||||
{
|
||||
PROFILE( "render entity overlays" );
|
||||
glColor3f( 1.0f, 0.0f, 1.0f );
|
||||
g_EntityManager.renderAll(); // <-- collision outlines, pathing routes
|
||||
g_EntityManager.RenderAll(); // <-- collision outlines, pathing routes
|
||||
}
|
||||
|
||||
glEnable( GL_DEPTH_TEST );
|
||||
|
||||
PROFILE_START( "render entity outlines" );
|
||||
g_Mouseover.renderSelectionOutlines();
|
||||
g_Selection.renderSelectionOutlines();
|
||||
g_Mouseover.RenderSelectionOutlines();
|
||||
g_Selection.RenderSelectionOutlines();
|
||||
PROFILE_END( "render entity outlines" );
|
||||
|
||||
PROFILE_START( "render entity auras" );
|
||||
g_Mouseover.renderAuras();
|
||||
g_Selection.renderAuras();
|
||||
g_Mouseover.RenderAuras();
|
||||
g_Selection.RenderAuras();
|
||||
PROFILE_END( "render entity auras" );
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
@ -340,8 +340,8 @@ void Render()
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
g_Mouseover.renderBars();
|
||||
g_Selection.renderBars();
|
||||
g_Mouseover.RenderBars();
|
||||
g_Selection.RenderBars();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
/*glPopMatrix();
|
||||
@ -355,8 +355,8 @@ void Render()
|
||||
|
||||
// Depth test is now enabled
|
||||
PROFILE_START( "render rally points" );
|
||||
g_Selection.renderRallyPoints();
|
||||
g_Mouseover.renderRallyPoints();
|
||||
g_Selection.RenderRallyPoints();
|
||||
g_Mouseover.RenderRallyPoints();
|
||||
PROFILE_END( "render rally points" );
|
||||
|
||||
PROFILE_START( "render cinematic splines" );
|
||||
@ -365,7 +365,7 @@ void Render()
|
||||
PROFILE_END( "render cinematic splines" );
|
||||
}
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
PROFILE_START( "render fonts" );
|
||||
MICROLOG(L"render fonts");
|
||||
@ -387,7 +387,7 @@ void Render()
|
||||
|
||||
PROFILE_END( "render fonts" );
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
#ifndef NO_GUI
|
||||
// Temp GUI message GeeTODO
|
||||
@ -397,10 +397,10 @@ void Render()
|
||||
PROFILE_END( "render gui" );
|
||||
#endif
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
// Particle Engine Updating
|
||||
CParticleEngine::GetInstance()->updateEmitters();
|
||||
CParticleEngine::GetInstance()->UpdateEmitters();
|
||||
|
||||
// Text:
|
||||
|
||||
@ -411,7 +411,7 @@ void Render()
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
// -- GL
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
{
|
||||
PROFILE( "render console" );
|
||||
@ -423,7 +423,7 @@ void Render()
|
||||
g_Console->Render();
|
||||
}
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
|
||||
// Profile information
|
||||
@ -432,16 +432,16 @@ void Render()
|
||||
g_ProfileViewer.RenderProfile();
|
||||
PROFILE_END( "render profiling" );
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
if (g_Game && g_Game->IsGameStarted())
|
||||
{
|
||||
PROFILE( "render selection overlays" );
|
||||
g_Mouseover.renderOverlays();
|
||||
g_Selection.renderOverlays();
|
||||
g_Mouseover.RenderOverlays();
|
||||
g_Selection.RenderOverlays();
|
||||
}
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
// Draw the cursor (or set the Windows cursor, on Windows)
|
||||
CStr cursorName = g_BuildingPlacer.m_active ? "action-build" : g_CursorName;
|
||||
@ -457,7 +457,7 @@ void Render()
|
||||
MICROLOG(L"end frame");
|
||||
g_Renderer.EndFrame();
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
}
|
||||
|
||||
|
||||
@ -636,7 +636,7 @@ static void InitPs(bool setup_gui)
|
||||
CFG_GET_SYS_VAL("language", String, lang);
|
||||
I18n::LoadLanguage(lang.c_str());
|
||||
|
||||
loadHotkeys();
|
||||
LoadHotkeys();
|
||||
}
|
||||
|
||||
// GUI uses VFS, so this must come after VFS init.
|
||||
@ -658,13 +658,13 @@ static void InitInput()
|
||||
// processed.
|
||||
in_add_handler(game_view_handler);
|
||||
|
||||
in_add_handler(interactInputHandler);
|
||||
in_add_handler(InteractInputHandler);
|
||||
|
||||
in_add_handler(conInputHandler);
|
||||
|
||||
in_add_handler(CProfileViewer::InputThunk);
|
||||
|
||||
in_add_handler(hotkeyInputHandler);
|
||||
in_add_handler(HotkeyInputHandler);
|
||||
|
||||
in_add_handler(GlobalsInputHandler);
|
||||
}
|
||||
@ -885,7 +885,7 @@ void Init(const CmdLineArgs& args, uint flags)
|
||||
debug_filter_add("TIMER");
|
||||
|
||||
// Query CPU capabilities, possibly set some CPU-dependent flags
|
||||
cpu_init();
|
||||
cpu_Init();
|
||||
|
||||
// Do this as soon as possible, because it chdirs
|
||||
// and will mess up the error reporting if anything
|
||||
@ -968,7 +968,7 @@ void Init(const CmdLineArgs& args, uint flags)
|
||||
// required by ogl_tex to detect broken gfx card/driver combos
|
||||
gfx_detect();
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
if(!g_Quickstart)
|
||||
{
|
||||
@ -984,8 +984,8 @@ void Init(const CmdLineArgs& args, uint flags)
|
||||
snd_disable(true);
|
||||
}
|
||||
|
||||
// (must come after SetVideoMode, since it calls oglInit)
|
||||
const char* missing = oglHaveExtensions(0,
|
||||
// (must come after SetVideoMode, since it calls ogl_Init)
|
||||
const char* missing = ogl_HaveExtensions(0,
|
||||
"GL_ARB_multitexture",
|
||||
"GL_EXT_draw_range_elements",
|
||||
"GL_ARB_texture_env_combine",
|
||||
@ -1003,7 +1003,7 @@ void Init(const CmdLineArgs& args, uint flags)
|
||||
// TODO: i18n
|
||||
}
|
||||
|
||||
if (!oglHaveExtension("GL_ARB_texture_env_crossbar"))
|
||||
if (!ogl_HaveExtension("GL_ARB_texture_env_crossbar"))
|
||||
{
|
||||
DISPLAY_ERROR(
|
||||
L"The GL_ARB_texture_env_crossbar extension doesn't appear to be available on your computer."
|
||||
@ -1015,14 +1015,14 @@ void Init(const CmdLineArgs& args, uint flags)
|
||||
// enable/disable VSync
|
||||
// note: "GL_EXT_SWAP_CONTROL" is "historical" according to dox.
|
||||
#if OS_WIN
|
||||
if(oglHaveExtension("WGL_EXT_swap_control"))
|
||||
if(ogl_HaveExtension("WGL_EXT_swap_control"))
|
||||
pwglSwapIntervalEXT(g_VSync? 1 : 0);
|
||||
#endif
|
||||
|
||||
MICROLOG(L"init ps");
|
||||
InitPs(setup_gui);
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
InitRenderer();
|
||||
|
||||
if (! (flags & INIT_NO_SIM))
|
||||
@ -1033,11 +1033,11 @@ void Init(const CmdLineArgs& args, uint flags)
|
||||
new CEntityTemplateCollection;
|
||||
new CFormationCollection;
|
||||
new CTechnologyCollection;
|
||||
g_EntityFormationCollection.loadTemplates();
|
||||
g_TechnologyCollection.loadTechnologies();
|
||||
g_EntityFormationCollection.LoadTemplates();
|
||||
g_TechnologyCollection.LoadTechnologies();
|
||||
new CFormationManager;
|
||||
new CTriggerManager;
|
||||
g_TriggerManager.LoadXML(CStr("scripts/TriggerSpecs.xml"));
|
||||
g_TriggerManager.LoadXml(CStr("scripts/TriggerSpecs.xml"));
|
||||
g_ScriptingHost.RunScript("scripts/trigger_functions.js");
|
||||
|
||||
// CEntityManager is managed by CWorld
|
||||
@ -1066,7 +1066,7 @@ void Init(const CmdLineArgs& args, uint flags)
|
||||
|
||||
InitInput();
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
#ifndef NO_GUI
|
||||
{
|
||||
|
@ -1,12 +1,13 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "Hotkey.h"
|
||||
|
||||
#include "lib/input.h"
|
||||
#include "ConfigDB.h"
|
||||
#include "CLogger.h"
|
||||
#include "CConsole.h"
|
||||
#include "CStr.h"
|
||||
#include "ps/Globals.h"
|
||||
#include "KeyName.h"
|
||||
|
||||
extern CConsole* g_Console;
|
||||
|
||||
@ -151,28 +152,27 @@ static SHotkeyInfo hotkeyInfo[] =
|
||||
|
||||
/* GUI-type */
|
||||
|
||||
struct SHotkeyMappingGUI
|
||||
struct SHotkeyMappingGui
|
||||
{
|
||||
CStr mapsTo;
|
||||
bool negation;
|
||||
std::vector<int> requires;
|
||||
SHotkeyMappingGUI() : mapsTo(-1) {}
|
||||
SHotkeyMappingGui() : mapsTo(-1) {}
|
||||
};
|
||||
|
||||
typedef std::vector<SHotkeyMappingGUI> GuiMapping;
|
||||
typedef std::vector<SHotkeyMappingGui> GuiMapping;
|
||||
|
||||
// A mapping of keycodes onto sets of hotkey name strings (e.g. '[hotkey.]camera.reset')
|
||||
static GuiMapping hotkeyMapGUI[HK_MAX_KEYCODES];
|
||||
static GuiMapping hotkeyMapGui[HK_MAX_KEYCODES];
|
||||
|
||||
typedef std::vector<CStr> GUIObjectList; // A list of GUI objects
|
||||
typedef std::map<CStr,GUIObjectList> GUIHotkeyMap; // A mapping of name strings to lists of GUI objects that they trigger
|
||||
typedef std::vector<CStr> GuiObjectList; // A list of GUI objects
|
||||
typedef std::map<CStr,GuiObjectList> GuiHotkeyMap; // A mapping of name strings to lists of GUI objects that they trigger
|
||||
|
||||
static GUIHotkeyMap guiHotkeyMap;
|
||||
static GuiHotkeyMap guiHotkeyMap;
|
||||
|
||||
// Look up a key binding in the config file and set the mappings for
|
||||
// all key combinations that trigger it.
|
||||
|
||||
void setBindings( const CStr& hotkeyName, int integerMapping = -1 )
|
||||
static void setBindings( const CStr& hotkeyName, int integerMapping = -1 )
|
||||
{
|
||||
CConfigValueSet* binding = g_ConfigDB.GetValues( CFG_USER, CStr( "hotkey." ) + hotkeyName );
|
||||
if( binding )
|
||||
@ -211,7 +211,7 @@ void setBindings( const CStr& hotkeyName, int integerMapping = -1 )
|
||||
}
|
||||
|
||||
// Attempt decode as key name
|
||||
mapping = getKeyCode( hotkey );
|
||||
mapping = FindKeyCode( hotkey );
|
||||
|
||||
// Attempt to decode as a negation of a keyname
|
||||
// Yes, it's going a bit far, perhaps.
|
||||
@ -237,7 +237,7 @@ void setBindings( const CStr& hotkeyName, int integerMapping = -1 )
|
||||
std::vector<int>::iterator itKey, itKey2;
|
||||
|
||||
SHotkeyMapping bindCode;
|
||||
SHotkeyMappingGUI bindName;
|
||||
SHotkeyMappingGui bindName;
|
||||
|
||||
for( itKey = keyCombination.begin(); itKey != keyCombination.end(); itKey++ )
|
||||
{
|
||||
@ -261,7 +261,7 @@ void setBindings( const CStr& hotkeyName, int integerMapping = -1 )
|
||||
}
|
||||
}
|
||||
|
||||
hotkeyMapGUI[*itKey & ~HOTKEY_NEGATION_FLAG].push_back( bindName );
|
||||
hotkeyMapGui[*itKey & ~HOTKEY_NEGATION_FLAG].push_back( bindName );
|
||||
if( integerMapping != -1 )
|
||||
hotkeyMap[*itKey & ~HOTKEY_NEGATION_FLAG].push_back( bindCode );
|
||||
}
|
||||
@ -282,13 +282,11 @@ void setBindings( const CStr& hotkeyName, int integerMapping = -1 )
|
||||
hotkeyMap[ hotkeyInfo[integerMapping].defaultmapping2 ].push_back( bind[1] );
|
||||
}
|
||||
}
|
||||
void loadHotkeys()
|
||||
void LoadHotkeys()
|
||||
{
|
||||
initKeyNameMap();
|
||||
InitKeyNameMap();
|
||||
|
||||
int i;
|
||||
|
||||
for( i = 0; i < HOTKEY_LAST; i++ )
|
||||
for(int i = 0; i < HOTKEY_LAST; i++ )
|
||||
setBindings( hotkeyInfo[i].name, i );
|
||||
|
||||
// Set up the state of the hotkeys given no key is down.
|
||||
@ -298,7 +296,7 @@ void loadHotkeys()
|
||||
std::vector<int>::iterator j;
|
||||
bool allNegated;
|
||||
|
||||
for( i = 1; i < HK_MAX_KEYCODES; i++ )
|
||||
for(int i = 1; i < HK_MAX_KEYCODES; i++ )
|
||||
{
|
||||
for( it = hotkeyMap[i].begin(); it != hotkeyMap[i].end(); it++ )
|
||||
{
|
||||
@ -319,9 +317,9 @@ void loadHotkeys()
|
||||
}
|
||||
}
|
||||
|
||||
void hotkeyRegisterGUIObject( const CStr& objName, const CStr& hotkeyName )
|
||||
void HotkeyRegisterGuiObject( const CStr& objName, const CStr& hotkeyName )
|
||||
{
|
||||
GUIObjectList& boundTo = guiHotkeyMap[hotkeyName];
|
||||
GuiObjectList& boundTo = guiHotkeyMap[hotkeyName];
|
||||
if( boundTo.empty() )
|
||||
{
|
||||
// Load keybindings from the config file
|
||||
@ -330,7 +328,7 @@ void hotkeyRegisterGUIObject( const CStr& objName, const CStr& hotkeyName )
|
||||
boundTo.push_back( objName );
|
||||
}
|
||||
|
||||
InReaction hotkeyInputHandler( const SDL_Event_* ev )
|
||||
InReaction HotkeyInputHandler( const SDL_Event_* ev )
|
||||
{
|
||||
int keycode = 0;
|
||||
|
||||
@ -358,31 +356,31 @@ InReaction hotkeyInputHandler( const SDL_Event_* ev )
|
||||
{
|
||||
(int&)phantom.ev.key.keysym.sym = UNIFIED_SHIFT;
|
||||
unified[0] = ( phantom.ev.type == SDL_KEYDOWN );
|
||||
hotkeyInputHandler( &phantom );
|
||||
HotkeyInputHandler( &phantom );
|
||||
}
|
||||
else if( ( keycode == SDLK_LCTRL ) || ( keycode == SDLK_RCTRL ) )
|
||||
{
|
||||
(int&)phantom.ev.key.keysym.sym = UNIFIED_CTRL;
|
||||
unified[1] = ( phantom.ev.type == SDL_KEYDOWN );
|
||||
hotkeyInputHandler( &phantom );
|
||||
HotkeyInputHandler( &phantom );
|
||||
}
|
||||
else if( ( keycode == SDLK_LALT ) || ( keycode == SDLK_RALT ) )
|
||||
{
|
||||
(int&)phantom.ev.key.keysym.sym = UNIFIED_ALT;
|
||||
unified[2] = ( phantom.ev.type == SDL_KEYDOWN );
|
||||
hotkeyInputHandler( &phantom );
|
||||
HotkeyInputHandler( &phantom );
|
||||
}
|
||||
else if( ( keycode == SDLK_LMETA ) || ( keycode == SDLK_RMETA ) )
|
||||
{
|
||||
(int&)phantom.ev.key.keysym.sym = UNIFIED_META;
|
||||
unified[3] = ( phantom.ev.type == SDL_KEYDOWN );
|
||||
hotkeyInputHandler( &phantom );
|
||||
HotkeyInputHandler( &phantom );
|
||||
}
|
||||
else if( ( keycode == SDLK_LSUPER ) || ( keycode == SDLK_RSUPER ) )
|
||||
{
|
||||
(int&)phantom.ev.key.keysym.sym = UNIFIED_SUPER;
|
||||
unified[4] = ( phantom.ev.type == SDL_KEYDOWN );
|
||||
hotkeyInputHandler( &phantom );
|
||||
HotkeyInputHandler( &phantom );
|
||||
}
|
||||
|
||||
// Inhibit the dispatch of hotkey events caused by printable or control keys
|
||||
@ -399,7 +397,7 @@ InReaction hotkeyInputHandler( const SDL_Event_* ev )
|
||||
consoleCapture = true;
|
||||
|
||||
std::vector<SHotkeyMapping>::iterator it;
|
||||
std::vector<SHotkeyMappingGUI>::iterator itGUI;
|
||||
std::vector<SHotkeyMappingGui>::iterator itGUI;
|
||||
|
||||
SDL_Event hotkeyNotification;
|
||||
|
||||
@ -493,7 +491,7 @@ InReaction hotkeyInputHandler( const SDL_Event_* ev )
|
||||
CStr closestMapName = -1;
|
||||
closestMapMatch = 0;
|
||||
|
||||
for( itGUI = hotkeyMapGUI[keycode].begin(); itGUI != hotkeyMapGUI[keycode].end(); itGUI++ )
|
||||
for( itGUI = hotkeyMapGui[keycode].begin(); itGUI != hotkeyMapGui[keycode].end(); itGUI++ )
|
||||
{
|
||||
// If a key has been pressed, and this event triggers on it's release, skip it.
|
||||
// Similarly, if the key's been released and the event triggers on a keypress, skip it.
|
||||
@ -549,12 +547,12 @@ InReaction hotkeyInputHandler( const SDL_Event_* ev )
|
||||
|
||||
if( closestMapMatch )
|
||||
{
|
||||
GUIHotkeyMap::iterator map_it;
|
||||
GUIObjectList::iterator obj_it;
|
||||
GuiHotkeyMap::iterator map_it;
|
||||
GuiObjectList::iterator obj_it;
|
||||
map_it = guiHotkeyMap.find( closestMapName );
|
||||
if( map_it != guiHotkeyMap.end() )
|
||||
{
|
||||
GUIObjectList& targets = map_it->second;
|
||||
GuiObjectList& targets = map_it->second;
|
||||
for( obj_it = targets.begin(); obj_it != targets.end(); obj_it++ )
|
||||
{
|
||||
hotkeyNotification.type = SDL_GUIHOTKEYPRESS;
|
||||
@ -611,10 +609,7 @@ InReaction hotkeyInputHandler( const SDL_Event_* ev )
|
||||
}
|
||||
|
||||
|
||||
// Returns true if the specified HOTKEY_* responds to the specified SDLK_*
|
||||
// (mainly for the screenshot system to know whether it needs to override
|
||||
// the printscreen screen). Ignores modifier keys.
|
||||
bool keyRespondsTo( int hotkey, int sdlkey )
|
||||
bool HotkeyRespondsTo( int hotkey, int sdlkey )
|
||||
{
|
||||
for (KeyMapping::iterator it = hotkeyMap[sdlkey].begin(); it != hotkeyMap[sdlkey].end(); ++it)
|
||||
if (it->mapsTo == hotkey)
|
||||
@ -622,8 +617,8 @@ bool keyRespondsTo( int hotkey, int sdlkey )
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns true if one of the key combinations for the given hotkey is pressed
|
||||
bool isKeyDown( const CStr& keyname )
|
||||
|
||||
bool HotkeyIsPressed( const CStr& keyname )
|
||||
{
|
||||
return hotkeys[getKeyCode(keyname)];
|
||||
return hotkeys[FindKeyCode(keyname)];
|
||||
}
|
||||
|
@ -118,14 +118,20 @@ enum
|
||||
HOTKEY_NEGATION_FLAG = 65536
|
||||
};
|
||||
|
||||
extern void loadHotkeys();
|
||||
extern InReaction hotkeyInputHandler( const SDL_Event_* ev );
|
||||
extern void hotkeyRegisterGUIObject( const CStr& objName, const CStr& hotkeyName );
|
||||
extern void LoadHotkeys();
|
||||
extern InReaction HotkeyInputHandler( const SDL_Event_* ev );
|
||||
extern void HotkeyRegisterGuiObject( const CStr& objName, const CStr& hotkeyName );
|
||||
|
||||
extern void initKeyNameMap();
|
||||
extern CStr getKeyName( int keycode );
|
||||
extern int getKeyCode( const CStr& keyname );
|
||||
/**
|
||||
* @return whether the specified HOTKEY_* responds to the specified SDLK_*
|
||||
* (mainly for the screenshot system to know whether it needs to override
|
||||
* the printscreen screen). Ignores modifier keys.
|
||||
**/
|
||||
extern bool HotkeyRespondsTo( int hotkey, int sdlkey );
|
||||
|
||||
extern bool keyRespondsTo( int hotkey, int sdlkey );
|
||||
/**
|
||||
* @return whether one of the key combinations for the given hotkey is pressed
|
||||
**/
|
||||
extern bool HotkeyIsPressed( const CStr& keyname );
|
||||
|
||||
extern bool hotkeys[HOTKEY_LAST];
|
||||
|
@ -47,19 +47,19 @@ const int ORDER_DELAY = 5;
|
||||
|
||||
bool customSelectionMode=false;
|
||||
|
||||
void CSelectedEntities::addSelection( HEntity entity )
|
||||
void CSelectedEntities::AddSelection( HEntity entity )
|
||||
{
|
||||
m_group = -1;
|
||||
debug_assert( !isSelected( entity ) );
|
||||
debug_assert( !IsSelected( entity ) );
|
||||
m_selected.push_back( entity );
|
||||
entity->m_selected = true;
|
||||
m_selectionChanged = true;
|
||||
}
|
||||
|
||||
void CSelectedEntities::removeSelection( HEntity entity )
|
||||
void CSelectedEntities::RemoveSelection( HEntity entity )
|
||||
{
|
||||
m_group = -1;
|
||||
debug_assert( isSelected( entity ) );
|
||||
debug_assert( IsSelected( entity ) );
|
||||
entity->m_selected = false;
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
||||
@ -73,11 +73,11 @@ void CSelectedEntities::removeSelection( HEntity entity )
|
||||
}
|
||||
}
|
||||
|
||||
void CSelectedEntities::renderSelectionOutlines()
|
||||
void CSelectedEntities::RenderSelectionOutlines()
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
||||
(*it)->renderSelectionOutline();
|
||||
(*it)->RenderSelectionOutline();
|
||||
|
||||
if( m_group_highlight != -1 )
|
||||
{
|
||||
@ -86,17 +86,17 @@ void CSelectedEntities::renderSelectionOutlines()
|
||||
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
||||
(*it)->renderSelectionOutline( 0.5f );
|
||||
(*it)->RenderSelectionOutline( 0.5f );
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
}
|
||||
}
|
||||
|
||||
void CSelectedEntities::renderBars()
|
||||
void CSelectedEntities::RenderBars()
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
||||
(*it)->renderBars();
|
||||
(*it)->RenderBars();
|
||||
|
||||
/*if( m_group_highlight != -1 )
|
||||
{
|
||||
@ -105,26 +105,26 @@ void CSelectedEntities::renderBars()
|
||||
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
||||
(*it)->renderBars();
|
||||
(*it)->RenderBars();
|
||||
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
}*/
|
||||
}
|
||||
void CSelectedEntities::renderAuras()
|
||||
void CSelectedEntities::RenderAuras()
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
for ( it = m_selected.begin(); it != m_selected.end(); ++it )
|
||||
(*it)->renderAuras();
|
||||
(*it)->RenderAuras();
|
||||
}
|
||||
void CSelectedEntities::renderHealthBars()
|
||||
void CSelectedEntities::RenderHealthBars()
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
||||
(*it)->renderHealthBar();
|
||||
(*it)->RenderHealthBar();
|
||||
|
||||
if( m_group_highlight != -1 )
|
||||
{
|
||||
@ -133,17 +133,17 @@ void CSelectedEntities::renderHealthBars()
|
||||
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
||||
(*it)->renderHealthBar();
|
||||
(*it)->RenderHealthBar();
|
||||
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
}
|
||||
}
|
||||
void CSelectedEntities::renderStaminaBars()
|
||||
void CSelectedEntities::RenderStaminaBars()
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
||||
(*it)->renderStaminaBar();
|
||||
(*it)->RenderStaminaBar();
|
||||
|
||||
if( m_group_highlight != -1 )
|
||||
{
|
||||
@ -152,16 +152,16 @@ void CSelectedEntities::renderStaminaBars()
|
||||
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
||||
(*it)->renderStaminaBar();
|
||||
(*it)->RenderStaminaBar();
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
}
|
||||
}
|
||||
void CSelectedEntities::renderBarBorders()
|
||||
void CSelectedEntities::RenderBarBorders()
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
||||
(*it)->renderBarBorders();
|
||||
(*it)->RenderBarBorders();
|
||||
|
||||
if( m_group_highlight != -1 )
|
||||
{
|
||||
@ -170,17 +170,17 @@ void CSelectedEntities::renderBarBorders()
|
||||
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
||||
(*it)->renderBarBorders();
|
||||
(*it)->RenderBarBorders();
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
}
|
||||
}
|
||||
|
||||
void CSelectedEntities::renderRanks()
|
||||
void CSelectedEntities::RenderRanks()
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
||||
(*it)->renderRank();
|
||||
(*it)->RenderRank();
|
||||
|
||||
if( m_group_highlight != -1 )
|
||||
{
|
||||
@ -189,14 +189,14 @@ void CSelectedEntities::renderRanks()
|
||||
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
||||
(*it)->renderRank();
|
||||
(*it)->RenderRank();
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSelectedEntities::renderOverlays()
|
||||
void CSelectedEntities::RenderOverlays()
|
||||
{
|
||||
CTerrain *pTerrain=g_Game->GetWorld()->GetTerrain();
|
||||
CCamera *pCamera=g_Game->GetView()->GetCamera();
|
||||
@ -214,7 +214,7 @@ void CSelectedEntities::renderOverlays()
|
||||
float x, y;
|
||||
CVector3D labelpos = (*it)->m_graphics_position - pCamera->m_Orientation.GetLeft() * (*it)->m_bounds->m_radius;
|
||||
#ifdef SELECTION_TERRAIN_CONFORMANCE
|
||||
labelpos.Y = pTerrain->getExactGroundLevel( labelpos.X, labelpos.Z );
|
||||
labelpos.Y = pTerrain->GetExactGroundLevel( labelpos.X, labelpos.Z );
|
||||
#endif
|
||||
pCamera->GetScreenCoordinates( labelpos, x, y );
|
||||
glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
@ -238,7 +238,7 @@ void CSelectedEntities::renderOverlays()
|
||||
float x, y;
|
||||
CVector3D labelpos = (*it)->m_graphics_position - pCamera->m_Orientation.GetLeft() * (*it)->m_bounds->m_radius;
|
||||
#ifdef SELECTION_TERRAIN_CONFORMANCE
|
||||
labelpos.Y = pTerrain->getExactGroundLevel( labelpos.X, labelpos.Z );
|
||||
labelpos.Y = pTerrain->GetExactGroundLevel( labelpos.X, labelpos.Z );
|
||||
#endif
|
||||
pCamera->GetScreenCoordinates( labelpos, x, y );
|
||||
glColor4f( 1.0f, 1.0f, 1.0f, 0.5f );
|
||||
@ -276,31 +276,31 @@ void CSelectedEntities::renderOverlays()
|
||||
glDisable( GL_TEXTURE_2D );
|
||||
glPopMatrix();
|
||||
}
|
||||
void CSelectedEntities::renderRallyPoints()
|
||||
void CSelectedEntities::RenderRallyPoints()
|
||||
{
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
glEnable( GL_BLEND );
|
||||
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
||||
(*it)->renderRallyPoint();
|
||||
(*it)->RenderRallyPoint();
|
||||
|
||||
if( m_group_highlight != -1 )
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
||||
(*it)->renderRallyPoint();
|
||||
(*it)->RenderRallyPoint();
|
||||
}
|
||||
glDisable( GL_BLEND );
|
||||
}
|
||||
void CSelectedEntities::setSelection( HEntity entity )
|
||||
void CSelectedEntities::SetSelection( HEntity entity )
|
||||
{
|
||||
m_group = -1;
|
||||
clearSelection();
|
||||
ClearSelection();
|
||||
m_selected.push_back( entity );
|
||||
}
|
||||
|
||||
void CSelectedEntities::clearSelection()
|
||||
void CSelectedEntities::ClearSelection()
|
||||
{
|
||||
m_group = -1;
|
||||
std::vector<HEntity>::iterator it;
|
||||
@ -310,7 +310,7 @@ void CSelectedEntities::clearSelection()
|
||||
m_selectionChanged = true;
|
||||
}
|
||||
|
||||
void CSelectedEntities::removeAll( HEntity entity )
|
||||
void CSelectedEntities::RemoveAll( HEntity entity )
|
||||
{
|
||||
// Remove a reference to an entity from everywhere
|
||||
// (for use when said entity is being destroyed)
|
||||
@ -338,7 +338,7 @@ void CSelectedEntities::removeAll( HEntity entity )
|
||||
}
|
||||
}
|
||||
|
||||
CVector3D CSelectedEntities::getSelectionPosition()
|
||||
CVector3D CSelectedEntities::GetSelectionPosition()
|
||||
{
|
||||
CVector3D avg;
|
||||
std::vector<HEntity>::iterator it;
|
||||
@ -347,7 +347,7 @@ CVector3D CSelectedEntities::getSelectionPosition()
|
||||
return( avg * ( 1.0f / m_selected.size() ) );
|
||||
}
|
||||
|
||||
void CSelectedEntities::saveGroup( i8 groupid )
|
||||
void CSelectedEntities::SaveGroup( i8 groupid )
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
// Clear all entities in the group...
|
||||
@ -380,7 +380,7 @@ void CSelectedEntities::saveGroup( i8 groupid )
|
||||
m_group = groupid;
|
||||
}
|
||||
|
||||
void CSelectedEntities::addToGroup( i8 groupid, HEntity entity )
|
||||
void CSelectedEntities::AddToGroup( i8 groupid, HEntity entity )
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
|
||||
@ -404,7 +404,7 @@ void CSelectedEntities::addToGroup( i8 groupid, HEntity entity )
|
||||
m_groups[groupid].push_back( entity );
|
||||
}
|
||||
|
||||
void CSelectedEntities::loadGroup( i8 groupid )
|
||||
void CSelectedEntities::LoadGroup( i8 groupid )
|
||||
{
|
||||
if( m_group == groupid )
|
||||
return;
|
||||
@ -415,7 +415,7 @@ void CSelectedEntities::loadGroup( i8 groupid )
|
||||
return;
|
||||
}
|
||||
|
||||
clearSelection();
|
||||
ClearSelection();
|
||||
m_selected = m_groups[groupid];
|
||||
|
||||
std::vector<HEntity>::iterator it;
|
||||
@ -426,19 +426,19 @@ void CSelectedEntities::loadGroup( i8 groupid )
|
||||
m_selectionChanged = true;
|
||||
}
|
||||
|
||||
void CSelectedEntities::addGroup( i8 groupid )
|
||||
void CSelectedEntities::AddGroup( i8 groupid )
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_groups[groupid].begin(); it < m_groups[groupid].end(); it++ )
|
||||
{
|
||||
if( !isSelected( *it ) )
|
||||
addSelection( *it );
|
||||
if( !IsSelected( *it ) )
|
||||
AddSelection( *it );
|
||||
}
|
||||
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
||||
(*it)->m_selected = true;
|
||||
}
|
||||
|
||||
void CSelectedEntities::changeGroup( HEntity entity, i8 groupid )
|
||||
void CSelectedEntities::ChangeGroup( HEntity entity, i8 groupid )
|
||||
{
|
||||
// Remove from current group
|
||||
i32 current = entity->m_grouped;
|
||||
@ -459,7 +459,7 @@ void CSelectedEntities::changeGroup( HEntity entity, i8 groupid )
|
||||
entity->m_grouped = groupid;
|
||||
}
|
||||
|
||||
bool CSelectedEntities::isSelected( HEntity entity )
|
||||
bool CSelectedEntities::IsSelected( HEntity entity )
|
||||
{
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
||||
@ -470,17 +470,17 @@ bool CSelectedEntities::isSelected( HEntity entity )
|
||||
return( false );
|
||||
}
|
||||
|
||||
void CSelectedEntities::highlightGroup( i8 groupid )
|
||||
void CSelectedEntities::HighlightGroup( i8 groupid )
|
||||
{
|
||||
if( m_group_highlight != -1 )
|
||||
return;
|
||||
if( !getGroupCount( groupid ) )
|
||||
if( !GetGroupCount( groupid ) )
|
||||
return;
|
||||
m_group_highlight = groupid;
|
||||
g_Game->GetView()->PushCameraTarget( getGroupPosition( groupid ) );
|
||||
g_Game->GetView()->PushCameraTarget( GetGroupPosition( groupid ) );
|
||||
}
|
||||
|
||||
void CSelectedEntities::highlightNone()
|
||||
void CSelectedEntities::HighlightNone()
|
||||
{
|
||||
|
||||
if( m_group_highlight != -1 )
|
||||
@ -489,12 +489,12 @@ void CSelectedEntities::highlightNone()
|
||||
|
||||
}
|
||||
|
||||
int CSelectedEntities::getGroupCount( i8 groupid )
|
||||
int CSelectedEntities::GetGroupCount( i8 groupid )
|
||||
{
|
||||
return( (int)m_groups[groupid].size() );
|
||||
}
|
||||
|
||||
CVector3D CSelectedEntities::getGroupPosition( i8 groupid )
|
||||
CVector3D CSelectedEntities::GetGroupPosition( i8 groupid )
|
||||
{
|
||||
CVector3D avg;
|
||||
std::vector<HEntity>::iterator it;
|
||||
@ -503,7 +503,7 @@ CVector3D CSelectedEntities::getGroupPosition( i8 groupid )
|
||||
return( avg * ( 1.0f / m_groups[groupid].size() ) );
|
||||
}
|
||||
|
||||
void CSelectedEntities::update()
|
||||
void CSelectedEntities::Update()
|
||||
{
|
||||
static std::vector<HEntity> lastSelection;
|
||||
|
||||
@ -520,7 +520,7 @@ void CSelectedEntities::update()
|
||||
if( m_selectionChanged || g_Mouseover.m_targetChanged )
|
||||
{
|
||||
// Can't order anything off the map
|
||||
if( !g_Game->GetWorld()->GetTerrain()->isOnMap( g_Mouseover.m_worldposition ) )
|
||||
if( !g_Game->GetWorld()->GetTerrain()->IsOnMap( g_Mouseover.m_worldposition ) )
|
||||
{
|
||||
m_defaultCommand = -1;
|
||||
m_secondaryCommand = -1;
|
||||
@ -631,12 +631,12 @@ void CSelectedEntities::update()
|
||||
g_Mouseover.m_targetChanged = false;
|
||||
}
|
||||
|
||||
if( ( m_group_highlight != -1 ) && getGroupCount( m_group_highlight ) )
|
||||
g_Game->GetView()->SetCameraTarget( getGroupPosition( m_group_highlight ) );
|
||||
if( ( m_group_highlight != -1 ) && GetGroupCount( m_group_highlight ) )
|
||||
g_Game->GetView()->SetCameraTarget( GetGroupPosition( m_group_highlight ) );
|
||||
|
||||
}
|
||||
|
||||
void CMouseoverEntities::update( float timestep )
|
||||
void CMouseoverEntities::Update( float timestep )
|
||||
{
|
||||
CCamera *pCamera=g_Game->GetView()->GetCamera();
|
||||
//CTerrain *pTerrain=g_Game->GetWorld()->GetTerrain();
|
||||
@ -670,14 +670,14 @@ void CMouseoverEntities::update( float timestep )
|
||||
|
||||
m_mouseover.clear();
|
||||
|
||||
std::vector<HEntity>* onscreen = g_EntityManager.matches( isOnScreen );
|
||||
std::vector<HEntity>::iterator it;
|
||||
|
||||
for( it = onscreen->begin(); it < onscreen->end(); it++ )
|
||||
if( (*it)->m_extant && ( (*it)->GetPlayer() == g_Game->GetLocalPlayer() ) )
|
||||
m_mouseover.push_back( SMouseoverFader( *it, m_fademaximum, false ) );
|
||||
|
||||
delete( onscreen );
|
||||
std::vector<HEntity> onscreen;
|
||||
g_EntityManager.GetMatchingAsHandles( onscreen, IsOnScreen );
|
||||
for(std::vector<HEntity>::iterator it = onscreen.begin(); it < onscreen.end(); it++ )
|
||||
{
|
||||
HEntity entity = *it;
|
||||
if( entity->m_extant && ( entity->GetPlayer() == g_Game->GetLocalPlayer() ) )
|
||||
m_mouseover.push_back( SMouseoverFader( entity, m_fademaximum, false ) );
|
||||
}
|
||||
}
|
||||
else if( m_bandbox )
|
||||
{
|
||||
@ -689,28 +689,26 @@ void CMouseoverEntities::update( float timestep )
|
||||
//
|
||||
// Fade in the ones in the box at (in+out) speed, then fade everything
|
||||
// out at (out) speed.
|
||||
std::vector<HEntity>* onscreen = g_EntityManager.matches( isOnScreen );
|
||||
std::vector<HEntity>::iterator it;
|
||||
std::vector<HEntity> onscreen;
|
||||
g_EntityManager.GetMatchingAsHandles( onscreen, IsOnScreen );
|
||||
|
||||
// Reset active flags on everything...
|
||||
|
||||
std::vector<SMouseoverFader>::iterator it2;
|
||||
for( it2 = m_mouseover.begin(); it2 < m_mouseover.end(); it2++ )
|
||||
for(std::vector<SMouseoverFader>::iterator it2 = m_mouseover.begin(); it2 < m_mouseover.end(); it2++ )
|
||||
it2->isActive = false;
|
||||
|
||||
for( it = onscreen->begin(); it < onscreen->end(); it++ )
|
||||
for(std::vector<HEntity>::iterator it = onscreen.begin(); it < onscreen.end(); it++ )
|
||||
{
|
||||
if( !(*it)->m_extant )
|
||||
HEntity entity = *it;
|
||||
if( !entity->m_extant )
|
||||
continue;
|
||||
|
||||
// Can only bandbox units the local player controls.
|
||||
if( (*it)->GetPlayer() != g_Game->GetLocalPlayer() )
|
||||
if( entity->GetPlayer() != g_Game->GetLocalPlayer() )
|
||||
continue;
|
||||
|
||||
CVector3D worldspace = (*it)->m_graphics_position;
|
||||
CVector3D worldspace = entity->m_graphics_position;
|
||||
|
||||
float x, y;
|
||||
|
||||
pCamera->GetScreenCoordinates( worldspace, x, y );
|
||||
|
||||
bool inBox;
|
||||
@ -735,7 +733,7 @@ void CMouseoverEntities::update( float timestep )
|
||||
if( inBox )
|
||||
{
|
||||
bool found = false;
|
||||
for( it2 = m_mouseover.begin(); it2 < m_mouseover.end(); it2++ )
|
||||
for(std::vector<SMouseoverFader>::iterator it2 = m_mouseover.begin(); it2 < m_mouseover.end(); it2++ )
|
||||
if( it2->entity == &(**it) )
|
||||
{
|
||||
found = true;
|
||||
@ -746,9 +744,8 @@ void CMouseoverEntities::update( float timestep )
|
||||
m_mouseover.push_back( SMouseoverFader( *it, ( m_fadeinrate + m_fadeoutrate ) * timestep ) );
|
||||
}
|
||||
}
|
||||
delete( onscreen );
|
||||
|
||||
for( it2 = m_mouseover.begin(); it2 < m_mouseover.end(); )
|
||||
for(std::vector<SMouseoverFader>::iterator it2 = m_mouseover.begin(); it2 < m_mouseover.end(); )
|
||||
{
|
||||
it2->fade -= m_fadeoutrate * timestep;
|
||||
if( it2->fade > m_fademaximum ) it2->fade = m_fademaximum;
|
||||
@ -762,10 +759,9 @@ void CMouseoverEntities::update( float timestep )
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
bool found = false;
|
||||
|
||||
for( it = m_mouseover.begin(); it < m_mouseover.end(); )
|
||||
for(std::vector<SMouseoverFader>::iterator it = m_mouseover.begin(); it < m_mouseover.end(); )
|
||||
{
|
||||
if( it->entity == m_target )
|
||||
{
|
||||
@ -794,7 +790,7 @@ void CMouseoverEntities::update( float timestep )
|
||||
}
|
||||
}
|
||||
|
||||
void CMouseoverEntities::addSelection()
|
||||
void CMouseoverEntities::AddSelection()
|
||||
{
|
||||
// Rules for shift-click selection:
|
||||
|
||||
@ -815,48 +811,54 @@ void CMouseoverEntities::addSelection()
|
||||
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
||||
if( it->isActive && !g_Selection.isSelected( it->entity ) )
|
||||
g_Selection.addSelection( it->entity );
|
||||
if( it->isActive && !g_Selection.IsSelected( it->entity ) )
|
||||
g_Selection.AddSelection( it->entity );
|
||||
}
|
||||
|
||||
void CMouseoverEntities::removeSelection()
|
||||
void CMouseoverEntities::RemoveSelection()
|
||||
{
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
||||
if( it->isActive && g_Selection.isSelected( it->entity ) )
|
||||
g_Selection.removeSelection( it->entity );
|
||||
if( it->isActive && g_Selection.IsSelected( it->entity ) )
|
||||
g_Selection.RemoveSelection( it->entity );
|
||||
}
|
||||
|
||||
void CMouseoverEntities::setSelection()
|
||||
void CMouseoverEntities::SetSelection()
|
||||
{
|
||||
g_Selection.clearSelection();
|
||||
addSelection();
|
||||
g_Selection.ClearSelection();
|
||||
AddSelection();
|
||||
}
|
||||
|
||||
void CMouseoverEntities::expandAcrossScreen()
|
||||
void CMouseoverEntities::ExpandAcrossScreen()
|
||||
{
|
||||
std::vector<HEntity>* activeset = g_EntityManager.matches(
|
||||
CEntityManager::EntityPredicateLogicalAnd<isMouseoverType,isOnScreen> );
|
||||
std::vector<HEntity> activeset;
|
||||
g_EntityManager.GetMatchingAsHandles(
|
||||
activeset,
|
||||
CEntityManager::EntityPredicateLogicalAnd<IsMouseoverType,IsOnScreen>
|
||||
);
|
||||
m_mouseover.clear();
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = activeset->begin(); it < activeset->end(); it++ )
|
||||
if( (*it)->m_extant )
|
||||
m_mouseover.push_back( SMouseoverFader( *it ) );
|
||||
delete( activeset );
|
||||
}
|
||||
|
||||
void CMouseoverEntities::expandAcrossWorld()
|
||||
for(std::vector<HEntity>::iterator it = activeset.begin(); it < activeset.end(); it++ )
|
||||
{
|
||||
std::vector<HEntity>* activeset = g_EntityManager.matches( isMouseoverType );
|
||||
m_mouseover.clear();
|
||||
std::vector<HEntity>::iterator it;
|
||||
for( it = activeset->begin(); it < activeset->end(); it++ )
|
||||
if( (*it)->m_extant )
|
||||
m_mouseover.push_back( SMouseoverFader( *it ) );
|
||||
delete( activeset );
|
||||
HEntity entity = *it;
|
||||
if( entity->m_extant )
|
||||
m_mouseover.push_back( SMouseoverFader( entity ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CMouseoverEntities::renderSelectionOutlines()
|
||||
void CMouseoverEntities::ExpandAcrossWorld()
|
||||
{
|
||||
std::vector<HEntity> activeset;
|
||||
g_EntityManager.GetMatchingAsHandles( activeset, IsMouseoverType );
|
||||
m_mouseover.clear();
|
||||
for(std::vector<HEntity>::iterator it = activeset.begin(); it < activeset.end(); it++ )
|
||||
{
|
||||
HEntity entity = *it;
|
||||
if( entity->m_extant )
|
||||
m_mouseover.push_back( SMouseoverFader( entity ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CMouseoverEntities::RenderSelectionOutlines()
|
||||
{
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
glEnable( GL_BLEND );
|
||||
@ -864,13 +866,13 @@ void CMouseoverEntities::renderSelectionOutlines()
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
||||
{
|
||||
if( !g_Selection.isSelected(it->entity) )
|
||||
it->entity->renderSelectionOutline( it->fade );
|
||||
if( !g_Selection.IsSelected(it->entity) )
|
||||
it->entity->RenderSelectionOutline( it->fade );
|
||||
}
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
}
|
||||
void CMouseoverEntities::renderAuras()
|
||||
void CMouseoverEntities::RenderAuras()
|
||||
{
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@ -878,77 +880,77 @@ void CMouseoverEntities::renderAuras()
|
||||
|
||||
for ( it = m_mouseover.begin(); it != m_mouseover.end(); ++it )
|
||||
{
|
||||
if( !g_Selection.isSelected(it->entity) )
|
||||
it->entity->renderAuras();
|
||||
if( !g_Selection.IsSelected(it->entity) )
|
||||
it->entity->RenderAuras();
|
||||
}
|
||||
}
|
||||
void CMouseoverEntities::renderBars()
|
||||
void CMouseoverEntities::RenderBars()
|
||||
{
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
||||
{
|
||||
if( !g_Selection.isSelected(it->entity) )
|
||||
it->entity->renderBars();
|
||||
if( !g_Selection.IsSelected(it->entity) )
|
||||
it->entity->RenderBars();
|
||||
}
|
||||
}
|
||||
|
||||
void CMouseoverEntities::renderHealthBars()
|
||||
void CMouseoverEntities::RenderHealthBars()
|
||||
{
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
glEnable( GL_BLEND );
|
||||
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
||||
it->entity->renderHealthBar();
|
||||
it->entity->RenderHealthBar();
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
}
|
||||
|
||||
void CMouseoverEntities::renderStaminaBars()
|
||||
void CMouseoverEntities::RenderStaminaBars()
|
||||
{
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
glEnable( GL_BLEND );
|
||||
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
||||
it->entity->renderStaminaBar();
|
||||
it->entity->RenderStaminaBar();
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
}
|
||||
void CMouseoverEntities::renderRanks()
|
||||
void CMouseoverEntities::RenderRanks()
|
||||
{
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
glEnable( GL_BLEND );
|
||||
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
||||
it->entity->renderRank();
|
||||
it->entity->RenderRank();
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
}
|
||||
void CMouseoverEntities::renderBarBorders()
|
||||
void CMouseoverEntities::RenderBarBorders()
|
||||
{
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
glEnable( GL_BLEND );
|
||||
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
||||
it->entity->renderBarBorders();
|
||||
it->entity->RenderBarBorders();
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
}
|
||||
void CMouseoverEntities::renderRallyPoints()
|
||||
void CMouseoverEntities::RenderRallyPoints()
|
||||
{
|
||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
glEnable( GL_BLEND );
|
||||
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
||||
it->entity->renderRallyPoint();
|
||||
it->entity->RenderRallyPoint();
|
||||
|
||||
glDisable( GL_BLEND );
|
||||
}
|
||||
// Helper function for CSelectedEntities::loadUnitUITextures
|
||||
// Helper function for CSelectedEntities::LoadUnitUiTextures
|
||||
static void LoadUnitUIThunk( const char* path, const DirEnt* UNUSED(ent), void* context )
|
||||
{
|
||||
std::map<CStr, Handle>* textures = (std::map<CStr, Handle>*) context;
|
||||
@ -966,13 +968,13 @@ static void LoadUnitUIThunk( const char* path, const DirEnt* UNUSED(ent), void*
|
||||
(*textures)[name] = tmp;
|
||||
ogl_tex_upload(tmp);
|
||||
}
|
||||
int CSelectedEntities::loadUnitUITextures()
|
||||
int CSelectedEntities::LoadUnitUiTextures()
|
||||
{
|
||||
THROW_ERR( vfs_dir_enum( "art/textures/ui/session/icons/", VFS_DIR_RECURSIVE,
|
||||
NULL, LoadUnitUIThunk, &m_unitUITextures ) );
|
||||
return 0;
|
||||
}
|
||||
void CSelectedEntities::destroyUnitUITextures()
|
||||
void CSelectedEntities::DestroyUnitUiTextures()
|
||||
{
|
||||
for ( std::map<CStr, Handle>::iterator it=m_unitUITextures.begin(); it != m_unitUITextures.end(); it++ )
|
||||
{
|
||||
@ -980,7 +982,7 @@ void CSelectedEntities::destroyUnitUITextures()
|
||||
it->second = 0;
|
||||
}
|
||||
}
|
||||
void CMouseoverEntities::renderOverlays()
|
||||
void CMouseoverEntities::RenderOverlays()
|
||||
{
|
||||
CCamera *pCamera=g_Game->GetView()->GetCamera();
|
||||
CTerrain *pTerrain=g_Game->GetWorld()->GetTerrain();
|
||||
@ -1013,7 +1015,7 @@ void CMouseoverEntities::renderOverlays()
|
||||
float x, y;
|
||||
CVector3D labelpos = it->entity->m_graphics_position - pCamera->m_Orientation.GetLeft() * it->entity->m_bounds->m_radius;
|
||||
#ifdef SELECTION_TERRAIN_CONFORMANCE
|
||||
labelpos.Y = pTerrain->getExactGroundLevel( labelpos.X, labelpos.Z );
|
||||
labelpos.Y = pTerrain->GetExactGroundLevel( labelpos.X, labelpos.Z );
|
||||
#endif
|
||||
pCamera->GetScreenCoordinates( labelpos, x, y );
|
||||
glColor4f( 1.0f, 1.0f, 1.0f, it->fade );
|
||||
@ -1026,13 +1028,13 @@ void CMouseoverEntities::renderOverlays()
|
||||
}
|
||||
}
|
||||
|
||||
void CMouseoverEntities::startBandbox( u16 x, u16 y )
|
||||
void CMouseoverEntities::StartBandbox( u16 x, u16 y )
|
||||
{
|
||||
m_bandbox = true;
|
||||
m_x1 = x; m_y1 = y;
|
||||
}
|
||||
|
||||
void CMouseoverEntities::stopBandbox()
|
||||
void CMouseoverEntities::StopBandbox()
|
||||
{
|
||||
m_bandbox = false;
|
||||
}
|
||||
@ -1074,7 +1076,7 @@ void MouseButtonUpHandler(const SDL_Event_* ev, int clicks)
|
||||
case SDL_BUTTON_LEFT:
|
||||
if( g_BuildingPlacer.m_active )
|
||||
{
|
||||
g_BuildingPlacer.mouseReleased();
|
||||
g_BuildingPlacer.MouseReleased();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1087,36 +1089,36 @@ void MouseButtonUpHandler(const SDL_Event_* ev, int clicks)
|
||||
if( clicks == 2 )
|
||||
{
|
||||
// Double click
|
||||
g_Mouseover.expandAcrossScreen();
|
||||
g_Mouseover.ExpandAcrossScreen();
|
||||
}
|
||||
else if( clicks == 3 )
|
||||
{
|
||||
// Triple click
|
||||
g_Mouseover.expandAcrossWorld();
|
||||
g_Mouseover.ExpandAcrossWorld();
|
||||
}
|
||||
|
||||
g_Mouseover.stopBandbox();
|
||||
g_Mouseover.StopBandbox();
|
||||
if( hotkeys[HOTKEY_SELECTION_ADD] )
|
||||
{
|
||||
g_Mouseover.addSelection();
|
||||
g_Mouseover.AddSelection();
|
||||
}
|
||||
else if( hotkeys[HOTKEY_SELECTION_REMOVE] )
|
||||
{
|
||||
g_Mouseover.removeSelection();
|
||||
g_Mouseover.RemoveSelection();
|
||||
}
|
||||
else
|
||||
g_Mouseover.setSelection();
|
||||
g_Mouseover.SetSelection();
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
if( g_BuildingPlacer.m_active )
|
||||
{
|
||||
g_BuildingPlacer.deactivate();
|
||||
g_BuildingPlacer.Deactivate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InReaction interactInputHandler( const SDL_Event_* ev )
|
||||
InReaction InteractInputHandler( const SDL_Event_* ev )
|
||||
{
|
||||
if (!g_app_has_focus || !g_Game)
|
||||
return IN_PASS;
|
||||
@ -1160,7 +1162,7 @@ InReaction interactInputHandler( const SDL_Event_* ev )
|
||||
break;
|
||||
case HOTKEY_SELECTION_SNAP:
|
||||
if( g_Selection.m_selected.size() )
|
||||
pView->SetCameraTarget( g_Selection.getSelectionPosition() );
|
||||
pView->SetCameraTarget( g_Selection.GetSelectionPosition() );
|
||||
break;
|
||||
case HOTKEY_CAMERA_UNIT_VIEW:
|
||||
{
|
||||
@ -1213,24 +1215,24 @@ InReaction interactInputHandler( const SDL_Event_* ev )
|
||||
|
||||
if( hotkeys[HOTKEY_SELECTION_GROUP_ADD] )
|
||||
{
|
||||
g_Selection.addGroup( id );
|
||||
g_Selection.AddGroup( id );
|
||||
}
|
||||
else if( hotkeys[HOTKEY_SELECTION_GROUP_SAVE] )
|
||||
{
|
||||
g_Selection.saveGroup( id );
|
||||
g_Selection.SaveGroup( id );
|
||||
}
|
||||
else if( hotkeys[HOTKEY_SELECTION_GROUP_SNAP] )
|
||||
{
|
||||
g_Selection.highlightGroup( id );
|
||||
g_Selection.HighlightGroup( id );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ( g_Selection.m_group == id ) && g_Selection.getGroupCount( id ) )
|
||||
if( ( g_Selection.m_group == id ) && g_Selection.GetGroupCount( id ) )
|
||||
{
|
||||
pView->SetCameraTarget( g_Selection.getGroupPosition( id ) );
|
||||
pView->SetCameraTarget( g_Selection.GetGroupPosition( id ) );
|
||||
}
|
||||
else
|
||||
g_Selection.loadGroup( id );
|
||||
g_Selection.LoadGroup( id );
|
||||
}
|
||||
return( IN_HANDLED );
|
||||
}
|
||||
@ -1243,7 +1245,7 @@ InReaction interactInputHandler( const SDL_Event_* ev )
|
||||
{
|
||||
case HOTKEY_SELECTION_GROUP_SNAP:
|
||||
if( g_Selection.m_group_highlight != -1 )
|
||||
g_Selection.highlightNone();
|
||||
g_Selection.HighlightNone();
|
||||
break;
|
||||
case HOTKEY_HIGHLIGHTALL:
|
||||
g_Mouseover.m_viewall = false;
|
||||
@ -1291,7 +1293,7 @@ InReaction interactInputHandler( const SDL_Event_* ev )
|
||||
button_down_time = get_time();
|
||||
if( g_BuildingPlacer.m_active )
|
||||
{
|
||||
g_BuildingPlacer.mousePressed();
|
||||
g_BuildingPlacer.MousePressed();
|
||||
}
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
@ -1299,19 +1301,19 @@ InReaction interactInputHandler( const SDL_Event_* ev )
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
if( !g_Mouseover.isBandbox() && button_down && !g_BuildingPlacer.m_active && !right_button_down )
|
||||
if( !g_Mouseover.IsBandbox() && button_down && !g_BuildingPlacer.m_active && !right_button_down )
|
||||
{
|
||||
int deltax = ev->ev.motion.x - button_down_x;
|
||||
int deltay = ev->ev.motion.y - button_down_y;
|
||||
if( abs( deltax ) > 2 || abs( deltay ) > 2 )
|
||||
g_Mouseover.startBandbox( button_down_x, button_down_y );
|
||||
g_Mouseover.StartBandbox( button_down_x, button_down_y );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return( IN_PASS );
|
||||
}
|
||||
|
||||
bool isOnScreen( CEntity* e, void* UNUSED(userdata) )
|
||||
bool IsOnScreen( CEntity* e, void* UNUSED(userdata) )
|
||||
{
|
||||
CCamera *pCamera=g_Game->GetView()->GetCamera();
|
||||
|
||||
@ -1324,7 +1326,7 @@ bool isOnScreen( CEntity* e, void* UNUSED(userdata) )
|
||||
return( frustum.IsBoxVisible( e->m_graphics_position, CBound() ) );
|
||||
}
|
||||
|
||||
bool isMouseoverType( CEntity* e, void* UNUSED(userdata) )
|
||||
bool IsMouseoverType( CEntity* e, void* UNUSED(userdata) )
|
||||
{
|
||||
std::vector<SMouseoverFader>::iterator it;
|
||||
for( it = g_Mouseover.m_mouseover.begin(); it < g_Mouseover.m_mouseover.end(); it++ )
|
||||
@ -1347,7 +1349,7 @@ void ResetInteraction()
|
||||
}
|
||||
|
||||
|
||||
bool CBuildingPlacer::activate(CStrW& templateName)
|
||||
bool CBuildingPlacer::Activate(CStrW& templateName)
|
||||
{
|
||||
if(m_active)
|
||||
{
|
||||
@ -1363,11 +1365,11 @@ bool CBuildingPlacer::activate(CStrW& templateName)
|
||||
m_totalTime = 0;
|
||||
m_valid = false;
|
||||
|
||||
m_template = g_EntityTemplateCollection.getTemplate( m_templateName );
|
||||
m_template = g_EntityTemplateCollection.GetTemplate( m_templateName );
|
||||
|
||||
if( !m_template )
|
||||
{
|
||||
deactivate();
|
||||
Deactivate();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1391,7 +1393,7 @@ bool CBuildingPlacer::activate(CStrW& templateName)
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBuildingPlacer::mousePressed()
|
||||
void CBuildingPlacer::MousePressed()
|
||||
{
|
||||
CCamera &camera=*g_Game->GetView()->GetCamera();
|
||||
if( m_template->m_socket == L"" )
|
||||
@ -1399,9 +1401,9 @@ void CBuildingPlacer::mousePressed()
|
||||
m_clicked = true;
|
||||
}
|
||||
|
||||
void CBuildingPlacer::mouseReleased()
|
||||
void CBuildingPlacer::MouseReleased()
|
||||
{
|
||||
deactivate(); // do it first in case we fail for any reason
|
||||
Deactivate(); // do it first in case we fail for any reason
|
||||
|
||||
if( m_valid )
|
||||
{
|
||||
@ -1419,11 +1421,11 @@ void CBuildingPlacer::mouseReleased()
|
||||
|
||||
if( hotkeys[HOTKEY_ORDER_QUEUE] )
|
||||
{
|
||||
activate( m_templateName ); // reactivate so we can place more buildings of the same type
|
||||
Activate( m_templateName ); // reactivate so we can place more buildings of the same type
|
||||
}
|
||||
}
|
||||
|
||||
void CBuildingPlacer::deactivate()
|
||||
void CBuildingPlacer::Deactivate()
|
||||
{
|
||||
m_active = false;
|
||||
g_Game->GetWorld()->GetUnitManager().RemoveUnit( m_actor );
|
||||
@ -1433,7 +1435,7 @@ void CBuildingPlacer::deactivate()
|
||||
m_bounds = 0;
|
||||
}
|
||||
|
||||
void CBuildingPlacer::update( float timeStep )
|
||||
void CBuildingPlacer::Update( float timeStep )
|
||||
{
|
||||
if(!m_active)
|
||||
return;
|
||||
@ -1476,8 +1478,8 @@ void CBuildingPlacer::update( float timeStep )
|
||||
if( m_template->m_socket != L"" )
|
||||
{
|
||||
// If we're on a socket of our type, remember that and snap ourselves to it
|
||||
m_bounds->setPosition(pos.X, pos.Z); // first, move bounds to mouse pos
|
||||
CEntity* ent = getCollisionEntity( m_bounds, 0 ); // now, check what we intersect
|
||||
m_bounds->SetPosition(pos.X, pos.Z); // first, move bounds to mouse pos
|
||||
CEntity* ent = GetCollisionEntity( m_bounds, 0 ); // now, check what we intersect
|
||||
if( ent && ent->m_classes.IsMember( m_template->m_socket ) ) // if it's a socket, snap to it
|
||||
{
|
||||
onSocket = true;
|
||||
@ -1494,19 +1496,19 @@ void CBuildingPlacer::update( float timeStep )
|
||||
m.Translate(pos);
|
||||
m_actor->GetModel()->SetTransform( m );
|
||||
|
||||
m_bounds->setPosition(pos.X, pos.Z);
|
||||
m_bounds->SetPosition(pos.X, pos.Z);
|
||||
|
||||
if( m_bounds->m_type == CBoundingObject::BOUND_OABB )
|
||||
{
|
||||
CBoundingBox* box = (CBoundingBox*) m_bounds;
|
||||
box->setOrientation( m_angle );
|
||||
box->SetOrientation( m_angle );
|
||||
}
|
||||
|
||||
// Check whether the placement location is valid (look at whether we're
|
||||
// on the map, who owns the territory, whether we are on a socket, and
|
||||
// whether we are colliding with anything).
|
||||
CTerrain *pTerrain=g_Game->GetWorld()->GetTerrain();
|
||||
if( pTerrain->isOnMap( pos.X, pos.Z ) )
|
||||
if( pTerrain->IsOnMap( pos.X, pos.Z ) )
|
||||
{
|
||||
// Check that we are being placed in a valid territory; currently, m_territoryRestriction
|
||||
// can be either "Allied" for placing in allied territories, or nothing.
|
||||
@ -1522,10 +1524,10 @@ void CBuildingPlacer::update( float timeStep )
|
||||
{
|
||||
// It's valid to place the object here if the position is unobstructed by
|
||||
// anything except possibly our socket (which we find out by passing an
|
||||
// ignoreClass to getCollisionObject); also, if we are a socketed object,
|
||||
// ignoreClass to GetCollisionObject); also, if we are a socketed object,
|
||||
// we check that we are actually on a socket, using onSocket (set above).
|
||||
m_valid = ( m_template->m_socket == L"" || onSocket )
|
||||
&& ( getCollisionObject( m_bounds, 0, &m_template->m_socket ) == 0 );
|
||||
&& ( GetCollisionObject( m_bounds, 0, &m_template->m_socket ) == 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -31,7 +31,7 @@ struct CSelectedEntities : public Singleton<CSelectedEntities>
|
||||
{
|
||||
CSelectedEntities()
|
||||
{
|
||||
clearSelection();
|
||||
ClearSelection();
|
||||
m_group = -1;
|
||||
m_group_highlight = -1;
|
||||
m_defaultCommand = -1;
|
||||
@ -41,11 +41,11 @@ struct CSelectedEntities : public Singleton<CSelectedEntities>
|
||||
m_selectionChanged = true;
|
||||
m_mouseOverMM = false;
|
||||
|
||||
loadUnitUITextures();
|
||||
LoadUnitUiTextures();
|
||||
}
|
||||
~CSelectedEntities()
|
||||
{
|
||||
destroyUnitUITextures();
|
||||
DestroyUnitUiTextures();
|
||||
}
|
||||
std::vector<HEntity> m_selected;
|
||||
std::vector<HEntity> m_groups[MAX_GROUPS];
|
||||
@ -57,38 +57,38 @@ struct CSelectedEntities : public Singleton<CSelectedEntities>
|
||||
int m_secondaryCommand;
|
||||
int m_secondaryAction;
|
||||
|
||||
void addSelection( HEntity entity );
|
||||
void removeSelection( HEntity entity );
|
||||
void setSelection( HEntity entity );
|
||||
void clearSelection();
|
||||
void removeAll( HEntity entity );
|
||||
bool isSelected( HEntity entity );
|
||||
CVector3D getSelectionPosition();
|
||||
void AddSelection( HEntity entity );
|
||||
void RemoveSelection( HEntity entity );
|
||||
void SetSelection( HEntity entity );
|
||||
void ClearSelection();
|
||||
void RemoveAll( HEntity entity );
|
||||
bool IsSelected( HEntity entity );
|
||||
CVector3D GetSelectionPosition();
|
||||
|
||||
void addToGroup( i8 groupid, HEntity entity );
|
||||
void saveGroup( i8 groupid );
|
||||
void loadGroup( i8 groupid );
|
||||
void addGroup( i8 groupid );
|
||||
void changeGroup( HEntity entity, i8 groupid );
|
||||
void highlightGroup( i8 groupid );
|
||||
void highlightNone();
|
||||
int getGroupCount( i8 groupid );
|
||||
CVector3D getGroupPosition( i8 groupid );
|
||||
void AddToGroup( i8 groupid, HEntity entity );
|
||||
void SaveGroup( i8 groupid );
|
||||
void LoadGroup( i8 groupid );
|
||||
void AddGroup( i8 groupid );
|
||||
void ChangeGroup( HEntity entity, i8 groupid );
|
||||
void HighlightGroup( i8 groupid );
|
||||
void HighlightNone();
|
||||
int GetGroupCount( i8 groupid );
|
||||
CVector3D GetGroupPosition( i8 groupid );
|
||||
|
||||
void update();
|
||||
void Update();
|
||||
|
||||
void renderSelectionOutlines();
|
||||
void renderOverlays();
|
||||
void renderAuras();
|
||||
void renderRallyPoints();
|
||||
void renderBars();
|
||||
void renderHealthBars();
|
||||
void renderStaminaBars();
|
||||
void renderRanks();
|
||||
void renderBarBorders();
|
||||
void RenderSelectionOutlines();
|
||||
void RenderOverlays();
|
||||
void RenderAuras();
|
||||
void RenderRallyPoints();
|
||||
void RenderBars();
|
||||
void RenderHealthBars();
|
||||
void RenderStaminaBars();
|
||||
void RenderRanks();
|
||||
void RenderBarBorders();
|
||||
|
||||
void destroyUnitUITextures();
|
||||
int loadUnitUITextures();
|
||||
void DestroyUnitUiTextures();
|
||||
int LoadUnitUiTextures();
|
||||
std::map<CStr, Handle> m_unitUITextures;
|
||||
};
|
||||
|
||||
@ -127,30 +127,30 @@ struct CMouseoverEntities : public Singleton<CMouseoverEntities>
|
||||
m_targetChanged = true;
|
||||
}
|
||||
std::vector<SMouseoverFader> m_mouseover;
|
||||
void update( float timestep );
|
||||
void Update( float timestep );
|
||||
|
||||
void addSelection();
|
||||
void removeSelection();
|
||||
void setSelection();
|
||||
void AddSelection();
|
||||
void RemoveSelection();
|
||||
void SetSelection();
|
||||
|
||||
void expandAcrossScreen();
|
||||
void expandAcrossWorld();
|
||||
void ExpandAcrossScreen();
|
||||
void ExpandAcrossWorld();
|
||||
|
||||
void renderSelectionOutlines();
|
||||
void renderOverlays();
|
||||
void renderRallyPoints();
|
||||
void renderAuras();
|
||||
void renderBars();
|
||||
void renderHealthBars();
|
||||
void renderStaminaBars();
|
||||
void renderRanks();
|
||||
void renderBarBorders();
|
||||
void RenderSelectionOutlines();
|
||||
void RenderOverlays();
|
||||
void RenderRallyPoints();
|
||||
void RenderAuras();
|
||||
void RenderBars();
|
||||
void RenderHealthBars();
|
||||
void RenderStaminaBars();
|
||||
void RenderRanks();
|
||||
void RenderBarBorders();
|
||||
|
||||
bool isBandbox() { return( m_bandbox ); }
|
||||
void startBandbox( u16 x, u16 y );
|
||||
void stopBandbox();
|
||||
bool IsBandbox() { return( m_bandbox ); }
|
||||
void StartBandbox( u16 x, u16 y );
|
||||
void StopBandbox();
|
||||
|
||||
void clear() { m_mouseover.clear(); }
|
||||
void Clear() { m_mouseover.clear(); }
|
||||
};
|
||||
|
||||
struct CBuildingPlacer : public Singleton<CBuildingPlacer>
|
||||
@ -175,20 +175,20 @@ struct CBuildingPlacer : public Singleton<CBuildingPlacer>
|
||||
CUnit* m_actor;
|
||||
CBoundingObject* m_bounds;
|
||||
|
||||
bool activate( CStrW& templateName );
|
||||
void deactivate();
|
||||
void mousePressed();
|
||||
void mouseReleased();
|
||||
void update( float timeStep );
|
||||
bool Activate( CStrW& templateName );
|
||||
void Deactivate();
|
||||
void MousePressed();
|
||||
void MouseReleased();
|
||||
void Update( float timeStep );
|
||||
};
|
||||
|
||||
bool isMouseoverType( CEntity* ev, void* userdata );
|
||||
bool isOnScreen( CEntity* ev, void* userdata );
|
||||
bool IsMouseoverType( CEntity* ev, void* userdata );
|
||||
bool IsOnScreen( CEntity* ev, void* userdata );
|
||||
|
||||
void StartCustomSelection();
|
||||
void ResetInteraction();
|
||||
|
||||
InReaction interactInputHandler( const SDL_Event_* ev );
|
||||
InReaction InteractInputHandler( const SDL_Event_* ev );
|
||||
|
||||
#define g_Selection CSelectedEntities::GetSingleton()
|
||||
#define g_Mouseover CMouseoverEntities::GetSingleton()
|
||||
|
@ -283,7 +283,7 @@ static SKeycodeMapping keycodeMapping[] =
|
||||
{ 0, 0, 0 },
|
||||
};
|
||||
|
||||
void initKeyNameMap()
|
||||
void InitKeyNameMap()
|
||||
{
|
||||
SKeycodeMapping* it = keycodeMapping;
|
||||
while( it->keycode != 0 )
|
||||
@ -295,7 +295,7 @@ void initKeyNameMap()
|
||||
};
|
||||
}
|
||||
|
||||
int getKeyCode( const CStr& keyname )
|
||||
int FindKeyCode( const CStr& keyname )
|
||||
{
|
||||
std::map<CStr,int>::iterator it;
|
||||
it = keymap.find( keyname.LowerCase() );
|
||||
@ -304,7 +304,7 @@ int getKeyCode( const CStr& keyname )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
CStr getKeyName( int keycode )
|
||||
CStr FindKeyName( int keycode )
|
||||
{
|
||||
SKeycodeMapping* it = keycodeMapping;
|
||||
while( it->keycode != 0 )
|
||||
|
8
source/ps/KeyName.h
Normal file
8
source/ps/KeyName.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef INCLUDED_KEYNAME
|
||||
#define INCLUDED_KEYNAME
|
||||
|
||||
extern void InitKeyNameMap();
|
||||
extern CStr FindKeyName( int keycode );
|
||||
extern int FindKeyCode( const CStr& keyname );
|
||||
|
||||
#endif // #ifndef INCLUDED_KEYNAME
|
@ -107,9 +107,9 @@ static bool ControllerPredicate( CEntity* entity, void* userdata )
|
||||
return( entity->GetPlayer() == userdata );
|
||||
}
|
||||
|
||||
std::vector<HEntity>* CPlayer::GetControlledEntities()
|
||||
void CPlayer::GetControlledEntities(std::vector<HEntity>& controlled_entities)
|
||||
{
|
||||
return( g_EntityManager.matches( ControllerPredicate, this ) );
|
||||
g_EntityManager.GetMatchingAsHandles( controlled_entities, ControllerPredicate, this );
|
||||
}
|
||||
|
||||
jsval CPlayer::JSI_ToString( JSContext* cx, uintN UNUSED(argc), jsval* UNUSED(argv) )
|
||||
@ -123,9 +123,9 @@ jsval CPlayer::JSI_ToString( JSContext* cx, uintN UNUSED(argc), jsval* UNUSED(ar
|
||||
|
||||
jsval CPlayer::JSI_GetControlledEntities(JSContext* UNUSED(cx))
|
||||
{
|
||||
std::vector<HEntity>* controlledSet = GetControlledEntities();
|
||||
jsval vp = OBJECT_TO_JSVAL( EntityCollection::Create( *controlledSet ) );
|
||||
delete( controlledSet );
|
||||
std::vector<HEntity> controlledSet;
|
||||
GetControlledEntities(controlledSet);
|
||||
jsval vp = OBJECT_TO_JSVAL( EntityCollection::Create( controlledSet ) );
|
||||
return( vp );
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,7 @@ public:
|
||||
return m_ActiveTechs;
|
||||
}
|
||||
|
||||
// Caller frees...
|
||||
std::vector<HEntity>* GetControlledEntities();
|
||||
void GetControlledEntities(std::vector<HEntity>& controlled_entities);
|
||||
|
||||
// JS Interface Functions
|
||||
jsval JSI_ToString( JSContext* context, uintN argc, jsval* argv );
|
||||
|
@ -62,8 +62,8 @@ void WriteSystemInfo()
|
||||
fprintf(f, "OS : %s %s (%s)\n", un.sysname, un.release, un.version);
|
||||
|
||||
// .. CPU
|
||||
fprintf(f, "CPU : %s, %s (%dx%dx%d)", un.machine, cpu_identifierString(), cpu_numPackages(), cpu_coresPerPackage(), cpu_logicalPerCore());
|
||||
const double cpu_freq = cpu_clockFrequency();
|
||||
fprintf(f, "CPU : %s, %s (%dx%dx%d)", un.machine, cpu_IdentifierString(), cpu_NumPackages(), cpu_CoresPerPackage(), cpu_LogicalPerCore());
|
||||
const double cpu_freq = cpu_ClockFrequency();
|
||||
if(cpu_freq != 0.0f)
|
||||
{
|
||||
if(cpu_freq < 1e9)
|
||||
@ -75,7 +75,7 @@ void WriteSystemInfo()
|
||||
fprintf(f, "\n");
|
||||
|
||||
// .. memory
|
||||
fprintf(f, "Memory : %lu MiB; %lu MiB free\n", cpu_memoryTotalMiB(), cpu_memorySize(CPU_MEM_AVAILABLE)/MiB);
|
||||
fprintf(f, "Memory : %lu MiB; %lu MiB free\n", cpu_MemoryTotalMiB(), cpu_MemorySize(CPU_MEM_AVAILABLE)/MiB);
|
||||
|
||||
// .. graphics
|
||||
fprintf(f, "Graphics Card : %s\n", gfx_card);
|
||||
@ -124,7 +124,7 @@ no_ip:
|
||||
|
||||
|
||||
// .. OpenGL extensions (write them last, since it's a lot of text)
|
||||
const char* exts = oglExtList();
|
||||
const char* exts = ogl_ExtensionString();
|
||||
if (!exts) exts = "{unknown}";
|
||||
fprintf(f, "\nOpenGL Extensions: \n%s\n", SplitExts(exts).c_str());
|
||||
|
||||
@ -240,7 +240,7 @@ void WriteBigScreenshot(const char* extension, int tiles)
|
||||
if(tex_wrap(img_w, img_h, bpp, flags, img, &t) < 0)
|
||||
return;
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
// Resize various things so that the sizes and aspect ratios are correct
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
{
|
||||
return( x == rhs.x && y == rhs.y );
|
||||
}
|
||||
static inline float dot( const CVector2D& u, const CVector2D& v )
|
||||
static inline float Dot( const CVector2D& u, const CVector2D& v )
|
||||
{
|
||||
return( u.x * v.x + u.y * v.y );
|
||||
}
|
||||
@ -48,9 +48,9 @@ public:
|
||||
{
|
||||
return( CVector2D( y, -x ) );
|
||||
}
|
||||
inline float dot( const CVector2D& u ) const
|
||||
inline float Dot( const CVector2D& u ) const
|
||||
{
|
||||
return( dot( *this, u ) );
|
||||
return( Dot( *this, u ) );
|
||||
}
|
||||
inline float betadot( const CVector2D& u ) const
|
||||
{
|
||||
@ -92,7 +92,7 @@ public:
|
||||
x /= scale; y /= scale;
|
||||
return( *this );
|
||||
}
|
||||
inline float length() const
|
||||
inline float Length() const
|
||||
{
|
||||
return( sqrt( x * x + y * y ) );
|
||||
}
|
||||
@ -100,9 +100,9 @@ public:
|
||||
{
|
||||
return( x * x + y * y );
|
||||
}
|
||||
CVector2D normalize() const
|
||||
CVector2D Normalize() const
|
||||
{
|
||||
float l = length();
|
||||
float l = Length();
|
||||
if( l < 0.00001 ) return( CVector2D( 1.0f, 0.0f ) );
|
||||
l = 1 / l;
|
||||
return( CVector2D( x * l, y * l ) );
|
||||
|
@ -64,7 +64,7 @@ CWorld::CWorld(CGame *pGame):
|
||||
void CWorld::Initialize(CGameAttributes *pAttribs)
|
||||
{
|
||||
// TODO: Find a better way of handling these global things
|
||||
ONCE(RegMemFun(CEntityTemplateCollection::GetSingletonPtr(), &CEntityTemplateCollection::loadTemplates, L"loadTemplates", 15));
|
||||
ONCE(RegMemFun(CEntityTemplateCollection::GetSingletonPtr(), &CEntityTemplateCollection::LoadTemplates, L"LoadTemplates", 15));
|
||||
|
||||
// Load the map, if one was specified
|
||||
if (pAttribs->m_MapFile.length())
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
/**
|
||||
* @return true if Errors Occured
|
||||
*/
|
||||
bool getSawErrors() const { return fSawErrors; }
|
||||
bool GetSawErrors() const { return fSawErrors; }
|
||||
|
||||
//@}
|
||||
private:
|
||||
|
@ -58,7 +58,7 @@ std::string XMBFile::ReadZStrA()
|
||||
return String;
|
||||
}
|
||||
|
||||
XMBElement XMBFile::getRoot() const
|
||||
XMBElement XMBFile::GetRoot() const
|
||||
{
|
||||
return XMBElement(m_Pointer);
|
||||
}
|
||||
@ -66,19 +66,19 @@ XMBElement XMBFile::getRoot() const
|
||||
|
||||
#ifdef XERO_USEMAP
|
||||
|
||||
int XMBFile::getElementID(const char* Name) const
|
||||
int XMBFile::GetElementID(const char* Name) const
|
||||
{
|
||||
return m_ElementNames[Name];
|
||||
}
|
||||
|
||||
int XMBFile::getAttributeID(const char* Name) const
|
||||
int XMBFile::GetAttributeID(const char* Name) const
|
||||
{
|
||||
return m_AttributeNames[Name];
|
||||
}
|
||||
|
||||
#else // #ifdef XERO_USEMAP
|
||||
|
||||
int XMBFile::getElementID(const char* Name) const
|
||||
int XMBFile::GetElementID(const char* Name) const
|
||||
{
|
||||
const char* Pos = m_ElementPointer;
|
||||
|
||||
@ -98,7 +98,7 @@ int XMBFile::getElementID(const char* Name) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
int XMBFile::getAttributeID(const char* Name) const
|
||||
int XMBFile::GetAttributeID(const char* Name) const
|
||||
{
|
||||
const char* Pos = m_AttributePointer;
|
||||
|
||||
@ -122,7 +122,7 @@ int XMBFile::getAttributeID(const char* Name) const
|
||||
|
||||
// Relatively inefficient, so only use when
|
||||
// laziness overcomes the need for speed
|
||||
std::string XMBFile::getElementString(const int ID) const
|
||||
std::string XMBFile::GetElementString(const int ID) const
|
||||
{
|
||||
const char* Pos = m_ElementPointer;
|
||||
for (int i = 0; i < ID; ++i)
|
||||
@ -130,7 +130,7 @@ std::string XMBFile::getElementString(const int ID) const
|
||||
return std::string(Pos+4);
|
||||
}
|
||||
|
||||
std::string XMBFile::getAttributeString(const int ID) const
|
||||
std::string XMBFile::GetAttributeString(const int ID) const
|
||||
{
|
||||
const char* Pos = m_AttributePointer;
|
||||
for (int i = 0; i < ID; ++i)
|
||||
@ -140,12 +140,12 @@ std::string XMBFile::getAttributeString(const int ID) const
|
||||
|
||||
|
||||
|
||||
int XMBElement::getNodeName() const
|
||||
int XMBElement::GetNodeName() const
|
||||
{
|
||||
return *(int*)(m_Pointer + 4); // == ElementName
|
||||
}
|
||||
|
||||
XMBElementList XMBElement::getChildNodes() const
|
||||
XMBElementList XMBElement::GetChildNodes() const
|
||||
{
|
||||
return XMBElementList(
|
||||
m_Pointer + 20 + *(int*)(m_Pointer + 16), // == Children[]
|
||||
@ -153,7 +153,7 @@ XMBElementList XMBElement::getChildNodes() const
|
||||
);
|
||||
}
|
||||
|
||||
XMBAttributeList XMBElement::getAttributes() const
|
||||
XMBAttributeList XMBElement::GetAttributes() const
|
||||
{
|
||||
return XMBAttributeList(
|
||||
m_Pointer + 24 + *(int*)(m_Pointer + 20), // == Attributes[]
|
||||
@ -161,7 +161,7 @@ XMBAttributeList XMBElement::getAttributes() const
|
||||
);
|
||||
}
|
||||
|
||||
utf16string XMBElement::getText() const
|
||||
utf16string XMBElement::GetText() const
|
||||
{
|
||||
// Return empty string if there's no text
|
||||
if (*(int*)(m_Pointer + 20) == 0)
|
||||
@ -170,7 +170,7 @@ utf16string XMBElement::getText() const
|
||||
return utf16string((utf16_t*)(m_Pointer + 28));
|
||||
}
|
||||
|
||||
int XMBElement::getLineNumber() const
|
||||
int XMBElement::GetLineNumber() const
|
||||
{
|
||||
// Make sure there actually was some text to record the line of
|
||||
if (*(int*)(m_Pointer + 20) == 0)
|
||||
@ -179,7 +179,7 @@ int XMBElement::getLineNumber() const
|
||||
return *(int*)(m_Pointer + 24);
|
||||
}
|
||||
|
||||
XMBElement XMBElementList::item(const int id)
|
||||
XMBElement XMBElementList::Item(const int id)
|
||||
{
|
||||
debug_assert(id >= 0 && id < Count && "Element ID out of range");
|
||||
const char* Pos;
|
||||
@ -205,7 +205,7 @@ XMBElement XMBElementList::item(const int id)
|
||||
return XMBElement(Pos);
|
||||
}
|
||||
|
||||
utf16string XMBAttributeList::getNamedItem(const int AttributeName) const
|
||||
utf16string XMBAttributeList::GetNamedItem(const int AttributeName) const
|
||||
{
|
||||
const char* Pos = m_Pointer;
|
||||
|
||||
@ -222,7 +222,7 @@ utf16string XMBAttributeList::getNamedItem(const int AttributeName) const
|
||||
return utf16string();
|
||||
}
|
||||
|
||||
XMBAttribute XMBAttributeList::item(const int id)
|
||||
XMBAttribute XMBAttributeList::Item(const int id)
|
||||
{
|
||||
debug_assert(id >= 0 && id < Count && "Attribute ID out of range");
|
||||
const char* Pos;
|
||||
|
@ -116,18 +116,18 @@ public:
|
||||
void Initialise(const char* FileData);
|
||||
|
||||
// Returns the root element
|
||||
XMBElement getRoot() const;
|
||||
XMBElement GetRoot() const;
|
||||
|
||||
|
||||
// Returns internal ID for a given ASCII element/attribute string.
|
||||
int getElementID(const char* Name) const;
|
||||
int getAttributeID(const char* Name) const;
|
||||
int GetElementID(const char* Name) const;
|
||||
int GetAttributeID(const char* Name) const;
|
||||
|
||||
// For lazy people (e.g. me) when speed isn't vital:
|
||||
|
||||
// Returns element/attribute string for a given internal ID
|
||||
std::string getElementString(const int ID) const;
|
||||
std::string getAttributeString(const int ID) const;
|
||||
std::string GetElementString(const int ID) const;
|
||||
std::string GetAttributeString(const int ID) const;
|
||||
|
||||
private:
|
||||
const char* m_Pointer;
|
||||
@ -155,11 +155,11 @@ public:
|
||||
XMBElement(const char* offset)
|
||||
: m_Pointer(offset) {}
|
||||
|
||||
int getNodeName() const;
|
||||
XMBElementList getChildNodes() const;
|
||||
XMBAttributeList getAttributes() const;
|
||||
utf16string getText() const;
|
||||
int getLineNumber() const;
|
||||
int GetNodeName() const;
|
||||
XMBElementList GetChildNodes() const;
|
||||
XMBAttributeList GetAttributes() const;
|
||||
utf16string GetText() const;
|
||||
int GetLineNumber() const;
|
||||
|
||||
private:
|
||||
// Pointer to the start of the node
|
||||
@ -178,7 +178,7 @@ public:
|
||||
m_Pointer(offset),
|
||||
m_LastItemID(-2) {} // use -2 because it isn't x-1 where x is a non-negative integer
|
||||
|
||||
XMBElement item(const int id); // returns Children[id]
|
||||
XMBElement Item(const int id); // returns Children[id]
|
||||
|
||||
int Count;
|
||||
|
||||
@ -208,10 +208,10 @@ public:
|
||||
: Count(count), m_Pointer(offset), m_LastItemID(-2) {};
|
||||
|
||||
// Get the attribute value directly (unlike Xerces)
|
||||
utf16string getNamedItem(const int AttributeName) const;
|
||||
utf16string GetNamedItem(const int AttributeName) const;
|
||||
|
||||
// Returns an attribute by position in the list
|
||||
XMBAttribute item(const int id);
|
||||
XMBAttribute Item(const int id);
|
||||
|
||||
int Count;
|
||||
|
||||
|
@ -316,7 +316,7 @@ PSRETURN CXeromyces::Load(const char* filename)
|
||||
|
||||
delete Parser;
|
||||
|
||||
if (errorHandler.getSawErrors())
|
||||
if (errorHandler.GetSawErrors())
|
||||
{
|
||||
LOG(ERROR, LOG_CATEGORY, "CXeromyces: Errors in XML file '%s'", filename);
|
||||
return PSRETURN_Xeromyces_XMLParseError;
|
||||
|
@ -53,19 +53,19 @@ private:
|
||||
#define _XERO_I _XERO_MAKE_UID1__(_i_, __LINE__)
|
||||
|
||||
#define XERO_ITER_EL(parent_element, child_element) \
|
||||
XMBElementList _XERO_CHILDREN = parent_element.getChildNodes(); \
|
||||
XMBElementList _XERO_CHILDREN = parent_element.GetChildNodes(); \
|
||||
XMBElement child_element (0); \
|
||||
for (int _XERO_I = 0; \
|
||||
_XERO_I < _XERO_CHILDREN.Count \
|
||||
&& (child_element = _XERO_CHILDREN.item(_XERO_I), 1); \
|
||||
&& (child_element = _XERO_CHILDREN.Item(_XERO_I), 1); \
|
||||
++_XERO_I)
|
||||
|
||||
#define XERO_ITER_ATTR(parent_element, attribute) \
|
||||
XMBAttributeList _XERO_CHILDREN = parent_element.getAttributes(); \
|
||||
XMBAttributeList _XERO_CHILDREN = parent_element.GetAttributes(); \
|
||||
XMBAttribute attribute; \
|
||||
for (int _XERO_I = 0; \
|
||||
_XERO_I < _XERO_CHILDREN.Count \
|
||||
&& (attribute = _XERO_CHILDREN.item(_XERO_I), 1); \
|
||||
&& (attribute = _XERO_CHILDREN.Item(_XERO_I), 1); \
|
||||
++_XERO_I)
|
||||
|
||||
#endif // _XEROMYCES_H_
|
||||
|
@ -16,7 +16,7 @@ JSBool JSI_Selection::getSelection( JSContext* UNUSED(cx), JSObject* UNUSED(obj)
|
||||
return( JS_TRUE );
|
||||
}
|
||||
|
||||
JSBool JSI_Selection::setSelection( JSContext* cx, JSObject* UNUSED(obj),
|
||||
JSBool JSI_Selection::SetSelection( JSContext* cx, JSObject* UNUSED(obj),
|
||||
jsval UNUSED(id), jsval* vp )
|
||||
{
|
||||
if( !JSVAL_IS_OBJECT( *vp ) )
|
||||
@ -36,11 +36,11 @@ JSBool JSI_Selection::setSelection( JSContext* cx, JSObject* UNUSED(obj),
|
||||
return( JS_TRUE );
|
||||
}
|
||||
|
||||
g_Selection.clearSelection();
|
||||
g_Selection.ClearSelection();
|
||||
std::vector<HEntity>::iterator it;
|
||||
|
||||
for( it = Info->m_Data->begin(); it < Info->m_Data->end(); it++ )
|
||||
g_Selection.addSelection( *it );
|
||||
g_Selection.AddSelection( *it );
|
||||
|
||||
return( JS_TRUE );
|
||||
}
|
||||
@ -88,7 +88,7 @@ JSBool JSI_Selection::setGroups( JSContext* cx, JSObject* UNUSED(obj),
|
||||
std::vector<HEntity>::iterator it;
|
||||
|
||||
for( it = Info->m_Data->begin(); it < Info->m_Data->end(); it++ )
|
||||
g_Selection.addToGroup( groupId, *it );
|
||||
g_Selection.AddToGroup( groupId, *it );
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,11 @@ namespace JSI_Selection
|
||||
void finalize( JSContext* cx, JSObject* obj );
|
||||
|
||||
JSBool getSelection( JSContext* context, JSObject* obj, jsval id, jsval* vp );
|
||||
JSBool setSelection( JSContext* context, JSObject* obj, jsval id, jsval* vp );
|
||||
JSBool SetSelection( JSContext* context, JSObject* obj, jsval id, jsval* vp );
|
||||
JSBool getGroups( JSContext* context, JSObject* obj, jsval id, jsval* vp );
|
||||
JSBool setGroups( JSContext* context, JSObject* obj, jsval id, jsval* vp );
|
||||
|
||||
JSBool isValidContextOrder( JSContext* context, JSObject* obj, uint argc, jsval* argv, jsval* rval );
|
||||
JSBool IsValidContextOrder( JSContext* context, JSObject* obj, uint argc, jsval* argv, jsval* rval );
|
||||
JSBool getContextOrder( JSContext* context, JSObject* obj, jsval id, jsval* vp );
|
||||
JSBool setContextOrder( JSContext* context, JSObject* obj, jsval id, jsval* vp );
|
||||
|
||||
|
@ -288,7 +288,7 @@ void BatchModelRenderer::Submit(CModel* model)
|
||||
{
|
||||
debug_assert(m->phase == BMRSubmit);
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
CModelDefPtr mdef = model->GetModelDef();
|
||||
BMRModelDefTracker* mdeftracker = (BMRModelDefTracker*)mdef->GetRenderData(m);
|
||||
@ -349,7 +349,7 @@ void BatchModelRenderer::Submit(CModel* model)
|
||||
bmrdata->m_Next = mdeftracker->m_ModelSlots[idx];
|
||||
mdeftracker->m_ModelSlots[idx] = bmrdata;
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
}
|
||||
|
||||
|
||||
|
@ -407,7 +407,7 @@ CRenderer::~CRenderer()
|
||||
delete m_VertexShader;
|
||||
m_VertexShader = 0;
|
||||
|
||||
CParticleEngine::GetInstance()->cleanup();
|
||||
CParticleEngine::GetInstance()->Cleanup();
|
||||
|
||||
// we no longer UnloadAlphaMaps / UnloadWaterTextures here -
|
||||
// that is the responsibility of the module that asked for
|
||||
@ -430,23 +430,23 @@ void CRenderer::EnumCaps()
|
||||
|
||||
// now start querying extensions
|
||||
if (!m_Options.m_NoVBO) {
|
||||
if (oglHaveExtension("GL_ARB_vertex_buffer_object")) {
|
||||
if (ogl_HaveExtension("GL_ARB_vertex_buffer_object")) {
|
||||
m_Caps.m_VBO=true;
|
||||
}
|
||||
}
|
||||
if (oglHaveExtension("GL_ARB_texture_border_clamp")) {
|
||||
if (ogl_HaveExtension("GL_ARB_texture_border_clamp")) {
|
||||
m_Caps.m_TextureBorderClamp=true;
|
||||
}
|
||||
if (oglHaveExtension("GL_SGIS_generate_mipmap")) {
|
||||
if (ogl_HaveExtension("GL_SGIS_generate_mipmap")) {
|
||||
m_Caps.m_GenerateMipmaps=true;
|
||||
}
|
||||
if (0 == oglHaveExtensions(0, "GL_ARB_shader_objects", "GL_ARB_shading_language_100", 0))
|
||||
if (0 == ogl_HaveExtensions(0, "GL_ARB_shader_objects", "GL_ARB_shading_language_100", 0))
|
||||
{
|
||||
if (oglHaveExtension("GL_ARB_vertex_shader"))
|
||||
if (ogl_HaveExtension("GL_ARB_vertex_shader"))
|
||||
m_Caps.m_VertexShader=true;
|
||||
}
|
||||
|
||||
if (0 == oglHaveExtensions(0, "GL_ARB_shadow", "GL_ARB_depth_texture", 0)) {
|
||||
if (0 == ogl_HaveExtensions(0, "GL_ARB_shadow", "GL_ARB_depth_texture", 0)) {
|
||||
// According to Delphi3d.net, all relevant graphics chips that support depth textures
|
||||
// (i.e. Geforce3+, Radeon9500+, even i915) also have >= 4 TMUs, so this restriction
|
||||
// isn't actually a restriction, and it helps with integrating depth texture
|
||||
@ -456,7 +456,7 @@ void CRenderer::EnumCaps()
|
||||
}
|
||||
if (!m_Options.m_NoFramebufferObject)
|
||||
{
|
||||
if (oglHaveExtension("GL_EXT_framebuffer_object"))
|
||||
if (ogl_HaveExtension("GL_EXT_framebuffer_object"))
|
||||
m_Caps.m_FramebufferObject = true;
|
||||
}
|
||||
}
|
||||
@ -525,9 +525,9 @@ bool CRenderer::Open(int width, int height, int depth)
|
||||
m->Model.ModTransparentDepthShadow = RenderModifierPtr(new TransparentDepthShadowModifier);
|
||||
|
||||
// Particle engine
|
||||
CParticleEngine::GetInstance()->initParticleSystem();
|
||||
CParticleEngine::GetInstance()->InitParticleSystem();
|
||||
// CEmitter *pEmitter = new CDefaultEmitter(1000, -1);
|
||||
// CParticleEngine::GetInstance()->addEmitter(pEmitter);
|
||||
// CParticleEngine::GetInstance()->AddEmitter(pEmitter);
|
||||
|
||||
// Dimensions
|
||||
m_Width = width;
|
||||
@ -978,7 +978,7 @@ CMatrix3D CRenderer::GetModelViewProjectionMatrix()
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// SetObliqueFrustumClipping: change the near plane to the given clip plane (in world space)
|
||||
// Based on code from Game Programming Gems 5, from http://www.terathon.com/code/oblique.html
|
||||
// - cp is a clip plane in camera space (cp.dot(v) = 0 for any vector v on the plane)
|
||||
// - cp is a clip plane in camera space (cp.Dot(v) = 0 for any vector v on the plane)
|
||||
// - sign is 1 or -1, to specify the side to clip on
|
||||
void CRenderer::SetObliqueFrustumClipping(const CVector4D& cp, int sign)
|
||||
{
|
||||
@ -1001,13 +1001,13 @@ void CRenderer::SetObliqueFrustumClipping(const CVector4D& cp, int sign)
|
||||
// Convert the normal to camera space
|
||||
CVector4D planeNormal(cp.m_X, cp.m_Y, cp.m_Z, 0);
|
||||
planeNormal = normalMatrix.Transform(planeNormal);
|
||||
planeNormal.normalize();
|
||||
planeNormal.Normalize();
|
||||
|
||||
// Find a point on the plane: we'll take the normal times -D
|
||||
float oldD = cp.m_W;
|
||||
CVector4D pointOnPlane(-oldD * cp.m_X, -oldD * cp.m_Y, -oldD * cp.m_Z, 1);
|
||||
pointOnPlane = viewMatrix.Transform(pointOnPlane);
|
||||
float newD = -pointOnPlane.dot(planeNormal);
|
||||
float newD = -pointOnPlane.Dot(planeNormal);
|
||||
|
||||
// Now create a clip plane from the new normal and new D
|
||||
CVector4D camPlane = planeNormal;
|
||||
@ -1027,7 +1027,7 @@ void CRenderer::SetObliqueFrustumClipping(const CVector4D& cp, int sign)
|
||||
q.m_W = (1.0f + matrix[10]) / matrix[14];
|
||||
|
||||
// Calculate the scaled plane vector
|
||||
CVector4D c = camPlane * (sign * 2.0f / camPlane.dot(q));
|
||||
CVector4D c = camPlane * (sign * 2.0f / camPlane.Dot(q));
|
||||
|
||||
// Replace the third row of the projection matrix
|
||||
matrix[2] = c.m_X;
|
||||
@ -1093,13 +1093,13 @@ void CRenderer::RenderReflections()
|
||||
|
||||
// Render sky, terrain and models
|
||||
m->skyManager.RenderSky();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
RenderPatches();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
RenderModels();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
RenderTransparentModels();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
// Copy the image to a texture
|
||||
pglActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
@ -1161,11 +1161,11 @@ void CRenderer::RenderRefractions()
|
||||
|
||||
// Render terrain and models
|
||||
RenderPatches();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
RenderModels();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
RenderTransparentModels();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
// Copy the image to a texture
|
||||
pglActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
@ -1188,7 +1188,7 @@ void CRenderer::RenderRefractions()
|
||||
// RenderSubmissions: force rendering of any batched objects
|
||||
void CRenderer::RenderSubmissions()
|
||||
{
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
// Set the camera
|
||||
m->SetOpenGLCamera(m_ViewCamera);
|
||||
@ -1218,7 +1218,7 @@ void CRenderer::RenderSubmissions()
|
||||
glClearColor(m_ClearColor[0],m_ClearColor[1],m_ClearColor[2],m_ClearColor[3]);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
if (m_WaterManager->m_RenderWater && m_Options.m_FancyWater)
|
||||
{
|
||||
@ -1237,44 +1237,44 @@ void CRenderer::RenderSubmissions()
|
||||
{
|
||||
MICROLOG(L"render sky");
|
||||
m->skyManager.RenderSky();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
}
|
||||
|
||||
// render submitted patches and models
|
||||
MICROLOG(L"render patches");
|
||||
RenderPatches();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
if (g_Game && m_RenderTerritories)
|
||||
{
|
||||
g_Game->GetWorld()->GetTerritoryManager()->renderTerritories();
|
||||
oglCheck();
|
||||
g_Game->GetWorld()->GetTerritoryManager()->RenderTerritories();
|
||||
ogl_WarnIfError();
|
||||
}
|
||||
|
||||
// render debug-related terrain overlays
|
||||
TerrainOverlay::RenderOverlays();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
MICROLOG(L"render models");
|
||||
RenderModels();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
// render transparent stuff, so it can overlap models/terrain
|
||||
MICROLOG(L"render transparent");
|
||||
RenderTransparentModels();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
// render water
|
||||
if (m_WaterManager->m_RenderWater && g_Game)
|
||||
{
|
||||
MICROLOG(L"render water");
|
||||
m->terrainRenderer->RenderWater();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
// render transparent stuff again, so it can overlap the water
|
||||
MICROLOG(L"render transparent 2");
|
||||
RenderTransparentModels();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
// TODO: Maybe think of a better way to deal with transparent objects;
|
||||
// they can appear both under and above water (seaweed vs. trees), but doing
|
||||
@ -1291,8 +1291,8 @@ void CRenderer::RenderSubmissions()
|
||||
|
||||
//// Particle Engine Rendering.
|
||||
MICROLOG(L"render particles");
|
||||
CParticleEngine::GetInstance()->renderParticles();
|
||||
oglCheck();
|
||||
CParticleEngine::GetInstance()->RenderParticles();
|
||||
ogl_WarnIfError();
|
||||
|
||||
// render debug lines
|
||||
if (m_DisplayFrustum)
|
||||
@ -1300,7 +1300,7 @@ void CRenderer::RenderSubmissions()
|
||||
MICROLOG(L"display frustum");
|
||||
DisplayFrustum();
|
||||
m->shadow->RenderDebugDisplay();
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
}
|
||||
|
||||
// empty lists
|
||||
@ -1423,7 +1423,7 @@ void CRenderer::RenderScene(Scene *scene)
|
||||
MICROLOG(L"collect objects");
|
||||
scene->EnumerateObjects(frustum, this);
|
||||
|
||||
oglCheck();
|
||||
ogl_WarnIfError();
|
||||
|
||||
MICROLOG(L"flush objects");
|
||||
RenderSubmissions();
|
||||
|
@ -131,7 +131,7 @@ void ShadowMap::SetupFrame(const CCamera& camera, const CVector3D& lightdir)
|
||||
|
||||
z.Normalize();
|
||||
x -= z * z.Dot(x);
|
||||
if (x.GetLength() < 0.001)
|
||||
if (x.Length() < 0.001)
|
||||
{
|
||||
// this is invoked if the camera and light directions almost coincide
|
||||
// assumption: light direction has a significant Z component
|
||||
|
@ -546,7 +546,7 @@ void TerrainRenderer::RenderWater()
|
||||
bool shouldRender = false;
|
||||
for(int j=0; j<4; j++)
|
||||
{
|
||||
float terrainHeight = terrain->getVertexGroundLevel(x + DX[j], z + DZ[j]);
|
||||
float terrainHeight = terrain->GetVertexGroundLevel(x + DX[j], z + DZ[j]);
|
||||
if( terrainHeight < WaterMgr->m_WaterHeight )
|
||||
{
|
||||
shouldRender = true;
|
||||
@ -566,7 +566,7 @@ void TerrainRenderer::RenderWater()
|
||||
float vertX = ix * CELL_SIZE;
|
||||
float vertZ = iz * CELL_SIZE;
|
||||
|
||||
float terrainHeight = terrain->getVertexGroundLevel(ix, iz);
|
||||
float terrainHeight = terrain->GetVertexGroundLevel(ix, iz);
|
||||
|
||||
float alpha = clamp(
|
||||
(WaterMgr->m_WaterHeight - terrainHeight) / WaterMgr->m_WaterFullDepth + WaterMgr->m_WaterAlphaOffset,
|
||||
|
@ -51,7 +51,7 @@ CVertexBuffer::CVertexBuffer(size_t vertexSize,bool dynamic)
|
||||
|
||||
// (PT: Disabled the VBOFailed test because it's not very useful at the
|
||||
// moment (it'll just cause the program to terminate, and I don't think
|
||||
// it has ever helped to discover any problems, and a later oglCheck()
|
||||
// it has ever helped to discover any problems, and a later ogl_WarnIfError()
|
||||
// will tell us if there were any VBO issues anyway), and so it's a
|
||||
// waste of time to call glGetError so frequently.)
|
||||
// glGetError(); // clear the error state
|
||||
|
@ -112,7 +112,7 @@ JSBool WriteLog(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
// Retrieve the entity currently occupying the specified handle.
|
||||
// params: handle [int]
|
||||
// returns: entity
|
||||
JSBool getEntityByUnitID( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool GetEntityByUnitID( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
*rval = JSVAL_NULL;
|
||||
@ -143,7 +143,7 @@ JSBool getEntityByUnitID( JSContext* cx, JSObject*, uint argc, jsval* argv, jsva
|
||||
// Look up an EntityTemplate by name.
|
||||
// params: template name [wstring]
|
||||
// returns: entity template object
|
||||
JSBool getEntityTemplate( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool GetEntityTemplate( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAM_RANGE(1, 2);
|
||||
*rval = JSVAL_NULL;
|
||||
@ -165,7 +165,7 @@ JSBool getEntityTemplate( JSContext* cx, JSObject*, uint argc, jsval* argv, jsva
|
||||
return( JS_TRUE );
|
||||
}
|
||||
|
||||
CEntityTemplate* v = g_EntityTemplateCollection.getTemplate( templateName, player );
|
||||
CEntityTemplate* v = g_EntityTemplateCollection.GetTemplate( templateName, player );
|
||||
if( !v )
|
||||
{
|
||||
JS_ReportError( cx, "No such template: %s", CStr(templateName).c_str() );
|
||||
@ -176,19 +176,19 @@ JSBool getEntityTemplate( JSContext* cx, JSObject*, uint argc, jsval* argv, jsva
|
||||
return( JS_TRUE );
|
||||
}
|
||||
|
||||
JSBool getPlayerUnitCount( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool GetPlayerUnitCount( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(2);
|
||||
int unitCount, playerNum = ToPrimitive<int>( argv[0] );
|
||||
CStrW unitName = ToPrimitive<CStrW>( argv[1] );
|
||||
|
||||
unitCount = g_EntityManager.getPlayerUnitCount((size_t)playerNum, unitName);
|
||||
unitCount = g_EntityManager.GetPlayerUnitCount((size_t)playerNum, unitName);
|
||||
*rval = ToJSVal( unitCount );
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//Used to create net messages for formations--msgList.front() is the original message. see issueCommand
|
||||
//Used to create net messages for formations--msgList.front() is the original message. see IssueCommand
|
||||
void CreateFormationMessage( std::vector<CNetMessage*>& msgList, CNetMessage* msg, CEntityList& formation )
|
||||
{
|
||||
CNetMessage* retMsg;
|
||||
@ -223,7 +223,7 @@ void CreateFormationMessage( std::vector<CNetMessage*>& msgList, CNetMessage* ms
|
||||
// params: either an entity- or entity collection object, message ID [int],
|
||||
// any further params needed by CNetMessage::CommandFromJSArgs
|
||||
// returns: command in serialized form [string]
|
||||
JSBool issueCommand( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool IssueCommand( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
// at least one for target object, one for isQueued, and then 1 or more for the CommandFromJSArgs
|
||||
JSU_REQUIRE_MIN_PARAMS(3);
|
||||
@ -281,55 +281,14 @@ JSBool issueCommand( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rv
|
||||
|
||||
for ( std::vector<CNetMessage*>::iterator it=messages.begin(); it != messages.end(); it++ )
|
||||
{
|
||||
//g_Console->InsertMessage(L"issueCommand: %hs", (*it)->GetString().c_str());
|
||||
//g_Console->InsertMessage(L"IssueCommand: %hs", (*it)->GetString().c_str());
|
||||
g_Game->GetSimulation()->QueueLocalCommand(*it);
|
||||
*rval = g_ScriptingHost.UCStringToValue((*it)->GetString());
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
//Formation stuff
|
||||
JSBool createEntityFormation( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(2);
|
||||
|
||||
CEntityList entities = *EntityCollection::RetrieveSet(cx, JSVAL_TO_OBJECT(argv[0]));
|
||||
CStrW name = ToPrimitive<CStrW>( argv[1] );
|
||||
g_FormationManager.CreateFormation( entities, name );
|
||||
*rval = JSVAL_VOID;
|
||||
return JS_TRUE;
|
||||
|
||||
}
|
||||
JSBool removeFromFormation( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
|
||||
CEntityList entities;
|
||||
if (JS_GetClass(JSVAL_TO_OBJECT(argv[0])) == &CEntity::JSI_class)
|
||||
entities.push_back( (ToNative<CEntity>(argv[0])) ->me);
|
||||
else
|
||||
entities = *EntityCollection::RetrieveSet(cx, JSVAL_TO_OBJECT(argv[0]));
|
||||
|
||||
*rval = g_FormationManager.RemoveUnitList(entities) ? JS_TRUE : JS_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
JSBool lockEntityFormation( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
|
||||
CEntity* entity = ToNative<CEntity>( argv[0] );
|
||||
entity->GetFormation()->SetLock( ToPrimitive<bool>( argv[1] ) );
|
||||
*rval = JSVAL_VOID;
|
||||
return JS_TRUE;
|
||||
}
|
||||
JSBool isFormationLocked( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
|
||||
CEntity* entity = ToNative<CEntity>( argv[0] );
|
||||
*rval = entity->GetFormation()->IsLocked() ? JS_TRUE : JS_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
// Get the state of a given hotkey (from the hotkeys file)
|
||||
JSBool isOrderQueued( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
@ -341,11 +300,61 @@ JSBool isOrderQueued( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* ar
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// formations
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
JSBool CreateEntityFormation( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(2);
|
||||
|
||||
CEntityList entities = *EntityCollection::RetrieveSet(cx, JSVAL_TO_OBJECT(argv[0]));
|
||||
CStrW name = ToPrimitive<CStrW>( argv[1] );
|
||||
g_FormationManager.CreateFormation( entities, name );
|
||||
*rval = JSVAL_VOID;
|
||||
return JS_TRUE;
|
||||
|
||||
}
|
||||
|
||||
JSBool RemoveFromFormation( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
|
||||
CEntityList entities;
|
||||
if (JS_GetClass(JSVAL_TO_OBJECT(argv[0])) == &CEntity::JSI_class)
|
||||
entities.push_back( (ToNative<CEntity>(argv[0])) ->me);
|
||||
else
|
||||
entities = *EntityCollection::RetrieveSet(cx, JSVAL_TO_OBJECT(argv[0]));
|
||||
|
||||
*rval = g_FormationManager.RemoveUnitList(entities) ? JS_TRUE : JS_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool LockEntityFormation( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
|
||||
CEntity* entity = ToNative<CEntity>( argv[0] );
|
||||
entity->GetFormation()->SetLock( ToPrimitive<bool>( argv[1] ) );
|
||||
*rval = JSVAL_VOID;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool IsFormationLocked( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
|
||||
CEntity* entity = ToNative<CEntity>( argv[0] );
|
||||
*rval = entity->GetFormation()->IsLocked() ? JS_TRUE : JS_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Techs
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
JSBool getTechnology( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool GetTechnology( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(2);
|
||||
|
||||
@ -359,17 +368,17 @@ JSBool getTechnology( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* ar
|
||||
}
|
||||
catch( PSERROR_Scripting_ConversionFailed )
|
||||
{
|
||||
JS_ReportError( cx, "Invalid parameters for getTechnology (expected name and player)" );
|
||||
JS_ReportError( cx, "Invalid parameters for GetTechnology (expected name and player)" );
|
||||
return( JS_TRUE );
|
||||
}
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
CTechnology* tech = g_TechnologyCollection.getTechnology( name, player );
|
||||
CTechnology* tech = g_TechnologyCollection.GetTechnology( name, player );
|
||||
if ( tech )
|
||||
*rval = ToJSVal( tech );
|
||||
else
|
||||
g_Console->InsertMessage( L"Warning: Invalid tech template name \"%ls\" passed for getTechnology()", name.c_str() );
|
||||
g_Console->InsertMessage( L"Warning: Invalid tech template name \"%ls\" passed for GetTechnology()", name.c_str() );
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
@ -420,9 +429,9 @@ JSBool RemoveGlobalHandler( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsv
|
||||
// therefore suspended while the game is paused or frozen. Granularity of
|
||||
// timing is also limited to 1/(Simulation frame rate); currently 100ms.
|
||||
// The called function or script executes in the same scope as the
|
||||
// code that called setTimeout (amongst other things, the
|
||||
// code that called SetTimeout (amongst other things, the
|
||||
// 'this' reference is usually maintained)
|
||||
JSBool setTimeout( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool SetTimeout( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAM_RANGE(2, 3);
|
||||
|
||||
@ -457,14 +466,14 @@ JSBool setTimeout( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval
|
||||
case JSTYPE_STRING:
|
||||
{
|
||||
CStrW fragment = g_ScriptingHost.ValueToUCString( argv[0] );
|
||||
int id = g_Scheduler.pushTime( delay, fragment, scope );
|
||||
int id = g_Scheduler.PushTime( delay, fragment, scope );
|
||||
*rval = INT_TO_JSVAL( id );
|
||||
return( JS_TRUE );
|
||||
}
|
||||
case JSTYPE_FUNCTION:
|
||||
{
|
||||
JSFunction* fn = JS_ValueToFunction( cx, argv[0] );
|
||||
int id = g_Scheduler.pushTime( delay, fn, scope );
|
||||
int id = g_Scheduler.PushTime( delay, fn, scope );
|
||||
*rval = INT_TO_JSVAL( id );
|
||||
return( JS_TRUE );
|
||||
}
|
||||
@ -479,8 +488,8 @@ JSBool setTimeout( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval
|
||||
// OR callback [fragment or function], period in ms [int] (initial delay = period)
|
||||
// returns:
|
||||
// notes:
|
||||
// - setTimeout's notes apply here as well.
|
||||
JSBool setInterval( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
// - SetTimeout's notes apply here as well.
|
||||
JSBool SetInterval( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAM_RANGE(2, 3);
|
||||
|
||||
@ -510,14 +519,14 @@ JSBool setInterval( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rva
|
||||
case JSTYPE_STRING:
|
||||
{
|
||||
CStrW fragment = g_ScriptingHost.ValueToUCString( argv[0] );
|
||||
int id = g_Scheduler.pushInterval( first, interval, fragment, JS_GetScopeChain( cx ) );
|
||||
int id = g_Scheduler.PushInterval( first, interval, fragment, JS_GetScopeChain( cx ) );
|
||||
*rval = INT_TO_JSVAL( id );
|
||||
return( JS_TRUE );
|
||||
}
|
||||
case JSTYPE_FUNCTION:
|
||||
{
|
||||
JSFunction* fn = JS_ValueToFunction( cx, argv[0] );
|
||||
int id = g_Scheduler.pushInterval( first, interval, fn, JS_GetScopeChain( cx ) );
|
||||
int id = g_Scheduler.PushInterval( first, interval, fn, JS_GetScopeChain( cx ) );
|
||||
*rval = INT_TO_JSVAL( id );
|
||||
return( JS_TRUE );
|
||||
}
|
||||
@ -527,14 +536,14 @@ JSBool setInterval( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rva
|
||||
}
|
||||
}
|
||||
|
||||
// Cause all periodic functions registered via setInterval to
|
||||
// Cause all periodic functions registered via SetInterval to
|
||||
// no longer be called.
|
||||
// params:
|
||||
// returns:
|
||||
// notes:
|
||||
// - Execution continues until the end of the triggered function or
|
||||
// script fragment, but is not triggered again.
|
||||
JSBool cancelInterval( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool CancelInterval( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -549,14 +558,14 @@ JSBool cancelInterval( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval*
|
||||
// notes:
|
||||
// - Execution continues until the end of the triggered function or
|
||||
// script fragment, but is not triggered again.
|
||||
JSBool cancelTimer( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool CancelTimer( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
|
||||
try
|
||||
{
|
||||
int id = ToPrimitive<int>( argv[0] );
|
||||
g_Scheduler.cancelTask( id );
|
||||
g_Scheduler.CancelTask( id );
|
||||
}
|
||||
catch( PSERROR_Scripting_ConversionFailed )
|
||||
{
|
||||
@ -569,7 +578,7 @@ JSBool cancelTimer( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rva
|
||||
|
||||
//Set the simulation rate scalar-time becomes time * SimRate.
|
||||
//Params: rate [float] : sets SimRate
|
||||
JSBool setSimRate(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool SetSimRate(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
|
||||
@ -578,7 +587,7 @@ JSBool setSimRate(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
}
|
||||
|
||||
//Generate a random float in [0, 1) using the simulation's random generator
|
||||
JSBool simRand(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool SimRand(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -587,35 +596,34 @@ JSBool simRand(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
}
|
||||
|
||||
//Generate a random float int between 0 and the given number - 1 using the simulation's RNG
|
||||
JSBool simRandInt(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool SimRandInt(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
JSU_ASSERT(JSVAL_IS_INT(argv[0]), "simRandInt(): first parameter must be an int");
|
||||
JSU_ASSERT(JSVAL_IS_INT(argv[0]), "SimRandInt(): first parameter must be an int");
|
||||
|
||||
*rval = ToJSVal( g_Game->GetSimulation()->RandInt(ToPrimitive<int>(argv[0])) );
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
// Script profiling functions: Begin timing a piece of code with startXTimer(num)
|
||||
// and stop timing with stopXTimer(num). The results will be printed to stdout
|
||||
// Script profiling functions: Begin timing a piece of code with StartJsTimer(num)
|
||||
// and stop timing with StopJsTimer(num). The results will be printed to stdout
|
||||
// when the game exits.
|
||||
|
||||
static const uint MAX_XTIMERS = 20;
|
||||
typedef TimerRdtsc XTimerImpl; // type must be kept in sync with timer.h TIMER_USE_RAW_TICKS
|
||||
static XTimerImpl xtimer_impl;
|
||||
static XTimerImpl::unit xstart_times[MAX_XTIMERS];
|
||||
static XTimerImpl::unit xoverhead;
|
||||
static TimerClient xclients[MAX_XTIMERS];
|
||||
static char xdescription_buf[MAX_XTIMERS * 11];
|
||||
static const uint MAX_JS_TIMERS = 20;
|
||||
static Timer js_timer;
|
||||
static TimerUnit js_start_times[MAX_JS_TIMERS];
|
||||
static TimerUnit js_timer_overhead;
|
||||
static TimerClient js_timer_clients[MAX_JS_TIMERS];
|
||||
static char js_timer_descriptions_buf[MAX_JS_TIMERS * 12]; // depends on MAX_JS_TIMERS and format string below
|
||||
|
||||
static void initXTimers()
|
||||
static void InitJsTimers()
|
||||
{
|
||||
char* pos = xdescription_buf;
|
||||
for(uint i = 0; i < MAX_XTIMERS; i++)
|
||||
char* pos = js_timer_descriptions_buf;
|
||||
for(uint i = 0; i < MAX_JS_TIMERS; i++)
|
||||
{
|
||||
const char* description = pos;
|
||||
pos += sprintf(pos, "xtimer %d", i)+1;
|
||||
timer_add_client(&xclients[i], description);
|
||||
pos += sprintf(pos, "js_timer %d", i)+1;
|
||||
timer_add_client(&js_timer_clients[i], description);
|
||||
}
|
||||
|
||||
// call several times to get a good approximation of 'hot' performance.
|
||||
@ -633,35 +641,35 @@ static void initXTimers()
|
||||
"stopXTimer (0);\n"
|
||||
"\n";
|
||||
g_ScriptingHost.RunMemScript(calibration_script, strlen(calibration_script));
|
||||
xoverhead = xclients[0].sum/4;
|
||||
js_timer_overhead = js_timer_clients[0].sum/4;
|
||||
}
|
||||
|
||||
JSBool startXTimer(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool StartJsTimer(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
ONCE(initXTimers());
|
||||
ONCE(InitJsTimers());
|
||||
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
uint slot = ToPrimitive<uint>(argv[0]);
|
||||
if (slot >= MAX_XTIMERS)
|
||||
if (slot >= MAX_JS_TIMERS)
|
||||
return JS_FALSE;
|
||||
|
||||
debug_assert(xstart_times[slot] == 0);
|
||||
xstart_times[slot] = xtimer_impl.get_timestamp();
|
||||
debug_assert(js_start_times[slot] == 0);
|
||||
js_start_times[slot] = js_timer.get_timestamp();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
JSBool stopXTimer(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool StopJsTimer(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
uint slot = ToPrimitive<uint>(argv[0]);
|
||||
if (slot >= MAX_XTIMERS)
|
||||
if (slot >= MAX_JS_TIMERS)
|
||||
return JS_FALSE;
|
||||
|
||||
debug_assert(xstart_times[slot] != 0);
|
||||
XTimerImpl::unit dt = xtimer_impl.get_timestamp() - xstart_times[slot] - xoverhead;
|
||||
xstart_times[slot] = 0;
|
||||
timer_bill_client(&xclients[slot], dt);
|
||||
debug_assert(js_start_times[slot] != 0);
|
||||
TimerUnit dt = js_timer.get_timestamp() - js_start_times[slot] - js_timer_overhead;
|
||||
js_start_times[slot] = 0;
|
||||
timer_bill_client(&js_timer_clients[slot], dt);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@ -673,7 +681,7 @@ JSBool stopXTimer(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
// Create a new network server object.
|
||||
// params:
|
||||
// returns: net server object
|
||||
JSBool createServer(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool CreateServer(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -690,7 +698,7 @@ JSBool createServer(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rva
|
||||
// Create a new network client object.
|
||||
// params:
|
||||
// returns: net client object
|
||||
JSBool createClient(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool CreateClient(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -711,9 +719,9 @@ JSBool createClient(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rva
|
||||
// - Performs necessary initialization while calling back into the
|
||||
// main loop, so the game remains responsive to display+user input.
|
||||
// - When complete, the engine calls the reallyStartGame JS function.
|
||||
// TODO: Replace startGame with create(Game|Server|Client)/game.start() -
|
||||
// TODO: Replace StartGame with Create(Game|Server|Client)/game.start() -
|
||||
// after merging CGame and CGameAttributes
|
||||
JSBool startGame(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool StartGame(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -722,7 +730,7 @@ JSBool startGame(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
// Hosted MP Game
|
||||
if (g_NetServer)
|
||||
*rval = BOOLEAN_TO_JSVAL(g_NetServer->StartGame() == 0);
|
||||
// Joined MP Game: startGame is invalid - do nothing
|
||||
// Joined MP Game: StartGame is invalid - do nothing
|
||||
else if (g_NetClient)
|
||||
{
|
||||
}
|
||||
@ -750,7 +758,7 @@ JSBool startGame(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
// Immediately ends the current game (if any).
|
||||
// params:
|
||||
// returns:
|
||||
JSBool endGame(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool EndGame(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -758,7 +766,7 @@ JSBool endGame(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool getGameMode(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool GetGameMode(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -778,7 +786,7 @@ JSBool getGameMode(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval
|
||||
// Replaces the current language (locale) with a new one.
|
||||
// params: language id [string] as in I18n::LoadLanguage
|
||||
// returns:
|
||||
JSBool loadLanguage(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool LoadLanguage(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
|
||||
@ -792,7 +800,7 @@ JSBool loadLanguage(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rva
|
||||
// Return identifier of the current language (locale) in use.
|
||||
// params:
|
||||
// returns: language id [string] as in I18n::LoadLanguage
|
||||
JSBool getLanguageID(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool GetLanguageID(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
*rval = JSVAL_NULL;
|
||||
@ -819,7 +827,7 @@ JSBool getLanguageID(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rv
|
||||
// notes:
|
||||
// - currently implemented via access violation (read of address 0)
|
||||
// - useful for testing the crashlog/stack trace code.
|
||||
JSBool crash(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool ProvokeCrash(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -828,12 +836,12 @@ JSBool crash(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
}
|
||||
|
||||
|
||||
// Force a JS GC (garbage collection) cycle to take place immediately.
|
||||
// Force a JS garbage collection cycle to take place immediately.
|
||||
// params:
|
||||
// returns: true [bool]
|
||||
// notes:
|
||||
// - writes an indication of how long this took to the console.
|
||||
JSBool forceGC(JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval)
|
||||
JSBool ForceGarbageCollection(JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -856,7 +864,7 @@ JSBool forceGC(JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsv
|
||||
// returns: global object
|
||||
// notes:
|
||||
// - Useful for accessing an object from another scope.
|
||||
JSBool getGUIGlobal(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool GetGuiGlobal(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -867,7 +875,7 @@ JSBool getGUIGlobal(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rva
|
||||
// Resets the entire GUI state and reloads the XML files.
|
||||
// params:
|
||||
// returns:
|
||||
JSBool resetGUI(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
JSBool ResetGui(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -893,7 +901,7 @@ JSBool resetGUI(JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval)
|
||||
// notes:
|
||||
// - This value is recalculated once a frame. We take special care to
|
||||
// filter it, so it is both accurate and free of jitter.
|
||||
JSBool getFPS( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool GetFps( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -908,7 +916,7 @@ JSBool getFPS( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
// notes:
|
||||
// - Exit happens after the current main loop iteration ends
|
||||
// (since this only sets a flag telling it to end)
|
||||
JSBool exitProgram( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool ExitProgram( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -924,7 +932,7 @@ JSBool exitProgram( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rva
|
||||
// - Not supported on all platforms.
|
||||
// - Only a rough approximation; do not base low-level decisions
|
||||
// ("should I allocate one more texture?") on this.
|
||||
JSBool vmem( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool WriteVideoMemToConsole( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -946,13 +954,14 @@ JSBool vmem( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
// returns:
|
||||
// notes:
|
||||
// - Cursors are stored in "art\textures\cursors"
|
||||
JSBool setCursor( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool SetCursor( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
g_CursorName = g_ScriptingHost.ValueToString(argv[0]);
|
||||
return JS_TRUE;
|
||||
}
|
||||
JSBool getCursorName( JSContext* UNUSED(cx), JSObject*, uint UNUSED(argc), jsval* UNUSED(argv), jsval* rval )
|
||||
|
||||
JSBool GetCursorName( JSContext* UNUSED(cx), JSObject*, uint UNUSED(argc), jsval* UNUSED(argv), jsval* rval )
|
||||
{
|
||||
*rval = ToJSVal(g_CursorName);
|
||||
return JS_TRUE;
|
||||
@ -963,7 +972,7 @@ JSBool getCursorName( JSContext* UNUSED(cx), JSObject*, uint UNUSED(argc), jsval
|
||||
// returns:
|
||||
// notes:
|
||||
// - Usefulness is unclear. If you need it, consider renaming this and updating the docs.
|
||||
JSBool _rewriteMaps( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool _RewriteMaps( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -978,7 +987,7 @@ JSBool _rewriteMaps( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rv
|
||||
// notes:
|
||||
// - value is as required by GL_TEXTURE_LOD_BIAS.
|
||||
// - useful for adjusting image "sharpness" (since it affects which mipmap level is chosen)
|
||||
JSBool _lodbias( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool _LodBias( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
|
||||
@ -990,7 +999,7 @@ JSBool _lodbias( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
// Focus the game camera on a given position.
|
||||
// params: target position vector [CVector3D]
|
||||
// returns: success [bool]
|
||||
JSBool setCameraTarget( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool SetCameraTarget( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(1);
|
||||
*rval = JSVAL_NULL;
|
||||
@ -1022,13 +1031,13 @@ JSBool setCameraTarget( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval*
|
||||
// but that's a bit more trouble.
|
||||
// - To be exact, the date/time returned is when scriptglue.cpp was
|
||||
// last compiled; since the auto-build does full rebuilds, that is moot.
|
||||
JSBool buildTime( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool GetBuildTimestamp( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAM_RANGE(0, 1);
|
||||
|
||||
// buildTime( ) = "date time"
|
||||
// buildTime(0) = "date"
|
||||
// buildTime(1) = "time"
|
||||
// no param => "date time"
|
||||
// param = 0 => "date"
|
||||
// param = 1 => "time"
|
||||
JSString* s = JS_NewStringCopyZ(cx,
|
||||
argc && argv[0]==JSVAL_ONE ? __TIME__
|
||||
: argc ? __DATE__
|
||||
@ -1042,13 +1051,13 @@ JSBool buildTime( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rval
|
||||
// Return distance between 2 points.
|
||||
// params: 2 position vectors [CVector3D]
|
||||
// returns: Euclidean distance [float]
|
||||
JSBool v3dist( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool ComputeDistanceBetweenTwoPoints( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(2);
|
||||
|
||||
CVector3D* a = ToNative<CVector3D>( argv[0] );
|
||||
CVector3D* b = ToNative<CVector3D>( argv[1] );
|
||||
float dist = ( *a - *b ).GetLength();
|
||||
float dist = ( *a - *b ).Length();
|
||||
*rval = ToJSVal( dist );
|
||||
return( JS_TRUE );
|
||||
}
|
||||
@ -1059,7 +1068,7 @@ JSBool v3dist( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsval* argv, jsv
|
||||
// returns: global object
|
||||
// notes:
|
||||
// - Useful for accessing an object from another scope.
|
||||
JSBool getGlobal( JSContext* cx, JSObject* globalObject, uint argc, jsval* argv, jsval* rval )
|
||||
JSBool GetGlobal( JSContext* cx, JSObject* globalObject, uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -1068,7 +1077,7 @@ JSBool getGlobal( JSContext* cx, JSObject* globalObject, uint argc, jsval* argv,
|
||||
}
|
||||
|
||||
// Saves the current profiling data to the logs/profile.txt file
|
||||
JSBool saveProfileData( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool SaveProfileData( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
g_ProfileViewer.SaveToFile();
|
||||
@ -1079,7 +1088,7 @@ JSBool saveProfileData( JSContext* cx, JSObject* UNUSED(globalObject), uint argc
|
||||
// are then ordered to construct the building if it is placed.
|
||||
// params: templateName - the name of the entity to place.
|
||||
// returns: true if cursor was activated, false if cursor was already active.
|
||||
JSBool startPlacing( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool StartPlacing( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
CStrW name;
|
||||
if(argc == 0) {
|
||||
@ -1094,27 +1103,13 @@ JSBool startPlacing( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, j
|
||||
}
|
||||
}
|
||||
|
||||
*rval = g_BuildingPlacer.activate(name) ? JS_TRUE : JS_FALSE;
|
||||
*rval = g_BuildingPlacer.Activate(name) ? JS_TRUE : JS_FALSE;
|
||||
|
||||
return( JS_TRUE );
|
||||
}
|
||||
|
||||
/*
|
||||
//Converts given screenspace coordinates to worldspace. (CURRENTLY NOT IN USE)
|
||||
JSBool getWorldCoordinates( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS(2);
|
||||
int x = ToPrimitive<int>( argv[0] );
|
||||
int y = ToPrimitive<int>( argv[1] );
|
||||
|
||||
CVector3D world = g_Game->GetView()->GetCamera()->GetWorldCoordinates(x, y);
|
||||
*rval = ToJSVal(world);
|
||||
return JS_TRUE;
|
||||
}
|
||||
*/
|
||||
|
||||
// Toggles drawing the sky
|
||||
JSBool toggleSky( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool ToggleSky( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
g_Renderer.GetSkyManager()->m_RenderSky = !g_Renderer.GetSkyManager()->m_RenderSky;
|
||||
@ -1123,7 +1118,7 @@ JSBool toggleSky( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsva
|
||||
}
|
||||
|
||||
// Toggles drawing territory outlines
|
||||
JSBool toggleTerritoryRendering( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool ToggleTerritoryRendering( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
g_Renderer.m_RenderTerritories = !g_Renderer.m_RenderTerritories;
|
||||
@ -1131,8 +1126,12 @@ JSBool toggleTerritoryRendering( JSContext* cx, JSObject* UNUSED(globalObject),
|
||||
return( JS_TRUE );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// water
|
||||
|
||||
// Toggles drawing the water plane
|
||||
JSBool toggleWater( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool ToggleWater( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
g_Renderer.GetWaterManager()->m_RenderWater = !g_Renderer.GetWaterManager()->m_RenderWater;
|
||||
@ -1141,7 +1140,7 @@ JSBool toggleWater( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, js
|
||||
}
|
||||
|
||||
// Sets the water plane height
|
||||
JSBool setWaterHeight( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool SetWaterHeight( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS( 1 );
|
||||
float newHeight;
|
||||
@ -1158,7 +1157,7 @@ JSBool setWaterHeight( JSContext* cx, JSObject* UNUSED(globalObject), uint argc,
|
||||
}
|
||||
|
||||
// Gets the water plane height
|
||||
JSBool getWaterHeight( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool GetWaterHeight( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
*rval = ToJSVal(g_Renderer.GetWaterManager()->m_WaterHeight);
|
||||
@ -1166,7 +1165,7 @@ JSBool getWaterHeight( JSContext* cx, JSObject* UNUSED(globalObject), uint argc,
|
||||
}
|
||||
|
||||
// Sets the water color
|
||||
JSBool setWaterColor( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool SetWaterColor( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS( 3 );
|
||||
float r,g,b;
|
||||
@ -1184,7 +1183,7 @@ JSBool setWaterColor( JSContext* cx, JSObject* UNUSED(globalObject), uint argc,
|
||||
}
|
||||
|
||||
// Sets the water tint (used to tint reflections in fancy water)
|
||||
JSBool setWaterTint( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool SetWaterTint( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS( 3 );
|
||||
float r,g,b;
|
||||
@ -1202,7 +1201,7 @@ JSBool setWaterTint( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, j
|
||||
}
|
||||
|
||||
// Sets the water tint (used to tint reflections in fancy water)
|
||||
JSBool setReflectionTint( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool SetReflectionTint( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS( 3 );
|
||||
float r,g,b;
|
||||
@ -1220,7 +1219,7 @@ JSBool setReflectionTint( JSContext* cx, JSObject* UNUSED(globalObject), uint ar
|
||||
}
|
||||
|
||||
// Sets the max water alpha (achieved when it is at WaterFullDepth or deeper)
|
||||
JSBool setWaterMaxAlpha( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool SetWaterMaxAlpha( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS( 1 );
|
||||
float val;
|
||||
@ -1236,7 +1235,7 @@ JSBool setWaterMaxAlpha( JSContext* cx, JSObject* UNUSED(globalObject), uint arg
|
||||
}
|
||||
|
||||
// Sets the water full depth (when it is colored WaterMaxAlpha)
|
||||
JSBool setWaterFullDepth( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool SetWaterFullDepth( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS( 1 );
|
||||
float val;
|
||||
@ -1252,7 +1251,7 @@ JSBool setWaterFullDepth( JSContext* cx, JSObject* UNUSED(globalObject), uint ar
|
||||
}
|
||||
|
||||
// Sets the water alpha offset (added to tweak water alpha near the shore)
|
||||
JSBool setWaterAlphaOffset( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool SetWaterAlphaOffset( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS( 1 );
|
||||
float val;
|
||||
@ -1267,8 +1266,10 @@ JSBool setWaterAlphaOffset( JSContext* cx, JSObject* UNUSED(globalObject), uint
|
||||
return( JS_TRUE );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Is the game paused?
|
||||
JSBool isPaused( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool IsPaused( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -1283,7 +1284,7 @@ JSBool isPaused( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval
|
||||
}
|
||||
|
||||
// Pause/unpause the game
|
||||
JSBool setPaused( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool SetPaused( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS( 1 );
|
||||
|
||||
@ -1299,14 +1300,14 @@ JSBool setPaused( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsva
|
||||
}
|
||||
catch( PSERROR_Scripting_ConversionFailed )
|
||||
{
|
||||
JS_ReportError( cx, "Invalid parameter to setPaused" );
|
||||
JS_ReportError( cx, "Invalid parameter to SetPaused" );
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
// Get game time
|
||||
JSBool getGameTime( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool GetGameTime( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_NO_PARAMS();
|
||||
|
||||
@ -1320,8 +1321,7 @@ JSBool getGameTime( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, js
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool registerTrigger( JSContext* cx, JSObject* UNUSED(globalObject), uint argc,
|
||||
jsval* argv, jsval* rval )
|
||||
JSBool RegisterTrigger( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS_CPP(1);
|
||||
CTrigger* trigger = ToNative<CTrigger>( argv[0] );
|
||||
@ -1331,8 +1331,8 @@ JSBool registerTrigger( JSContext* cx, JSObject* UNUSED(globalObject), uint argc
|
||||
*rval = JSVAL_NULL;
|
||||
return JS_TRUE;
|
||||
}
|
||||
JSBool getTrigger( JSContext* cx, JSObject* UNUSED(globalObject), uint argc,
|
||||
jsval* argv, jsval* rval )
|
||||
|
||||
JSBool GetTrigger( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS_CPP(1);
|
||||
CStrW name = ToPrimitive<CStrW>( argv[0] );
|
||||
@ -1348,7 +1348,7 @@ JSBool getTrigger( JSContext* cx, JSObject* UNUSED(globalObject), uint argc,
|
||||
}
|
||||
|
||||
// Reveal map
|
||||
JSBool revealMap( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
JSBool RevealMap( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsval* argv, jsval* rval )
|
||||
{
|
||||
JSU_REQUIRE_PARAM_RANGE(0, 1);
|
||||
|
||||
@ -1381,120 +1381,123 @@ JSBool revealMap( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsva
|
||||
// - Extra (reserved for future use, always zero)
|
||||
//
|
||||
// we simplify this a bit with a macro:
|
||||
#define JS_FUNC(script_name, cpp_function, min_params) { #script_name, cpp_function, min_params, 0, 0 },
|
||||
#define JS_FUNC(script_name, cpp_function, min_params) { script_name, cpp_function, min_params, 0, 0 },
|
||||
|
||||
JSFunctionSpec ScriptFunctionTable[] =
|
||||
{
|
||||
// Console
|
||||
JS_FUNC(writeConsole, JSI_Console::writeConsole, 1) // external
|
||||
JS_FUNC("writeConsole", JSI_Console::writeConsole, 1) // external
|
||||
|
||||
// Entity
|
||||
JS_FUNC(getEntityByUnitID, getEntityByUnitID, 1)
|
||||
JS_FUNC(getPlayerUnitCount, getPlayerUnitCount, 1)
|
||||
JS_FUNC(getEntityTemplate, getEntityTemplate, 1)
|
||||
JS_FUNC(issueCommand, issueCommand, 2)
|
||||
JS_FUNC(startPlacing, startPlacing, 1)
|
||||
JS_FUNC("getEntityByUnitID", GetEntityByUnitID, 1)
|
||||
JS_FUNC("GetPlayerUnitCount", GetPlayerUnitCount, 1)
|
||||
JS_FUNC("getEntityTemplate", GetEntityTemplate, 1)
|
||||
JS_FUNC("issueCommand", IssueCommand, 2)
|
||||
JS_FUNC("startPlacing", StartPlacing, 1)
|
||||
|
||||
JS_FUNC(createEntityFormation, createEntityFormation, 2)
|
||||
JS_FUNC(removeFromFormation, removeFromFormation, 1)
|
||||
JS_FUNC(lockEntityFormation, lockEntityFormation, 1)
|
||||
JS_FUNC(isFormationLocked, isFormationLocked, 1)
|
||||
// Formation
|
||||
JS_FUNC("createEntityFormation", CreateEntityFormation, 2)
|
||||
JS_FUNC("removeFromFormation", RemoveFromFormation, 1)
|
||||
JS_FUNC("lockEntityFormation", LockEntityFormation, 1)
|
||||
JS_FUNC("isFormationLocked", IsFormationLocked, 1)
|
||||
|
||||
JS_FUNC(registerTrigger, registerTrigger, 1)
|
||||
// Trigger
|
||||
JS_FUNC("registerTrigger", RegisterTrigger, 1)
|
||||
|
||||
// Tech
|
||||
JS_FUNC(getTechnology, getTechnology, 2)
|
||||
JS_FUNC("getTechnology", GetTechnology, 2)
|
||||
|
||||
// Camera
|
||||
JS_FUNC(setCameraTarget, setCameraTarget, 1)
|
||||
JS_FUNC("setCameraTarget", SetCameraTarget, 1)
|
||||
|
||||
// Sky
|
||||
JS_FUNC(toggleSky, toggleSky, 0)
|
||||
JS_FUNC("toggleSky", ToggleSky, 0)
|
||||
|
||||
// Water
|
||||
JS_FUNC(toggleWater, toggleWater, 0)
|
||||
JS_FUNC(setWaterHeight, setWaterHeight, 1)
|
||||
JS_FUNC(getWaterHeight, getWaterHeight, 0)
|
||||
JS_FUNC(setWaterColor, setWaterColor, 3)
|
||||
JS_FUNC(setWaterTint, setWaterTint, 3)
|
||||
JS_FUNC(setReflectionTint, setReflectionTint, 3)
|
||||
JS_FUNC(setWaterMaxAlpha, setWaterMaxAlpha, 0)
|
||||
JS_FUNC(setWaterFullDepth, setWaterFullDepth, 0)
|
||||
JS_FUNC(setWaterAlphaOffset, setWaterAlphaOffset, 0)
|
||||
JS_FUNC("toggleWater", ToggleWater, 0)
|
||||
JS_FUNC("setWaterHeight", SetWaterHeight, 1)
|
||||
JS_FUNC("getWaterHeight", GetWaterHeight, 0)
|
||||
JS_FUNC("setWaterColor", SetWaterColor, 3)
|
||||
JS_FUNC("setWaterTint", SetWaterTint, 3)
|
||||
JS_FUNC("setReflectionTint", SetReflectionTint, 3)
|
||||
JS_FUNC("setWaterMaxAlpha", SetWaterMaxAlpha, 0)
|
||||
JS_FUNC("setWaterFullDepth", SetWaterFullDepth, 0)
|
||||
JS_FUNC("setWaterAlphaOffset", SetWaterAlphaOffset, 0)
|
||||
|
||||
// Territory rendering
|
||||
JS_FUNC(toggleTerritoryRendering, toggleTerritoryRendering, 0)
|
||||
JS_FUNC("toggleTerritoryRendering", ToggleTerritoryRendering, 0)
|
||||
|
||||
// GUI
|
||||
#ifndef NO_GUI
|
||||
JS_FUNC(getGUIObjectByName, JSI_IGUIObject::getByName, 1) // external
|
||||
JS_FUNC(getGUIGlobal, getGUIGlobal, 0)
|
||||
JS_FUNC(resetGUI, resetGUI, 0)
|
||||
JS_FUNC("getGUIObjectByName", JSI_IGUIObject::getByName, 1) // external
|
||||
JS_FUNC("getGUIGlobal", GetGuiGlobal, 0)
|
||||
JS_FUNC("resetGUI", ResetGui, 0)
|
||||
#endif
|
||||
|
||||
// Events
|
||||
JS_FUNC(addGlobalHandler, AddGlobalHandler, 2)
|
||||
JS_FUNC(removeGlobalHandler, RemoveGlobalHandler, 2)
|
||||
JS_FUNC("addGlobalHandler", AddGlobalHandler, 2)
|
||||
JS_FUNC("removeGlobalHandler", RemoveGlobalHandler, 2)
|
||||
|
||||
// Timer
|
||||
JS_FUNC(setTimeout, setTimeout, 2)
|
||||
JS_FUNC(setInterval, setInterval, 2)
|
||||
JS_FUNC(cancelInterval, cancelInterval, 0)
|
||||
JS_FUNC(cancelTimer, cancelTimer, 0)
|
||||
JS_FUNC(setSimRate, setSimRate, 1)
|
||||
JS_FUNC("setTimeout", SetTimeout, 2)
|
||||
JS_FUNC("setInterval", SetInterval, 2)
|
||||
JS_FUNC("cancelInterval", CancelInterval, 0)
|
||||
JS_FUNC("cancelTimer", CancelTimer, 0)
|
||||
JS_FUNC("setSimRate", SetSimRate, 1)
|
||||
|
||||
// Random number generator
|
||||
JS_FUNC(simRand, simRand, 0)
|
||||
JS_FUNC(simRandInt, simRandInt, 1)
|
||||
JS_FUNC("simRand", SimRand, 0)
|
||||
JS_FUNC("simRandInt", SimRandInt, 1)
|
||||
|
||||
// Profiling
|
||||
JS_FUNC(startXTimer, startXTimer, 1)
|
||||
JS_FUNC(stopXTimer, stopXTimer, 1)
|
||||
JS_FUNC("startXTimer", StartJsTimer, 1)
|
||||
JS_FUNC("stopXTimer", StopJsTimer, 1)
|
||||
|
||||
// Game Setup
|
||||
JS_FUNC(startGame, startGame, 0)
|
||||
JS_FUNC(endGame, endGame, 0)
|
||||
JS_FUNC(getGameMode, getGameMode, 0)
|
||||
JS_FUNC(createClient, createClient, 0)
|
||||
JS_FUNC(createServer, createServer, 0)
|
||||
JS_FUNC("startGame", StartGame, 0)
|
||||
JS_FUNC("endGame", EndGame, 0)
|
||||
JS_FUNC("getGameMode", GetGameMode, 0)
|
||||
JS_FUNC("createClient", CreateClient, 0)
|
||||
JS_FUNC("createServer", CreateServer, 0)
|
||||
|
||||
// VFS (external)
|
||||
JS_FUNC(buildDirEntList, JSI_VFS::BuildDirEntList, 1)
|
||||
JS_FUNC(getFileMTime, JSI_VFS::GetFileMTime, 1)
|
||||
JS_FUNC(getFileSize, JSI_VFS::GetFileSize, 1)
|
||||
JS_FUNC(readFile, JSI_VFS::ReadFile, 1)
|
||||
JS_FUNC(readFileLines, JSI_VFS::ReadFileLines, 1)
|
||||
JS_FUNC(archiveBuilderCancel, JSI_VFS::ArchiveBuilderCancel, 1)
|
||||
JS_FUNC("buildDirEntList", JSI_VFS::BuildDirEntList, 1)
|
||||
JS_FUNC("getFileMTime", JSI_VFS::GetFileMTime, 1)
|
||||
JS_FUNC("getFileSize", JSI_VFS::GetFileSize, 1)
|
||||
JS_FUNC("readFile", JSI_VFS::ReadFile, 1)
|
||||
JS_FUNC("readFileLines", JSI_VFS::ReadFileLines, 1)
|
||||
JS_FUNC("archiveBuilderCancel", JSI_VFS::ArchiveBuilderCancel, 1)
|
||||
|
||||
// Internationalization
|
||||
JS_FUNC(loadLanguage, loadLanguage, 1)
|
||||
JS_FUNC(getLanguageID, getLanguageID, 0)
|
||||
JS_FUNC("loadLanguage", LoadLanguage, 1)
|
||||
JS_FUNC("getLanguageID", GetLanguageID, 0)
|
||||
// note: i18n/ScriptInterface.cpp registers translate() itself.
|
||||
// rationale: see implementation section above.
|
||||
|
||||
// Debug
|
||||
JS_FUNC(crash, crash, 0)
|
||||
JS_FUNC(forceGC, forceGC, 0)
|
||||
JS_FUNC(revealMap, revealMap, 1)
|
||||
JS_FUNC("crash", ProvokeCrash, 0)
|
||||
JS_FUNC("forceGC", ForceGarbageCollection, 0)
|
||||
JS_FUNC("revealMap", RevealMap, 1)
|
||||
|
||||
// Misc. Engine Interface
|
||||
JS_FUNC(writeLog, WriteLog, 1)
|
||||
JS_FUNC(exit, exitProgram, 0)
|
||||
JS_FUNC(isPaused, isPaused, 0)
|
||||
JS_FUNC(setPaused, setPaused, 1)
|
||||
JS_FUNC(getGameTime, getGameTime, 0)
|
||||
JS_FUNC(vmem, vmem, 0)
|
||||
JS_FUNC(_rewriteMaps, _rewriteMaps, 0)
|
||||
JS_FUNC(_lodbias, _lodbias, 0)
|
||||
JS_FUNC(setCursor, setCursor, 1)
|
||||
JS_FUNC(getCursorName, getCursorName, 0)
|
||||
JS_FUNC(getFPS, getFPS, 0)
|
||||
JS_FUNC(isOrderQueued, isOrderQueued, 1)
|
||||
JS_FUNC("writeLog", WriteLog, 1)
|
||||
JS_FUNC("exit", ExitProgram, 0)
|
||||
JS_FUNC("isPaused", IsPaused, 0)
|
||||
JS_FUNC("setPaused", SetPaused, 1)
|
||||
JS_FUNC("getGameTime", GetGameTime, 0)
|
||||
JS_FUNC("vmem", WriteVideoMemToConsole, 0)
|
||||
JS_FUNC("_rewriteMaps", _RewriteMaps, 0)
|
||||
JS_FUNC("_lodBias", _LodBias, 0)
|
||||
JS_FUNC("setCursor", SetCursor, 1)
|
||||
JS_FUNC("getCursorName", GetCursorName, 0)
|
||||
JS_FUNC("getFPS", GetFps, 0)
|
||||
JS_FUNC("isOrderQueued", isOrderQueued, 1)
|
||||
|
||||
// Miscellany
|
||||
JS_FUNC(v3dist, v3dist, 2)
|
||||
JS_FUNC(buildTime, buildTime, 0)
|
||||
JS_FUNC(getGlobal, getGlobal, 0)
|
||||
JS_FUNC(saveProfileData, saveProfileData, 0)
|
||||
JS_FUNC("v3dist", ComputeDistanceBetweenTwoPoints, 2)
|
||||
JS_FUNC("buildTime", GetBuildTimestamp, 0)
|
||||
JS_FUNC("getGlobal", GetGlobal, 0)
|
||||
JS_FUNC("saveProfileData", SaveProfileData, 0)
|
||||
|
||||
// end of table marker
|
||||
{0, 0, 0, 0, 0}
|
||||
@ -1590,7 +1593,7 @@ enum ScriptGlobalTinyIDs
|
||||
|
||||
JSPropertySpec ScriptGlobalTable[] =
|
||||
{
|
||||
{ "selection" , GLOBAL_SELECTION, PERM, JSI_Selection::getSelection, JSI_Selection::setSelection },
|
||||
{ "selection" , GLOBAL_SELECTION, PERM, JSI_Selection::getSelection, JSI_Selection::SetSelection },
|
||||
{ "groups" , GLOBAL_GROUPSARRAY, PERM, JSI_Selection::getGroups, JSI_Selection::setGroups },
|
||||
{ "camera" , GLOBAL_CAMERA, PERM, JSI_Camera::getCamera, JSI_Camera::setCamera },
|
||||
{ "console" , GLOBAL_CONSOLE, PERM | CONST, JSI_Console::getConsole, 0 },
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
virtual void Rebuild() = 0;
|
||||
|
||||
// HACK: Doesn't belong here.
|
||||
virtual void rebuildClassSet() = 0;
|
||||
virtual void RebuildClassSet() = 0;
|
||||
|
||||
// Check for a property
|
||||
virtual IJSComplexProperty* HasProperty( const CStrW& PropertyName ) = 0;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "AStarEngine.h"
|
||||
|
||||
/* For AStarGoalLowLevel isPassable/cost */
|
||||
/* For AStarGoalLowLevel IsPassable/cost */
|
||||
#include "Collision.h"
|
||||
#include "Entity.h"
|
||||
|
||||
@ -66,38 +66,38 @@ CAStarEngine::~CAStarEngine()
|
||||
}
|
||||
|
||||
|
||||
bool CAStarEngine::findPath(
|
||||
bool CAStarEngine::FindPath(
|
||||
const CVector2D &src, const CVector2D &dest, HEntity entity, float radius )
|
||||
{
|
||||
mSolved = false;
|
||||
int iterations = 0;
|
||||
|
||||
mGoal->setDestination(dest);
|
||||
mGoal->setRadius(radius);
|
||||
mGoal->SetDestination(dest);
|
||||
mGoal->SetRadius(radius);
|
||||
|
||||
AStarNode *start = getFreeASNode();
|
||||
start->coord = mGoal->getTile(src);
|
||||
AStarNode *start = GetFreeASNode();
|
||||
start->coord = mGoal->GetTile(src);
|
||||
start->parent = NULL;
|
||||
start->g = 0;
|
||||
start->f = start->h = mGoal->distanceToGoal(start->coord);
|
||||
start->f = start->h = mGoal->DistanceToGoal(start->coord);
|
||||
|
||||
clearOpen();
|
||||
clearClosed();
|
||||
ClearOpen();
|
||||
ClearClosed();
|
||||
PROFILE_START("memset cache");
|
||||
memset(mFlags, 0, mFlagArraySize*mFlagArraySize*sizeof(AStarNodeFlag));
|
||||
PROFILE_END("memset cache");
|
||||
|
||||
addToOpen(start);
|
||||
AddToOpen(start);
|
||||
|
||||
AStarNode *best = NULL;
|
||||
|
||||
while( iterations<mSearchLimit && (best = removeBestOpenNode()) != NULL )
|
||||
while( iterations<mSearchLimit && (best = RemoveBestOpenNode()) != NULL )
|
||||
{
|
||||
iterations++;
|
||||
PROFILE_START("addToClosed");
|
||||
addToClosed(best);
|
||||
PROFILE_END("addToClosed");
|
||||
if ( mGoal->atGoal(best->coord) )
|
||||
PROFILE_START("AddToClosed");
|
||||
AddToClosed(best);
|
||||
PROFILE_END("AddToClosed");
|
||||
if ( mGoal->IsAtGoal(best->coord) )
|
||||
{
|
||||
/* Path solved */
|
||||
mSolved = true;
|
||||
@ -107,33 +107,33 @@ bool CAStarEngine::findPath(
|
||||
/* Get neighbors of the best node */
|
||||
std::vector<CVector2D> neighbors;
|
||||
PROFILE_START("get neighbors");
|
||||
neighbors = mGoal->getNeighbors(best->coord, entity);
|
||||
neighbors = mGoal->GetNeighbors(best->coord, entity);
|
||||
PROFILE_END("get neighbors");
|
||||
|
||||
/* Update the neighbors of the best node */
|
||||
std::vector<CVector2D>::iterator it;
|
||||
for( it = neighbors.begin(); it != neighbors.end(); it++ )
|
||||
{
|
||||
AStarNode* N = getFreeASNode();
|
||||
AStarNode* N = GetFreeASNode();
|
||||
PROFILE_START("initialize neighbor");
|
||||
N->coord = *it;
|
||||
// Assign f,g,h to neighbor
|
||||
N->g = best->g + mGoal->getTileCost(best->coord, N->coord);
|
||||
N->h = mGoal->distanceToGoal(*it);
|
||||
N->g = best->g + mGoal->GetTileCost(best->coord, N->coord);
|
||||
N->h = mGoal->DistanceToGoal(*it);
|
||||
N->f = N->g + N->h;
|
||||
N->parent = best;
|
||||
PROFILE_END("initialize neighbor");
|
||||
|
||||
AStarNode* C;
|
||||
PROFILE_START("search closed");
|
||||
C = getFromClosed(N->coord);
|
||||
C = GetFromClosed(N->coord);
|
||||
PROFILE_END("search closed");
|
||||
bool update = false;
|
||||
if( C!=NULL && (N->f < C->f) )
|
||||
{
|
||||
PROFILE_START("remove from closed");
|
||||
/* N is on Closed and N->f is better */
|
||||
removeFromClosed(C);
|
||||
RemoveFromClosed(C);
|
||||
update = true;
|
||||
PROFILE_END("remove from closed");
|
||||
}
|
||||
@ -141,7 +141,7 @@ bool CAStarEngine::findPath(
|
||||
{
|
||||
PROFILE_START("add to open");
|
||||
/* N is not on Closed */
|
||||
addToOpen(N);
|
||||
AddToOpen(N);
|
||||
PROFILE_END("add to open");
|
||||
}
|
||||
}
|
||||
@ -150,45 +150,45 @@ bool CAStarEngine::findPath(
|
||||
if (mSolved && best!=NULL)
|
||||
{
|
||||
//debug_printf("Number of nodes searched: %d\n", iterations);
|
||||
constructPath(best);
|
||||
ConstructPath(best);
|
||||
}
|
||||
|
||||
cleanup();
|
||||
Cleanup();
|
||||
|
||||
return mSolved;
|
||||
}
|
||||
|
||||
|
||||
void CAStarEngine::constructPath( AStarNode* end )
|
||||
void CAStarEngine::ConstructPath( AStarNode* end )
|
||||
{
|
||||
std::deque<CVector2D> path;
|
||||
mPath.clear();
|
||||
while( end!=NULL && (end->parent)!=NULL )
|
||||
{
|
||||
path.push_front(mGoal->getCoord(end->coord));
|
||||
path.push_front(mGoal->GetCoord(end->coord));
|
||||
end = end->parent;
|
||||
}
|
||||
mPath.insert(mPath.begin(), path.begin(), path.end());
|
||||
}
|
||||
|
||||
|
||||
std::vector<CVector2D> CAStarEngine::getLastPath()
|
||||
std::vector<CVector2D> CAStarEngine::GetLastPath()
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
|
||||
void CAStarEngine::setSearchLimit( int limit )
|
||||
void CAStarEngine::SetSearchLimit( int limit )
|
||||
{
|
||||
mSearchLimit = limit;
|
||||
}
|
||||
|
||||
|
||||
void CAStarEngine::addToOpen( AStarNode* node )
|
||||
void CAStarEngine::AddToOpen( AStarNode* node )
|
||||
{
|
||||
/* If not in open, should add, otherwise should promote */
|
||||
AStarNodeFlag *flag = GetFlag(node->coord);
|
||||
if (!GetIsOpen(flag))
|
||||
if (!IsOpen(flag))
|
||||
{
|
||||
mOpen.push(node);
|
||||
}
|
||||
@ -200,7 +200,7 @@ void CAStarEngine::addToOpen( AStarNode* node )
|
||||
}
|
||||
|
||||
|
||||
AStarNode* CAStarEngine::removeBestOpenNode()
|
||||
AStarNode* CAStarEngine::RemoveBestOpenNode()
|
||||
{
|
||||
if (mOpen.empty())
|
||||
return NULL;
|
||||
@ -214,23 +214,23 @@ AStarNode* CAStarEngine::removeBestOpenNode()
|
||||
}
|
||||
|
||||
|
||||
void CAStarEngine::addToClosed( AStarNode* node )
|
||||
void CAStarEngine::AddToClosed( AStarNode* node )
|
||||
{
|
||||
mClosed[node->coord] = node;
|
||||
SetClosedFlag(GetFlag(node->coord));
|
||||
}
|
||||
|
||||
|
||||
void CAStarEngine::removeFromClosed( AStarNode* node )
|
||||
void CAStarEngine::RemoveFromClosed( AStarNode* node )
|
||||
{
|
||||
mClosed.erase(node->coord);
|
||||
ClearClosedFlag(GetFlag(node->coord));
|
||||
}
|
||||
|
||||
|
||||
AStarNode* CAStarEngine::getFromClosed( const CVector2D& loc )
|
||||
AStarNode* CAStarEngine::GetFromClosed( const CVector2D& loc )
|
||||
{
|
||||
if (!GetIsClosed(GetFlag(loc)))
|
||||
if (!IsClosed(GetFlag(loc)))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -239,19 +239,19 @@ AStarNode* CAStarEngine::getFromClosed( const CVector2D& loc )
|
||||
}
|
||||
|
||||
|
||||
void CAStarEngine::clearOpen()
|
||||
void CAStarEngine::ClearOpen()
|
||||
{
|
||||
mOpen.clear();
|
||||
}
|
||||
|
||||
|
||||
void CAStarEngine::clearClosed()
|
||||
void CAStarEngine::ClearClosed()
|
||||
{
|
||||
mClosed.clear();
|
||||
}
|
||||
|
||||
|
||||
AStarNode* CAStarEngine::getFreeASNode()
|
||||
AStarNode* CAStarEngine::GetFreeASNode()
|
||||
{
|
||||
AStarNode* ret;
|
||||
PROFILE_START("allocator");
|
||||
@ -271,7 +271,7 @@ AStarNode* CAStarEngine::getFreeASNode()
|
||||
}
|
||||
|
||||
|
||||
void CAStarEngine::cleanup()
|
||||
void CAStarEngine::Cleanup()
|
||||
{
|
||||
std::vector<AStarNode*>::iterator it;
|
||||
for( it = usedNodes.begin(); it != usedNodes.end(); it++)
|
||||
@ -327,40 +327,40 @@ CVector2D WorldspaceToTilespace( const CVector2D &ws )
|
||||
}
|
||||
|
||||
|
||||
void AStarGoalLowLevel::setDestination( const CVector2D &dest )
|
||||
void AStarGoalLowLevel::SetDestination( const CVector2D &dest )
|
||||
{
|
||||
coord = WorldspaceToTilespace(dest);
|
||||
}
|
||||
|
||||
|
||||
void AStarGoalLowLevel::setRadius( float r )
|
||||
void AStarGoalLowLevel::SetRadius( float r )
|
||||
{
|
||||
radius = r;
|
||||
}
|
||||
|
||||
float AStarGoalLowLevel::getRadius()
|
||||
float AStarGoalLowLevel::GetRadius()
|
||||
{
|
||||
return radius;
|
||||
}
|
||||
|
||||
float AStarGoalLowLevel::distanceToGoal( const CVector2D &loc )
|
||||
float AStarGoalLowLevel::DistanceToGoal( const CVector2D &loc )
|
||||
{
|
||||
return ((coord-loc).length());
|
||||
return ((coord-loc).Length());
|
||||
}
|
||||
|
||||
bool AStarGoalLowLevel::atGoal( const CVector2D &loc )
|
||||
bool AStarGoalLowLevel::IsAtGoal( const CVector2D &loc )
|
||||
{
|
||||
float dx = coord.x - loc.x;
|
||||
float dy = coord.y - loc.y;
|
||||
return dx*dx + dy*dy <= radius*radius;
|
||||
}
|
||||
|
||||
float AStarGoalLowLevel::getTileCost( const CVector2D& loc1, const CVector2D& loc2 )
|
||||
float AStarGoalLowLevel::GetTileCost( const CVector2D& loc1, const CVector2D& loc2 )
|
||||
{
|
||||
return (loc2-loc1).length() - radius;
|
||||
return (loc2-loc1).Length() - radius;
|
||||
}
|
||||
|
||||
bool AStarGoalLowLevel::isPassable( const CVector2D &loc, HEntity entity )
|
||||
bool AStarGoalLowLevel::IsPassable( const CVector2D &loc, HEntity entity )
|
||||
{
|
||||
CTerrain* pTerrain = g_Game->GetWorld()->GetTerrain();
|
||||
int size = pTerrain->GetTilesPerSide();
|
||||
@ -370,12 +370,12 @@ bool AStarGoalLowLevel::isPassable( const CVector2D &loc, HEntity entity )
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( pTerrain->isPassable(loc, entity) )
|
||||
if ( pTerrain->IsPassable(loc, entity) )
|
||||
{
|
||||
// If no entity blocking, return true
|
||||
CVector2D wloc = TilespaceToWorldspace(loc);
|
||||
CBoundingBox bounds(wloc.x, wloc.y, 0, CELL_SIZE, CELL_SIZE, 3);
|
||||
if ( getCollisionObject(&bounds, entity->GetPlayer()) == NULL )
|
||||
if ( GetCollisionObject(&bounds, entity->GetPlayer()) == NULL )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -383,17 +383,17 @@ bool AStarGoalLowLevel::isPassable( const CVector2D &loc, HEntity entity )
|
||||
return false;
|
||||
}
|
||||
|
||||
CVector2D AStarGoalLowLevel::getCoord( const CVector2D &loc )
|
||||
CVector2D AStarGoalLowLevel::GetCoord( const CVector2D &loc )
|
||||
{
|
||||
return TilespaceToWorldspace(loc);
|
||||
}
|
||||
|
||||
CVector2D AStarGoalLowLevel::getTile( const CVector2D &loc )
|
||||
CVector2D AStarGoalLowLevel::GetTile( const CVector2D &loc )
|
||||
{
|
||||
return WorldspaceToTilespace(loc);
|
||||
}
|
||||
|
||||
std::vector<CVector2D> AStarGoalLowLevel::getNeighbors( const CVector2D &loc, HEntity entity)
|
||||
std::vector<CVector2D> AStarGoalLowLevel::GetNeighbors( const CVector2D &loc, HEntity entity)
|
||||
{
|
||||
std::vector<CVector2D> vec;
|
||||
|
||||
@ -405,7 +405,7 @@ std::vector<CVector2D> AStarGoalLowLevel::getNeighbors( const CVector2D &loc, HE
|
||||
{
|
||||
CVector2D c = loc;
|
||||
c.x += xdiff; c.y += ydiff;
|
||||
if ( isPassable(c, entity) )
|
||||
if ( IsPassable(c, entity) )
|
||||
{
|
||||
vec.push_back(c);
|
||||
}
|
||||
@ -425,19 +425,19 @@ inline AStarNodeFlag* CAStarEngine::GetFlag(const CVector2D &loc)
|
||||
}
|
||||
|
||||
|
||||
inline bool CAStarEngine::GetIsClear(AStarNodeFlag* flag)
|
||||
inline bool CAStarEngine::IsClear(AStarNodeFlag* flag)
|
||||
{
|
||||
return (*flag)==kClear;
|
||||
}
|
||||
|
||||
|
||||
inline bool CAStarEngine::GetIsClosed(AStarNodeFlag* flag)
|
||||
inline bool CAStarEngine::IsClosed(AStarNodeFlag* flag)
|
||||
{
|
||||
return ((*flag) & kClosed) != kClear;
|
||||
}
|
||||
|
||||
|
||||
inline bool CAStarEngine::GetIsOpen(AStarNodeFlag* flag)
|
||||
inline bool CAStarEngine::IsOpen(AStarNodeFlag* flag)
|
||||
{
|
||||
return ((*flag) & kOpen) != kClear;
|
||||
}
|
||||
@ -467,13 +467,13 @@ inline void CAStarEngine::ClearOpenFlag(AStarNodeFlag* flag)
|
||||
}
|
||||
|
||||
|
||||
inline bool CAStarEngine::GetIsPassable(AStarNodeFlag* flag)
|
||||
inline bool CAStarEngine::IsPassable(AStarNodeFlag* flag)
|
||||
{
|
||||
return ((*flag) & kPassable) != kClear;
|
||||
}
|
||||
|
||||
|
||||
inline bool CAStarEngine::GetIsBlocked(AStarNodeFlag* flag)
|
||||
inline bool CAStarEngine::IsBlocked(AStarNodeFlag* flag)
|
||||
{
|
||||
return ((*flag) & kBlocked) != kClear;
|
||||
}
|
||||
|
@ -61,13 +61,13 @@ public:
|
||||
CAStarEngine(AStarGoalBase* goal);
|
||||
virtual ~CAStarEngine();
|
||||
|
||||
void setGoal(AStarGoalBase* goal) { mGoal = goal; }
|
||||
void SetGoal(AStarGoalBase* goal) { mGoal = goal; }
|
||||
|
||||
bool findPath( const CVector2D& src, const CVector2D& dest, HEntity entity, float radius=0.0f );
|
||||
std::vector<CVector2D> getLastPath();
|
||||
bool FindPath( const CVector2D& src, const CVector2D& dest, HEntity entity, float radius=0.0f );
|
||||
std::vector<CVector2D> GetLastPath();
|
||||
|
||||
// The maximum number of nodes that will be expanded before failure is declared
|
||||
void setSearchLimit( int limit );
|
||||
void SetSearchLimit( int limit );
|
||||
|
||||
protected:
|
||||
AStarGoalBase* mGoal;
|
||||
@ -84,32 +84,32 @@ private:
|
||||
std::vector<AStarNode*> freeNodes;
|
||||
std::vector<AStarNode*> usedNodes;
|
||||
|
||||
// addToOpen will promote if the node already is in Open
|
||||
void addToOpen( AStarNode* );
|
||||
AStarNode* removeBestOpenNode();
|
||||
// AddToOpen will promote if the node already is in Open
|
||||
void AddToOpen( AStarNode* );
|
||||
AStarNode* RemoveBestOpenNode();
|
||||
|
||||
void addToClosed( AStarNode* );
|
||||
void removeFromClosed( AStarNode* );
|
||||
AStarNode* getFromClosed( const CVector2D& );
|
||||
void AddToClosed( AStarNode* );
|
||||
void RemoveFromClosed( AStarNode* );
|
||||
AStarNode* GetFromClosed( const CVector2D& );
|
||||
|
||||
void clearOpen();
|
||||
void clearClosed();
|
||||
void ClearOpen();
|
||||
void ClearClosed();
|
||||
|
||||
void constructPath( AStarNode* );
|
||||
void ConstructPath( AStarNode* );
|
||||
|
||||
AStarNode* getFreeASNode();
|
||||
void cleanup();
|
||||
AStarNode* GetFreeASNode();
|
||||
void Cleanup();
|
||||
|
||||
inline AStarNodeFlag* GetFlag(const CVector2D&);
|
||||
inline bool GetIsClear(AStarNodeFlag*);
|
||||
inline bool GetIsClosed(AStarNodeFlag*);
|
||||
inline bool GetIsOpen(AStarNodeFlag*);
|
||||
inline bool IsClear(AStarNodeFlag*);
|
||||
inline bool IsClosed(AStarNodeFlag*);
|
||||
inline bool IsOpen(AStarNodeFlag*);
|
||||
inline void SetClosedFlag(AStarNodeFlag*);
|
||||
inline void ClearClosedFlag(AStarNodeFlag*);
|
||||
inline void SetOpenFlag(AStarNodeFlag*);
|
||||
inline void ClearOpenFlag(AStarNodeFlag*);
|
||||
inline bool GetIsPassable(AStarNodeFlag*);
|
||||
inline bool GetIsBlocked(AStarNodeFlag*);
|
||||
inline bool IsPassable(AStarNodeFlag*);
|
||||
inline bool IsBlocked(AStarNodeFlag*);
|
||||
inline void SetPassableFlag(AStarNodeFlag*);
|
||||
inline void SetBlockedFlag(AStarNodeFlag*);
|
||||
|
||||
@ -126,32 +126,32 @@ class AStarGoalBase
|
||||
{
|
||||
public:
|
||||
AStarGoalBase() {}
|
||||
virtual void setDestination( const CVector2D& ) = 0;
|
||||
virtual void setRadius( float r ) = 0;
|
||||
virtual float distanceToGoal( const CVector2D& ) = 0;
|
||||
virtual bool atGoal( const CVector2D& ) = 0;
|
||||
virtual float getTileCost( const CVector2D&, const CVector2D& ) = 0;
|
||||
virtual bool isPassable( const CVector2D&, HEntity entity) = 0;
|
||||
virtual std::vector<CVector2D> getNeighbors( const CVector2D&, HEntity entity) = 0;
|
||||
virtual CVector2D getCoord( const CVector2D& ) = 0;
|
||||
virtual CVector2D getTile( const CVector2D& ) = 0;
|
||||
virtual float getRadius() = 0;
|
||||
virtual void SetDestination( const CVector2D& ) = 0;
|
||||
virtual void SetRadius( float r ) = 0;
|
||||
virtual float DistanceToGoal( const CVector2D& ) = 0;
|
||||
virtual bool IsAtGoal( const CVector2D& ) = 0;
|
||||
virtual float GetTileCost( const CVector2D&, const CVector2D& ) = 0;
|
||||
virtual bool IsPassable( const CVector2D&, HEntity entity) = 0;
|
||||
virtual std::vector<CVector2D> GetNeighbors( const CVector2D&, HEntity entity) = 0;
|
||||
virtual CVector2D GetCoord( const CVector2D& ) = 0;
|
||||
virtual CVector2D GetTile( const CVector2D& ) = 0;
|
||||
virtual float GetRadius() = 0;
|
||||
};
|
||||
|
||||
class AStarGoalLowLevel : public AStarGoalBase
|
||||
{
|
||||
public:
|
||||
AStarGoalLowLevel(): radius(0.0f) {}
|
||||
void setDestination( const CVector2D& dest );
|
||||
void setRadius( float r );
|
||||
float distanceToGoal( const CVector2D& loc );
|
||||
bool atGoal( const CVector2D& loc );
|
||||
float getTileCost( const CVector2D& loc1, const CVector2D& loc2 );
|
||||
bool isPassable( const CVector2D& loc, HEntity entity);
|
||||
std::vector<CVector2D> getNeighbors( const CVector2D& loc, HEntity entity);
|
||||
CVector2D getCoord( const CVector2D& loc);
|
||||
CVector2D getTile( const CVector2D& loc);
|
||||
float getRadius();
|
||||
void SetDestination( const CVector2D& dest );
|
||||
void SetRadius( float r );
|
||||
float DistanceToGoal( const CVector2D& loc );
|
||||
bool IsAtGoal( const CVector2D& loc );
|
||||
float GetTileCost( const CVector2D& loc1, const CVector2D& loc2 );
|
||||
bool IsPassable( const CVector2D& loc, HEntity entity);
|
||||
std::vector<CVector2D> GetNeighbors( const CVector2D& loc, HEntity entity);
|
||||
CVector2D GetCoord( const CVector2D& loc);
|
||||
CVector2D GetTile( const CVector2D& loc);
|
||||
float GetRadius();
|
||||
private:
|
||||
CVector2D coord;
|
||||
float radius;
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "lib/ogl.h"
|
||||
#include "maths/MathUtil.h"
|
||||
|
||||
bool CBoundingObject::intersects( CBoundingObject* obj )
|
||||
bool CBoundingObject::Intersects( CBoundingObject* obj )
|
||||
{
|
||||
CVector2D delta = m_pos - obj->m_pos;
|
||||
|
||||
@ -13,28 +13,28 @@ bool CBoundingObject::intersects( CBoundingObject* obj )
|
||||
|
||||
if( obj->m_type > m_type ) // More complex types get the burden of processing.
|
||||
{
|
||||
return( obj->_intersects( this, delta ) );
|
||||
return( obj->LooselyIntersects( this, delta ) );
|
||||
}
|
||||
else
|
||||
return( _intersects( obj, delta ) );
|
||||
return( LooselyIntersects( obj, delta ) );
|
||||
}
|
||||
|
||||
bool CBoundingObject::contains( const CVector2D& point )
|
||||
bool CBoundingObject::Contains( const CVector2D& point )
|
||||
{
|
||||
CVector2D delta = m_pos - point;
|
||||
|
||||
if( !delta.within( m_radius ) )
|
||||
return( false );
|
||||
|
||||
return( _contains( point, delta ) );
|
||||
return( LooselyContains( point, delta ) );
|
||||
}
|
||||
|
||||
void CBoundingObject::setPosition( float x, float y )
|
||||
void CBoundingObject::SetPosition( float x, float y )
|
||||
{
|
||||
m_pos.x = x; m_pos.y = y;
|
||||
}
|
||||
|
||||
void CBoundingObject::setHeight( float height )
|
||||
void CBoundingObject::SetHeight( float height )
|
||||
{
|
||||
m_height = height;
|
||||
}
|
||||
@ -42,25 +42,25 @@ void CBoundingObject::setHeight( float height )
|
||||
CBoundingCircle::CBoundingCircle( float x, float y, float radius, float height )
|
||||
{
|
||||
m_type = BOUND_CIRCLE;
|
||||
setPosition( x, y );
|
||||
setRadius( radius );
|
||||
setHeight( height );
|
||||
SetPosition( x, y );
|
||||
SetRadius( radius );
|
||||
SetHeight( height );
|
||||
}
|
||||
|
||||
CBoundingCircle::CBoundingCircle( float x, float y, CBoundingCircle* copy )
|
||||
{
|
||||
m_type = BOUND_CIRCLE;
|
||||
setPosition( x, y );
|
||||
setRadius( copy->m_radius );
|
||||
setHeight( copy->m_height );
|
||||
SetPosition( x, y );
|
||||
SetRadius( copy->m_radius );
|
||||
SetHeight( copy->m_height );
|
||||
}
|
||||
|
||||
void CBoundingCircle::setRadius( float radius )
|
||||
void CBoundingCircle::SetRadius( float radius )
|
||||
{
|
||||
m_radius = radius;
|
||||
}
|
||||
|
||||
bool CBoundingCircle::_intersects( CBoundingObject* obj, const CVector2D& UNUSED(delta) )
|
||||
bool CBoundingCircle::LooselyIntersects( CBoundingObject* obj, const CVector2D& UNUSED(delta) )
|
||||
{
|
||||
debug_assert( obj->m_type == BOUND_CIRCLE );
|
||||
// Easy enough. The only time this gets called is a circle-circle collision,
|
||||
@ -68,12 +68,12 @@ bool CBoundingCircle::_intersects( CBoundingObject* obj, const CVector2D& UNUSED
|
||||
return( true );
|
||||
}
|
||||
|
||||
bool CBoundingCircle::_contains( const CVector2D& UNUSED(point), const CVector2D& UNUSED(delta) )
|
||||
bool CBoundingCircle::LooselyContains( const CVector2D& UNUSED(point), const CVector2D& UNUSED(delta) )
|
||||
{
|
||||
return( true );
|
||||
}
|
||||
|
||||
void CBoundingCircle::render( float height )
|
||||
void CBoundingCircle::Render( float height )
|
||||
{
|
||||
glBegin( GL_LINE_LOOP );
|
||||
|
||||
@ -91,47 +91,47 @@ void CBoundingCircle::render( float height )
|
||||
CBoundingBox::CBoundingBox( float x, float y, const CVector2D& u, float width, float depth, float height )
|
||||
{
|
||||
m_type = BOUND_OABB;
|
||||
setPosition( x, y );
|
||||
setDimensions( width, depth );
|
||||
setHeight( height );
|
||||
setOrientation( u );
|
||||
SetPosition( x, y );
|
||||
SetDimensions( width, depth );
|
||||
SetHeight( height );
|
||||
SetOrientation( u );
|
||||
}
|
||||
|
||||
CBoundingBox::CBoundingBox( float x, float y, const CVector2D& u, CBoundingBox* copy )
|
||||
{
|
||||
m_type = BOUND_OABB;
|
||||
setPosition( x, y );
|
||||
setDimensions( copy->getWidth(), copy->getDepth() );
|
||||
setHeight( copy->m_height );
|
||||
setOrientation( u );
|
||||
SetPosition( x, y );
|
||||
SetDimensions( copy->GetWidth(), copy->GetDepth() );
|
||||
SetHeight( copy->m_height );
|
||||
SetOrientation( u );
|
||||
}
|
||||
|
||||
CBoundingBox::CBoundingBox( float x, float y, float orientation, float width, float depth, float height )
|
||||
{
|
||||
m_type = BOUND_OABB;
|
||||
setPosition( x, y );
|
||||
setDimensions( width, depth );
|
||||
setHeight( height );
|
||||
setOrientation( orientation );
|
||||
SetPosition( x, y );
|
||||
SetDimensions( width, depth );
|
||||
SetHeight( height );
|
||||
SetOrientation( orientation );
|
||||
}
|
||||
|
||||
CBoundingBox::CBoundingBox( float x, float y, float orientation, CBoundingBox* copy )
|
||||
{
|
||||
m_type = BOUND_OABB;
|
||||
setPosition( x, y );
|
||||
setDimensions( copy->getWidth(), copy->getDepth() );
|
||||
setHeight( copy->m_height );
|
||||
setOrientation( orientation );
|
||||
SetPosition( x, y );
|
||||
SetDimensions( copy->GetWidth(), copy->GetDepth() );
|
||||
SetHeight( copy->m_height );
|
||||
SetOrientation( orientation );
|
||||
}
|
||||
|
||||
void CBoundingBox::setDimensions( float width, float depth )
|
||||
void CBoundingBox::SetDimensions( float width, float depth )
|
||||
{
|
||||
m_w = width / 2.0f;
|
||||
m_d = depth / 2.0f;
|
||||
m_radius = sqrt( ( m_w * m_w ) + ( m_d * m_d ) );
|
||||
}
|
||||
|
||||
void CBoundingBox::setOrientation( float orientation )
|
||||
void CBoundingBox::SetOrientation( float orientation )
|
||||
{
|
||||
m_u.x = sin( orientation );
|
||||
m_u.y = cos( orientation );
|
||||
@ -139,23 +139,23 @@ void CBoundingBox::setOrientation( float orientation )
|
||||
m_v.y = -m_u.x;
|
||||
}
|
||||
|
||||
void CBoundingBox::setOrientation( const CVector2D& u )
|
||||
void CBoundingBox::SetOrientation( const CVector2D& u )
|
||||
{
|
||||
m_u = u;
|
||||
m_v.x = m_u.y;
|
||||
m_v.y = -m_u.x;
|
||||
}
|
||||
|
||||
bool CBoundingBox::_intersects( CBoundingObject* obj, const CVector2D& delta )
|
||||
bool CBoundingBox::LooselyIntersects( CBoundingObject* obj, const CVector2D& delta )
|
||||
{
|
||||
if( obj->m_type == BOUND_CIRCLE )
|
||||
{
|
||||
// Imperfect but quick...
|
||||
|
||||
CBoundingCircle* c = (CBoundingCircle*)obj;
|
||||
float deltad = fabs( delta.dot( m_u ) );
|
||||
float deltad = fabs( delta.Dot( m_u ) );
|
||||
if( deltad > ( m_d + c->m_radius ) ) return( false );
|
||||
float deltaw = fabs( delta.dot( m_v ) );
|
||||
float deltaw = fabs( delta.Dot( m_v ) );
|
||||
if( deltaw > ( m_w + c->m_radius ) ) return( false );
|
||||
return( true );
|
||||
}
|
||||
@ -183,16 +183,16 @@ bool CBoundingBox::_intersects( CBoundingObject* obj, const CVector2D& delta )
|
||||
// Note that a trivial-rejection test has already taken place by this point.
|
||||
|
||||
float uv, vu, uu, vv, prj1, prj2, dm;
|
||||
uv = m_u.dot( b->m_v );
|
||||
vu = m_v.dot( b->m_u );
|
||||
uu = m_u.dot( b->m_u );
|
||||
vv = m_v.dot( b->m_v );
|
||||
uv = m_u.Dot( b->m_v );
|
||||
vu = m_v.Dot( b->m_u );
|
||||
uu = m_u.Dot( b->m_u );
|
||||
vv = m_v.Dot( b->m_v );
|
||||
|
||||
// Project box 2 onto v-axis of box 1
|
||||
|
||||
prj1 = fabs( vu * b->m_d + vv * b->m_w );
|
||||
prj2 = fabs( vu * b->m_d - vv * b->m_w );
|
||||
dm = delta.dot( m_v );
|
||||
dm = delta.Dot( m_v );
|
||||
|
||||
if( prj1 > prj2 )
|
||||
{
|
||||
@ -205,7 +205,7 @@ bool CBoundingBox::_intersects( CBoundingObject* obj, const CVector2D& delta )
|
||||
|
||||
prj1 = fabs( uu * b->m_d + uv * b->m_w );
|
||||
prj2 = fabs( uu * b->m_d - uv * b->m_w );
|
||||
dm = delta.dot( m_u );
|
||||
dm = delta.Dot( m_u );
|
||||
|
||||
if( prj1 > prj2 )
|
||||
{
|
||||
@ -218,7 +218,7 @@ bool CBoundingBox::_intersects( CBoundingObject* obj, const CVector2D& delta )
|
||||
|
||||
prj1 = fabs( uv * m_d + vv * m_w );
|
||||
prj2 = fabs( uv * m_d - vv * m_w );
|
||||
dm = delta.dot( b->m_v );
|
||||
dm = delta.Dot( b->m_v );
|
||||
|
||||
if( prj1 > prj2 )
|
||||
{
|
||||
@ -231,7 +231,7 @@ bool CBoundingBox::_intersects( CBoundingObject* obj, const CVector2D& delta )
|
||||
|
||||
prj1 = fabs( uu * m_d + vu * m_w );
|
||||
prj2 = fabs( uu * m_d - vu * m_w );
|
||||
dm = delta.dot( b->m_u );
|
||||
dm = delta.Dot( b->m_u );
|
||||
|
||||
if( prj1 > prj2 )
|
||||
{
|
||||
@ -245,16 +245,16 @@ bool CBoundingBox::_intersects( CBoundingObject* obj, const CVector2D& delta )
|
||||
}
|
||||
}
|
||||
|
||||
bool CBoundingBox::_contains( const CVector2D& UNUSED(point), const CVector2D& delta )
|
||||
bool CBoundingBox::LooselyContains( const CVector2D& UNUSED(point), const CVector2D& delta )
|
||||
{
|
||||
float deltad = fabs( delta.dot( m_u ) );
|
||||
float deltad = fabs( delta.Dot( m_u ) );
|
||||
if( deltad > m_d ) return( false );
|
||||
float deltaw = fabs( delta.dot( m_v ) );
|
||||
float deltaw = fabs( delta.Dot( m_v ) );
|
||||
if( deltaw > m_w ) return( false );
|
||||
return( true );
|
||||
}
|
||||
|
||||
void CBoundingBox::render( float height )
|
||||
void CBoundingBox::Render( float height )
|
||||
{
|
||||
glBegin( GL_LINE_LOOP );
|
||||
|
||||
|
@ -29,13 +29,13 @@ public:
|
||||
float m_radius;
|
||||
float m_height;
|
||||
|
||||
void setPosition( float x, float y );
|
||||
void setHeight( float height );
|
||||
bool intersects( CBoundingObject* obj );
|
||||
bool contains( const CVector2D& point );
|
||||
virtual bool _intersects( CBoundingObject* obj, const CVector2D& delta ) = 0;
|
||||
virtual bool _contains( const CVector2D& point, const CVector2D& delta ) = 0;
|
||||
virtual void render( float height ) = 0; // Temporary
|
||||
void SetPosition( float x, float y );
|
||||
void SetHeight( float height );
|
||||
bool Intersects( CBoundingObject* obj );
|
||||
bool Contains( const CVector2D& point );
|
||||
virtual bool LooselyIntersects( CBoundingObject* obj, const CVector2D& delta ) = 0;
|
||||
virtual bool LooselyContains( const CVector2D& point, const CVector2D& delta ) = 0;
|
||||
virtual void Render( float height ) = 0; // Temporary
|
||||
};
|
||||
|
||||
class CBoundingCircle : public CBoundingObject
|
||||
@ -44,10 +44,10 @@ public:
|
||||
CBoundingCircle() { m_type = BOUND_OABB; }
|
||||
CBoundingCircle( float x, float y, float radius, float height );
|
||||
CBoundingCircle( float x, float y, CBoundingCircle* copy );
|
||||
void setRadius( float radius );
|
||||
bool _intersects( CBoundingObject* obj, const CVector2D& delta );
|
||||
bool _contains( const CVector2D& point, const CVector2D& delta );
|
||||
void render( float height ); // Temporary
|
||||
void SetRadius( float radius );
|
||||
bool LooselyIntersects( CBoundingObject* obj, const CVector2D& delta );
|
||||
bool LooselyContains( const CVector2D& point, const CVector2D& delta );
|
||||
void Render( float height ); // Temporary
|
||||
};
|
||||
|
||||
class CBoundingBox : public CBoundingObject
|
||||
@ -62,14 +62,14 @@ public:
|
||||
CBoundingBox( float x, float y, const CVector2D& orientation, float width, float depth, float height );
|
||||
CBoundingBox( float x, float y, float orientation, CBoundingBox* copy );
|
||||
CBoundingBox( float x, float y, const CVector2D& orientation, CBoundingBox* copy );
|
||||
void setDimensions( float width, float depth );
|
||||
void setOrientation( float orientation );
|
||||
void setOrientation( const CVector2D& orientation );
|
||||
float getWidth() const { return( 2.0f * m_w ); };
|
||||
float getDepth() const { return( 2.0f * m_d ); };
|
||||
bool _intersects( CBoundingObject* obj, const CVector2D& delta );
|
||||
bool _contains( const CVector2D& point, const CVector2D& delta );
|
||||
void render( float height ); // Temporary
|
||||
void SetDimensions( float width, float depth );
|
||||
void SetOrientation( float orientation );
|
||||
void SetOrientation( const CVector2D& orientation );
|
||||
float GetWidth() const { return( 2.0f * m_w ); };
|
||||
float GetDepth() const { return( 2.0f * m_d ); };
|
||||
bool LooselyIntersects( CBoundingObject* obj, const CVector2D& delta );
|
||||
bool LooselyContains( const CVector2D& point, const CVector2D& delta );
|
||||
void Render( float height ); // Temporary
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include <float.h>
|
||||
|
||||
CBoundingObject* getContainingObject( const CVector2D& point )
|
||||
CBoundingObject* GetContainingObject( const CVector2D& point )
|
||||
{
|
||||
std::vector<CEntity*> entities;
|
||||
g_EntityManager.GetInRange( point.x, point.y, COLLISION_RANGE, entities );
|
||||
@ -16,7 +16,7 @@ CBoundingObject* getContainingObject( const CVector2D& point )
|
||||
for( it = entities.begin(); it != entities.end(); it++ )
|
||||
{
|
||||
if( !(*it)->m_bounds ) continue;
|
||||
if( (*it)->m_bounds->contains( point ) )
|
||||
if( (*it)->m_bounds->Contains( point ) )
|
||||
{
|
||||
CBoundingObject* bounds = (*it)->m_bounds;
|
||||
return( bounds );
|
||||
@ -37,7 +37,7 @@ CEntity* GetCollisionObject( float x, float y )
|
||||
for( it = entities.begin(); it != entities.end(); it++ )
|
||||
{
|
||||
if( !(*it)->m_bounds ) continue;
|
||||
if( (*it)->m_bounds->contains( point ) )
|
||||
if( (*it)->m_bounds->Contains( point ) )
|
||||
{
|
||||
CEntity* e = (*it);
|
||||
return( e );
|
||||
@ -47,7 +47,7 @@ CEntity* GetCollisionObject( float x, float y )
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
CBoundingObject* getCollisionObject( CBoundingObject* bounds, CPlayer* player, const CStrW* ignoreClass )
|
||||
CBoundingObject* GetCollisionObject( CBoundingObject* bounds, CPlayer* player, const CStrW* ignoreClass )
|
||||
{
|
||||
std::vector<CEntity*> entities;
|
||||
g_EntityManager.GetInRange( bounds->m_pos.x, bounds->m_pos.y, COLLISION_RANGE, entities );
|
||||
@ -64,7 +64,7 @@ CBoundingObject* getCollisionObject( CBoundingObject* bounds, CPlayer* player, c
|
||||
|
||||
if( ignoreClass && (*it)->m_classes.IsMember( *ignoreClass ) ) continue;
|
||||
|
||||
if( bounds->intersects( (*it)->m_bounds ) )
|
||||
if( bounds->Intersects( (*it)->m_bounds ) )
|
||||
{
|
||||
CBoundingObject* obj = (*it)->m_bounds;
|
||||
return( obj );
|
||||
@ -74,7 +74,7 @@ CBoundingObject* getCollisionObject( CBoundingObject* bounds, CPlayer* player, c
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
CEntity* getCollisionEntity( CBoundingObject* bounds, CPlayer* player, const CStrW* ignoreClass )
|
||||
CEntity* GetCollisionEntity( CBoundingObject* bounds, CPlayer* player, const CStrW* ignoreClass )
|
||||
{
|
||||
std::vector<CEntity*> entities;
|
||||
g_EntityManager.GetInRange( bounds->m_pos.x, bounds->m_pos.y, COLLISION_RANGE, entities );
|
||||
@ -91,7 +91,7 @@ CEntity* getCollisionEntity( CBoundingObject* bounds, CPlayer* player, const CSt
|
||||
|
||||
if( ignoreClass && (*it)->m_classes.IsMember( *ignoreClass ) ) continue;
|
||||
|
||||
if( bounds->intersects( (*it)->m_bounds ) )
|
||||
if( bounds->Intersects( (*it)->m_bounds ) )
|
||||
{
|
||||
return (*it);
|
||||
}
|
||||
@ -100,7 +100,7 @@ CEntity* getCollisionEntity( CBoundingObject* bounds, CPlayer* player, const CSt
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
HEntity getCollisionObject( CEntity* entity, bool enablePassThroughAllies )
|
||||
HEntity GetCollisionObject( CEntity* entity, bool enablePassThroughAllies )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
debug_assert( entity->m_bounds );
|
||||
@ -123,7 +123,7 @@ HEntity getCollisionObject( CEntity* entity, bool enablePassThroughAllies )
|
||||
&& entity->GetPlayer() == (*it)->GetPlayer() )
|
||||
continue;
|
||||
|
||||
if( entity->m_bounds->intersects( (*it)->m_bounds ) )
|
||||
if( entity->m_bounds->Intersects( (*it)->m_bounds ) )
|
||||
{
|
||||
HEntity collisionObject = HEntity((*it)->me);
|
||||
return( collisionObject );
|
||||
@ -133,17 +133,17 @@ HEntity getCollisionObject( CEntity* entity, bool enablePassThroughAllies )
|
||||
return HEntity();
|
||||
}
|
||||
|
||||
HEntity getCollisionObject( CEntity* entity, float x, float y )
|
||||
HEntity GetCollisionObject( CEntity* entity, float x, float y )
|
||||
{
|
||||
float _x = entity->m_bounds->m_pos.x;
|
||||
float _y = entity->m_bounds->m_pos.y;
|
||||
entity->m_bounds->setPosition( x, y );
|
||||
HEntity _e = getCollisionObject( entity );
|
||||
entity->m_bounds->setPosition( _x, _y );
|
||||
entity->m_bounds->SetPosition( x, y );
|
||||
HEntity _e = GetCollisionObject( entity );
|
||||
entity->m_bounds->SetPosition( _x, _y );
|
||||
return( _e );
|
||||
}
|
||||
|
||||
bool getRayIntersection( const CVector2D& source, const CVector2D& forward, const CVector2D& right, float length, float maxDistance, CBoundingObject* destinationCollisionObject, rayIntersectionResults* results )
|
||||
bool GetRayIntersection( const CVector2D& source, const CVector2D& forward, const CVector2D& right, float length, float maxDistance, CBoundingObject* destinationCollisionObject, rayIntersectionResults* results )
|
||||
{
|
||||
std::vector<CEntity*> entities;
|
||||
g_EntityManager.GetExtant( entities );
|
||||
@ -167,8 +167,8 @@ bool getRayIntersection( const CVector2D& source, const CVector2D& forward, cons
|
||||
|
||||
CBoundingObject* obj = (*it)->m_bounds;
|
||||
delta = obj->m_pos - source;
|
||||
closestApproach = delta.dot( right );
|
||||
dist = delta.dot( forward );
|
||||
closestApproach = delta.Dot( right );
|
||||
dist = delta.Dot( forward );
|
||||
float collisionRadius = maxDistance + obj->m_radius;
|
||||
|
||||
if( ( fabs( closestApproach ) < collisionRadius ) && ( dist > collisionRadius * 0.0f ) && ( dist < length - collisionRadius * 0.0f ) )
|
||||
@ -206,7 +206,7 @@ void GetProjectileIntersection( const CVector2D& position, const CVector2D& axis
|
||||
closestApproach = delta.betadot( axis );
|
||||
if( fabs( closestApproach ) > obj->m_radius )
|
||||
continue; // Safe, doesn't get close enough.
|
||||
dist = delta.dot( axis );
|
||||
dist = delta.Dot( axis );
|
||||
// I just want to see if this will work before I simplify the maths
|
||||
l = sqrt( obj->m_radius * obj->m_radius - closestApproach * closestApproach );
|
||||
if( dist > 0 )
|
||||
|
@ -4,10 +4,10 @@
|
||||
//
|
||||
// Collision detection functions
|
||||
//
|
||||
// Usage: Fairly trivial; getCollisionObject( CEntity* entity ) will return the first entity colliding with the given entity.
|
||||
// Usage: Fairly trivial; GetCollisionObject( CEntity* entity ) will return the first entity colliding with the given entity.
|
||||
// The version with (x, y) parameters is just a helper; it temporarily moves the entity's collision bounds to the given
|
||||
// position before transferring to the other function.
|
||||
// Notes: getCollisionObject will only return the /first/ entity it finds in collision. This /may/ need a rethink when
|
||||
// Notes: GetCollisionObject will only return the /first/ entity it finds in collision. This /may/ need a rethink when
|
||||
// multiple-entity (pileup) collisions become possible, I don't know.
|
||||
//
|
||||
// Mark Thompson mot20@cam.ac.uk / mark@wildfiregames.com
|
||||
@ -37,13 +37,13 @@ struct rayIntersectionResults
|
||||
|
||||
typedef std::vector<CEntity*> RayIntersects;
|
||||
|
||||
HEntity getCollisionObject( CEntity* entity, bool enablePassThroughAllies=true );
|
||||
HEntity getCollisionObject( CEntity* entity, float x, float y );
|
||||
CBoundingObject* getCollisionObject( CBoundingObject* bounds, CPlayer* player=0, const CStrW* ignoreClass=0 );
|
||||
CEntity* getCollisionEntity( CBoundingObject* bounds, CPlayer* player=0, const CStrW* ignoreClass=0 );
|
||||
CBoundingObject* getContainingObject( const CVector2D& point );
|
||||
HEntity GetCollisionObject( CEntity* entity, bool enablePassThroughAllies=true );
|
||||
HEntity GetCollisionObject( CEntity* entity, float x, float y );
|
||||
CBoundingObject* GetCollisionObject( CBoundingObject* bounds, CPlayer* player=0, const CStrW* ignoreClass=0 );
|
||||
CEntity* GetCollisionEntity( CBoundingObject* bounds, CPlayer* player=0, const CStrW* ignoreClass=0 );
|
||||
CBoundingObject* GetContainingObject( const CVector2D& point );
|
||||
CEntity* GetCollisionObject( float x, float y ); // Point collision
|
||||
bool getRayIntersection( const CVector2D& source, const CVector2D& forward, const CVector2D& right, float length, float maxDistance, CBoundingObject* destinationCollisionObject, rayIntersectionResults* results );
|
||||
bool GetRayIntersection( const CVector2D& source, const CVector2D& forward, const CVector2D& right, float length, float maxDistance, CBoundingObject* destinationCollisionObject, rayIntersectionResults* results );
|
||||
// Assumes zero width, also includes moving units (other one doesn't).
|
||||
void GetProjectileIntersection( const CVector2D& position, const CVector2D& axis, float length, RayIntersects& results );
|
||||
// Stores results in shared area
|
||||
|
@ -71,10 +71,10 @@ CEntity::CEntity( CEntityTemplate* base, CVector3D position, float orientation,
|
||||
m_base = base;
|
||||
|
||||
m_actorSelections = actorSelections;
|
||||
loadBase();
|
||||
LoadBase();
|
||||
|
||||
if( m_bounds )
|
||||
m_bounds->setPosition( m_position.X, m_position.Z );
|
||||
m_bounds->SetPosition( m_position.X, m_position.Z );
|
||||
|
||||
m_graphics_position = m_position;
|
||||
m_graphics_orientation = m_orientation;
|
||||
@ -147,7 +147,7 @@ CEntity::~CEntity()
|
||||
g_FormationManager.RemoveUnit(remove);
|
||||
}
|
||||
|
||||
void CEntity::loadBase()
|
||||
void CEntity::LoadBase()
|
||||
{
|
||||
int previous_unit_id = -1;
|
||||
|
||||
@ -222,7 +222,7 @@ void CEntity::initAuraData()
|
||||
}
|
||||
}
|
||||
|
||||
void CEntity::kill(bool keepActor)
|
||||
void CEntity::Kill(bool keepActor)
|
||||
{
|
||||
if( entf_get( ENTF_DESTROYED ) )
|
||||
{
|
||||
@ -246,21 +246,21 @@ void CEntity::kill(bool keepActor)
|
||||
|
||||
ExitAuras();
|
||||
|
||||
clearOrders();
|
||||
ClearOrders();
|
||||
|
||||
SAFE_DELETE(m_bounds);
|
||||
|
||||
m_extant = false;
|
||||
|
||||
updateCollisionPatch();
|
||||
UpdateCollisionPatch();
|
||||
|
||||
g_Selection.removeAll( me );
|
||||
g_Selection.RemoveAll( me );
|
||||
|
||||
entf_set(ENTF_DESTROYED);
|
||||
g_EntityManager.m_refd[me.m_handle] = false; // refd must be made false when DESTROYED is set
|
||||
g_EntityManager.SetDeath(true); // remember that a unit died this frame
|
||||
|
||||
g_EntityManager.removeUnitCount(this); //Decrease population
|
||||
g_EntityManager.RemoveUnitCount(this); //Decrease population
|
||||
|
||||
// If we have a death animation and want to keep the actor, play that animation
|
||||
if( keepActor && m_actor &&
|
||||
@ -273,16 +273,16 @@ void CEntity::kill(bool keepActor)
|
||||
m_orientation_smoothed = m_orientation;
|
||||
m_orientation_previous = m_orientation;
|
||||
|
||||
snapToGround();
|
||||
SnapToGround();
|
||||
|
||||
// Conform to the ground
|
||||
CVector2D targetXZ = g_Game->GetWorld()->GetTerrain()->getSlopeAngleFace(this);
|
||||
CVector2D targetXZ = g_Game->GetWorld()->GetTerrain()->GetSlopeAngleFace(this);
|
||||
m_orientation.X = clamp( targetXZ.x, -1.0f, 1.0f );
|
||||
m_orientation.Z = clamp( targetXZ.y, -1.0f, 1.0f );
|
||||
m_orientation_unclamped.x = targetXZ.x;
|
||||
m_orientation_unclamped.y = targetXZ.y;
|
||||
|
||||
updateActorTransforms();
|
||||
UpdateActorTransforms();
|
||||
m_actor_transform_valid = true;
|
||||
|
||||
// Play death animation and keep the actor in the game in a dead state
|
||||
@ -310,7 +310,7 @@ void CEntity::SetPlayer(CPlayer *pPlayer)
|
||||
m_associatedTerritory->owner = pPlayer;
|
||||
}
|
||||
|
||||
void CEntity::updateActorTransforms()
|
||||
void CEntity::UpdateActorTransforms()
|
||||
{
|
||||
CMatrix3D m;
|
||||
CMatrix3D mXZ;
|
||||
@ -331,47 +331,47 @@ void CEntity::updateActorTransforms()
|
||||
m_actor->GetModel()->SetTransform( mXZ );
|
||||
}
|
||||
|
||||
void CEntity::snapToGround()
|
||||
void CEntity::SnapToGround()
|
||||
{
|
||||
m_graphics_position.Y = getAnchorLevel( m_graphics_position.X, m_graphics_position.Z );
|
||||
m_graphics_position.Y = GetAnchorLevel( m_graphics_position.X, m_graphics_position.Z );
|
||||
}
|
||||
|
||||
void CEntity::updateXZOrientation()
|
||||
void CEntity::UpdateXZOrientation()
|
||||
{
|
||||
// Make sure m_ahead is correct
|
||||
m_ahead.x = sin( m_orientation.Y );
|
||||
m_ahead.y = cos( m_orientation.Y );
|
||||
|
||||
CVector2D targetXZ = g_Game->GetWorld()->GetTerrain()->getSlopeAngleFace(this);
|
||||
CVector2D targetXZ = g_Game->GetWorld()->GetTerrain()->GetSlopeAngleFace(this);
|
||||
m_orientation.X = clamp( targetXZ.x, -m_base->m_anchorConformX, m_base->m_anchorConformX );
|
||||
m_orientation.Z = clamp( targetXZ.y, -m_base->m_anchorConformZ, m_base->m_anchorConformZ );
|
||||
m_orientation_unclamped.x = targetXZ.x;
|
||||
m_orientation_unclamped.y = targetXZ.y;
|
||||
}
|
||||
|
||||
jsval CEntity::getClassSet()
|
||||
jsval CEntity::GetClassSet()
|
||||
{
|
||||
CStrW result = m_classes.getMemberList();
|
||||
CStrW result = m_classes.GetMemberList();
|
||||
return( ToJSVal( result ) );
|
||||
}
|
||||
|
||||
void CEntity::setClassSet( jsval value )
|
||||
void CEntity::SetClassSet( jsval value )
|
||||
{
|
||||
CStr memberCmdList = ToPrimitive<CStrW>( value );
|
||||
m_classes.setFromMemberList(memberCmdList);
|
||||
m_classes.SetFromMemberList(memberCmdList);
|
||||
|
||||
rebuildClassSet();
|
||||
RebuildClassSet();
|
||||
}
|
||||
|
||||
void CEntity::rebuildClassSet()
|
||||
void CEntity::RebuildClassSet()
|
||||
{
|
||||
m_classes.Rebuild();
|
||||
InheritorsList::iterator it;
|
||||
for( it = m_Inheritors.begin(); it != m_Inheritors.end(); it++ )
|
||||
(*it)->rebuildClassSet();
|
||||
(*it)->RebuildClassSet();
|
||||
}
|
||||
|
||||
void CEntity::update( size_t timestep )
|
||||
void CEntity::Update( size_t timestep )
|
||||
{
|
||||
if( !m_extant ) return;
|
||||
|
||||
@ -404,7 +404,7 @@ void CEntity::update( size_t timestep )
|
||||
|
||||
PROFILE_END( "aura processing" );
|
||||
|
||||
updateOrders( timestep );
|
||||
UpdateOrders( timestep );
|
||||
|
||||
|
||||
// Calculate smoothed rotation: rotate around Y by at most MAX_ROTATION_RATE per second
|
||||
@ -427,7 +427,7 @@ void CEntity::update( size_t timestep )
|
||||
);
|
||||
}
|
||||
|
||||
void CEntity::updateOrders( size_t timestep )
|
||||
void CEntity::UpdateOrders( size_t timestep )
|
||||
{
|
||||
// The process[...] functions return 'true' if the order at the top of the stack
|
||||
// still needs to be (re-)evaluated; else 'false' to terminate the processing of
|
||||
@ -444,7 +444,7 @@ void CEntity::updateOrders( size_t timestep )
|
||||
{
|
||||
// We are idle. Tell our stance in case it wants us to do something.
|
||||
PROFILE( "unit ai" );
|
||||
m_stance->onIdle();
|
||||
m_stance->OnIdle();
|
||||
}
|
||||
|
||||
while( !m_orderQueue.empty() )
|
||||
@ -489,14 +489,14 @@ void CEntity::updateOrders( size_t timestep )
|
||||
case CEntityOrder::ORDER_GOTO_NOPATHING:
|
||||
case CEntityOrder::ORDER_GOTO_COLLISION:
|
||||
case CEntityOrder::ORDER_GOTO_SMOOTHED:
|
||||
if( processGotoNoPathing( current, timestep ) )
|
||||
if( ProcessGotoNoPathing( current, timestep ) )
|
||||
break;
|
||||
updateCollisionPatch();
|
||||
UpdateCollisionPatch();
|
||||
return;
|
||||
case CEntityOrder::ORDER_GENERIC:
|
||||
if( processGeneric( current, timestep ) )
|
||||
if( ProcessGeneric( current, timestep ) )
|
||||
break;
|
||||
updateCollisionPatch();
|
||||
UpdateCollisionPatch();
|
||||
return;
|
||||
case CEntityOrder::ORDER_START_CONSTRUCTION:
|
||||
{
|
||||
@ -506,34 +506,34 @@ void CEntity::updateOrders( size_t timestep )
|
||||
}
|
||||
break;
|
||||
case CEntityOrder::ORDER_PRODUCE:
|
||||
processProduce( current );
|
||||
ProcessProduce( current );
|
||||
m_orderQueue.pop_front();
|
||||
break;
|
||||
case CEntityOrder::ORDER_GENERIC_NOPATHING:
|
||||
if( processGenericNoPathing( current, timestep ) )
|
||||
if( ProcessGenericNoPathing( current, timestep ) )
|
||||
break;
|
||||
updateCollisionPatch();
|
||||
UpdateCollisionPatch();
|
||||
return;
|
||||
case CEntityOrder::ORDER_GOTO_WAYPOINT:
|
||||
if ( processGotoWaypoint( current, timestep, false ) )
|
||||
if ( ProcessGotoWaypoint( current, timestep, false ) )
|
||||
break;
|
||||
updateCollisionPatch();
|
||||
UpdateCollisionPatch();
|
||||
return;
|
||||
case CEntityOrder::ORDER_GOTO_WAYPOINT_CONTACT:
|
||||
if ( processGotoWaypoint( current, timestep, true ) )
|
||||
if ( ProcessGotoWaypoint( current, timestep, true ) )
|
||||
break;
|
||||
updateCollisionPatch();
|
||||
UpdateCollisionPatch();
|
||||
return;
|
||||
case CEntityOrder::ORDER_GOTO:
|
||||
case CEntityOrder::ORDER_RUN:
|
||||
if( processGoto( current, timestep ) )
|
||||
if( ProcessGoto( current, timestep ) )
|
||||
break;
|
||||
updateCollisionPatch();
|
||||
UpdateCollisionPatch();
|
||||
return;
|
||||
case CEntityOrder::ORDER_PATROL:
|
||||
if( processPatrol( current, timestep ) )
|
||||
if( ProcessPatrol( current, timestep ) )
|
||||
break;
|
||||
updateCollisionPatch();
|
||||
UpdateCollisionPatch();
|
||||
return;
|
||||
case CEntityOrder::ORDER_PATH_END_MARKER:
|
||||
m_orderQueue.pop_front();
|
||||
@ -577,9 +577,9 @@ void CEntity::updateOrders( size_t timestep )
|
||||
}
|
||||
}
|
||||
|
||||
void CEntity::updateCollisionPatch()
|
||||
void CEntity::UpdateCollisionPatch()
|
||||
{
|
||||
std::vector<CEntity*>* newPatch = g_EntityManager.getCollisionPatch( this );
|
||||
std::vector<CEntity*>* newPatch = g_EntityManager.GetCollisionPatch( this );
|
||||
if( newPatch != m_collisionPatch )
|
||||
{
|
||||
if( m_collisionPatch )
|
||||
@ -739,7 +739,7 @@ bool CEntity::Initialize()
|
||||
const std::vector<CTechnology*>& techs = m_player->GetActiveTechs();
|
||||
for( size_t i=0; i<techs.size(); i++ )
|
||||
{
|
||||
techs[i]->apply( this );
|
||||
techs[i]->Apply( this );
|
||||
}
|
||||
|
||||
// Dispatch the initialize script event
|
||||
@ -747,7 +747,7 @@ bool CEntity::Initialize()
|
||||
if( !DispatchEvent( &evt ) )
|
||||
{
|
||||
//debug_printf("start construction failed, killing self\n");
|
||||
kill();
|
||||
Kill();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -755,7 +755,7 @@ bool CEntity::Initialize()
|
||||
{
|
||||
// Stay in Hold stance no matter what the init script wanted us to be
|
||||
m_stanceName = "hold";
|
||||
stanceChanged();
|
||||
StanceChanged();
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -769,7 +769,7 @@ void CEntity::Tick()
|
||||
}
|
||||
*/
|
||||
|
||||
void CEntity::clearOrders()
|
||||
void CEntity::ClearOrders()
|
||||
{
|
||||
if ( m_orderQueue.empty() )
|
||||
return;
|
||||
@ -777,7 +777,7 @@ void CEntity::clearOrders()
|
||||
DispatchEvent(&evt);
|
||||
m_orderQueue.clear();
|
||||
}
|
||||
void CEntity::popOrder()
|
||||
void CEntity::PopOrder()
|
||||
{
|
||||
if ( m_orderQueue.empty() )
|
||||
return;
|
||||
@ -786,7 +786,7 @@ void CEntity::popOrder()
|
||||
|
||||
m_orderQueue.pop_front();
|
||||
}
|
||||
void CEntity::pushOrder( CEntityOrder& order )
|
||||
void CEntity::PushOrder( CEntityOrder& order )
|
||||
{
|
||||
CEventPrepareOrder evt( order.m_target_entity, order.m_type, order.m_action, order.m_produce_name );
|
||||
if( DispatchEvent(&evt) )
|
||||
@ -852,7 +852,7 @@ void CEntity::DispatchFormationEvent( int type )
|
||||
CFormationEvent evt( type );
|
||||
DispatchEvent( &evt );
|
||||
}
|
||||
void CEntity::repath()
|
||||
void CEntity::Repath()
|
||||
{
|
||||
CVector2D destination;
|
||||
CEntityOrder::EOrderSource orderSource = CEntityOrder::SOURCE_PLAYER;
|
||||
@ -869,10 +869,10 @@ void CEntity::repath()
|
||||
orderSource = m_orderQueue.front().m_source;
|
||||
m_orderQueue.pop_front();
|
||||
}
|
||||
g_Pathfinder.requestPath( me, destination, orderSource );
|
||||
g_Pathfinder.RequestPath( me, destination, orderSource );
|
||||
}
|
||||
|
||||
void CEntity::reorient()
|
||||
void CEntity::Reorient()
|
||||
{
|
||||
m_graphics_orientation = m_orientation;
|
||||
m_orientation_previous = m_orientation;
|
||||
@ -881,25 +881,25 @@ void CEntity::reorient()
|
||||
m_ahead.x = sin( m_orientation.Y );
|
||||
m_ahead.y = cos( m_orientation.Y );
|
||||
if( m_bounds->m_type == CBoundingObject::BOUND_OABB )
|
||||
((CBoundingBox*)m_bounds)->setOrientation( m_ahead );
|
||||
updateActorTransforms();
|
||||
((CBoundingBox*)m_bounds)->SetOrientation( m_ahead );
|
||||
UpdateActorTransforms();
|
||||
}
|
||||
|
||||
void CEntity::teleport()
|
||||
void CEntity::Teleport()
|
||||
{
|
||||
m_position_previous = m_position;
|
||||
m_graphics_position = m_position;
|
||||
m_bounds->setPosition( m_position.X, m_position.Z );
|
||||
updateActorTransforms();
|
||||
updateCollisionPatch();
|
||||
m_bounds->SetPosition( m_position.X, m_position.Z );
|
||||
UpdateActorTransforms();
|
||||
UpdateCollisionPatch();
|
||||
|
||||
// TODO: repath breaks things - entities get sent to (0,0) if they're moved in
|
||||
// Atlas. I can't see teleport being used anywhere else important, so
|
||||
// TODO: Repath breaks things - entities get sent to (0,0) if they're moved in
|
||||
// Atlas. I can't see Teleport being used anywhere else important, so
|
||||
// hopefully it won't hurt to just remove it for now...
|
||||
// repath();
|
||||
// Repath();
|
||||
}
|
||||
|
||||
void CEntity::stanceChanged()
|
||||
void CEntity::StanceChanged()
|
||||
{
|
||||
delete m_stance;
|
||||
m_stance = 0;
|
||||
@ -922,35 +922,35 @@ void CEntity::stanceChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void CEntity::checkSelection()
|
||||
void CEntity::CheckSelection()
|
||||
{
|
||||
if( m_selected )
|
||||
{
|
||||
if( !g_Selection.isSelected( me ) )
|
||||
g_Selection.addSelection( me );
|
||||
if( !g_Selection.IsSelected( me ) )
|
||||
g_Selection.AddSelection( me );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( g_Selection.isSelected( me ) )
|
||||
g_Selection.removeSelection( me );
|
||||
if( g_Selection.IsSelected( me ) )
|
||||
g_Selection.RemoveSelection( me );
|
||||
}
|
||||
}
|
||||
|
||||
void CEntity::checkGroup()
|
||||
void CEntity::CheckGroup()
|
||||
{
|
||||
g_Selection.changeGroup( me, -1 ); // Ungroup
|
||||
g_Selection.ChangeGroup( me, -1 ); // Ungroup
|
||||
if( ( m_grouped >= 0 ) && ( m_grouped < MAX_GROUPS ) )
|
||||
g_Selection.changeGroup( me, m_grouped );
|
||||
g_Selection.ChangeGroup( me, m_grouped );
|
||||
}
|
||||
|
||||
void CEntity::interpolate( float relativeoffset )
|
||||
void CEntity::Interpolate( float relativeoffset )
|
||||
{
|
||||
CVector3D old_graphics_position = m_graphics_position;
|
||||
CVector3D old_graphics_orientation = m_graphics_orientation;
|
||||
|
||||
relativeoffset = clamp( relativeoffset, 0.f, 1.f );
|
||||
|
||||
m_graphics_position = Interpolate<CVector3D>( m_position_previous, m_position, relativeoffset );
|
||||
m_graphics_position = ::Interpolate<CVector3D>( m_position_previous, m_position, relativeoffset );
|
||||
|
||||
// Avoid wraparound glitches for interpolating angles.
|
||||
|
||||
@ -973,14 +973,14 @@ void CEntity::interpolate( float relativeoffset )
|
||||
while( m_orientation.Z > m_orientation_previous.Z + PI )
|
||||
m_orientation_previous.Z += 2 * PI;
|
||||
|
||||
updateXZOrientation();
|
||||
UpdateXZOrientation();
|
||||
|
||||
m_graphics_orientation = Interpolate<CVector3D>( m_orientation_previous, m_orientation_smoothed, relativeoffset );
|
||||
m_graphics_orientation = ::Interpolate<CVector3D>( m_orientation_previous, m_orientation_smoothed, relativeoffset );
|
||||
|
||||
// Mark the actor transform data as invalid if the entity has moved since
|
||||
// the last call to 'interpolate'.
|
||||
// position.Y is ignored because we can't determine the new value without
|
||||
// calling snapToGround, which is slow. TODO: This may need to be adjusted to
|
||||
// calling SnapToGround, which is slow. TODO: This may need to be adjusted to
|
||||
// handle flying units or moving terrain.
|
||||
if( m_graphics_orientation != old_graphics_orientation ||
|
||||
m_graphics_position.X != old_graphics_position.X ||
|
||||
@ -992,21 +992,21 @@ void CEntity::interpolate( float relativeoffset )
|
||||
// Update the actor transform data when necessary.
|
||||
if( !m_actor_transform_valid )
|
||||
{
|
||||
snapToGround();
|
||||
updateActorTransforms();
|
||||
SnapToGround();
|
||||
UpdateActorTransforms();
|
||||
m_actor_transform_valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CEntity::invalidateActor()
|
||||
void CEntity::InvalidateActor()
|
||||
{
|
||||
m_actor_transform_valid = false;
|
||||
}
|
||||
|
||||
float CEntity::getAnchorLevel( float x, float z )
|
||||
float CEntity::GetAnchorLevel( float x, float z )
|
||||
{
|
||||
CTerrain *pTerrain = g_Game->GetWorld()->GetTerrain();
|
||||
float groundLevel = pTerrain->getExactGroundLevel( x, z );
|
||||
float groundLevel = pTerrain->GetExactGroundLevel( x, z );
|
||||
if( m_base->m_anchorType==L"Ground" )
|
||||
{
|
||||
return groundLevel;
|
||||
@ -1017,7 +1017,7 @@ float CEntity::getAnchorLevel( float x, float z )
|
||||
}
|
||||
}
|
||||
|
||||
int CEntity::findSector( int divs, float angle, float maxAngle, bool negative )
|
||||
int CEntity::FindSector( int divs, float angle, float maxAngle, bool negative )
|
||||
{
|
||||
float step=maxAngle/divs;
|
||||
if ( negative )
|
||||
@ -1047,7 +1047,7 @@ int CEntity::findSector( int divs, float angle, float maxAngle, bool negative )
|
||||
return i;
|
||||
}
|
||||
}
|
||||
debug_warn("CEntity::findSector() - invalid parameters passed.");
|
||||
debug_warn("CEntity::FindSector() - invalid parameters passed.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -12,14 +12,14 @@
|
||||
// Destroying entities: An entity is destroyed when all references to it expire.
|
||||
// It is somewhat unfunny if this happens while a method from this
|
||||
// class is still executing. If you need to kill an entity,
|
||||
// use CEntity::kill(). If kill() releases the final handle,
|
||||
// use CEntity::Kill(). If Kill() releases the final handle,
|
||||
// the entity is placed in the reaper queue and is deleted immediately
|
||||
// prior to its next update cycle.
|
||||
//
|
||||
// CUnit* m_actor: is the visible representation of this entity.
|
||||
//
|
||||
// snapToGround(): Called every frame, this will ensure the entity never takes flight.
|
||||
// updateActorTransforms(): Must be called every time the position of this entity changes.
|
||||
// SnapToGround(): Called every frame, this will ensure the entity never takes flight.
|
||||
// UpdateActorTransforms(): Must be called every time the position of this entity changes.
|
||||
// Also remember to update the collision object if you alter the position directly.
|
||||
//
|
||||
|
||||
@ -226,27 +226,27 @@ public:
|
||||
private:
|
||||
CEntity( CEntityTemplate* base, CVector3D position, float orientation, const std::set<CStr8>& actorSelections, const CStrW* building = 0 );
|
||||
|
||||
uint processGotoHelper( CEntityOrder* current, size_t timestep_milli, HEntity& collide );
|
||||
uint ProcessGotoHelper( CEntityOrder* current, size_t timestep_milli, HEntity& collide );
|
||||
|
||||
bool processContactAction( CEntityOrder* current, size_t timestep_millis, CEntityOrder::EOrderType transition, SEntityAction* action );
|
||||
bool processContactActionNoPathing( CEntityOrder* current, size_t timestep_millis, const CStr& animation, CScriptEvent* contactEvent, SEntityAction* action );
|
||||
bool ProcessContactAction( CEntityOrder* current, size_t timestep_millis, CEntityOrder::EOrderType transition, SEntityAction* action );
|
||||
bool ProcessContactActionNoPathing( CEntityOrder* current, size_t timestep_millis, const CStr& animation, CScriptEvent* contactEvent, SEntityAction* action );
|
||||
|
||||
bool processGeneric( CEntityOrder* current, size_t timestep_milli );
|
||||
bool processGenericNoPathing( CEntityOrder* current, size_t timestep_milli );
|
||||
bool ProcessGeneric( CEntityOrder* current, size_t timestep_milli );
|
||||
bool ProcessGenericNoPathing( CEntityOrder* current, size_t timestep_milli );
|
||||
|
||||
bool processProduce( CEntityOrder* order );
|
||||
bool ProcessProduce( CEntityOrder* order );
|
||||
|
||||
bool processGotoNoPathing( CEntityOrder* current, size_t timestep_milli );
|
||||
bool processGoto( CEntityOrder* current, size_t timestep_milli );
|
||||
bool processGotoWaypoint( CEntityOrder* current, size_t timestep_milli, bool contact );
|
||||
bool ProcessGotoNoPathing( CEntityOrder* current, size_t timestep_milli );
|
||||
bool ProcessGoto( CEntityOrder* current, size_t timestep_milli );
|
||||
bool ProcessGotoWaypoint( CEntityOrder* current, size_t timestep_milli, bool contact );
|
||||
|
||||
bool processPatrol( CEntityOrder* current, size_t timestep_milli );
|
||||
bool ProcessPatrol( CEntityOrder* current, size_t timestep_milli );
|
||||
|
||||
float chooseMovementSpeed( float distance );
|
||||
float ChooseMovementSpeed( float distance );
|
||||
|
||||
bool shouldRun( float distance ); // Given our distance to a target, can we be running?
|
||||
bool ShouldRun( float distance ); // Given our distance to a target, can we be running?
|
||||
|
||||
void updateOrders( size_t timestep_millis );
|
||||
void UpdateOrders( size_t timestep_millis );
|
||||
|
||||
public:
|
||||
~CEntity();
|
||||
@ -255,15 +255,15 @@ public:
|
||||
HEntity me;
|
||||
|
||||
// Updates gameplay information for the specified timestep
|
||||
void update( size_t timestep_millis );
|
||||
void Update( size_t timestep_millis );
|
||||
// Updates graphical information for a point between the last and current
|
||||
// simulation frame; should be 0 <= relativeoffset <= 1 (else it'll be
|
||||
// clamped)
|
||||
void interpolate( float relativeoffset );
|
||||
void Interpolate( float relativeoffset );
|
||||
|
||||
// Forces update of actor information during next call to 'interpolate'.
|
||||
// (Necessary when terrain might move underneath the actor.)
|
||||
void invalidateActor();
|
||||
void InvalidateActor();
|
||||
|
||||
// Updates auras
|
||||
void UpdateAuras( size_t timestep_millis );
|
||||
@ -275,32 +275,32 @@ public:
|
||||
// The keepActor parameter specifies whether to remove the unit's actor immediately (for
|
||||
// units we want removed immediately, e.g. in Atkas) or to keep it and play the death
|
||||
// animation (for units that die of "natural causes").
|
||||
void kill(bool keepActor = false);
|
||||
void Kill(bool keepActor = false);
|
||||
|
||||
// Process initialization
|
||||
bool Initialize();
|
||||
void initAuraData();
|
||||
|
||||
// Process tick.
|
||||
// void Tick(); // (see comment in CEntityManager::updateAll)
|
||||
// void Tick(); // (see comment in CEntityManager::UpdateAll)
|
||||
|
||||
// Calculate distances along the terrain
|
||||
|
||||
float distance2D( float x, float z )
|
||||
float Distance2D( float x, float z )
|
||||
{
|
||||
float dx = x - m_position.X;
|
||||
float dz = z - m_position.Z;
|
||||
return sqrt( dx*dx + dz*dz );
|
||||
}
|
||||
|
||||
float distance2D( CEntity* other )
|
||||
float Distance2D( CEntity* other )
|
||||
{
|
||||
return distance2D( other->m_position.X, other->m_position.Z );
|
||||
return Distance2D( other->m_position.X, other->m_position.Z );
|
||||
}
|
||||
|
||||
float distance2D( CVector2D p )
|
||||
float Distance2D( CVector2D p )
|
||||
{
|
||||
return distance2D( p.x, p.y );
|
||||
return Distance2D( p.x, p.y );
|
||||
}
|
||||
|
||||
private:
|
||||
@ -313,66 +313,66 @@ public:
|
||||
CPlayer* GetPlayer() { return m_player; }
|
||||
|
||||
// Update collision patch (move ourselves to a new one if necessary)
|
||||
void updateCollisionPatch();
|
||||
void UpdateCollisionPatch();
|
||||
|
||||
float getAnchorLevel( float x, float z );
|
||||
float GetAnchorLevel( float x, float z );
|
||||
|
||||
void snapToGround();
|
||||
void updateActorTransforms();
|
||||
void updateXZOrientation();
|
||||
void SnapToGround();
|
||||
void UpdateActorTransforms();
|
||||
void UpdateXZOrientation();
|
||||
|
||||
// Getter and setter for the class sets
|
||||
jsval getClassSet();
|
||||
void setClassSet( jsval value );
|
||||
void rebuildClassSet();
|
||||
jsval GetClassSet();
|
||||
void SetClassSet( jsval value );
|
||||
void RebuildClassSet();
|
||||
|
||||
// Things like selection circles and debug info - possibly move to gui if/when it becomes responsible for (and capable of) it.
|
||||
void render();
|
||||
void renderSelectionOutline( float alpha = 1.0f );
|
||||
void renderAuras();
|
||||
void renderBars();
|
||||
void renderBarBorders();
|
||||
void renderHealthBar();
|
||||
void renderStaminaBar();
|
||||
void renderRank();
|
||||
void renderRallyPoint();
|
||||
void Render();
|
||||
void RenderSelectionOutline( float alpha = 1.0f );
|
||||
void RenderAuras();
|
||||
void RenderBars();
|
||||
void RenderBarBorders();
|
||||
void RenderHealthBar();
|
||||
void RenderStaminaBar();
|
||||
void RenderRank();
|
||||
void RenderRallyPoint();
|
||||
|
||||
// Utility functions for rendering:
|
||||
|
||||
// Draw rectangle around the given centre, aligned with the given axes
|
||||
void drawRect(CVector3D& centre, CVector3D& up, CVector3D& right, float x1, float y1, float x2, float y2);
|
||||
void drawBar(CVector3D& centre, CVector3D& up, CVector3D& right,
|
||||
void DrawRect(CVector3D& centre, CVector3D& up, CVector3D& right, float x1, float y1, float x2, float y2);
|
||||
void DrawBar(CVector3D& centre, CVector3D& up, CVector3D& right,
|
||||
float x1, float y1, float x2, float y2,
|
||||
SColour col1, SColour col2, float currVal, float maxVal);
|
||||
|
||||
CVector2D getScreenCoords( float height );
|
||||
CVector2D GetScreenCoords( float height );
|
||||
|
||||
// After a collision, recalc the path to the next fixed waypoint.
|
||||
void repath();
|
||||
void Repath();
|
||||
|
||||
//Calculate stamina points
|
||||
void CalculateRegen(float timestep);
|
||||
|
||||
// Reset properties after the entity-template we use changes.
|
||||
void loadBase();
|
||||
static void initAttributes(const CEntity* _this);
|
||||
void LoadBase();
|
||||
static void InitAttributes(const CEntity* _this);
|
||||
|
||||
void reorient(); // Orientation
|
||||
void teleport(); // Fixes things if the position is changed by something externally.
|
||||
void stanceChanged(); // Sets m_stance to the right CStance object when our stance property is changed through scripts
|
||||
void checkSelection(); // In case anyone tries to select/deselect this through JavaScript.
|
||||
void checkGroup(); // Groups
|
||||
void checkExtant(); // Existence
|
||||
void Reorient(); // Orientation
|
||||
void Teleport(); // Fixes things if the position is changed by something externally.
|
||||
void StanceChanged(); // Sets m_stance to the right CStance object when our stance property is changed through scripts
|
||||
void CheckSelection(); // In case anyone tries to select/deselect this through JavaScript.
|
||||
void CheckGroup(); // Groups
|
||||
void CheckExtant(); // Existence
|
||||
|
||||
void clearOrders();
|
||||
void popOrder(); //Use this if and order has finished instead of m_orderQueue.pop_front()
|
||||
void pushOrder( CEntityOrder& order );
|
||||
void ClearOrders();
|
||||
void PopOrder(); //Use this if an order has finished instead of m_orderQueue.pop_front()
|
||||
void PushOrder( CEntityOrder& order );
|
||||
|
||||
void DispatchNotification( CEntityOrder order, int type );
|
||||
int DestroyNotifier( CEntity* target ); //Stop notifier from sending to us
|
||||
void DestroyAllNotifiers();
|
||||
|
||||
int findSector( int divs, float angle, float maxAngle, bool negative=true );
|
||||
int FindSector( int divs, float angle, float maxAngle, bool negative=true );
|
||||
jsval FlattenTerrain( JSContext* cx, uintN argc, jsval* argv );
|
||||
|
||||
CEntityFormation* GetFormation();
|
||||
@ -393,8 +393,8 @@ public:
|
||||
jsval GetAttackDirections( JSContext* cx, uintN argc, jsval* argv );
|
||||
|
||||
jsval FindSector( JSContext* cx, uintN argc, jsval* argv );
|
||||
// Script constructor
|
||||
|
||||
// Script constructor
|
||||
static JSBool Construct( JSContext* cx, JSObject* obj, uint argc, jsval* argv, jsval* rval );
|
||||
|
||||
// Script-bound functions
|
||||
@ -441,7 +441,7 @@ public:
|
||||
|
||||
bool Order( JSContext* cx, uintN argc, jsval* argv, CEntityOrder::EOrderSource source, bool Queued );
|
||||
|
||||
// TODO: Replace these variants of order() with a single function, and update scripts accordingly.
|
||||
// TODO: Replace these variants of Order() with a single function, and update scripts accordingly.
|
||||
inline bool OrderSingle( JSContext* cx, uintN argc, jsval* argv )
|
||||
{
|
||||
return( Order( cx, argc, argv, CEntityOrder::SOURCE_PLAYER, false ) );
|
||||
|
@ -63,6 +63,7 @@ void CEntityFormation::SwitchBase( CFormation*& base )
|
||||
for ( std::vector<CEntity*>::iterator it=copy.begin(); it != copy.end(); it++ )
|
||||
g_FormationManager.AddUnit(*it, m_index);
|
||||
}
|
||||
|
||||
bool CEntityFormation::AddUnit( CEntity* entity )
|
||||
{
|
||||
debug_assert( entity );
|
||||
@ -89,6 +90,7 @@ bool CEntityFormation::AddUnit( CEntity* entity )
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CEntityFormation::RemoveUnit( CEntity* entity )
|
||||
{
|
||||
if ( !(IsValidOrder(entity->m_formationSlot) && entity) )
|
||||
@ -101,6 +103,7 @@ void CEntityFormation::RemoveUnit( CEntity* entity )
|
||||
--m_numEntities;
|
||||
//UpdateFormation();
|
||||
}
|
||||
|
||||
bool CEntityFormation::IsSlotAppropriate( int order, CEntity* entity )
|
||||
{
|
||||
debug_assert( entity );
|
||||
@ -115,6 +118,7 @@ bool CEntityFormation::IsSlotAppropriate( int order, CEntity* entity )
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CEntityFormation::IsBetterUnit( int order, CEntity* entity )
|
||||
{
|
||||
if ( !( IsValidOrder(order) && entity ) )
|
||||
@ -175,17 +179,19 @@ void CEntityFormation::ResetAllEntities()
|
||||
for ( int i=0; i<m_base->m_numSlots; ++i )
|
||||
m_entities[i] = NULL;
|
||||
}
|
||||
|
||||
void CEntityFormation::ResetAngleDivs()
|
||||
{
|
||||
for ( int i=0; i<m_base->m_anglePenaltyDivs; ++i )
|
||||
m_angleDivs[i] = false;
|
||||
}
|
||||
|
||||
void CEntityFormation::SelectAllUnits()
|
||||
{
|
||||
for ( int i=0; i<m_base->m_numSlots; ++i )
|
||||
{
|
||||
if ( m_entities[i] && !g_Selection.isSelected(m_entities[i]->me) )
|
||||
g_Selection.addSelection( m_entities[i]->me );
|
||||
if ( m_entities[i] && !g_Selection.IsSelected(m_entities[i]->me) )
|
||||
g_Selection.AddSelection( m_entities[i]->me );
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,16 +212,18 @@ CVector2D CEntityFormation::GetSlotPosition( int order )
|
||||
return CVector2D ( m_base->m_slots[order].rankOff, m_base->m_slots[order].fileOff );
|
||||
return CVector2D(-1, -1);
|
||||
}
|
||||
|
||||
void CEntityFormation::BaseToMovement()
|
||||
{
|
||||
CFormation* tmp = m_self;
|
||||
CFormation* move = g_EntityFormationCollection.getTemplate( m_base->m_movement );
|
||||
CFormation* move = g_EntityFormationCollection.GetTemplate( m_base->m_movement );
|
||||
if (!move)
|
||||
return;
|
||||
SwitchBase( move );
|
||||
//SwitchBase resets m_self, so reset it so we can return to the correct base later
|
||||
m_self = tmp;
|
||||
}
|
||||
|
||||
void CEntityFormation::ResetIndex( size_t index )
|
||||
{
|
||||
m_index = (int)index;
|
||||
@ -226,6 +234,7 @@ void CEntityFormation::ResetIndex( size_t index )
|
||||
m_entities[i]->m_formation = m_index;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
inline void CEntityFormation::SetDuplication( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* argv )
|
||||
{
|
||||
|
@ -15,13 +15,13 @@ CHandle::CHandle()
|
||||
HEntity::HEntity( u16 index )
|
||||
{
|
||||
m_handle = index;
|
||||
addRef();
|
||||
AddRef();
|
||||
}
|
||||
|
||||
HEntity::HEntity( const HEntity& copy )
|
||||
{
|
||||
m_handle = copy.m_handle;
|
||||
addRef();
|
||||
AddRef();
|
||||
}
|
||||
|
||||
HEntity::HEntity()
|
||||
@ -32,14 +32,14 @@ HEntity::HEntity()
|
||||
HEntity::~HEntity()
|
||||
{
|
||||
if( CEntityManager::IsExtant() )
|
||||
decRef();
|
||||
DecRef();
|
||||
}
|
||||
|
||||
void HEntity::operator=( const HEntity& copy )
|
||||
{
|
||||
decRef();
|
||||
DecRef();
|
||||
m_handle = copy.m_handle;
|
||||
addRef();
|
||||
AddRef();
|
||||
}
|
||||
|
||||
bool HEntity::operator ==( const HEntity& test ) const
|
||||
@ -65,7 +65,7 @@ bool HEntity::operator!() const
|
||||
return( g_EntityManager.m_entities[m_handle].m_entity->entf_get(ENTF_DESTROYED) );
|
||||
}
|
||||
|
||||
void HEntity::addRef()
|
||||
void HEntity::AddRef()
|
||||
{
|
||||
if( m_handle != INVALID_HANDLE )
|
||||
{
|
||||
@ -75,14 +75,14 @@ void HEntity::addRef()
|
||||
}
|
||||
}
|
||||
|
||||
void HEntity::decRef()
|
||||
void HEntity::DecRef()
|
||||
{
|
||||
if( m_handle != INVALID_HANDLE )
|
||||
{
|
||||
if( --g_EntityManager.m_entities[m_handle].m_refcount == 0 )
|
||||
{
|
||||
g_EntityManager.m_refd[m_handle] = false;
|
||||
g_EntityManager.destroy( m_handle );
|
||||
g_EntityManager.Destroy( m_handle );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,9 +123,9 @@ u8 *HEntity::Serialize(u8* buffer) const
|
||||
const u8* HEntity::Deserialize(const u8* buffer, const u8* UNUSED(end))
|
||||
{
|
||||
Deserialize_int_2(buffer, m_handle);
|
||||
// We can't let addRef debug_assert just because someone sent us bogus data
|
||||
// We can't let AddRef debug_assert just because someone sent us bogus data
|
||||
if (m_handle < MAX_HANDLES && m_handle != INVALID_HANDLE)
|
||||
addRef();
|
||||
AddRef();
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,8 @@ class HEntity
|
||||
friend struct CEntityList;
|
||||
u16 m_handle;
|
||||
private:
|
||||
void addRef();
|
||||
void decRef();
|
||||
void AddRef();
|
||||
void DecRef();
|
||||
HEntity( u16 index );
|
||||
public:
|
||||
CEntity& operator*() const;
|
||||
@ -63,7 +63,7 @@ public:
|
||||
bool operator!() const;
|
||||
operator CEntity*() const;
|
||||
// Visual C++ 2003 can't handle (bool && HEntity) expressions, so provide another alias for operator bool()
|
||||
bool isValid() const {return this->operator bool();}
|
||||
bool IsValid() const {return this->operator bool();}
|
||||
~HEntity();
|
||||
|
||||
uint GetSerializedLength() const;
|
||||
|
@ -38,7 +38,7 @@ CEntityManager::CEntityManager()
|
||||
}
|
||||
|
||||
|
||||
void CEntityManager::deleteAllHelper()
|
||||
void CEntityManager::DeleteAllHelper()
|
||||
{
|
||||
for( int i = 0; i < MAX_HANDLES; i++ )
|
||||
{
|
||||
@ -55,9 +55,9 @@ void CEntityManager::deleteAllHelper()
|
||||
CEntityManager::~CEntityManager()
|
||||
{
|
||||
m_extant = false;
|
||||
deleteAllHelper();
|
||||
DeleteAllHelper();
|
||||
|
||||
// Delete entities that were killed, but not yet reaped by a call to updateAll,
|
||||
// Delete entities that were killed, but not yet reaped by a call to UpdateAll,
|
||||
// to avoid memory leak warnings upon exiting
|
||||
std::vector<CEntity*>::iterator it;
|
||||
for( it = m_reaper.begin(); it < m_reaper.end(); it++ )
|
||||
@ -68,11 +68,11 @@ CEntityManager::~CEntityManager()
|
||||
m_collisionPatches = NULL;
|
||||
}
|
||||
|
||||
void CEntityManager::deleteAll()
|
||||
void CEntityManager::DeleteAll()
|
||||
{
|
||||
m_extant = false;
|
||||
|
||||
deleteAllHelper();
|
||||
DeleteAllHelper();
|
||||
|
||||
m_nextalloc = 0;
|
||||
|
||||
@ -82,7 +82,7 @@ void CEntityManager::deleteAll()
|
||||
m_extant = true;
|
||||
}
|
||||
|
||||
HEntity CEntityManager::create(CEntityTemplate* base, CVector3D position, float orientation,
|
||||
HEntity CEntityManager::Create(CEntityTemplate* base, CVector3D position, float orientation,
|
||||
const std::set<CStr>& actorSelections, const CStrW* building)
|
||||
{
|
||||
debug_assert( base );
|
||||
@ -105,7 +105,7 @@ HEntity CEntityManager::create(CEntityTemplate* base, CVector3D position, float
|
||||
|
||||
m_entities[pos].m_entity = new CEntity( base, position, orientation, actorSelections, building );
|
||||
if( m_collisionPatches)
|
||||
m_entities[pos].m_entity->updateCollisionPatch();
|
||||
m_entities[pos].m_entity->UpdateCollisionPatch();
|
||||
m_entities[pos].m_entity->me = HEntity( pos );
|
||||
return( HEntity( pos ) );
|
||||
}
|
||||
@ -114,7 +114,7 @@ void CEntityManager::AddEntityClassData(const HEntity& handle)
|
||||
{
|
||||
//Add data for this particular entity and player
|
||||
size_t playerID = handle->GetPlayer()->GetPlayerID();
|
||||
CStrW className, classList = handle->m_classes.getMemberList();
|
||||
CStrW className, classList = handle->m_classes.GetMemberList();
|
||||
|
||||
while ( (className = classList.BeforeFirst(L" ")) != classList )
|
||||
{
|
||||
@ -130,23 +130,23 @@ void CEntityManager::AddEntityClassData(const HEntity& handle)
|
||||
++m_entityClassData[playerID][className];
|
||||
}
|
||||
|
||||
HEntity CEntityManager::create( const CStrW& templateName, CPlayer* player, CVector3D position, float orientation, const CStrW* building )
|
||||
HEntity CEntityManager::Create( const CStrW& templateName, CPlayer* player, CVector3D position, float orientation, const CStrW* building )
|
||||
{
|
||||
CEntityTemplate* base = g_EntityTemplateCollection.getTemplate( templateName, player );
|
||||
CEntityTemplate* base = g_EntityTemplateCollection.GetTemplate( templateName, player );
|
||||
debug_assert( base );
|
||||
if( !base )
|
||||
return HEntity();
|
||||
|
||||
std::set<CStr> selections;
|
||||
|
||||
HEntity ret = create( base, position, orientation, selections, building );
|
||||
HEntity ret = Create( base, position, orientation, selections, building );
|
||||
AddEntityClassData(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
HEntity CEntityManager::createFoundation( const CStrW& templateName, CPlayer* player, CVector3D position, float orientation )
|
||||
HEntity CEntityManager::CreateFoundation( const CStrW& templateName, CPlayer* player, CVector3D position, float orientation )
|
||||
{
|
||||
CEntityTemplate* base = g_EntityTemplateCollection.getTemplate( templateName, player );
|
||||
CEntityTemplate* base = g_EntityTemplateCollection.GetTemplate( templateName, player );
|
||||
debug_assert( base );
|
||||
if( !base )
|
||||
return HEntity();
|
||||
@ -154,41 +154,42 @@ HEntity CEntityManager::createFoundation( const CStrW& templateName, CPlayer* pl
|
||||
std::set<CStr> selections;
|
||||
|
||||
if( base->m_foundation == L"" )
|
||||
return create( base, position, orientation, selections ); // Entity has no foundation, so just create it
|
||||
return Create( base, position, orientation, selections ); // Entity has no foundation, so just create it
|
||||
|
||||
// Else, place the foundation object, telling it to convert into the right template when built.
|
||||
CEntityTemplate* foundation = g_EntityTemplateCollection.getTemplate( base->m_foundation );
|
||||
return create( foundation, position, orientation, selections, &templateName );
|
||||
CEntityTemplate* foundation = g_EntityTemplateCollection.GetTemplate( base->m_foundation );
|
||||
return Create( foundation, position, orientation, selections, &templateName );
|
||||
}
|
||||
|
||||
HEntity* CEntityManager::getByHandle( u16 index )
|
||||
HEntity* CEntityManager::GetByHandle( u16 index )
|
||||
{
|
||||
if( index >= MAX_HANDLES ) return( NULL );
|
||||
if( !m_entities[index].m_refcount ) return( NULL );
|
||||
return( new HEntity( index ) );
|
||||
}
|
||||
CHandle *CEntityManager::getHandle( int index )
|
||||
CHandle *CEntityManager::GetHandle( int index )
|
||||
{
|
||||
if (!m_entities[index].m_refcount )
|
||||
return NULL;
|
||||
return &m_entities[index];
|
||||
}
|
||||
|
||||
std::vector<HEntity>* CEntityManager::matches( EntityPredicate predicate, void* userdata )
|
||||
void CEntityManager::GetMatchingAsHandles(std::vector<HEntity>& matchlist, EntityPredicate predicate, void* userdata)
|
||||
{
|
||||
std::vector<HEntity>* matchlist = new std::vector<HEntity>;
|
||||
matchlist.clear();
|
||||
for( int i = 0; i < MAX_HANDLES; i++ )
|
||||
if( isEntityRefd(i) )
|
||||
{
|
||||
if( IsEntityRefd(i) )
|
||||
if( predicate( m_entities[i].m_entity, userdata ) )
|
||||
matchlist->push_back( HEntity( i ) );
|
||||
return( matchlist );
|
||||
matchlist.push_back( HEntity( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CEntityManager::GetExtantAsHandles( std::vector<HEntity>& results )
|
||||
{
|
||||
results.clear();
|
||||
for( int i = 0; i < MAX_HANDLES; i++ )
|
||||
if( isEntityRefd(i) )
|
||||
if( IsEntityRefd(i) )
|
||||
results.push_back( HEntity( i ) );
|
||||
}
|
||||
|
||||
@ -196,7 +197,7 @@ void CEntityManager::GetExtant( std::vector<CEntity*>& results )
|
||||
{
|
||||
results.clear();
|
||||
for( int i = 0; i < MAX_HANDLES; i++ )
|
||||
if( isEntityRefd(i) && m_entities[i].m_entity->m_extant )
|
||||
if( IsEntityRefd(i) && m_entities[i].m_entity->m_extant )
|
||||
results.push_back( m_entities[i].m_entity );
|
||||
}
|
||||
|
||||
@ -264,14 +265,14 @@ void CEntityManager::InitializeAll()
|
||||
|
||||
for( int i = 0; i < MAX_HANDLES; i++ )
|
||||
{
|
||||
if( isEntityRefd(i) )
|
||||
if( IsEntityRefd(i) )
|
||||
{
|
||||
// [2006-06-26 2780ms total]
|
||||
CEntity* e = m_entities[i].m_entity;
|
||||
e->Initialize();
|
||||
|
||||
// [2006-06-26 8ms total]
|
||||
e->updateCollisionPatch();
|
||||
e->UpdateCollisionPatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -280,12 +281,12 @@ void CEntityManager::InitializeAll()
|
||||
void CEntityManager::TickAll()
|
||||
{
|
||||
for( int i = 0; i < MAX_HANDLES; i++ )
|
||||
if( isEntityRefd(i) && m_entities[i].m_entity->m_extant )
|
||||
if( IsEntityRefd(i) && m_entities[i].m_entity->m_extant )
|
||||
m_entities[i].m_entity->Tick();
|
||||
}
|
||||
*/
|
||||
|
||||
void CEntityManager::updateAll( size_t timestep )
|
||||
void CEntityManager::UpdateAll( size_t timestep )
|
||||
{
|
||||
PROFILE_START( "reaper" );
|
||||
std::vector<CEntity*>::iterator it;
|
||||
@ -310,53 +311,53 @@ void CEntityManager::updateAll( size_t timestep )
|
||||
|
||||
PROFILE_START( "update all" );
|
||||
for( int i = 0; i < MAX_HANDLES; i++ )
|
||||
if( isEntityRefd(i) )
|
||||
m_entities[i].m_entity->update( timestep );
|
||||
if( IsEntityRefd(i) )
|
||||
m_entities[i].m_entity->Update( timestep );
|
||||
PROFILE_END( "update all" );
|
||||
}
|
||||
|
||||
void CEntityManager::interpolateAll( float relativeoffset )
|
||||
void CEntityManager::InterpolateAll( float relativeoffset )
|
||||
{
|
||||
for( int i = 0; i < MAX_HANDLES; i++ )
|
||||
// This needs to handle all entities, including destroyed/non-extant ones
|
||||
// (mainly dead bodies), so it can't use isEntityRefd
|
||||
// (mainly dead bodies), so it can't use IsEntityRefd
|
||||
if( m_entities[i].m_refcount )
|
||||
m_entities[i].m_entity->interpolate( relativeoffset );
|
||||
m_entities[i].m_entity->Interpolate( relativeoffset );
|
||||
}
|
||||
|
||||
void CEntityManager::renderAll()
|
||||
void CEntityManager::RenderAll()
|
||||
{
|
||||
for( int i = 0; i < MAX_HANDLES; i++ )
|
||||
if( isEntityRefd(i) )
|
||||
m_entities[i].m_entity->render();
|
||||
if( IsEntityRefd(i) )
|
||||
m_entities[i].m_entity->Render();
|
||||
}
|
||||
|
||||
void CEntityManager::conformAll()
|
||||
void CEntityManager::ConformAll()
|
||||
{
|
||||
PROFILE_START("conform all");
|
||||
for ( int i=0; i < MAX_HANDLES; i++ )
|
||||
{
|
||||
if( isEntityRefd(i) )
|
||||
if( IsEntityRefd(i) )
|
||||
{
|
||||
m_entities[i].m_entity->updateXZOrientation();
|
||||
m_entities[i].m_entity->updateActorTransforms();
|
||||
m_entities[i].m_entity->UpdateXZOrientation();
|
||||
m_entities[i].m_entity->UpdateActorTransforms();
|
||||
}
|
||||
}
|
||||
PROFILE_END("conform all");
|
||||
}
|
||||
|
||||
void CEntityManager::invalidateAll()
|
||||
void CEntityManager::InvalidateAll()
|
||||
{
|
||||
for( int i = 0; i < MAX_HANDLES; i++ )
|
||||
if( isEntityRefd(i) )
|
||||
m_entities[i].m_entity->invalidateActor();
|
||||
if( IsEntityRefd(i) )
|
||||
m_entities[i].m_entity->InvalidateActor();
|
||||
}
|
||||
|
||||
|
||||
void CEntityManager::removeUnitCount(CEntity* ent)
|
||||
void CEntityManager::RemoveUnitCount(CEntity* ent)
|
||||
{
|
||||
size_t playerID = (size_t)ent->GetPlayer()->GetPlayerID();
|
||||
CStrW className, classList = ent->m_classes.getMemberList();
|
||||
CStrW className, classList = ent->m_classes.GetMemberList();
|
||||
|
||||
while ( (className = classList.BeforeFirst(L" ")) != classList )
|
||||
{
|
||||
@ -365,14 +366,14 @@ void CEntityManager::removeUnitCount(CEntity* ent)
|
||||
}
|
||||
--m_entityClassData[playerID][className];
|
||||
}
|
||||
void CEntityManager::destroy( u16 handle )
|
||||
void CEntityManager::Destroy( u16 handle )
|
||||
{
|
||||
m_reaper.push_back( m_entities[handle].m_entity );
|
||||
}
|
||||
|
||||
bool CEntityManager::m_extant = false;
|
||||
|
||||
std::vector<CEntity*>* CEntityManager::getCollisionPatch( CEntity* e )
|
||||
std::vector<CEntity*>* CEntityManager::GetCollisionPatch( CEntity* e )
|
||||
{
|
||||
if( !e->m_extant )
|
||||
{
|
||||
|
@ -5,12 +5,12 @@
|
||||
// Maintains entity id->object mappings. Does most of the work involved in creating an entity.
|
||||
//
|
||||
// Usage: Do not attempt to directly instantiate an entity class.
|
||||
// HEntity bob = g_EntityManager.create( unit_class_name, position, orientation );
|
||||
// or HEntity jim = g_EntityManager.create( pointer_to_unit_class, position, orientation );
|
||||
// HEntity bob = g_EntityManager.Create( unit_class_name, position, orientation );
|
||||
// or HEntity jim = g_EntityManager.Create( pointer_to_unit_class, position, orientation );
|
||||
//
|
||||
// Perform updates on all world entities by g_EntityManager.updateAll( timestep )
|
||||
// Perform updates on all world entities by g_EntityManager.UpdateAll( timestep )
|
||||
// Dispatch an identical message to all world entities by g_EntityManager.dispatchAll( message_pointer )
|
||||
// Get an STL vector container of all entities with a certain property with g_EntityManager.matches( predicate )
|
||||
// Fill an STL vector container with all entities matching a certain predicate with g_EntityManager.GetMatchingAsHandles( container, predicate, data )
|
||||
// or just get all entities with g_EntityManager.GetExtant().
|
||||
//
|
||||
// Those last two functions - caller has responsibility for deleting the collection when you're done with it.
|
||||
@ -53,10 +53,10 @@ friend class CHandle;
|
||||
//Optimized data for triggers. key = playerID, nested key = entity class, value = frequency
|
||||
std::map<size_t, std::map<CStrW, int> > m_entityClassData;
|
||||
|
||||
void destroy( u16 handle );
|
||||
void deleteAllHelper();
|
||||
void Destroy( u16 handle );
|
||||
void DeleteAllHelper();
|
||||
|
||||
inline bool isEntityRefd( u16 index )
|
||||
inline bool IsEntityRefd( u16 index )
|
||||
{
|
||||
return m_refd[index];
|
||||
//return m_entities[index].m_refcount && !m_entities[index].m_entity->entf_get(ENTF_DESTROYED);
|
||||
@ -68,36 +68,36 @@ public:
|
||||
CEntityManager();
|
||||
~CEntityManager();
|
||||
|
||||
HEntity create( CEntityTemplate* base, CVector3D position, float orientation,
|
||||
HEntity Create( CEntityTemplate* base, CVector3D position, float orientation,
|
||||
const std::set<CStr>& actorSelections, const CStrW* building = 0 );
|
||||
|
||||
HEntity create( const CStrW& templateName, CPlayer* player, CVector3D position,
|
||||
HEntity Create( const CStrW& templateName, CPlayer* player, CVector3D position,
|
||||
float orientation, const CStrW* building = 0 );
|
||||
|
||||
HEntity createFoundation( const CStrW& templateName, CPlayer* player, CVector3D position,
|
||||
HEntity CreateFoundation( const CStrW& templateName, CPlayer* player, CVector3D position,
|
||||
float orientation );
|
||||
|
||||
HEntity* getByHandle( u16 index );
|
||||
CHandle *getHandle( int index );
|
||||
HEntity* GetByHandle( u16 index );
|
||||
CHandle *GetHandle( int index );
|
||||
|
||||
inline int getPlayerUnitCount( size_t player, const CStrW& name )
|
||||
inline int GetPlayerUnitCount( size_t player, const CStrW& name )
|
||||
{
|
||||
if ( m_entityClassData[player].find(name) == m_entityClassData[player].end() )
|
||||
m_entityClassData[player][name] = 0;
|
||||
return m_entityClassData[player][name];
|
||||
}
|
||||
void removeUnitCount(CEntity* ent); //Removes unit from population count
|
||||
void RemoveUnitCount(CEntity* ent); //Removes unit from population count
|
||||
void AddEntityClassData(const HEntity& handle);
|
||||
|
||||
void updateAll( size_t timestep );
|
||||
void interpolateAll( float relativeoffset );
|
||||
void UpdateAll( size_t timestep );
|
||||
void InterpolateAll( float relativeoffset );
|
||||
void InitializeAll();
|
||||
// void TickAll();
|
||||
void renderAll();
|
||||
void conformAll();
|
||||
void invalidateAll();
|
||||
void RenderAll();
|
||||
void ConformAll();
|
||||
void InvalidateAll();
|
||||
|
||||
void deleteAll();
|
||||
void DeleteAll();
|
||||
|
||||
bool GetDeath() { return m_death; }
|
||||
void SetDeath(bool set) { m_death=set; }
|
||||
@ -112,7 +112,7 @@ public:
|
||||
template<EntityPredicate operand> static bool EntityPredicateLogicalNot( CEntity* target, void* userdata )
|
||||
{ return( !operand( target, userdata ) ); }
|
||||
|
||||
std::vector<HEntity>* matches( EntityPredicate predicate, void* userdata = NULL );
|
||||
void GetMatchingAsHandles( std::vector<HEntity>& matchlist, EntityPredicate predicate, void* userdata = 0 );
|
||||
void GetExtantAsHandles( std::vector<HEntity>& results );
|
||||
void GetExtant( std::vector<CEntity*>& results );
|
||||
static inline bool IsExtant() // True if the singleton is actively maintaining handles. When false, system is shutting down, handles are quietly dumped.
|
||||
@ -123,7 +123,7 @@ public:
|
||||
void GetInRange( float x, float z, float radius, std::vector<CEntity*>& results );
|
||||
void GetInLOS( CEntity* entity, std::vector<CEntity*>& results );
|
||||
|
||||
std::vector<CEntity*>* getCollisionPatch( CEntity* e );
|
||||
std::vector<CEntity*>* GetCollisionPatch( CEntity* e );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
extern int g_xres, g_yres;
|
||||
|
||||
void CEntity::render()
|
||||
void CEntity::Render()
|
||||
{
|
||||
if( !m_visible ) return;
|
||||
|
||||
@ -55,7 +55,7 @@ void CEntity::render()
|
||||
x = it->m_target_location.x;
|
||||
y = it->m_target_location.y;
|
||||
}
|
||||
destinationCollisionObject = getContainingObject( CVector2D( x, y ) );
|
||||
destinationCollisionObject = GetContainingObject( CVector2D( x, y ) );
|
||||
|
||||
glShadeModel( GL_FLAT );
|
||||
glBegin( GL_LINE_STRIP );
|
||||
@ -73,19 +73,19 @@ void CEntity::render()
|
||||
y = it->m_target_location.y;
|
||||
rayIntersectionResults r;
|
||||
CVector2D fwd( x - x0, y - y0 );
|
||||
float l = fwd.length();
|
||||
fwd = fwd.normalize();
|
||||
float l = fwd.Length();
|
||||
fwd = fwd.Normalize();
|
||||
CVector2D rgt = fwd.beta();
|
||||
if( getRayIntersection( CVector2D( x0, y0 ), fwd, rgt, l, m_bounds->m_radius, destinationCollisionObject, &r ) )
|
||||
if( GetRayIntersection( CVector2D( x0, y0 ), fwd, rgt, l, m_bounds->m_radius, destinationCollisionObject, &r ) )
|
||||
{
|
||||
glEnd();
|
||||
glBegin( GL_LINES );
|
||||
glColor3f( 1.0f, 0.0f, 0.0f );
|
||||
glVertex3f( x0 + fwd.x * r.distance, getAnchorLevel( x0 + fwd.x * r.distance, y0 + fwd.y * r.distance ) + 0.25f, y0 + fwd.y * r.distance );
|
||||
glVertex3f( r.position.x, getAnchorLevel( r.position.x, r.position.y ) + 0.25f, r.position.y );
|
||||
glVertex3f( x0 + fwd.x * r.distance, GetAnchorLevel( x0 + fwd.x * r.distance, y0 + fwd.y * r.distance ) + 0.25f, y0 + fwd.y * r.distance );
|
||||
glVertex3f( r.position.x, GetAnchorLevel( r.position.x, r.position.y ) + 0.25f, r.position.y );
|
||||
glEnd();
|
||||
glBegin( GL_LINE_STRIP );
|
||||
glVertex3f( x0, getAnchorLevel( x0, y0 ), y0 );
|
||||
glVertex3f( x0, GetAnchorLevel( x0, y0 ), y0 );
|
||||
}
|
||||
switch( it->m_type )
|
||||
{
|
||||
@ -106,7 +106,7 @@ void CEntity::render()
|
||||
continue;
|
||||
}
|
||||
|
||||
glVertex3f( x, getAnchorLevel( x, y ) + 0.25f, y );
|
||||
glVertex3f( x, GetAnchorLevel( x, y ) + 0.25f, y );
|
||||
}
|
||||
|
||||
glEnd();
|
||||
@ -114,17 +114,17 @@ void CEntity::render()
|
||||
}
|
||||
|
||||
glColor3f( 1.0f, 1.0f, 1.0f );
|
||||
if( getCollisionObject( this ) )
|
||||
if( GetCollisionObject( this ) )
|
||||
glColor3f( 0.5f, 0.5f, 1.0f );
|
||||
m_bounds->render( getAnchorLevel( m_position.X, m_position.Z ) + 0.25f ); //m_position.Y + 0.25f );
|
||||
m_bounds->Render( GetAnchorLevel( m_position.X, m_position.Z ) + 0.25f ); //m_position.Y + 0.25f );
|
||||
}
|
||||
|
||||
void CEntity::renderSelectionOutline( float alpha )
|
||||
void CEntity::RenderSelectionOutline( float alpha )
|
||||
{
|
||||
if( !m_bounds || !m_visible )
|
||||
return;
|
||||
|
||||
if( getCollisionObject( m_bounds, m_player, &m_base->m_socket ) )
|
||||
if( GetCollisionObject( m_bounds, m_player, &m_base->m_socket ) )
|
||||
{
|
||||
glColor4f( 1.0f, 0.5f, 0.5f, alpha ); // We're colliding with another unit; colour outline pink
|
||||
}
|
||||
@ -150,7 +150,7 @@ void CEntity::renderSelectionOutline( float alpha )
|
||||
float y = pos.Z + radius * cos( ang );
|
||||
#ifdef SELECTION_TERRAIN_CONFORMANCE
|
||||
|
||||
glVertex3f( x, getAnchorLevel( x, y ) + 0.25f, y );
|
||||
glVertex3f( x, GetAnchorLevel( x, y ) + 0.25f, y );
|
||||
#else
|
||||
|
||||
glVertex3f( x, pos.Y + 0.25f, y );
|
||||
@ -178,38 +178,38 @@ void CEntity::renderSelectionOutline( float alpha )
|
||||
for( int i = SELECTION_BOX_POINTS; i > -SELECTION_BOX_POINTS; i-- )
|
||||
{
|
||||
p = q + u * d + v * ( w * (float)i / (float)SELECTION_BOX_POINTS );
|
||||
glVertex3f( p.x, getAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
glVertex3f( p.x, GetAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
}
|
||||
|
||||
for( int i = SELECTION_BOX_POINTS; i > -SELECTION_BOX_POINTS; i-- )
|
||||
{
|
||||
p = q + u * ( d * (float)i / (float)SELECTION_BOX_POINTS ) - v * w;
|
||||
glVertex3f( p.x, getAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
glVertex3f( p.x, GetAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
}
|
||||
|
||||
for( int i = -SELECTION_BOX_POINTS; i < SELECTION_BOX_POINTS; i++ )
|
||||
{
|
||||
p = q - u * d + v * ( w * (float)i / (float)SELECTION_BOX_POINTS );
|
||||
glVertex3f( p.x, getAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
glVertex3f( p.x, GetAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
}
|
||||
|
||||
for( int i = -SELECTION_BOX_POINTS; i < SELECTION_BOX_POINTS; i++ )
|
||||
{
|
||||
p = q + u * ( d * (float)i / (float)SELECTION_BOX_POINTS ) + v * w;
|
||||
glVertex3f( p.x, getAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
glVertex3f( p.x, GetAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
}
|
||||
#else
|
||||
p = q + u * h + v * w;
|
||||
glVertex3f( p.x, getAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
glVertex3f( p.x, GetAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
|
||||
p = q + u * h - v * w;
|
||||
glVertex3f( p.x, getAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
glVertex3f( p.x, GetAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
|
||||
p = q - u * h + v * w;
|
||||
glVertex3f( p.x, getAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
glVertex3f( p.x, GetAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
|
||||
p = q + u * h + v * w;
|
||||
glVertex3f( p.x, getAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
glVertex3f( p.x, GetAnchorLevel( p.x, p.y ) + 0.25f, p.y );
|
||||
#endif
|
||||
|
||||
|
||||
@ -220,7 +220,7 @@ void CEntity::renderSelectionOutline( float alpha )
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void CEntity::renderAuras()
|
||||
void CEntity::RenderAuras()
|
||||
{
|
||||
if( !(m_bounds && m_visible && !m_auras.empty()) )
|
||||
return;
|
||||
@ -242,19 +242,19 @@ void CEntity::renderAuras()
|
||||
if ( it->second->m_radius < 15.0f )
|
||||
{
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glVertex3f(0.0f, getAnchorLevel(m_graphics_position.X,
|
||||
glVertex3f(0.0f, GetAnchorLevel(m_graphics_position.X,
|
||||
m_graphics_position.Z)-m_graphics_position.Y+.5f, 0.0f);
|
||||
for ( int j=0; j<AURA_CIRCLE_POINTS; ++j )
|
||||
{
|
||||
CVector2D ypos( m_unsnappedPoints[i][j].x+m_graphics_position.X,
|
||||
m_unsnappedPoints[i][j].y+m_graphics_position.Z );
|
||||
CVector3D pos( m_unsnappedPoints[i][j].x, getAnchorLevel(ypos.x, ypos.y)-
|
||||
CVector3D pos( m_unsnappedPoints[i][j].x, GetAnchorLevel(ypos.x, ypos.y)-
|
||||
m_graphics_position.Y+.5f, m_unsnappedPoints[i][j].y );
|
||||
glVertex3f(pos.X, pos.Y, pos.Z);
|
||||
}
|
||||
//Loop around
|
||||
CVector3D pos( m_unsnappedPoints[i][0].x,
|
||||
getAnchorLevel(m_unsnappedPoints[i][0].x+m_graphics_position.X,
|
||||
GetAnchorLevel(m_unsnappedPoints[i][0].x+m_graphics_position.X,
|
||||
m_unsnappedPoints[i][0].y+m_graphics_position.Z)-
|
||||
m_graphics_position.Y+.5f, m_unsnappedPoints[i][0].y );
|
||||
glVertex3f(pos.X, pos.Y, pos.Z);
|
||||
@ -270,7 +270,7 @@ void CEntity::renderAuras()
|
||||
{
|
||||
CVector2D ypos( m_unsnappedPoints[i][j].x+m_graphics_position.X,
|
||||
m_unsnappedPoints[i][j].y+m_graphics_position.Z );
|
||||
CVector3D pos( m_unsnappedPoints[i][j].x, getAnchorLevel(ypos.x, ypos.y)-
|
||||
CVector3D pos( m_unsnappedPoints[i][j].x, GetAnchorLevel(ypos.x, ypos.y)-
|
||||
m_graphics_position.Y+.5f, m_unsnappedPoints[i][j].y );
|
||||
glVertex3f(pos.X, pos.Y, pos.Z);
|
||||
}
|
||||
@ -296,7 +296,7 @@ void CEntity::renderAuras()
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
CVector2D CEntity::getScreenCoords( float height )
|
||||
CVector2D CEntity::GetScreenCoords( float height )
|
||||
{
|
||||
CCamera &camera = *g_Game->GetView()->GetCamera();
|
||||
|
||||
@ -304,12 +304,12 @@ CVector2D CEntity::getScreenCoords( float height )
|
||||
CVector3D above;
|
||||
above.X = m_position.X;
|
||||
above.Z = m_position.Z;
|
||||
above.Y = getAnchorLevel(m_position.X, m_position.Z) + height;
|
||||
above.Y = GetAnchorLevel(m_position.X, m_position.Z) + height;
|
||||
camera.GetScreenCoordinates(above, sx, sy);
|
||||
return CVector2D( sx, sy );
|
||||
}
|
||||
|
||||
void CEntity::drawRect( CVector3D& centre, CVector3D& up, CVector3D& right, float x1, float y1, float x2, float y2 )
|
||||
void CEntity::DrawRect( CVector3D& centre, CVector3D& up, CVector3D& right, float x1, float y1, float x2, float y2 )
|
||||
{
|
||||
glBegin(GL_QUADS);
|
||||
const int X[] = {1,1,0,0}; // which X and Y to choose at each vertex
|
||||
@ -323,7 +323,7 @@ void CEntity::drawRect( CVector3D& centre, CVector3D& up, CVector3D& right, floa
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void CEntity::drawBar( CVector3D& centre, CVector3D& up, CVector3D& right,
|
||||
void CEntity::DrawBar( CVector3D& centre, CVector3D& up, CVector3D& right,
|
||||
float x1, float y1, float x2, float y2,
|
||||
SColour col1, SColour col2, float currVal, float maxVal )
|
||||
{
|
||||
@ -334,7 +334,7 @@ void CEntity::drawBar( CVector3D& centre, CVector3D& up, CVector3D& right,
|
||||
|
||||
/*// Draw the border at full size
|
||||
ogl_tex_bind( g_Selection.m_unitUITextures[m_base->m_barBorder] );
|
||||
drawRect( centre, up, right, x1, y1, x2, y2 );
|
||||
DrawRect( centre, up, right, x1, y1, x2, y2 );
|
||||
ogl_tex_bind( 0 );
|
||||
|
||||
// Make the bar contents slightly smaller than the border
|
||||
@ -346,17 +346,17 @@ void CEntity::drawBar( CVector3D& centre, CVector3D& up, CVector3D& right,
|
||||
// Draw the bar contents
|
||||
float xMid = x2 * fraction + x1 * (1.0f - fraction);
|
||||
glColor3fv( &col1.r );
|
||||
drawRect( centre, up, right, x1, y1, xMid, y2 );
|
||||
DrawRect( centre, up, right, x1, y1, xMid, y2 );
|
||||
glColor3fv( &col2.r );
|
||||
drawRect( centre, up, right, xMid, y1, x2, y2 );
|
||||
DrawRect( centre, up, right, xMid, y1, x2, y2 );
|
||||
}
|
||||
|
||||
void CEntity::renderBars()
|
||||
void CEntity::RenderBars()
|
||||
{
|
||||
if( !m_base->m_barsEnabled || !m_bounds || !m_visible)
|
||||
return;
|
||||
|
||||
snapToGround();
|
||||
SnapToGround();
|
||||
CVector3D centre = m_graphics_position;
|
||||
centre.Y += m_base->m_barOffset;
|
||||
CVector3D up = g_Game->GetView()->GetCamera()->m_Orientation.GetUp();
|
||||
@ -375,16 +375,16 @@ void CEntity::renderBars()
|
||||
float backgroundW = w+2*borderSize;
|
||||
float backgroundH = hasStamina ? 2*h+2*borderSize : h+2*borderSize;
|
||||
ogl_tex_bind( g_Selection.m_unitUITextures[m_base->m_barBorder] );
|
||||
drawRect( centre, up, right, -backgroundW/2, -backgroundH/2, backgroundW/2, backgroundH/2 );
|
||||
DrawRect( centre, up, right, -backgroundW/2, -backgroundH/2, backgroundW/2, backgroundH/2 );
|
||||
ogl_tex_bind( 0 );
|
||||
|
||||
float off = hasStamina ? h/2 : 0;
|
||||
drawBar( centre, up, right, -w/2, off-h/2, w/2, off+h/2,
|
||||
DrawBar( centre, up, right, -w/2, off-h/2, w/2, off+h/2,
|
||||
SColour(0,1,0), SColour(1,0,0), m_healthCurr, m_healthMax );
|
||||
|
||||
if( hasStamina )
|
||||
{
|
||||
drawBar( centre, up, right, -w/2, -h, w/2, 0,
|
||||
DrawBar( centre, up, right, -w/2, -h, w/2, 0,
|
||||
SColour(0,0,1), SColour(0.4f,0.4f,0.1f), m_staminaCurr, m_staminaMax );
|
||||
}
|
||||
|
||||
@ -395,12 +395,12 @@ void CEntity::renderBars()
|
||||
{
|
||||
float size = 2*h + borderSize;
|
||||
ogl_tex_bind( it->second );
|
||||
drawRect( centre, up, right, w/2+borderSize, -size/2, w/2+borderSize+size, size/2 );
|
||||
DrawRect( centre, up, right, w/2+borderSize, -size/2, w/2+borderSize+size, size/2 );
|
||||
ogl_tex_bind( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void CEntity::renderBarBorders()
|
||||
void CEntity::RenderBarBorders()
|
||||
{
|
||||
if( !m_visible )
|
||||
return;
|
||||
@ -409,7 +409,7 @@ void CEntity::renderBarBorders()
|
||||
g_Selection.m_unitUITextures.find(m_base->m_healthBorderName) != g_Selection.m_unitUITextures.end() )
|
||||
{
|
||||
ogl_tex_bind( g_Selection.m_unitUITextures[m_base->m_healthBorderName] );
|
||||
CVector2D pos = getScreenCoords( m_base->m_healthBarHeight );
|
||||
CVector2D pos = GetScreenCoords( m_base->m_healthBarHeight );
|
||||
|
||||
float left = pos.x - m_base->m_healthBorderWidth/2;
|
||||
float right = pos.x + m_base->m_healthBorderWidth/2;
|
||||
@ -431,7 +431,7 @@ void CEntity::renderBarBorders()
|
||||
{
|
||||
ogl_tex_bind( g_Selection.m_unitUITextures[m_base->m_staminaBorderName] );
|
||||
|
||||
CVector2D pos = getScreenCoords( m_base->m_staminaBarHeight );
|
||||
CVector2D pos = GetScreenCoords( m_base->m_staminaBarHeight );
|
||||
float left = pos.x - m_base->m_staminaBorderWidth/2;
|
||||
float right = pos.x + m_base->m_staminaBorderWidth/2;
|
||||
pos.y = g_yres - pos.y;
|
||||
@ -449,7 +449,7 @@ void CEntity::renderBarBorders()
|
||||
}
|
||||
}
|
||||
|
||||
void CEntity::renderHealthBar()
|
||||
void CEntity::RenderHealthBar()
|
||||
{
|
||||
if( !m_bounds || !m_visible )
|
||||
return;
|
||||
@ -460,7 +460,7 @@ void CEntity::renderHealthBar()
|
||||
if(m_healthMax == 0) fraction = 1.0f;
|
||||
else fraction = clamp(m_healthCurr / m_healthMax, 0.0f, 1.0f);
|
||||
|
||||
CVector2D pos = getScreenCoords( m_base->m_healthBarHeight );
|
||||
CVector2D pos = GetScreenCoords( m_base->m_healthBarHeight );
|
||||
float x1 = pos.x - m_base->m_healthBarSize/2;
|
||||
float x2 = pos.x + m_base->m_healthBarSize/2;
|
||||
float y = g_yres - pos.y;
|
||||
@ -485,7 +485,7 @@ void CEntity::renderHealthBar()
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
|
||||
void CEntity::renderStaminaBar()
|
||||
void CEntity::RenderStaminaBar()
|
||||
{
|
||||
if( !m_bounds || !m_visible )
|
||||
return;
|
||||
@ -496,7 +496,7 @@ void CEntity::renderStaminaBar()
|
||||
if(m_staminaMax == 0) fraction = 1.0f;
|
||||
else fraction = clamp(m_staminaCurr / m_staminaMax, 0.0f, 1.0f);
|
||||
|
||||
CVector2D pos = getScreenCoords( m_base->m_staminaBarHeight );
|
||||
CVector2D pos = GetScreenCoords( m_base->m_staminaBarHeight );
|
||||
float x1 = pos.x - m_base->m_staminaBarSize/2;
|
||||
float x2 = pos.x + m_base->m_staminaBarSize/2;
|
||||
float y = g_yres - pos.y;
|
||||
@ -520,7 +520,7 @@ void CEntity::renderStaminaBar()
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
|
||||
void CEntity::renderRank()
|
||||
void CEntity::RenderRank()
|
||||
{
|
||||
if( !m_bounds || !m_visible )
|
||||
return;
|
||||
@ -536,7 +536,7 @@ void CEntity::renderRank()
|
||||
CVector3D above;
|
||||
above.X = m_position.X;
|
||||
above.Z = m_position.Z;
|
||||
above.Y = getAnchorLevel(m_position.X, m_position.Z) + m_base->m_rankHeight;
|
||||
above.Y = GetAnchorLevel(m_position.X, m_position.Z) + m_base->m_rankHeight;
|
||||
camera->GetScreenCoordinates(above, sx, sy);
|
||||
int size = m_base->m_rankWidth/2;
|
||||
|
||||
@ -560,7 +560,7 @@ void CEntity::renderRank()
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void CEntity::renderRallyPoint()
|
||||
void CEntity::RenderRallyPoint()
|
||||
{
|
||||
if( !m_visible )
|
||||
return;
|
||||
|
@ -76,18 +76,18 @@ void CEntity::ScriptingInit()
|
||||
AddMethod<jsval, &CEntity::RegisterDamage>( "registerDamage", 0 );
|
||||
AddMethod<jsval, &CEntity::RegisterOrderChange>( "registerOrderChange", 0 );
|
||||
AddMethod<jsval, &CEntity::GetAttackDirections>( "getAttackDirections", 0 );
|
||||
AddMethod<jsval, &CEntity::FindSector>( "findSector", 4);
|
||||
AddMethod<jsval, &CEntity::FindSector>( "FindSector", 4);
|
||||
AddMethod<jsval, &CEntity::GetHeight>( "getHeight", 0 );
|
||||
AddMethod<jsval, &CEntity::HasRallyPoint>( "hasRallyPoint", 0 );
|
||||
AddMethod<jsval, &CEntity::SetRallyPoint>( "setRallyPoint", 0 );
|
||||
AddMethod<jsval, &CEntity::GetRallyPoint>( "getRallyPoint", 0 );
|
||||
AddMethod<jsval, &CEntity::OnDamaged>( "onDamaged", 1 );
|
||||
AddMethod<jsval, &CEntity::OnDamaged>( "OnDamaged", 1 );
|
||||
AddMethod<jsval, &CEntity::GetVisibleEntities>( "getVisibleEntities", 0 );
|
||||
AddMethod<float, &CEntity::GetDistance>( "getDistance", 1 );
|
||||
AddMethod<jsval, &CEntity::FlattenTerrain>( "flattenTerrain", 0 );
|
||||
|
||||
AddClassProperty( L"traits.id.classes", (GetFn)&CEntity::getClassSet, (SetFn)&CEntity::setClassSet );
|
||||
AddClassProperty( L"template", (CEntityTemplate* CEntity::*)&CEntity::m_base, false, (NotifyFn)&CEntity::loadBase );
|
||||
AddClassProperty( L"traits.id.classes", (GetFn)&CEntity::GetClassSet, (SetFn)&CEntity::SetClassSet );
|
||||
AddClassProperty( L"template", (CEntityTemplate* CEntity::*)&CEntity::m_base, false, (NotifyFn)&CEntity::LoadBase );
|
||||
|
||||
/* Any inherited property MUST be added to EntityTemplate.cpp as well */
|
||||
|
||||
@ -97,12 +97,12 @@ void CEntity::ScriptingInit()
|
||||
AddClassProperty( L"actions.move.run.range", &CEntity::m_runMaxRange );
|
||||
AddClassProperty( L"actions.move.run.regenRate", &CEntity::m_runRegenRate );
|
||||
AddClassProperty( L"actions.move.run.decayRate", &CEntity::m_runDecayRate );
|
||||
AddClassProperty( L"selected", &CEntity::m_selected, false, (NotifyFn)&CEntity::checkSelection );
|
||||
AddClassProperty( L"group", &CEntity::m_grouped, false, (NotifyFn)&CEntity::checkGroup );
|
||||
AddClassProperty( L"selected", &CEntity::m_selected, false, (NotifyFn)&CEntity::CheckSelection );
|
||||
AddClassProperty( L"group", &CEntity::m_grouped, false, (NotifyFn)&CEntity::CheckGroup );
|
||||
AddClassProperty( L"traits.extant", &CEntity::m_extant );
|
||||
AddClassProperty( L"actions.move.turningRadius", &CEntity::m_turningRadius );
|
||||
AddClassProperty( L"position", &CEntity::m_position, false, (NotifyFn)&CEntity::teleport );
|
||||
AddClassProperty( L"orientation", &CEntity::m_orientation, false, (NotifyFn)&CEntity::reorient );
|
||||
AddClassProperty( L"position", &CEntity::m_position, false, (NotifyFn)&CEntity::Teleport );
|
||||
AddClassProperty( L"orientation", &CEntity::m_orientation, false, (NotifyFn)&CEntity::Reorient );
|
||||
AddClassProperty( L"player", (GetFn)&CEntity::JSI_GetPlayer, (SetFn)&CEntity::JSI_SetPlayer );
|
||||
AddClassProperty( L"traits.health.curr", &CEntity::m_healthCurr );
|
||||
AddClassProperty( L"traits.health.max", &CEntity::m_healthMax );
|
||||
@ -113,7 +113,7 @@ void CEntity::ScriptingInit()
|
||||
AddClassProperty( L"traits.stamina.max", &CEntity::m_staminaMax );
|
||||
AddClassProperty( L"traits.rank.name", &CEntity::m_rankName );
|
||||
AddClassProperty( L"traits.vision.los", &CEntity::m_los );
|
||||
AddClassProperty( L"traits.ai.stance.curr", &CEntity::m_stanceName, false, (NotifyFn)&CEntity::stanceChanged );
|
||||
AddClassProperty( L"traits.ai.stance.curr", &CEntity::m_stanceName, false, (NotifyFn)&CEntity::StanceChanged );
|
||||
AddClassProperty( L"lastCombatTime", &CEntity::m_lastCombatTime );
|
||||
AddClassProperty( L"lastRunTime", &CEntity::m_lastRunTime );
|
||||
AddClassProperty( L"building", &CEntity::m_building );
|
||||
@ -153,7 +153,7 @@ JSBool CEntity::Construct( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsva
|
||||
JS_ReportError( cx, "Invalid template identifier" );
|
||||
return( JS_TRUE );
|
||||
}
|
||||
baseEntity = g_EntityTemplateCollection.getTemplate( templateName );
|
||||
baseEntity = g_EntityTemplateCollection.GetTemplate( templateName );
|
||||
}
|
||||
|
||||
if( !baseEntity )
|
||||
@ -198,7 +198,7 @@ JSBool CEntity::Construct( JSContext* cx, JSObject* UNUSED(obj), uint argc, jsva
|
||||
}
|
||||
|
||||
std::set<CStr8> selections; // TODO: let scripts specify selections?
|
||||
HEntity handle = g_EntityManager.create( baseEntity, position, orientation, selections );
|
||||
HEntity handle = g_EntityManager.Create( baseEntity, position, orientation, selections );
|
||||
handle->m_actor->SetPlayerID( player->GetPlayerID() );
|
||||
handle->Initialize();
|
||||
|
||||
@ -343,8 +343,8 @@ bool CEntity::Order( JSContext* cx, uintN argc, jsval* argv, CEntityOrder::EOrde
|
||||
}
|
||||
|
||||
if( !Queued )
|
||||
clearOrders();
|
||||
pushOrder( newOrder );
|
||||
ClearOrders();
|
||||
PushOrder( newOrder );
|
||||
|
||||
return( true );
|
||||
}
|
||||
@ -354,7 +354,7 @@ bool CEntity::Kill( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(arg
|
||||
CEventDeath evt;
|
||||
DispatchEvent( &evt );
|
||||
|
||||
kill(true);
|
||||
Kill(true);
|
||||
|
||||
return( true );
|
||||
}
|
||||
@ -423,7 +423,7 @@ jsval CEntity::GetSpawnPoint( JSContext* UNUSED(cx), uintN argc, jsval* argv )
|
||||
|
||||
// Then step around the edge (clockwise) until a free space is found, or
|
||||
// we've gone all the way around.
|
||||
while( getCollisionObject( &spawn ) )
|
||||
while( GetCollisionObject( &spawn ) )
|
||||
{
|
||||
switch( edge )
|
||||
{
|
||||
@ -468,7 +468,7 @@ jsval CEntity::GetSpawnPoint( JSContext* UNUSED(cx), uintN argc, jsval* argv )
|
||||
return( JSVAL_NULL );
|
||||
spawn.m_pos = pos;
|
||||
}
|
||||
CVector3D rval( pos.x, getAnchorLevel( pos.x, pos.y ), pos.y );
|
||||
CVector3D rval( pos.x, GetAnchorLevel( pos.x, pos.y ), pos.y );
|
||||
return( ToJSVal( rval ) );
|
||||
}
|
||||
else if( m_bounds->m_type == CBoundingObject::BOUND_CIRCLE )
|
||||
@ -484,15 +484,15 @@ jsval CEntity::GetSpawnPoint( JSContext* UNUSED(cx), uintN argc, jsval* argv )
|
||||
{
|
||||
x = m_position.X + radius * cos( ang );
|
||||
y = m_position.Z + radius * sin( ang );
|
||||
spawn.setPosition( x, y );
|
||||
if( !getCollisionObject( &spawn ) )
|
||||
spawn.SetPosition( x, y );
|
||||
if( !GetCollisionObject( &spawn ) )
|
||||
break;
|
||||
}
|
||||
if( ang < ang_end )
|
||||
{
|
||||
// Found a satisfactory position...
|
||||
CVector3D pos( x, 0, y );
|
||||
pos.Y = getAnchorLevel( x, y );
|
||||
pos.Y = GetAnchorLevel( x, y );
|
||||
return( ToJSVal( pos ) );
|
||||
}
|
||||
else
|
||||
@ -751,11 +751,11 @@ jsval CEntity::RegisterDamage( JSContext* cx, uintN argc, jsval* argv )
|
||||
CEntity* inflictor = ToNative<CEntity>( argv[0] );
|
||||
CVector2D up(1.0f, 0.0f);
|
||||
CVector2D pos = CVector2D( inflictor->m_position.X, inflictor->m_position.Z );
|
||||
CVector2D posDelta = (pos - m_position).normalize();
|
||||
CVector2D posDelta = (pos - m_position).Normalize();
|
||||
|
||||
float angle = acosf( up.dot(posDelta) );
|
||||
float angle = acosf( up.Dot(posDelta) );
|
||||
//Find what section it is between and "activate" it
|
||||
int sector = findSector(m_base->m_sectorDivs, angle, DEGTORAD(360.0f))-1;
|
||||
int sector = FindSector(m_base->m_sectorDivs, angle, DEGTORAD(360.0f))-1;
|
||||
m_sectorValues[sector]=true;
|
||||
return JS_TRUE;
|
||||
}
|
||||
@ -766,11 +766,11 @@ jsval CEntity::RegisterOrderChange( JSContext* cx, uintN argc, jsval* argv )
|
||||
|
||||
CVector2D up(1.0f, 0.0f);
|
||||
CVector2D pos = CVector2D( idleEntity->m_position.X, idleEntity->m_position.Z );
|
||||
CVector2D posDelta = (pos - m_position).normalize();
|
||||
CVector2D posDelta = (pos - m_position).Normalize();
|
||||
|
||||
float angle = acosf( up.dot(posDelta) );
|
||||
float angle = acosf( up.Dot(posDelta) );
|
||||
//Find what section it is between and "deactivate" it
|
||||
int sector = std::max(0, findSector(m_base->m_sectorDivs, angle, DEGTORAD(360.0f)));
|
||||
int sector = std::max(0, FindSector(m_base->m_sectorDivs, angle, DEGTORAD(360.0f)));
|
||||
m_sectorValues[sector]=false;
|
||||
return JS_TRUE;
|
||||
}
|
||||
@ -796,11 +796,11 @@ jsval CEntity::FindSector( JSContext* cx, uintN argc, jsval* argv )
|
||||
float maxAngle = ToPrimitive<float>( argv[2] );
|
||||
bool negative = ToPrimitive<bool>( argv[3] );
|
||||
|
||||
return ToJSVal( findSector(divs, angle, maxAngle, negative) );
|
||||
return ToJSVal( FindSector(divs, angle, maxAngle, negative) );
|
||||
}
|
||||
catch( PSERROR_Scripting_ConversionFailed )
|
||||
{
|
||||
JS_ReportError( cx, "Invalid parameters for findSector" );
|
||||
JS_ReportError( cx, "Invalid parameters for FindSector" );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -824,7 +824,7 @@ jsval CEntity::OnDamaged( JSContext* cx, uintN argc, jsval* argv )
|
||||
{
|
||||
JSU_REQUIRE_PARAMS_CPP(1);
|
||||
CEntity* damageSource = ToNative<CEntity>( argv[0] );
|
||||
m_stance->onDamaged( damageSource );
|
||||
m_stance->OnDamaged( damageSource );
|
||||
return JSVAL_VOID;
|
||||
}
|
||||
|
||||
@ -844,7 +844,7 @@ float CEntity::GetDistance( JSContext* cx, uintN argc, jsval* argv )
|
||||
CEntity* target = ToNative<CEntity>( argv[0] );
|
||||
if( !target )
|
||||
return -1.0f;
|
||||
return this->distance2D( target );
|
||||
return this->Distance2D( target );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -896,6 +896,6 @@ jsval CEntity::FlattenTerrain( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval*
|
||||
// points[i].y *= sin*circle.Z;
|
||||
//}
|
||||
g_Game->GetWorld()->GetTerrain()->FlattenArea(pos.X-xDiff, pos.X+xDiff, pos.Z-yDiff, pos.Z+yDiff);
|
||||
snapToGround();
|
||||
SnapToGround();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ enum EGotoSituation
|
||||
STANCE_DISALLOWS
|
||||
};
|
||||
|
||||
bool CEntity::shouldRun(float distance)
|
||||
bool CEntity::ShouldRun(float distance)
|
||||
{
|
||||
if( !entf_get(ENTF_SHOULD_RUN) )
|
||||
return false;
|
||||
@ -53,9 +53,9 @@ bool CEntity::shouldRun(float distance)
|
||||
return true;
|
||||
}
|
||||
|
||||
float CEntity::chooseMovementSpeed( float distance )
|
||||
float CEntity::ChooseMovementSpeed( float distance )
|
||||
{
|
||||
bool should_run = shouldRun(distance);
|
||||
bool should_run = ShouldRun(distance);
|
||||
|
||||
float speed = should_run? m_runSpeed : m_speed;
|
||||
const char* anim_name = should_run? "run" : "walk";
|
||||
@ -83,7 +83,7 @@ float CEntity::chooseMovementSpeed( float distance )
|
||||
|
||||
// Does all the shared processing for line-of-sight gotos
|
||||
|
||||
uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis, HEntity& collide )
|
||||
uint CEntity::ProcessGotoHelper( CEntityOrder* current, size_t timestep_millis, HEntity& collide )
|
||||
{
|
||||
float timestep=timestep_millis/1000.0f;
|
||||
|
||||
@ -91,7 +91,7 @@ uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis,
|
||||
delta.x = (float)current->m_target_location.x - m_position.X;
|
||||
delta.y = (float)current->m_target_location.y - m_position.Z;
|
||||
|
||||
float len = delta.length();
|
||||
float len = delta.Length();
|
||||
|
||||
if( len < 0.01f )
|
||||
return( ALREADY_AT_DESTINATION );
|
||||
@ -99,7 +99,7 @@ uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis,
|
||||
// Curve smoothing.
|
||||
// Here there be trig.
|
||||
|
||||
float scale = chooseMovementSpeed( len ) * timestep;
|
||||
float scale = ChooseMovementSpeed( len ) * timestep;
|
||||
|
||||
// Note: Easy optimization: flag somewhere that this unit
|
||||
// is already pointing the way, and don't do this
|
||||
@ -147,10 +147,10 @@ uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis,
|
||||
m_orientation.Y = m_targetorientation;
|
||||
}
|
||||
|
||||
updateXZOrientation();
|
||||
UpdateXZOrientation();
|
||||
|
||||
if( m_bounds && m_bounds->m_type == CBoundingObject::BOUND_OABB )
|
||||
((CBoundingBox*)m_bounds)->setOrientation( m_ahead );
|
||||
((CBoundingBox*)m_bounds)->SetOrientation( m_ahead );
|
||||
|
||||
EGotoSituation rc = NORMAL;
|
||||
|
||||
@ -169,13 +169,13 @@ uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis,
|
||||
|
||||
if( m_bounds )
|
||||
{
|
||||
m_bounds->setPosition( m_position.X, m_position.Z );
|
||||
m_bounds->SetPosition( m_position.X, m_position.Z );
|
||||
|
||||
// For now, ignore passThroughAllies for low-level movement (but leave it on for long-range
|
||||
// pathfinding); ideally we will enable pass-through-allies only for the long-range pathing
|
||||
// and when the unit is moving to assume its place in a formation, since it looks bad to have
|
||||
// units stand on each other otherwise.
|
||||
collide = getCollisionObject( this, false );
|
||||
collide = GetCollisionObject( this, false );
|
||||
|
||||
if( collide )
|
||||
{
|
||||
@ -186,7 +186,7 @@ uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis,
|
||||
|
||||
// Is it too late to avoid the collision?
|
||||
|
||||
if( collide->m_bounds->intersects( m_bounds ) )
|
||||
if( collide->m_bounds->Intersects( m_bounds ) )
|
||||
{
|
||||
// Yes. Oh dear. That can't be good.
|
||||
// This really shouldn't happen in the current build.
|
||||
@ -199,7 +199,7 @@ uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis,
|
||||
}
|
||||
|
||||
// No. Is our destination within the obstacle?
|
||||
if( collide->m_bounds->contains( current->m_target_location ) )
|
||||
if( collide->m_bounds->Contains( current->m_target_location ) )
|
||||
return( COLLISION_WITH_DESTINATION );
|
||||
|
||||
// No. Are we nearing our destination, do we wish to stop there, and is it obstructed?
|
||||
@ -207,7 +207,7 @@ uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis,
|
||||
if( ( m_orderQueue.size() == 1 ) && ( len <= 10.0f ) )
|
||||
{
|
||||
CBoundingCircle destinationObs( current->m_target_location.x, current->m_target_location.y, m_bounds->m_radius, 0.0f );
|
||||
if( getCollisionObject( &destinationObs ) )
|
||||
if( GetCollisionObject( &destinationObs ) )
|
||||
{
|
||||
// Yes. (Chances are a bunch of units were tasked to the same destination)
|
||||
return( COLLISION_NEAR_DESTINATION );
|
||||
@ -221,14 +221,14 @@ uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis,
|
||||
}
|
||||
|
||||
// Will we step off the map?
|
||||
if( !g_Game->GetWorld()->GetTerrain()->isOnMap( m_position.X, m_position.Z ) )
|
||||
if( !g_Game->GetWorld()->GetTerrain()->IsOnMap( m_position.X, m_position.Z ) )
|
||||
{
|
||||
// Yes. That's not a particularly good idea, either.
|
||||
|
||||
m_position.X -= delta.x;
|
||||
m_position.Z -= delta.y;
|
||||
if( m_bounds )
|
||||
m_bounds->setPosition( m_position.X, m_position.Z );
|
||||
m_bounds->SetPosition( m_position.X, m_position.Z );
|
||||
|
||||
// All things being equal, we should only get here while on a collision path
|
||||
// (No destination should be off the map)
|
||||
@ -237,12 +237,12 @@ uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis,
|
||||
}
|
||||
|
||||
// Does our stance not allow us to go there?
|
||||
if( current->m_source==CEntityOrder::SOURCE_UNIT_AI && !m_stance->checkMovement( m_position ) )
|
||||
if( current->m_source==CEntityOrder::SOURCE_UNIT_AI && !m_stance->CheckMovement( m_position ) )
|
||||
{
|
||||
m_position.X -= delta.x;
|
||||
m_position.Z -= delta.y;
|
||||
if( m_bounds )
|
||||
m_bounds->setPosition( m_position.X, m_position.Z );
|
||||
m_bounds->SetPosition( m_position.X, m_position.Z );
|
||||
|
||||
return( STANCE_DISALLOWS );
|
||||
}
|
||||
@ -253,16 +253,16 @@ uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis,
|
||||
}
|
||||
|
||||
|
||||
bool CEntity::processGotoNoPathing( CEntityOrder* current, size_t timestep_millis )
|
||||
bool CEntity::ProcessGotoNoPathing( CEntityOrder* current, size_t timestep_millis )
|
||||
{
|
||||
HEntity collide;
|
||||
switch( processGotoHelper( current, timestep_millis, collide ) )
|
||||
switch( ProcessGotoHelper( current, timestep_millis, collide ) )
|
||||
{
|
||||
case ALREADY_AT_DESTINATION:
|
||||
// If on a collision path; decide where to go next. Otherwise, proceed to the next waypoint.
|
||||
if( current->m_type == CEntityOrder::ORDER_GOTO_COLLISION )
|
||||
{
|
||||
repath();
|
||||
Repath();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -295,8 +295,8 @@ bool CEntity::processGotoNoPathing( CEntityOrder* current, size_t timestep_milli
|
||||
delta = interval / r;
|
||||
theta += delta;
|
||||
r += ( interval * delta ) / ( 2 * PI );
|
||||
destinationObs.setPosition( _x + r * cosf( theta ), _y + r * sinf( theta ) );
|
||||
if( !getCollisionObject( &destinationObs ) ) break;
|
||||
destinationObs.SetPosition( _x + r * cosf( theta ), _y + r * sinf( theta ) );
|
||||
if( !GetCollisionObject( &destinationObs ) ) break;
|
||||
}
|
||||
|
||||
// Reset our destination
|
||||
@ -318,7 +318,7 @@ bool CEntity::processGotoNoPathing( CEntityOrder* current, size_t timestep_milli
|
||||
// Which is the shortest diversion, going left or right?
|
||||
// (Weight a little towards the right, to stop both units dodging the same way)
|
||||
|
||||
if( ( collide->m_bounds->m_pos - m_bounds->m_pos ).dot( right ) < 1 )
|
||||
if( ( collide->m_bounds->m_pos - m_bounds->m_pos ).Dot( right ) < 1 )
|
||||
{
|
||||
// Turn right.
|
||||
avoidancePosition = collide->m_bounds->m_pos + right * ( collide->m_bounds->m_radius + m_bounds->m_radius * 2.5f );
|
||||
@ -339,7 +339,7 @@ bool CEntity::processGotoNoPathing( CEntityOrder* current, size_t timestep_milli
|
||||
return( false );
|
||||
}
|
||||
case WOULD_LEAVE_MAP:
|
||||
// Just stop here, repath if necessary.
|
||||
// Just stop here, Repath if necessary.
|
||||
m_orderQueue.pop_front();
|
||||
//entf_clear(ENTF_IS_RUNNING);
|
||||
//entf_clear(ENTF_SHOULD_RUN);
|
||||
@ -354,14 +354,14 @@ bool CEntity::processGotoNoPathing( CEntityOrder* current, size_t timestep_milli
|
||||
}
|
||||
|
||||
// Handles processing common to (at the moment) gather and melee attack actions
|
||||
bool CEntity::processContactAction( CEntityOrder* current, size_t UNUSED(timestep_millis), CEntityOrder::EOrderType transition, SEntityAction* action )
|
||||
bool CEntity::ProcessContactAction( CEntityOrder* current, size_t UNUSED(timestep_millis), CEntityOrder::EOrderType transition, SEntityAction* action )
|
||||
{
|
||||
HEntity target = current->m_target_entity;
|
||||
|
||||
if( !target || !target->m_extant )
|
||||
{
|
||||
popOrder();
|
||||
if( m_orderQueue.empty() && target.isValid() )
|
||||
PopOrder();
|
||||
if( m_orderQueue.empty() && target.IsValid() )
|
||||
{
|
||||
CEventTargetExhausted evt( target, action->m_Id );
|
||||
DispatchEvent( &evt );
|
||||
@ -372,12 +372,12 @@ bool CEntity::processContactAction( CEntityOrder* current, size_t UNUSED(timeste
|
||||
if( current->m_source != CEntityOrder::SOURCE_TRIGGERS &&
|
||||
g_Game->GetWorld()->GetLOSManager()->GetUnitStatus( target, m_player ) == UNIT_HIDDEN )
|
||||
{
|
||||
popOrder();
|
||||
PopOrder();
|
||||
return false;
|
||||
}
|
||||
|
||||
current->m_target_location = target->m_position;
|
||||
float Distance = distance2D(current->m_target_location);
|
||||
float Distance = Distance2D(current->m_target_location);
|
||||
|
||||
if( Distance < action->m_MaxRange )
|
||||
{
|
||||
@ -387,24 +387,24 @@ bool CEntity::processContactAction( CEntityOrder* current, size_t UNUSED(timeste
|
||||
}
|
||||
else
|
||||
{
|
||||
if( current->m_source == CEntityOrder::SOURCE_UNIT_AI && !m_stance->allowsMovement() )
|
||||
if( current->m_source == CEntityOrder::SOURCE_UNIT_AI && !m_stance->AllowsMovement() )
|
||||
{
|
||||
popOrder();
|
||||
PopOrder();
|
||||
return false; // We're not allowed to move at all by the current stance
|
||||
}
|
||||
|
||||
chooseMovementSpeed( Distance );
|
||||
ChooseMovementSpeed( Distance );
|
||||
|
||||
// The pathfinder will push its result back into this unit's queue and
|
||||
// add back the current order at the end with the transition type.
|
||||
current->m_type = transition;
|
||||
g_Pathfinder.requestContactPath( me, current, action->m_MaxRange );
|
||||
g_Pathfinder.RequestContactPath( me, current, action->m_MaxRange );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t timestep_millis, const CStr& animation, CScriptEvent* contactEvent, SEntityAction* action )
|
||||
bool CEntity::ProcessContactActionNoPathing( CEntityOrder* current, size_t timestep_millis, const CStr& animation, CScriptEvent* contactEvent, SEntityAction* action )
|
||||
{
|
||||
HEntity target = current->m_target_entity;
|
||||
|
||||
@ -423,8 +423,8 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times
|
||||
entf_clear(ENTF_IS_RUNNING);
|
||||
entf_clear(ENTF_SHOULD_RUN);
|
||||
m_actor->SetAnimationState( "idle" );
|
||||
popOrder();
|
||||
if( m_orderQueue.empty() && target.isValid() )
|
||||
PopOrder();
|
||||
if( m_orderQueue.empty() && target.IsValid() )
|
||||
{
|
||||
CEventTargetExhausted evt( target, action->m_Id );
|
||||
DispatchEvent( &evt );
|
||||
@ -449,8 +449,8 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times
|
||||
if( !target || !target->m_extant
|
||||
|| g_Game->GetWorld()->GetLOSManager()->GetUnitStatus( target, m_player ) == UNIT_HIDDEN )
|
||||
{
|
||||
popOrder();
|
||||
if( m_orderQueue.empty() && target.isValid() )
|
||||
PopOrder();
|
||||
if( m_orderQueue.empty() && target.IsValid() )
|
||||
{
|
||||
CEventTargetExhausted evt( target, action->m_Id );
|
||||
DispatchEvent( &evt );
|
||||
@ -462,7 +462,7 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times
|
||||
}
|
||||
|
||||
CVector2D delta = CVector2D(target->m_position) - CVector2D(m_position);
|
||||
float deltaLength = delta.length();
|
||||
float deltaLength = delta.Length();
|
||||
|
||||
float adjRange = action->m_MaxRange + m_bounds->m_radius + target->m_bounds->m_radius;
|
||||
|
||||
@ -472,21 +472,21 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times
|
||||
if( delta.within( adjMinRange ) )
|
||||
{
|
||||
// Too close... avoid it if allowed by the current stance.
|
||||
if( current->m_source == CEntityOrder::SOURCE_UNIT_AI && !m_stance->allowsMovement() )
|
||||
if( current->m_source == CEntityOrder::SOURCE_UNIT_AI && !m_stance->AllowsMovement() )
|
||||
{
|
||||
popOrder();
|
||||
PopOrder();
|
||||
m_actor->SetAnimationState( "idle" );
|
||||
return false; // We're not allowed to move at all by the current stance
|
||||
}
|
||||
|
||||
entf_set(ENTF_SHOULD_RUN);
|
||||
chooseMovementSpeed( action->m_MinRange );
|
||||
ChooseMovementSpeed( action->m_MinRange );
|
||||
|
||||
// The pathfinder will push its result in front of the current order
|
||||
if( !g_Pathfinder.requestAvoidPath( me, current, action->m_MinRange + 2.0f ) )
|
||||
if( !g_Pathfinder.RequestAvoidPath( me, current, action->m_MinRange + 2.0f ) )
|
||||
{
|
||||
m_actor->SetAnimationState( "idle" ); // Nothing we can do.. maybe we'll find a better target
|
||||
popOrder();
|
||||
PopOrder();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -496,22 +496,22 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times
|
||||
if( !delta.within( adjRange ) )
|
||||
{
|
||||
// Too far away at the moment, chase after the target if allowed...
|
||||
if( current->m_source == CEntityOrder::SOURCE_UNIT_AI && !m_stance->allowsMovement() )
|
||||
if( current->m_source == CEntityOrder::SOURCE_UNIT_AI && !m_stance->AllowsMovement() )
|
||||
{
|
||||
popOrder();
|
||||
PopOrder();
|
||||
return false;
|
||||
}
|
||||
|
||||
// We're aiming to end up at a location just inside our maximum range
|
||||
// (is this good enough?)
|
||||
delta = delta.normalize() * ( adjRange - m_bounds->m_radius );
|
||||
delta = delta.Normalize() * ( adjRange - m_bounds->m_radius );
|
||||
|
||||
chooseMovementSpeed(deltaLength);
|
||||
ChooseMovementSpeed(deltaLength);
|
||||
|
||||
current->m_target_location = (CVector2D)target->m_position - delta;
|
||||
|
||||
HEntity collide;
|
||||
switch( processGotoHelper( current, timestep_millis, collide ) )
|
||||
switch( ProcessGotoHelper( current, timestep_millis, collide ) )
|
||||
{
|
||||
case ALREADY_AT_DESTINATION:
|
||||
case REACHED_DESTINATION:
|
||||
@ -540,7 +540,7 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times
|
||||
// Which is the shortest diversion, going left or right?
|
||||
// (Weight a little towards the right, to stop both units dodging the same way)
|
||||
|
||||
if( ( collide->m_bounds->m_pos - m_bounds->m_pos ).dot( right ) < 1 )
|
||||
if( ( collide->m_bounds->m_pos - m_bounds->m_pos ).Dot( right ) < 1 )
|
||||
{
|
||||
// Turn right.
|
||||
avoidancePosition = collide->m_bounds->m_pos + right * ( collide->m_bounds->m_radius + m_bounds->m_radius * 2.5f );
|
||||
@ -564,7 +564,7 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times
|
||||
{
|
||||
// Close enough, but turn to face them.
|
||||
m_orientation.Y = atan2( delta.x, delta.y );
|
||||
m_ahead = delta.normalize();
|
||||
m_ahead = delta.Normalize();
|
||||
entf_clear(ENTF_IS_RUNNING);
|
||||
}
|
||||
|
||||
@ -576,17 +576,17 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times
|
||||
return( false );
|
||||
}
|
||||
|
||||
bool CEntity::processGeneric( CEntityOrder* current, size_t timestep_millis )
|
||||
bool CEntity::ProcessGeneric( CEntityOrder* current, size_t timestep_millis )
|
||||
{
|
||||
if( m_actions.find( current->m_action ) == m_actions.end() )
|
||||
{
|
||||
return false; // we've been tasked as part of a group but we can't do this action
|
||||
}
|
||||
SEntityAction& action_obj = m_actions[current->m_action];
|
||||
return( processContactAction( current, timestep_millis, CEntityOrder::ORDER_GENERIC_NOPATHING, &action_obj ) );
|
||||
return( ProcessContactAction( current, timestep_millis, CEntityOrder::ORDER_GENERIC_NOPATHING, &action_obj ) );
|
||||
}
|
||||
|
||||
bool CEntity::processGenericNoPathing( CEntityOrder* current, size_t timestep_millis )
|
||||
bool CEntity::ProcessGenericNoPathing( CEntityOrder* current, size_t timestep_millis )
|
||||
{
|
||||
if( m_actions.find( current->m_action ) == m_actions.end() )
|
||||
{
|
||||
@ -595,10 +595,10 @@ bool CEntity::processGenericNoPathing( CEntityOrder* current, size_t timestep_mi
|
||||
CEventGeneric evt( current->m_target_entity, current->m_action );
|
||||
if( !m_actor ) return( false );
|
||||
SEntityAction& action_obj = m_actions[current->m_action];
|
||||
return( processContactActionNoPathing( current, timestep_millis, action_obj.m_Animation, &evt, &action_obj ) );
|
||||
return( ProcessContactActionNoPathing( current, timestep_millis, action_obj.m_Animation, &evt, &action_obj ) );
|
||||
}
|
||||
|
||||
bool CEntity::processGoto( CEntityOrder* current, size_t UNUSED(timestep_millis) )
|
||||
bool CEntity::ProcessGoto( CEntityOrder* current, size_t UNUSED(timestep_millis) )
|
||||
{
|
||||
// float timestep=timestep_millis/1000.0f;
|
||||
// janwas: currently unused
|
||||
@ -607,7 +607,7 @@ bool CEntity::processGoto( CEntityOrder* current, size_t UNUSED(timestep_millis)
|
||||
CVector2D pos( m_position.X, m_position.Z );
|
||||
CVector2D path_to = current->m_target_location;
|
||||
m_orderQueue.pop_front();
|
||||
float Distance = ( path_to - pos ).length();
|
||||
float Distance = ( path_to - pos ).Length();
|
||||
|
||||
// Let's just check we're going somewhere...
|
||||
if( Distance < 0.1f )
|
||||
@ -617,21 +617,21 @@ bool CEntity::processGoto( CEntityOrder* current, size_t UNUSED(timestep_millis)
|
||||
return( false );
|
||||
}
|
||||
|
||||
chooseMovementSpeed( Distance );
|
||||
ChooseMovementSpeed( Distance );
|
||||
|
||||
// The pathfinder will push its result back into this unit's queue.
|
||||
|
||||
g_Pathfinder.requestPath( me, path_to, current->m_source );
|
||||
g_Pathfinder.RequestPath( me, path_to, current->m_source );
|
||||
|
||||
return( true );
|
||||
}
|
||||
|
||||
bool CEntity::processGotoWaypoint( CEntityOrder* current, size_t UNUSED(timestep_milli), bool contact )
|
||||
bool CEntity::ProcessGotoWaypoint( CEntityOrder* current, size_t UNUSED(timestep_milli), bool contact )
|
||||
{
|
||||
CVector2D pos( m_position.X, m_position.Z );
|
||||
CVector2D path_to = current->m_target_location;
|
||||
m_orderQueue.pop_front();
|
||||
float Distance = ( path_to - pos ).length();
|
||||
float Distance = ( path_to - pos ).Length();
|
||||
|
||||
// Let's just check we're going somewhere...
|
||||
if( Distance < 0.1f )
|
||||
@ -641,14 +641,14 @@ bool CEntity::processGotoWaypoint( CEntityOrder* current, size_t UNUSED(timestep
|
||||
return( false );
|
||||
}
|
||||
|
||||
chooseMovementSpeed( Distance );
|
||||
ChooseMovementSpeed( Distance );
|
||||
|
||||
g_Pathfinder.requestLowLevelPath( me, path_to, contact, current->m_pathfinder_radius, current->m_source );
|
||||
g_Pathfinder.RequestLowLevelPath( me, path_to, contact, current->m_pathfinder_radius, current->m_source );
|
||||
|
||||
return( true );
|
||||
}
|
||||
|
||||
bool CEntity::processPatrol( CEntityOrder* current, size_t UNUSED(timestep_millis) )
|
||||
bool CEntity::ProcessPatrol( CEntityOrder* current, size_t UNUSED(timestep_millis) )
|
||||
{
|
||||
// float timestep=timestep_millis/1000.0f;
|
||||
// janwas: currently unused
|
||||
@ -670,7 +670,7 @@ bool CEntity::processPatrol( CEntityOrder* current, size_t UNUSED(timestep_milli
|
||||
return( true );
|
||||
}
|
||||
|
||||
bool CEntity::processProduce( CEntityOrder* order )
|
||||
bool CEntity::ProcessProduce( CEntityOrder* order )
|
||||
{
|
||||
CEventStartProduction evt( order->m_produce_type, order->m_produce_name );
|
||||
if( DispatchEvent( &evt ) && evt.GetTime() >= 0 )
|
||||
|
@ -55,7 +55,7 @@ void CClassSet::Rebuild()
|
||||
m_Members = newMembers;
|
||||
}
|
||||
|
||||
CStrW CClassSet::getMemberList()
|
||||
CStrW CClassSet::GetMemberList()
|
||||
{
|
||||
Set::iterator it = m_Members.begin();
|
||||
CStrW result = L"";
|
||||
@ -68,7 +68,7 @@ CStrW CClassSet::getMemberList()
|
||||
return result;
|
||||
}
|
||||
|
||||
void CClassSet::setFromMemberList(const CStrW& list)
|
||||
void CClassSet::SetFromMemberList(const CStrW& list)
|
||||
{
|
||||
CStr entry;
|
||||
CStr temp = list;
|
||||
|
@ -36,8 +36,8 @@ public:
|
||||
inline void SetParent(CClassSet* Parent)
|
||||
{ m_Parent = Parent; Rebuild(); }
|
||||
|
||||
CStrW getMemberList();
|
||||
void setFromMemberList(const CStrW& list);
|
||||
CStrW GetMemberList();
|
||||
void SetFromMemberList(const CStrW& list);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user