Server Help

ASSS Questions - PlayerAction/ShipChange problems

Smong - 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.
Grelminar - 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?
Smong - 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.
Dr Brain - 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.
Mine GO BOOM - 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).
Smong - 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.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group