Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Hosted Game Core
Goto page 1, 2  Next
 
Post new topic   Reply to topic Printable version
 View previous topic  ACE -- ASSS C Enricher (beta 2 release... Post :: Post <C> Multizone Module  View next topic  
Author Message
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Mon Feb 02, 2009 5:08 pm    Post subject: Hosted Game Core Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Thu Feb 05, 2009 12:07 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Send email
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Thu Feb 05, 2009 6:35 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Thu Feb 05, 2009 6:43 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Thu Feb 05, 2009 11:40 pm    Post subject: Reply to topic Reply with quote

why not incorporate these events into hyperspace...?

biggrin.gif
_________________
SSC Distension Owner
SSCU Trench Wars Developer
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Fri Feb 06, 2009 5:14 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Wed Feb 11, 2009 3:50 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
Chambahs
Power attack
Power attack


Joined: Jun 19 2005
Posts: 820
Offline

PostPosted: Wed Feb 11, 2009 9:13 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Wed Feb 11, 2009 10:38 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Send email
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Thu Feb 12, 2009 11:29 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Thu Feb 12, 2009 12:09 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
Chambahs
Power attack
Power attack


Joined: Jun 19 2005
Posts: 820
Offline

PostPosted: Thu Feb 12, 2009 6:42 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Thu Feb 12, 2009 8:28 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Sun Feb 15, 2009 5:28 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Tue May 12, 2009 8:14 am    Post subject: Reply to topic Reply with quote

Bump for new features! Host/arena gametype permissions and a command to switch between them, detailed here.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Mon May 23, 2011 10:05 pm    Post subject: Reply to topic Reply with quote

Big bump!

I'm trying to use hgcore for some race module I'm making, and I can't get my arena to detach properly...

Code: Show/Hide

I <arenaman> {0} [Samapico] entering arena
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.
E <module> {f1racetest} failed to detach 'hg_race' while detaching modules
E <module> {f1racetest} failed to detach 'hgcore' 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.



In my arena.conf:
[ Modules ]
; this key holds the names of the modules that will take effect in this
; arena. typical things to put here are modules for scoring, special
; game types, flag guards, etc.
AttachModules = \
fm_normal \
points_kill \
points_flag \
points_goal \
buy \
hgcore \
hg_race



In my modules.conf at the end:
hosted:hgcore
hosted:hg_race


My module:
http://pastebin.com/E1Z07xGZ
(I also tried allocating/freeing the player data in load/unload, same error)



I just noticed aman wasn't released in the 'Unload'... I copied that from hg_pb.c, and it has the same bug. It doesn't fix my problem though icon_sad.gif
Back to top
View users profile Send private message Add User to Ignore List
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Tue May 24, 2011 8:59 pm    Post subject: Reply to topic Reply with quote

I couldn't reproduce this icon_confused.gif

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
View users profile Send private message Add User to Ignore List Visit posters website
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Tue May 24, 2011 9:04 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Tue May 24, 2011 9:21 pm    Post subject: Reply to topic Reply with quote

Yeah... the code on the repository has that bug:

Code: Show/Hide

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
View users profile Send private message Add User to Ignore List
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Tue May 24, 2011 9:27 pm    Post subject: Reply to topic Reply with quote

I added some log lines in my detach sequence:

Code: Show/Hide
    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?
Code: Show/Hide

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:
Code: Show/Hide
    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
View users profile Send private message Add User to Ignore List
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Tue May 24, 2011 11:00 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Tue May 24, 2011 11:13 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Wed May 25, 2011 7:03 am    Post subject: Reply to topic Reply with quote

Just a thought: try reversing the order of the two modules in the arena.conf's attach modules setting.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Wed May 25, 2011 7:43 am    Post subject: Reply to topic Reply with quote

Well, I tried many things... but at the moment, hg_race isn't even in my arena.conf tongue.gif

hgcore attaches the module automatically when you ?switchgame
Back to top
View users profile Send private message Add User to Ignore List
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Thu May 26, 2011 11:17 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Custom Projects All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 654 page(s) served in previous 5 minutes.

phpBB Created this page in 0.511934 seconds : 50 queries executed (77.1%): GZIP compression disabled