1
0
forked from 0ad/0ad

Linux/GCC Compat

This was SVN commit r1393.
This commit is contained in:
Simon Brenner 2004-11-23 23:56:10 +00:00
parent 7bf6d11d8c
commit 30ad195c0b
14 changed files with 40 additions and 25 deletions

View File

@ -1,7 +1,7 @@
#ifndef __H_MESHMANAGER_H__ #ifndef __H_MESHMANAGER_H__
#define __H_MESHMANAGER_H__ #define __H_MESHMANAGER_H__
#include "singleton.h" #include "Singleton.h"
#include "graphics/ModelDef.h" #include "graphics/ModelDef.h"
#define g_MeshManager CMeshManager::GetSingleton() #define g_MeshManager CMeshManager::GetSingleton()

View File

@ -119,7 +119,7 @@ int cpu_smp = -1;
// are there actually multiple physical processors, // are there actually multiple physical processors,
// not only logical hyperthreaded CPUs? relevant for wtime. // not only logical hyperthreaded CPUs? relevant for wtime.
inline void get_cpu_info() void get_cpu_info()
{ {
#ifdef _WIN32 #ifdef _WIN32
win_get_cpu_info(); win_get_cpu_info();
@ -138,9 +138,14 @@ inline void get_cpu_info()
char snd_card[SND_CARD_LEN]; char snd_card[SND_CARD_LEN];
char snd_drv_ver[SND_DRV_VER_LEN]; char snd_drv_ver[SND_DRV_VER_LEN];
inline void get_snd_info() void get_snd_info()
{ {
#ifdef _WIN32 #ifdef _WIN32
win_get_snd_info(); win_get_snd_info();
#else
// At least reset the values for unhandled platforms. Should perhaps do
// something like storing the OpenAL version or similar.
strcpy(snd_card, "Unknown");
strcpy(snd_drv_ver, "Unknown");
#endif #endif
} }

View File

@ -882,7 +882,7 @@ static void hsd_list_free_all()
static void SndData_init(SndData* sd, va_list args) static void SndData_init(SndData* sd, va_list args)
{ {
sd->is_stream = va_arg(args, bool); sd->is_stream = va_arg(args, int);
} }
static void SndData_dtor(SndData* sd) static void SndData_dtor(SndData* sd)
@ -1003,7 +1003,7 @@ static Handle snd_data_load(const char* const fn, const bool stream)
// (both references would read from the same file handle). // (both references would read from the same file handle).
const uint flags = stream? RES_UNIQUE : 0; const uint flags = stream? RES_UNIQUE : 0;
return h_alloc(H_SndData, fn, flags, stream); return h_alloc(H_SndData, fn, flags, (int)stream);
} }

View File

@ -2,7 +2,7 @@
// //
// Mark Thompson (mark@wildfiregames.com / mot20@cam.ac.uk) // Mark Thompson (mark@wildfiregames.com / mot20@cam.ac.uk)
#include "Serialization.h" #include "Network/Serialization.h"
#include "JSConversions.h" #include "JSConversions.h"
#include "CStr.h" #include "CStr.h"

View File

@ -49,6 +49,13 @@ public:
bool m_Inherited; bool m_Inherited;
bool m_Intrinsic; bool m_Intrinsic;
// This is to make sure that all the fields are initialized at construction
inline IJSProperty():
m_AllowsInheritance(true),
m_Inherited(true),
m_Intrinsic(true)
{}
virtual jsval Get( JSContext* cx ) = 0; virtual jsval Get( JSContext* cx ) = 0;
virtual void Set( JSContext* cx, jsval Value ) = 0; virtual void Set( JSContext* cx, jsval Value ) = 0;

View File

