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

Heuristics

Members
  • Content count

    18
  • Joined

  • Last visited

Community Reputation

147 Neutral

About Heuristics

  • Rank
    Member
  1. I tried the latest svn version via sourceforge tarball download of trunk, same problem.    As usual I caution that I may not be registering things properly and this might just be my fault (though i did try my best to do things correctly).
  2. I am using the latest version: 2.26.1. (I am the dude that first brought up the issue with mingw 4.7.1 behaving strangely a few months back).
  3. The following is a short summary of the code that crashes angelscript in 4.7.1 but not in 4.4.1:   struct A { A() {} static void Constructor(A *self) {new(self) A();} static void Destructor(A *memory) {memory->~A();} std::string getText() {return this->text;} std::string text; A getA() {return A();} }; ____Code run in Angelscript____: void main() { A a; string text = a.getA().getText(); }   I have appended a full runnable example below since it might just be that I am registering things in the wrong way (lets hope so). It appears to be the case that running a function that returns text from an object that was created within angelscript causes a crash.   #include <angelscript.h> #include <add_on/scriptstdstring/scriptstdstring.h> #include <add_on/scriptbuilder/scriptbuilder.h> #include <stdio.h> #include <assert.h> #include <iostream> void MessageCallback(const asSMessageInfo *msg, void *param) { const char *type = "ERR "; if( msg->type == asMSGTYPE_WARNING ) type = "WARN"; else if( msg->type == asMSGTYPE_INFORMATION ) type = "INFO"; printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message); } void print(const std::string &in) { std::cout << in << std::endl; } struct A { A() {} static void Constructor(A *self) {new(self) A();} static void Destructor(A *memory) {memory->~A();} std::string getText() {return this->text;} std::string text; A getA() {return A();} }; void registerA(asIScriptEngine *engine) { std::string name = "A"; int r = engine->RegisterObjectType(name.c_str(), sizeof(A), asOBJ_VALUE | asOBJ_APP_CLASS | asOBJ_APP_CLASS_CONSTRUCTOR); assert( r >= 0 ); r = engine->RegisterObjectBehaviour(name.c_str(), asBEHAVE_CONSTRUCT, std::string("void f()").c_str(), asFUNCTION(A::Constructor), asCALL_CDECL_OBJLAST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour(name.c_str(), asBEHAVE_DESTRUCT, "void f()", asFUNCTION(A::Destructor), asCALL_CDECL_OBJLAST); assert( r >= 0 ); r = engine->RegisterObjectMethod("A", "string getText()", asMETHOD(A,getText), asCALL_THISCALL);assert( r >= 0 ); r = engine->RegisterObjectMethod("A", "A getA()", asMETHOD(A,getA), asCALL_THISCALL);assert( r >= 0 ); } std::string app = "void main() {A a;string text = a.getA().getText();}"; int main() { asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); int r = engine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL); assert( r >= 0 ); RegisterStdString(engine); r = engine->RegisterGlobalFunction("void print(const string &in)", asFUNCTION(print), asCALL_CDECL); assert( r >= 0 ); registerA(engine); CScriptBuilder builder; r = builder.StartNewModule(engine, "MyModule"); if( r < 0 ) {printf("Unrecoverable error while starting a new module.\n");return 0;} r = builder.AddSectionFromMemory("TestSection", app.c_str());if( r < 0 ) {printf("Please correct the errors in the script and try again.\n");return 0;} r = builder.BuildModule(); if( r < 0 ) {printf("Please correct the errors in the script and try again.\n");return 0;} asIScriptModule *mod = engine->GetModule("MyModule"); asIScriptFunction *func = mod->GetFunctionByDecl("void main()"); if( func == 0 ) {printf("The script must have the function 'void main()'. Please add it and try again.\n");return 0;} asIScriptContext *ctx = engine->CreateContext(); ctx->Prepare(func); r = ctx->Execute(); if( r != asEXECUTION_FINISHED and r == asEXECUTION_EXCEPTION) {printf("An exception '%s' occurred. Please correct the code and try again.\n", ctx->GetExceptionString());} }    
  4. Oh, that is worrying. Is it possible for end user like myself know how a value type should be registered? Is there a method end users can use to deduce how it should be done in all cases? 
  5. I have seen something that might be a problem here.   If a class that does not define any constructors contains a member variable that does define them then these traits return that the class with the member variable actually does have these functions (even though it does not).   struct TestA { TestA() {} }; struct TestB { TestA a; }; bool hasConstructor = std::is_default_constructible<TestB>::value && !std::has_trivial_default_constructor<TestB>::value; // hasConstructor == true     I have a feeling that this is something that angelscript would not like during automatic registration.
  6. Ok, I have now dug deep into gccs type_traits and tr1/type_traits files and this looks like it might work after some simple testing (will need to do more testing, will report back later). Only problem with this one appears to be that I cannot find a c++11 has_trivial_copy function, it appears to be unimplemented, but it does exist in the tr1 (pre c++11 file)   #include <type_traits> #include <tr1/type_traits> template<typename T> void automaticallyRegisterObjectTypeAsValue(asIScriptEngine *engine, std::string name) { bool hasConstructor = std::is_default_constructible<T>::value && !std::has_trivial_default_constructor<T>::value; bool hasDestructor = std::is_destructible<T>::value && !std::has_trivial_destructor<T>::value; bool hasAssignmentOperator = std::is_copy_assignable<T>::value && !std::has_trivial_copy_assign<T>::value; bool hasCopyConstructor = std::is_copy_constructible<T>::value && !std::tr1::has_trivial_copy<T>::value; asDWORD flags = asOBJ_VALUE | asOBJ_APP_CLASS; if(hasConstructor) flags = flags | asOBJ_APP_CLASS_CONSTRUCTOR; if(hasDestructor) flags = flags | asOBJ_APP_CLASS_DESTRUCTOR; if(hasAssignmentOperator) flags = flags | asOBJ_APP_CLASS_ASSIGNMENT; if(hasCopyConstructor) flags = flags | asOBJ_APP_CLASS_COPY_CONSTRUCTOR; int r = engine->RegisterObjectType(name.c_str(), sizeof(T), flags ); assert( r >= 0 ); }
  7. Thank you! I now understand that the way I was thinking about the existence of the constructors destructors etc in classes were wrong. I thought there was no change introduced to a struct when compiled simply because you added a default constructor (I thought the compiler did on its own if you didn't define one), that's why I thought it was fine to just use asOBJ_APP_CLASS_CDAK since then all of them would be called.
  8. Just tried it with this compiler (mingw 4.6.2) http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.6.2/32-bit/ Same problem happened (crash+wrong 'this' on last line).   I also tried it with 4.6.2 and angelscript 2.25.2 (I had to make a slight change to the AddSectionFromMemory line due to api change). Same problem happened.   I also did something extra. My old eee 900 laptop did not have any development stuff installed so I wanted to make sure this wasnt due to some random crap I had installed. I installed the latest codeblocks (that includes mingw 4.7.2) and the latest angelscript. The same problem there as well.
  9. I am trying to download a version of mingw 4.6 to check. I'll post the results.
  10. compiler: mingw 4.7.2 os: Windows 7 angelscript: official 2.26.1   I have a problem that I cannot solve, I am hoping that I am just registering something wrong.   The short story of the symptoms: ---------------------- When registering a struct as a value type the value of 'this' changes by a few bytes if a called member function of that struct is returning another registered struct value type, 'this' does not change when returning nothing (void) or when returning float.   This bug goes away if at least 3 int (for example) member variables are added to the registered value struct that is returned, if so then 'this' does not change. ----------------------   Here is a small example that illustrates the problem.   We have 2 structs (Dummy and Test) and we register them in angelscript. 'Test' has a debug printing of 'this' at every function that gets run from it. We then run these lines in angelscript: void main() { Test test; test.noReturnValue(); test.floatReturnValue(); test.getDummy(); }     This run outputs:   Constructor self address: 0x60e7c4 This print from constructor: 0x60e7c4 This print from noReturnValue function: 0x60e7c4 This print from floatReturnValue function: 0x60e7c4 This print from getDummy function: 0x60e7bc The application also crashes at the end of the run.   The last lines shows that 'this' changes slightly due to that function call returning a 'Dummy' value.   Here is an example program that is as small as I could make it that still shows the problem (this is c++11 code).       #include <angelscript.h> #include <add_on/scriptstdstring/scriptstdstring.h> #include <add_on/scriptbuilder/scriptbuilder.h> #include <stdio.h> #include <assert.h> #include <iostream> void MessageCallback(const asSMessageInfo *msg, void *param) { const char *type = "ERR "; if( msg->type == asMSGTYPE_WARNING ) type = "WARN"; else if( msg->type == asMSGTYPE_INFORMATION ) type = "INFO"; printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message); } void print(const std::string &in) { std::cout << in << std::endl; } struct Dummy { static void Constructor(Dummy *self) {new(self) Dummy();} static void Destructor(Dummy *memory) {memory->~Dummy();} //int a, b, c; // uncomment this line for it to work again //int a, b; // will not work, requires at least 3 extra vars }; struct Test { Test() { std::cout << "This print from constructor: " << this << std::endl; } static void Constructor(Test *self) {std::cout << "Constructor self address: " << self << std::endl;new(self) Test();} static void Destructor(Test *memory) {memory->~Test();} void noReturnValue() { std::cout << "This print from noReturnValue function: " << this << std::endl; } float floatReturnValue() { std::cout << "This print from floatReturnValue function: " << this << std::endl; return 5.6; } Dummy getDummy() { std::cout << "This print from getDummy function: " << this << std::endl; return Dummy(); } }; template<typename T> void reg(asIScriptEngine *engine, std::string name) { int r = engine->RegisterObjectType(name.c_str(), sizeof(T), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK ); assert( r >= 0 ); r = engine->RegisterObjectBehaviour(name.c_str(), asBEHAVE_CONSTRUCT, std::string("void f()").c_str(), asFUNCTION(T::Constructor), asCALL_CDECL_OBJLAST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour(name.c_str(), asBEHAVE_DESTRUCT, "void f()", asFUNCTION(T::Destructor), asCALL_CDECL_OBJLAST); assert( r >= 0 ); } std::string app = R"(void main() { Test test; test.noReturnValue(); test.floatReturnValue(); test.getDummy(); })"; int main() { asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); int r = engine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL); assert( r >= 0 ); RegisterStdString(engine); r = engine->RegisterGlobalFunction("void print(const string &in)", asFUNCTION(print), asCALL_CDECL); assert( r >= 0 ); reg<Dummy>(engine, "Dummy"); reg<Test>(engine, "Test"); r = engine->RegisterObjectMethod("Test", "Dummy getDummy()", asMETHOD(Test,getDummy), asCALL_THISCALL);assert( r >= 0 ); r = engine->RegisterObjectMethod("Test", "void noReturnValue()", asMETHOD(Test,noReturnValue), asCALL_THISCALL);assert( r >= 0 ); r = engine->RegisterObjectMethod("Test", "float floatReturnValue()", asMETHOD(Test,floatReturnValue), asCALL_THISCALL);assert( r >= 0 ); CScriptBuilder builder; r = builder.StartNewModule(engine, "MyModule"); if( r < 0 ) {printf("Unrecoverable error while starting a new module.\n");return 0;} r = builder.AddSectionFromMemory("TestSection", app.c_str());if( r < 0 ) {printf("Please correct the errors in the script and try again.\n");return 0;} r = builder.BuildModule(); if( r < 0 ) {printf("Please correct the errors in the script and try again.\n");return 0;} asIScriptModule *mod = engine->GetModule("MyModule"); asIScriptFunction *func = mod->GetFunctionByDecl("void main()"); if( func == 0 ) {printf("The script must have the function 'void main()'. Please add it and try again.\n");return 0;} asIScriptContext *ctx = engine->CreateContext(); ctx->Prepare(func); r = ctx->Execute(); if( r != asEXECUTION_FINISHED and r == asEXECUTION_EXCEPTION) {printf("An exception '%s' occurred. Please correct the code and try again.\n", ctx->GetExceptionString());} }      
  11. Ah! That makes sense, I feel a bit silly now (was mislead by it not crashing on 4.6.0). Sorry about that. But thank you very much for your help again!
  12. Hello again. I extended my little test code with using a class as value instead of as reference and then it crashes in mingw 4.7.0 but works fine in 4.6.0. Perhaps this is another problem? (or I might just be doing it wrong ) Here is the modified example: http://pastebin.com/27BzeQcy
  13. Great to hear! I tested it as well with my own code and it does indeed appear to work. Thanks a lot, I very much appreciate the very quick fix to this issue. I now get to use fancy c++11 features with angelscript Strange about the ABI though, but then again I know little about such things. But I do know that it is sometimes hard to understand how the GNU devs pick their priorities.
  14. I think I did something like getting this file: http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/mingw-get-inst-20120426/ and during the installation I picked "download latest repository catalogues". From checking now that appears to download mingw 4.7
  15. [quote name='Andreas Jonsson' timestamp='1349791382' post='4988349'] MinGW 4.7 probably has more changes to the ABI then. Can you run the test_feature project with MinGW 4.7 and tell me which tests pass, and which don't? Especifically the tests focused on the native calling conventions (starting at line 324 in main.cpp). You'll find the code for the project in the SVN. This will help me figure out what needs to be modified to add compatibility for MinGW 4.7. [/quote] I am unable to get that project to compile, I tried the codeblocks, cmake and mingw projects. The mingw one gives: 4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible ./libangelscript.a when searching for -langelscript The codeblocks project is unable to find 3 .o files and the cmake project cannot find the angelscript.h file