Author |
Message |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Wed Sep 17, 2003 4:38 pm Post subject: PlayerAction/ShipChange problems |
 |
|
|
|
I'm posting this in the bugs forum (feel free to move it somewhere more appropriate like server suggestions -MGB) as I believe more functionality could be squeezed out of these functions. Any ideas on work arounds are appreciated too.
core.h PlayerActionFunc(Player *p, int action, Arena *arena);
When action is PA_LEAVEARENA (and the player quit the server), p has already been freed (attempting p->p_ship will crash the server). How about this being called just before p is freed?
I want to know how to find out the last person that left the arena and preferably what ship they were in too (I'm working on some events, and if it's a duel and someone decides to quit, I won't be able to know if it was them or someone in spec).
game.h ShipChangeFunc(Player *p, int newship, int newfreq);
newship is the same as p->p_ship (not surprisingly), however oldship would be a better argument. The alternative I guess is to allocate some player data holding info on their ship, and only update that info once I've finished handling ShipChange() in my module. If each module that wanted this sort of info did that, then there would be loads of duplicate info stored in the extra player data. |
|
Back to top |
|
 |
Grelminar Creator of Asss
Joined: Feb 26 2003 Posts: 378 Offline
|
Posted: Thu Sep 18, 2003 1:13 am Post subject: |
 |
|
|
|
Your first point is just wrong. The player struct isn't freed until much later.
As for finding the last person to leave the arena, you'll have to figure it out yourself, by handling the PA_LEAVEARENA event.
About the parameters to ShipChangeFunc, I agree having the old ship and freq would be useful. I can do one of three things: add two more parameters for the old ship/freq, change the two existing paramaters to mean the old ship/freq, or leave their meanings alone and leave p->p_ship/freq set to the old ones when the callback is invoked. Any preference? |
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Thu Sep 18, 2003 2:46 am Post subject: |
 |
|
|
|
To keep it backwards compatible and keep the meaning of the prototype it is probably best to leave p->p_ship/freq set to the old ones, thanks. |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Sep 18, 2003 9:37 am Post subject: |
 |
|
|
|
I personally would keep the p->p_ship and freq always up to date, and pass in the old freq and ship into the function.
If it were me. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:42 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Thu Sep 18, 2003 5:49 pm Post subject: |
 |
|
|
|
Smong wrote: | To keep it backwards compatible... |
Don't need to keep it backwards compatiable if almost nothing except some testing servers are using it. Its not that hard to recompile something like this, when maybe 10 people are working with it actively.
I'd think keeping an OldFreq/Ship is nice, as I've found it useful when dealing with games and such. Plus, its only 3 bytes (short + char). |
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Fri Sep 19, 2003 1:47 pm Post subject: |
 |
|
|
|
OK, pass in the old freq and ship, I'm not too bothered, so long as it gets fixed in the official distro. |
|
Back to top |
|
 |
|