• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

153 Neutral

About shabtronic

  • Rank

Personal Information

  1. passing anonymous arrays from Angelscript to C

    Thanks Andreas - I thought it might be something like the vptr - but assumed the lack any inheritance would nuke it :) I will try it later on today - I really hope it works - because having that anonymity saves me a fair bit of typing and fits with my reckless R&D code style :)
  2. Hi There   I'm trying to pass arrays from angelscript to C - and having a few problems   The problems being it doesn't work at all - doesn't fill the vec array - and probably will eventually crash - I can't really tell what is going - because the C code is compiled at run time and my shabby system has no really debugging at the moment.   here's my C code:   typedef struct { int maxElements; int numElements; unsigned char  data[1]; }  SArrayBuffer; typedef struct { int       refCount; _Bool      gcFlag; void*     objType; SArrayBuffer*     buffer; int       elementSize; int       subTypeId; } ASarray; void Init(void) { Debug("TCC init called"); //asRegisterGlobalFunction("float TestFunk(float)",TestFunk); //asRegisterGlobalFunction("vec3 vectest(vec3)",vectest); //asRegisterGlobalFunction("vec3 vecpointer(const vec3 &in)",vecpointer); asRegisterGlobalFunction("void vecfill(vec3[]@,int)",vecfill); } void vecfill(ASarray *a,int l) { vec3* v=(vec3*)a->buffer->data; for (int a=0;a<l;a++) { v[a].x=counter++; v[a].y=counter++; v[a].z=counter++; } }   here's my angelscript code array<vec3> TestArray(50); vecfill(TestArray,2); I am doing it this way because 1) I want to be able to pass arrays anonymously without having to define a specific class or struct 2) I'm using TCC so the C code is compile at runtime - it's actually called from angelscript: ExecuteTCC("./NewDir2/Test.c","Init"); I realise this is probably as dodgy as hell - but it's  not a commercial thing, pure R&D - so I just hope it is possible.     thanks!
  3. the compiler doesn't compile the script

    I had a quick look at the exe - coz I'm so nosey and enjoy mystery .exe's it's a legit PE, I didn't check for any nasties but it's:   "Allegro Game Creator"   uses: OpenAL wxWidgets OpenGL some GCC stuff and a few more     probably doesn't load because it uses a few .dlls   libgcc_s_dw2-1.dll libgcj-13.dll   and it does have that function above in there:   int __thiscall sub_401838(void *this, int a2) {   int v2; // ebx@1   int v3; // ebx@6   int v4; // eax@6   int v5; // ebx@16   void (__thiscall *v6)(_DWORD, _DWORD, _DWORD); // ebx@16   void *v8; // [sp+44h] [bp-16Ch]@1   char v9; // [sp+48h] [bp-168h]@4   char v10; // [sp+100h] [bp-B0h]@4   char v11; // [sp+108h] [bp-A8h]@1   char v12; // [sp+114h] [bp-9Ch]@1   char v13; // [sp+120h] [bp-90h]@1   char v14; // [sp+12Ch] [bp-84h]@1   char v15; // [sp+138h] [bp-78h]@1   char v16; // [sp+144h] [bp-6Ch]@6   char v17; // [sp+150h] [bp-60h]@10   char v18; // [sp+15Ch] [bp-54h]@16   char v19; // [sp+168h] [bp-48h]@16   char v20; // [sp+174h] [bp-3Ch]@16   int v21; // [sp+180h] [bp-30h]@16   int v22; // [sp+184h] [bp-2Ch]@14   int v23; // [sp+188h] [bp-28h]@12   int v24; // [sp+18Ch] [bp-24h]@4   int v25; // [sp+190h] [bp-20h]@1   int v26; // [sp+194h] [bp-1Ch]@1     v8 = this;   sub_90112C(&v11);   sub_901210("Executable Files(*.exe)|*.exe");   sub_9008CC("compile");   sub_9008CC(&unk_9EE184);   sub_9008CC(&unk_9EE184);   sub_9008CC("compilesavedlg");   v2 = sub_98D050(576);   sub_4F5E00(v8, &v12, &v13, &v14, &v11, 6, &dword_C3CB04, &dword_C3CAFC, &v15);   v26 = v2;   sub_9011C0(&v15);   sub_9011C0(&v14);   sub_9011C0(&v13);   sub_9011C0(&v12);   v25 = (*(int (__thiscall **)(int))(*(_DWORD *)v26 + 956))(v26);   if ( v25 == 5101 )     sub_4E3A32(0);   if ( v25 == 5100 )   {     sub_8B2DE8(&v10);     sub_799F20(&v9);     v24 = sub_79ADD0(dword_C37024, "build");     if ( v24 >= 0 )     {       v3 = sub_4FB696(*((_DWORD *)v8 + 122));       sub_4FB5CA(*((_DWORD *)v8 + 122));       v4 = sub_92B2E0(&v16);       v24 = sub_79C5C0("sec", v4, v3);       sub_9011C0(&v16);       if ( v24 >= 0 )       {         v24 = sub_79D9D0(&v9);         if ( v24 >= 0 )         {           (*(void (__thiscall **)(char *, int))(*(_DWORD *)v26 + 1024))(&v17, v26);           v24 = sub_8B2D50(&v17);           sub_9011C0(&v17);           if ( v24 >= 0 )           {             v23 = (*(int (__thiscall **)(int, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 196))(dword_C37024, "build", 0);             if ( v23 )             {               v22 = (*(int (__thiscall **)(int, _DWORD))(*(_DWORD *)v23 + 52))(v23, "void main()");               if ( v22 )               {                 sub_4E3A32(1);                 sub_9008CC("compiling");                 sub_9008CC("please wait while the script is being compiled");                 v5 = sub_98D050(588);                 sub_504D58(&v18, &v19, 100, v8, 6);                 v21 = v5;                 sub_9011C0(&v19);                 sub_9011C0(&v18);                 (*(void (__thiscall **)(int, char *, _DWORD))(*(_DWORD *)v23 + 168))(v23, &v10, 0);                 v6 = *(void (__thiscall **)(_DWORD, _DWORD, _DWORD))(*(_DWORD *)v21 + 1000);                 sub_900B20(off_9E5488);                 v6(v21, &v20, 0);                 sub_9011C0(&v20);               }               else               {                 (*(void (__thiscall **)(int, char[4], _DWORD, _DWORD, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 24))(                   dword_C37024,                   "sec",                   0,                   0,                   0,                   "your script must have Void Main() function");               }             }             else             {               (*(void (__thiscall **)(int, char[4], _DWORD, _DWORD, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 24))(                 dword_C37024,                 "sec",                 0,                 0,                 0,                 "can't load the compile byet code");             }           }           else           {             (*(void (__thiscall **)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 24))(               dword_C37024,               "sec",               0,               0,               0,               "can't Open the given file for compilation!");           }         }         else         {           (*(void (__thiscall **)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 24))(             dword_C37024,             "sec",             0,             0,             0,             "unknown error!");         }       }       else       {         (*(void (__thiscall **)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 24))(           dword_C37024,           "sec",           0,           0,           0,           "can't get the script!");       }     }     else     {       (*(void (__thiscall **)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))(*(_DWORD *)dword_C37024 + 24))(         dword_C37024,         "sec",         0,         0,         0,         "can't start compilation");     }     sub_8B1590(&v9);     sub_8B2E30(&v10);   }   return sub_9011C0(&v11); }
  4. Help BCB 6.00

    Hi Andreas   >>However, BCB6 is more than 10 years old already. Any particular reason why you're still using it?   I know :) - I use BCB 6.00 for my really fast R&D work - the compiler is uber fast and the VCL component architecture is wicked and the portable install size is 30mb - for me it's the fastest way to do disposable native c++ R&D work. Quite tragically I have to totally ditch it soon tho - since the debugger doesn't work in x64 :(    Shabby
  5. Help BCB 6.00

    Update to my problem   Investigating the problem further - it seems it's related to stl stringstream - it gets stuck in some sort of deallocation    so I commented out anything to do with stringstream - which is a lot of the stdstring extension - and I get no hang - yaay!! but I also no fully working string - booo!!   I really don't understand the under the hood stl code - it's all voodoo to me, looks like the stream code is used for int/float to string conversion so I can easily work around it.   I'm guessing that it's a Borland compiler/STL port issue - I actually tested this and is completely a STL port issue (with a standalone exe - no angelscript) - nothing to do with angelscript :)   and easy fix for any other crazy folk using BCB 6 - is to enable    # define _STLP_DEBUG_UNINITIALIZED 1   in STL's STL_USER_CONFIG.h    no more windows hang - yaaay :)
  6. Help BCB 6.00

    Hi Andreas   Yes I tried that eariler, I changed the AS_USE_STRINGPOOL define, no joy tho :(   btw - thx for your awesome work Angelscript, my fav scripting lang by far!       Shabby
  7. Help BCB 6.00

    Hi All I've got a problem with the Latest version of angelscript and borlands BCB 6.00 - I got it to compile (there were a few compile issues - but very easily fixed). It all worked fine - Building angelscript code exectuing e.t.c. - The problem happens when using the STDSTRING extension, using strings in script works fine and it compiles and runs - the problem is that my EXE hangs when exiting back to windows - I've tried to track down the issue - but no joy yet - anybody got any similar issues?   I've tried the following scenarios:   RegisterScriptArray(Angel,true); RegisterStdString(Angel);   Exe hangs when exiting back to window - even if my script code has no string usage   RegisterScriptArray(Angel,true); //RegisterStdString(Angel);   Exe is fine and exits back to windows properly   //RegisterScriptArray(Angel,true); RegisterStdString(Angel);   Exe hangs when exiting back to window - even if my script code has no string usage   I'm thinking it's some kind of STL Issue - but who knows?     here's the call stack from the hang ******************************** 005599F2 _STL::__node_alloc<1, 0>::_M_deallocate 00532B94 _STL::__node_alloc<1, 0>::_M_deallocate 004ABC13 TForm2::~TForm2 004AD53B TForm2::~TForm2 00534D54 _STL::__node_alloc<1, 0>::_M_deallocate 0053409C _STL::__node_alloc<1, 0>::_M_deallocate 00533FFF _STL::__node_alloc<1, 0>::_M_deallocate 005196C3 __init_exit_proc 00519712 __cleanup 005189D4 _exit 005198E8 __startup ******************************* many thanks   Shabby   p.s. anybody else trying to uses BCB 6.00 you have to change any of the macros that have a ; after them, bcb wont compile class with ; and no definitions.   from: protected: DECLARECRITICALSECTION(cs); to: protected: DECLARECRITICALSECTION(cs)   and some of the object pointers have to be explicitly cast before the compile will swallow them (forget which ones - easy fix tho).
  8. noob help with global class functions

    Hey Andreas    Yeah I thought there would be some sort of declaration I was missing, I just couldn't find it in the doc.   Just got my vec2,vec3 and vec4 classes 100% matched to GLSL and my own native classes - let the uber quick prototyping begin :)   Just wanted to say - thanks for all your awesome work on Angelscript - it's like a dream come true - soo soo soo easy to bind to native c++ it's the script system I've been after for ages - but only just found it now :)     Shabby
  9. noob help with global class functions

    Heh - in answer to my own question - and a few posts down   gScriptEngine->SetEngineProperty(asEP_ALLOW_UNSAFE_REFERENCES, true);   allows the ref to work - sweet!
  10. Hi All   I've just discovered angelscript and totally love it - having used lua,squirrel e.t.c. it's just awesome - everything I've need in a script lang - typed fast and easy to convert to native code.   I've currently got a problem with my vec3 class - I'm using global functions instead of member functions so I can directly match GLSL - this is so I can easily convert code from native c++ to GLSL and to script if needed.   I'm trying to register a global func:     r = gScriptEngine->RegisterGlobalFunction("vec3 normalize( vec3 &v1)", asFUNCTION(normalize), asCALL_CDECL);     but I get error -10 and "Failed in call to function 'RegisterGlobalFunction' with 'vec3 normalize( vec3 &v1)' (Code: -10)"   and I just can't figure out the issue, apologies in advance if it's silly problem - I've looked at all the various vector3 classes out there and search the net for answers - but no joy yet :(   thanks   Shabby
  11. Sequencing Code

    Hey That's cool I actually did that on my first pass, a very similar mechanism of just a Func pointer and some timing, my only issue with that is, I have to write multiple callbacks. I'm using frames because it's guaranteed to run at 60fps - else I would be using parametric seconds as the timer. If I was working with a big team - I would engineer it so it's super awesome and all that, My main thing is that I'm designing this game and writing it at the same time, and I'm finding that having to switch from engineer to design whilst I'm coding really kills the creativity, hence I was looking for a super slick way of doing it. It sounds bonkers that - having to write a small function could do that - but that really does happen with me! void BigEyes(u32 FrameTime) { switch (FrameTime) { case 0: TweakMorphFromFile("EyesBig.txt",0.2); break; case 50:TweakMorphFromFile("EyesMassive.txt",0.2);break; case 100:TweakMorphFromFile("EyesNormal.txt",0.2);break; } } void BlinkEyes(u32 FrameTime) { switch (FrameTime) { case 0: TweakMorphFromFile("EyesBlink.txt",0.6); break; case 10:TweakMorphFromFile("EyesNormal.txt",0.4);break; } } void MainLoop() { if (rr<0.01 && rr>=0.005) AddSequence(BlinkEyes,0,11); if (rr<0.005) AddSequencer(BigEyes,0,101); UpdateSequences();}
  12. Sequencing Code

    That sounds interesting, I envisage that to work something like this: (assuming the string pool compare works) void TriggerSys(char* TriggerName,u32 FrameTime) { switch (TriggerName) { case "BigEyes" : { switch (FrameTime) { case 0: MorphToBigEyes(0.1); break case 40: MorphToSmallEyes(0.1); break case 80: MorphToNormalEyes(0.1); break } break; } case "BoomSound": { PlayWav("Boom.wav"); break; } } } void TriggerHandler() {...} MainLoop() { if (thisthing) { AddTrigger("BigEyes",0,81); // Trigger BigEyes in o frames time for 81 frames duration AddTrigger("BoomSound",100,1); // Trigger BoomSound in 100 frames time for 1 frame } TriggerHandler(); } is that what your talking about?
  13. HI I'm trying to come up with a way to sequence code easily and without using a million classes. I want to be able to execute code x frames in the future for y frame duration - something like this: if (HitSomething) { Seq(10,20,PlaySound,"CrashHit.wav"); // Call fun Playsound("CrashHit.wav") in 10 frames time for 20 frames Seq(10,50,StarFlare,10,20,1.5,4); // Call func StarFlare(10,20,1.5,5) in 10 frames time for 50 frames } This is great because it can handle any function, and the code is localised. I can do this - but it's alot of work to get the Variadic stuff working across different platform - requires some hardcore asm to calc the Param stack Size and setup the epilog code e.t.c. wondering if there are any neat tricks to get something similar.
  • Advertisement