Jump to content

  • Log In with Google      Sign In   
  • Create Account


_Vicious_

Member Since 07 Feb 2009
Offline Last Active Jun 23 2014 01:15 PM

Topics I've Started

Implicit conversion changed sign of value

31 January 2014 - 01:41 PM

Hi Andreas,

 

here I am again with another question :)

 

The following code produces a warning which says "Implicit conversion changed sign of value":

       
if ( ( G_PointContents( spawn.origin ) & CONTENTS_NODROP ) != 0 )
...

 

G_PointContents's declaration is:

 

int G_PointContents( const Vec3 &in origin )

 

and CONTENTS_NODROP is an enum. Changing the line to read:

 

if ( ( G_PointContents( spawn.origin ) & uint( CONTENTS_NODROP ) ) != 0 )

 

fixes the warning. Why casting an enum to unsigned int fixes the warning, while G_PointContents is obviously a signed integer?


Builtin range/collection type

30 January 2014 - 02:35 AM

Hello fellow AngelScripters,

now that we have 'auto' keyword support thanks to GGLucas ( http://www.gamedev.net/topic/652525-experimental-patches-named-arguments-and-auto-declarations/ ) maybe we could start thinking on how it'd be best to implement iteratable ranges/collection types in AS? For example, it'd be nice to be able to iterate in the following manner:
 

uint maxPlayers;
...
for( auto playerIndex : range<int>(0,maxPlayers-1) ) {

or even
 

array <Player @> players;
...
for( auto @Player : players ) {

I'm using C++11 syntax here but there might be other alternatives.

Any thoughts or suggestions?


[BUG] Problem with dictionary addon/implicit casts

26 January 2014 - 04:44 PM

I suspect rev 1812 "Implicit cast didn't work in initialization of global vars" broke the dictionary addon in case a global String object was passed as the agument for the get method.

 

    r = engine->RegisterObjectMethod("Dictionary", "void set(const String &in, ?&in)", asFUNCTION(ScriptDictionarySet_Generic), asCALL_GENERIC); assert( r >= 0 );
    r = engine->RegisterObjectMethod("Dictionary", "bool get(const String &in, ?&out) const", asFUNCTION(ScriptDictionaryGet_Generic), asCALL_GENERIC); assert( r >= 0 );

    r = engine->RegisterObjectMethod("Dictionary", "void set(const String &in, int64&in)", asFUNCTION(ScriptDictionarySetInt_Generic), asCALL_GENERIC); assert( r >= 0 );
    r = engine->RegisterObjectMethod("Dictionary", "bool get(const String &in, int64&out) const", asFUNCTION(ScriptDictionaryGetInt_Generic), asCALL_GENERIC); assert( r >= 0 );

    r = engine->RegisterObjectMethod("Dictionary", "void set(const String &in, double&in)", asFUNCTION(ScriptDictionarySetFlt_Generic), asCALL_GENERIC); assert( r >= 0 );
    r = engine->RegisterObjectMethod("Dictionary", "bool get(const String &in, double&out) const", asFUNCTION(ScriptDictionaryGetFlt_Generic), asCALL_GENERIC); assert( r >= 0 );

 

AS code:

String browserTableName = ''; // persistent for document's lifetime
...
// get the 'servers' query string parameter value
const Dictionary @dict = body.ownerDocument.URL.getParameters();
dict.get( 'servers', browserTableName );

 

browserTableName is a global var and instead of proper values it gets assigned bizarre values such as '1.12398e-315'. Debugging the code actually reveals that AS hits the following codepath in CScriptDictionary::Get(const asstring_t &key, void *value, int typeId) const:

           // We know all numbers are stored as either int64 or double, since we register overloaded functions for those
            if( it->second.typeId == asTYPEID_INT64 && typeId == asTYPEID_DOUBLE )
            {
                *(double*)value = double(it->second.valueInt);
                return true;
            }

 

I haven't managed to prove my suspicion correct since I'm about to hit the bed but something tells me I'm on the right track here..


Current trunk doesn't compile with mingw

25 January 2014 - 11:32 AM

Here's extract from compilation log:

 


../../source/as_thread.cpp: In constructor ‘asCThreadCriticalSection::asCThreadCriticalSection()’:

../../source/as_thread.cpp:332:42: error: ‘InitializeCriticalSectionEx’ was not declared in this scope InitializeCriticalSectionEx(&cs, 4000, 0);

 

../../source/as_thread.cpp: In constructor ‘asCThreadReadWriteLock::asCThreadReadWriteLock()’:

../../source/as_thread.cpp:382:70: error: ‘CreateSemaphoreExW’ was not declared in this scope readLocks = CreateSemaphoreExW(NULL, maxReaders, maxReaders, 0, 0, 0);

 

../../source/as_thread.cpp:384:49: error: ‘InitializeCriticalSectionEx’ was not declared in this scope InitializeCriticalSectionEx(&writeLock, 4000, 0);


Factory for const string

16 December 2013 - 05:27 AM

Hello Andreas,

 

is it possible to register factory for a constant string handle? The reason I'm asking is that would allow to reduce the number of allocations in the app by storing the string struct and the string buffer in the same memory region, knowing that the string is immutable.


PARTNERS