Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (SBGuy), 712 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
how to pass pointers using event functions #349469
12/07/10 22:01
12/07/10 22:01
Joined: Nov 2008
Posts: 354
saeculum II
MPQ Offline OP
Senior Member
MPQ  Offline OP
Senior Member

Joined: Nov 2008
Posts: 354
saeculum II
Hi everybody,

I have the folloing problem: There is no possiblity to pass pointers, references, parametes unsing the event function.

My objective is the following: removing an Entity (a local one!) when hitting an other entity!

example

Code:
void ent_1(ENTITY* temp)
{
   c_move (temp, ...);
   temp.emask = ENABLE_ENTITY;
   temp.event = remove_temp;//here is the problem: no parameter can be passed
}


void remove_temp (HERE NO PARAMENTER POSSIBLE)
{
   ent_remove (THE temp POINTER is invalid here);
}



Last edited by MPQ; 12/07/10 22:33.

new project in early stage...

Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
Re: how to pass pointers using event functions [Re: MPQ] #349472
12/07/10 22:23
12/07/10 22:23
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Code:
void remove_temp()
{
   ent_remove(me);
}
void ent_1(ENTITY* temp)
{
   c_move (temp, ...);
   temp.emask = ENABLE_ENTITY;
   temp.event = remove_temp;//here is the problem: no parameter can be passed
}



Doesn't this work?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: how to pass pointers using event functions [Re: Superku] #349473
12/07/10 22:31
12/07/10 22:31
Joined: Nov 2008
Posts: 354
saeculum II
MPQ Offline OP
Senior Member
MPQ  Offline OP
Senior Member

Joined: Nov 2008
Posts: 354
saeculum II
ok i ll try out:

ok it looks like that the me pointer is automatically passed, thank you superku. But an other problem arises: When the entity is removed, the local entity of the calling function becomes invalid, what to do laugh

Code:
void remove_temp()
{
   wait(1);
   ent_remove(me);//now the temp pointer of the calling function becomes invalid

}
void ent_1(ENTITY* temp)
{
   temp.emask = ENABLE_ENTITY;
   temp.event = remove_temp;//here is the problem: no parameter can be passed
   while(1)//while(temp)
   {
      c_move (temp, ...);//temp becomes invalid when it is removed, invalid pointer error
      wait(1);
   }

}



no idea?

Last edited by MPQ; 12/09/10 09:35.

new project in early stage...

Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
Re: how to pass pointers using event functions [Re: MPQ] #349596
12/09/10 14:32
12/09/10 14:32
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
you can do something like this

Code:
void remove_temp()
{
   my.skill1 = 1;
}
void ent_1(ENTITY* temp)
{
   temp.emask = ENABLE_ENTITY;
   temp.event = remove_temp;

   while(!temp.skill1)
   {
      c_move (temp, ...);
      wait(1);
   }

   ent_remove(temp);
}



Re: how to pass pointers using event functions [Re: txesmi] #349685
12/10/10 10:24
12/10/10 10:24
Joined: Nov 2008
Posts: 354
saeculum II
MPQ Offline OP
Senior Member
MPQ  Offline OP
Senior Member

Joined: Nov 2008
Posts: 354
saeculum II
thanks i'll try this out


new project in early stage...

Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com
Re: how to pass pointers using event functions [Re: MPQ] #351399
12/24/10 10:50
12/24/10 10:50
Joined: Nov 2008
Posts: 354
saeculum II
MPQ Offline OP
Senior Member
MPQ  Offline OP
Senior Member

Joined: Nov 2008
Posts: 354
saeculum II
thanx with the pattern of txsmi it works pretty well, the code looks like that:
Code:
int remove_temp()
{
   return (my.skill1 = 1);
}

void ent_move(ENTITY *temp)
{
   temp.emask = ENABLE_ENTITY;
   temp.event = remove_temp;

   while(!temp.skill1)
   {
      c_move (temp, ...);
      wait(1);
   }

   ent_remove(temp);
}

void create_ent()
{
   ENTITY *temp1;
   temp1 = ent_create (...);
   ent_move (temp1);
}



Ok, the handing over of pointers works quite well so far, but why does lite-c not support references, I thought it would be more like C++ and supports this feature, but here it look more like C. Does lite-c support Classes?

Last edited by MPQ; 12/24/10 13:48.

new project in early stage...

Intel Xeon X3450 2,66GHz | Mushkin 8 Gib | Zotac GTS250 + 7300LE | A8.3 com

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1