Jump to content
  • Advertisement

Rakkar2

Member
  • Content Count

    39
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Rakkar2

  • Rank
    Member
  1. Here's a 4 minute video demoing my new data mining tool for games. http://www.jenkinssoftware.com/echochamber/manual/EchoChamberDemoVideo.html If you'd like to beta test it, you can get it here http://www.jenkinssoftware.com/echochamber/downloads/EchoChamber-Beta1-windows-installer.exe The forum is here: http://www.jenkinssoftware.com/forum The C++ side requires RakNet, which you can get off the front page of http://www.jenkinssoftware.com All beta testers that contribute meaningful feedback in the forum will get a free license once beta is up. Be sure to use a valid email address so I know who you are. It should bring up a registration screen. You can just hit trial and the app will start. Thanks to all those that help!
  2. Script: // ANGELSCRIPT BUG: Must have ==true or it is always true if (this.FirstElapse(2000)==true) C++ bool ScriptThread::FirstElapse(unsigned int time) { if (time==0 && elapsedScriptTime==0) return true; else return elapsedScriptTime >= time && lastScriptTime < time; } C++ Registration result = ScriptManager::engine->RegisterObjectMethod(className, "bool FirstElapse(uint)", asMETHOD(ScriptThread, FirstElapse),asCALL_THISCALL); RakAssert(result>=0);
  3. Rakkar2

    Simple object without AddRef

    I have some non-virtual, shallow-copy safe classes that I cannot change, such as vectors and matrices. I want these to be instantiable objects which are automatically created when they are in-scope and deleted out of scope, without reference counting. I will never reference an object created in script from C++. For example: { // myVec should be created here! Vector3 myVec; myVec.x=0; // myVec should be deleted here! } The problem is, some of my functions return pointers to vectors. Which means I have to use references "@". At first I tried reference counting by adding a refCount via inheritance. But that only works for functions I control. Because when the function returns a pointer to the base class, and not to the derived class, the reference counter doesn't get instantiated. It's not an option to derive/change 200+ functions to return instances of my reference counted class. What I really need is just a reference/pointer to the true class, forget about reference counting. I already tried SetEngineProperty(asEP_ALLOW_UNSAFE_REFERENCES,1) but it won't allow me to make a reference without first registering a function ADD_REF What can I do? [Edited by - Rakkar2 on May 8, 2007 8:13:12 PM]
  4. Rakkar2

    Can't copy a string?

    This one line brings it up: string copiedString(this.getSceneNode().getName()); Says column 22, which is between the g of copiedString and ( Functions are as I pasted earlier.
  5. Rakkar2

    Can't copy a string?

    That fixed the first problem. I still get "Reference is read only" though.
  6. Rakkar2

    Can't copy a string?

    Here it is: static void ConstructString_Generic(asIScriptGeneric *gen) { asCScriptString *thisPointer = (asCScriptString *)gen->GetObject(); ConstructString(thisPointer); } static void ConstructStringCopy_Generic(const asCScriptString &str, asIScriptGeneric *gen) { asCScriptString *thisPointer = (asCScriptString *)gen->GetObject(); ConstructStringCopy(str, thisPointer); } r = engine->RegisterObjectBehaviour("string", asBEHAVE_CONSTRUCT, "void f(const string &in)", asFUNCTION(ConstructStringCopy), asCALL_CDECL_OBJLAST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("string", asBEHAVE_CONSTRUCT, "void f(const string &in)", asFUNCTION(ConstructStringCopy_Generic), asCALL_GENERIC); assert( r >= 0 );
  7. Rakkar2

    Can't copy a string?

    Sorry for this dumb question but after an hour I just can't figure it out. All I want to do is copy one string to another, using scriptstring that comes with AngelScript. I wrote a function that returns a string ScriptManager::engine->RegisterObjectMethod(className, "const string& getName() const", asMETHOD(Node, getName),asCALL_THISCALL); And I want to copy it to another string. (Script) string copiedString(this.getSceneNode().getName()); DebugPrint(1000, copiedString); But I get an error: No matching signatures to 'string(const string)' (and) Reference is read only Ideas?
  8. Rakkar2

    Explicit derefence

    I think this is good: SceneNode @parent = @this.getSceneNode(); Registering it with a size of 0 is fine in my case, but isn't a total solution.
  9. Rakkar2

    Explicit derefence

    Unless I misunderstand things, it seems like a design flaw that both of these expressions are equally valid SceneNode parent = this.getSceneNode(); SceneNode @parent = this.getSceneNode(); The first form improperly creates an instance of scene node, dereferences the pointer, and makes a copy of the object. The second form is correct. In my opinion, this is a design flaw for 4 reasons: 1. This syntax is rarely needed. While technically I may want either of these, 95% of the time if someone calls a function that returns an object pointer, they use that pointer, rather than immediately dereference and copy the pointer. 2. Causes very difficult to find bugs. For example, I have about 10 objects I deal with only through pointers, and never locally instantiate or copy. Doing so just does a shallow copy, and crashes in some weird place later. I can see myself and others constantly forgetting the @ and losing a lot of time debugging this. 3. Unintuitive AngelScript is like C in every way except this. This mistake is practically begging to happen. I made it on my very first script, and it cost me 15 minutes to figure out why it was crashing in std::map, and then only because it was what I was immediately working on. 4. Used constantly Every time I use the pointer, I need to remember @. I use it all over the place. Thus, I'm going to forget @ all over the place. My only solution at this point is to purposely crash, so at least it crashes at the source of the problem, rather than somewhere unrelated later on. void ScriptSceneNode::AddRef() {} void ScriptSceneNode::ReleaseRef() {} void ScriptSceneNodeConstructAssert(void *ptr) { ScriptManager::ScriptLog(std::string("Attempted to create instance of ScriptSceneNode! Use @ reference only.")); // Crash! int *a=0; *a=10; } ... ScriptManager::engine->RegisterObjectType("SceneNode", sizeof(Ogre::SceneNode), asOBJ_CLASS_CD); ScriptManager::engine->RegisterObjectBehaviour("SceneNode", asBEHAVE_ADDREF, "void f()", asMETHOD(ScriptSceneNode, AddRef),asCALL_THISCALL); ScriptManager::engine->RegisterObjectBehaviour("SceneNode", asBEHAVE_RELEASE, "void f()", asMETHOD(ScriptSceneNode, ReleaseRef),asCALL_THISCALL); // You can't construct this class ScriptManager::engine->RegisterObjectBehaviour("SceneNode", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ScriptSceneNodeConstructAssert),asCALL_CDECL_OBJLAST); ScriptManager::engine->RegisterObjectBehaviour("SceneNode", asBEHAVE_ASSIGNMENT, "SceneNode &f(const SceneNode &in)", asFUNCTION(ScriptSceneNodeConstructAssert),asCALL_CDECL_OBJLAST);
  10. Rakkar2

    Can't do a valid cast

    I will write a global function to do it then.
  11. Rakkar2

    Can't do a valid cast

    There needs to be a way to force the cast to take place no matter what. This doesn't work either ScriptManager::engine->RegisterObjectBehaviour("MovableObject", asBEHAVE_ASSIGNMENT, "MovableObject @&f(const BillboardSet @& in)", asFUNCTION((Wrap::AssignCast<MovableObject*&,MovableObject*,const BillboardSet*&>)), asCALL_CDECL_OBJLAST); Just returns INVALID_DECLARATION
  12. Rakkar2

    Can't do a valid cast

    I'm trying to pass a pointer to a derived class to a function that takes a pointer to a base class. It doesn't work through script though. Error: No matching signatures to 'attachObject(BillboardSet@&) Script Code: SceneNode parent = this.getSceneNode(); BillboardSet @billboardSet = createBillboardSet("Blah", 20); billboardSet.setMaterialName("PhotonGunMaterial"); parent.attachObject(cast<MovableObject>(billboardSet)); C++ Script registration: ScriptManager::engine->RegisterGlobalFunction("BillboardSet@ createBillboardSet(const string& in, int)", asFUNCTION(ScriptSceneManager::CreateBillboardSet), asCALL_CDECL); ... ScriptManager::engine->RegisterObjectMethod("SceneNode", "void attachObject(MovableObject@)", asMETHOD(SceneNode, attachObject),asCALL_THISCALL); Actual C++: Ogre::BillboardSet* ScriptSceneManager::CreateBillboardSet(std::string &name) { return sm->createBillboardSet(name); } ... class _OgreExport BillboardSet : public MovableObject, public Renderable { protected:
  13. Rakkar2

    Typedefs and integral types

    If I do this: engine->RegisterObjectType("size_t", sizeof(size_t), asOBJ_PRIMITIVE) Are the normal math operations going to work the same way they would as an int? All I want is a typedef sort of system.
  14. Rakkar2

    How to use MethodThroughPointer ?

    By the way, this isn't easy to figure out - to use it with a const function, the const has to be placed as follows: ScriptManager::engine->RegisterObjectMethod("Light", "int getType() const", asFUNCTION((Wrap::MethodThroughPointer0<Light::LightTypes, Light*,Light const,&Light::getType>)),asCALL_CDECL_OBJLAST);
  15. Rakkar2

    How to use MethodThroughPointer ?

    Thanks! Here is the correct version, for others that need it: template<typename R,typename P, typename C, R(C::*M)()> R MethodThroughPointer0(P* thisp) { return ((**thisp).*M)(); } template<typename R,typename P, typename C, typename P1, R(C::*M)(P1)> R MethodThroughPointer1(P1 p1, P* thisp) { return ((**thisp).*M)(p1); } template<typename R,typename P, typename C, typename P1, typename P2, R(C::*M)(P1,P2)> R MethodThroughPointer2(P1 p1, P2 p2, P* thisp) { return ((**thisp).*M)(p1,p2); } template<typename R,typename P, typename C, typename P1, typename P2, typename P3, R(C::*M)(P1,P2,P3)> R MethodThroughPointer3(P1 p1, P2 p2, P3 p3, P* thisp) { return ((**thisp).*M)(p1,p2,p3); } template<typename R,typename P, typename C, typename P1, typename P2, typename P3, typename P4, R(C::*M)(P1,P2,P3,P4)> R MethodThroughPointer4(P1 p1, P2 p2, P3 p3, P4 p4, P* thisp) { return ((**thisp).*M)(p1,p2,p3,p4); } template<typename R,typename P, typename C, typename P1, typename P2, typename P3, typename P4, typename P5, R(C::*M)(P1,P2,P3,P4,P5)> R MethodThroughPointer5(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P* thisp) { return ((**thisp).*M)(p1,p2,p3,p4,p5); } Usage: ScriptManager::engine->RegisterObjectMethod("Light", "void setType(int)", asFUNCTION((Wrap::MethodThroughPointer1<void, Light*,Light,Light::LightTypes,&Light::setType>)),asCALL_CDECL_OBJLAST);
  • 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!