Development > Newbie Coding
computing surface- and contentflags
ShipIt:
What should be my general approach when I try to find out if a certain flag is set, based on the number given in the .map file?
So, if the value for surfaceflags given in the .map file is 24059. How do I know whether the flag for 'light' (1) is set or not?
Right now I am using a quite excessive method:subtract the highest value and check the result, next value, ... for each single value down from high to low. Somehow I have the feeling there should be an easier way.
DarkRain:
Open your windows calculator, set it to scientific mode, then you can use the 'and' operator on the surface flags and the value for the flag you are checking (like: 24059 'and' 1), if the result is the flag's value (in this case 1) then the flag is set, if it is zero then the flag is not set.
ShipIt:
Somehow I missed the reply. Sorry and thank you.
What I am looking for is a way to do that in a script. Is there a name for this kind of encoding that I could ask my favourite www-search-engine for? Or an easy way to do this in ..., well ..., let's say ..., Python? :-[
Mattn:
bit operations. especially the logical and and the right shifting for the level flags.
ShipIt:
So surfaceflags is 'bitwise and' ?
Navigation
[0] Message Index
[#] Next page
Go to full version