Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Another shared memory question - participant array ordering

  1. #1
    GT5 Pilot mr_belowski's Avatar
    Join Date
    May 2015
    Posts
    1,381
    Platform
    PC

    Another shared memory question - participant array ordering

    Ayup folks, got a quick data question. In shared memory there's no indication that the viewed participant is the player. We know which car is being viewed (in race or via the monitor) but we don't know if that car is the player.

    Can we use the ordering of the participants array here? Is the local player always at position 0, even when viewing a different participant?

    The UDP format has an 'isHuman' variable to help with this, but there's no equivalent in shared memory


    For pcars 1 I wrote loads of horrible hacks to try and get the right participant for the player, but I really don't want to do this, and as far as I can see the only alternative is to assume the player is always at position 0
    Crew Chief details here http://forum.projectcarsgame.com/sho...r-for-PC-users
    Website, download link and forum: http://thecrewchief.org
    Or make a donation, if you think the chief needs to drink more beer:
    https://www.paypal.com/cgi-bin/websc...=LW33XFXP4DPZE

  2. #2
    WMD Member daniel_'s Avatar
    Join Date
    Jul 2012
    Posts
    4
    I have the same question. However, for the time being I will stick with the currently viewed player and show his information.

    However, the 'isHuman' - flag. What about multiplayer with AI? Some players will have the flag = true and some don't, right?

  3. #3
    GT5 Pilot mr_belowski's Avatar
    Join Date
    May 2015
    Posts
    1,381
    Platform
    PC
    from the UDP spec:

    unsigned shortsCarIndex; // -- top bit shows if participant is (local or remote) human player or not

    so i guess this isn't enough to identify the participant index of the local player.

    Because Crew Chief builds up the race state (including the player's timing data) over the course of a session, being able to know whether a lap time or whatever is for the player is really important - if the app thinks data from other participants is actually for the player, the internal state gets really screwed up
    Crew Chief details here http://forum.projectcarsgame.com/sho...r-for-PC-users
    Website, download link and forum: http://thecrewchief.org
    Or make a donation, if you think the chief needs to drink more beer:
    https://www.paypal.com/cgi-bin/websc...=LW33XFXP4DPZE

  4. #4
    GT5 Pilot mr_belowski's Avatar
    Join Date
    May 2015
    Posts
    1,381
    Platform
    PC
    Answering my own question here -

    "no" the order of the participants array is *not* consistent and the local player can be at *any* index online. The viewed participant index when you first enter a session is *not* always the same as the local player's viewed participant index - in one example I entered the session and this was '9', and when I clicked Drive it changed to '1'.

    So I have no sensible way to establish who is the local player
    Crew Chief details here http://forum.projectcarsgame.com/sho...r-for-PC-users
    Website, download link and forum: http://thecrewchief.org
    Or make a donation, if you think the chief needs to drink more beer:
    https://www.paypal.com/cgi-bin/websc...=LW33XFXP4DPZE

  5. #5
    GT5 Pilot mr_belowski's Avatar
    Join Date
    May 2015
    Posts
    1,381
    Platform
    PC
    Fingers crossed it gets added to the data output. In the mean time I'm doing this:


    Code:
    int latestGuessAtPlayerIndexInThisSession = -1;
    public static int getPlayerIndex(pCars2APIStruct pCars2APIStruct)
            {
                // we have no idea where in the participants array the local player is.
                // Offline it's generally 0. Online it can be anything. We can't use mViewedParticipantIndex directly here because monitoring other
                // cars will mess up the internal state. mViewedParticipantIndex can be wrong when you first enter a session so we 
                // can't just grab and reuse the first value we get.
                //
                // If we're 'playing' assume we're the player:
                if (pCars2APIStruct.mGameState == (uint) eGameState.GAME_INGAME_PLAYING)
                {
                    latestGuessAtPlayerIndexInThisSession = pCars2APIStruct.mViewedParticipantIndex;
                }
                // if we've never played in this session, return what the game tells us (might be wrong, it's the best we have):
                if (latestGuessAtPlayerIndexInThisSession == -1)
                {
                    return pCars2APIStruct.mViewedParticipantIndex;
                }
                return latestGuessAtPlayerIndexInThisSession;
            }
    Crew Chief details here http://forum.projectcarsgame.com/sho...r-for-PC-users
    Website, download link and forum: http://thecrewchief.org
    Or make a donation, if you think the chief needs to drink more beer:
    https://www.paypal.com/cgi-bin/websc...=LW33XFXP4DPZE
    The following user likes this Post: pablito


  6. #6
    WMD Member daniel_'s Avatar
    Join Date
    Jul 2012
    Posts
    4
    What about asking the player for his name? Should not change that often...

  7. #7
    GT5 Pilot mr_belowski's Avatar
    Join Date
    May 2015
    Posts
    1,381
    Platform
    PC
    i did that in pcars1. The issue here is that the player name may be misspelled, or contain characters that the UDP / shared memory String encoding (<cough> should always be UTF8 <cough>) can't represent. So relying on this is risky
    Crew Chief details here http://forum.projectcarsgame.com/sho...r-for-PC-users
    Website, download link and forum: http://thecrewchief.org
    Or make a donation, if you think the chief needs to drink more beer:
    https://www.paypal.com/cgi-bin/websc...=LW33XFXP4DPZE

  8. #8
    WMD Member daniel_'s Avatar
    Join Date
    Jul 2012
    Posts
    4
    and letting the user choose? Like 'Hey, I found these people, who is you?' And then save this...

  9. #9
    GT5 Pilot mr_belowski's Avatar
    Join Date
    May 2015
    Posts
    1,381
    Platform
    PC
    again, because the game sends the Steam name, and loads of Steam names have non-Latin characters in them, the app will only receive the name text up to the point that the game encounters a character it can't encode in platform-default encoding (Cp1252 for windows I think). All the rest will be truncated
    Crew Chief details here http://forum.projectcarsgame.com/sho...r-for-PC-users
    Website, download link and forum: http://thecrewchief.org
    Or make a donation, if you think the chief needs to drink more beer:
    https://www.paypal.com/cgi-bin/websc...=LW33XFXP4DPZE

  10. #10
    WMD Member daniel_'s Avatar
    Join Date
    Jul 2012
    Posts
    4
    ok, I see. "Please click here if you are watching yourself" - I get your point. Let's see how I will have to treat this.
    Last edited by daniel_; 01-11-2017 at 12:11.

Similar Threads

  1. [HowTo] Shared Memory (API) App
    By Lars Rosenquist in forum Third-Party Apps & API Discussion
    Replies: 53
    Last Post: 09-03-2017, 13:56
  2. Use Shared Memory ON = no internet connection
    By slimzlim in forum PC - Technical Help & Support
    Replies: 12
    Last Post: 09-08-2016, 23:27
  3. Getting Shared Memory Data mCarFlags
    By hophans in forum Third-Party Apps & API Discussion
    Replies: 4
    Last Post: 09-05-2016, 15:04
  4. Shared Memory On/Off Hotkey...
    By townnet in forum General Discussion
    Replies: 2
    Last Post: 06-07-2015, 03:52
  5. [ANSWERED] what its shared memory
    By Chanur in forum PC - Technical Help & Support
    Replies: 7
    Last Post: 08-05-2015, 21:34

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •