1. Forum moved (you can use login and pass from old forum)
  2. Many discussions moved to the bugtracker

Battlescape progress and questions

Discussion in 'Coding' started by Istrebitel, Aug 26, 2016.

  1. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    84
    Best Answers:
    1
    Another thing:

    Apparently, our rng is quite bad at generating number from 1 to 3. When doing randBoundsInclusive 1-3 it very rarely generates 2's. Only 1's and 3's. I had to use Exclusive(10,40)/10 to substitute for now, but I think we'd rather fix it properly?
     
    makus likes this.
  2. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    84
    Best Answers:
    1
    And another:

    Do we have means to track playing sound? Or real time? Because I need to loop the fire sound. Right now I'm tracking ticks in update() method of the GUI, assuming it will be 60 per second, but when it lags, this means audio stops playing for a while. If I could somehow track whether a sound stopped playing, or real system time, that could be done in a better way.
     
    makus likes this.
  3. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    84
    Best Answers:
    1
    Aaaand another:

    It seems buttons misbehave still to this moment. If you hold mouse down on button and drag away, it stays pressed in and won't depress. It didn't happen before.
     
    makus likes this.
  4. JonnyH

    JonnyH Well-Known Member Official Developer Administrator

    Joined:
    Jul 17, 2014
    Messages:
    185
    Likes Received:
    39
    Best Answers:
    0
    This specific issue seems to be the 'using OpenApoc;' in test_serialize.cpp causes the 'operator==' for sp<T> to be pulled in, which msvc then appears to select in preference to a specialised operator== for std::shared_ptr<SomeTypeInItsSystemThreadLibrary> - causing this problem.

    I had a crack at solving it (on top of my msvc2017 work, as that's what I had installed) here https://github.com/JonnyH/OpenApoc/commit/696f5038e1fb177c5a0930fbbbba0189b8a9375b#diff-4d386dc9cd978980afba9d797f53f83f - Ignore all the msvc build stuff, the code should work however.

    I don't know why this affects msvc, possible as it (still) doesn't properly implement two-phase template type lookup?
     
    makus likes this.
  5. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    84
    Best Answers:
    1
    Unfortuately this doesn't help. Now I have like 50 unresolved externals - for SDL functions and our functions. IDK what's wrong with it.

    I'll compile list of pressing issues:
    1) Radiobuttons misbehaving (can click pressed radiobutton to make it depressed and then no radiobutton in group is pressed at all)
    2) Buttons misbehaving (can hold mouse down on button and drag away, button stays in "pressed" visual state)
    3) Need to handle looped sounds. For example, fire sound must loop, and every new loop must have volume adjusted to current position of fire.
    4) Confirm I've properly fixed our sound conversion routine in the framework
    5) Why do we consider sounds to be 22050? Fire is 11025, maybe other sounds?
     
    makus likes this.
  6. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    84
    Best Answers:
    1
    And also, I'm getting weird failures on travis. Could you see what's wrong here? https://travis-ci.org/Istrebitel/OpenApoc
     
    makus likes this.
  7. JonnyH

    JonnyH Well-Known Member Official Developer Administrator

    Joined:
    Jul 17, 2014
    Messages:
    185
    Likes Received:
    39
    Best Answers:
    0
    Hopefully the code for test_serialise works. I think the sdl issues are due to the nuget sdl package having been built against msvc 2015 and I was testing on 2017.

    I'll hopefully be able to look at the others later today.
     
    makus likes this.
  8. JonnyH

    JonnyH Well-Known Member Official Developer Administrator

    Joined:
    Jul 17, 2014
    Messages:
    185
    Likes Received:
    39
    Best Answers:
    0
    I rebased that test_serialize.cpp fix on top of master - no more msvc2017 sdl issues - though you might have to re-apply any changes you made to test_serialize.cpp in your branch - https://github.com/pmprog/OpenApoc/commit/788fc3c7c29398f9c9d2e0932d6eb532eda3791b

    1) Should be fixed https://github.com/pmprog/OpenApoc/commit/21b7423f335be9e697f0d39376f201bcf4dc4ba1
    2) Should be fixed https://github.com/pmprog/OpenApoc/commit/40ef826453b35495b4324138a65574d153844335
    3) I'll have to look into this - so far the assumption is that SFX are one-shot, but this would be a change to that (IE you need some kind of reference to use to notify it when it needs to stop) - or if there are performance issues involved (e.g. trying to mix 5000 instances of the 'fire' sound would likely blow up your headphones as well as tank performance)
    4) Should we really be using the 'len_mult' value from SDL_AudioCVT for calculating the needed size of the buffer? We could rework this so the output buffer isn't allocated until after SDL_BuiltAudioCVT, and as that's the value SDL provided it's less likely to disagree with their own SDL_ConvertAudio() call?
    5) There appears to be a big table of sound effects -> samplerate (and other metadata) - I wrote a quick reader in tools/extractors/common/audio.h but nothing actually uses it. I've just been appending :22050 to the resource manually, as it happened to be that was what all the sfx files I have needed so far was used. Does that table contain the incorrect information for the sfx files involved? Do we handle the files correctly by appending :11025?
     
    makus likes this.
  9. JonnyH

    JonnyH Well-Known Member Official Developer Administrator

    Joined:
    Jul 17, 2014
    Messages:
    185
    Likes Received:
    39
    Best Answers:
    0
    4) I had a go at implementing this:
    https://github.com/pmprog/OpenApoc/commit/a8a807a149410555ce8abcc29e09ce0796bd4b4e

    Please let me know if this doesn't solve the issues. It feels more correct than trying to recalculate something sdl is effectively already providing for us.
     
    makus likes this.
  10. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    84
    Best Answers:
    1
    Yeah, your sound solution is more elegant than mine, thanks.

    On test_serialize, it now only complains about 42 SDL_xyz functions being unresolved. How do I fix that?
     
    makus likes this.
  11. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    84
    Best Answers:
    1
    Also, Travis now for some reason fails the test: https://travis-ci.org/Istrebitel/OpenApoc
    It says animation pack unit does not exist. What could be the problem? It should all work, well, at least when I run the game the pack is present, as it is present in the xml files
     
    makus likes this.
  12. JonnyH

    JonnyH Well-Known Member Official Developer Administrator

    Joined:
    Jul 17, 2014
    Messages:
    185
    Likes Received:
    39
    Best Answers:
    0
    That likely means the sdl nuget package needs to be added to that project - I can't remember if it propagates through Framework (the library that actually uses sdl) when used in MSVC or if you need to add it for every executable that's linked.

    I think I had this issue on msvc2017 a well, as the sdl nuget only seems to have a version built for msvc2015 right now (or some other behaviour difference that causes a similar issue when using 2017, I haven't really dug too deep into that)
     
    makus likes this.
  13. JonnyH

    JonnyH Well-Known Member Official Developer Administrator

    Joined:
    Jul 17, 2014
    Messages:
    185
    Likes Received:
    39
    Best Answers:
    0
    The latest failure (f78f838) is due to the generated OpenApoc::serializeIn(OpenApoc::GameState const*, std::shared_ptr<OpenApoc::SerializationNode>, OpenApoc::TacticalAI::Type&) being used in gamestate_serialize.cpp, but currently all the generated serializeIn/serializeOut symbols are marked 'inline' in the generation tool, which explicitly marks them as not to generate symbols visible to objects outside that compilation unit.

    It happened to be that before this change all 'custom' serialise functions were either at the top of the tree, or a template (and thus generated for every compilation unit). I guess we'll just have to remove the 'inline' attribute from these functions in the serialisation generator and cope with the large number of extra symbols it will expose.

    It's kinda weird msvc doesn't fail - maybe it just doesn't honour the 'inline' attribute?

    *EDIT*
    The generated code for serialisation objects allow a 'external' flag to be set in the xml to stop them being inlined, but enums right now do not. I don't know if it'll be best to add that option to enums too, and piecemeal mark them as 'external', or just stop all generated symbols being inlined.
     
    makus likes this.
  14. JonnyH

    JonnyH Well-Known Member Official Developer Administrator

    Joined:
    Jul 17, 2014
    Messages:
    185
    Likes Received:
    39
    Best Answers:
    0
    BTW I too get "E 9033284585 static OpenApoc::sp<OpenApoc::BattleUnitAnimationPack> OpenApoc::BattleUnitAnimationPack::get(const OpenApoc::GameState&, const OpenApoc::UString&): No BattleUnitAnimationPack matching ID "BATTLEUNITIANIMATIONPACK_unit"" when trying to start a battlescape game on linux on my local build.

    Perhaps it's a filesystem case issue? If we're reading the name of something back from the FS? Or an extractor stage that hasn't been added to the linux build system?

    I'm currently in an airport just about to go on holiday, doubt I can really look into it for a couple of days at least ;)
     
    makus likes this.
  15. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    84
    Best Answers:
    1
    Oh, it's fine, enjoy your holiday. I will have to go without Travis for some days then. I guess we should introduce external for enums, instead of everything. We just need to have external for those enums used in superclass serializations.
     
  16. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    84
    Best Answers:
    1
    JonnyH, when you have time, please check our slider control. It seems to bug out. You can test it, for example, with priming explosives in battlescape (you will have to kill a dude with a pistol, which is instakill, then pick up and drop his gear using "drop" button in paused mode until you pickup an explosive). The problem is that leftmost position is not minimum value. It's some other value, but not minimum. Minimum is the second leftmost position. You can see it because it says "delay = 0" when leftmost (which is rounded so it's not actually 0) and "activates now" when one step to the right (which is shown if delay actually = 0).

    Also, on topic of throwing interface, we need to change "Delay = %i" string, it should take a float, not an int, and it should have "s" in the end. (for seconds)
     
    makus likes this.
  17. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    84
    Best Answers:
    1
    So to sum it up, JonnyH, list of what I'm waiting on:
    - Our rng is bad with small numbers. Generating like 1 of 2 or 1 of 3 very frequently gives on number and hardly others. Have to generate in ranges of 10's and divide to work around, but maybe fix the generator instead?
    - Our scrollbar is buggy (when you reach left edge then go right, it bugs out somehow, evident when priming explosives)
    - We need a tooltip functionality (for showing attack TUs and for showing pose change / item use costs)
    - Agent inventory
     
    makus likes this.
  18. JonnyH

    JonnyH Well-Known Member Official Developer Administrator

    Joined:
    Jul 17, 2014
    Messages:
    185
    Likes Received:
    39
    Best Answers:
    0
    I've been looking at this, I added a quick test to test_rng that runs a number of randBoundsExclusive(0,4) and counts the number of each value returned:

    Linux x86_64 gcc 6.3.0:
    RNG buckets:
    0: 113092
    1: 136907
    2: 119049
    3: 130952

    windows x64 and win32 msvc2015:
    0: 101193
    1: 127974
    2: 142856
    3: 127977

    The diffences are due to the different std::uniform_int_distribution implementations, but both look even 'enough' to handwave the differences away as random noise, and no obvious bias.

    The code is here: https://github.com/JonnyH/OpenApoc/commit/28fae6ce3d727728106768797cf2c4dec3189f0e

    Is there anything I'm missing? Or we're doing differently?

    EDIT:


    But that is quite a large amount of handwaving...

    I looked a bit deeper and realised that using result_type for the internal state is a problem with the default shift values if it's not 64-bit too:

    For example, setting A=23 means the "s1 << A" effectively loses all but (32-23)=9 bits of entropy, which *is* causing a bias.

    I changed it to *always* use uint64_t as it's internal state, and only clamp to result_type at output time. This results in a more even distribution through the same test_rng code (linux x86_64 gcc 6.3.0):

    0: 125036
    1: 124984
    2: 124954
    3: 125026

    https://github.com/JonnyH/OpenApoc/commit/a06a4dc18191a1cc9b97a17382db4c4645116043

    Hopefully that'll make your rng use more 'random' :)
     
    Last edited: Mar 28, 2017
    makus likes this.
  19. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    84
    Best Answers:
    1
    Nice! I also forgot something, tooltips for attack TU are not done in the same way as tooltips for other things. Also, while coding inventory, would it be possible to also implement squad members display, at least their health and shield, copying cityscape?

    So, updated list:
    - Our scrollbar is buggy (when you reach left edge then go right, it bugs out somehow, evident when priming explosives)
    - We need a tooltip functionality (for showing pose change / item use costs and button tooltips)
    - Agent inventory, based on city's Vehicle inventory
    - Unit portraits with shield/health bars on battlescape screen, based on city's vehicles
     
    makus likes this.
  20. JonnyH

    JonnyH Well-Known Member Official Developer Administrator

    Joined:
    Jul 17, 2014
    Messages:
    185
    Likes Received:
    39
    Best Answers:
    0
    I think this was due to the 'scrollbar value changed' event (and therefore callbacks) being emitted before the Value member was actaully changed, so it was using the previous value when setting the "Delay"/"Activating Now" text. Hopefully fixed by this:

    https://github.com/pmprog/OpenApoc/commit/ca341ab6a05decac2ec1e361ad04233bc3005dce
     

Share This Page