thomasleveil / b3-plugin-poweradminbf3

BigBrotherBot Poweradmin plugin for Battlefield 3
https://github.com/courgette/b3-plugin-poweradminbf3/wiki
4 stars 3 forks source link

!loadconfig command #1

Closed thomasleveil closed 12 years ago

thomasleveil commented 13 years ago

Description

the !loadconfig <preset> command will be used to change server cvars according to predefined settings.

Algorithm

<settings name="presets">
    <set name="hardcoreTDM">
            vars.autoBalance true
            vars.roundStartPlayerCount 8
            vars.roundRestartPlayerCount 4
            vars.friendlyFire true
            vars.killCam false
            vars.miniMap true
            vars.hud false
            vars.crossHair true
            vars.3dSpotting false
            vars.miniMapSpotting true
            vars.nameTag false
            vars.3pCam false
            vars.regenerateHealth false
            vars.vehicleSpawnAllowed true
            vars.vehicleSpawnDelay 100
            vars.soldierHealth 60
            vars.playerRespawnTime 100
            vars.playerManDownTime 100
            vars.bulletDamage 100
            vars.onlySquadLeaderSpawn true

            MP_001 TeamDeathMatch0 1
            MP_003 TeamDeathMatch0 1
            MP_007 TeamDeathMatch0 1
            MP_011 TeamDeathMatch0 1
            MP_012 TeamDeathMatch0 1
    </set>
    <set name="infantryRUSH1">
        vars.autoBalance true
        vars.friendlyFire false
        vars.killCam true
        vars.miniMap true
        vars.hud true
        vars.3dSpotting true
        vars.miniMapSpotting true
        vars.nameTag true
        vars.3pCam false
        vars.regenerateHealth true
        vars.vehicleSpawnAllowed false
        vars.soldierHealth 100
        vars.playerRespawnTime 100
        vars.playerManDownTime 100
        vars.bulletDamage 100
        vars.onlySquadLeaderSpawn false

        MP_007 RushLarge0 4
        MP_011 RushLarge0 4
        MP_012 SquadRush0 4
        MP_013 SquadRush0 4
    </set>
</settings>
markweirath commented 12 years ago

Is this the same as the start of the !setmode implementation? (v0.5)

thomasleveil commented 12 years ago

yes !setmode was put there as a placeholder, but that spec changed a lot :)

What do you think of current spec ?

markweirath commented 12 years ago

you mean !loadconfig instead of !setmode and configured as in this example above?

markweirath commented 12 years ago

Perhaps I would go for a file-based solution. A folder with normal.cfg, hardcore.cfg etc. Would be easier for users to create new configs and overview all server configs...

markweirath commented 12 years ago

I'll take this one and start with a file-based approach.

markweirath commented 12 years ago

Does the server understand a sequence of rcon commands like this:

        MP_001 TeamDeathMatch0 1
        MP_003 TeamDeathMatch0 1
        MP_007 TeamDeathMatch0 1
        MP_011 TeamDeathMatch0 1
        MP_012 TeamDeathMatch0 1

is that how a maplist is built?

thomasleveil commented 12 years ago

not exactly, you would need something similar to :

self.console.write(('mapList.clear',)) # clear current in-memory map rotation list
self.console.write(('mapList.add', 'MP_001', 'TeamDeathMatch0', '1'))
self.console.write(('mapList.add', 'MP_003', 'TeamDeathMatch0', '1'))
self.console.write(('mapList.add', 'MP_007', 'TeamDeathMatch0', '1'))
self.console.write(('mapList.add', 'MP_011', 'TeamDeathMatch0', '1'))
self.console.write(('mapList.add', 'MP_012', 'TeamDeathMatch0', '1'))
self.console.write(('mapList.save',)) # write current in-memory map list to server config file so if the server restarts our list is recovered.

a bit of doc from BF3 protocol :

Request: mapList.add <map: string> <gamemode: string> <rounds: integer> [index: integer] Response: OK Response: InvalidArguments Response: InvalidMap – incorrect map name Response: InvalidGameModeOnMap – gamemode does not exist for that map Response: InvalidRoundsPerMap – number of rounds must be 1 or greater Response: Full – Map list maximum size has been reached Response: InvalidMapIndex – Index value is out of range Effect: Adds the map , with gamemode , for rounds, to the maplist. If is not specified, it is appended to the end; otherwise, it is inserted before the map which is currently at position .

BF3 server map rotation list file format

The format as below is how the map rotation list is saved to the disk in the map rotation list file.

MP_001 TeamDeathMatch0 1
MP_003 TeamDeathMatch0 1
MP_007 TeamDeathMatch0 1
MP_011 TeamDeathMatch0 1
MP_012 TeamDeathMatch0 1

This format is only understood in this file.

markweirath commented 12 years ago

Okay, first basic implementation is done. Pull request is regarding a testing branch that holds this new code. There is no dealing with responses yet, I'd rather know if the basic code is a working starting point.

thomasleveil commented 12 years ago

I tested it and made sure it works. 5ee32be made it to the 0.6 release.

Also changed the way the config folder path can be defined in the plugin config. You can now use a path relative to the plugin config file directory.

Further refinements could be to use regular expressions to recognize lines between :