Jump to content
  • Advertisement

PhilCK

Member
  • Content Count

    20
  • Joined

  • Last visited

Community Reputation

165 Neutral

About PhilCK

  • Rank
    Member
  1. This is exactly how I do it, regardless of AS. I have an ObserverPtr for all entities which essentially has an isValid() method.
  2. PhilCK

    Runtime error VS 2013

    Ah there we go - I have a C++ method addComponent(string, params); however params has a default value an isn't used on scripting side. So I exposed it "addComponent(const string &in)" only. Sent it to a glue function now and it works fine. Was engine->RegisterObjectMethod("Entity", "bool addComponent(const string &in)",       asMETHODPR(CaffEnt::Entity, addComponent, (const std::string&, const CaffUtil::Param&), bool), asCALL_THISCALL); Now engine->RegisterObjectMethod("Entity", "bool addComponent(const string &in)", asFUNCTION(AddComponent), asCALL_CDECL_OBJLAST); Thanks.
  3. PhilCK

    Runtime error VS 2013

    Now this might not be an AS fault, but I'm running out of options. I've neglected the Windows side of the engine for a few months, and I am trying to update it. Part of that update was switching from compiling AS from source inside the project to linking to the library (built from projects that AS supplies). However when the game runs I get the following error. Run-Time Check Failure #2 - Stack around the variable 'retQW' was corrupted. This happens in as_callfun_x86.cpp line 1189 (CallThisCallFunction). Any ideas? I'm sure this is me being stupid, but after a day of trying to figure this I'm at a loss.   Like I said this might not be down to AS, MSVS isn't my usual environment so I could done something dumb. Edit I should mention that I've compiled it with /MD   Edit - Some Background I define my game components in AS, this app has many components however the crash always with the same component which is not the first component to be initialized. They all run through a common script interface. The crash occus when AS calls one of the hook methods (It doesn't matter which if I comment out the line it will crash on a different hook but same component). This is odd, the component in question appears in almost every game object, this isn't the first GO to be created, another is created before and runs through most of the component hooks before this one is even created. This also all works fine on MacOS.
  4. PhilCK

    Passing Strings inline.

    Ah sorry :) Thanks for looking into it. This is just a convince function I have in C++, it isn't something I really like doing with implicit ctors.
  5. PhilCK

    enums

    Thanks. I only use enum's locally to index array's, no big need here :), although class level could would be useful, again I have no strong need.  
  6. PhilCK

    enums

    Ah right, I had tried in class scope but now see that it needs to be global.    Thanks.
  7. PhilCK

    enums

    I'm sure this is me being silly but I can't make an enum in AS. I get this. AS Error: ShipView (29, 3) Expected expression value AS Error: ShipView (29, 3) Instead found 'enum' For this. void Baz() { enum Foo { BAR }; }  
  8. PhilCK

    Passing Strings inline.

    I have a function that has takes some objects by value. sendEvent(const uint id, EventArg = EventArg(), EventArg = EventArg() .... ); EventArg has constructors for all the available types it can handle, including string. However if I pass a string inline sendEvent(123, "string", 1.234f); // Generates error. No matching signatures to 'EventManager::sendInstantEvent(const uint, const string, const float)' // However this works. string stringVar = "foo"; sendEvent(123, stringVar, floatVar); EventArg is registered as a value type and has ctors for string (I tried both ref and pass by value). I assume this might have something todo with the string addon, its not a big issue but I would like to know why this might be happening. The Registrations .addCtor("void f()", asFUNCTION(EventArgCtor), asCALL_CDECL_OBJLAST) //.addCtor("void f(const string)", asFUNCTION(EventArgString2Ctor),asCALL_CDECL_OBJLAST) .addCtor("void f(const string &in)", asFUNCTION(EventArgStringCtor), asCALL_CDECL_OBJLAST) .addCtor("void f(const float)", asFUNCTION(EventArgFloatCtor), asCALL_CDECL_OBJLAST) .addCtor("void f(const uint)", asFUNCTION(EventArgUInt32Ctor), asCALL_CDECL_OBJLAST) .addCtor("void f(const int)", asFUNCTION(EventArgInt32Ctor), asCALL_CDECL_OBJLAST) .addCtor("void f(const EventArg &in)", asFUNCTION(EventArgCCtor), asCALL_CDECL_OBJLAST) .addDtor("void f()", asFUNCTION(EventArgDtor), asCALL_CDECL_OBJLAST) .addMethod("void sendInstantEvent(const uint, EventArg = EventArg(), EventArg = EventArg(), EventArg = EventArg(), EventArg = EventArg(), EventArg = EventArg(), EventArg = EventArg(), EventArg = EventArg(), EventArg = EventArg())", asMETHODPR(CaffSys::EventManager, sendInstantEvent, (const CaffSys::EventID id, CaffSys::EventArg, CaffSys::EventArg, CaffSys::EventArg, CaffSys::EventArg, CaffSys::EventArg, CaffSys::EventArg, CaffSys::EventArg, CaffSys::EventArg), void), asCALL_THISCALL) Any ideas?   Edit I actually get this with any type that I've added I just tried to add Vec3 which is a value type and I get the same message. Further Edit Hmm I can't remember why I opted for pass by type, but pass by ref (including Vec3/string) yeilds a Bad Access crash in asCContext::ExecuteNext(). I should mention that EventArg is basically (but not) boost::variant. Variant<std::nullptr_t, float, int, uint, Vec3, std::string>
  9. PhilCK

    asGetTypeTraits

    Yes it seems to work :)
  10. PhilCK

    asGetTypeTraits

    Sorry for the dealy I was trying to find the time to check the libc++ and stdlibc++ stuff but haven't found a moment yet. This is what I've got, but I think you'd need to tweak it, as I'm not sure whats the best way to test for libc++ or stdlibc++, currently I'm just falling back on the fact that if all the other CPP11 macro code doesn't pass then treat it as clang with libc++. template<typename T> asUINT asGetTypeTraits() { #if defined(LIBSTDCPP11) || defined(OTHERCPP11) bool hasConstructor =  std::is_default_constructible<T>::value && !std::has_trivial_default_constructor<T>::value; #else bool hasConstructor =  std::is_default_constructible<T>::value && !std::is_trivially_default_constructible<T>::value; #endif #if defined(LIBSTDCPP11) bool hasDestructor = std::is_destructible<T>::value && !std::is_trivially_destructible<T>::value; #elsif defined(LIBCPP11) bool hasDestructor = std::is_destructible<T>::value && !std::is_trivially_destructible<T>::value; #else bool hasDestructor = std::is_destructible<T>::value && !std::has_virtual_destructor<T>::value; #endif #if defined(LIBSTDCPP11) || defined(OTHERCPP11) bool hasAssignmentOperator = std::is_copy_assignable<T>::value && !std::has_trivial_copy_assign<T>::value; bool hasCopyConstructor = std::is_copy_constructible<T>::value && !std::has_trivial_copy_constructor<T>::value; #else bool hasAssignmentOperator = std::is_copy_assignable<T>::value && !std::is_trivially_copy_assignable<T>::value; bool hasCopyConstructor = std::is_copy_constructible<T>::value && !std::is_trivially_copy_constructible<T>::value; #endif bool isFloat = std::is_floating_point<T>::value; bool isPrimitive = std::is_integral<T>::value || std::is_pointer<T>::value || std::is_enum<T>::value; bool isClass = std::is_class<T>::value; bool isArray = std::is_array<T>::value; if( isFloat ) return asOBJ_APP_FLOAT; if( isPrimitive ) return asOBJ_APP_PRIMITIVE; if( isClass ) { asDWORD flags = asOBJ_APP_CLASS; if( hasConstructor ) flags |= asOBJ_APP_CLASS_CONSTRUCTOR; if( hasDestructor ) flags |= asOBJ_APP_CLASS_DESTRUCTOR; if( hasAssignmentOperator ) flags |= asOBJ_APP_CLASS_ASSIGNMENT; if( hasCopyConstructor ) flags |= asOBJ_APP_CLASS_COPY_CONSTRUCTOR; return flags; } if( isArray ) return asOBJ_APP_ARRAY; // Unknown type traits return 0; } I found this http://clang.llvm.org/docs/LanguageExtensions.html#feature_check, which seems to imply that these macros can be used across platforms (Which doesn't really solve the problem as there function names are different anyway.). LIBSTDCPP11 would be __GNUC__  
  11. PhilCK

    asGetTypeTraits

    I upgraded to the latest version of AS, and started to try and use the asGetTypeTraits<T>() but couldn't get it to work. After a little digging AS wasn't recognising my compiler (Xcode/Clang) as C++11, is this intentional because of the <type_traits> being slightly different with the whole is/has stuff? I noticed you had a stackoverflow post in the comments, and that you did a #if defined ... for the destructor trait. Why wasn't this followed through with the other trait functions? Should I avoid using this with Clang for the moment?   Thanks Phil.
  12. PhilCK

    Casting and Inheritance.

    That sounds promising. I have some of that already. class ScriptComponent : public Component; Is the impl inside ASComponent, with asIScriptFunction for the engine callbacks.  Although i'm not sure how ref cast with asBEHAVE_REF_CAST or asBEHAVE_IMPLICIT_REF_CAST works with script types unless I've missed something.
  13. PhilCK

    Casting and Inheritance.

    Whats the best way to get around this.   I have a C++ component class where some C++ implemented components inherit from. class Component; class Transform : public Component; // etc... When it was all just C++ only the application would also create and inherit from this component. However I faked the Component class in AS by doing. class ASComponent {     Component @baseImpl; // C++ component } The issue comes when I wish to retrieve components as ASComponent doesn't inherit from Component. Component@ getComponent(string componentName); I doubt I'm the first to run into this issue.
  14. PhilCK

    Nested Context Calls?

    Thank you.
  15. PhilCK

    Nested Context Calls?

    I have an error that I keep getting when I call Prepare() with error asCONTEXT_ACTIVE (and then Execute() asCONTEXT_NOT_PREPARED). I guess this is because I'm nesting calls into the AS code, is this possible? My application has an event system on the C++ side and I'm trying to route event calls from both C++ and AS through the same event manager, however some events are instant, so a program flow might look like this.   C++ : Game Object Manager will call the components update methods (as scripts). AS : component fires instant event. C++ : Delivers events to all subscribers (both C++ and AS). !!!ERROR!!! AS : Finishes rest of update method. Is this possible? Or do I have to finish the execution of the current AS method? 
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!