GithubHelp home page GithubHelp logo

Comments (3)

moritzuehling avatar moritzuehling commented on May 18, 2024

Hey,

you seem to have seen why we can't really just give back the player-objects. The thing is, in Valves internal code there is a new object created when a player connects, so I don't feel like it makes sense if I try to let it survive.

This, coupled with the fact that there's no event raised when a player connects

There is event the possibility that a player leaves the PVS an re-enters it that could lead to a new object - without any game-event.

But this is actually a bug - I currently really don't have the time, but if anyone opens a pull-request to add these events I'd be very willing to accept those. See 44413d8 on how to implement it.

What's the recommended way of dealing with player reconnects?

Aggregate everything by the SteamID. You got, for example, a Dictionary<Player, List<Kill>>? Make it a Dictionary<long, List<Kill>>, and let the key be the SteamID.

You want to check if two Players are equal? Check for their SteamID. If you really want you can override GetHashCode and Equals (and maybe the == operator) to only check if the SteamID equals, then you can check for Player-Equality the way you do now.

from demoinfo.

econoraptor avatar econoraptor commented on May 18, 2024

There is event the possibility that a player leaves the PVS an re-enters it that could lead to a new object - without any game-event.

Are you saying that the connect/disconnect events sometimes aren't raised in the demo or that the parser sometimes doesn't catch them? Also, what does PVS stand for?

I just assumed that it was a conscious decision not to include player connects/disconnects, but it sounds like that's not the case so I'll add them in and make a pull request later tonight.

Aggregate everything by the SteamID. You got, for example, a Dictionary<Player, List>? Make it a Dictionary<long, List>, and let the key be the SteamID.

This was my initial thought, but there would still be a problem in my program of tying to SteamIDs to their Player objects. That's where the connect/disconnect events come in -- I can just modify the dictionary whenever a player connects. An alternative I suppose would be to make a PlayerDict class that wraps the dictionary accessor with a KeyNotFoundException exception handler.

from demoinfo.

moritzuehling avatar moritzuehling commented on May 18, 2024

PVS

The potentially visibile set. It's the players you can possibly see. If they leave and rejoin, it might give a new reference without the player having actually reconnected.

I just assumed that it was a conscious decision not to include player connects/disconnects

Yes, it was. But I see that it was the wrong one.

tying to SteamIDs to their Player objects

Simply try not to do that, even if it's the harder way. If you want to find the player just do a Parser.Players.FirstOrDefault(a => a.SteamID == needle) - at least that's how I handle things.

Sure it's a bit slower, but actually not that slow.

from demoinfo.

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.