• 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.

Quittouff

Members
  • Content count

    28
  • Joined

  • Last visited

Community Reputation

118 Neutral

About Quittouff

  • Rank
    Member

Personal Information

  • Location
    France
  1. The only modifications I made is being able to point a method address: I added a "IsSignatureExceptNameAndObjectEqual" that is the same as "IsSignatureExceptNameEqual" and does not care about the object type, so a funcdef is not dependent on the object type but only on the method signature. It may not be ideal but it was the fastest way for me to do what I wanted. And actually yes, this method provide a compile time verification of the callback signature, if you implement a callback with the wrong signature, it will not compile at the "SetCallback" as the second argument is a pointer to a funcdef. It would produce this kind of error: (example taken for my script sorry if names are not very relevant) [CODE]Compiling BPE MainMenuForm.bhass (3, 5): INFO: Compiling CMainMenuForm::CMainMenuForm() MainMenuForm.bhass (6, 27): ERROR: No matching signatures to 'CButtonEventHandler::SetCallback(CMainMenuForm&, OnChallengesClick@const)' MainMenuForm.bhass (6, 27): INFO: Candidates are: MainMenuForm.bhass (6, 27): INFO: void CButtonEventHandler::SetCallback(IEventHandler@, ButtonEvent@)[/CODE] (just added an int parameter to the callback method) So even if the error is not very clear with current implementation, it is triggered when the callback signature is incorrect at compile time. I didn't think of the CScriptHandle that would have been cleaner indeed. But now the product has been released so it may be for the next one .
  2. I made some delegates system in C++ that I exposed to Angel script in my project with minor modifications of a v2.22.0 WIP of AS (in order to be able to specify a method adress). This delegate system works with events and subscribers, only subscribers has been exposed to my angelscript (ie AS can catch some Engine event but not raise some event). To expose briefly how it's used: I register a funcdef in the ASEngine which will be my signature (for instance void MouseMoveEvent(CMouse@, const CVec2f&in)) Then I expose to the script an "event subscriber" (for instance: CMouseMoveEventHandler) that declares a method "SetCallback" which takes in our exemple (IEventHandler@, MouseMoveEvent@). IEventHandler is an empty interface that I declared so AS classes can register and catch events simply by inherit from it (there may be better solutions, and maybe there already is a hidden common parent class to all script classes) After that all Game Engine that have events expose a RegisterToEventxxx and a UnregisterFromEventxxx (in our exemple RegisterToEventMouseMove(CMouseEventHandler@+) / UnregisterFromEventMouseMove(CMouseEventHandler@+) Then the class script declares an EventHandler, implements the "callback" method and all is done (this is pseudo code and may contain syntax errors) [CODE] class CScriptCatcher : IEventHandler { CScriptCatcher() { m_MouseMoved.SetCallback(this, @OnMouseMove); GetGame().RegisterToEventMouseMove(m_MouseMoved); } ~CScriptCatcher() { GetGame().UnregisterFromEventMouseMove(m_MouseMoved); } private void OnMouseMove(CMouse@ _pMouse, const CVec2f& _vDelta) { //Do some stuff here to hande mouse move } private CMouseMoveEventHandler m_MouseMoved; } [/CODE] There certainly a better way and a better interface to use the idea to be a little more lightweight for the user, but it might help you to have an idea on how things could be done. For the delegate implementation in C++, it's an event class that holds a list of generics subscribers using templates (because the system is primarily used with C++). Subscribers are only a "this" pointer and method pointer OR a function pointer so delegates can be either method members with a this or a static method / a function. Hope this might help ;)
  3. Ok, it seems that I finally found a solution. Adding a custom Build setting "USE_HEADERMAP" set to NO stopped the confusion between headers. It seems that xCode uses a "magic recipe" to found your headers (the heade map), and this command disables it. Magic recipes are always baaaad
  4. Hi everyone, We bought an iMac to port our game from PC to mac, and I'm a true beginner with xCode. Our (in-house) engine and game are fully in C++ and I'm currently trying to make the projects under xCode. But I'm not very far in the process as I spent my entire first day with a header path problem... Note: I'm using xCode 4.4 under OS X 10.8.1 (Mountain Lion) So the problem is that the compiler seems to mess up header paths. Here is the deal: I have my xproject in Sources/MakeFiles/xCode/Base/base.xproject I have all my project sources (headers and cpp) in Sources/Base/ Now I added all the files to the project, no problem, but it couldn't find the headers, so I go to the options, add ../../../ to "Header Search path" (so the root of the include directory is "Sources"), I don't check the recursive option, it now finds my headers. But when I include <string> which includes <string.h>(via some nested headers like cstring), the compiler go for a file located in Sources/Base/String/String.h. But I haven't checked the "recursive" checkbox! So I know I could rename my headers or change every includes to use "" instead of <>. But it's a fairly big project (2500+ files) and I really don't want to mess all up for something which looks like a bug on xCode part, or silly misuse on mine. I tried a lot of things, including copying all system headers in a custom dir and adding this dir first in "Header Search path", it always includes my Base/String/String.h instead of <string.h> Am I missing something? I feel so dumb! I spent nearly 12 hours on this, googling, trying tons of insane stuff, I'm in a dead end, please help!
  5. Okay, I'm just dumb, but the solution may help others in the future: By looking to the byte code, I realized that the return of GetString is copied and stored in a temp local variable. My String class was declared as POD with no copy constructor so the string was copied "as is". Removing the POD flag and adding a CopyConstructor did the trick and solved my problem as the copy is now correct.
  6. Hi, I got a very odd thing going on with my strings when I use const references in the script. I exposed these methods: const CString& GetString(const CString&in); void SetText(const CString&in); then in the script i do something like: SetText(GetString("foo")); All is right until the destructor is called on the string returned by GetString and it destroys the original string. I can't understand why it would call the destructor when I only use references. The thing is, I use an 'old' version of AngelScript (v2.22.0 WIP changelist 1010). If this issue is corrected after my version, tell me. I didn't change to newer version because I'd like to have a "final" version as my shipping date approach.
  7. [quote name='Andreas Jonsson' timestamp='1318440079' post='4871918'] Thanks for this report. While the root cause was the lack of the GC behaviours, I've made some changes to make the library more robust in this scenario. Instead of crashing due to attempting to call a method that no longer exists, the engine will report an error message to the message stream and then simply skip the destruction the objects that couldn't be destroyed due to circular references with application objects. This will cause a memory leak, but at least it won't crash the application. [/quote] I just got the branch on SVN, this change is very usefull and save me a lot of time to see what classes causes some troubles and see if the game is still holding some references when it shouldn't! Thanks!
  8. Sorry I answer so late but I have a sh*load of work and I come back to AS by cycles. So, no I didn't try Unsafe references because I already have a hard time using AS correctly with secured references and I can't afford adding another hazard in my code for now. I still have troubles with references and refcounting. It's always the same class that causes me headaches, it's one of the nerves of my communication between my engine and scripts and every time I think I resolved my problems (thanks to you guys) couple days/weeks later, something else come bite me in the @... When I'll have some more stability, I'll try unsafe Ref and keep you posted though Thanks.
  9. Ok so it seems it's the same issue that I found some months ago. I'm not sure about using unsafe reference as I don't really understand what it implies. I think I'll use some work around for now.
  10. Adding gc behaviors to CFoo solved the problem on the example, and I integrated the solution in my actual classes with the same success. Doing so I found an issue in the doc: EnumReferences and ReleaseAllReferences are with no parameter in the examples but they really take an asIScriptEngine* (which is much better as the object don't have to know directly the script engine), so I had some ESP errors at first . Thanks behc for your precious help.
  11. [quote name='behc' timestamp='1318075330' post='4870465'] Hi, my guess is that calling CFoo::SetScriptObject makes circular references that AS is unaware of (and crash happens because AS releases objects in some 'random' order without proper cleanup first). Try implementing garbage collector behaviors for CFoo (as documented in Manual->Using AngelScript->Registering the app.. ->Advanced app... ->Garbage collected objects). [/quote] Ho ok. So commenting the member in the base class would mess this random order and make it work properly, it makes sense. I'll try to implement the Garbage collected interface to see if it works better. Thanks. [quote name='behc' timestamp='1318075330' post='4870465'] On the other note, [font="Consolas,"]m_pObject [/font]is never released when set with CFoo::SetScriptObject. AS will AddRef any handles passed as parameters, but will not release them (until you register function with @+ autohandles), this is expected behavior for CFoo::SetScriptObject because you keep the reference but still [font="Consolas,"]m_pObject[/font] needs to be released somewhere. [/quote] That's my bad, i forgot the destructor CFoo in my example making the release on the m_pObject.
  12. Hi again, I have some crash in angelscript when I close my program. It seems that the garbage collector is doing something odd: deleting all functions table on every types and then ask for the GetRefCount (set to 0) on one of the types, but only under some specific circumstances. I spent hours trying to find out what is going on and narrowing it down to a very simple example so I could have a basic example that should allow you to reproduce the issue: C++ code: [source lang="cpp"] class CFoo { public: CFoo() : m_Ref(1) { } void SetScriptObject(AngelScript::asIScriptObject* _pObject) { m_pObject = _pObject; } void AddRef() { m_Ref++; } void Release() { if( --m_Ref == 0 ) { delete this; } } static CFoo* CreateObject() { return new CFoo; } private: AngelScript::asIScriptObject* m_pObject; uint32 m_Ref; }; class CDummy { public: CDummy() {} void AddRef() {} void Release() {} private: uint32 m_DummyMember; }; pEngine->RegisterInterface("IMyInterface"); pEngine->RegisterObjectType("CFoo", sizeof(CFoo), AngelScript::asOBJ_REF); pEngine->RegisterObjectBehaviour("CFoo", AngelScript::asBEHAVE_ADDREF, "void f()", AngelScript::asMETHOD(CFoo, AddRef), AngelScript::asCALL_THISCALL); pEngine->RegisterObjectBehaviour("CFoo", AngelScript::asBEHAVE_RELEASE, "void f()", AngelScript::asMETHOD(CFoo, Release), AngelScript::asCALL_THISCALL); pEngine->RegisterObjectBehaviour("CFoo", AngelScript::asBEHAVE_FACTORY, "CFoo@ f()", AngelScript::asFUNCTION(&CFoo::CreateObject), AngelScript::asCALL_CDECL); pEngine->RegisterObjectMethod("CFoo", "void SetObject(IMyInterface@)", AngelScript::asMETHOD(CFoo, SetScriptObject), AngelScript::asCALL_THISCALL); pEngine->RegisterObjectType("CDummy", sizeof(CDummy), AngelScript::asOBJ_REF); pEngine->RegisterObjectBehaviour("CDummy", AngelScript::asBEHAVE_ADDREF, "void f()", AngelScript::asMETHOD(CFoo, AddRef), AngelScript::asCALL_THISCALL); pEngine->RegisterObjectBehaviour("CDummy", AngelScript::asBEHAVE_RELEASE, "void f()", AngelScript::asMETHOD(CFoo, Release), AngelScript::asCALL_THISCALL);[/source] Script code [source lang="cpp"] CBar test; class CBase : IMyInterface { CDummy@ m_dummy; //Comment only this and everything is ok } class CBar : CBase { CBar() { m_foo.SetObject(this); //Comment only this and everything is ok } CFoo m_foo; }; [/source] Note: I'm still at the version 2.21.0 as I didn't see that it may be corrected in next versions
  13. Hi, I'm little confused as it seems that using only references still requires a copy operator. Here is the configuration: I declare a MyObject type with flags asOBJ_POD |asOBJ_VALUE | asOBJ_APP_CLASS_CD then 2 functions with the signatures "const MyObject& GetMyObject()const" and "void SetMyObject(const MyObject&in)" and when i do: SetMyObject(GetMyObject()); in the script I get the "ERROR: There is no copy operator for this type available." why would I need a copy operator exposed to angelscript when all I use is some const refs? Is there anything I can do to work around this without adding some copy operator?
  14. I tested your code on Visual 2008, and I crash directly after where AddRef should be called. Actually it's ExtraTesting that is called instead of AddRef. It still seems a lot like pointer arithmetic issues to me. I tried to trace in AngelScript, there is a loooot of manipulation on methods pointers to finally end up to the call in CallObjectMethod. In there the code is different for MSVC and GCC(?) compilers. The last one seems to do some specific tricks to reach the right method via the vtable, but on MSVC it doesn't. My guess is that there is something wrong in here but tbh I have no clue how it could be solved. Hope the search I did will benefit anyway.
  15. RTM: http://www.angelcode.com/angelscript/sdk/docs/manual/doc_use_script_class.html