Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 05 Jan 2012
Offline Last Active Oct 01 2013 12:04 AM

#5062427 CScriptArray::Destruct

Posted by on 16 May 2013 - 06:58 PM



Ok i am sorry, i just did the math for real this time. You are right. I should have rushed to answer without checking my facts :)


A script object handle has mask of asTYPEID_MASK_OBJECT | asTYPEID_OBJHANDLE

An c++ object handle has mask of asTYPEID_APPOBJECT | asTYPEID_OBJHANDLE


I don't think there is anything wrong with if( subTypeId & asTYPEID_MASK_OBJECT ).

It doesn't care about handles because all handles are asTYPEID_APPOBJECT or asTYPEID_MASK_OBJECT or asTYPEID_TEMPLATE .

There aren't any handle types that doesn't fit those 3. No such thing as pure asTYPEID_OBJHANDLE

#5057078 passing class/function to asMETHOD

Posted by on 26 April 2013 - 02:53 PM

You are just storing void* and expecting C++ to call correct function.

C++ can not call the correct function just with a void*.


There was a project called AngelBinder, google it.

What you want is doable, but require advanced c++ templates knowledge.

#5010634 Delegates in AngelScript

Posted by on 14 December 2012 - 09:32 AM

There is also this very simple implementation:

map<int,void*> handles; // object destructor sets this to null.

class WeakHandle
   int id;
   void *Get() 
	 	return handles[id].ptr;

class Function
   WeakHandle handleToObject;

two improvements would be
- use array to lessen cache misses. WeakHandle needs to hold another integer to do that
- weak references hold count so that GC can clean handles array from nulls. Prevent handles array to keep much unnecessary memory.
- promote script objects to weak objects only when they are referenced from weak pointers. so we don't query handles array for every destructor call.

I have used this system to catch nasty memory leaks, it works wonderfully.
Weak references are much easier to implement than strong ones. That is if the existing system permit this kind of flexibility.

I am not trying to push a new feature on you. Just some ideas for the future of this advanced language.
There is nothing like angelscript on the market.

#5010590 Delegates in AngelScript

Posted by on 14 December 2012 - 07:10 AM

