• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

zerochen

Members
  • Content count

    12
  • Joined

  • Last visited

Community Reputation

542 Good

About zerochen

  • Rank
    Member
  1. hi, i also would love to see a getter for the scripthandle addon, so that i can access the internal pointer and can do stuff with it. thanks in advance
  2. Hi,   what are the next big features / addons / updates that you will add?
  3. hi, i finally found the problem. the problem was that i register the default constructor for the vector and the matrix with the same functionname in different source files. so the defaullt constructor of the maxtrix overrides the vectors default constructor because they have the same structure & name. thanks anyway
  4. hi, i use visual studio 2012, the lastest angelscript rev and win 7 64bit. i also noticed that this only happens with the default constructor (no arguments are passed). for other methods and behaviours it works.
  5. hi, i have a problem with the constructor and templates. if i register my vector class with constructorDefault<T> it doesnt work because the constructorDefault function is never been called. only then i use the constructorDefaultf function it works. is there something i missed? C++: [CODE]template<typename T> void constructorDefault(void *memory) // this isnt called { new (memory) core::vector3d<T>(); } void constructorDefaultf(void *memory) // works fine { new (memory) core::vector3d<float>(); } template<typename T> void deconstructor(void *memory) { ((core::vector3d<T>*)memory)->~vector3d<T>(); } // called like that -> registerVector3dT<float>(engine, "vector3df", "float"); template<typename T> void registerVector3dT(asIScriptEngine *engine, const char *typeName, const char *asType) { int r; std::stringstream ss; // Bind Vector2d<T> class. r = engine->RegisterObjectType(typeName, sizeof(core::vector3d<T>), asOBJ_VALUE | asOBJ_APP_CLASS_CDA); assert(r >= 0); //this doesnt work r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_CONSTRUCT, "void f()", asFUNCTIONPR(constructorDefault<T>, (void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0); // this works //r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_CONSTRUCT, "void f()", asFUNCTIONPR(constructorDefaultf, (void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0); r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_DESTRUCT, "void f()", asFUNCTIONPR(deconstructor<T>, (void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0); // Assignment vector3d<T>& operator=(const vector3d<T>& other) ss.str(""); ss << typeName << "& opAssign(const " << typeName << " &in)"; r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), asMETHODPR(core::vector3d<T>, operator=, (const core::vector3d<T>&), core::vector3d<T>&), asCALL_THISCALL); assert(r >= 0); // Bind core::vector3d<T> class properties. ss.str(""); ss << asType << " X"; r = engine->RegisterObjectProperty(typeName, ss.str().c_str(), offsetof(core::vector3d<T>, X)); assert(r >= 0); ss.str(""); ss << asType << " Y"; r = engine->RegisterObjectProperty(typeName, ss.str().c_str(), offsetof(core::vector3d<T>, Y)); assert(r >= 0); ss.str(""); ss << asType << " Z"; r = engine->RegisterObjectProperty(typeName, ss.str().c_str(), offsetof(core::vector3d<T>, Z)); assert(r >= 0); } [/CODE] Angelscript: [CODE] class d { void dummy() { vector3df ss(); vector3df sss(); sss = ss; } } [/CODE] in that line it crashed: void asCScriptEngine::CallObjectMethod(void *obj, asSSystemFunctionInterface *i, asCScriptFunction *s) line 3394: (((asCSimpleDummy*)obj)->*f)(); callstack: game.exe![thunk]:asCScriptObject::`vcall'{4,{flat}}' }'() C++ game.exe!asCScriptEngine::CallObjectMethod(void * obj, asSSystemFunctionInterface * i, asCScriptFunction * s) Zeile 3413 C++ game.exe!asCScriptEngine::CallObjectMethod(void * obj, int func) Zeile 3367 C++ game.exe!asCContext::ExecuteNext() Zeile 2503 C++ game.exe!asCContext::Execute() Zeile 1155 C++ i guess it crashs there because the constructor isnt called. any help would be appreciated thx
  6. Hi, this code leads to a wrong error msg. [CODE] void dum() {} int dummy() { return 0; dum(); //return 1; } [/CODE] output: player.as (35, 2) : INFO : Compiling int CPlayer::dummy() player.as (38, 3) : WARN : Unreachable code player.as (36, 2) : ERR : Not all paths return a value If you uncomment the last line it works. it works also with an int a; instead of a func call
  7. hi, i wrote a patch for this some time ago [CODE] Index: include/angelscript.h =================================================================== --- include/angelscript.h (Revision 1359) +++ include/angelscript.h (Arbeitskopie) @@ -520,6 +520,7 @@ virtual asIJITCompiler *GetJITCompiler() const = 0; // Global functions + virtual int RegisterGlobalFunction(const char* declaration, const asSFuncPtr &funcPointer, void* obj, asDWORD callConv) = 0; virtual int RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv) = 0; virtual asUINT GetGlobalFunctionCount() const = 0; #ifdef AS_DEPRECATED Index: source/as_callfunc.cpp =================================================================== --- source/as_callfunc.cpp (Revision 1359) +++ source/as_callfunc.cpp (Arbeitskopie) @@ -409,12 +409,8 @@ if( callConv >= ICC_THISCALL ) { - if( objectPointer ) + if(!((obj = objectPointer) || (obj = descr->GetUserData()))) { - obj = objectPointer; - } - else - { // The object pointer should be popped from the context stack popSize += AS_PTR_SIZE; Index: source/as_scriptengine.cpp =================================================================== --- source/as_scriptengine.cpp (Revision 1359) +++ source/as_scriptengine.cpp (Arbeitskopie) @@ -2458,6 +2458,83 @@ } // interface +int asCScriptEngine::RegisterGlobalFunction(const char* declaration, const asSFuncPtr &funcPointer, void* obj, asDWORD callConv) +{ + asSSystemFunctionInterface internal; + + int r = DetectCallingConvention(true, funcPointer, callConv, &internal); + if( r < 0 ) + return ConfigError(r, "RegisterGlobalFunction", declaration, 0); + + if( callConv != asCALL_THISCALL) + return ConfigError(asNOT_SUPPORTED, "RegisterGlobalFunction", declaration, 0); + + isPrepared = false; + + // Put the system function in the list of system functions + asSSystemFunctionInterface *newInterface = asNEW(asSSystemFunctionInterface)(internal); + + if( newInterface == 0 ) + return ConfigError(asOUT_OF_MEMORY, "RegisterGlobalFunction", declaration, 0); + + asCScriptFunction *func = asNEW(asCScriptFunction)(this, 0, asFUNC_SYSTEM); + + if( func == 0 ) + { + asDELETE(newInterface, asSSystemFunctionInterface); + return ConfigError(asOUT_OF_MEMORY, "RegisterGlobalFunction", declaration, 0); + } + + func->sysFuncIntf = newInterface; + func->SetUserData(obj); + + asCBuilder bld(this, 0); + r = bld.ParseFunctionDeclaration(0, declaration, func, true, &newInterface->paramAutoHandles, &newInterface->returnAutoHandle, defaultNamespace); + if( r < 0 ) + { + // Set as dummy function before deleting + func->funcType = asFUNC_DUMMY; + asDELETE(func,asCScriptFunction); + return ConfigError(asINVALID_DECLARATION, "RegisterGlobalFunction", declaration, 0); + } + + // TODO: namespace: What if the declaration defined an explicit namespace? + func->nameSpace = defaultNamespace; + + // Check name conflicts + r = bld.CheckNameConflict(func->name.AddressOf(), 0, 0, defaultNamespace); + if( r < 0 ) + { + asDELETE(func,asCScriptFunction); + return ConfigError(asNAME_TAKEN, "RegisterGlobalFunction", declaration, 0); + } + + func->id = GetNextScriptFunctionId(); + SetScriptFunction(func); + + currentGroup->scriptFunctions.PushLast(func); + func->accessMask = defaultAccessMask; + registeredGlobalFuncs.PushLast(func); + + // If parameter type from other groups are used, add references + if( func->returnType.GetObjectType() ) + { + asCConfigGroup *group = FindConfigGroupForObjectType(func->returnType.GetObjectType()); + currentGroup->RefConfigGroup(group); + } + for( asUINT n = 0; n < func->parameterTypes.GetLength(); n++ ) + { + if( func->parameterTypes[n].GetObjectType() ) + { + asCConfigGroup *group = FindConfigGroupForObjectType(func->parameterTypes[n].GetObjectType()); + currentGroup->RefConfigGroup(group); + } + } + + // Return the function id as success + return func->id; +} + int asCScriptEngine::RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv) { asSSystemFunctionInterface internal; Index: source/as_scriptengine.h =================================================================== --- source/as_scriptengine.h (Revision 1359) +++ source/as_scriptengine.h (Arbeitskopie) @@ -100,6 +100,7 @@ virtual asIJITCompiler *GetJITCompiler() const; // Global functions + virtual int RegisterGlobalFunction(const char* declaration, const asSFuncPtr &funcPointer, void* obj, asDWORD callConv); virtual int RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv); virtual asUINT GetGlobalFunctionCount() const; #ifdef AS_DEPRECATED [/CODE] example usage: engine->RegisterGlobalFunction("void Println(const string& in)", asMETHODPR(CScriptFunction, println, (const std::string&), void), this /*pointer to obj of CScriptFunction*/, asCALL_THISCALL);
  8. ok thx that solved the problem. i thought it was because the createScriptObject func returns sometimes an obj with ref count 2
  9. [CODE] // this function is called from angelscript CScriptHandle CScriptFunction::createObject(const std::string& name, const core::vector3df& pos) { int id = builder.GetModule()->GetTypeIdByDecl(name.c_str()); if(id == asINVALID_TYPE) { //error msg return CScriptHandle(); } asIScriptObject* s = reinterpret_cast<asIScriptObject*>(engine->CreateScriptObject(id)); //here the ref count is sometimes 2 if(!scriptObj) return CScriptHandle(); // set pos // add it to an objArray return CScriptHandle(scriptObj, scriptObj->GetObjectType()); } [/CODE] [quote]// The CScriptHandle increased the ref count when it // stored the handle internally so we need to release one[/quote] yes but if the CScriptHandle will be destroyed the ref counter will dec but the problem is direct after the engine createObject function so i think it is a angelscript problem i will write a little example that reproduce the problem but now i have no time sry
  10. with angelscript in c++ yes [CODE] CScriptHandle CScriptFunction::createObject(const std::string& name, const core::vector3df& pos) r = script->getEngine()->RegisterGlobalFunction("ref@ CreateObject(const string& in, const vector3df& in)", asMETHODPR(CScriptFunction, createObject, (const std::string&, const core::vector3df&), CScriptHandle), this, asCALL_THISCALL); assert( r >= 0 ); [/CODE] i wrote a patch for angelscript that allows me to register a global script function as a method of a class. maybe thats the problem but i use it for weeks without any problems. i think it is the nested context here is the patch file. [CODE] Index: include/angelscript.h =================================================================== --- include/angelscript.h (Revision 1359) +++ include/angelscript.h (Arbeitskopie) @@ -520,6 +520,7 @@ virtual asIJITCompiler *GetJITCompiler() const = 0; // Global functions + virtual int RegisterGlobalFunction(const char* declaration, const asSFuncPtr &funcPointer, void* obj, asDWORD callConv) = 0; virtual int RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv) = 0; virtual asUINT GetGlobalFunctionCount() const = 0; #ifdef AS_DEPRECATED Index: source/as_callfunc.cpp =================================================================== --- source/as_callfunc.cpp (Revision 1359) +++ source/as_callfunc.cpp (Arbeitskopie) @@ -409,12 +409,8 @@ if( callConv >= ICC_THISCALL ) { - if( objectPointer ) + if(!((obj = objectPointer) || (obj = descr->GetUserData()))) { - obj = objectPointer; - } - else - { // The object pointer should be popped from the context stack popSize += AS_PTR_SIZE; Index: source/as_scriptengine.cpp =================================================================== --- source/as_scriptengine.cpp (Revision 1359) +++ source/as_scriptengine.cpp (Arbeitskopie) @@ -2458,6 +2458,83 @@ } // interface +int asCScriptEngine::RegisterGlobalFunction(const char* declaration, const asSFuncPtr &funcPointer, void* obj, asDWORD callConv) +{ + asSSystemFunctionInterface internal; + + int r = DetectCallingConvention(true, funcPointer, callConv, &internal); + if( r < 0 ) + return ConfigError(r, "RegisterGlobalFunction", declaration, 0); + + if( callConv != asCALL_THISCALL) + return ConfigError(asNOT_SUPPORTED, "RegisterGlobalFunction", declaration, 0); + + isPrepared = false; + + // Put the system function in the list of system functions + asSSystemFunctionInterface *newInterface = asNEW(asSSystemFunctionInterface)(internal); + + if( newInterface == 0 ) + return ConfigError(asOUT_OF_MEMORY, "RegisterGlobalFunction", declaration, 0); + + asCScriptFunction *func = asNEW(asCScriptFunction)(this, 0, asFUNC_SYSTEM); + + if( func == 0 ) + { + asDELETE(newInterface, asSSystemFunctionInterface); + return ConfigError(asOUT_OF_MEMORY, "RegisterGlobalFunction", declaration, 0); + } + + func->sysFuncIntf = newInterface; + func->SetUserData(obj); + + asCBuilder bld(this, 0); + r = bld.ParseFunctionDeclaration(0, declaration, func, true, &newInterface->paramAutoHandles, &newInterface->returnAutoHandle, defaultNamespace); + if( r < 0 ) + { + // Set as dummy function before deleting + func->funcType = asFUNC_DUMMY; + asDELETE(func,asCScriptFunction); + return ConfigError(asINVALID_DECLARATION, "RegisterGlobalFunction", declaration, 0); + } + + // TODO: namespace: What if the declaration defined an explicit namespace? + func->nameSpace = defaultNamespace; + + // Check name conflicts + r = bld.CheckNameConflict(func->name.AddressOf(), 0, 0, defaultNamespace); + if( r < 0 ) + { + asDELETE(func,asCScriptFunction); + return ConfigError(asNAME_TAKEN, "RegisterGlobalFunction", declaration, 0); + } + + func->id = GetNextScriptFunctionId(); + SetScriptFunction(func); + + currentGroup->scriptFunctions.PushLast(func); + func->accessMask = defaultAccessMask; + registeredGlobalFuncs.PushLast(func); + + // If parameter type from other groups are used, add references + if( func->returnType.GetObjectType() ) + { + asCConfigGroup *group = FindConfigGroupForObjectType(func->returnType.GetObjectType()); + currentGroup->RefConfigGroup(group); + } + for( asUINT n = 0; n < func->parameterTypes.GetLength(); n++ ) + { + if( func->parameterTypes[n].GetObjectType() ) + { + asCConfigGroup *group = FindConfigGroupForObjectType(func->parameterTypes[n].GetObjectType()); + currentGroup->RefConfigGroup(group); + } + } + + // Return the function id as success + return func->id; +} + int asCScriptEngine::RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv) { asSSystemFunctionInterface internal; Index: source/as_scriptengine.h =================================================================== --- source/as_scriptengine.h (Revision 1359) +++ source/as_scriptengine.h (Arbeitskopie) @@ -100,6 +100,7 @@ virtual asIJITCompiler *GetJITCompiler() const; // Global functions + virtual int RegisterGlobalFunction(const char* declaration, const asSFuncPtr &funcPointer, void* obj, asDWORD callConv); virtual int RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv); virtual asUINT GetGlobalFunctionCount() const; #ifdef AS_DEPRECATED [/CODE] i just copied the RegisterGlobalFunction, added the void* obj pointer to the function and set it after func->sysFuncIntf = newInterface; + func->SetUserData(obj); ah i use the lastest angelscript svn version of couse
  11. hi, i have following base structure Script: [CODE] class A { }; class B { void init() { create("A"); }; }; [/CODE] pseudo c++: [CODE] asIScriptObject* create(string s) { int id = getClassId(s); return reinterpret_cast<asIScriptObject*>(engine->CreateScriptObject(id)); } [/CODE] so now to my problem. i create class B and than i call the function init() from B that creates a new object from A something like this: pseudo call stack: [CODE] objB = create("B") objB.callMethod("init") that calls objA = create("A") [/CODE] after that the ref count of objB is 1 (as expected) the ref count of objA is 2 (have to be 1) have i an error in my logic? i tracked this down to: as_scriptobject.cpp line 122 that line doesnt dec the ref counter of objA but it does it for objB. is that because to call a script function there has to be an active context? is this a bug or have i call the release func myself? thx for help zerochen
  12. hi, i think i found a bug with a switch and return statements asscript: [source lang="cpp"] bool onEvent() { switch(1) { case 1: return true; default: return false; } }[/source] error: objects/Controller.as (54, 2) : INFO : Compiling bool Controller::onEvent() objects/Controller.as (55, 2) : ERR : Not all paths return a value but that isnt true. maybe return statements are not supported in switch cases. if so this is a feature request:) thx