Add support for const methods in components and make those that can be const const.
Reviewed By: Itms Differential Revision: https://code.wildfiregames.com/D75 This was SVN commit r19156.
This commit is contained in:
parent
678e082230
commit
be1a205f91
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -220,7 +220,7 @@ public:
|
||||
/**
|
||||
* Rotate the vector by the given angle (anticlockwise).
|
||||
*/
|
||||
CFixedVector2D Rotate(fixed angle)
|
||||
CFixedVector2D Rotate(fixed angle) const
|
||||
{
|
||||
fixed s, c;
|
||||
sincos_approx(angle, s, c);
|
||||
|
@ -212,7 +212,7 @@ bool CTemplateLoader::TemplateExists(const std::string& templateName) const
|
||||
return VfsFileExists(VfsPath(TEMPLATE_ROOT) / wstring_from_utf8(baseName + ".xml"));
|
||||
}
|
||||
|
||||
std::vector<std::string> CTemplateLoader::FindPlaceableTemplates(const std::string& path, bool includeSubdirectories, ETemplatesType templatesType, ScriptInterface& scriptInterface)
|
||||
std::vector<std::string> CTemplateLoader::FindPlaceableTemplates(const std::string& path, bool includeSubdirectories, ETemplatesType templatesType, ScriptInterface& scriptInterface) const
|
||||
{
|
||||
if (templatesType != SIMULATION_TEMPLATES && templatesType != ACTOR_TEMPLATES && templatesType != ALL_TEMPLATES)
|
||||
{
|
||||
@ -295,7 +295,7 @@ std::vector<std::string> CTemplateLoader::FindPlaceableTemplates(const std::stri
|
||||
return templates;
|
||||
}
|
||||
|
||||
std::vector<std::string> CTemplateLoader::FindTemplates(const std::string& path, bool includeSubdirectories, ETemplatesType templatesType)
|
||||
std::vector<std::string> CTemplateLoader::FindTemplates(const std::string& path, bool includeSubdirectories, ETemplatesType templatesType) const
|
||||
{
|
||||
std::vector<std::string> templates;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -63,9 +63,9 @@ public:
|
||||
* Returns a list of strings that could be validly passed as @c templateName to LoadTemplateFile.
|
||||
* (This includes "actor|foo" etc names).
|
||||
*/
|
||||
std::vector<std::string> FindTemplates(const std::string& path, bool includeSubdirectories, ETemplatesType templatesType);
|
||||
std::vector<std::string> FindTemplates(const std::string& path, bool includeSubdirectories, ETemplatesType templatesType) const;
|
||||
|
||||
std::vector<std::string> FindPlaceableTemplates(const std::string& path, bool includeSubdirectories, ETemplatesType templatesType, ScriptInterface& scriptInterface);
|
||||
std::vector<std::string> FindPlaceableTemplates(const std::string& path, bool includeSubdirectories, ETemplatesType templatesType, ScriptInterface& scriptInterface) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -33,7 +33,7 @@ template <typename T> struct MaybeRef;
|
||||
// Some other things
|
||||
#define TYPED_ARGS(z, i, data) , T##i a##i
|
||||
#define TYPED_ARGS_MAYBE_REF(z, i, data) , typename MaybeRef<T##i>::Type a##i
|
||||
#define TYPED_ARGS_CONST_REF(z, i, data) const T##i& a##i,
|
||||
#define TYPED_ARGS_CONST_REF(z, i, data) , const T##i& a##i
|
||||
|
||||
// TODO: We allow optional parameters when the C++ type can be converted from JS::UndefinedValue.
|
||||
// FromJSVal is expected to either set a##i or return false (otherwise we could get undefined
|
||||
@ -62,7 +62,7 @@ template <typename T> struct MaybeRef;
|
||||
#define T0_TAIL_MAYBE_REF(z, i) BOOST_PP_REPEAT_##z (i, NUMBERED_LIST_TAIL_MAYBE_REF, T) // ", const T0&, T1"
|
||||
#define T0_A0(z, i) BOOST_PP_REPEAT_##z (i, TYPED_ARGS, ~) // ",T0 a0, T1 a1"
|
||||
#define T0_A0_MAYBE_REF(z, i) BOOST_PP_REPEAT_##z (i, TYPED_ARGS_MAYBE_REF, ~) // ",const T0& a0, T1 a1"
|
||||
#define T0_A0_CONST_REF(z, i) BOOST_PP_REPEAT_##z (i, TYPED_ARGS_CONST_REF, ~) // ", const T0& a0, const T1& a1, "
|
||||
#define T0_A0_TAIL_CONST_REF(z, i) BOOST_PP_REPEAT_##z (i, TYPED_ARGS_CONST_REF, ~) // ", const T0& a0, const T1& a1"
|
||||
#define A0(z, i) BOOST_PP_REPEAT_##z (i, NUMBERED_LIST_BALANCED, a) // "a0, a1"
|
||||
#define A0_TAIL(z, i) BOOST_PP_REPEAT_##z (i, NUMBERED_LIST_TAIL, a) // ", a0, a1"
|
||||
|
||||
@ -90,6 +90,13 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
#undef OVERLOADS
|
||||
|
||||
// const methods
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template <typename R, TYPENAME_T0_HEAD(z,i) JSClass* CLS, typename TC, R (TC::*fptr) ( T0_MAYBE_REF(z,i) ) const> \
|
||||
static bool callMethodConst(JSContext* cx, uint argc, jsval* vp);
|
||||
BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
#undef OVERLOADS
|
||||
|
||||
// Argument-number counter
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template <int dummy TYPENAME_T0_TAIL(z,i)> /* add a dummy parameter so we still compile with 0 template args */ \
|
||||
@ -100,7 +107,7 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
// Call the named property on the given object
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template <typename R TYPENAME_T0_TAIL(z, i)> \
|
||||
bool CallFunction(JS::HandleValue val, const char* name, T0_A0_CONST_REF(z,i) R& ret);
|
||||
bool CallFunction(JS::HandleValue val, const char* name T0_A0_TAIL_CONST_REF(z,i), R& ret) const;
|
||||
BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
#undef OVERLOADS
|
||||
|
||||
@ -109,7 +116,7 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
// (as people would expect it to work based on the SpiderMonkey rooting guide).
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template <typename R TYPENAME_T0_TAIL(z, i)> \
|
||||
bool CallFunction(JS::HandleValue val, const char* name, T0_A0_CONST_REF(z,i) JS::Rooted<R>* ret);
|
||||
bool CallFunction(JS::HandleValue val, const char* name T0_A0_TAIL_CONST_REF(z,i), JS::Rooted<R>* ret) const;
|
||||
BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
#undef OVERLOADS
|
||||
|
||||
@ -117,7 +124,7 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
// without requiring implicit conversion.
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template <typename R TYPENAME_T0_TAIL(z, i)> \
|
||||
bool CallFunction(JS::HandleValue val, const char* name, T0_A0_CONST_REF(z,i) JS::MutableHandle<R> ret);
|
||||
bool CallFunction(JS::HandleValue val, const char* name T0_A0_TAIL_CONST_REF(z,i), JS::MutableHandle<R> ret) const;
|
||||
BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
#undef OVERLOADS
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -120,7 +120,8 @@ struct ScriptInterface_NativeMethodWrapper<void, TC> {
|
||||
// JSFastNative-compatible function that wraps the function identified in the template argument list
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template <typename R, TYPENAME_T0_HEAD(z,i) R (*fptr) ( ScriptInterface::CxPrivate* T0_TAIL_MAYBE_REF(z,i) )> \
|
||||
bool ScriptInterface::call(JSContext* cx, uint argc, jsval* vp) { \
|
||||
bool ScriptInterface::call(JSContext* cx, uint argc, jsval* vp) \
|
||||
{ \
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \
|
||||
JSAutoRequest rq(cx); \
|
||||
BOOST_PP_REPEAT_##z (i, CONVERT_ARG, ~) \
|
||||
@ -135,7 +136,8 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
// Same idea but for methods
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template <typename R, TYPENAME_T0_HEAD(z,i) JSClass* CLS, typename TC, R (TC::*fptr) ( T0_MAYBE_REF(z,i) )> \
|
||||
bool ScriptInterface::callMethod(JSContext* cx, uint argc, jsval* vp) { \
|
||||
bool ScriptInterface::callMethod(JSContext* cx, uint argc, jsval* vp) \
|
||||
{ \
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \
|
||||
JSAutoRequest rq(cx); \
|
||||
JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp)); \
|
||||
@ -151,11 +153,31 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
#undef OVERLOADS
|
||||
|
||||
// const methods
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template <typename R, TYPENAME_T0_HEAD(z,i) JSClass* CLS, typename TC, R (TC::*fptr) ( T0_MAYBE_REF(z,i) ) const> \
|
||||
bool ScriptInterface::callMethodConst(JSContext* cx, uint argc, jsval* vp) \
|
||||
{ \
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \
|
||||
JSAutoRequest rq(cx); \
|
||||
JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp)); \
|
||||
if (ScriptInterface::GetClass(thisObj) != CLS) return false; \
|
||||
TC* c = static_cast<TC*>(ScriptInterface::GetPrivate(thisObj)); \
|
||||
if (! c) return false; \
|
||||
BOOST_PP_REPEAT_##z (i, CONVERT_ARG, ~) \
|
||||
JS::RootedValue rval(cx); \
|
||||
ScriptInterface_NativeMethodWrapper<R, TC>::template call<T0_HEAD(z,i) R (TC::*)(T0_MAYBE_REF(z,i)) const>(cx, &rval, c, fptr A0_TAIL(z,i)); \
|
||||
args.rval().set(rval); \
|
||||
return !ScriptInterface::IsExceptionPending(cx); \
|
||||
}
|
||||
BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
#undef OVERLOADS
|
||||
|
||||
#define ASSIGN_OR_TO_JS_VAL(z, i, data) AssignOrToJSVal(cx, argv[i], a##i);
|
||||
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template<typename R TYPENAME_T0_TAIL(z, i)> \
|
||||
bool ScriptInterface::CallFunction(JS::HandleValue val, const char* name, T0_A0_CONST_REF(z,i) R& ret) \
|
||||
bool ScriptInterface::CallFunction(JS::HandleValue val, const char* name T0_A0_TAIL_CONST_REF(z,i), R& ret) const \
|
||||
{ \
|
||||
JSContext* cx = GetContext(); \
|
||||
JSAutoRequest rq(cx); \
|
||||
@ -173,7 +195,7 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template<typename R TYPENAME_T0_TAIL(z, i)> \
|
||||
bool ScriptInterface::CallFunction(JS::HandleValue val, const char* name, T0_A0_CONST_REF(z,i) JS::Rooted<R>* ret) \
|
||||
bool ScriptInterface::CallFunction(JS::HandleValue val, const char* name T0_A0_TAIL_CONST_REF(z,i), JS::Rooted<R>* ret) const \
|
||||
{ \
|
||||
JSContext* cx = GetContext(); \
|
||||
JSAutoRequest rq(cx); \
|
||||
@ -181,17 +203,14 @@ bool ScriptInterface::CallFunction(JS::HandleValue val, const char* name, T0_A0_
|
||||
JS::AutoValueVector argv(cx); \
|
||||
argv.resize(i); \
|
||||
BOOST_PP_REPEAT_##z (i, ASSIGN_OR_TO_JS_VAL, ~) \
|
||||
bool ok = CallFunction_(val, name, argv, jsRet); \
|
||||
if (!ok) \
|
||||
return false; \
|
||||
return true; \
|
||||
return CallFunction_(val, name, argv, jsRet); \
|
||||
}
|
||||
BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
#undef OVERLOADS
|
||||
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template<typename R TYPENAME_T0_TAIL(z, i)> \
|
||||
bool ScriptInterface::CallFunction(JS::HandleValue val, const char* name, T0_A0_CONST_REF(z,i) JS::MutableHandle<R> ret) \
|
||||
bool ScriptInterface::CallFunction(JS::HandleValue val, const char* name T0_A0_TAIL_CONST_REF(z,i), JS::MutableHandle<R> ret) const \
|
||||
{ \
|
||||
JSContext* cx = GetContext(); \
|
||||
JSAutoRequest rq(cx); \
|
||||
@ -226,6 +245,6 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
|
||||
#undef T0_TAIL_MAYBE_REF
|
||||
#undef T0_A0
|
||||
#undef T0_A0_MAYBE_REF
|
||||
#undef T0_A0_CONST_REF
|
||||
#undef T0_A0_TAIL_CONST_REF
|
||||
#undef A0
|
||||
#undef A0_TAIL
|
||||
|
@ -569,7 +569,8 @@ bool ScriptInterface::CallFunctionVoid(JS::HandleValue val, const char* name)
|
||||
return CallFunction_(val, name, JS::HandleValueArray::empty(), &jsRet);
|
||||
}
|
||||
|
||||
bool ScriptInterface::CallFunction_(JS::HandleValue val, const char* name, JS::HandleValueArray argv, JS::MutableHandleValue ret)
|
||||
|
||||
bool ScriptInterface::CallFunction_(JS::HandleValue val, const char* name, JS::HandleValueArray argv, JS::MutableHandleValue ret) const
|
||||
{
|
||||
JSAutoRequest rq(m->m_cx);
|
||||
JS::RootedObject obj(m->m_cx);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -379,7 +379,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
bool CallFunction_(JS::HandleValue val, const char* name, JS::HandleValueArray argv, JS::MutableHandleValue ret);
|
||||
bool CallFunction_(JS::HandleValue val, const char* name, JS::HandleValueArray argv, JS::MutableHandleValue ret) const;
|
||||
bool Eval_(const char* code, JS::MutableHandleValue ret);
|
||||
bool Eval_(const wchar_t* code, JS::MutableHandleValue ret);
|
||||
bool SetGlobal_(const char* name, JS::HandleValue value, bool replace);
|
||||
@ -440,6 +440,9 @@ public:
|
||||
// template <R, T0..., JSClass*, TC, TR (TC:*fptr) (T0...)>
|
||||
// static JSNative callMethod;
|
||||
//
|
||||
// template <R, T0..., JSClass*, TC, TR (TC:*fptr) const (T0...)>
|
||||
// static JSNative callMethodConst;
|
||||
//
|
||||
// template <dummy, T0...>
|
||||
// static size_t nargs();
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -119,7 +119,7 @@ public:
|
||||
Init(paramNode);
|
||||
}
|
||||
|
||||
virtual void GetShape(EShape& shape, entity_pos_t& size0, entity_pos_t& size1, entity_pos_t& height)
|
||||
virtual void GetShape(EShape& shape, entity_pos_t& size0, entity_pos_t& size1, entity_pos_t& height) const
|
||||
{
|
||||
shape = m_Shape;
|
||||
size0 = m_Size0;
|
||||
@ -127,7 +127,7 @@ public:
|
||||
height = m_Height;
|
||||
}
|
||||
|
||||
virtual CFixedVector3D PickSpawnPoint(entity_id_t spawned)
|
||||
virtual CFixedVector3D PickSpawnPoint(entity_id_t spawned) const
|
||||
{
|
||||
// Try to find a free space around the building's footprint.
|
||||
// (Note that we use the footprint, not the obstruction shape - this might be a bit dodgy
|
||||
@ -257,7 +257,7 @@ public:
|
||||
return error;
|
||||
}
|
||||
|
||||
virtual CFixedVector3D PickSpawnPointBothPass(entity_id_t spawned)
|
||||
virtual CFixedVector3D PickSpawnPointBothPass(entity_id_t spawned) const
|
||||
{
|
||||
// Try to find a free space inside and around this footprint
|
||||
// at the intersection between the footprint passability and the unit passability.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -207,7 +207,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool GetRenderData(u8& r, u8& g, u8& b, entity_pos_t& x, entity_pos_t& z)
|
||||
virtual bool GetRenderData(u8& r, u8& g, u8& b, entity_pos_t& x, entity_pos_t& z) const
|
||||
{
|
||||
if (!m_Active)
|
||||
return false;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -26,9 +26,6 @@
|
||||
#include "simulation2/components/ICmpUnitMotion.h"
|
||||
#include "simulation2/serialization/SerializeTemplates.h"
|
||||
|
||||
#define MAX(x,y) x>y ? x : y
|
||||
#define MIN(x,y) x>y ? y : x
|
||||
|
||||
/**
|
||||
* Obstruction implementation. This keeps the ICmpPathfinder's model of the world updated when the
|
||||
* entities move and die, with shapes derived from ICmpFootprint.
|
||||
@ -237,13 +234,13 @@ public:
|
||||
b.da = entity_angle_t::FromInt(0);
|
||||
b.flags = m_Flags;
|
||||
m_Shapes.push_back(b);
|
||||
max.X = MAX(max.X, b.dx + b.size0/2);
|
||||
max.Y = MAX(max.Y, b.dz + b.size1/2);
|
||||
min.X = MIN(min.X, b.dx - b.size0/2);
|
||||
min.Y = MIN(min.Y, b.dz - b.size1/2);
|
||||
max.X = std::max(max.X, b.dx + b.size0/2);
|
||||
max.Y = std::max(max.Y, b.dz + b.size1/2);
|
||||
min.X = std::min(min.X, b.dx - b.size0/2);
|
||||
min.Y = std::min(min.Y, b.dz - b.size1/2);
|
||||
}
|
||||
m_Size0 = fixed::FromInt(2).Multiply(MAX(max.X, -min.X));
|
||||
m_Size1 = fixed::FromInt(2).Multiply(MAX(max.Y, -min.Y));
|
||||
m_Size0 = fixed::FromInt(2).Multiply(std::max(max.X, -min.X));
|
||||
m_Size1 = fixed::FromInt(2).Multiply(std::max(max.Y, -min.Y));
|
||||
}
|
||||
|
||||
m_Active = paramNode.GetChild("Active").ToBool();
|
||||
@ -451,27 +448,27 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool GetBlockMovementFlag()
|
||||
virtual bool GetBlockMovementFlag() const
|
||||
{
|
||||
return (m_TemplateFlags & ICmpObstructionManager::FLAG_BLOCK_MOVEMENT) != 0;
|
||||
}
|
||||
|
||||
virtual ICmpObstructionManager::tag_t GetObstruction()
|
||||
virtual ICmpObstructionManager::tag_t GetObstruction() const
|
||||
{
|
||||
return m_Tag;
|
||||
}
|
||||
|
||||
virtual bool GetPreviousObstructionSquare(ICmpObstructionManager::ObstructionSquare& out)
|
||||
virtual bool GetPreviousObstructionSquare(ICmpObstructionManager::ObstructionSquare& out) const
|
||||
{
|
||||
return GetObstructionSquare(out, true);
|
||||
}
|
||||
|
||||
virtual bool GetObstructionSquare(ICmpObstructionManager::ObstructionSquare& out)
|
||||
virtual bool GetObstructionSquare(ICmpObstructionManager::ObstructionSquare& out) const
|
||||
{
|
||||
return GetObstructionSquare(out, false);
|
||||
}
|
||||
|
||||
virtual bool GetObstructionSquare(ICmpObstructionManager::ObstructionSquare& out, bool previousPosition)
|
||||
virtual bool GetObstructionSquare(ICmpObstructionManager::ObstructionSquare& out, bool previousPosition) const
|
||||
{
|
||||
CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle());
|
||||
if (!cmpPosition)
|
||||
@ -496,7 +493,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual entity_pos_t GetUnitRadius()
|
||||
virtual entity_pos_t GetUnitRadius() const
|
||||
{
|
||||
if (m_Type == UNIT)
|
||||
return m_Clearance;
|
||||
@ -504,7 +501,7 @@ public:
|
||||
return entity_pos_t::Zero();
|
||||
}
|
||||
|
||||
virtual entity_pos_t GetSize()
|
||||
virtual entity_pos_t GetSize() const
|
||||
{
|
||||
if (m_Type == UNIT)
|
||||
return m_Clearance;
|
||||
@ -518,17 +515,17 @@ public:
|
||||
m_Clearance = clearance;
|
||||
}
|
||||
|
||||
virtual bool IsControlPersistent()
|
||||
virtual bool IsControlPersistent() const
|
||||
{
|
||||
return m_ControlPersist;
|
||||
}
|
||||
|
||||
virtual EFoundationCheck CheckFoundation(std::string className)
|
||||
virtual EFoundationCheck CheckFoundation(const std::string& className) const
|
||||
{
|
||||
return CheckFoundation(className, false);
|
||||
}
|
||||
|
||||
virtual EFoundationCheck CheckFoundation(std::string className, bool onlyCenterPoint)
|
||||
virtual EFoundationCheck CheckFoundation(const std::string& className, bool onlyCenterPoint) const
|
||||
{
|
||||
CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle());
|
||||
if (!cmpPosition)
|
||||
@ -565,7 +562,7 @@ public:
|
||||
return cmpPathfinder->CheckBuildingPlacement(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, GetEntityId(), passClass, onlyCenterPoint);
|
||||
}
|
||||
|
||||
virtual bool CheckDuplicateFoundation()
|
||||
virtual bool CheckDuplicateFoundation() const
|
||||
{
|
||||
CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle());
|
||||
if (!cmpPosition)
|
||||
@ -597,7 +594,7 @@ public:
|
||||
return !cmpObstructionManager->TestStaticShape(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, NULL );
|
||||
}
|
||||
|
||||
virtual std::vector<entity_id_t> GetUnitCollisions()
|
||||
virtual std::vector<entity_id_t> GetUnitCollisions() const
|
||||
{
|
||||
std::vector<entity_id_t> ret;
|
||||
|
||||
@ -648,12 +645,12 @@ public:
|
||||
UpdateControlGroups();
|
||||
}
|
||||
|
||||
virtual entity_id_t GetControlGroup()
|
||||
virtual entity_id_t GetControlGroup() const
|
||||
{
|
||||
return m_ControlGroup;
|
||||
}
|
||||
|
||||
virtual entity_id_t GetControlGroup2()
|
||||
virtual entity_id_t GetControlGroup2() const
|
||||
{
|
||||
return m_ControlGroup2;
|
||||
}
|
||||
@ -685,7 +682,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void ResolveFoundationCollisions()
|
||||
void ResolveFoundationCollisions() const
|
||||
{
|
||||
if (m_Type == UNIT)
|
||||
return;
|
||||
|
@ -78,7 +78,7 @@ struct StaticShape
|
||||
struct SerializeUnitShape
|
||||
{
|
||||
template<typename S>
|
||||
void operator()(S& serialize, const char* UNUSED(name), UnitShape& value)
|
||||
void operator()(S& serialize, const char* UNUSED(name), UnitShape& value) const
|
||||
{
|
||||
serialize.NumberU32_Unbounded("entity", value.entity);
|
||||
serialize.NumberFixed_Unbounded("x", value.x);
|
||||
@ -95,7 +95,7 @@ struct SerializeUnitShape
|
||||
struct SerializeStaticShape
|
||||
{
|
||||
template<typename S>
|
||||
void operator()(S& serialize, const char* UNUSED(name), StaticShape& value)
|
||||
void operator()(S& serialize, const char* UNUSED(name), StaticShape& value) const
|
||||
{
|
||||
serialize.NumberU32_Unbounded("entity", value.entity);
|
||||
serialize.NumberFixed_Unbounded("x", value.x);
|
||||
@ -309,7 +309,7 @@ public:
|
||||
return STATIC_INDEX_TO_TAG(id);
|
||||
}
|
||||
|
||||
virtual ObstructionSquare GetUnitShapeObstruction(entity_pos_t x, entity_pos_t z, entity_pos_t clearance)
|
||||
virtual ObstructionSquare GetUnitShapeObstruction(entity_pos_t x, entity_pos_t z, entity_pos_t clearance) const
|
||||
{
|
||||
CFixedVector2D u(entity_pos_t::FromInt(1), entity_pos_t::Zero());
|
||||
CFixedVector2D v(entity_pos_t::Zero(), entity_pos_t::FromInt(1));
|
||||
@ -317,7 +317,7 @@ public:
|
||||
return o;
|
||||
}
|
||||
|
||||
virtual ObstructionSquare GetStaticShapeObstruction(entity_pos_t x, entity_pos_t z, entity_angle_t a, entity_pos_t w, entity_pos_t h)
|
||||
virtual ObstructionSquare GetStaticShapeObstruction(entity_pos_t x, entity_pos_t z, entity_angle_t a, entity_pos_t w, entity_pos_t h) const
|
||||
{
|
||||
fixed s, c;
|
||||
sincos_approx(a, s, c);
|
||||
@ -445,13 +445,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual ObstructionSquare GetObstruction(tag_t tag)
|
||||
virtual ObstructionSquare GetObstruction(tag_t tag) const
|
||||
{
|
||||
ENSURE(TAG_IS_VALID(tag));
|
||||
|
||||
if (TAG_IS_UNIT(tag))
|
||||
{
|
||||
UnitShape& shape = m_UnitShapes[TAG_TO_INDEX(tag)];
|
||||
const UnitShape& shape = m_UnitShapes.at(TAG_TO_INDEX(tag));
|
||||
CFixedVector2D u(entity_pos_t::FromInt(1), entity_pos_t::Zero());
|
||||
CFixedVector2D v(entity_pos_t::Zero(), entity_pos_t::FromInt(1));
|
||||
ObstructionSquare o = { shape.x, shape.z, u, v, shape.clearance, shape.clearance };
|
||||
@ -459,21 +459,21 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
StaticShape& shape = m_StaticShapes[TAG_TO_INDEX(tag)];
|
||||
const StaticShape& shape = m_StaticShapes.at(TAG_TO_INDEX(tag));
|
||||
ObstructionSquare o = { shape.x, shape.z, shape.u, shape.v, shape.hw, shape.hh };
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool TestLine(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, bool relaxClearanceForUnits = false);
|
||||
virtual bool TestStaticShape(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, std::vector<entity_id_t>* out);
|
||||
virtual bool TestUnitShape(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, std::vector<entity_id_t>* out);
|
||||
virtual bool TestLine(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, bool relaxClearanceForUnits = false) const;
|
||||
virtual bool TestStaticShape(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, std::vector<entity_id_t>* out) const;
|
||||
virtual bool TestUnitShape(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, std::vector<entity_id_t>* out) const;
|
||||
|
||||
virtual void Rasterize(Grid<NavcellData>& grid, const std::vector<PathfinderPassability>& passClasses, bool fullUpdate);
|
||||
virtual void GetObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares);
|
||||
virtual void GetUnitObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares);
|
||||
virtual void GetStaticObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares);
|
||||
virtual void GetUnitsOnObstruction(const ObstructionSquare& square, std::vector<entity_id_t>& out, const IObstructionTestFilter& filter, bool strict = false);
|
||||
virtual void GetObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares) const;
|
||||
virtual void GetUnitObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares) const;
|
||||
virtual void GetStaticObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares) const;
|
||||
virtual void GetUnitsOnObstruction(const ObstructionSquare& square, std::vector<entity_id_t>& out, const IObstructionTestFilter& filter, bool strict = false) const;
|
||||
|
||||
virtual void SetPassabilityCircular(bool enabled)
|
||||
{
|
||||
@ -640,7 +640,7 @@ private:
|
||||
/**
|
||||
* Return whether the given point is within the world bounds by at least r
|
||||
*/
|
||||
inline bool IsInWorld(entity_pos_t x, entity_pos_t z, entity_pos_t r)
|
||||
inline bool IsInWorld(entity_pos_t x, entity_pos_t z, entity_pos_t r) const
|
||||
{
|
||||
return (m_WorldX0+r <= x && x <= m_WorldX1-r && m_WorldZ0+r <= z && z <= m_WorldZ1-r);
|
||||
}
|
||||
@ -648,17 +648,17 @@ private:
|
||||
/**
|
||||
* Return whether the given point is within the world bounds
|
||||
*/
|
||||
inline bool IsInWorld(const CFixedVector2D& p)
|
||||
inline bool IsInWorld(const CFixedVector2D& p) const
|
||||
{
|
||||
return (m_WorldX0 <= p.X && p.X <= m_WorldX1 && m_WorldZ0 <= p.Y && p.Y <= m_WorldZ1);
|
||||
}
|
||||
|
||||
void RasterizeHelper(Grid<NavcellData>& grid, ICmpObstructionManager::flags_t requireMask, bool fullUpdate, pass_class_t appliedMask, entity_pos_t clearance = fixed::Zero());
|
||||
void RasterizeHelper(Grid<NavcellData>& grid, ICmpObstructionManager::flags_t requireMask, bool fullUpdate, pass_class_t appliedMask, entity_pos_t clearance = fixed::Zero()) const;
|
||||
};
|
||||
|
||||
REGISTER_COMPONENT_TYPE(ObstructionManager)
|
||||
|
||||
bool CCmpObstructionManager::TestLine(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, bool relaxClearanceForUnits)
|
||||
bool CCmpObstructionManager::TestLine(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, bool relaxClearanceForUnits) const
|
||||
{
|
||||
PROFILE("TestLine");
|
||||
|
||||
@ -678,7 +678,7 @@ bool CCmpObstructionManager::TestLine(const IObstructionTestFilter& filter, enti
|
||||
m_UnitSubdivision.GetInRange(unitShapes, posMin, posMax);
|
||||
for (size_t i = 0; i < unitShapes.size(); ++i)
|
||||
{
|
||||
std::map<u32, UnitShape>::iterator it = m_UnitShapes.find(unitShapes[i]);
|
||||
std::map<u32, UnitShape>::const_iterator it = m_UnitShapes.find(unitShapes[i]);
|
||||
ENSURE(it != m_UnitShapes.end());
|
||||
|
||||
if (!filter.TestShape(UNIT_INDEX_TO_TAG(it->first), it->second.flags, it->second.group, INVALID_ENTITY))
|
||||
@ -694,7 +694,7 @@ bool CCmpObstructionManager::TestLine(const IObstructionTestFilter& filter, enti
|
||||
m_StaticSubdivision.GetInRange(staticShapes, posMin, posMax);
|
||||
for (size_t i = 0; i < staticShapes.size(); ++i)
|
||||
{
|
||||
std::map<u32, StaticShape>::iterator it = m_StaticShapes.find(staticShapes[i]);
|
||||
std::map<u32, StaticShape>::const_iterator it = m_StaticShapes.find(staticShapes[i]);
|
||||
ENSURE(it != m_StaticShapes.end());
|
||||
|
||||
if (!filter.TestShape(STATIC_INDEX_TO_TAG(it->first), it->second.flags, it->second.group, it->second.group2))
|
||||
@ -711,7 +711,7 @@ bool CCmpObstructionManager::TestLine(const IObstructionTestFilter& filter, enti
|
||||
|
||||
bool CCmpObstructionManager::TestStaticShape(const IObstructionTestFilter& filter,
|
||||
entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h,
|
||||
std::vector<entity_id_t>* out)
|
||||
std::vector<entity_id_t>* out) const
|
||||
{
|
||||
PROFILE("TestStaticShape");
|
||||
|
||||
@ -739,7 +739,7 @@ bool CCmpObstructionManager::TestStaticShape(const IObstructionTestFilter& filte
|
||||
return true;
|
||||
}
|
||||
|
||||
for (std::map<u32, UnitShape>::iterator it = m_UnitShapes.begin(); it != m_UnitShapes.end(); ++it)
|
||||
for (std::map<u32, UnitShape>::const_iterator it = m_UnitShapes.begin(); it != m_UnitShapes.end(); ++it)
|
||||
{
|
||||
if (!filter.TestShape(UNIT_INDEX_TO_TAG(it->first), it->second.flags, it->second.group, INVALID_ENTITY))
|
||||
continue;
|
||||
@ -755,7 +755,7 @@ bool CCmpObstructionManager::TestStaticShape(const IObstructionTestFilter& filte
|
||||
}
|
||||
}
|
||||
|
||||
for (std::map<u32, StaticShape>::iterator it = m_StaticShapes.begin(); it != m_StaticShapes.end(); ++it)
|
||||
for (std::map<u32, StaticShape>::const_iterator it = m_StaticShapes.begin(); it != m_StaticShapes.end(); ++it)
|
||||
{
|
||||
if (!filter.TestShape(STATIC_INDEX_TO_TAG(it->first), it->second.flags, it->second.group, it->second.group2))
|
||||
continue;
|
||||
@ -779,7 +779,7 @@ bool CCmpObstructionManager::TestStaticShape(const IObstructionTestFilter& filte
|
||||
|
||||
bool CCmpObstructionManager::TestUnitShape(const IObstructionTestFilter& filter,
|
||||
entity_pos_t x, entity_pos_t z, entity_pos_t clearance,
|
||||
std::vector<entity_id_t>* out)
|
||||
std::vector<entity_id_t>* out) const
|
||||
{
|
||||
PROFILE("TestUnitShape");
|
||||
|
||||
@ -796,7 +796,7 @@ bool CCmpObstructionManager::TestUnitShape(const IObstructionTestFilter& filter,
|
||||
|
||||
CFixedVector2D center(x, z);
|
||||
|
||||
for (std::map<u32, UnitShape>::iterator it = m_UnitShapes.begin(); it != m_UnitShapes.end(); ++it)
|
||||
for (std::map<u32, UnitShape>::const_iterator it = m_UnitShapes.begin(); it != m_UnitShapes.end(); ++it)
|
||||
{
|
||||
if (!filter.TestShape(UNIT_INDEX_TO_TAG(it->first), it->second.flags, it->second.group, INVALID_ENTITY))
|
||||
continue;
|
||||
@ -816,7 +816,7 @@ bool CCmpObstructionManager::TestUnitShape(const IObstructionTestFilter& filter,
|
||||
}
|
||||
}
|
||||
|
||||
for (std::map<u32, StaticShape>::iterator it = m_StaticShapes.begin(); it != m_StaticShapes.end(); ++it)
|
||||
for (std::map<u32, StaticShape>::const_iterator it = m_StaticShapes.begin(); it != m_StaticShapes.end(); ++it)
|
||||
{
|
||||
if (!filter.TestShape(STATIC_INDEX_TO_TAG(it->first), it->second.flags, it->second.group, it->second.group2))
|
||||
continue;
|
||||
@ -882,7 +882,7 @@ void CCmpObstructionManager::Rasterize(Grid<NavcellData>& grid, const std::vecto
|
||||
m_DirtyUnitShapes.clear();
|
||||
}
|
||||
|
||||
void CCmpObstructionManager::RasterizeHelper(Grid<NavcellData>& grid, ICmpObstructionManager::flags_t requireMask, bool fullUpdate, pass_class_t appliedMask, entity_pos_t clearance)
|
||||
void CCmpObstructionManager::RasterizeHelper(Grid<NavcellData>& grid, ICmpObstructionManager::flags_t requireMask, bool fullUpdate, pass_class_t appliedMask, entity_pos_t clearance) const
|
||||
{
|
||||
for (auto& pair : m_StaticShapes)
|
||||
{
|
||||
@ -928,13 +928,13 @@ void CCmpObstructionManager::RasterizeHelper(Grid<NavcellData>& grid, ICmpObstru
|
||||
}
|
||||
}
|
||||
|
||||
void CCmpObstructionManager::GetObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares)
|
||||
void CCmpObstructionManager::GetObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares) const
|
||||
{
|
||||
GetUnitObstructionsInRange(filter, x0, z0, x1, z1, squares);
|
||||
GetStaticObstructionsInRange(filter, x0, z0, x1, z1, squares);
|
||||
}
|
||||
|
||||
void CCmpObstructionManager::GetUnitObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares)
|
||||
void CCmpObstructionManager::GetUnitObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares) const
|
||||
{
|
||||
PROFILE("GetObstructionsInRange");
|
||||
|
||||
@ -962,7 +962,7 @@ void CCmpObstructionManager::GetUnitObstructionsInRange(const IObstructionTestFi
|
||||
}
|
||||
}
|
||||
|
||||
void CCmpObstructionManager::GetStaticObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares)
|
||||
void CCmpObstructionManager::GetStaticObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares) const
|
||||
{
|
||||
PROFILE("GetObstructionsInRange");
|
||||
|
||||
@ -990,7 +990,7 @@ void CCmpObstructionManager::GetStaticObstructionsInRange(const IObstructionTest
|
||||
}
|
||||
}
|
||||
|
||||
void CCmpObstructionManager::GetUnitsOnObstruction(const ObstructionSquare& square, std::vector<entity_id_t>& out, const IObstructionTestFilter& filter, bool strict)
|
||||
void CCmpObstructionManager::GetUnitsOnObstruction(const ObstructionSquare& square, std::vector<entity_id_t>& out, const IObstructionTestFilter& filter, bool strict) const
|
||||
{
|
||||
PROFILE("GetUnitsOnObstruction");
|
||||
|
||||
@ -1012,7 +1012,7 @@ void CCmpObstructionManager::GetUnitsOnObstruction(const ObstructionSquare& squa
|
||||
auto it = m_UnitShapes.find(unitShape);
|
||||
ENSURE(it != m_UnitShapes.end());
|
||||
|
||||
UnitShape& shape = it->second;
|
||||
const UnitShape& shape = it->second;
|
||||
|
||||
if (!filter.TestShape(UNIT_INDEX_TO_TAG(unitShape), shape.flags, shape.group, INVALID_ENTITY))
|
||||
continue;
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual player_id_t GetOwner()
|
||||
virtual player_id_t GetOwner() const
|
||||
{
|
||||
return m_Owner;
|
||||
}
|
||||
|
@ -203,15 +203,16 @@ void CCmpPathfinder::SetAtlasOverlay(bool enable, pass_class_t passClass)
|
||||
SAFE_DELETE(m_AtlasOverlay);
|
||||
}
|
||||
|
||||
pass_class_t CCmpPathfinder::GetPassabilityClass(const std::string& name)
|
||||
pass_class_t CCmpPathfinder::GetPassabilityClass(const std::string& name) const
|
||||
{
|
||||
if (m_PassClassMasks.find(name) == m_PassClassMasks.end())
|
||||
std::map<std::string, pass_class_t>::const_iterator it = m_PassClassMasks.find(name);
|
||||
if (it == m_PassClassMasks.end())
|
||||
{
|
||||
LOGERROR("Invalid passability class name '%s'", name.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m_PassClassMasks[name];
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void CCmpPathfinder::GetPassabilityClasses(std::map<std::string, pass_class_t>& passClasses) const
|
||||
@ -221,7 +222,7 @@ void CCmpPathfinder::GetPassabilityClasses(std::map<std::string, pass_class_t>&
|
||||
|
||||
void CCmpPathfinder::GetPassabilityClasses(std::map<std::string, pass_class_t>& nonPathfindingPassClasses, std::map<std::string, pass_class_t>& pathfindingPassClasses) const
|
||||
{
|
||||
for (auto& pair : m_PassClassMasks)
|
||||
for (const std::pair<std::string, pass_class_t>& pair : m_PassClassMasks)
|
||||
{
|
||||
if ((GetPassabilityFromMask(pair.second)->m_Obstructions == PathfinderPassability::PATHFINDING))
|
||||
pathfindingPassClasses[pair.first] = pair.second;
|
||||
@ -791,7 +792,7 @@ void CCmpPathfinder::ProcessSameTurnMoves()
|
||||
|
||||
bool CCmpPathfinder::CheckMovement(const IObstructionTestFilter& filter,
|
||||
entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r,
|
||||
pass_class_t passClass)
|
||||
pass_class_t passClass) const
|
||||
{
|
||||
PROFILE2_IFSPIKE("Check Movement", 0.001);
|
||||
|
||||
@ -808,7 +809,7 @@ bool CCmpPathfinder::CheckMovement(const IObstructionTestFilter& filter,
|
||||
}
|
||||
|
||||
ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckUnitPlacement(const IObstructionTestFilter& filter,
|
||||
entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool UNUSED(onlyCenterPoint))
|
||||
entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool UNUSED(onlyCenterPoint)) const
|
||||
{
|
||||
// Check unit obstruction
|
||||
CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity());
|
||||
@ -834,7 +835,7 @@ ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckUnitPlacement(const IObst
|
||||
|
||||
ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckBuildingPlacement(const IObstructionTestFilter& filter,
|
||||
entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w,
|
||||
entity_pos_t h, entity_id_t id, pass_class_t passClass)
|
||||
entity_pos_t h, entity_id_t id, pass_class_t passClass) const
|
||||
{
|
||||
return CCmpPathfinder::CheckBuildingPlacement(filter, x, z, a, w, h, id, passClass, false);
|
||||
}
|
||||
@ -842,7 +843,7 @@ ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckBuildingPlacement(const I
|
||||
|
||||
ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckBuildingPlacement(const IObstructionTestFilter& filter,
|
||||
entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w,
|
||||
entity_pos_t h, entity_id_t id, pass_class_t passClass, bool UNUSED(onlyCenterPoint))
|
||||
entity_pos_t h, entity_id_t id, pass_class_t passClass, bool UNUSED(onlyCenterPoint)) const
|
||||
{
|
||||
// Check unit obstruction
|
||||
CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity());
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -202,7 +202,7 @@ public:
|
||||
|
||||
virtual void HandleMessage(const CMessage& msg, bool global);
|
||||
|
||||
virtual pass_class_t GetPassabilityClass(const std::string& name);
|
||||
virtual pass_class_t GetPassabilityClass(const std::string& name) const;
|
||||
|
||||
virtual void GetPassabilityClasses(std::map<std::string, pass_class_t>& passClasses) const;
|
||||
virtual void GetPassabilityClasses(
|
||||
@ -264,20 +264,20 @@ public:
|
||||
m_LongPathfinder.SetHierDebugOverlay(enabled, &GetSimContext());
|
||||
}
|
||||
|
||||
virtual void GetDebugData(u32& steps, double& time, Grid<u8>& grid)
|
||||
virtual void GetDebugData(u32& steps, double& time, Grid<u8>& grid) const
|
||||
{
|
||||
m_LongPathfinder.GetDebugData(steps, time, grid);
|
||||
}
|
||||
|
||||
virtual void SetAtlasOverlay(bool enable, pass_class_t passClass = 0);
|
||||
|
||||
virtual bool CheckMovement(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, pass_class_t passClass);
|
||||
virtual bool CheckMovement(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, pass_class_t passClass) const;
|
||||
|
||||
virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool onlyCenterPoint);
|
||||
virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool onlyCenterPoint) const;
|
||||
|
||||
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass);
|
||||
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass) const;
|
||||
|
||||
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, bool onlyCenterPoint);
|
||||
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, bool onlyCenterPoint) const;
|
||||
|
||||
virtual void FinishAsyncRequests();
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -501,7 +501,7 @@ struct SquareSort
|
||||
{
|
||||
CFixedVector2D src;
|
||||
SquareSort(CFixedVector2D src) : src(src) { }
|
||||
bool operator()(const Square& a, const Square& b)
|
||||
bool operator()(const Square& a, const Square& b) const
|
||||
{
|
||||
if ((a.p0 - src).CompareLength(b.p0 - src) < 0)
|
||||
return true;
|
||||
@ -862,7 +862,7 @@ void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter,
|
||||
xz.push_back(npos.X.ToFloat());
|
||||
xz.push_back(npos.Y.ToFloat());
|
||||
SimRender::ConstructLineOnGround(GetSimContext(), xz, m_DebugOverlayShortPathLines.back(), false);
|
||||
//*/
|
||||
*/
|
||||
|
||||
if (visible)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -319,12 +319,12 @@ public:
|
||||
UpdateTurretPosition();
|
||||
}
|
||||
|
||||
virtual entity_id_t GetTurretParent()
|
||||
virtual entity_id_t GetTurretParent() const
|
||||
{
|
||||
return m_TurretParent;
|
||||
}
|
||||
|
||||
virtual bool IsInWorld()
|
||||
virtual bool IsInWorld() const
|
||||
{
|
||||
return m_InWorld;
|
||||
}
|
||||
@ -396,7 +396,7 @@ public:
|
||||
AdvertiseInterpolatedPositionChanges();
|
||||
}
|
||||
|
||||
virtual entity_pos_t GetHeightOffset()
|
||||
virtual entity_pos_t GetHeightOffset() const
|
||||
{
|
||||
if (m_RelativeToGround)
|
||||
return m_Y;
|
||||
@ -423,7 +423,7 @@ public:
|
||||
AdvertiseInterpolatedPositionChanges();
|
||||
}
|
||||
|
||||
virtual entity_pos_t GetHeightFixed()
|
||||
virtual entity_pos_t GetHeightFixed() const
|
||||
{
|
||||
if (!m_RelativeToGround)
|
||||
return m_Y;
|
||||
@ -442,7 +442,7 @@ public:
|
||||
return m_Y + baseY;
|
||||
}
|
||||
|
||||
virtual bool IsHeightRelative()
|
||||
virtual bool IsHeightRelative() const
|
||||
{
|
||||
return m_RelativeToGround;
|
||||
}
|
||||
@ -456,7 +456,7 @@ public:
|
||||
AdvertiseInterpolatedPositionChanges();
|
||||
}
|
||||
|
||||
virtual bool IsFloating()
|
||||
virtual bool IsFloating() const
|
||||
{
|
||||
return m_Floating;
|
||||
}
|
||||
@ -479,7 +479,7 @@ public:
|
||||
AdvertiseInterpolatedPositionChanges();
|
||||
}
|
||||
|
||||
virtual CFixedVector3D GetPosition()
|
||||
virtual CFixedVector3D GetPosition() const
|
||||
{
|
||||
if (!m_InWorld)
|
||||
{
|
||||
@ -490,7 +490,7 @@ public:
|
||||
return CFixedVector3D(m_X, GetHeightFixed(), m_Z);
|
||||
}
|
||||
|
||||
virtual CFixedVector2D GetPosition2D()
|
||||
virtual CFixedVector2D GetPosition2D() const
|
||||
{
|
||||
if (!m_InWorld)
|
||||
{
|
||||
@ -501,7 +501,7 @@ public:
|
||||
return CFixedVector2D(m_X, m_Z);
|
||||
}
|
||||
|
||||
virtual CFixedVector3D GetPreviousPosition()
|
||||
virtual CFixedVector3D GetPreviousPosition() const
|
||||
{
|
||||
if (!m_InWorld)
|
||||
{
|
||||
@ -512,7 +512,7 @@ public:
|
||||
return CFixedVector3D(m_PrevX, GetHeightFixed(), m_PrevZ);
|
||||
}
|
||||
|
||||
virtual CFixedVector2D GetPreviousPosition2D()
|
||||
virtual CFixedVector2D GetPreviousPosition2D() const
|
||||
{
|
||||
if (!m_InWorld)
|
||||
{
|
||||
@ -574,7 +574,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual CFixedVector3D GetRotation()
|
||||
virtual CFixedVector3D GetRotation() const
|
||||
{
|
||||
entity_angle_t y = m_RotY;
|
||||
if (m_TurretParent != INVALID_ENTITY)
|
||||
@ -586,7 +586,7 @@ public:
|
||||
return CFixedVector3D(m_RotX, y, m_RotZ);
|
||||
}
|
||||
|
||||
virtual fixed GetDistanceTravelled()
|
||||
virtual fixed GetDistanceTravelled() const
|
||||
{
|
||||
if (!m_InWorld)
|
||||
{
|
||||
@ -597,7 +597,7 @@ public:
|
||||
return CFixedVector2D(m_X - m_LastX, m_Z - m_LastZ).Length();
|
||||
}
|
||||
|
||||
float GetConstructionProgressOffset(const CVector3D& pos)
|
||||
float GetConstructionProgressOffset(const CVector3D& pos) const
|
||||
{
|
||||
if (m_ConstructionProgress.IsZero())
|
||||
return 0.0f;
|
||||
@ -627,7 +627,7 @@ public:
|
||||
return (m_ConstructionProgress.ToFloat() - 1.0f) * dy;
|
||||
}
|
||||
|
||||
virtual void GetInterpolatedPosition2D(float frameOffset, float& x, float& z, float& rotY)
|
||||
virtual void GetInterpolatedPosition2D(float frameOffset, float& x, float& z, float& rotY) const
|
||||
{
|
||||
if (!m_InWorld)
|
||||
{
|
||||
@ -641,7 +641,7 @@ public:
|
||||
rotY = m_InterpolatedRotY;
|
||||
}
|
||||
|
||||
virtual CMatrix3D GetInterpolatedTransform(float frameOffset)
|
||||
virtual CMatrix3D GetInterpolatedTransform(float frameOffset) const
|
||||
{
|
||||
if (m_TurretParent != INVALID_ENTITY)
|
||||
{
|
||||
@ -715,7 +715,7 @@ public:
|
||||
return m;
|
||||
}
|
||||
|
||||
void GetInterpolatedPositions(CVector3D& pos0, CVector3D& pos1)
|
||||
void GetInterpolatedPositions(CVector3D& pos0, CVector3D& pos1) const
|
||||
{
|
||||
float baseY0 = 0;
|
||||
float baseY1 = 0;
|
||||
@ -876,7 +876,7 @@ private:
|
||||
* - m_X, m_Z
|
||||
* - m_RotY
|
||||
*/
|
||||
void AdvertisePositionChanges()
|
||||
void AdvertisePositionChanges() const
|
||||
{
|
||||
for (std::set<entity_id_t>::const_iterator it = m_Turrets.begin(); it != m_Turrets.end(); ++it)
|
||||
{
|
||||
@ -906,7 +906,7 @@ private:
|
||||
* - If m_RelativeToGround, then the ground under this unit
|
||||
* - If m_RelativeToGround && m_Float, then the water level
|
||||
*/
|
||||
void AdvertiseInterpolatedPositionChanges()
|
||||
void AdvertiseInterpolatedPositionChanges() const
|
||||
{
|
||||
if (m_InWorld)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -149,11 +149,11 @@ private:
|
||||
|
||||
uint32_t LaunchProjectile(entity_id_t source, CFixedVector3D targetPoint, fixed speed, fixed gravity);
|
||||
|
||||
void AdvanceProjectile(Projectile& projectile, float dt);
|
||||
void AdvanceProjectile(Projectile& projectile, float dt) const;
|
||||
|
||||
void Interpolate(float frameTime);
|
||||
|
||||
void RenderSubmit(SceneCollector& collector, const CFrustum& frustum, bool culling);
|
||||
void RenderSubmit(SceneCollector& collector, const CFrustum& frustum, bool culling) const;
|
||||
};
|
||||
|
||||
REGISTER_COMPONENT_TYPE(ProjectileManager)
|
||||
@ -215,7 +215,7 @@ uint32_t CCmpProjectileManager::LaunchProjectile(entity_id_t source, CFixedVecto
|
||||
return projectile.id;
|
||||
}
|
||||
|
||||
void CCmpProjectileManager::AdvanceProjectile(Projectile& projectile, float dt)
|
||||
void CCmpProjectileManager::AdvanceProjectile(Projectile& projectile, float dt) const
|
||||
{
|
||||
projectile.time += dt;
|
||||
if (projectile.stopped)
|
||||
@ -316,7 +316,7 @@ void CCmpProjectileManager::RemoveProjectile(uint32_t id)
|
||||
}
|
||||
}
|
||||
|
||||
void CCmpProjectileManager::RenderSubmit(SceneCollector& collector, const CFrustum& frustum, bool culling)
|
||||
void CCmpProjectileManager::RenderSubmit(SceneCollector& collector, const CFrustum& frustum, bool culling) const
|
||||
{
|
||||
CmpPtr<ICmpRangeManager> cmpRangeManager(GetSystemEntity());
|
||||
int player = GetSimContext().GetCurrentDisplayedPlayer();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -60,7 +60,7 @@ struct SVisibilitySegment
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
bool IsSinglePoint()
|
||||
bool IsSinglePoint() const
|
||||
{
|
||||
return (m_StartIndex == m_EndIndex);
|
||||
}
|
||||
@ -326,7 +326,7 @@ public:
|
||||
/**
|
||||
* Returns true if at least one display rally point is set; i.e., if we have a point to render our marker/line at.
|
||||
*/
|
||||
bool IsSet()
|
||||
bool IsSet() const
|
||||
{
|
||||
return !m_RallyPoints.empty();
|
||||
}
|
||||
@ -405,18 +405,18 @@ private:
|
||||
* nicely to the edge of the building's footprint. Only needed if the pathfinder can possibly return obstructed tile waypoints,
|
||||
* i.e. when pathfinding is started from an obstructed tile.
|
||||
*/
|
||||
void FixFootprintWaypoints(std::vector<CVector2D>& coords, CmpPtr<ICmpPosition> cmpPosition, CmpPtr<ICmpFootprint> cmpFootprint);
|
||||
void FixFootprintWaypoints(std::vector<CVector2D>& coords, CmpPtr<ICmpPosition> cmpPosition, CmpPtr<ICmpFootprint> cmpFootprint) const;
|
||||
|
||||
/**
|
||||
* Get the point on the footprint edge that's as close from "start" as possible.
|
||||
*/
|
||||
void GetClosestsEdgePointFrom(CFixedVector2D& result, CFixedVector2D& start, CmpPtr<ICmpPosition> cmpPosition, CmpPtr<ICmpFootprint> cmpFootprint);
|
||||
void GetClosestsEdgePointFrom(CFixedVector2D& result, CFixedVector2D& start, CmpPtr<ICmpPosition> cmpPosition, CmpPtr<ICmpFootprint> cmpFootprint) const;
|
||||
|
||||
/**
|
||||
* Returns a list of indices of waypoints in the current path (m_Path[index]) where the LOS visibility changes, ordered from
|
||||
* building/previous rally point to rally point. Used to construct the overlay line segments and track changes to the SoD.
|
||||
*/
|
||||
void GetVisibilitySegments(std::deque<SVisibilitySegment>& out, size_t index);
|
||||
void GetVisibilitySegments(std::deque<SVisibilitySegment>& out, size_t index) const;
|
||||
|
||||
/**
|
||||
* Simplifies the path by removing waypoints that lie between two points that are visible from one another. This is primarily
|
||||
@ -430,7 +430,7 @@ private:
|
||||
* at most 3 consecutive node links will be joined into a single link.
|
||||
* @p floating whether to consider nodes who are under the water level as floating on top of the water
|
||||
*/
|
||||
void ReduceSegmentsByVisibility(std::vector<CVector2D>& coords, unsigned maxSegmentLinks = 0, bool floating = true);
|
||||
void ReduceSegmentsByVisibility(std::vector<CVector2D>& coords, unsigned maxSegmentLinks = 0, bool floating = true) const;
|
||||
|
||||
/**
|
||||
* Helper function to GetVisibilitySegments, factored out for testing. Merges single-point segments with its neighbouring
|
||||
@ -920,7 +920,7 @@ void CCmpRallyPointRenderer::UpdateOverlayLines()
|
||||
}
|
||||
}
|
||||
|
||||
void CCmpRallyPointRenderer::GetClosestsEdgePointFrom(CFixedVector2D& result, CFixedVector2D& start, CmpPtr<ICmpPosition> cmpPosition, CmpPtr<ICmpFootprint> cmpFootprint)
|
||||
void CCmpRallyPointRenderer::GetClosestsEdgePointFrom(CFixedVector2D& result, CFixedVector2D& start, CmpPtr<ICmpPosition> cmpPosition, CmpPtr<ICmpFootprint> cmpFootprint) const
|
||||
{
|
||||
ENSURE(cmpPosition);
|
||||
ENSURE(cmpFootprint);
|
||||
@ -967,7 +967,7 @@ void CCmpRallyPointRenderer::GetClosestsEdgePointFrom(CFixedVector2D& result, CF
|
||||
}
|
||||
}
|
||||
|
||||
void CCmpRallyPointRenderer::FixFootprintWaypoints(std::vector<CVector2D>& coords, CmpPtr<ICmpPosition> cmpPosition, CmpPtr<ICmpFootprint> cmpFootprint)
|
||||
void CCmpRallyPointRenderer::FixFootprintWaypoints(std::vector<CVector2D>& coords, CmpPtr<ICmpPosition> cmpPosition, CmpPtr<ICmpFootprint> cmpFootprint) const
|
||||
{
|
||||
ENSURE(cmpPosition);
|
||||
ENSURE(cmpFootprint);
|
||||
@ -1052,7 +1052,7 @@ void CCmpRallyPointRenderer::FixFootprintWaypoints(std::vector<CVector2D>& coord
|
||||
}
|
||||
}
|
||||
|
||||
void CCmpRallyPointRenderer::ReduceSegmentsByVisibility(std::vector<CVector2D>& coords, unsigned maxSegmentLinks, bool floating)
|
||||
void CCmpRallyPointRenderer::ReduceSegmentsByVisibility(std::vector<CVector2D>& coords, unsigned maxSegmentLinks, bool floating) const
|
||||
{
|
||||
CmpPtr<ICmpPathfinder> cmpPathFinder(GetSystemEntity());
|
||||
CmpPtr<ICmpTerrain> cmpTerrain(GetSystemEntity());
|
||||
@ -1146,7 +1146,7 @@ void CCmpRallyPointRenderer::ReduceSegmentsByVisibility(std::vector<CVector2D>&
|
||||
coords.swap(newCoords);
|
||||
}
|
||||
|
||||
void CCmpRallyPointRenderer::GetVisibilitySegments(std::deque<SVisibilitySegment>& out, size_t index)
|
||||
void CCmpRallyPointRenderer::GetVisibilitySegments(std::deque<SVisibilitySegment>& out, size_t index) const
|
||||
{
|
||||
out.clear();
|
||||
|
||||
|
@ -269,7 +269,7 @@ struct EntityDistanceOrdering
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()(entity_id_t a, entity_id_t b)
|
||||
bool operator()(entity_id_t a, entity_id_t b) const
|
||||
{
|
||||
const EntityData& da = m_EntityData.find(a)->second;
|
||||
const EntityData& db = m_EntityData.find(b)->second;
|
||||
@ -854,7 +854,7 @@ public:
|
||||
q.enabled = false;
|
||||
}
|
||||
|
||||
virtual bool IsActiveQueryEnabled(tag_t tag)
|
||||
virtual bool IsActiveQueryEnabled(tag_t tag) const
|
||||
{
|
||||
std::map<tag_t, Query>::const_iterator it = m_Queries.find(tag);
|
||||
if (it == m_Queries.end())
|
||||
@ -942,17 +942,17 @@ public:
|
||||
return r;
|
||||
}
|
||||
|
||||
virtual std::vector<entity_id_t> GetEntitiesByPlayer(player_id_t player)
|
||||
virtual std::vector<entity_id_t> GetEntitiesByPlayer(player_id_t player) const
|
||||
{
|
||||
return GetEntitiesByMask(CalcOwnerMask(player));
|
||||
}
|
||||
|
||||
virtual std::vector<entity_id_t> GetNonGaiaEntities()
|
||||
virtual std::vector<entity_id_t> GetNonGaiaEntities() const
|
||||
{
|
||||
return GetEntitiesByMask(((1 << MAX_LOS_PLAYER_ID) - 1) << 1);
|
||||
}
|
||||
|
||||
std::vector<entity_id_t> GetEntitiesByMask(u32 ownerMask)
|
||||
std::vector<entity_id_t> GetEntitiesByMask(u32 ownerMask) const
|
||||
{
|
||||
std::vector<entity_id_t> entities;
|
||||
|
||||
@ -1035,7 +1035,7 @@ public:
|
||||
/**
|
||||
* Returns whether the given entity matches the given query (ignoring maxRange)
|
||||
*/
|
||||
bool TestEntityQuery(const Query& q, entity_id_t id, const EntityData& entity)
|
||||
bool TestEntityQuery(const Query& q, entity_id_t id, const EntityData& entity) const
|
||||
{
|
||||
// Quick filter to ignore entities with the wrong owner
|
||||
if (!(CalcOwnerMask(entity.owner) & q.ownersMask))
|
||||
@ -1152,7 +1152,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual entity_pos_t GetElevationAdaptedRange(const CFixedVector3D& pos1, const CFixedVector3D& rot, entity_pos_t range, entity_pos_t elevationBonus, entity_pos_t angle)
|
||||
virtual entity_pos_t GetElevationAdaptedRange(const CFixedVector3D& pos1, const CFixedVector3D& rot, entity_pos_t range, entity_pos_t elevationBonus, entity_pos_t angle) const
|
||||
{
|
||||
CFixedVector3D pos(pos1);
|
||||
entity_pos_t r = entity_pos_t::Zero() ;
|
||||
@ -1179,15 +1179,13 @@ public:
|
||||
|
||||
}
|
||||
|
||||
virtual std::vector<entity_pos_t> getParabolicRangeForm(CFixedVector3D pos, entity_pos_t maxRange, entity_pos_t cutoff, entity_pos_t minAngle, entity_pos_t maxAngle, int numberOfSteps)
|
||||
virtual std::vector<entity_pos_t> getParabolicRangeForm(CFixedVector3D pos, entity_pos_t maxRange, entity_pos_t cutoff, entity_pos_t minAngle, entity_pos_t maxAngle, int numberOfSteps) const
|
||||
{
|
||||
std::vector<entity_pos_t> r;
|
||||
|
||||
// angle = 0 goes in the positive Z direction
|
||||
entity_pos_t precision = entity_pos_t::FromInt((int)TERRAIN_TILE_SIZE)/8;
|
||||
|
||||
std::vector<entity_pos_t> r;
|
||||
|
||||
|
||||
CmpPtr<ICmpTerrain> cmpTerrain(GetSystemEntity());
|
||||
CmpPtr<ICmpWaterManager> cmpWaterManager(GetSystemEntity());
|
||||
entity_pos_t waterLevel = cmpWaterManager->GetWaterLevel(pos.X,pos.Z);
|
||||
@ -1252,12 +1250,11 @@ public:
|
||||
|
||||
}
|
||||
return r;
|
||||
|
||||
}
|
||||
|
||||
Query ConstructQuery(entity_id_t source,
|
||||
entity_pos_t minRange, entity_pos_t maxRange,
|
||||
const std::vector<int>& owners, int requiredInterface, u8 flagsMask)
|
||||
const std::vector<int>& owners, int requiredInterface, u8 flagsMask) const
|
||||
{
|
||||
// Min range must be non-negative
|
||||
if (minRange < entity_pos_t::Zero())
|
||||
@ -1290,7 +1287,7 @@ public:
|
||||
|
||||
Query ConstructParabolicQuery(entity_id_t source,
|
||||
entity_pos_t minRange, entity_pos_t maxRange, entity_pos_t elevationBonus,
|
||||
const std::vector<int>& owners, int requiredInterface, u8 flagsMask)
|
||||
const std::vector<int>& owners, int requiredInterface, u8 flagsMask) const
|
||||
{
|
||||
Query q = ConstructQuery(source,minRange,maxRange,owners,requiredInterface,flagsMask);
|
||||
q.parabolic = true;
|
||||
@ -1434,7 +1431,7 @@ public:
|
||||
collector.Submit(&m_DebugOverlayLines[i]);
|
||||
}
|
||||
|
||||
virtual u8 GetEntityFlagMask(const std::string& identifier)
|
||||
virtual u8 GetEntityFlagMask(const std::string& identifier) const
|
||||
{
|
||||
if (identifier == "normal")
|
||||
return 1;
|
||||
@ -1472,7 +1469,7 @@ public:
|
||||
|
||||
// LOS implementation:
|
||||
|
||||
virtual CLosQuerier GetLosQuerier(player_id_t player)
|
||||
virtual CLosQuerier GetLosQuerier(player_id_t player) const
|
||||
{
|
||||
if (GetLosRevealAll(player))
|
||||
return CLosQuerier(0xFFFFFFFFu, m_LosStateRevealed, m_TerrainVerticesPerSide);
|
||||
@ -1487,7 +1484,7 @@ public:
|
||||
it->second.scriptedVisibility = status ? 1 : 0;
|
||||
}
|
||||
|
||||
ELosVisibility ComputeLosVisibility(CEntityHandle ent, player_id_t player)
|
||||
ELosVisibility ComputeLosVisibility(CEntityHandle ent, player_id_t player) const
|
||||
{
|
||||
// Entities not with positions in the world are never visible
|
||||
if (ent.GetId() == INVALID_ENTITY)
|
||||
@ -1520,7 +1517,7 @@ public:
|
||||
CmpPtr<ICmpVisibility> cmpVisibility(ent);
|
||||
|
||||
// Possibly ask the scripted Visibility component
|
||||
EntityMap<EntityData>::iterator it = m_EntityData.find(ent.GetId());
|
||||
EntityMap<EntityData>::const_iterator it = m_EntityData.find(ent.GetId());
|
||||
if (it != m_EntityData.end())
|
||||
{
|
||||
if (it->second.scriptedVisibility == 1 && cmpVisibility)
|
||||
@ -1585,13 +1582,13 @@ public:
|
||||
return VIS_FOGGED;
|
||||
}
|
||||
|
||||
ELosVisibility ComputeLosVisibility(entity_id_t ent, player_id_t player)
|
||||
ELosVisibility ComputeLosVisibility(entity_id_t ent, player_id_t player) const
|
||||
{
|
||||
CEntityHandle handle = GetSimContext().GetComponentManager().LookupEntityHandle(ent);
|
||||
return ComputeLosVisibility(handle, player);
|
||||
}
|
||||
|
||||
virtual ELosVisibility GetLosVisibility(CEntityHandle ent, player_id_t player)
|
||||
virtual ELosVisibility GetLosVisibility(CEntityHandle ent, player_id_t player) const
|
||||
{
|
||||
entity_id_t entId = ent.GetId();
|
||||
|
||||
@ -1615,20 +1612,20 @@ public:
|
||||
if (std::find(m_ModifiedEntities.begin(), m_ModifiedEntities.end(), entId) != m_ModifiedEntities.end())
|
||||
return ComputeLosVisibility(ent, player);
|
||||
|
||||
EntityMap<EntityData>::iterator it = m_EntityData.find(entId);
|
||||
EntityMap<EntityData>::const_iterator it = m_EntityData.find(entId);
|
||||
if (it == m_EntityData.end())
|
||||
return ComputeLosVisibility(ent, player);
|
||||
|
||||
return static_cast<ELosVisibility>(GetPlayerVisibility(it->second.visibilities, player));
|
||||
}
|
||||
|
||||
virtual ELosVisibility GetLosVisibility(entity_id_t ent, player_id_t player)
|
||||
virtual ELosVisibility GetLosVisibility(entity_id_t ent, player_id_t player) const
|
||||
{
|
||||
CEntityHandle handle = GetSimContext().GetComponentManager().LookupEntityHandle(ent);
|
||||
return GetLosVisibility(handle, player);
|
||||
}
|
||||
|
||||
i32 PosToLosTilesHelper(entity_pos_t x, entity_pos_t z)
|
||||
i32 PosToLosTilesHelper(entity_pos_t x, entity_pos_t z) const
|
||||
{
|
||||
i32 i = Clamp(
|
||||
(x/(entity_pos_t::FromInt(TERRAIN_TILE_SIZE * LOS_TILES_RATIO))).ToInt_RoundToZero(),
|
||||
@ -1736,7 +1733,7 @@ public:
|
||||
m_GlobalVisibilityUpdate = true;
|
||||
}
|
||||
|
||||
virtual bool GetLosRevealAll(player_id_t player)
|
||||
virtual bool GetLosRevealAll(player_id_t player) const
|
||||
{
|
||||
// Special player value can force reveal-all for every player
|
||||
if (m_LosRevealAll[MAX_LOS_PLAYER_ID+1] || player == -1)
|
||||
@ -1756,7 +1753,7 @@ public:
|
||||
ResetDerivedData();
|
||||
}
|
||||
|
||||
virtual bool GetLosCircular()
|
||||
virtual bool GetLosCircular() const
|
||||
{
|
||||
return m_LosCircular;
|
||||
}
|
||||
@ -1783,7 +1780,7 @@ public:
|
||||
m_GlobalPlayerVisibilityUpdate[player-1] = 1;
|
||||
}
|
||||
|
||||
virtual u32 GetSharedLosMask(player_id_t player)
|
||||
virtual u32 GetSharedLosMask(player_id_t player) const
|
||||
{
|
||||
return m_SharedLosMasks[player];
|
||||
}
|
||||
@ -1854,7 +1851,7 @@ public:
|
||||
* This is useful for miraging entities inside the territory borders at the beginning of a game,
|
||||
* or if the "Explore Map" option has been set.
|
||||
*/
|
||||
void SeeExploredEntities(player_id_t p)
|
||||
void SeeExploredEntities(player_id_t p) const
|
||||
{
|
||||
// Warning: Code related to fogging (like ForceMiraging) shouldn't be
|
||||
// invoked while iterating through m_EntityData.
|
||||
@ -1863,7 +1860,7 @@ public:
|
||||
// So we just remember what entities to mirage and do that later.
|
||||
std::vector<entity_id_t> miragableEntities;
|
||||
|
||||
for (EntityMap<EntityData>::iterator it = m_EntityData.begin(); it != m_EntityData.end(); ++it)
|
||||
for (EntityMap<EntityData>::const_iterator it = m_EntityData.begin(); it != m_EntityData.end(); ++it)
|
||||
{
|
||||
CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), it->first);
|
||||
if (!cmpPosition || !cmpPosition->IsInWorld())
|
||||
@ -1925,7 +1922,7 @@ public:
|
||||
* Returns whether the given vertex is outside the normal bounds of the world
|
||||
* (i.e. outside the range of a circular map)
|
||||
*/
|
||||
inline bool LosIsOffWorld(ssize_t i, ssize_t j)
|
||||
inline bool LosIsOffWorld(ssize_t i, ssize_t j) const
|
||||
{
|
||||
// WARNING: CCmpPathfinder::UpdateGrid needs to be kept in sync with this
|
||||
const ssize_t edgeSize = 3; // number of vertexes around the edge that will be off-world
|
||||
@ -2288,12 +2285,12 @@ public:
|
||||
LosUpdateHelperIncremental((u8)owner, visionRange, from, to);
|
||||
}
|
||||
|
||||
virtual u8 GetPercentMapExplored(player_id_t player)
|
||||
virtual u8 GetPercentMapExplored(player_id_t player) const
|
||||
{
|
||||
return m_ExploredVertices.at((u8)player) * 100 / m_TotalInworldVertices;
|
||||
}
|
||||
|
||||
virtual u8 GetUnionPercentMapExplored(const std::vector<player_id_t>& players)
|
||||
virtual u8 GetUnionPercentMapExplored(const std::vector<player_id_t>& players) const
|
||||
{
|
||||
u32 exploredVertices = 0;
|
||||
std::vector<player_id_t>::const_iterator playerIt;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -211,7 +211,7 @@ public:
|
||||
UpdateMessageSubscriptions();
|
||||
}
|
||||
|
||||
virtual bool IsEditorOnly()
|
||||
virtual bool IsEditorOnly() const
|
||||
{
|
||||
return m_EditorOnly;
|
||||
}
|
||||
|
@ -106,17 +106,17 @@ public:
|
||||
|
||||
virtual const CParamNode* GetTemplateWithoutValidation(const std::string& templateName);
|
||||
|
||||
virtual bool TemplateExists(const std::string& templateName);
|
||||
virtual bool TemplateExists(const std::string& templateName) const;
|
||||
|
||||
virtual const CParamNode* LoadLatestTemplate(entity_id_t ent);
|
||||
|
||||
virtual std::string GetCurrentTemplateName(entity_id_t ent);
|
||||
virtual std::string GetCurrentTemplateName(entity_id_t ent) const;
|
||||
|
||||
virtual std::vector<std::string> FindAllTemplates(bool includeActors);
|
||||
virtual std::vector<std::string> FindAllTemplates(bool includeActors) const;
|
||||
|
||||
virtual std::vector<std::string> FindAllPlaceableTemplates(bool includeActors);
|
||||
virtual std::vector<std::string> FindAllPlaceableTemplates(bool includeActors) const;
|
||||
|
||||
virtual std::vector<entity_id_t> GetEntitiesUsingTemplate(const std::string& templateName);
|
||||
virtual std::vector<entity_id_t> GetEntitiesUsingTemplate(const std::string& templateName) const;
|
||||
|
||||
private:
|
||||
// Template loader
|
||||
@ -189,7 +189,7 @@ const CParamNode* CCmpTemplateManager::GetTemplateWithoutValidation(const std::s
|
||||
return &templateRoot;
|
||||
}
|
||||
|
||||
bool CCmpTemplateManager::TemplateExists(const std::string& templateName)
|
||||
bool CCmpTemplateManager::TemplateExists(const std::string& templateName) const
|
||||
{
|
||||
return m_templateLoader.TemplateExists(templateName);
|
||||
}
|
||||
@ -202,7 +202,7 @@ const CParamNode* CCmpTemplateManager::LoadLatestTemplate(entity_id_t ent)
|
||||
return LoadTemplate(ent, it->second);
|
||||
}
|
||||
|
||||
std::string CCmpTemplateManager::GetCurrentTemplateName(entity_id_t ent)
|
||||
std::string CCmpTemplateManager::GetCurrentTemplateName(entity_id_t ent) const
|
||||
{
|
||||
std::map<entity_id_t, std::string>::const_iterator it = m_LatestTemplates.find(ent);
|
||||
if (it == m_LatestTemplates.end())
|
||||
@ -210,13 +210,13 @@ std::string CCmpTemplateManager::GetCurrentTemplateName(entity_id_t ent)
|
||||
return it->second;
|
||||
}
|
||||
|
||||
std::vector<std::string> CCmpTemplateManager::FindAllTemplates(bool includeActors)
|
||||
std::vector<std::string> CCmpTemplateManager::FindAllTemplates(bool includeActors) const
|
||||
{
|
||||
ETemplatesType templatesType = includeActors ? ALL_TEMPLATES : SIMULATION_TEMPLATES;
|
||||
return m_templateLoader.FindTemplates("", true, templatesType);
|
||||
}
|
||||
|
||||
std::vector<std::string> CCmpTemplateManager::FindAllPlaceableTemplates(bool includeActors)
|
||||
std::vector<std::string> CCmpTemplateManager::FindAllPlaceableTemplates(bool includeActors) const
|
||||
{
|
||||
ScriptInterface& scriptInterface = this->GetSimContext().GetScriptInterface();
|
||||
|
||||
@ -227,13 +227,12 @@ std::vector<std::string> CCmpTemplateManager::FindAllPlaceableTemplates(bool inc
|
||||
/**
|
||||
* Get the list of entities using the specified template
|
||||
*/
|
||||
std::vector<entity_id_t> CCmpTemplateManager::GetEntitiesUsingTemplate(const std::string& templateName)
|
||||
std::vector<entity_id_t> CCmpTemplateManager::GetEntitiesUsingTemplate(const std::string& templateName) const
|
||||
{
|
||||
std::vector<entity_id_t> entities;
|
||||
for (std::map<entity_id_t, std::string>::const_iterator it = m_LatestTemplates.begin(); it != m_LatestTemplates.end(); ++it)
|
||||
{
|
||||
if(it->second == templateName)
|
||||
entities.push_back(it->first);
|
||||
}
|
||||
for (const std::pair<entity_id_t, std::string>& p : m_LatestTemplates)
|
||||
if (p.second == templateName)
|
||||
entities.push_back(p.first);
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -63,36 +63,36 @@ public:
|
||||
Init(paramNode);
|
||||
}
|
||||
|
||||
virtual bool IsLoaded()
|
||||
virtual bool IsLoaded() const
|
||||
{
|
||||
return m_Terrain->GetVerticesPerSide() != 0;
|
||||
}
|
||||
|
||||
virtual CFixedVector3D CalcNormal(entity_pos_t x, entity_pos_t z)
|
||||
virtual CFixedVector3D CalcNormal(entity_pos_t x, entity_pos_t z) const
|
||||
{
|
||||
CFixedVector3D normal;
|
||||
m_Terrain->CalcNormalFixed((x / (int)TERRAIN_TILE_SIZE).ToInt_RoundToZero(), (z / (int)TERRAIN_TILE_SIZE).ToInt_RoundToZero(), normal);
|
||||
return normal;
|
||||
}
|
||||
|
||||
virtual CVector3D CalcExactNormal(float x, float z)
|
||||
virtual CVector3D CalcExactNormal(float x, float z) const
|
||||
{
|
||||
return m_Terrain->CalcExactNormal(x, z);
|
||||
}
|
||||
|
||||
virtual entity_pos_t GetGroundLevel(entity_pos_t x, entity_pos_t z)
|
||||
virtual entity_pos_t GetGroundLevel(entity_pos_t x, entity_pos_t z) const
|
||||
{
|
||||
// TODO: this can crash if the terrain heightmap isn't initialised yet
|
||||
|
||||
return m_Terrain->GetExactGroundLevelFixed(x, z);
|
||||
}
|
||||
|
||||
virtual float GetExactGroundLevel(float x, float z)
|
||||
virtual float GetExactGroundLevel(float x, float z) const
|
||||
{
|
||||
return m_Terrain->GetExactGroundLevel(x, z);
|
||||
}
|
||||
|
||||
virtual u16 GetTilesPerSide()
|
||||
virtual u16 GetTilesPerSide() const
|
||||
{
|
||||
ssize_t tiles = m_Terrain->GetTilesPerSide();
|
||||
|
||||
@ -102,7 +102,7 @@ public:
|
||||
return (u16)tiles;
|
||||
}
|
||||
|
||||
virtual u16 GetVerticesPerSide()
|
||||
virtual u16 GetVerticesPerSide() const
|
||||
{
|
||||
ssize_t vertices = m_Terrain->GetVerticesPerSide();
|
||||
ENSURE(1 <= vertices && vertices <= 65535);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -73,17 +73,17 @@ public:
|
||||
Init(paramNode);
|
||||
}
|
||||
|
||||
virtual bool IsRoot()
|
||||
virtual bool IsRoot() const
|
||||
{
|
||||
return m_Root;
|
||||
}
|
||||
|
||||
virtual u16 GetWeight()
|
||||
virtual u16 GetWeight() const
|
||||
{
|
||||
return m_Weight;
|
||||
}
|
||||
|
||||
virtual u32 GetRadius()
|
||||
virtual u32 GetRadius() const
|
||||
{
|
||||
CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSystemEntity());
|
||||
if (!cmpValueModificationManager)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -256,7 +256,7 @@ public:
|
||||
m_TriggerEvent = true;
|
||||
}
|
||||
|
||||
virtual bool NeedUpdate(size_t* dirtyID)
|
||||
virtual bool NeedUpdate(size_t* dirtyID) const
|
||||
{
|
||||
if (*dirtyID != m_DirtyID)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -439,32 +439,32 @@ public:
|
||||
GetSimContext().GetComponentManager().DynamicSubscriptionNonsync(MT_RenderSubmit, this, needRender);
|
||||
}
|
||||
|
||||
virtual bool IsMoving()
|
||||
virtual bool IsMoving() const
|
||||
{
|
||||
return m_Moving;
|
||||
}
|
||||
|
||||
virtual fixed GetWalkSpeed()
|
||||
virtual fixed GetWalkSpeed() const
|
||||
{
|
||||
return m_WalkSpeed;
|
||||
}
|
||||
|
||||
virtual fixed GetRunSpeed()
|
||||
virtual fixed GetRunSpeed() const
|
||||
{
|
||||
return m_RunSpeed;
|
||||
}
|
||||
|
||||
virtual pass_class_t GetPassabilityClass()
|
||||
virtual pass_class_t GetPassabilityClass() const
|
||||
{
|
||||
return m_PassClass;
|
||||
}
|
||||
|
||||
virtual std::string GetPassabilityClassName()
|
||||
virtual std::string GetPassabilityClassName() const
|
||||
{
|
||||
return m_PassClassName;
|
||||
}
|
||||
|
||||
virtual void SetPassabilityClassName(std::string passClassName)
|
||||
virtual void SetPassabilityClassName(const std::string& passClassName)
|
||||
{
|
||||
m_PassClassName = passClassName;
|
||||
CmpPtr<ICmpPathfinder> cmpPathfinder(GetSystemEntity());
|
||||
@ -472,7 +472,7 @@ public:
|
||||
m_PassClass = cmpPathfinder->GetPassabilityClass(passClassName);
|
||||
}
|
||||
|
||||
virtual fixed GetCurrentSpeed()
|
||||
virtual fixed GetCurrentSpeed() const
|
||||
{
|
||||
return m_CurSpeed;
|
||||
}
|
||||
@ -494,9 +494,9 @@ public:
|
||||
}
|
||||
|
||||
virtual bool MoveToPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange);
|
||||
virtual bool IsInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange);
|
||||
virtual bool IsInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange) const;
|
||||
virtual bool MoveToTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange);
|
||||
virtual bool IsInTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange);
|
||||
virtual bool IsInTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) const;
|
||||
virtual void MoveToFormationOffset(entity_id_t target, entity_pos_t x, entity_pos_t z);
|
||||
|
||||
virtual void FaceTowardsPoint(entity_pos_t x, entity_pos_t z);
|
||||
@ -511,7 +511,7 @@ public:
|
||||
m_ShortPath.m_Waypoints.clear();
|
||||
}
|
||||
|
||||
virtual entity_pos_t GetUnitClearance()
|
||||
virtual entity_pos_t GetUnitClearance() const
|
||||
{
|
||||
return m_Clearance;
|
||||
}
|
||||
@ -613,7 +613,7 @@ private:
|
||||
* Computes the current location of our target entity (plus offset).
|
||||
* Returns false if no target entity or no valid position.
|
||||
*/
|
||||
bool ComputeTargetPosition(CFixedVector2D& out);
|
||||
bool ComputeTargetPosition(CFixedVector2D& out) const;
|
||||
|
||||
/**
|
||||
* Attempts to replace the current path with a straight line to the goal,
|
||||
@ -1063,7 +1063,7 @@ void CCmpUnitMotion::Move(fixed dt)
|
||||
}
|
||||
}
|
||||
|
||||
bool CCmpUnitMotion::ComputeTargetPosition(CFixedVector2D& out)
|
||||
bool CCmpUnitMotion::ComputeTargetPosition(CFixedVector2D& out) const
|
||||
{
|
||||
if (m_TargetEntity == INVALID_ENTITY)
|
||||
return false;
|
||||
@ -1455,7 +1455,7 @@ bool CCmpUnitMotion::MoveToPointRange(entity_pos_t x, entity_pos_t z, entity_pos
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCmpUnitMotion::IsInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange)
|
||||
bool CCmpUnitMotion::IsInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange) const
|
||||
{
|
||||
CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle());
|
||||
if (!cmpPosition || !cmpPosition->IsInWorld())
|
||||
@ -1668,7 +1668,7 @@ bool CCmpUnitMotion::MoveToTargetRange(entity_id_t target, entity_pos_t minRange
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCmpUnitMotion::IsInTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange)
|
||||
bool CCmpUnitMotion::IsInTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) const
|
||||
{
|
||||
// This function closely mirrors MoveToTargetRange - it needs to return true
|
||||
// after that Move has completed
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -256,9 +256,9 @@ public:
|
||||
void Interpolate(float frameTime, float frameOffset);
|
||||
void RenderSubmit(SceneCollector& collector, const CFrustum& frustum, bool culling);
|
||||
|
||||
void UpdateVisibility(SUnit& unit);
|
||||
void UpdateVisibility(SUnit& unit) const;
|
||||
|
||||
virtual float GetFrameOffset()
|
||||
virtual float GetFrameOffset() const
|
||||
{
|
||||
return m_FrameOffset;
|
||||
}
|
||||
@ -268,14 +268,13 @@ public:
|
||||
m_EnableDebugOverlays = enabled;
|
||||
}
|
||||
|
||||
virtual void PickAllEntitiesAtPoint(std::vector<std::pair<CEntityHandle, CVector3D> >& outEntities, const CVector3D& origin, const CVector3D& dir, bool allowEditorSelectables)
|
||||
virtual void PickAllEntitiesAtPoint(std::vector<std::pair<CEntityHandle, CVector3D> >& outEntities, const CVector3D& origin, const CVector3D& dir, bool allowEditorSelectables) const
|
||||
{
|
||||
// First, make a rough test with the worst-case bounding boxes to pick all
|
||||
// entities/models that could possibly be hit by the ray.
|
||||
std::vector<SUnit*> candidates;
|
||||
for (size_t i = 0; i < m_Units.size(); ++i)
|
||||
std::vector<const SUnit*> candidates;
|
||||
for (const SUnit& unit : m_Units)
|
||||
{
|
||||
SUnit& unit = m_Units[i];
|
||||
if (!unit.actor || !unit.inWorld)
|
||||
continue;
|
||||
if (unit.sweptBounds.RayIntersect(origin, dir))
|
||||
@ -442,7 +441,7 @@ void CCmpUnitRenderer::RenderSubmit(SceneCollector& collector, const CFrustum& f
|
||||
collector.Submit(&m_DebugSpheres[i]);
|
||||
}
|
||||
|
||||
void CCmpUnitRenderer::UpdateVisibility(SUnit& unit)
|
||||
void CCmpUnitRenderer::UpdateVisibility(SUnit& unit) const
|
||||
{
|
||||
if (unit.inWorld)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -130,12 +130,12 @@ public:
|
||||
GetSimContext().GetComponentManager().BroadcastMessage(msg);
|
||||
}
|
||||
|
||||
virtual entity_pos_t GetRange()
|
||||
virtual entity_pos_t GetRange() const
|
||||
{
|
||||
return m_Range;
|
||||
}
|
||||
|
||||
virtual bool GetRevealShore()
|
||||
virtual bool GetRevealShore() const
|
||||
{
|
||||
return m_RevealShore;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -347,7 +347,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual CBoundingBoxAligned GetBounds()
|
||||
virtual CBoundingBoxAligned GetBounds() const
|
||||
{
|
||||
if (!m_Unit)
|
||||
return CBoundingBoxAligned::EMPTY;
|
||||
@ -359,35 +359,35 @@ public:
|
||||
return m_Unit;
|
||||
}
|
||||
|
||||
virtual CBoundingBoxOriented GetSelectionBox()
|
||||
virtual CBoundingBoxOriented GetSelectionBox() const
|
||||
{
|
||||
if (!m_Unit)
|
||||
return CBoundingBoxOriented::EMPTY;
|
||||
return m_Unit->GetModel().GetSelectionBox();
|
||||
}
|
||||
|
||||
virtual CVector3D GetPosition()
|
||||
virtual CVector3D GetPosition() const
|
||||
{
|
||||
if (!m_Unit)
|
||||
return CVector3D(0, 0, 0);
|
||||
return m_Unit->GetModel().GetTransform().GetTranslation();
|
||||
}
|
||||
|
||||
virtual std::wstring GetActorShortName()
|
||||
virtual std::wstring GetActorShortName() const
|
||||
{
|
||||
if (!m_Unit)
|
||||
return L"";
|
||||
return m_Unit->GetObject().m_Base->m_ShortName;
|
||||
}
|
||||
|
||||
virtual std::wstring GetProjectileActor()
|
||||
virtual std::wstring GetProjectileActor() const
|
||||
{
|
||||
if (!m_Unit)
|
||||
return L"";
|
||||
return m_Unit->GetObject().m_ProjectileModelName;
|
||||
}
|
||||
|
||||
virtual CVector3D GetProjectileLaunchPoint()
|
||||
virtual CVector3D GetProjectileLaunchPoint() const
|
||||
{
|
||||
if (!m_Unit)
|
||||
return CVector3D();
|
||||
@ -492,7 +492,7 @@ public:
|
||||
m_Unit->GetModel().SetEntityVariable(name, value);
|
||||
}
|
||||
|
||||
virtual u32 GetActorSeed()
|
||||
virtual u32 GetActorSeed() const
|
||||
{
|
||||
return m_Seed;
|
||||
}
|
||||
@ -506,7 +506,7 @@ public:
|
||||
ReloadActor();
|
||||
}
|
||||
|
||||
virtual bool HasConstructionPreview()
|
||||
virtual bool HasConstructionPreview() const
|
||||
{
|
||||
return m_ConstructionPreview;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -124,12 +124,12 @@ public:
|
||||
GetSimContext().GetComponentManager().BroadcastMessage(msg);
|
||||
}
|
||||
|
||||
virtual entity_pos_t GetWaterLevel(entity_pos_t UNUSED(x), entity_pos_t UNUSED(z))
|
||||
virtual entity_pos_t GetWaterLevel(entity_pos_t UNUSED(x), entity_pos_t UNUSED(z)) const
|
||||
{
|
||||
return m_WaterHeight;
|
||||
}
|
||||
|
||||
virtual float GetExactWaterLevel(float UNUSED(x), float UNUSED(z))
|
||||
virtual float GetExactWaterLevel(float UNUSED(x), float UNUSED(z)) const
|
||||
{
|
||||
return m_WaterHeight.ToFloat();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -24,7 +24,7 @@
|
||||
#include "simulation2/system/SimContext.h"
|
||||
#include "maths/FixedVector3D.h"
|
||||
|
||||
JS::Value ICmpFootprint::GetShape_wrapper()
|
||||
JS::Value ICmpFootprint::GetShape_wrapper() const
|
||||
{
|
||||
EShape shape;
|
||||
entity_pos_t size0, size1, height;
|
||||
@ -69,7 +69,7 @@ JS::Value ICmpFootprint::GetShape_wrapper()
|
||||
}
|
||||
|
||||
BEGIN_INTERFACE_WRAPPER(Footprint)
|
||||
DEFINE_INTERFACE_METHOD_1("PickSpawnPoint", CFixedVector3D, ICmpFootprint, PickSpawnPoint, entity_id_t)
|
||||
DEFINE_INTERFACE_METHOD_1("PickSpawnPointBothPass", CFixedVector3D, ICmpFootprint, PickSpawnPointBothPass, entity_id_t)
|
||||
DEFINE_INTERFACE_METHOD_0("GetShape", JS::Value, ICmpFootprint, GetShape_wrapper)
|
||||
DEFINE_INTERFACE_METHOD_CONST_1("PickSpawnPoint", CFixedVector3D, ICmpFootprint, PickSpawnPoint, entity_id_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_1("PickSpawnPointBothPass", CFixedVector3D, ICmpFootprint, PickSpawnPointBothPass, entity_id_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetShape", JS::Value, ICmpFootprint, GetShape_wrapper)
|
||||
END_INTERFACE_WRAPPER(Footprint)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -47,14 +47,14 @@ public:
|
||||
* @param[out] size1 if CIRCLE then radius, else depth (size in Z axis)
|
||||
* @param[out] height size in Y axis
|
||||
*/
|
||||
virtual void GetShape(EShape& shape, entity_pos_t& size0, entity_pos_t& size1, entity_pos_t& height) = 0;
|
||||
virtual void GetShape(EShape& shape, entity_pos_t& size0, entity_pos_t& size1, entity_pos_t& height) const = 0;
|
||||
|
||||
/**
|
||||
* GetShape wrapper for script calls.
|
||||
* Returns { "type": "circle", "radius": 5.0, "height": 1.0 }
|
||||
* or { "type": "square", "width": 5.0, "depth": 5.0, "height": 1.0 }
|
||||
*/
|
||||
JS::Value GetShape_wrapper();
|
||||
JS::Value GetShape_wrapper() const;
|
||||
|
||||
/**
|
||||
* Pick a sensible position to place a newly-spawned entity near this footprint,
|
||||
@ -62,14 +62,14 @@ public:
|
||||
* orientation.
|
||||
* @return the X and Z coordinates of the spawn point, with Y = 0; or the special value (-1, -1, -1) if there's no space
|
||||
*/
|
||||
virtual CFixedVector3D PickSpawnPoint(entity_id_t spawned) = 0;
|
||||
virtual CFixedVector3D PickSpawnPoint(entity_id_t spawned) const = 0;
|
||||
|
||||
/**
|
||||
* Pick a sensible position to place a newly-spawned entity near this footprint,
|
||||
* at the intersection between the footprint passability and the entity one.
|
||||
* @return the X and Z coordinates of the spawn point, with Y = 0; or the special value (-1, -1, -1) if there's no space
|
||||
*/
|
||||
virtual CFixedVector3D PickSpawnPointBothPass(entity_id_t spawned) = 0;
|
||||
virtual CFixedVector3D PickSpawnPointBothPass(entity_id_t spawned) const = 0;
|
||||
|
||||
DECLARE_INTERFACE_TYPE(Footprint)
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -33,7 +33,7 @@ public:
|
||||
* If it should not be drawn, returns false; otherwise the arguments are set
|
||||
* to the color and world position.
|
||||
*/
|
||||
virtual bool GetRenderData(u8& r, u8& g, u8& b, entity_pos_t& x, entity_pos_t& z) = 0;
|
||||
virtual bool GetRenderData(u8& r, u8& g, u8& b, entity_pos_t& x, entity_pos_t& z) const = 0;
|
||||
|
||||
/**
|
||||
* Return true if entity is actively pinging based on the current time
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
#include "simulation2/system/SimContext.h"
|
||||
|
||||
std::string ICmpObstruction::CheckFoundation_wrapper(const std::string& className, bool onlyCenterPoint)
|
||||
std::string ICmpObstruction::CheckFoundation_wrapper(const std::string& className, bool onlyCenterPoint) const
|
||||
{
|
||||
EFoundationCheck check = CheckFoundation(className, onlyCenterPoint);
|
||||
|
||||
@ -46,15 +46,15 @@ std::string ICmpObstruction::CheckFoundation_wrapper(const std::string& classNam
|
||||
}
|
||||
|
||||
BEGIN_INTERFACE_WRAPPER(Obstruction)
|
||||
DEFINE_INTERFACE_METHOD_0("GetUnitRadius", entity_pos_t, ICmpObstruction, GetUnitRadius)
|
||||
DEFINE_INTERFACE_METHOD_2("CheckFoundation", std::string, ICmpObstruction, CheckFoundation_wrapper, std::string, bool)
|
||||
DEFINE_INTERFACE_METHOD_0("CheckDuplicateFoundation", bool, ICmpObstruction, CheckDuplicateFoundation)
|
||||
DEFINE_INTERFACE_METHOD_0("GetUnitCollisions", std::vector<entity_id_t>, ICmpObstruction, GetUnitCollisions)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetUnitRadius", entity_pos_t, ICmpObstruction, GetUnitRadius)
|
||||
DEFINE_INTERFACE_METHOD_CONST_2("CheckFoundation", std::string, ICmpObstruction, CheckFoundation_wrapper, std::string, bool)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("CheckDuplicateFoundation", bool, ICmpObstruction, CheckDuplicateFoundation)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetUnitCollisions", std::vector<entity_id_t>, ICmpObstruction, GetUnitCollisions)
|
||||
DEFINE_INTERFACE_METHOD_1("SetActive", void, ICmpObstruction, SetActive, bool)
|
||||
DEFINE_INTERFACE_METHOD_3("SetDisableBlockMovementPathfinding", void, ICmpObstruction, SetDisableBlockMovementPathfinding, bool, bool, int32_t)
|
||||
DEFINE_INTERFACE_METHOD_0("GetBlockMovementFlag", bool, ICmpObstruction, GetBlockMovementFlag)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetBlockMovementFlag", bool, ICmpObstruction, GetBlockMovementFlag)
|
||||
DEFINE_INTERFACE_METHOD_1("SetControlGroup", void, ICmpObstruction, SetControlGroup, entity_id_t)
|
||||
DEFINE_INTERFACE_METHOD_0("GetControlGroup", entity_id_t, ICmpObstruction, GetControlGroup)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetControlGroup", entity_id_t, ICmpObstruction, GetControlGroup)
|
||||
DEFINE_INTERFACE_METHOD_1("SetControlGroup2", void, ICmpObstruction, SetControlGroup2, entity_id_t)
|
||||
DEFINE_INTERFACE_METHOD_0("GetControlGroup2", entity_id_t, ICmpObstruction, GetControlGroup2)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetControlGroup2", entity_id_t, ICmpObstruction, GetControlGroup2)
|
||||
END_INTERFACE_WRAPPER(Obstruction)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -38,27 +38,27 @@ public:
|
||||
FOUNDATION_CHECK_FAIL_TERRAIN_CLASS
|
||||
};
|
||||
|
||||
virtual ICmpObstructionManager::tag_t GetObstruction() = 0;
|
||||
virtual ICmpObstructionManager::tag_t GetObstruction() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the square corresponding to this obstruction shape.
|
||||
* @return true and updates @p out on success;
|
||||
* false on failure (e.g. object not in the world).
|
||||
*/
|
||||
virtual bool GetObstructionSquare(ICmpObstructionManager::ObstructionSquare& out) = 0;
|
||||
virtual bool GetObstructionSquare(ICmpObstructionManager::ObstructionSquare& out) const = 0;
|
||||
|
||||
/**
|
||||
* Same as the method above, but returns an obstruction shape for the previous turn
|
||||
*/
|
||||
virtual bool GetPreviousObstructionSquare(ICmpObstructionManager::ObstructionSquare& out) = 0;
|
||||
virtual bool GetPreviousObstructionSquare(ICmpObstructionManager::ObstructionSquare& out) const = 0;
|
||||
|
||||
virtual entity_pos_t GetSize() = 0;
|
||||
virtual entity_pos_t GetSize() const = 0;
|
||||
|
||||
virtual entity_pos_t GetUnitRadius() = 0;
|
||||
virtual entity_pos_t GetUnitRadius() const = 0;
|
||||
|
||||
virtual void SetUnitClearance(const entity_pos_t& clearance) = 0;
|
||||
|
||||
virtual bool IsControlPersistent() = 0;
|
||||
virtual bool IsControlPersistent() const = 0;
|
||||
|
||||
/**
|
||||
* Test whether this entity is colliding with any obstruction that are set to
|
||||
@ -67,33 +67,33 @@ public:
|
||||
* @return FOUNDATION_CHECK_SUCCESS if check passes, else an EFoundationCheck
|
||||
* value describing the type of failure.
|
||||
*/
|
||||
virtual EFoundationCheck CheckFoundation(std::string className) = 0;
|
||||
virtual EFoundationCheck CheckFoundation(std::string className, bool onlyCenterPoint) = 0;
|
||||
virtual EFoundationCheck CheckFoundation(const std::string& className) const = 0;
|
||||
virtual EFoundationCheck CheckFoundation(const std::string& className, bool onlyCenterPoint) const = 0;
|
||||
|
||||
/**
|
||||
* CheckFoundation wrapper for script calls, to return friendly strings instead of an EFoundationCheck.
|
||||
* @return "success" if check passes, else a string describing the type of failure.
|
||||
*/
|
||||
virtual std::string CheckFoundation_wrapper(const std::string& className, bool onlyCenterPoint);
|
||||
virtual std::string CheckFoundation_wrapper(const std::string& className, bool onlyCenterPoint) const;
|
||||
|
||||
/**
|
||||
* Test whether this entity is colliding with any obstructions that share its
|
||||
* control groups and block the creation of foundations.
|
||||
* @return true if foundation is valid (not obstructed)
|
||||
*/
|
||||
virtual bool CheckDuplicateFoundation() = 0;
|
||||
virtual bool CheckDuplicateFoundation() const = 0;
|
||||
|
||||
/**
|
||||
* Returns a list of units that are colliding with this entity,
|
||||
* @return vector of blocking units
|
||||
*/
|
||||
virtual std::vector<entity_id_t> GetUnitCollisions() = 0;
|
||||
virtual std::vector<entity_id_t> GetUnitCollisions() const = 0;
|
||||
|
||||
/**
|
||||
* Detects collisions between foundation-blocking entities and
|
||||
* tries to fix them by setting control groups, if appropriate.
|
||||
*/
|
||||
virtual void ResolveFoundationCollisions() = 0;
|
||||
virtual void ResolveFoundationCollisions() const = 0;
|
||||
|
||||
virtual void SetActive(bool active) = 0;
|
||||
|
||||
@ -101,7 +101,7 @@ public:
|
||||
|
||||
virtual void SetDisableBlockMovementPathfinding(bool movementDisabled, bool pathfindingDisabled, int32_t shape) = 0;
|
||||
|
||||
virtual bool GetBlockMovementFlag() = 0;
|
||||
virtual bool GetBlockMovementFlag() const = 0;
|
||||
|
||||
/**
|
||||
* Change the control group that the entity belongs to.
|
||||
@ -111,10 +111,10 @@ public:
|
||||
virtual void SetControlGroup(entity_id_t group) = 0;
|
||||
|
||||
/// See SetControlGroup.
|
||||
virtual entity_id_t GetControlGroup() = 0;
|
||||
virtual entity_id_t GetControlGroup() const = 0;
|
||||
|
||||
virtual void SetControlGroup2(entity_id_t group2) = 0;
|
||||
virtual entity_id_t GetControlGroup2() = 0;
|
||||
virtual entity_id_t GetControlGroup2() const = 0;
|
||||
|
||||
DECLARE_INTERFACE_TYPE(Obstruction)
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -61,7 +61,7 @@ public:
|
||||
{
|
||||
tag_t() : n(0) {}
|
||||
explicit tag_t(u32 n) : n(n) {}
|
||||
bool valid() { return n != 0; }
|
||||
bool valid() const { return n != 0; }
|
||||
|
||||
u32 n;
|
||||
};
|
||||
@ -171,7 +171,7 @@ public:
|
||||
* @param relaxClearanceForUnits whether unit-unit collisions should be more permissive.
|
||||
* @return true if there is a collision
|
||||
*/
|
||||
virtual bool TestLine(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, bool relaxClearanceForUnits) = 0;
|
||||
virtual bool TestLine(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, bool relaxClearanceForUnits) const = 0;
|
||||
|
||||
/**
|
||||
* Collision test a static square shape against the current set of shapes.
|
||||
@ -186,7 +186,7 @@ public:
|
||||
*/
|
||||
virtual bool TestStaticShape(const IObstructionTestFilter& filter,
|
||||
entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h,
|
||||
std::vector<entity_id_t>* out) = 0;
|
||||
std::vector<entity_id_t>* out) const = 0;
|
||||
|
||||
/**
|
||||
* Collision test a unit shape against the current set of registered shapes, and optionally writes a list of the colliding
|
||||
@ -202,7 +202,7 @@ public:
|
||||
*/
|
||||
virtual bool TestUnitShape(const IObstructionTestFilter& filter,
|
||||
entity_pos_t x, entity_pos_t z, entity_pos_t clearance,
|
||||
std::vector<entity_id_t>* out) = 0;
|
||||
std::vector<entity_id_t>* out) const = 0;
|
||||
|
||||
/**
|
||||
* Convert the current set of shapes onto a navcell grid, for all passability classes contained in @p passClasses.
|
||||
@ -237,9 +237,9 @@ public:
|
||||
* @param z1 Z coordinate of top edge of range
|
||||
* @param squares output list of obstructions
|
||||
*/
|
||||
virtual void GetObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares) = 0;
|
||||
virtual void GetStaticObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares) = 0;
|
||||
virtual void GetUnitObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares) = 0;
|
||||
virtual void GetObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares) const = 0;
|
||||
virtual void GetStaticObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares) const = 0;
|
||||
virtual void GetUnitObstructionsInRange(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, std::vector<ObstructionSquare>& squares) const = 0;
|
||||
|
||||
/**
|
||||
* Returns the entity IDs of all unit shapes that intersect the given
|
||||
@ -249,17 +249,17 @@ public:
|
||||
* @param filter filter for the obstructing units
|
||||
* @param strict whether to be strict in the check or more permissive (ie rasterize more or less). Default false.
|
||||
*/
|
||||
virtual void GetUnitsOnObstruction(const ObstructionSquare& square, std::vector<entity_id_t>& out, const IObstructionTestFilter& filter, bool strict = false) = 0;
|
||||
virtual void GetUnitsOnObstruction(const ObstructionSquare& square, std::vector<entity_id_t>& out, const IObstructionTestFilter& filter, bool strict = false) const = 0;
|
||||
|
||||
/**
|
||||
* Get the obstruction square representing the given shape.
|
||||
* @param tag tag of shape (must be valid)
|
||||
*/
|
||||
virtual ObstructionSquare GetObstruction(tag_t tag) = 0;
|
||||
virtual ObstructionSquare GetObstruction(tag_t tag) const = 0;
|
||||
|
||||
virtual ObstructionSquare GetUnitShapeObstruction(entity_pos_t x, entity_pos_t z, entity_pos_t clearance) = 0;
|
||||
virtual ObstructionSquare GetUnitShapeObstruction(entity_pos_t x, entity_pos_t z, entity_pos_t clearance) const = 0;
|
||||
|
||||
virtual ObstructionSquare GetStaticShapeObstruction(entity_pos_t x, entity_pos_t z, entity_angle_t a, entity_pos_t w, entity_pos_t h) = 0;
|
||||
virtual ObstructionSquare GetStaticShapeObstruction(entity_pos_t x, entity_pos_t z, entity_angle_t a, entity_pos_t w, entity_pos_t h) const = 0;
|
||||
|
||||
/**
|
||||
* Set the passability to be restricted to a circular map.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -22,7 +22,7 @@
|
||||
#include "simulation2/system/InterfaceScripted.h"
|
||||
|
||||
BEGIN_INTERFACE_WRAPPER(Ownership)
|
||||
DEFINE_INTERFACE_METHOD_0("GetOwner", player_id_t, ICmpOwnership, GetOwner)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetOwner", player_id_t, ICmpOwnership, GetOwner)
|
||||
DEFINE_INTERFACE_METHOD_1("SetOwner", void, ICmpOwnership, SetOwner, player_id_t)
|
||||
DEFINE_INTERFACE_METHOD_1("SetOwnerQuiet", void, ICmpOwnership, SetOwnerQuiet, player_id_t)
|
||||
END_INTERFACE_WRAPPER(Ownership)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -29,7 +29,7 @@
|
||||
class ICmpOwnership : public IComponent
|
||||
{
|
||||
public:
|
||||
virtual player_id_t GetOwner() = 0;
|
||||
virtual player_id_t GetOwner() const = 0;
|
||||
|
||||
virtual void SetOwner(player_id_t playerID) = 0;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -66,7 +66,7 @@ public:
|
||||
* Get the tag for a given passability class name.
|
||||
* Logs an error and returns something acceptable if the name is unrecognised.
|
||||
*/
|
||||
virtual pass_class_t GetPassabilityClass(const std::string& name) = 0;
|
||||
virtual pass_class_t GetPassabilityClass(const std::string& name) const = 0;
|
||||
|
||||
virtual entity_pos_t GetClearance(pass_class_t passClass) const = 0;
|
||||
|
||||
@ -129,7 +129,7 @@ public:
|
||||
* or impassable terrain.
|
||||
* Returns true if the movement is okay.
|
||||
*/
|
||||
virtual bool CheckMovement(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, pass_class_t passClass) = 0;
|
||||
virtual bool CheckMovement(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, pass_class_t passClass) const = 0;
|
||||
|
||||
/**
|
||||
* Check whether a unit placed here is valid and doesn't hit any obstructions
|
||||
@ -138,7 +138,7 @@ public:
|
||||
* @return ICmpObstruction::FOUNDATION_CHECK_SUCCESS if the placement is okay, else
|
||||
* a value describing the type of failure.
|
||||
*/
|
||||
virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool onlyCenterPoint = false) = 0;
|
||||
virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass, bool onlyCenterPoint = false) const = 0;
|
||||
|
||||
/**
|
||||
* Check whether a building placed here is valid and doesn't hit any obstructions
|
||||
@ -146,7 +146,7 @@ public:
|
||||
* @return ICmpObstruction::FOUNDATION_CHECK_SUCCESS if the placement is okay, else
|
||||
* a value describing the type of failure.
|
||||
*/
|
||||
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass) = 0;
|
||||
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass) const = 0;
|
||||
|
||||
/**
|
||||
* Check whether a building placed here is valid and doesn't hit any obstructions
|
||||
@ -155,7 +155,7 @@ public:
|
||||
* @return ICmpObstruction::FOUNDATION_CHECK_SUCCESS if the placement is okay, else
|
||||
* a value describing the type of failure.
|
||||
*/
|
||||
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, bool onlyCenterPoint) = 0;
|
||||
virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, bool onlyCenterPoint) const = 0;
|
||||
|
||||
|
||||
/**
|
||||
@ -186,7 +186,7 @@ public:
|
||||
/**
|
||||
* Returns some stats about the last ComputePath.
|
||||
*/
|
||||
virtual void GetDebugData(u32& steps, double& time, Grid<u8>& grid) = 0;
|
||||
virtual void GetDebugData(u32& steps, double& time, Grid<u8>& grid) const = 0;
|
||||
|
||||
/**
|
||||
* Sets up the pathfinder passability overlay in Atlas.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2011 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -23,28 +23,28 @@
|
||||
|
||||
BEGIN_INTERFACE_WRAPPER(Position)
|
||||
DEFINE_INTERFACE_METHOD_2("SetTurretParent", void, ICmpPosition, SetTurretParent, entity_id_t, CFixedVector3D)
|
||||
DEFINE_INTERFACE_METHOD_0("GetTurretParent", entity_id_t, ICmpPosition, GetTurretParent)
|
||||
DEFINE_INTERFACE_METHOD_0("IsInWorld", bool, ICmpPosition, IsInWorld)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetTurretParent", entity_id_t, ICmpPosition, GetTurretParent)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("IsInWorld", bool, ICmpPosition, IsInWorld)
|
||||
DEFINE_INTERFACE_METHOD_0("MoveOutOfWorld", void, ICmpPosition, MoveOutOfWorld)
|
||||
DEFINE_INTERFACE_METHOD_2("MoveTo", void, ICmpPosition, MoveTo, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_3("MoveAndTurnTo", void, ICmpPosition, MoveAndTurnTo, entity_pos_t, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_2("JumpTo", void, ICmpPosition, JumpTo, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_1("SetHeightOffset", void, ICmpPosition, SetHeightOffset, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_0("GetHeightOffset", entity_pos_t, ICmpPosition, GetHeightOffset)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetHeightOffset", entity_pos_t, ICmpPosition, GetHeightOffset)
|
||||
DEFINE_INTERFACE_METHOD_1("SetHeightFixed", void, ICmpPosition, SetHeightFixed, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_0("GetHeightFixed", entity_pos_t, ICmpPosition, GetHeightFixed)
|
||||
DEFINE_INTERFACE_METHOD_0("IsHeightRelative", bool, ICmpPosition, IsHeightRelative)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetHeightFixed", entity_pos_t, ICmpPosition, GetHeightFixed)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("IsHeightRelative", bool, ICmpPosition, IsHeightRelative)
|
||||
DEFINE_INTERFACE_METHOD_1("SetHeightRelative", void, ICmpPosition, SetHeightRelative, bool)
|
||||
DEFINE_INTERFACE_METHOD_0("IsFloating", bool, ICmpPosition, IsFloating)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("IsFloating", bool, ICmpPosition, IsFloating)
|
||||
DEFINE_INTERFACE_METHOD_1("SetFloating", void, ICmpPosition, SetFloating, bool)
|
||||
DEFINE_INTERFACE_METHOD_1("SetConstructionProgress", void, ICmpPosition, SetConstructionProgress, fixed)
|
||||
DEFINE_INTERFACE_METHOD_0("GetPosition", CFixedVector3D, ICmpPosition, GetPosition)
|
||||
DEFINE_INTERFACE_METHOD_0("GetPosition2D", CFixedVector2D, ICmpPosition, GetPosition2D)
|
||||
DEFINE_INTERFACE_METHOD_0("GetPreviousPosition", CFixedVector3D, ICmpPosition, GetPreviousPosition)
|
||||
DEFINE_INTERFACE_METHOD_0("GetPreviousPosition2D", CFixedVector2D, ICmpPosition, GetPreviousPosition2D)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetPosition", CFixedVector3D, ICmpPosition, GetPosition)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetPosition2D", CFixedVector2D, ICmpPosition, GetPosition2D)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetPreviousPosition", CFixedVector3D, ICmpPosition, GetPreviousPosition)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetPreviousPosition2D", CFixedVector2D, ICmpPosition, GetPreviousPosition2D)
|
||||
DEFINE_INTERFACE_METHOD_1("TurnTo", void, ICmpPosition, TurnTo, entity_angle_t)
|
||||
DEFINE_INTERFACE_METHOD_1("SetYRotation", void, ICmpPosition, SetYRotation, entity_angle_t)
|
||||
DEFINE_INTERFACE_METHOD_2("SetXZRotation", void, ICmpPosition, SetXZRotation, entity_angle_t, entity_angle_t)
|
||||
DEFINE_INTERFACE_METHOD_0("GetRotation", CFixedVector3D, ICmpPosition, GetRotation)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetRotation", CFixedVector3D, ICmpPosition, GetRotation)
|
||||
// Excluded: GetInterpolatedTransform (not safe for scripts)
|
||||
END_INTERFACE_WRAPPER(Position)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -68,7 +68,7 @@ public:
|
||||
/**
|
||||
* Get the turret parent of this entity
|
||||
*/
|
||||
virtual entity_id_t GetTurretParent() = 0;
|
||||
virtual entity_id_t GetTurretParent() const = 0;
|
||||
|
||||
/**
|
||||
* Has to be called to update the simulation position of the turret
|
||||
@ -83,7 +83,7 @@ public:
|
||||
/**
|
||||
* Returns true if the entity currently exists at a defined position in the world.
|
||||
*/
|
||||
virtual bool IsInWorld() = 0;
|
||||
virtual bool IsInWorld() const = 0;
|
||||
|
||||
/**
|
||||
* Causes IsInWorld to return false. (Use MoveTo() or JumpTo() to move back into the world.)
|
||||
@ -113,7 +113,7 @@ public:
|
||||
/**
|
||||
* Returns the current vertical offset above the terrain/water surface.
|
||||
*/
|
||||
virtual entity_pos_t GetHeightOffset() = 0;
|
||||
virtual entity_pos_t GetHeightOffset() const = 0;
|
||||
|
||||
/**
|
||||
* Set the vertical position above the map zero point
|
||||
@ -123,12 +123,12 @@ public:
|
||||
/**
|
||||
* Returns the vertical offset above the map zero point
|
||||
*/
|
||||
virtual entity_pos_t GetHeightFixed() = 0;
|
||||
virtual entity_pos_t GetHeightFixed() const = 0;
|
||||
|
||||
/**
|
||||
* Returns true iff the entity will follow the terrain height (possibly with an offset)
|
||||
*/
|
||||
virtual bool IsHeightRelative() = 0;
|
||||
virtual bool IsHeightRelative() const = 0;
|
||||
|
||||
/**
|
||||
* When set to true, the entity will follow the terrain height (possibly with an offset)
|
||||
@ -139,7 +139,7 @@ public:
|
||||
/**
|
||||
* Returns whether the entity floats on water.
|
||||
*/
|
||||
virtual bool IsFloating() = 0;
|
||||
virtual bool IsFloating() const = 0;
|
||||
|
||||
/**
|
||||
* Set the entity to float on water
|
||||
@ -163,26 +163,26 @@ public:
|
||||
* Depends on the current terrain heightmap.
|
||||
* Must not be called unless IsInWorld is true.
|
||||
*/
|
||||
virtual CFixedVector3D GetPosition() = 0;
|
||||
virtual CFixedVector3D GetPosition() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the current x,z position (no interpolation).
|
||||
* Must not be called unless IsInWorld is true.
|
||||
*/
|
||||
virtual CFixedVector2D GetPosition2D() = 0;
|
||||
virtual CFixedVector2D GetPosition2D() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the previous turn's x,y,z position (no interpolation).
|
||||
* Depends on the current terrain heightmap.
|
||||
* Must not be called unless IsInWorld is true.
|
||||
*/
|
||||
virtual CFixedVector3D GetPreviousPosition() = 0;
|
||||
virtual CFixedVector3D GetPreviousPosition() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the previous turn's x,z position (no interpolation).
|
||||
* Must not be called unless IsInWorld is true.
|
||||
*/
|
||||
virtual CFixedVector2D GetPreviousPosition2D() = 0;
|
||||
virtual CFixedVector2D GetPreviousPosition2D() const = 0;
|
||||
|
||||
/**
|
||||
* Rotate smoothly to the given angle around the upwards axis.
|
||||
@ -212,25 +212,25 @@ public:
|
||||
* Returns the current rotation (relative to the upwards axis), as Euler
|
||||
* angles with X=pitch, Y=yaw, Z=roll. (TODO: is that the right way round?)
|
||||
*/
|
||||
virtual CFixedVector3D GetRotation() = 0;
|
||||
virtual CFixedVector3D GetRotation() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the distance that the unit will be interpolated over,
|
||||
* i.e. the distance travelled since the start of the turn.
|
||||
*/
|
||||
virtual fixed GetDistanceTravelled() = 0;
|
||||
virtual fixed GetDistanceTravelled() const = 0;
|
||||
|
||||
/**
|
||||
* Get the current interpolated 2D position and orientation, for rendering.
|
||||
* Must not be called unless IsInWorld is true.
|
||||
*/
|
||||
virtual void GetInterpolatedPosition2D(float frameOffset, float& x, float& z, float& rotY) = 0;
|
||||
virtual void GetInterpolatedPosition2D(float frameOffset, float& x, float& z, float& rotY) const = 0;
|
||||
|
||||
/**
|
||||
* Get the current interpolated transform matrix, for rendering.
|
||||
* Must not be called unless IsInWorld is true.
|
||||
*/
|
||||
virtual CMatrix3D GetInterpolatedTransform(float frameOffset) = 0;
|
||||
virtual CMatrix3D GetInterpolatedTransform(float frameOffset) const = 0;
|
||||
|
||||
DECLARE_INTERFACE_TYPE(Position)
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -28,5 +28,5 @@ DEFINE_INTERFACE_METHOD_1("SetPosition", void, ICmpRallyPointRenderer, SetPositi
|
||||
DEFINE_INTERFACE_METHOD_2("UpdatePosition", void, ICmpRallyPointRenderer, UpdatePosition, u32, CFixedVector2D)
|
||||
DEFINE_INTERFACE_METHOD_1("AddPosition", void, ICmpRallyPointRenderer, AddPosition_wrapper, CFixedVector2D)
|
||||
DEFINE_INTERFACE_METHOD_0("Reset", void, ICmpRallyPointRenderer, Reset)
|
||||
DEFINE_INTERFACE_METHOD_0("IsSet", bool, ICmpRallyPointRenderer, IsSet)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("IsSet", bool, ICmpRallyPointRenderer, IsSet)
|
||||
END_INTERFACE_WRAPPER(RallyPointRenderer)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -48,7 +48,7 @@ public:
|
||||
virtual void Reset() = 0;
|
||||
|
||||
/// Returns true if at least one display rally point is set
|
||||
virtual bool IsSet() = 0;
|
||||
virtual bool IsSet() const = 0;
|
||||
|
||||
DECLARE_INTERFACE_TYPE(RallyPointRenderer)
|
||||
};
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "simulation2/system/InterfaceScripted.h"
|
||||
|
||||
std::string ICmpRangeManager::GetLosVisibility_wrapper(entity_id_t ent, int player)
|
||||
std::string ICmpRangeManager::GetLosVisibility_wrapper(entity_id_t ent, int player) const
|
||||
{
|
||||
ELosVisibility visibility = GetLosVisibility(ent, player);
|
||||
switch (visibility)
|
||||
@ -41,24 +41,24 @@ DEFINE_INTERFACE_METHOD_7("CreateActiveParabolicQuery", ICmpRangeManager::tag_t,
|
||||
DEFINE_INTERFACE_METHOD_1("DestroyActiveQuery", void, ICmpRangeManager, DestroyActiveQuery, ICmpRangeManager::tag_t)
|
||||
DEFINE_INTERFACE_METHOD_1("EnableActiveQuery", void, ICmpRangeManager, EnableActiveQuery, ICmpRangeManager::tag_t)
|
||||
DEFINE_INTERFACE_METHOD_1("DisableActiveQuery", void, ICmpRangeManager, DisableActiveQuery, ICmpRangeManager::tag_t)
|
||||
DEFINE_INTERFACE_METHOD_1("IsActiveQueryEnabled", bool, ICmpRangeManager, IsActiveQueryEnabled, ICmpRangeManager::tag_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_1("IsActiveQueryEnabled", bool, ICmpRangeManager, IsActiveQueryEnabled, ICmpRangeManager::tag_t)
|
||||
DEFINE_INTERFACE_METHOD_1("ResetActiveQuery", std::vector<entity_id_t>, ICmpRangeManager, ResetActiveQuery, ICmpRangeManager::tag_t)
|
||||
DEFINE_INTERFACE_METHOD_3("SetEntityFlag", void, ICmpRangeManager, SetEntityFlag, entity_id_t, std::string, bool)
|
||||
DEFINE_INTERFACE_METHOD_1("GetEntityFlagMask", u8, ICmpRangeManager, GetEntityFlagMask, std::string)
|
||||
DEFINE_INTERFACE_METHOD_1("GetEntitiesByPlayer", std::vector<entity_id_t>, ICmpRangeManager, GetEntitiesByPlayer, player_id_t)
|
||||
DEFINE_INTERFACE_METHOD_0("GetNonGaiaEntities", std::vector<entity_id_t>, ICmpRangeManager, GetNonGaiaEntities)
|
||||
DEFINE_INTERFACE_METHOD_CONST_1("GetEntityFlagMask", u8, ICmpRangeManager, GetEntityFlagMask, std::string)
|
||||
DEFINE_INTERFACE_METHOD_CONST_1("GetEntitiesByPlayer", std::vector<entity_id_t>, ICmpRangeManager, GetEntitiesByPlayer, player_id_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetNonGaiaEntities", std::vector<entity_id_t>, ICmpRangeManager, GetNonGaiaEntities)
|
||||
DEFINE_INTERFACE_METHOD_1("SetDebugOverlay", void, ICmpRangeManager, SetDebugOverlay, bool)
|
||||
DEFINE_INTERFACE_METHOD_1("ExploreAllTiles", void, ICmpRangeManager, ExploreAllTiles, player_id_t)
|
||||
DEFINE_INTERFACE_METHOD_0("ExploreTerritories", void, ICmpRangeManager, ExploreTerritories)
|
||||
DEFINE_INTERFACE_METHOD_2("SetLosRevealAll", void, ICmpRangeManager, SetLosRevealAll, player_id_t, bool)
|
||||
DEFINE_INTERFACE_METHOD_1("GetLosRevealAll", bool, ICmpRangeManager, GetLosRevealAll, player_id_t)
|
||||
DEFINE_INTERFACE_METHOD_5("GetElevationAdaptedRange", entity_pos_t, ICmpRangeManager, GetElevationAdaptedRange, CFixedVector3D, CFixedVector3D, entity_pos_t, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_1("GetLosRevealAll", bool, ICmpRangeManager, GetLosRevealAll, player_id_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_5("GetElevationAdaptedRange", entity_pos_t, ICmpRangeManager, GetElevationAdaptedRange, CFixedVector3D, CFixedVector3D, entity_pos_t, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_2("ActivateScriptedVisibility", void, ICmpRangeManager, ActivateScriptedVisibility, entity_id_t, bool)
|
||||
DEFINE_INTERFACE_METHOD_2("GetLosVisibility", std::string, ICmpRangeManager, GetLosVisibility_wrapper, entity_id_t, player_id_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_2("GetLosVisibility", std::string, ICmpRangeManager, GetLosVisibility_wrapper, entity_id_t, player_id_t)
|
||||
DEFINE_INTERFACE_METHOD_1("RequestVisibilityUpdate", void, ICmpRangeManager, RequestVisibilityUpdate, entity_id_t)
|
||||
DEFINE_INTERFACE_METHOD_1("SetLosCircular", void, ICmpRangeManager, SetLosCircular, bool)
|
||||
DEFINE_INTERFACE_METHOD_0("GetLosCircular", bool, ICmpRangeManager, GetLosCircular)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetLosCircular", bool, ICmpRangeManager, GetLosCircular)
|
||||
DEFINE_INTERFACE_METHOD_2("SetSharedLos", void, ICmpRangeManager, SetSharedLos, player_id_t, std::vector<player_id_t>)
|
||||
DEFINE_INTERFACE_METHOD_1("GetPercentMapExplored", u8, ICmpRangeManager, GetPercentMapExplored, player_id_t)
|
||||
DEFINE_INTERFACE_METHOD_1("GetUnionPercentMapExplored", u8, ICmpRangeManager, GetUnionPercentMapExplored, std::vector<player_id_t>)
|
||||
DEFINE_INTERFACE_METHOD_CONST_1("GetPercentMapExplored", u8, ICmpRangeManager, GetPercentMapExplored, player_id_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_1("GetUnionPercentMapExplored", u8, ICmpRangeManager, GetUnionPercentMapExplored, std::vector<player_id_t>)
|
||||
END_INTERFACE_WRAPPER(RangeManager)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -149,7 +149,7 @@ public:
|
||||
* @param range the distance to compare terrain height with
|
||||
* @return a fixed number representing the average difference. It's positive when the entity is on average higher than the terrain surrounding it.
|
||||
*/
|
||||
virtual entity_pos_t GetElevationAdaptedRange(const CFixedVector3D& pos, const CFixedVector3D& rot, entity_pos_t range, entity_pos_t elevationBonus, entity_pos_t angle) = 0;
|
||||
virtual entity_pos_t GetElevationAdaptedRange(const CFixedVector3D& pos, const CFixedVector3D& rot, entity_pos_t range, entity_pos_t elevationBonus, entity_pos_t angle) const = 0;
|
||||
|
||||
/**
|
||||
* Destroy a query and clean up resources. This must be called when an entity no longer needs its
|
||||
@ -174,7 +174,7 @@ public:
|
||||
* Check if the processing of a query is enabled.
|
||||
* @param tag identifier of a query.
|
||||
*/
|
||||
virtual bool IsActiveQueryEnabled(tag_t tag) = 0;
|
||||
virtual bool IsActiveQueryEnabled(tag_t tag) const = 0;
|
||||
|
||||
/**
|
||||
* Immediately execute a query, and re-enable it if disabled.
|
||||
@ -191,12 +191,12 @@ public:
|
||||
* Maybe it should be extended to be more like ExecuteQuery without
|
||||
* the range parameter.)
|
||||
*/
|
||||
virtual std::vector<entity_id_t> GetEntitiesByPlayer(player_id_t player) = 0;
|
||||
virtual std::vector<entity_id_t> GetEntitiesByPlayer(player_id_t player) const = 0;
|
||||
|
||||
/**
|
||||
* Returns a list of all entities of all players except gaia.
|
||||
*/
|
||||
virtual std::vector<entity_id_t> GetNonGaiaEntities() = 0;
|
||||
virtual std::vector<entity_id_t> GetNonGaiaEntities() const = 0;
|
||||
|
||||
/**
|
||||
* Toggle the rendering of debug info.
|
||||
@ -206,7 +206,7 @@ public:
|
||||
/**
|
||||
* Returns the mask for the specified identifier.
|
||||
*/
|
||||
virtual u8 GetEntityFlagMask(const std::string& identifier) = 0;
|
||||
virtual u8 GetEntityFlagMask(const std::string& identifier) const = 0;
|
||||
|
||||
/**
|
||||
* Set the flag specified by the identifier to the supplied value for the entity
|
||||
@ -256,7 +256,7 @@ public:
|
||||
/**
|
||||
* Returns whether the given vertex is visible (i.e. is within a unit's LOS).
|
||||
*/
|
||||
inline bool IsVisible(ssize_t i, ssize_t j)
|
||||
inline bool IsVisible(ssize_t i, ssize_t j) const
|
||||
{
|
||||
if (!(i >= 0 && j >= 0 && i < m_VerticesPerSide && j < m_VerticesPerSide))
|
||||
return false;
|
||||
@ -271,7 +271,7 @@ public:
|
||||
/**
|
||||
* Returns whether the given vertex is explored (i.e. was (or still is) within a unit's LOS).
|
||||
*/
|
||||
inline bool IsExplored(ssize_t i, ssize_t j)
|
||||
inline bool IsExplored(ssize_t i, ssize_t j) const
|
||||
{
|
||||
if (!(i >= 0 && j >= 0 && i < m_VerticesPerSide && j < m_VerticesPerSide))
|
||||
return false;
|
||||
@ -287,7 +287,7 @@ public:
|
||||
* Returns whether the given vertex is visible (i.e. is within a unit's LOS).
|
||||
* i and j must be in the range [0, verticesPerSide), else behaviour is undefined.
|
||||
*/
|
||||
inline bool IsVisible_UncheckedRange(ssize_t i, ssize_t j)
|
||||
inline bool IsVisible_UncheckedRange(ssize_t i, ssize_t j) const
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
ENSURE(i >= 0 && j >= 0 && i < m_VerticesPerSide && j < m_VerticesPerSide);
|
||||
@ -303,7 +303,7 @@ public:
|
||||
* Returns whether the given vertex is explored (i.e. was (or still is) within a unit's LOS).
|
||||
* i and j must be in the range [0, verticesPerSide), else behaviour is undefined.
|
||||
*/
|
||||
inline bool IsExplored_UncheckedRange(ssize_t i, ssize_t j)
|
||||
inline bool IsExplored_UncheckedRange(ssize_t i, ssize_t j) const
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
ENSURE(i >= 0 && j >= 0 && i < m_VerticesPerSide && j < m_VerticesPerSide);
|
||||
@ -325,7 +325,7 @@ public:
|
||||
* Returns a CLosQuerier for checking whether vertex positions are visible to the given player
|
||||
* (or other players it shares LOS with).
|
||||
*/
|
||||
virtual CLosQuerier GetLosQuerier(player_id_t player) = 0;
|
||||
virtual CLosQuerier GetLosQuerier(player_id_t player) const = 0;
|
||||
|
||||
/**
|
||||
* Toggle the scripted Visibility component activation for entity ent.
|
||||
@ -337,8 +337,8 @@ public:
|
||||
* Returns VIS_HIDDEN if the entity doesn't exist or is not in the world.
|
||||
* This respects the GetLosRevealAll flag.
|
||||
*/
|
||||
virtual ELosVisibility GetLosVisibility(CEntityHandle ent, player_id_t player) = 0;
|
||||
virtual ELosVisibility GetLosVisibility(entity_id_t ent, player_id_t player) = 0;
|
||||
virtual ELosVisibility GetLosVisibility(CEntityHandle ent, player_id_t player) const = 0;
|
||||
virtual ELosVisibility GetLosVisibility(entity_id_t ent, player_id_t player) const = 0;
|
||||
|
||||
/**
|
||||
* Request the update of the visibility cache of ent at next turn.
|
||||
@ -351,7 +351,7 @@ public:
|
||||
* GetLosVisibility wrapped for script calls.
|
||||
* Returns "hidden", "fogged" or "visible".
|
||||
*/
|
||||
std::string GetLosVisibility_wrapper(entity_id_t ent, player_id_t player);
|
||||
std::string GetLosVisibility_wrapper(entity_id_t ent, player_id_t player) const;
|
||||
|
||||
/**
|
||||
* Explore all tiles (but leave them in the FoW) for player p
|
||||
@ -381,7 +381,7 @@ public:
|
||||
/**
|
||||
* Returns whether the whole map has been made visible to the given player.
|
||||
*/
|
||||
virtual bool GetLosRevealAll(player_id_t player) = 0;
|
||||
virtual bool GetLosRevealAll(player_id_t player) const = 0;
|
||||
|
||||
/**
|
||||
* Set the LOS to be restricted to a circular map.
|
||||
@ -391,7 +391,7 @@ public:
|
||||
/**
|
||||
* Returns whether the LOS is restricted to a circular map.
|
||||
*/
|
||||
virtual bool GetLosCircular() = 0;
|
||||
virtual bool GetLosCircular() const = 0;
|
||||
|
||||
/**
|
||||
* Sets shared LOS data for player to the given list of players.
|
||||
@ -401,18 +401,18 @@ public:
|
||||
/**
|
||||
* Returns shared LOS mask for player.
|
||||
*/
|
||||
virtual u32 GetSharedLosMask(player_id_t player) = 0;
|
||||
virtual u32 GetSharedLosMask(player_id_t player) const = 0;
|
||||
|
||||
/**
|
||||
* Get percent map explored statistics for specified player.
|
||||
*/
|
||||
virtual u8 GetPercentMapExplored(player_id_t player) = 0;
|
||||
virtual u8 GetPercentMapExplored(player_id_t player) const = 0;
|
||||
|
||||
/**
|
||||
* Get percent map explored statistics for specified set of players.
|
||||
* Note: this function computes statistics from scratch and should not be called too often.
|
||||
*/
|
||||
virtual u8 GetUnionPercentMapExplored(const std::vector<player_id_t>& players) = 0;
|
||||
virtual u8 GetUnionPercentMapExplored(const std::vector<player_id_t>& players) const = 0;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2012 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -50,7 +50,7 @@ public:
|
||||
/**
|
||||
* Returns true if the entity is only selectable in Atlas editor, e.g. a decorative visual actor.
|
||||
*/
|
||||
virtual bool IsEditorOnly() = 0;
|
||||
virtual bool IsEditorOnly() const = 0;
|
||||
|
||||
/**
|
||||
* Set the selection highlight state.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -24,8 +24,8 @@
|
||||
BEGIN_INTERFACE_WRAPPER(TemplateManager)
|
||||
DEFINE_INTERFACE_METHOD_1("GetTemplate", const CParamNode*, ICmpTemplateManager, GetTemplate, std::string)
|
||||
DEFINE_INTERFACE_METHOD_1("GetTemplateWithoutValidation", const CParamNode*, ICmpTemplateManager, GetTemplateWithoutValidation, std::string)
|
||||
DEFINE_INTERFACE_METHOD_1("TemplateExists", bool, ICmpTemplateManager, TemplateExists, std::string)
|
||||
DEFINE_INTERFACE_METHOD_1("GetCurrentTemplateName", std::string, ICmpTemplateManager, GetCurrentTemplateName, entity_id_t)
|
||||
DEFINE_INTERFACE_METHOD_1("FindAllTemplates", std::vector<std::string>, ICmpTemplateManager, FindAllTemplates, bool)
|
||||
DEFINE_INTERFACE_METHOD_1("GetEntitiesUsingTemplate", std::vector<entity_id_t>, ICmpTemplateManager, GetEntitiesUsingTemplate, std::string)
|
||||
DEFINE_INTERFACE_METHOD_CONST_1("TemplateExists", bool, ICmpTemplateManager, TemplateExists, std::string)
|
||||
DEFINE_INTERFACE_METHOD_CONST_1("GetCurrentTemplateName", std::string, ICmpTemplateManager, GetCurrentTemplateName, entity_id_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_1("FindAllTemplates", std::vector<std::string>, ICmpTemplateManager, FindAllTemplates, bool)
|
||||
DEFINE_INTERFACE_METHOD_CONST_1("GetEntitiesUsingTemplate", std::vector<entity_id_t>, ICmpTemplateManager, GetEntitiesUsingTemplate, std::string)
|
||||
END_INTERFACE_WRAPPER(TemplateManager)
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
/**
|
||||
* Check if the template XML file exists, without trying to load it.
|
||||
*/
|
||||
virtual bool TemplateExists(const std::string& templateName) = 0;
|
||||
virtual bool TemplateExists(const std::string& templateName) const = 0;
|
||||
|
||||
/**
|
||||
* Returns the template most recently specified for the entity 'ent'.
|
||||
@ -89,21 +89,21 @@ public:
|
||||
/**
|
||||
* Returns the name of the template most recently specified for the entity 'ent'.
|
||||
*/
|
||||
virtual std::string GetCurrentTemplateName(entity_id_t ent) = 0;
|
||||
virtual std::string GetCurrentTemplateName(entity_id_t ent) const = 0;
|
||||
|
||||
/**
|
||||
* Returns the list of entities having the specified template.
|
||||
*/
|
||||
virtual std::vector<entity_id_t> GetEntitiesUsingTemplate(const std::string& templateName) = 0;
|
||||
virtual std::vector<entity_id_t> GetEntitiesUsingTemplate(const std::string& templateName) const = 0;
|
||||
|
||||
/**
|
||||
* Returns a list of strings that could be validly passed as @c templateName to LoadTemplate.
|
||||
* (This includes "actor|foo" etc names).
|
||||
* Intended for use by the map editor. This is likely to be quite slow.
|
||||
*/
|
||||
virtual std::vector<std::string> FindAllTemplates(bool includeActors) = 0;
|
||||
virtual std::vector<std::string> FindAllTemplates(bool includeActors) const = 0;
|
||||
|
||||
virtual std::vector<std::string> FindAllPlaceableTemplates(bool includeActors) = 0;
|
||||
virtual std::vector<std::string> FindAllPlaceableTemplates(bool includeActors) const = 0;
|
||||
|
||||
/**
|
||||
* Permanently disable XML validation (intended solely for test cases).
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -22,7 +22,7 @@
|
||||
#include "simulation2/system/InterfaceScripted.h"
|
||||
|
||||
BEGIN_INTERFACE_WRAPPER(Terrain)
|
||||
DEFINE_INTERFACE_METHOD_2("GetGroundLevel", entity_pos_t, ICmpTerrain, GetGroundLevel, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_2("CalcNormal", CFixedVector3D, ICmpTerrain, CalcNormal, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_0("GetTilesPerSide", u16, ICmpTerrain, GetTilesPerSide)
|
||||
DEFINE_INTERFACE_METHOD_CONST_2("GetGroundLevel", entity_pos_t, ICmpTerrain, GetGroundLevel, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_2("CalcNormal", CFixedVector3D, ICmpTerrain, CalcNormal, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetTilesPerSide", u16, ICmpTerrain, GetTilesPerSide)
|
||||
END_INTERFACE_WRAPPER(Terrain)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -30,27 +30,27 @@ class CVector3D;
|
||||
class ICmpTerrain : public IComponent
|
||||
{
|
||||
public:
|
||||
virtual bool IsLoaded() = 0;
|
||||
virtual bool IsLoaded() const = 0;
|
||||
|
||||
virtual CFixedVector3D CalcNormal(entity_pos_t x, entity_pos_t z) = 0;
|
||||
virtual CFixedVector3D CalcNormal(entity_pos_t x, entity_pos_t z) const = 0;
|
||||
|
||||
virtual CVector3D CalcExactNormal(float x, float z) = 0;
|
||||
virtual CVector3D CalcExactNormal(float x, float z) const = 0;
|
||||
|
||||
virtual entity_pos_t GetGroundLevel(entity_pos_t x, entity_pos_t z) = 0;
|
||||
virtual entity_pos_t GetGroundLevel(entity_pos_t x, entity_pos_t z) const = 0;
|
||||
|
||||
virtual float GetExactGroundLevel(float x, float z) = 0;
|
||||
virtual float GetExactGroundLevel(float x, float z) const = 0;
|
||||
|
||||
/**
|
||||
* Returns number of tiles per side on the terrain.
|
||||
* Return value is always non-zero.
|
||||
*/
|
||||
virtual u16 GetTilesPerSide() = 0;
|
||||
virtual u16 GetTilesPerSide() const = 0;
|
||||
|
||||
/**
|
||||
* Returns number of vertices per side on the terrain.
|
||||
* Return value is always non-zero.
|
||||
*/
|
||||
virtual u16 GetVerticesPerSide() = 0;
|
||||
virtual u16 GetVerticesPerSide() const = 0;
|
||||
|
||||
virtual CTerrain* GetCTerrain() = 0;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -23,11 +23,11 @@
|
||||
class ICmpTerritoryInfluence : public IComponent
|
||||
{
|
||||
public:
|
||||
virtual bool IsRoot() = 0;
|
||||
virtual bool IsRoot() const = 0;
|
||||
|
||||
virtual u16 GetWeight() = 0;
|
||||
virtual u16 GetWeight() const = 0;
|
||||
|
||||
virtual u32 GetRadius() = 0;
|
||||
virtual u32 GetRadius() const = 0;
|
||||
|
||||
DECLARE_INTERFACE_TYPE(TerritoryInfluence)
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -27,7 +27,7 @@
|
||||
class ICmpTerritoryManager : public IComponent
|
||||
{
|
||||
public:
|
||||
virtual bool NeedUpdate(size_t* dirtyID) = 0;
|
||||
virtual bool NeedUpdate(size_t* dirtyID) const = 0;
|
||||
|
||||
/**
|
||||
* Number of pathfinder navcells per territory tile.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -24,19 +24,19 @@
|
||||
|
||||
BEGIN_INTERFACE_WRAPPER(UnitMotion)
|
||||
DEFINE_INTERFACE_METHOD_4("MoveToPointRange", bool, ICmpUnitMotion, MoveToPointRange, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_4("IsInPointRange", bool, ICmpUnitMotion, IsInPointRange, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_3("IsInTargetRange", bool, ICmpUnitMotion, IsInTargetRange, entity_id_t, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_4("IsInPointRange", bool, ICmpUnitMotion, IsInPointRange, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_3("IsInTargetRange", bool, ICmpUnitMotion, IsInTargetRange, entity_id_t, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_3("MoveToTargetRange", bool, ICmpUnitMotion, MoveToTargetRange, entity_id_t, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_3("MoveToFormationOffset", void, ICmpUnitMotion, MoveToFormationOffset, entity_id_t, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_2("FaceTowardsPoint", void, ICmpUnitMotion, FaceTowardsPoint, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_0("StopMoving", void, ICmpUnitMotion, StopMoving)
|
||||
DEFINE_INTERFACE_METHOD_0("GetCurrentSpeed", fixed, ICmpUnitMotion, GetCurrentSpeed)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetCurrentSpeed", fixed, ICmpUnitMotion, GetCurrentSpeed)
|
||||
DEFINE_INTERFACE_METHOD_1("SetSpeed", void, ICmpUnitMotion, SetSpeed, fixed)
|
||||
DEFINE_INTERFACE_METHOD_0("IsMoving", bool, ICmpUnitMotion, IsMoving)
|
||||
DEFINE_INTERFACE_METHOD_0("GetWalkSpeed", fixed, ICmpUnitMotion, GetWalkSpeed)
|
||||
DEFINE_INTERFACE_METHOD_0("GetRunSpeed", fixed, ICmpUnitMotion, GetRunSpeed)
|
||||
DEFINE_INTERFACE_METHOD_0("GetPassabilityClassName", std::string, ICmpUnitMotion, GetPassabilityClassName)
|
||||
DEFINE_INTERFACE_METHOD_0("GetUnitClearance", entity_pos_t, ICmpUnitMotion, GetUnitClearance)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("IsMoving", bool, ICmpUnitMotion, IsMoving)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetWalkSpeed", fixed, ICmpUnitMotion, GetWalkSpeed)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetRunSpeed", fixed, ICmpUnitMotion, GetRunSpeed)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetPassabilityClassName", std::string, ICmpUnitMotion, GetPassabilityClassName)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetUnitClearance", entity_pos_t, ICmpUnitMotion, GetUnitClearance)
|
||||
DEFINE_INTERFACE_METHOD_1("SetFacePointAfterMove", void, ICmpUnitMotion, SetFacePointAfterMove, bool)
|
||||
DEFINE_INTERFACE_METHOD_1("SetDebugOverlay", void, ICmpUnitMotion, SetDebugOverlay, bool)
|
||||
END_INTERFACE_WRAPPER(UnitMotion)
|
||||
@ -51,12 +51,12 @@ public:
|
||||
return m_Script.Call<bool>("MoveToPointRange", x, z, minRange, maxRange);
|
||||
}
|
||||
|
||||
virtual bool IsInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange)
|
||||
virtual bool IsInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange) const
|
||||
{
|
||||
return m_Script.Call<bool>("IsInPointRange", x, z, minRange, maxRange);
|
||||
}
|
||||
|
||||
virtual bool IsInTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange)
|
||||
virtual bool IsInTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) const
|
||||
{
|
||||
return m_Script.Call<bool>("IsInTargetRange", target, minRange, maxRange);
|
||||
}
|
||||
@ -81,7 +81,7 @@ public:
|
||||
m_Script.CallVoid("StopMoving");
|
||||
}
|
||||
|
||||
virtual fixed GetCurrentSpeed()
|
||||
virtual fixed GetCurrentSpeed() const
|
||||
{
|
||||
return m_Script.Call<fixed>("GetCurrentSpeed");
|
||||
}
|
||||
@ -91,17 +91,17 @@ public:
|
||||
m_Script.CallVoid("SetSpeed", speed);
|
||||
}
|
||||
|
||||
virtual bool IsMoving()
|
||||
virtual bool IsMoving() const
|
||||
{
|
||||
return m_Script.Call<bool>("IsMoving");
|
||||
}
|
||||
|
||||
virtual fixed GetWalkSpeed()
|
||||
virtual fixed GetWalkSpeed() const
|
||||
{
|
||||
return m_Script.Call<fixed>("GetWalkSpeed");
|
||||
}
|
||||
|
||||
virtual fixed GetRunSpeed()
|
||||
virtual fixed GetRunSpeed() const
|
||||
{
|
||||
return m_Script.Call<fixed>("GetRunSpeed");
|
||||
}
|
||||
@ -111,17 +111,17 @@ public:
|
||||
m_Script.CallVoid("SetFacePointAfterMove", facePointAfterMove);
|
||||
}
|
||||
|
||||
virtual pass_class_t GetPassabilityClass()
|
||||
virtual pass_class_t GetPassabilityClass() const
|
||||
{
|
||||
return m_Script.Call<pass_class_t>("GetPassabilityClass");
|
||||
}
|
||||
|
||||
virtual std::string GetPassabilityClassName()
|
||||
virtual std::string GetPassabilityClassName() const
|
||||
{
|
||||
return m_Script.Call<std::string>("GetPassabilityClassName");
|
||||
}
|
||||
|
||||
virtual entity_pos_t GetUnitClearance()
|
||||
virtual entity_pos_t GetUnitClearance() const
|
||||
{
|
||||
return m_Script.Call<entity_pos_t>("GetUnitClearance");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -50,13 +50,13 @@ public:
|
||||
* Determine wether the givven point is within the given range, using the same measurement
|
||||
* as MoveToPointRange.
|
||||
*/
|
||||
virtual bool IsInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange) = 0;
|
||||
virtual bool IsInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange) const = 0;
|
||||
|
||||
/**
|
||||
* Determine whether the target is within the given range, using the same measurement
|
||||
* as MoveToTargetRange.
|
||||
*/
|
||||
virtual bool IsInTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) = 0;
|
||||
virtual bool IsInTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) const = 0;
|
||||
|
||||
/**
|
||||
* Attempt to walk into range of a given target entity, or as close as possible.
|
||||
@ -89,7 +89,7 @@ public:
|
||||
/**
|
||||
* Get the current movement speed.
|
||||
*/
|
||||
virtual fixed GetCurrentSpeed() = 0;
|
||||
virtual fixed GetCurrentSpeed() const = 0;
|
||||
|
||||
/**
|
||||
* Set the current movement speed.
|
||||
@ -99,17 +99,17 @@ public:
|
||||
/**
|
||||
* Get whether the unit is moving.
|
||||
*/
|
||||
virtual bool IsMoving() = 0;
|
||||
virtual bool IsMoving() const = 0;
|
||||
|
||||
/**
|
||||
* Get the default speed that this unit will have when walking, in metres per second.
|
||||
*/
|
||||
virtual fixed GetWalkSpeed() = 0;
|
||||
virtual fixed GetWalkSpeed() const = 0;
|
||||
|
||||
/**
|
||||
* Get the default speed that this unit will have when running, in metres per second.
|
||||
*/
|
||||
virtual fixed GetRunSpeed() = 0;
|
||||
virtual fixed GetRunSpeed() const = 0;
|
||||
|
||||
/**
|
||||
* Set whether the unit will turn to face the target point after finishing moving.
|
||||
@ -119,17 +119,17 @@ public:
|
||||
/**
|
||||
* Get the unit's passability class.
|
||||
*/
|
||||
virtual pass_class_t GetPassabilityClass() = 0;
|
||||
virtual pass_class_t GetPassabilityClass() const = 0;
|
||||
|
||||
/**
|
||||
* Get the passability class name (as defined in pathfinder.xml)
|
||||
*/
|
||||
virtual std::string GetPassabilityClassName() = 0;
|
||||
virtual std::string GetPassabilityClassName() const = 0;
|
||||
|
||||
/**
|
||||
* Get the unit clearance (used by the Obstruction component)
|
||||
*/
|
||||
virtual entity_pos_t GetUnitClearance() = 0;
|
||||
virtual entity_pos_t GetUnitClearance() const = 0;
|
||||
|
||||
/**
|
||||
* Toggle the rendering of debug info.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -35,7 +35,7 @@ public:
|
||||
{
|
||||
tag_t() : n(0) {}
|
||||
explicit tag_t(u32 n) : n(n) {}
|
||||
bool valid() { return n != 0; }
|
||||
bool valid() const { return n != 0; }
|
||||
|
||||
u32 n;
|
||||
};
|
||||
@ -65,12 +65,12 @@ public:
|
||||
*/
|
||||
virtual void PickAllEntitiesAtPoint(std::vector<std::pair<CEntityHandle, CVector3D> >& outEntities,
|
||||
const CVector3D& origin, const CVector3D& dir,
|
||||
bool allowEditorSelectables) = 0;
|
||||
bool allowEditorSelectables) const = 0;
|
||||
|
||||
/**
|
||||
* Returns the frame offset from the last Interpolate message.
|
||||
*/
|
||||
virtual float GetFrameOffset() = 0;
|
||||
virtual float GetFrameOffset() const = 0;
|
||||
|
||||
/**
|
||||
* Toggle the rendering of debug info.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -22,5 +22,5 @@
|
||||
#include "simulation2/system/InterfaceScripted.h"
|
||||
|
||||
BEGIN_INTERFACE_WRAPPER(Vision)
|
||||
DEFINE_INTERFACE_METHOD_0("GetRange", entity_pos_t, ICmpVision, GetRange)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetRange", entity_pos_t, ICmpVision, GetRange)
|
||||
END_INTERFACE_WRAPPER(Vision)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -28,8 +28,8 @@
|
||||
class ICmpVision : public IComponent
|
||||
{
|
||||
public:
|
||||
virtual entity_pos_t GetRange() = 0;
|
||||
virtual bool GetRevealShore() = 0;
|
||||
virtual entity_pos_t GetRange() const = 0;
|
||||
virtual bool GetRevealShore() const = 0;
|
||||
|
||||
DECLARE_INTERFACE_TYPE(Vision)
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -31,7 +31,7 @@ DEFINE_INTERFACE_METHOD_1("SetAnimationSyncRepeat", void, ICmpVisual, SetAnimati
|
||||
DEFINE_INTERFACE_METHOD_1("SetAnimationSyncOffset", void, ICmpVisual, SetAnimationSyncOffset, fixed)
|
||||
DEFINE_INTERFACE_METHOD_4("SetShadingColor", void, ICmpVisual, SetShadingColor, fixed, fixed, fixed, fixed)
|
||||
DEFINE_INTERFACE_METHOD_2("SetVariable", void, ICmpVisual, SetVariable, std::string, float)
|
||||
DEFINE_INTERFACE_METHOD_0("GetActorSeed", u32, ICmpVisual, GetActorSeed)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("GetActorSeed", u32, ICmpVisual, GetActorSeed)
|
||||
DEFINE_INTERFACE_METHOD_1("SetActorSeed", void, ICmpVisual, SetActorSeed, u32)
|
||||
DEFINE_INTERFACE_METHOD_0("HasConstructionPreview", bool, ICmpVisual, HasConstructionPreview)
|
||||
DEFINE_INTERFACE_METHOD_CONST_0("HasConstructionPreview", bool, ICmpVisual, HasConstructionPreview)
|
||||
END_INTERFACE_WRAPPER(Visual)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -38,39 +38,39 @@ public:
|
||||
* Get the world-space bounding box of the object's visual representation.
|
||||
* (Not safe for use in simulation code.)
|
||||
*/
|
||||
virtual CBoundingBoxAligned GetBounds() = 0;
|
||||
virtual CBoundingBoxAligned GetBounds() const = 0;
|
||||
|
||||
/**
|
||||
* Get the oriented world-space bounding box of the object's visual representation, clipped at the Y=0 plane in object space
|
||||
* to prevent it from extending into the terrain. The primary difference with GetBounds is that this bounding box is not aligned
|
||||
* to the world axes, but arbitrarily rotated according to the model transform.
|
||||
*/
|
||||
virtual CBoundingBoxOriented GetSelectionBox() = 0;
|
||||
virtual CBoundingBoxOriented GetSelectionBox() const = 0;
|
||||
|
||||
/**
|
||||
* Get the world-space position of the base point of the object's visual representation.
|
||||
* (Not safe for use in simulation code.)
|
||||
*/
|
||||
virtual CVector3D GetPosition() = 0;
|
||||
virtual CVector3D GetPosition() const = 0;
|
||||
|
||||
/**
|
||||
* Return the short name of the actor that's being displayed, or the empty string on error.
|
||||
* (Not safe for use in simulation code.)
|
||||
*/
|
||||
virtual std::wstring GetActorShortName() = 0;
|
||||
virtual std::wstring GetActorShortName() const = 0;
|
||||
|
||||
/**
|
||||
* Return the filename of the actor to be used for projectiles from this unit, or the empty string if none.
|
||||
* (Not safe for use in simulation code.)
|
||||
*/
|
||||
virtual std::wstring GetProjectileActor() = 0;
|
||||
virtual std::wstring GetProjectileActor() const = 0;
|
||||
|
||||
/**
|
||||
* Return the exact position where a projectile should be launched from (based on the actor's
|
||||
* ammo prop points).
|
||||
* Returns (0,0,0) if no point can be found.
|
||||
*/
|
||||
virtual CVector3D GetProjectileLaunchPoint() = 0;
|
||||
virtual CVector3D GetProjectileLaunchPoint() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the underlying unit of this visual actor. May return NULL to indicate that no unit exists (e.g. may happen if the
|
||||
@ -151,7 +151,7 @@ public:
|
||||
/**
|
||||
* Get actor seed used for random variations
|
||||
*/
|
||||
virtual u32 GetActorSeed() = 0;
|
||||
virtual u32 GetActorSeed() const = 0;
|
||||
|
||||
/**
|
||||
* Set actor seed for random variations and reload model
|
||||
@ -161,7 +161,7 @@ public:
|
||||
/**
|
||||
* Returns true if this entity should have a construction preview
|
||||
*/
|
||||
virtual bool HasConstructionPreview() = 0;
|
||||
virtual bool HasConstructionPreview() const = 0;
|
||||
|
||||
/**
|
||||
* Called when an actor file has been modified and reloaded dynamically.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -24,5 +24,5 @@
|
||||
BEGIN_INTERFACE_WRAPPER(WaterManager)
|
||||
DEFINE_INTERFACE_METHOD_0("RecomputeWaterData", void, ICmpWaterManager, RecomputeWaterData)
|
||||
DEFINE_INTERFACE_METHOD_1("SetWaterLevel", void, ICmpWaterManager, SetWaterLevel, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_2("GetWaterLevel", entity_pos_t, ICmpWaterManager, GetWaterLevel, entity_pos_t, entity_pos_t)
|
||||
DEFINE_INTERFACE_METHOD_CONST_2("GetWaterLevel", entity_pos_t, ICmpWaterManager, GetWaterLevel, entity_pos_t, entity_pos_t)
|
||||
END_INTERFACE_WRAPPER(WaterManager)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -38,12 +38,12 @@ public:
|
||||
/**
|
||||
* Get the current water level at the given point.
|
||||
*/
|
||||
virtual entity_pos_t GetWaterLevel(entity_pos_t x, entity_pos_t z) = 0;
|
||||
virtual entity_pos_t GetWaterLevel(entity_pos_t x, entity_pos_t z) const = 0;
|
||||
|
||||
/**
|
||||
* Get the current water level at the given point.
|
||||
*/
|
||||
virtual float GetExactWaterLevel(float x, float z) = 0;
|
||||
virtual float GetExactWaterLevel(float x, float z) const = 0;
|
||||
|
||||
DECLARE_INTERFACE_TYPE(WaterManager)
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -30,8 +30,8 @@ class MockVision : public ICmpVision
|
||||
public:
|
||||
DEFAULT_MOCK_COMPONENT()
|
||||
|
||||
virtual entity_pos_t GetRange() { return entity_pos_t::FromInt(66); }
|
||||
virtual bool GetRevealShore() { return false; }
|
||||
virtual entity_pos_t GetRange() const { return entity_pos_t::FromInt(66); }
|
||||
virtual bool GetRevealShore() const { return false; }
|
||||
};
|
||||
|
||||
class MockPosition : public ICmpPosition
|
||||
@ -40,35 +40,35 @@ public:
|
||||
DEFAULT_MOCK_COMPONENT()
|
||||
|
||||
virtual void SetTurretParent(entity_id_t UNUSED(id), const CFixedVector3D& UNUSED(pos)) {}
|
||||
virtual entity_id_t GetTurretParent() {return INVALID_ENTITY;}
|
||||
virtual entity_id_t GetTurretParent() const {return INVALID_ENTITY;}
|
||||
virtual void UpdateTurretPosition() {}
|
||||
virtual std::set<entity_id_t>* GetTurrets() { return NULL; }
|
||||
virtual bool IsInWorld() { return true; }
|
||||
virtual bool IsInWorld() const { return true; }
|
||||
virtual void MoveOutOfWorld() { }
|
||||
virtual void MoveTo(entity_pos_t UNUSED(x), entity_pos_t UNUSED(z)) { }
|
||||
virtual void MoveAndTurnTo(entity_pos_t UNUSED(x), entity_pos_t UNUSED(z), entity_angle_t UNUSED(a)) { }
|
||||
virtual void JumpTo(entity_pos_t UNUSED(x), entity_pos_t UNUSED(z)) { }
|
||||
virtual void SetHeightOffset(entity_pos_t UNUSED(dy)) { }
|
||||
virtual entity_pos_t GetHeightOffset() { return entity_pos_t::Zero(); }
|
||||
virtual entity_pos_t GetHeightOffset() const { return entity_pos_t::Zero(); }
|
||||
virtual void SetHeightFixed(entity_pos_t UNUSED(y)) { }
|
||||
virtual entity_pos_t GetHeightFixed() { return entity_pos_t::Zero(); }
|
||||
virtual bool IsHeightRelative() { return true; }
|
||||
virtual entity_pos_t GetHeightFixed() const { return entity_pos_t::Zero(); }
|
||||
virtual bool IsHeightRelative() const { return true; }
|
||||
virtual void SetHeightRelative(bool UNUSED(relative)) { }
|
||||
virtual bool IsFloating() { return false; }
|
||||
virtual bool IsFloating() const { return false; }
|
||||
virtual void SetFloating(bool UNUSED(flag)) { }
|
||||
virtual void SetActorFloating(bool UNUSED(flag)) { }
|
||||
virtual void SetConstructionProgress(fixed UNUSED(progress)) { }
|
||||
virtual CFixedVector3D GetPosition() { return CFixedVector3D(); }
|
||||
virtual CFixedVector2D GetPosition2D() { return CFixedVector2D(); }
|
||||
virtual CFixedVector3D GetPreviousPosition() { return CFixedVector3D(); }
|
||||
virtual CFixedVector2D GetPreviousPosition2D() { return CFixedVector2D(); }
|
||||
virtual CFixedVector3D GetPosition() const { return CFixedVector3D(); }
|
||||
virtual CFixedVector2D GetPosition2D() const { return CFixedVector2D(); }
|
||||
virtual CFixedVector3D GetPreviousPosition() const { return CFixedVector3D(); }
|
||||
virtual CFixedVector2D GetPreviousPosition2D() const { return CFixedVector2D(); }
|
||||
virtual void TurnTo(entity_angle_t UNUSED(y)) { }
|
||||
virtual void SetYRotation(entity_angle_t UNUSED(y)) { }
|
||||
virtual void SetXZRotation(entity_angle_t UNUSED(x), entity_angle_t UNUSED(z)) { }
|
||||
virtual CFixedVector3D GetRotation() { return CFixedVector3D(); }
|
||||
virtual fixed GetDistanceTravelled() { return fixed::Zero(); }
|
||||
virtual void GetInterpolatedPosition2D(float UNUSED(frameOffset), float& x, float& z, float& rotY) { x = z = rotY = 0; }
|
||||
virtual CMatrix3D GetInterpolatedTransform(float UNUSED(frameOffset)) { return CMatrix3D(); }
|
||||
virtual CFixedVector3D GetRotation() const { return CFixedVector3D(); }
|
||||
virtual fixed GetDistanceTravelled() const { return fixed::Zero(); }
|
||||
virtual void GetInterpolatedPosition2D(float UNUSED(frameOffset), float& x, float& z, float& rotY) const { x = z = rotY = 0; }
|
||||
virtual CMatrix3D GetInterpolatedTransform(float UNUSED(frameOffset)) const { return CMatrix3D(); }
|
||||
};
|
||||
|
||||
class TestCmpRangeManager : public CxxTest::TestSuite
|
||||
|
@ -1040,7 +1040,7 @@ void LongPathfinder::ImprovePathWaypoints(WaypointPath& path, pass_class_t passC
|
||||
path.m_Waypoints.swap(newWaypoints);
|
||||
}
|
||||
|
||||
void LongPathfinder::GetDebugDataJPS(u32& steps, double& time, Grid<u8>& grid)
|
||||
void LongPathfinder::GetDebugDataJPS(u32& steps, double& time, Grid<u8>& grid) const
|
||||
{
|
||||
steps = m_DebugSteps;
|
||||
time = m_DebugTime;
|
||||
|
@ -71,15 +71,15 @@ public:
|
||||
STATUS_CLOSED = 2
|
||||
};
|
||||
|
||||
bool IsUnexplored() { return GetStatus() == STATUS_UNEXPLORED; }
|
||||
bool IsOpen() { return GetStatus() == STATUS_OPEN; }
|
||||
bool IsClosed() { return GetStatus() == STATUS_CLOSED; }
|
||||
bool IsUnexplored() const { return GetStatus() == STATUS_UNEXPLORED; }
|
||||
bool IsOpen() const { return GetStatus() == STATUS_OPEN; }
|
||||
bool IsClosed() const { return GetStatus() == STATUS_CLOSED; }
|
||||
void SetStatusOpen() { SetStatus(STATUS_OPEN); }
|
||||
void SetStatusClosed() { SetStatus(STATUS_CLOSED); }
|
||||
|
||||
// Get pi,pj coords of predecessor to this tile on best path, given i,j coords of this tile
|
||||
inline int GetPredI(int i) { return i + GetPredDI(); }
|
||||
inline int GetPredJ(int j) { return j + GetPredDJ(); }
|
||||
inline int GetPredI(int i) const { return i + GetPredDI(); }
|
||||
inline int GetPredJ(int j) const { return j + GetPredDJ(); }
|
||||
|
||||
inline PathCost GetCost() const { return g; }
|
||||
inline void SetCost(PathCost cost) { g = cost; }
|
||||
@ -244,7 +244,7 @@ public:
|
||||
return m_PathfinderHier.GetConnectivityGrid(passClass);
|
||||
}
|
||||
|
||||
void GetDebugData(u32& steps, double& time, Grid<u8>& grid)
|
||||
void GetDebugData(u32& steps, double& time, Grid<u8>& grid) const
|
||||
{
|
||||
GetDebugDataJPS(steps, time, grid);
|
||||
}
|
||||
@ -280,7 +280,7 @@ private:
|
||||
* TODO: cleanup documentation
|
||||
*/
|
||||
void ComputeJPSPath(entity_pos_t x0, entity_pos_t z0, const PathGoal& origGoal, pass_class_t passClass, WaypointPath& path);
|
||||
void GetDebugDataJPS(u32& steps, double& time, Grid<u8>& grid);
|
||||
void GetDebugDataJPS(u32& steps, double& time, Grid<u8>& grid) const;
|
||||
|
||||
// Helper functions for ComputePath
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -46,17 +46,20 @@ public:
|
||||
void Deserialize(const CParamNode& paramNode, IDeserializer& deserialize, entity_id_t ent);
|
||||
|
||||
// Use Boost.PP to define:
|
||||
// template<typename R> R Call(const char* funcname);
|
||||
// template<typename R, typename T0> R Call(const char* funcname, const T0& a0);
|
||||
// template<typename R> R Call(const char* funcname) const;
|
||||
// template<typename R, typename T0> R Call(const char* funcname, const T0& a0) const;
|
||||
// ...
|
||||
// void CallVoid(const char* funcname);
|
||||
// template<typename T0> void CallVoid(const char* funcname, const T0& a0);
|
||||
// template<typename R> void CallRef(const char* funcname, R ret) const;
|
||||
// template<typename R, typename T0> void CallRef(const char* funcname, const T0& a0, R ret) const;
|
||||
// ...
|
||||
// void CallVoid(const char* funcname) const;
|
||||
// template<typename T0> void CallVoid(const char* funcname, const T0& a0) const;
|
||||
// ...
|
||||
|
||||
// CallRef is mainly used for returning script values with correct stack rooting.
|
||||
#define OVERLOADS(z, i, data) \
|
||||
template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(i, typename T)> \
|
||||
R Call(const char* funcname BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(i, const T, &a)) \
|
||||
R Call(const char* funcname BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(i, const T, &a)) const \
|
||||
{ \
|
||||
R ret; \
|
||||
if (m_ScriptInterface.CallFunction(m_Instance, funcname BOOST_PP_ENUM_TRAILING_PARAMS(i, a), ret)) \
|
||||
@ -65,13 +68,13 @@ public:
|
||||
return R(); \
|
||||
} \
|
||||
template<typename R BOOST_PP_ENUM_TRAILING_PARAMS(i, typename T)> \
|
||||
void CallRef(const char* funcname BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(i, const T, &a), R ret) \
|
||||
void CallRef(const char* funcname BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(i, const T, &a), R ret) const \
|
||||
{ \
|
||||
if (!m_ScriptInterface.CallFunction(m_Instance, funcname BOOST_PP_ENUM_TRAILING_PARAMS(i, a), ret)) \
|
||||
LOGERROR("Error calling component script function %s", funcname); \
|
||||
} \
|
||||
BOOST_PP_IF(i, template<, ) BOOST_PP_ENUM_PARAMS(i, typename T) BOOST_PP_IF(i, >, ) \
|
||||
void CallVoid(const char* funcname BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(i, const T, &a)) \
|
||||
void CallVoid(const char* funcname BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(i, const T, &a)) const \
|
||||
{ \
|
||||
if (m_ScriptInterface.CallFunctionVoid(m_Instance, funcname BOOST_PP_ENUM_TRAILING_PARAMS(i, a))) \
|
||||
return; \
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -182,37 +182,37 @@ class MockTerrain : public ICmpTerrain
|
||||
public:
|
||||
DEFAULT_MOCK_COMPONENT()
|
||||
|
||||
virtual bool IsLoaded()
|
||||
virtual bool IsLoaded() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual CFixedVector3D CalcNormal(entity_pos_t UNUSED(x), entity_pos_t UNUSED(z))
|
||||
virtual CFixedVector3D CalcNormal(entity_pos_t UNUSED(x), entity_pos_t UNUSED(z)) const
|
||||
{
|
||||
return CFixedVector3D(fixed::FromInt(0), fixed::FromInt(1), fixed::FromInt(0));
|
||||
}
|
||||
|
||||
virtual CVector3D CalcExactNormal(float UNUSED(x), float UNUSED(z))
|
||||
virtual CVector3D CalcExactNormal(float UNUSED(x), float UNUSED(z)) const
|
||||
{
|
||||
return CVector3D(0.f, 1.f, 0.f);
|
||||
}
|
||||
|
||||
virtual entity_pos_t GetGroundLevel(entity_pos_t UNUSED(x), entity_pos_t UNUSED(z))
|
||||
virtual entity_pos_t GetGroundLevel(entity_pos_t UNUSED(x), entity_pos_t UNUSED(z)) const
|
||||
{
|
||||
return entity_pos_t::FromInt(50);
|
||||
}
|
||||
|
||||
virtual float GetExactGroundLevel(float UNUSED(x), float UNUSED(z))
|
||||
virtual float GetExactGroundLevel(float UNUSED(x), float UNUSED(z)) const
|
||||
{
|
||||
return 50.f;
|
||||
}
|
||||
|
||||
virtual u16 GetTilesPerSide()
|
||||
virtual u16 GetTilesPerSide() const
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
virtual u16 GetVerticesPerSide()
|
||||
virtual u16 GetVerticesPerSide() const
|
||||
{
|
||||
return 17;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -65,4 +65,29 @@
|
||||
#define DEFINE_INTERFACE_METHOD_7(scriptname, rettype, classname, methodname, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
|
||||
JS_FN(scriptname, (ScriptInterface::callMethod<rettype, arg1, arg2, arg3, arg4, arg5, arg6, arg7, &class_##classname, classname, &classname::methodname>), 7, JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT),
|
||||
|
||||
// const methods
|
||||
#define DEFINE_INTERFACE_METHOD_CONST_0(scriptname, rettype, classname, methodname) \
|
||||
JS_FN(scriptname, (ScriptInterface::callMethodConst<rettype, &class_##classname, classname, &classname::methodname>), 0, JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT),
|
||||
|
||||
#define DEFINE_INTERFACE_METHOD_CONST_1(scriptname, rettype, classname, methodname, arg1) \
|
||||
JS_FN(scriptname, (ScriptInterface::callMethodConst<rettype, arg1, &class_##classname, classname, &classname::methodname>), 1, JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT),
|
||||
|
||||
#define DEFINE_INTERFACE_METHOD_CONST_2(scriptname, rettype, classname, methodname, arg1, arg2) \
|
||||
JS_FN(scriptname, (ScriptInterface::callMethodConst<rettype, arg1, arg2, &class_##classname, classname, &classname::methodname>), 2, JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT),
|
||||
|
||||
#define DEFINE_INTERFACE_METHOD_CONST_3(scriptname, rettype, classname, methodname, arg1, arg2, arg3) \
|
||||
JS_FN(scriptname, (ScriptInterface::callMethodConst<rettype, arg1, arg2, arg3, &class_##classname, classname, &classname::methodname>), 3, JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT),
|
||||
|
||||
#define DEFINE_INTERFACE_METHOD_CONST_4(scriptname, rettype, classname, methodname, arg1, arg2, arg3, arg4) \
|
||||
JS_FN(scriptname, (ScriptInterface::callMethodConst<rettype, arg1, arg2, arg3, arg4, &class_##classname, classname, &classname::methodname>), 4, JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT),
|
||||
|
||||
#define DEFINE_INTERFACE_METHOD_CONST_5(scriptname, rettype, classname, methodname, arg1, arg2, arg3, arg4, arg5) \
|
||||
JS_FN(scriptname, (ScriptInterface::callMethodConst<rettype, arg1, arg2, arg3, arg4, arg5, &class_##classname, classname, &classname::methodname>), 5, JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT),
|
||||
|
||||
#define DEFINE_INTERFACE_METHOD_CONST_6(scriptname, rettype, classname, methodname, arg1, arg2, arg3, arg4, arg5, arg6) \
|
||||
JS_FN(scriptname, (ScriptInterface::callMethodConst<rettype, arg1, arg2, arg3, arg4, arg5, arg6, &class_##classname, classname, &classname::methodname>), 6, JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT),
|
||||
|
||||
#define DEFINE_INTERFACE_METHOD_CONST_7(scriptname, rettype, classname, methodname, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
|
||||
JS_FN(scriptname, (ScriptInterface::callMethodConst<rettype, arg1, arg2, arg3, arg4, arg5, arg6, arg7, &class_##classname, classname, &classname::methodname>), 7, JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT),
|
||||
|
||||
#endif // INCLUDED_INTERFACE_SCRIPTED
|
||||
|
Loading…
Reference in New Issue
Block a user