mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
remove apparently no longer used files (contents are empty or commented out)
This was SVN commit r5018.
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
// EntityMessage.h
|
||||
//
|
||||
// Mark Thompson mot20@cam.ac.uk / mark@wildfiregames.com
|
||||
//
|
||||
// Entity message structure.
|
||||
//
|
||||
// Usage: Message types are currently: EMSG_TICK: Sent once per sim frame.
|
||||
// EMSG_INIT: When a new entity is instantiated.
|
||||
// At map loading, do not issue this message immediately
|
||||
// for each entity as it is loaded; instead, wait for all
|
||||
// entities to be created, then issue this message to all
|
||||
// of them simultaneously.
|
||||
// EMSG_ORDER:To push a message into the entity's order queue
|
||||
|
||||
/*
|
||||
#ifndef MESSAGING_INCLUDED
|
||||
#define MESSAGING_INCLUDED
|
||||
|
||||
#include "EntityOrders.h"
|
||||
#include "EntitySupport.h"
|
||||
|
||||
struct CMessage
|
||||
{
|
||||
enum EMessageType
|
||||
{
|
||||
EMSG_TICK,
|
||||
EMSG_INIT,
|
||||
EMSG_ORDER,
|
||||
EMSG_DAMAGE
|
||||
} type;
|
||||
CMessage( EMessageType _type )
|
||||
{
|
||||
type = _type;
|
||||
}
|
||||
};
|
||||
|
||||
struct CMessageOrder : public CMessage
|
||||
{
|
||||
CMessageOrder( CEntityOrder& _order, bool _queue = false ) : CMessage( EMSG_ORDER ), order( _order ), queue( _queue ) {}
|
||||
CEntityOrder order;
|
||||
bool queue;
|
||||
};
|
||||
|
||||
struct CMessageDamage : public CMessage
|
||||
{
|
||||
CMessageDamage( HEntity _inflictor, CDamageType _damage ) : CMessage( EMSG_DAMAGE ), inflictor( inflictor ), damage( damage ) {}
|
||||
HEntity inflictor;
|
||||
CDamageType damage;
|
||||
}
|
||||
|
||||
#endif
|
||||
*/
|
||||
@@ -1,204 +0,0 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
/*
|
||||
#include "EntityProperties.h"
|
||||
#include "EntityTemplateCollection.h"
|
||||
#include "simulation/scripting/JSInterface_EntityTemplate.h"
|
||||
|
||||
#undef new // to avoid confusing warnings
|
||||
|
||||
void IBoundProperty::associate( IBoundPropertyOwner* owner, const CStrW& name )
|
||||
{
|
||||
m_owner = owner;
|
||||
owner->m_properties[name] = this;
|
||||
m_updateFn = NULL;
|
||||
}
|
||||
|
||||
void IBoundProperty::associate( IBoundPropertyOwner* owner, const CStrW& name, void (IBoundPropertyOwner::*updateFn)() )
|
||||
{
|
||||
m_owner = owner;
|
||||
owner->m_properties[name] = this;
|
||||
m_updateFn = updateFn;
|
||||
}
|
||||
|
||||
void IBoundProperty::fromjsval( const jsval value )
|
||||
{
|
||||
set( value );
|
||||
if( m_updateFn )
|
||||
(m_owner->*m_updateFn)();
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
|
||||
|
||||
// ---
|
||||
|
||||
void CBoundProperty<int>::set( const jsval value )
|
||||
{
|
||||
try
|
||||
{
|
||||
m_data = ToPrimitive<int>( value );
|
||||
m_inherited = false;
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
jsval CBoundProperty<int>::tojsval()
|
||||
{
|
||||
return( INT_TO_JSVAL( m_data ) );
|
||||
}
|
||||
|
||||
void CBoundProperty<bool>::set( const jsval value )
|
||||
{
|
||||
try
|
||||
{
|
||||
m_data = ToPrimitive<bool>( value );
|
||||
m_inherited = false;
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
jsval CBoundProperty<bool>::tojsval()
|
||||
{
|
||||
return( BOOLEAN_TO_JSVAL( m_data ) );
|
||||
}
|
||||
|
||||
void CBoundProperty<float>::set( const jsval value )
|
||||
{
|
||||
try
|
||||
{
|
||||
m_data = ToPrimitive<float>( value );
|
||||
m_inherited = false;
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
jsval CBoundProperty<float>::tojsval()
|
||||
{
|
||||
return( DOUBLE_TO_JSVAL( JS_NewDouble( g_ScriptingHost.getContext(), (jsdouble)m_data ) ) );
|
||||
}
|
||||
|
||||
void CBoundObjectProperty<CStr>::set( const jsval value )
|
||||
{
|
||||
try
|
||||
{
|
||||
m_String = g_ScriptingHost.ValueToString( value );
|
||||
m_inherited = false;
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
jsval CBoundObjectProperty<CStr>::tojsval()
|
||||
{
|
||||
return( STRING_TO_JSVAL( JS_NewStringCopyZ( g_ScriptingHost.getContext(), m_String.c_str() ) ) );
|
||||
}
|
||||
|
||||
void CBoundObjectProperty<CStrW>::set( const jsval value )
|
||||
{
|
||||
try
|
||||
{
|
||||
m_String = g_ScriptingHost.ValueToUCString( value );
|
||||
m_inherited = false;
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
jsval CBoundObjectProperty<CStrW>::tojsval()
|
||||
{
|
||||
return( STRING_TO_JSVAL( JS_NewUCStringCopyZ( g_ScriptingHost.getContext(), utf16().c_str() ) ) );
|
||||
}
|
||||
|
||||
CBoundObjectProperty<CVector3D>::CBoundObjectProperty()
|
||||
{
|
||||
m_inherited = false;
|
||||
}
|
||||
|
||||
void CBoundObjectProperty<CVector3D>::set( const jsval value )
|
||||
{
|
||||
JSObject* vector3d = JSVAL_TO_OBJECT( value );
|
||||
JSI_Vector3D::Vector3D_Info* v = NULL;
|
||||
if( JSVAL_IS_OBJECT( value ) && ( v = (JSI_Vector3D::Vector3D_Info*)JS_GetInstancePrivate( g_ScriptingHost.getContext(), vector3d, &JSI_Vector3D::JSI_class, NULL ) ) )
|
||||
{
|
||||
CVector3D* copy = v->vector;
|
||||
X = copy->X;
|
||||
Y = copy->Y;
|
||||
Z = copy->Z;
|
||||
m_inherited = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
X = 0.0f; Y = 0.0f; Z = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
jsval CBoundObjectProperty<CVector3D>::tojsval()
|
||||
{
|
||||
JSObject* vector3d = JS_NewObject( g_ScriptingHost.getContext(), &JSI_Vector3D::JSI_class, NULL, NULL );
|
||||
JS_SetPrivate( g_ScriptingHost.getContext(), vector3d, new JSI_Vector3D::Vector3D_Info( this, m_owner, m_updateFn ) );
|
||||
return( OBJECT_TO_JSVAL( vector3d ) );
|
||||
}
|
||||
|
||||
bool CBoundObjectProperty<CVector3D>::rebuild( IBoundProperty* parent, bool triggerFn )
|
||||
{
|
||||
return( false );
|
||||
}
|
||||
|
||||
//--
|
||||
|
||||
void CBoundObjectProperty<CScriptObject>::set( const jsval value )
|
||||
{
|
||||
switch( JS_TypeOfValue( g_ScriptingHost.GetContext(), value ) )
|
||||
{
|
||||
case JSTYPE_STRING:
|
||||
CompileScript( L"", g_ScriptingHost.ValueToUCString( value ) );
|
||||
m_inherited = false;
|
||||
break;
|
||||
case JSTYPE_FUNCTION:
|
||||
Function = JS_ValueToFunction( g_ScriptingHost.GetContext(), value );
|
||||
m_inherited = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
jsval CBoundObjectProperty<CScriptObject>::tojsval()
|
||||
{
|
||||
if( Function )
|
||||
return( OBJECT_TO_JSVAL( JS_GetFunctionObject( Function ) ) );
|
||||
return( JSVAL_NULL );
|
||||
}
|
||||
|
||||
//--
|
||||
|
||||
void CBoundProperty<CEntityTemplate*>::set( const jsval value )
|
||||
{
|
||||
JSObject* baseEntity = JSVAL_TO_OBJECT( value );
|
||||
CEntityTemplate* base = NULL;
|
||||
|
||||
if( JSVAL_IS_OBJECT( value ) && ( base = ToNative<CEntityTemplate>( g_ScriptingHost.GetContext(), baseEntity ) ) )
|
||||
{
|
||||
m_data = base;
|
||||
}
|
||||
else
|
||||
JS_ReportError( g_ScriptingHost.getContext(), "[EntityTemplate] Invalid reference" );
|
||||
}
|
||||
|
||||
jsval CBoundProperty<CEntityTemplate*>::tojsval()
|
||||
{
|
||||
JSObject* baseEntity = m_data->GetScript();
|
||||
return( OBJECT_TO_JSVAL( baseEntity ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
*/
|
||||
@@ -1,187 +0,0 @@
|
||||
// EntityProperties.h
|
||||
//
|
||||
// Mark Thompson mot20@cam.ac.uk / mark@wildfiregames.com
|
||||
//
|
||||
// Extended properties table, primarily intended for data-inheritable properties and those defined by JavaScript functions.
|
||||
//
|
||||
// Usage: These properties are accessed via functions in CEntity/CEntityTemplate
|
||||
//
|
||||
|
||||
// TODO: Fix the silent failures of the conversion functions: need to work out what to do in these cases.
|
||||
|
||||
// Mark Thompson mot20@cam.ac.uk / mark@wildfiregames.com
|
||||
|
||||
/*
|
||||
#ifndef ENTITY_PROPERTIES_INCLUDED
|
||||
#define ENTITY_PROPERTIES_INCLUDED
|
||||
|
||||
#include "ps/CStr.h"
|
||||
#include "maths/Vector3D.h"
|
||||
#include "ScriptObject.h"
|
||||
|
||||
#include "simulation/scripting/JSInterface_Entity.h"
|
||||
#include "maths/scripting/JSInterface_Vector3D.h"
|
||||
|
||||
#if !GCC_VERSION
|
||||
|
||||
|
||||
|
||||
class IBoundPropertyOwner;
|
||||
class CEntityTemplate;
|
||||
|
||||
// Property interface
|
||||
|
||||
class IBoundProperty
|
||||
{
|
||||
protected:
|
||||
IBoundPropertyOwner* m_owner;
|
||||
void (IBoundPropertyOwner::*m_updateFn)();
|
||||
virtual void set( const jsval value ) = 0;
|
||||
public:
|
||||
void fromjsval( const jsval value );
|
||||
virtual jsval tojsval() = 0;
|
||||
virtual bool rebuild( IBoundProperty* parent, bool triggerFn = true ) = 0; // Returns true if the rebuild changed the value of this property.
|
||||
void associate( IBoundPropertyOwner* owner, const CStrW& name );
|
||||
void associate( IBoundPropertyOwner* owner, const CStrW& name, void (IBoundPropertyOwner::*updateFn)() );
|
||||
virtual ~IBoundProperty() {}
|
||||
};
|
||||
|
||||
// Specialize at least:
|
||||
// - jsval conversion functions (set, tojsval)
|
||||
|
||||
// Generic primitive one:
|
||||
|
||||
template<typename T> class CBoundProperty : public IBoundProperty
|
||||
{
|
||||
T m_data;
|
||||
bool m_inherited;
|
||||
|
||||
public:
|
||||
CBoundProperty() { m_inherited = true; }
|
||||
CBoundProperty( const T& copy ) { m_inherited = false; m_data = copy; }
|
||||
operator T&() { return( m_data ); }
|
||||
operator const T&() const { return( m_data ); }
|
||||
T& operator=( const T& copy ) { m_inherited = false; return( m_data = copy ); }
|
||||
|
||||
void set( const jsval value );
|
||||
jsval tojsval();
|
||||
bool rebuild( IBoundProperty* parent, bool triggerFn = true )
|
||||
{
|
||||
if( m_inherited && parent )
|
||||
{
|
||||
*this = *( (CBoundProperty<T>*)parent );
|
||||
if( triggerFn && m_updateFn )
|
||||
(m_owner->*m_updateFn)();
|
||||
}
|
||||
return( !m_inherited );
|
||||
}
|
||||
};
|
||||
|
||||
// Generic class one:
|
||||
|
||||
template<typename T> class CBoundObjectProperty : public IBoundProperty, public T
|
||||
{
|
||||
bool m_inherited;
|
||||
|
||||
public:
|
||||
CBoundObjectProperty() { m_inherited = true; }
|
||||
CBoundObjectProperty( const T& copy ) : T( copy ) { m_inherited = false; }
|
||||
|
||||
T& operator=( const T& copy )
|
||||
{
|
||||
IBoundPropertyOwner* sv_owner = m_owner;
|
||||
void (IBoundPropertyOwner::*sv_updateFn)() = m_updateFn;
|
||||
|
||||
(T&)*this = copy;
|
||||
|
||||
m_owner = sv_owner;
|
||||
m_updateFn = sv_updateFn;
|
||||
m_inherited = false;
|
||||
|
||||
return( *this );
|
||||
}
|
||||
void set( const jsval value );
|
||||
jsval tojsval();
|
||||
bool rebuild( IBoundProperty* parent, bool triggerFn = true )
|
||||
{
|
||||
if( m_inherited && parent )
|
||||
{
|
||||
// Save some properties so they won't be overwritten
|
||||
IBoundPropertyOwner* sv_owner = m_owner;
|
||||
void (IBoundPropertyOwner::*sv_updateFn)() = m_updateFn;
|
||||
|
||||
*this = *( (CBoundObjectProperty<T>*)parent );
|
||||
|
||||
m_owner = sv_owner;
|
||||
m_updateFn = sv_updateFn;
|
||||
m_inherited = true;
|
||||
|
||||
if( triggerFn && m_updateFn )
|
||||
(m_owner->*m_updateFn)();
|
||||
}
|
||||
return( !m_inherited );
|
||||
}
|
||||
};
|
||||
|
||||
// And an explicit one:
|
||||
|
||||
template<> class CBoundProperty<CEntityTemplate*> : public IBoundProperty
|
||||
{
|
||||
CEntityTemplate* m_data;
|
||||
|
||||
public:
|
||||
CBoundProperty() { m_data = NULL; }
|
||||
CBoundProperty( CEntityTemplate* copy ) { m_data = copy; }
|
||||
|
||||
operator CEntityTemplate*&() { return( m_data ); }
|
||||
operator CEntityTemplate*() const { return( m_data ); }
|
||||
CEntityTemplate*& operator=( CEntityTemplate* copy ) { return( m_data = copy ); }
|
||||
|
||||
// Standard pointerish things
|
||||
|
||||
CEntityTemplate& operator*() { return( *m_data ); }
|
||||
CEntityTemplate* operator->() { return( m_data ); }
|
||||
|
||||
void set( const jsval value );
|
||||
jsval tojsval();
|
||||
bool rebuild( IBoundProperty* parent, bool triggerFn = true )
|
||||
{
|
||||
return( false ); // Can't inherit a CEntityTemplate*
|
||||
}
|
||||
};
|
||||
|
||||
// A jsval property
|
||||
template<> class CBoundProperty<jsval> : public IBoundProperty
|
||||
{
|
||||
jsval m_data;
|
||||
bool m_inherited;
|
||||
public:
|
||||
CBoundProperty() { m_data = JSVAL_NULL; m_inherited = true; RootJSVal(); }
|
||||
CBoundProperty( const jsval value ) { set( value ); m_inherited = false; RootJSVal(); }
|
||||
CBoundProperty( const CStrW& value )
|
||||
{
|
||||
m_data = STRING_TO_JSVAL( JS_NewUCStringCopyZ( g_ScriptingHost.getContext(), value ) );
|
||||
RootJSVal();
|
||||
}
|
||||
~CBoundProperty()
|
||||
{
|
||||
UprootJSVal();
|
||||
}
|
||||
void set( const jsval value ) { UprootJSVal(); m_data = value; m_inherited = false; RootJSVal(); }
|
||||
jsval tojsval() { return( m_data ); }
|
||||
bool rebuild( IBoundProperty* parent, bool triggerFn = true )
|
||||
{
|
||||
if( m_inherited && parent )
|
||||
{
|
||||
UprootJSVal();
|
||||
m_data = ( (CBoundProperty<jsval>*)parent )->m_data;
|
||||
RootJSVal();
|
||||
}
|
||||
return( !m_inherited );
|
||||
}
|
||||
void RootJSVal() { if( JSVAL_IS_GCTHING( m_data ) ) JS_AddRoot( g_ScriptingHost.GetContext(), &m_data ); }
|
||||
void UprootJSVal() { if( JSVAL_IS_GCTHING( m_data ) ) JS_RemoveRoot( g_ScriptingHost.GetContext(), &m_data ); }
|
||||
};
|
||||
|
||||
#endif
|
||||
*/
|
||||
Reference in New Issue
Block a user