 |
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
Posted: Tue Sep 18, 2007 9:44 am Post subject: persist |
 |
|
|
|
I do not fully understand the API of persist, so I am hoping someone can tell me how to solve my problem.
Lets say I want to record some statistics of a player during a flag game. (This is not what I actually want to do, but it allows me to simplify my problem)
/* this code very simplified, removed sanity checks, etc */
local int playerKey;
struct playerData {
int kills;
int deaths;
}
//raise kills and deaths
local void Kill(Arena *arena, Player *killer, Player *killed, int bounty, int flags, int *pts, int *green) {
struct playerData *killerData = PPDATA(killer, playerKey);
struct playerData *killedData = PPDATA(killed, playerKey);
killerData->kills++;
killedData->deaths++;
}
//reset kills and deaths when a new game begins
local void StartGame (Arena *arena) {
Player *p;
Link *link;
pd->Lock();
FOR_EACH_PLAYER(p) {
if (arena == p->arena) {
struct playerData *pData = PPDATA(p, playerKey);
pData->deaths = pData->kills = 0;
}
}
pd->Unlock();
}
//reset kills and deaths when entering a new arena
local void PlayerAction (Player *p, int action, Arena *arena)
{
if (action == PA_ENTERARENA)
{
struct playerData *pData = PPDATA(p, playerKey);
pData->deaths = pData->kills = 0;
}
|
The problem is, when a player gets disconnected for some reason, he ofcourse looses all his statistics.
So I want to cache his statistics using the persist module, while being able to do the following things:
- When a new flag game begins, the information of the old flag game must be removed.
- When the module is detached (MM_DETACH), the game is ended and the information has to be removed
- If the flag game is running in for example Public 0 and Public 5, switching between these publics does not reset the statistics of the other public.
- Being able to store non integral data. (Not a problem with persist, but perhaps a problem with other available methods)
After looking at the persist module I figured I need the following:
local PlayerPersistentData persistData = {
5560050, INTERVAL_GAME, PERSIST_ALLARENAS,
getData, setData, clearData
};
EXPORT int MM_mymodule(int action, Imodman *mm_, Arena *arena)
{
if (action == MM_LOAD) {
...
persist->RegPlayerPD(&persistData);
...
} else if (action == MM_UNLOAD) {
...
persist->UnregPlayerPD(&persistData);
...
}
}
local int GetData(Player *p, void *data, int len, void *clos) {
//..
}
local void SetData(Player *p, void *data, int len, void *clos) {
//..
}
local void ClearData(Player *p, void *clos) {
//..
}
|
So, my real questions are:
Am I correct that I need INTERVAL_GAME? Or do I need INTERVAL_FOREVER_NONSHARED?
What is the correct way to handle everything in GetData, SetData and Cleardata?
How do I remove the statistics when a new game begins?
Thank you |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Tue Sep 18, 2007 10:14 am Post subject: |
 |
|
|
|
there's a kickass wrapper i wrote for persist that deals with per player data that takes care of GetData, SetData, and ClearData such that it works like the playerdata interface. It's at http://rshl.org/bak/asss.html
Your other issues still exist though, my guess would be to use interval INTERVAL_GAME, scope PERSIST_ALLARENAS, and to make the scores reset when the game ends, call Ipersist->EndInterval when the game ends (and on arena unloading). _________________ SubSpace Discretion: A Third Generation SubSpace Client |
|
Back to top |
|
 |
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Thu Sep 20, 2007 6:11 pm Post subject: |
 |
|
|
|
if the game restarts when an arena is created than that shouldn't be a problem for you, I was only concerned with scores saving after a arena is destroyed and then created again.
although asss shouldn't kick everyone out for this reason.
is asss kicking everyone out? or is it crashing and restarting?
also: does it occur when a player switches arenas or when an arena gets destroyed (when mm_detach occurs)? |
|
Back to top |
|
 |
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
Posted: Fri Sep 21, 2007 7:25 am Post subject: |
 |
|
|
|
As far as I have been able to test:
- ASSS does not crash, nothing appears in the console(all=WE), no restart.
- Everyone times out, I can immediately reconnect. It's like ASSS removes all players from memory.
It happens when:
1. Public (0) has two players: ABC and XYZ
2. ABC Switches to Public (1), game begins in Public (1)
3. ABC goes back from Public (1) to Public (0). Game is still running in Public (0) because of XYZ
4. In Public (1), MM_DETACH is called, everything is fine.
5. ABC switches back to Public (1), ABC and XYZ timeout before MM_ATTACH is called. (Immediately after ?go is sent).
I remember Hyperspace having the same kind of crashing behavior a while back. Perhaps it is an unknown bug in the ASSS distribution. |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 23 page(s) served in previous 5 minutes.
|