Linux/GCC Compat(tm)
This was SVN commit r1284.
This commit is contained in:
parent
5ab0be984b
commit
3136791492
@ -37,4 +37,4 @@ private:
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -586,4 +586,4 @@ void CGUIString::SetValue(const CStrW& str)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -507,4 +507,4 @@ void IGUIObject::SetFocus()
|
||||
bool IGUIObject::IsFocused() const
|
||||
{
|
||||
return GetGUI()->m_FocusedObject == this;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,18 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "gui/MiniMap.h"
|
||||
#include "ps/game.h"
|
||||
#include "ps/Game.h"
|
||||
|
||||
#include "ogl.h"
|
||||
#include "renderer/renderer.h"
|
||||
#include "renderer/Renderer.h"
|
||||
#include "graphics/TextureEntry.h"
|
||||
#include "graphics/TextureManager.h"
|
||||
|
||||
static unsigned int ScaleColor(unsigned int color,float x)
|
||||
{
|
||||
unsigned int r=unsigned int(float(color & 0xff)*x);
|
||||
unsigned int g=unsigned int(float((color>>8) & 0xff)*x);
|
||||
unsigned int b=unsigned int(float((color>>16) & 0xff)*x);
|
||||
unsigned int r=uint(float(color & 0xff)*x);
|
||||
unsigned int g=uint(float((color>>8) & 0xff)*x);
|
||||
unsigned int b=uint(float((color>>16) & 0xff)*x);
|
||||
return (0xff000000 | r | g<<8 | b<<16);
|
||||
}
|
||||
|
||||
@ -199,4 +200,4 @@ CVector2D CMiniMap::GetMapSpaceCoords(CVector3D worldPos)
|
||||
float scaleX = float(m_Width) / float(m_MapSize - 1);
|
||||
float scaleY = float(m_Height) / float(m_MapSize - 1);
|
||||
return CVector2D(float(x) * scaleX, float(y) * scaleY);
|
||||
}
|
||||
}
|
||||
|
@ -56,4 +56,4 @@ protected:
|
||||
u32 m_TextureSize;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -6,4 +6,4 @@
|
||||
// with 32 bits, we'd need >= 12 for the index, leaving < 512K tags -
|
||||
// not a lot.
|
||||
typedef i64 Handle;
|
||||
#define HANDLE_DEFINED
|
||||
#define HANDLE_DEFINED
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include <al/al.h>
|
||||
#include <AL/al.h>
|
||||
#include <vorbis/vorbisfile.h>
|
||||
|
||||
|
||||
|
@ -6,4 +6,4 @@ void ogg_open(void* o, ALenum& fmt, ALsizei& freq);
|
||||
|
||||
size_t ogg_read(void* o, void* buf, size_t max_size);
|
||||
|
||||
void ogg_release(void* o);
|
||||
void ogg_release(void* o);
|
||||
|
@ -63,6 +63,20 @@ extern float fmaxf(float a, float b);
|
||||
# include <ext/hash_map>
|
||||
# define STL_HASH_MAP __gnu_cxx::hash_map
|
||||
# define STL_HASH_MULTIMAP __gnu_cxx::hash_multimap
|
||||
|
||||
// Hack: GCC Doesn't have a hash instance for std::string included (and it looks
|
||||
// like they won't add it - marked resolved/wontfix in the gcc bugzilla)
|
||||
namespace __gnu_cxx
|
||||
{
|
||||
template<> struct hash<std::string>
|
||||
{
|
||||
size_t operator()(const std::string& __x) const
|
||||
{
|
||||
return __stl_hash_string(__x.c_str());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#else // !__GNUC__
|
||||
# include <hash_map>
|
||||
# if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "ps/Game.h"
|
||||
|
||||
#include "Config.h"
|
||||
#include "MapReader.h"
|
||||
#include "Terrain.h"
|
||||
#include "TextureManager.h"
|
||||
@ -592,7 +591,7 @@ static void LoadGlobals()
|
||||
val->GetBool(g_Shadows);
|
||||
|
||||
LOG(NORMAL, LOG_CATEGORY, "g_x/yres is %dx%d", g_xres, g_yres);
|
||||
LOG(NORMAL, LOG_CATEGORY, "Active profile is %s", g_ActiveProfile);
|
||||
LOG(NORMAL, LOG_CATEGORY, "Active profile is %s", g_ActiveProfile.c_str());
|
||||
}
|
||||
|
||||
static void ParseArgs(int argc, char* argv[])
|
||||
|
@ -62,4 +62,4 @@ class CVector3D
|
||||
void Normalize ();
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -15,7 +15,7 @@ extern bool keys[SDLK_LAST];
|
||||
extern bool g_active;
|
||||
|
||||
static const float SELECT_DBLCLICK_RATE = 0.5f;
|
||||
static const int ORDER_DELAY = 5;
|
||||
const int ORDER_DELAY = 5;
|
||||
|
||||
void CSelectedEntities::addSelection( HEntity entity )
|
||||
{
|
||||
|
@ -39,4 +39,4 @@ bool VFSUtil::FindFiles (CStr dirname, const char* filter, FileList& files)
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,4 @@ namespace VFSUtil
|
||||
// On failure, logs an error and returns false.
|
||||
bool FindFiles(CStr dirname, const char* filter, FileList& files);
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#include "scripting/ScriptingHost.h"
|
||||
#include "scripting/JSInterface_Entity.h"
|
||||
#include "simulation/ScriptObject.h"
|
||||
#include "scripting/JSConversions.h"
|
||||
|
||||
#ifndef JS_COLLECTION_INCLUDED
|
||||
#define JS_COLLECTION_INCLUDED
|
||||
@ -264,7 +266,7 @@ template<typename T, JSClass* ScriptType> JSBool CJSCollection<T, ScriptType>::S
|
||||
CJSCollectionData* CollectionData = new CJSCollectionData();
|
||||
CollectionData->m_EngineOwned = false;
|
||||
|
||||
std::vector<T>::iterator it;
|
||||
typename std::vector<T>::iterator it;
|
||||
|
||||
CScriptObject Predicate( argv[0] );
|
||||
|
||||
|
@ -32,4 +32,4 @@ private:
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -12,8 +12,8 @@ CScriptEvent::CScriptEvent( const CStrW& Type, bool Cancelable, unsigned int Typ
|
||||
|
||||
void CScriptEvent::ScriptingInit()
|
||||
{
|
||||
AddMethod<jsval, ToString>( "toString", 0 );
|
||||
AddMethod<jsval, PreventDefault>( "preventDefault", 0 );
|
||||
AddMethod<jsval, &CScriptEvent::ToString>( "toString", 0 );
|
||||
AddMethod<jsval, &CScriptEvent::PreventDefault>( "preventDefault", 0 );
|
||||
|
||||
CJSObject<CScriptEvent>::ScriptingInit( "Event" );
|
||||
}
|
||||
@ -27,9 +27,10 @@ jsval CScriptEvent::PreventDefault( JSContext* cx, uintN argc, jsval* argv )
|
||||
|
||||
jsval CScriptEvent::ToString( JSContext* cx, uintN argc, jsval* argv )
|
||||
{
|
||||
utf16_t buffer[256];
|
||||
wchar_t buffer[256];
|
||||
swprintf( buffer, 256, L"[object Event: %ls]", m_Type.c_str() );
|
||||
buffer[255] = 0;
|
||||
return( STRING_TO_JSVAL( JS_NewUCStringCopyZ( cx, buffer ) ) );
|
||||
utf16string str16=utf16string(buffer, buffer+wcslen(buffer));
|
||||
return( STRING_TO_JSVAL( JS_NewUCStringCopyZ( cx, str16.c_str() ) ) );
|
||||
}
|
||||
|
||||
|
@ -197,12 +197,12 @@ template<> bool ToPrimitive<CStrW>( JSContext* cx, jsval v, CStrW& Storage )
|
||||
|
||||
template<> jsval ToJSVal<CStrW>( const CStrW& Native )
|
||||
{
|
||||
return( STRING_TO_JSVAL( JS_NewUCStringCopyZ( g_ScriptingHost.GetContext(), Native.c_str() ) ) );
|
||||
return( STRING_TO_JSVAL( JS_NewUCStringCopyZ( g_ScriptingHost.GetContext(), Native.utf16().c_str() ) ) );
|
||||
}
|
||||
|
||||
template<> jsval ToJSVal<CStrW>( CStrW& Native )
|
||||
{
|
||||
return( STRING_TO_JSVAL( JS_NewUCStringCopyZ( g_ScriptingHost.GetContext(), Native.c_str() ) ) );
|
||||
return( STRING_TO_JSVAL( JS_NewUCStringCopyZ( g_ScriptingHost.GetContext(), Native.utf16().c_str() ) ) );
|
||||
}
|
||||
|
||||
// jsval
|
||||
|
@ -115,4 +115,4 @@ template<> jsval ToJSVal<jsval>( const jsval& Native );
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -164,7 +164,7 @@ template<typename T, bool ReadOnly> class CJSProperty : public IJSProperty
|
||||
public:
|
||||
CJSProperty( T* Data, IJSObject* Owner = NULL, bool AllowsInheritance = false, IJSObject::NotifyFn Update = NULL, IJSObject::NotifyFn Freshen = NULL )
|
||||
{
|
||||
assert( !( !m_Owner && ( Freshen || Update ) ) ); // Bad programmer.
|
||||
assert( !( !Owner && ( Freshen || Update ) ) ); // Bad programmer.
|
||||
m_Data = Data;
|
||||
m_Owner = Owner;
|
||||
m_AllowsInheritance = AllowsInheritance;
|
||||
@ -336,7 +336,8 @@ public:
|
||||
static void ScriptingInit( const char* ClassName, JSNative Constructor = NULL, uintN ConstructorMinArgs = 0 )
|
||||
{
|
||||
JSFunctionSpec* JSI_methods = new JSFunctionSpec[ m_Methods.size() + 1 ];
|
||||
for( unsigned int MethodID = 0; MethodID < m_Methods.size(); MethodID++ )
|
||||
unsigned int MethodID;
|
||||
for( MethodID = 0; MethodID < m_Methods.size(); MethodID++ )
|
||||
JSI_methods[MethodID] = m_Methods[MethodID];
|
||||
|
||||
JSI_methods[MethodID].name = 0;
|
||||
|
@ -327,6 +327,17 @@ CStrW ScriptingHost::ValueToUCString( const jsval value )
|
||||
return CStrW(std::wstring(strptr, strptr+length));
|
||||
}
|
||||
|
||||
utf16string ScriptingHost::ValueToUTF16( const jsval value )
|
||||
{
|
||||
JSString* string = JS_ValueToString(m_Context, value);
|
||||
if (string == NULL)
|
||||
throw PSERROR_Scripting_ConversionFailed();
|
||||
|
||||
jschar *strptr=JS_GetStringChars(string);
|
||||
size_t length=JS_GetStringLength(string);
|
||||
return utf16string(strptr, strptr+length);
|
||||
}
|
||||
|
||||
jsval ScriptingHost::UCStringToValue(const utf16string &str)
|
||||
{
|
||||
return STRING_TO_JSVAL(JS_NewUCStringCopyZ(m_Context, str.c_str()));
|
||||
|
@ -114,6 +114,7 @@ public:
|
||||
bool ValueToBool(const jsval value);
|
||||
std::string ValueToString(const jsval value);
|
||||
CStrW ValueToUCString( const jsval value );
|
||||
utf16string ValueToUTF16( const jsval value );
|
||||
double ValueToDouble(const jsval value);
|
||||
|
||||
jsval UCStringToValue(const utf16string &str);
|
||||
|
@ -244,7 +244,7 @@ void CBaseEntity::XMLLoadProperty( const CXeromyces& XeroFile, const XMBElement&
|
||||
|
||||
void CBaseEntity::ScriptingInit()
|
||||
{
|
||||
AddMethod<jsval, ToString>( "toString", 0 );
|
||||
AddMethod<jsval, &CBaseEntity::ToString>( "toString", 0 );
|
||||
CJSObject<CBaseEntity, true>::ScriptingInit( "EntityTemplate" );
|
||||
}
|
||||
|
||||
@ -252,8 +252,9 @@ void CBaseEntity::ScriptingInit()
|
||||
|
||||
jsval CBaseEntity::ToString( JSContext* cx, uintN argc, jsval* argv )
|
||||
{
|
||||
utf16_t buffer[256];
|
||||
wchar_t buffer[256];
|
||||
swprintf( buffer, 256, L"[object EntityTemplate: %ls]", m_Tag.c_str() );
|
||||
buffer[255] = 0;
|
||||
return( STRING_TO_JSVAL( JS_NewUCStringCopyZ( cx, buffer ) ) );
|
||||
}
|
||||
utf16string str16(buffer, buffer+wcslen(buffer));
|
||||
return( STRING_TO_JSVAL( JS_NewUCStringCopyZ( cx, str16.c_str() ) ) );
|
||||
}
|
||||
|
@ -25,14 +25,14 @@ CEntity::CEntity( CBaseEntity* base, CVector3D position, float orientation )
|
||||
m_ahead.x = sin( m_orientation );
|
||||
m_ahead.y = cos( m_orientation );
|
||||
|
||||
AddProperty( L"template", (CBaseEntity**)&m_base, false, (NotifyFn)loadBase );
|
||||
AddProperty( L"template", (CBaseEntity**)&m_base, false, (NotifyFn)&CEntity::loadBase );
|
||||
AddProperty( L"actions.move.speed", &m_speed );
|
||||
AddProperty( L"selected", &m_selected, false, (NotifyFn)checkSelection );
|
||||
AddProperty( L"group", &m_grouped, false, (NotifyFn)checkGroup );
|
||||
AddProperty( L"extant", &m_extant, false, (NotifyFn)checkExtant );
|
||||
AddProperty( L"selected", &m_selected, false, (NotifyFn)&CEntity::checkSelection );
|
||||
AddProperty( L"group", &m_grouped, false, (NotifyFn)&CEntity::checkGroup );
|
||||
AddProperty( L"extant", &m_extant, false, (NotifyFn)&CEntity::checkExtant );
|
||||
AddProperty( L"actions.move.turningradius", &m_turningRadius );
|
||||
AddProperty( L"position", &m_graphics_position, false, (NotifyFn)teleport );
|
||||
AddProperty( L"orientation", &m_graphics_orientation, false, (NotifyFn)reorient );
|
||||
AddProperty( L"position", &m_graphics_position, false, (NotifyFn)&CEntity::teleport );
|
||||
AddProperty( L"orientation", &m_graphics_orientation, false, (NotifyFn)&CEntity::reorient );
|
||||
|
||||
|
||||
for( int t = 0; t < EVENT_LAST; t++ )
|
||||
@ -521,9 +521,9 @@ void CEntity::renderSelectionOutline( float alpha )
|
||||
|
||||
void CEntity::ScriptingInit()
|
||||
{
|
||||
AddMethod<jsval, ToString>( "toString", 0 );
|
||||
AddMethod<bool, OrderSingle>( "order", 1 );
|
||||
AddMethod<bool, OrderQueued>( "orderQueued", 1 );
|
||||
AddMethod<jsval, &CEntity::ToString>( "toString", 0 );
|
||||
AddMethod<bool, &CEntity::OrderSingle>( "order", 1 );
|
||||
AddMethod<bool, &CEntity::OrderQueued>( "orderQueued", 1 );
|
||||
CJSObject<CEntity, true>::ScriptingInit( "Entity", Construct, 2 );
|
||||
}
|
||||
|
||||
@ -593,10 +593,11 @@ JSBool CEntity::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsva
|
||||
|
||||
jsval CEntity::ToString( JSContext* cx, uintN argc, jsval* argv )
|
||||
{
|
||||
utf16_t buffer[256];
|
||||
wchar_t buffer[256];
|
||||
swprintf( buffer, 256, L"[object Entity: %ls]", m_base->m_Tag.c_str() );
|
||||
buffer[255] = 0;
|
||||
return( STRING_TO_JSVAL( JS_NewUCStringCopyZ( cx, buffer ) ) );
|
||||
utf16string str16(buffer, buffer+wcslen(buffer));
|
||||
return( STRING_TO_JSVAL( JS_NewUCStringCopyZ( cx, str16.c_str() ) ) );
|
||||
}
|
||||
|
||||
bool CEntity::Order( JSContext* cx, uintN argc, jsval* argv, bool Queued )
|
||||
|
@ -201,4 +201,4 @@ jsval CBoundProperty<CBaseEntity*>::tojsval()
|
||||
|
||||
|
||||
|
||||
*/
|
||||
*/
|
||||
|
@ -30,4 +30,4 @@ class CEventTick : public CScriptEvent
|
||||
public: CEventTick() : CScriptEvent( L"tick", false, EVENT_TICK ) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -81,5 +81,6 @@ void CScriptObject::DispatchEvent( JSObject* Context, CScriptEvent* evt )
|
||||
void CScriptObject::Compile( CStrW FileNameTag, CStrW FunctionBody )
|
||||
{
|
||||
const char* argnames[] = { "evt" };
|
||||
Function = JS_CompileUCFunction( g_ScriptingHost.GetContext(), NULL, NULL, 1, argnames, FunctionBody, FunctionBody.Length(), (CStr)FileNameTag, 0 );
|
||||
utf16string str16=FunctionBody.utf16();
|
||||
Function = JS_CompileUCFunction( g_ScriptingHost.GetContext(), NULL, NULL, 1, argnames, str16.c_str(), str16.size(), (CStr)FileNameTag, 0 );
|
||||
}
|
||||
|
@ -42,4 +42,4 @@ public:
|
||||
void DispatchEvent( JSObject* Context, CScriptEvent* evt );
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -225,4 +225,4 @@ JSBool JSI_Entity::order( JSContext* cx, JSObject* obj, uintN argc, jsval* argv,
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user