I am sorry :(, i don't understand.

array<funcPtr> events;

class Object
	 	 events.insertLast(funcPtr(Object::SomeFunc, @this));

	 void SomeFunc()  {    }

void main()
	 Object o;

Above code puts to forces script writer to release reference by hand. If she forgets it will be hell to debug why object aren't released.
But a weak reference releases object and shows a null pointer access warning, which is much easier to spot.

That is not to say all function pointers should be weak references, strong references also have their places.
Maybe a new keyword before objects and function pointers to make them weak pointers.
weak Object @o = Object();
Probably implementation will be a proxy handle.

I am not experienced with GC languages, probably extending discussion out of my ignorance.

#5003633 Quick Unity and Blender Question

Posted by on 23 November 2012 - 07:41 PM

Blender uses their own gui implementation, they draw it on opengl textures.
I think Unity3D does the same but with directx. It cant know for sure, it even renders HTML's inside editor with WebKit.

big projects always feel constrained with what OS gives them.

#5001370 Unique ID for every objects using reinterpret_cast

Posted by on 15 November 2012 - 04:27 PM


same memory address will be used after delete/free called on that object.
it is messy.

just use a id generator class. if you want something more advanced i recommend boost::Uuid

#4995239 MSVC 2010 vs MSVC 2012 - Performance question.

Posted by on 29 October 2012 - 07:02 PM

2012 is faster and less buggy than 2010. tip: uninstall extensions, they use way too much memory.
do you write directx? vs2012 has surprisingly good amount of features for directx. it even has a hlsl designer.
2012 cant create xp programs. so its not really option as a go-to IDE for a lot of people.
visual studio intellisense if still not good enough. i get a lot of false errors.
code compiles fine but intellisense insists on reporting hundreds of errors.
there is not enough options to tweak it neither.

my setup: Eclipse for coding, cmake for building, VS for debugging.
seems to be the best setup for productivity.
more people should use Eclipse, it is not slow as it used to be.

#4994826 What does it mean to "be creative"? And how does one "be creative...

Posted by on 28 October 2012 - 02:06 PM

definition is as you said "think what others don't".
as long as it is in the context.

did you want add decapitation in your cutesy platformer?

please tell us your idea, i am curious.

#4994417 A class that contains an instance of itself

Posted by on 27 October 2012 - 08:03 AM

Menu in your example does not contain another instance of Menu. It holds a pointer to a Menu object. Therefore possible.

#4985495 Passing a value into a bound class.

Posted by on 30 September 2012 - 03:27 PM

I strongly suggest you read this article: http://gameprogrammi.../singleton.html Singletons have a lot of attractive features at first glance, but they're really a bad idea in the long run.

I do understand the difference between a plain global and the singleton pattern, but functionally they serve the same purpose of providing global access to the same variable anywhere in your program. Additionally, my engine is designed so I could have multiple instances of it running in the same program. Using a singleton for the engine would prevent me from doing this.

As far as malicious use goes (although I'm not sure why that would ever be a concern), your singleton example above is just as susceptible:

delete Engine::get();

To each his own. Let's not go any further off topic. Posted Image

friend void Game::EndGame();

now only Game::EndGame() can call delete on singleton. applies to "get" and any other functions too.

#4985190 Passing a value into a bound class.

Posted by on 29 September 2012 - 05:42 PM

a very wrong misconception.
singletons are definitely not global variables. you cant control access with global variables.

the way you do it is more akin to a global variable.
it makes engine to accessible and volatile to every piece of code in your program.

what if some evil soul decides to call asGetActiveContext()->GetEngine()->SetUserdata(null);
angry employee maybe?

#4985184 Passing a value into a bound class.

Posted by on 29 September 2012 - 05:20 PM

i might be missing the point here but wouldn't singleton engine class solve this?

class Engine
	 static Engine *instance;
	 static Engine *get()
  	 if (!instance)
   	 instance = new Engine;
	   return instance;
	 void init()
	 	 // Do init.
Engine* Engine::instance = 0;

they you will have access to it anywhere anytime.

#4978013 Compile Time. How to reduce it?

Posted by on 08 September 2012 - 10:17 AM

Understanding how compiler works if the best way to go.

most common method;
- Define your translation units, make a list of what each of them includes.
- Find headers that are included more than once.
- If these headers rarely change put them in your precompiled header. ( if you dont know what this is, better google it)

use #pragma message("including XXX.h") to find a file is include more than once.
remember header guards and '#pragma once' does not help if same file is included in more than one translation unit.
ex. if you see an output something like this, then header.h is a good candidate for precompiled header
compiling a.cpp
including header.h
compiling b.cpp
including header.h

other tips include;
- try your best to not include a header file in an other header file. use forward declarations if possible.
- avoid big header files.
- header files should change very very rarely. a change in an header file will cause all translation units including it to be recompiled. designing you classes before writing them is a good idea.
- if your project is modular and a module is stable, make that module to its own project.

#4976680 User Interface

Posted by on 04 September 2012 - 09:54 PM

i use berkelium. i am happy with it.

1. chrome does not have 64bit compilation on windows. so, no. if you aim to release an 64bit application in windows that is. runs in 64bit OS as 32bit nicely.
2. flash works. but user need to have flash player to installed. no different than a browser running flash.
3. i have active/animated interface running. 1000+ fps. it gets chromes render output and writes it in any texture you want.
only dirty pixel are written over. no different than most gui middleware
4. yes. a separate process is a must. it will be running along side your game. this is a good thing.
but i have seen some players thinking it is a malware.
like this http://forums.heroesofnewerth.com/showthread.php?359619-AwesomiumProcess-exe-Malware

here are some cons:
- You can not release your game to consoles. if you have dreams of xbox or ps3, just forget it.
- Every html you start will at least cost 25mb of ram. keep this in mind
- Initial integration will be troublesome. just needing to compile chrome is so much of a hassle. it took 10 hours to download from svn + 2 setup + 8 hours just to compile it. that is provided your are experienced with building complex applications.

- it is very nice to work with HTML/JS/CSS. no need to edit some vague xmls to create widgets.
- hundreds of javascript UI middlewares. most of em BSD or MIT licensed.
- stuck on how to create an element? internet is full of information about web design.

#4976152 AngelScript mixin classes - preview

Posted by on 03 September 2012 - 01:10 PM

mixin seem to be doing all interface does and more.

Is interface going to be deprecated?