• (disco)

    Confession: Frist. :tada:

  • (disco)

    Reminds me of a game I reverse engineered called "Domination" (no, not that kind!) The board was made of buttons. Each button was specifically named so that it could be mapped to a three-dimensional array, which contained the state of said board position, and each button got drawn using custom rendering code (on top of/after the normal rendering).

    If I find it I might post the thing, though I think I only have the executable....

  • (disco) in reply to Tsaukpaetra
    Tsaukpaetra:
    ...a game I reverse engineered...If I find it I might post the thing, though I think I only have the executable....

    Yo dawg...

  • (disco)

    This is horrific.

    I've almost had to do this when building a UI, but I managed to convince the person who'd commissioned me that I could do it infinitely better if I modified his UI design slightly.

    I also just remembered that I did actually do this in one of my other SL products, but there are only three buttons built like it and the rest are sort of like sliders based on their distance from the middle. And there's no rect.contains() in LSL. T_T

  • (disco)

    As I started looking at the code several phrases came to mind

    You are in a Little maze of twisting passages Little maze of twisty passages Little twisty maze of passages Maze of little twisting passages Maze of little twisty passages Maze of twisting little passages Maze of twisty little passages Twisting little maze of passages Twisting maze of little passages Twisty little maze of passages Twisty maze of little passages

  • (disco)

    Is that GetState() method cheap to call? (If it is, why isn't it just a State property?)

  • (disco)

    Yes, nothing like confessions...

    My biggest Doh moment was the result of a function overload and happened some 5 or 6 years ago.

    A few years previously I had made the first version of a data logging and process control system and there I had wanted an error logging functionality. Not wanting to write log_error($errstr)or similar all the time, I just created the function log($str) and was done with it. All worked well for a long time, untill I needed to do some post test processing of some data and hapily importet my god module which contained all my utility functions and what not (Yes that was ALSO a WTF to lump everything in a single module)

    All was well except the calculations was consistently a bit off, not much, just a few percent.

    After days of debugging and trying everything it finally dawned on me that the calculations used the natural logarithm which is implemented as log($var)....

    In my module I also had a log() function (i.e the errorlog function) which also returned a nummeric value (either 1 for success of 0 for failure) and it so happened that the arguments to the logarithm was so that the result of 1 was close to the correct value.... ARGH

    The funny thing is that I never thought to actually look in the error log, as that should only be used for the control part of the system and not for the post test processing..... Had I done that, I would likely had been curious about all those numbers beeing appended to the error log.....

  • (disco)

    This reminds me of some javascript I have on my plate to reverse engineer and debug by end of week. I need to reverse engineer it because nobody is owning up to having written it.

  • (disco) in reply to Fox

    Even if you did have to do this instead of having a rect.Contains(point), wouldn't you want to store all the numbers in an array of some sort and loop over them instead of having 50 long, almost identical lines of code in a row?

    for position in positions { // or however this works in C#, or any other way of iterating over them, sheesh
       if (X > (int)position.xmin*graphicscale && X < (int)position.max*graphicscale &&
           Y > (int)position.ymin*graphicscale &&Y < (int)position.ymax*graphicscale) {
          if (position.figureplacement ==marker_null) { // bonus WTF, 50 null char constants 
             position.figureplacement = marker[playerturn]; //and a bunch of '1' and '2' also
             ++figurecounts[playerturn];
             increment(playerturn);
          }
          break; // Also doing it this way lets you stop looking quicker if they clicked on an occupied space
       }
    }
    

    Of course there would be more code which defined the positions, but it's just a bunch of constants.

    I've written code that starts looking like this, but when I have more than about 5 or 6 of almost the same line in a row I realize that I should be doing it differently.

  • (disco) in reply to Yazeran
    Yazeran:
    In my module I also had a log() function (i.e the errorlog function) which also returned a nummeric value (either 1 for success of 0 for failure) and it so happened that the arguments to the logarithm was so that the result of 1 was close to the correct value.... ARGH

    That reminds me of the time (decades ago) when I created a bunch of icons for the GUI I was working on and wrote a little factory function for each of them that would return the icon when you asked for it. It all worked fine when I dealt with new() (this was plain C) and save(), but adding open() and close() broke the I/O for the whole application and it took me embarrassingly long to figure out why…

  • (disco) in reply to devjoe

    Filthy imperative code! Behold the one true C# way!!1!

    var betweenX = (min, max) => X > (int)min*graphicscale && X < (int)max*graphicscale; 
    var betweenY = (min, max) => Y > (int)min*graphicscale && Y < (int)max*graphicscale; 
    
    var position = positions.Where(p => p.figureplacement != marker_null 
                                        && betweenX(p.xmin, p.xmax) 
                                        && betweenY(p.ymin, p.ymax)).FirstOrDefault();
    if (position != null) {
        position.figureplacement = marker[playerturn]; //and a bunch of '1' and '2' also
        ++figurecounts[playerturn];
        increment(playerturn);
    }
    

    [spoiler]I may have been doing too much F# lately....[/spoiler]

  • (disco) in reply to devjoe

    Well, in my case, a loop wouldn't work because it's not incrementing, but if I'm remembering how I did it, I could probably shorten it by a few dozen lines by applying a bit of extra math before using the position.

    But my version only has... 7 cases, rather than 50ish, so it's not that bad

  • (disco) in reply to dkf

    Is that GetState() method cheap to call? (If it is, why isn't it just a State property

    The public State property, most likely implemented through a getter, probably calls GetState() any way.

  • (disco) in reply to Fox

    /me points finger at the screen Huh, yeah that is difficult to do. Why wouldn't LSL have this? Raytracing too hard or something?

  • (disco) in reply to devjoe
    devjoe:
    when I have more than about 5 or 6 of almost the same line in a row I realize that I should be doing it differently

    Or you're writing assembly and you don't want a bunch of pipeline flushes.

    https://github.com/BenLubar/coolc/blob/4122078b658ac7268f16e1f4c8207a61187d03ad/libcool/basic.s#L442-L522

  • (disco) in reply to Tsaukpaetra

    Raytracing is actually pretty easy :P ironically, that product actually uses it for something else.

  • (disco) in reply to ben_lubar

    +1 for not using intel syntax.

Leave a comment on “Confession: rect.Contains(point)”

Log In or post as a guest

Replying to comment #:

« Return to Article