- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Confession: Frist. :tada:
Admin
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....
Admin
Yo dawg...
Admin
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
Admin
As I started looking at the code several phrases came to mind
Admin
Is that
GetState()
method cheap to call? (If it is, why isn't it just aState
property?)Admin
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.....
Admin
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.
Admin
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?
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.
Admin
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) andsave()
, but addingopen()
andclose()
broke the I/O for the whole application and it took me embarrassingly long to figure out why…Admin
Filthy imperative code! Behold the one true C# way!!1!
[spoiler]I may have been doing too much F# lately....[/spoiler]
Admin
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
Admin
The public State property, most likely implemented through a getter, probably calls GetState() any way.
Admin
/me points finger at the screen Huh, yeah that is difficult to do. Why wouldn't LSL have this? Raytracing too hard or something?
Admin
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
Admin
Raytracing is actually pretty easy :P ironically, that product actually uses it for something else.
Admin
+1 for not using intel syntax.