@ -30,7 +30,7 @@ CBaseEntity::CBaseEntity()
// Initialize, make life a little easier on the scriptors // Initialize, make life a little easier on the scriptors
m_speed = m_turningRadius = m_meleeRange = m_meleeRangeMin = 0.0f; m_speed = m_turningRadius = m_meleeRange = m_meleeRangeMin = 0.0f;
m_extant = true; m_corpse = NULL; m_extant = true; m_corpse = CStrW();
m_bound_type = CBoundingObject::BOUND_NONE; m_bound_type = CBoundingObject::BOUND_NONE;
m_bound_circle = NULL; m_bound_circle = NULL;
@ -226,6 +226,7 @@ void CBaseEntity::XMLLoadProperty( const CXeromyces& XeroFile, const XMBElement&
XMBAttribute Attribute = AttributeSet.item( AttributeID ); XMBAttribute Attribute = AttributeSet.item( AttributeID );
CStrW AttributeName = PropertyName + CStr8( XeroFile.getAttributeString( Attribute.Name ) ); CStrW AttributeName = PropertyName + CStr8( XeroFile.getAttributeString( Attribute.Name ) );
Existing = HasProperty( AttributeName ); Existing = HasProperty( AttributeName );
if( Existing ) if( Existing )
{ {
Existing->Set( ToJSVal<CStrW>( Attribute.Value ) ); Existing->Set( ToJSVal<CStrW>( Attribute.Value ) );
@ -253,7 +254,7 @@ void CBaseEntity::XMLLoadProperty( const CXeromyces& XeroFile, const XMBElement&
void CBaseEntity::ScriptingInit() void CBaseEntity::ScriptingInit()
{ {
AddMethod<jsval, ToString>( "toString", 0 ); AddMethod<jsval, &CBaseEntity::ToString>( "toString", 0 );
CJSObject<CBaseEntity>::ScriptingInit( "EntityTemplate" ); CJSObject<CBaseEntity>::ScriptingInit( "EntityTemplate" );
} }

View File

@ -587,12 +587,12 @@ void CEntity::renderSelectionOutline( float alpha )
void CEntity::ScriptingInit() void CEntity::ScriptingInit()
{ {
AddMethod<jsval, ToString>( "toString", 0 ); AddMethod<jsval, &CEntity::ToString>( "toString", 0 );
AddMethod<bool, OrderSingle>( "order", 1 ); AddMethod<bool, &CEntity::OrderSingle>( "order", 1 );
AddMethod<bool, OrderQueued>( "orderQueued", 1 ); AddMethod<bool, &CEntity::OrderQueued>( "orderQueued", 1 );
AddMethod<bool, Kill>( "kill", 0 ); AddMethod<bool, &CEntity::Kill>( "kill", 0 );
AddMethod<bool, Damage>( "damage", 1 ); AddMethod<bool, &CEntity::Damage>( "damage", 1 );
AddMethod<bool, IsIdle>( "isIdle", 0 ); AddMethod<bool, &CEntity::IsIdle>( "isIdle", 0 );
CJSObject<CEntity>::ScriptingInit( "Entity", Construct, 2 ); CJSObject<CEntity>::ScriptingInit( "Entity", Construct, 2 );
} }
@ -745,7 +745,8 @@ bool CEntity::Damage( JSContext* cx, uintN argc, jsval* argv )
if( argc >= 3 ) if( argc >= 3 )
{ {
Damage( CDamageType( ToPrimitive<float>( argv[0] ), ToPrimitive<float>( argv[1] ), ToPrimitive<float>( argv[2] ) ), inflictor ); CDamageType dmgType( ToPrimitive<float>( argv[0] ), ToPrimitive<float>( argv[1] ), ToPrimitive<float>( argv[2] ) );
Damage( dmgType, inflictor );
return( true ); return( true );
} }
@ -763,7 +764,9 @@ bool CEntity::Damage( JSContext* cx, uintN argc, jsval* argv )
if( !ToPrimitive<float>( cx, argv[0], dmgN ) ) if( !ToPrimitive<float>( cx, argv[0], dmgN ) )
return( false ); return( false );
Damage( CDamageType( dmgN ), inflictor ); CDamageType dmgType( dmgN );
Damage( dmgType, inflictor );
return( true ); return( true );
} }

View File

@ -116,7 +116,7 @@ public:
private: private:
CEntity( CBaseEntity* base, CVector3D position, float orientation ); CEntity( CBaseEntity* base, CVector3D position, float orientation );
EGotoSituation processGotoHelper( CEntityOrder* current, size_t timestep_milli, HEntity& collide ); /*EGotoSituation*/ uint processGotoHelper( CEntityOrder* current, size_t timestep_milli, HEntity& collide );
bool processAttackMelee( CEntityOrder* current, size_t timestep_milli ); bool processAttackMelee( CEntityOrder* current, size_t timestep_milli );
bool processAttackMeleeNoPathing( CEntityOrder* current, size_t timestep_milli ); bool processAttackMeleeNoPathing( CEntityOrder* current, size_t timestep_milli );
bool processGotoNoPathing( CEntityOrder* current, size_t timestep_milli ); bool processGotoNoPathing( CEntityOrder* current, size_t timestep_milli );

View File

@ -25,7 +25,7 @@ enum EGotoSituation
// Does all the shared processing for line-of-sight gotos // Does all the shared processing for line-of-sight gotos
EGotoSituation CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis, HEntity& collide ) uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis, HEntity& collide )
{ {
float timestep=timestep_millis/1000.0f; float timestep=timestep_millis/1000.0f;

View File

@ -1,7 +1,6 @@
// Supporting data types for CEntity and related // Supporting data types for CEntity and related
class CEntityManager; class CEntityManager;
enum EGotoSituation;
class CDamageType : public CJSObject<CDamageType> class CDamageType : public CJSObject<CDamageType>
{ {