I always loved to hack around on the limits of 3dgs. Today I decided to play around with litec again after a long time. After playing around a bit, I found a way to call struct methods and pass 'this' to it(without actually passing it...). Difficult to explain, here is an example wink

Php Code:

	Test* test1 = newTest();
	test1->GetX = Test_GetX;
	test1->x = 40;
	
	Test* test2 = newTest();
	test2->GetX = Test_GetX;
	test2->x = 80;
	
	printf("Test1: %d | Test2: %d", test1->GetX(), test2->GetX());
 




Will print 40 and 80, even though i newer pass test1 or test2 as parameter to the GetX functions of the struct

regards Alain

EDIT: never mind, it's the same as in this post http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=420134. I used the following macros however to make it simpler:

Php Code:
#define ClassDefStart(className) typedef struct _##className {
#define ClassDefEnd(className) } _##className; typedef interface className { _##className *lpVtbl;} className; className* new##className() {className* r = sys_malloc(sizeof(className)); r->lpVtbl = sys_malloc(sizeof(_##className)); return r;}

ClassDefStart(Test)
	var x;
	var GetX(void* this);
ClassDefEnd(Test) 



Last edited by krial057; 02/12/15 00:53.