Author |
Message |
D1st0rt Miss Directed Wannabe
Age:36 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Mon Feb 02, 2009 5:08 pm Post subject: Hosted Game Core |
|
|
|
|
Here's a pre-release of something I've been working on for a couple of weeks now to make it easier to write modules for game types that are designed to have a human host. I call it the Hosted Game Core (HGC) and it is comprised of two parts: the core module itself and various hosted game modules that operate on top of it. The core handles a lot of host commands and all of the team/player tracking you should (hopefully) need in a game. Hosted game modules can be written in C or Python, though I had to make some changes to pymod.c/pymod_process.py to get it to work (available on request!)
The two interfaces in question are fairly well documented and it comes with a sample module that is a basic but fully functional deathmatch game (only 100 lines, wow!). More usage documentation is forthcoming, and if you have specific questions I can answer any of those as well.
I have a project page for it where you can grab the source, read some docs, and submit tickets:
http://code.google.com/p/asss-hostedgame _________________
|
|
Back to top |
|
|
Hakaku Server Help Squatter
Joined: Apr 07 2006 Posts: 299 Location: Canada Offline
|
Posted: Thu Feb 05, 2009 12:07 pm Post subject: |
|
|
|
|
This looks really promising, and I look forward to seeing more events or examples added. Though maybe I missed it, but how exactly do you start an event? Also, is there a way to pass specific parameters for individual games? For example, specifying the # of deaths rather than always having the default of 5. |
|
Back to top |
|
|
D1st0rt Miss Directed Wannabe
Age:36 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Thu Feb 05, 2009 6:35 pm Post subject: |
|
|
|
|
There is a set of commands the core handles for things like starting games and so forth, this brings some consistency across games:
Set a new game up with ?newgame
Then you can freq pm teams "?addteam to put them into the game. If you change your mind, "?removeteam takes them out of the game.
Once you have two+ teams added, you can start it up with ?startgame, and you can kill a game in progress with ?stopgame.
As for the deathmatch example, it was hardcoded to 5 just for simplicity. Ideally you'd be able to set it via an arena setting like HG_DM:KillsToWin.
If people want to fiddle around with this a little bit, let me know if there are any API changes that need to be made to allow for something. This is just a pre-release so I haven't frozen anything yet. |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Feb 05, 2009 6:43 pm Post subject: |
|
|
|
|
Just an idea (haven't looked at the code): pass the params from ?startgame to the module. Then they can parse out the # of kills (or whatever) if they want to. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Thu Feb 05, 2009 11:40 pm Post subject: |
|
|
|
|
why not incorporate these events into hyperspace...?
_________________ SSC Distension Owner
SSCU Trench Wars Developer |
|
Back to top |
|
|
D1st0rt Miss Directed Wannabe
Age:36 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Fri Feb 06, 2009 5:14 pm Post subject: |
|
|
|
|
Dr Brain wrote: | Just an idea (haven't looked at the code): pass the params from ?startgame to the module. Then they can parse out the # of kills (or whatever) if they want to. |
Easy enough, this is now in trunk |
|
Back to top |
|
|
D1st0rt Miss Directed Wannabe
Age:36 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Wed Feb 11, 2009 3:50 pm Post subject: |
|
|
|
|
Hakaku wrote: | I look forward to seeing more events or examples added. |
Are there any specific examples of events people would like to see implemented? In addition to promoting the system it will help me find any problems that may exist. |
|
Back to top |
|
|
Chambahs Power attack
Joined: Jun 19 2005 Posts: 820 Offline
|
Posted: Wed Feb 11, 2009 9:13 pm Post subject: |
|
|
|
|
MVP, person with most kills after x ammount of time wins.
Another, person who holds flag gets 1 point per second, first person to get to x amount of points first wins, or after x amount of time whoever has the most wins.
I got tons, lemme know if you need more. |
|
Back to top |
|
|
Hakaku Server Help Squatter
Joined: Apr 07 2006 Posts: 299 Location: Canada Offline
|
Posted: Wed Feb 11, 2009 10:38 pm Post subject: |
|
|
|
|
D1st0rt wrote: | Are there any specific examples of events people would like to see implemented? In addition to promoting the system it will help me find any problems that may exist. |
I still haven't taken the time to look through it much, but I suppose implementing some basic game types such as elim, conquer, and other merv games would be a start. Deva's own half-broken event core included (team)elim, (team)killrace, conquer, zombies, juggernaught, pb (i.e. a soccer-style event), and race. I don't actually expect you to write any of those, but it's just to give you an idea of what could potentially be created with a game core such as this. |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Thu Feb 12, 2009 11:29 am Post subject: |
|
|
|
|
Speaking of race... Has anyone ever made some kind of racing module, with checkpoints and stuff? If I get bored one day I could try to finish my F1 racing events with some ASSS fancy stuff... Actually if I do learn to use ASSS one day that would probably be my first project.
Are the regions pretty reliable? Like is it possible for someone to just, lag-jump over a region completely? Or if someone goes from one side of the region to the other they still trigger the region_enter / region_leave events? _________________ (Insert a bunch of dead links here) |
|
Back to top |
|
|
D1st0rt Miss Directed Wannabe
Age:36 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Thu Feb 12, 2009 12:09 pm Post subject: |
|
|
|
|
Is conquer the one where someone joins your team when you kill them? That could be interesting, and I feel like a lot of these could be cranked out in python in a very short amount of time.
I guess something I should figure out is a good way to do events where people are on teams by themselves; it's kind of a pain for a host to have to manually add everyone before they can start. One idea I had was that you create one "playing" team and then when the game starts the core goes through and creates a team for each player. I'd probably enable this behavior with an arena setting. Alternatively there could be a separate command to put everyone on their own team and add it but I feel like that wouldn't be as clean.
Racing is interesting because at the moment you need 2 teams to start a game. A fake player is the quickest workaround at the moment. |
|
Back to top |
|
|
Chambahs Power attack
Joined: Jun 19 2005 Posts: 820 Offline
|
Posted: Thu Feb 12, 2009 6:42 pm Post subject: |
|
|
|
|
Quote: | Are the regions pretty reliable? Like is it possible for someone to just, lag-jump over a region completely? Or if someone goes from one side of the region to the other they still trigger the region_enter / region_leave events? |
Depends on how big the regions are. I used to have the problem with UT that the regions didnt used to detect the player, so I had to make them bigger. If they were 5x5, id have to make them 8x8 so that by the time they hit that 8th tile, the server would recognize it and it would do its action in time so that it would SEEM to that player that it picked it up immediately at the 5th tile.
If you understand that |
|
Back to top |
|
|
D1st0rt Miss Directed Wannabe
Age:36 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Thu Feb 12, 2009 8:28 pm Post subject: |
|
|
|
|
I think the issue there is that the server doesn't do any interpolation when it comes to regions so unless it receives a packet where they are specifically inside it won't trigger. |
|
Back to top |
|
|
D1st0rt Miss Directed Wannabe
Age:36 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Sun Feb 15, 2009 5:28 pm Post subject: |
|
|
|
|
So I added a zombies game and made a new wiki page to list the games. I also set up a ticket template if anyone has a request. |
|
Back to top |
|
|
D1st0rt Miss Directed Wannabe
Age:36 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Tue May 12, 2009 8:14 am Post subject: |
|
|
|
|
Bump for new features! Host/arena gametype permissions and a command to switch between them, detailed here. |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
|
Back to top |
|
|
D1st0rt Miss Directed Wannabe
Age:36 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Tue May 24, 2011 8:59 pm Post subject: |
|
|
|
|
I couldn't reproduce this
I tried leaving the arena to another of the same arena, to a different arena, and disconnecting but it all worked fine.
Could you describe anything else you're doing? |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Tue May 24, 2011 9:04 pm Post subject: |
|
|
|
|
I just realized I get the problem even if I don't attach my hg_race, and I don't ?switchgame. Just move in the arena, and leave, and hgcore itself throws the same error.
.................
wait...... something is messed up in my hgcore.c... there's no "return MM_OK;" in the detach and preunload cases............. |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Tue May 24, 2011 9:21 pm Post subject: |
|
|
|
|
Yeah... the code on the repository has that bug:
else if (action == MM_DETACH)
{
//Data
hgcore_adata *ad = P_ARENA_DATA(arena, adkey);
if(ad->Status != HGS_IDLE)
{
CleanupGame(arena);
}
pthread_mutex_lock(&globalmutex);
LLFree(ad->Teams);
HashFree(ad->Players);
pthread_mutex_unlock(&globalmutex);
afree(ad->cfg_AllowedGames);
//Timers
//Callbacks
mm->UnregCallback(CB_PLAYERACTION, PlayerAction, arena);
mm->UnregCallback(CB_SHIPCHANGE, ShipChange, arena);
mm->UnregCallback(CB_FREQCHANGE, FreqChange, arena);
mm->UnregCallback(CB_ARENAACTION, ArenaAction, arena);
//Commands
cmd->RemoveCommand("newgame", C_newgame, arena);
cmd->RemoveCommand("addteam", C_addteam, arena);
cmd->RemoveCommand("removeteam", C_removeteam, arena);
cmd->RemoveCommand("showteams", C_showteams, arena);
cmd->RemoveCommand("startgame", C_startgame, arena);
cmd->RemoveCommand("stopgame", C_stopgame, arena);
cmd->RemoveCommand("listgames", C_listgames, arena);
cmd->RemoveCommand("switchgame", C_switchgame, arena);
cmd->RemoveCommand("pausegame", C_pausegame, arena);
cmd->RemoveCommand("resumegame", C_resumegame, arena);
//SHOULD RETURN MM_OK HERE
}
else if (action == MM_PREUNLOAD) //server is shutting down
{
Link *link;
Arena *a;
aman->Lock();
FOR_EACH_ARENA(a)
{
EndGame(a, HGR_FORCED);
DetachGame(a);
}
aman->Unlock();
//SHOULD RETURN MM_OK HERE
}
return MM_FAIL;
|
It fixes half of the problem... hgcore detaches properly (duh), but my hg_race is still giving an error... |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Tue May 24, 2011 9:27 pm Post subject: |
|
|
|
|
I added some log lines in my detach sequence:
else if (action == MM_DETACH)
{
//Data
lm->Log(L_INFO, "Detaching hg_race");
aman->Lock();
hg_race_adata *ad = P_ARENA_DATA(arena, adkey);
if (ad)
{
ad->cp_count = 0;
if (ad->checkpoints)
afree(ad->checkpoints);
ad->checkpoints = NULL;
ad->pit_count = 0;
if (ad->pitlane)
afree(ad->pitlane);
ad->pitlane = NULL;
}
aman->Unlock();
//Timers
lm->Log(L_INFO, "Unregistering callbacks...");
//Callbacks
mm->UnregCallback(CB_PPK, PlayerMove, arena);
mm->UnregCallback(CB_PLAYERACTION, PlayerAction, arena);
//Commands
lm->Log(L_INFO, "Detaching game from hgcore...");
// Interface registration
if(!hgcore->DetachGame(arena))
{
return MM_FAIL;
}
lm->Log(L_INFO, "Unregistering interface...");
if (mm->UnregInterface(&hginterface, arena))
{
return MM_FAIL;
}
lm->Log(L_INFO, "Detach OK!");
return MM_OK;
|
And here's the resulting output...
hgcore detaches the game, and the game tries to detach itself from hgcore as well... that's probably why it fails?
D <arenaman> {f1racetest} arena being destroyed
W <hgcore> {f1racetest} Ignored trying to end game that is already in POSTGAME or IDLE
I <hgcore> {f1racetest} Detached hosted game.
I Detaching hg_race
I Unregistering callbacks...
I Detaching game from hgcore...
E <module> {f1racetest} failed to detach 'hg_race' while detaching modules
E <arenaman> {f1racetest} failed to detach modules from arena, arena will not be destroyed. check for correct interface releasing.
E <arenaman> {#foof1racetest} WARNING: the server is no longer in a stable state because of this error. your modules need to be fixed.
I <arenaman> {0} [Samapico] leaving arena
|
Edit: If that was the game, the DetachGame method should output this the 2nd time:
else if(!ad->hg)
{
lm->LogA(L_WARN, "hgcore", a, "Ignored detaching hosted game that is already detached.");
} |
But it doesn't... hmm... Also, if it went in there, it would still return a 'fail'...
Edit2: If DetachGame doesn't output anything, it means the HG_CHECK_RETURN(a, 0); part exits the function... and it returns a 0, which is a fail, and it makes the MM_Detach fail... mhm... |
|
Back to top |
|
|
D1st0rt Miss Directed Wannabe
Age:36 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Tue May 24, 2011 11:00 pm Post subject: |
|
|
|
|
What's happening is that hgcore listens for the arena destroy callback and forcibly closes the game going on in that arena. I still haven't reproduced this on my system, but try commenting out the DetachGame call on line 1124 in hgcore.c's ArenaAction and see if that is a valid workaround. |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Tue May 24, 2011 11:13 pm Post subject: |
|
|
|
|
Is the code at https://bitbucket.org/d1st0rt/asss_hostedgame up to date? Cause there's no way it can work without the "return MM_OK;" lines... so I'd be curious if your code has any other differences... can you send me (or attach here) your hgcore.c, and one of your module if possible...
And yeah, commenting out the DetachGame call in hgcore.c seems to work |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Wed May 25, 2011 7:03 am Post subject: |
|
|
|
|
Just a thought: try reversing the order of the two modules in the arena.conf's attach modules setting. |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Wed May 25, 2011 7:43 am Post subject: |
|
|
|
|
Well, I tried many things... but at the moment, hg_race isn't even in my arena.conf
hgcore attaches the module automatically when you ?switchgame |
|
Back to top |
|
|
D1st0rt Miss Directed Wannabe
Age:36 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
Posted: Thu May 26, 2011 11:17 pm Post subject: |
|
|
|
|
Strangely enough, I'm using a fresh checkout of the 1.5 branch with the file you provided and I can't reproduce your problem. It all works fine on my system for some reason.
I agree the MM_OK calls should be there, so I added them on my local copy. The DetachGame call in ArenaAction is probably a little bit overreaching from a design perspective, because once EndGame has been called the game module should be able (and coded to) detach itself when the time comes.
the HG_CHECK_RETURN macro shouldn't fail unless your per arena data hasn't been initialized, or more likely the arena doesn't exist (because the first case shouldn't happen). Off the top of my head the arena should still be good in AA_DESTROY, I think there was something like AA_DESTROY2 that took care of that. Check and see what you're passing. Also, do you have any other arenas created at the time this happens?
What revision of asss are you running, I checked mine and I'm on changeset 1188 |
|
Back to top |
|
|
|