Changing slot_id in shared memory driver data

Discussion in 'Community Workshop' started by mr_belowski, Nov 7, 2015.

  1. mr_belowski

    mr_belowski Well-Known Member Beta tester

    Joined:
    Apr 23, 2015
    Ratings:
    +1,286 / 0
    Hey chaps,

    I might be losing my marbles here, but I'm seeing cases where the slot_id allocated to drivers (driver_data.driver_info.slot_id) changes in the shared memory.

    Say you have 3 opponent drivers in an online race, using slots 1 to 3. If the driver at slot 1 disconnects, the slot_id values for the remaining 2 opponents get updated to 1 and 2. I've been expecting these to be constant, so in this case the remaining opponents slot_ids would still be 2 and 3, and there would be no one with slot_id 1.

    What are the rules here? Are slot_ids reused and changed mid session? I know the array gets reordered but that's not an issue.

    Having these slot_ids change mid-session is really awkward. I have to use driver names to check if the slot_ids have been changed, but names aren't unique and in some series a car might change driver.

    I'll work around it at my end, but it'd be nice to know exactly what the game does with these
     
  2. Christian Göpfert

    Christian Göpfert Topological Agitator Beta tester

    Joined:
    Apr 8, 2015
    Ratings:
    +2,197 / 0
    Mikkael or or somebody else from dev definitely knows for sure, but I think I remember it being the way you described, slot 1 remaining empty when the user leaves, but that caused some bugs so it had to be changed.
     
  3. mr_belowski

    mr_belowski Well-Known Member Beta tester

    Joined:
    Apr 23, 2015
    Ratings:
    +1,286 / 0
    Thanks for the info. Like I said, I can work around it but there'll be some edge cases where my app will get confused
     
  4. mr_belowski

    mr_belowski Well-Known Member Beta tester

    Joined:
    Apr 23, 2015
    Ratings:
    +1,286 / 0
    Hmm... the behaviour here is really grotty.

    Here's some debug showing how the game has assigned slots:

    to start with we had:

    17:47:36.093 : Slot 0 name = Günther Willers
    17:47:36.085 : Slot 1 name = Jasper Blomqvist
    17:47:36.078 : Slot 2 name = Tine Raspou
    17:47:36.099 : Slot 3 name = Franz Meersdonk
    17:47:36.107 : Slot 4 name = René Rohde
    17:47:36.114 : Slot 5 name = Tim Ullrich
    17:47:36.122 : Slot 6 name = Larry Henry
    17:47:36.130 : Slot 7 name = Echse Leguan
    [slot 8: me]
    17:47:36.137 : Slot 9 name = Easter Vomit


    the some time later:

    17:51:16.930 : Slot 0 name = Günther Willers
    17:51:16.860 : Slot 0 name = Franz Meersdonk
    17:51:16.880 : Slot 1 name = Jasper Blomqvist
    17:51:16.870 : Slot 2 name = Tine Raspou
    17:51:16.890 : Slot 3 name = Deni Kremer
    17:51:16.900 : Slot 4 name = René Rohde
    17:51:16.900 : Slot 5 name = Tim Ullrich
    17:51:16.910 : Slot 6 name = Larry Henry
    [slot 8: me]
    17:51:16.920 : Slot 7 name = Echse Leguan


    and then after a minute of the above data,:

    17:51:16.970 : Slot 0 name = Franz Meersdonk
    17:51:16.980 : Slot 1 name = Jasper Blomqvist
    17:51:16.970 : Slot 2 name = Tine Raspou
    17:51:16.990 : Slot 3 name = Deni Kremer
    17:51:17.000 : Slot 4 name = René Rohde
    17:51:17.010 : Slot 5 name = Tim Ullrich
    17:51:17.010 : Slot 6 name = Larry Henry
    17:51:17.020 : Slot 7 name = Echse Leguan
    [slot 8: me]
    17:51:17.030 : Slot 9 name = Easter Vomit

    the debug log times are all close together because I'm replaying some recorded data captured while I raced, without any pause between 'ticks'.

    Given that names are not unique, I'm struggling to see what I can sensibly do with this kind of data to track what the opponents are doing in race :(
     
    Last edited: Nov 7, 2015
  5. mr_belowski

    mr_belowski Well-Known Member Beta tester

    Joined:
    Apr 23, 2015
    Ratings:
    +1,286 / 0
    For each opponent driver name, if this name appears more than once in the set, append the slot_id to it. Then track opponent drivers by their name or their name + slot_id.

    This will *only* work if the driver names are unique (i guess / hope this is the case online) OR the slot_ids never change (against the AI, again fingers crossed).

    All rather flaky and annoying
     
  6. mr_belowski

    mr_belowski Well-Known Member Beta tester

    Joined:
    Apr 23, 2015
    Ratings:
    +1,286 / 0
    Wow... having looked deeper into this, I see a big big mess.

    Sometimes there are duplicate entries - the same driver name with the same slot_id is in the array more than once. Sometimes a driver is missing from the array entirely, only for him to reappear some time later. Sometimes a driver appears twice in the array with the same name, but a different slot_id.

    If they're missing from the array I can't remove them from my game state, because they might reappear. If they appear twice with the same slot_id, which is the most current? If they appear twice with different slot_ids, which is correct? If they appear twice, how do I know if the second version is an incorrect duplicate, or a proper driver who has the same name? (e.g. racing the AI there are sometimes duplicate driver names).

    It looks like I'm ranting here, and I suppose I am. I'm cutting huge amounts of awful code to try and work around this issue and it's burning all my time that should be spent fixing other stuff :(
     
  7. mr_belowski

    mr_belowski Well-Known Member Beta tester

    Joined:
    Apr 23, 2015
    Ratings:
    +1,286 / 0
    Bugger it. I'm going to track opponents by their name only and completely ignore the slot_id. This means it's going to behave really badly when you have multiple opponents with the same name in the race. When the game sends the driver data array, my app will only add drivers for each unique driver names then ignore any entries which have names that it's already added in that 'tick'. The spotter and some other bits will be OK, but stuff about position changes, race leader, who's pitting, opponent lap times, lap & sector deltas, stuff like that will be messed up.

    I also have to remove the pruning so my app no longer removes inactive drivers because a driver not appearing in the drivers array doesn't necessarily mean he's left the race - he might reappear a tenth of a second later.

    So a big "known issue" with Crew Chief is it won't work properly with duplicate driver names - no more fields of 20 AI Hill Climb Icons cars :(.

    "What's wrong with the current code?" you might ask... Well it occasionally sees lead changes that don't really exist, prevents the gap messages playing as often as they should because the car in front / behind has changed slot_id, tells you some one's leading when they're not, gives incorrect opponent lap times, and other weird things where it just plain gets things wrong. Stuff that's had me looking for bugs in the wrong places quite a lot recently
     
  8. Christian Göpfert

    Christian Göpfert Topological Agitator Beta tester

    Joined:
    Apr 8, 2015
    Ratings:
    +2,197 / 0
    Yeah, that sounds a bit messy. As I don't really have a clue or the inside view I can't really say anything useful right now, but I'm pretty sure Mikkael or Robert will read this come next week and maybe comment on how things are and whether they are planning to improving them.
     
  9. pixeljetstream

    pixeljetstream Well-Known Member Beta tester

    Joined:
    Jan 29, 2015
    Ratings:
    +371 / 0
    A unique driver ID/hash must exist (and if it's just the raw pointer value or so hehe), would be good to have that.
     
  10. Stefan Mizzi

    Stefan Mizzi Well-Known Member

    Joined:
    Feb 6, 2015
    Ratings:
    +615 / 0
    Hopefully they will check it out when they are back from the holidays :) I'm not going to use driver names and hopefully wait for a fix with the slot Id.

    I can confirm that Jim's findings about how the slot Id changes , duplicate records etc are all correct.

    Wish I could release my latest results app, but this issue is holding it back from public release.