Giter VIP home page Giter VIP logo

Comments (4)

thomasleveil avatar thomasleveil commented on August 16, 2024

Although send a rcon request to the Frostbite(2) engine for each player is not a traffic issue, this rcon spaming can be with Q3 game engine which usually support only 2 queries per second.

I wanted getPlayerPings() to expand the parameters client_ids = None so that we can pass a list of client id's. This should be done for all parser and would also make it a lot broken. So rather a bad idea.

It is a good idea IMHO as adding an optional parameter would make this change backward compatible.

Current signature is

    def getPlayerPings(self):
        """\
        returns a dict having players' id for keys and players' ping for values
        """
        # TODO implementation

I would then see :

    def getPlayerPings(self, filter_client_id=None):
        """\
        returns a dict having players' id for keys and players' ping for values.
        If filter_client_id is an iterable, only return values for the given client ids.
        """
        # TODO implementation

Any pull request for such a change is welcome :)

Therefore I would suggest that parsers implement getPlayerPing(player_id)

This change would break backward compatibility and break 3rd party plugins.

or even better, the client get an attribute with the name 'ping' (which would still include a getPlayerPing).

This would make the ping info closer to the client but I'm afraid that if more and more code from both the B3 core and plugins start to use the Client.ping this will force one rcon query per client, but for some game this can be a lot more expensive than making one rcon call which returns all player pings at once.

If a game parser needs to address this issue for a particular game, it would have to monkey patch the Client.ping attribute getter implementation ; while if we keep the ping info access only from the getPlayerPing parser method, we let game specific implementation tuning where it belongs : the game parser.

Do you see what I mean with that point ?

from big-brother-bot.

ozon avatar ozon commented on August 16, 2024

Thanks for your remarks.
Currently, I have implemented the following for test:

def getPlayerPings(self, client_ids=None):
    """Ask the server for a given client's pings
    :param clients_id: list of client ids
    """
    pings = {}
    if not client_ids:
        client_ids = [client.cid for client in self.clients.getList()]

    for cid in client_ids:
        try:
            words = self.write(("player.ping", cid))
            pings[cid] = int(words[0])
        except ValueError:
            pass
        except Exception, err:
            self.error("could not get ping info for player %s: %s" % (cid, err), exc_info=err)
    return pings

from big-brother-bot.

thomasleveil avatar thomasleveil commented on August 16, 2024

That's for BF3 isn't it ?
Would you mind renaming client_ids to filter_client_ids in your pull requests and also update the B3 core parser.py file with the new signature ?

from big-brother-bot.

ozon avatar ozon commented on August 16, 2024

That's for BF3 isn't it ?

You know my games ;)

I make the update and pull request soon.

from big-brother-bot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.