Comments (9)
Near as I can tell, all this junk is being used in stuff having to do with pixel values R G B and Alpha. The idea is to do some of the math in a fixed-point representation where we have an int32_t holding a 24 bits left of the decimal and 8 bits to the right. Of course, it's sorta lame to be doing signed math on unsigned values, but whatever. Most of the uses are creating the values 0x00000000 and 0x00000100 (0.0 and 1.0).
In at least one place, the int32_t value is stored in an int16_t so I hope whoever did that made very sure to avoid any implicit sign extension errors.
Is this a code smell? Yes.
Is it screaming to be fixed? No. It doesn't seem to be causing any problems.
Is it premature optimization? Probably. But, considering where it's used, in the few places it actually does anything, it's probably actually speeding things up enough to be warranted.
My recommendation would be to hold our noses, leave things as they are and put the entire src/utils/math.hpp file on the list of good projects for a new programmer to work on because it's probably not causing issues, but it's just asking for cleanup and/or elimination.
from wesnoth.
Can this be closed?
- the OP is from 2005
- there is no src/utils.hpp any more.
- src/display.cpp has no display::draw_bar any more.
from wesnoth.
I seem to recall those macros being removed, as well.
from wesnoth.
These macros still exist:
Lines 312 to 335 in d78ed1c
And they are still being used by scale_surface()
.
from wesnoth.
Ah, okay. Well, presumably we can just remove the #if
and stuff, then. I think changing it ti #if 1
satisfied the issue though.
from wesnoth.
Um. WTF? We seriously were doing a de-normalizing floating-point implementation? What, did one of the target machines lack a working floating-point unit?
I'd strongly suggest change #if 1
to #if 0
, debug, then reduce until the macros meet their long-overdue demise.
from wesnoth.
I believe one of the target machines actually did lack a floating-point unit - OpenPandora possibly? Support for that has been dropped now, though.
from wesnoth.
My guess would be that the fixed-point implementation is used for performance.
from wesnoth.
Well, take the junk out and see if the game crawls.
While I agree, it's possible someone's attempt at an optimization, but if so it smells highly of premature optimization. I'd want a comment block with A/B test results proving a significant improvement. Otherwise, this is just an obscure way to hide basic errors.
from wesnoth.
Related Issues (20)
- Status icons are rendered deformed (poisoned, slowed, petrified) HOT 15
- [Units] [1.19.0] Give Firebomb Ant its `explode` ability HOT 1
- Update xBRZ to latest version HOT 7
- Implement an asset redirector system HOT 2
- SoF S6 - opening dialog HOT 2
- Visual Bug: some cured units look poisoned until mouse hover over them HOT 2
- Errors (to terminal) when opening addons menu in 1.17 HOT 5
- Make wmllint not write files by default HOT 2
- [Units] `movement_type=lightfly` in Raven unit tree does not recognize assigned `[defense]` tag. HOT 4
- [NR] [The Pursuit] Abhai should not trigger moveto event meant for human/dwarf units HOT 3
- Deprecate [campaign]rank= in favour of a reference-based ordering HOT 1
- missing_mandatory_wml_key forces too many square brackets
- Nym, Kaleh, and Zhul have odd interactions with poison and deydration in UtBS
- Provide require_scenario equivalent for [resource] HOT 1
- During enemy turns on Android, the main game map interface shakes or jitters when enemy characters move. HOT 2
- [Terrain Graphics] Dwarven Underground Castle to Dry Mountain Transition looks non-existent
- GCC-13's -Wdangling-reference HOT 2
- [UI] Side bar Unit Image is no longer centered
- [NR] [07a - Settling Disputes] possibility of getting the scenario unwinnable early due to Gryphon rush HOT 4
- [NR][HttT][other?] capitalization of artifact names (Sceptre of Fire, Rod of Justice etc.) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wesnoth.