From https://github.com/CRYTEK-CRYENGINE/CRYENGINE/blob/release/C...:
// State flags
enum EGlassRNState
{
EGlassRNState_Initial = 0,
EGlassRNState_Weakened = 1 << 0,
EGlassRNState_Shattering = 1 << 1,
EGlassRNState_Shattered = 1 << 2,
EGlassRNState_ActiveFrags = 1 << 3
};
Als a C# dev, I write Enum flags from time to time, but I always just write out the values; never thought of using bit-shifting to prevent typos :)If you don't care about backward compatibility (i.e. the flags are used internally and never written anywhere), then a better method is actually to grab the value one line above and bit shift it by one. That way you can insert values in the middle and you won't have to change every single line (just two).
#define BIT(nr) (1UL << (nr))
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
#define BITS_TO_TYPE(nr, t) (((nr)+(t)-1)/(t))
type EGlassRNState int
const (
EGlassRNState_Initial EGlassRNState = 1 << iota
EGlassRNState_Weakened
EGlassRNState_Shattering
EGlassRNState_Shattered
EGlassRNState_ActiveFrags
) enum MyEnum
{
MyEnum_Foo = 1 << 0,
MyEnum_Bar = 1 << 1,
MyEnum_Baz = 1 << 2,
MyEnum_Quux = 1 << 4,
MyEnum_Xyzzy = 1 << 8
};
:)From the language spec:
const ( // iota is reset to 0
a = 1 << iota // a == 1
b = 1 << iota // b == 2
c = 3 // c == 3 (iota is not used but still incremented)
d = 1 << iota // d == 8
)Edit: I was mistaken, it still requires manually setting the numbers, it just adds neater ToString support: https://msdn.microsoft.com/en-us/library/system.flagsattribu...
I refactor as soon as my code gets past 3 levels, I don't know how one is supposed to readily understand this block of code.
The lack of comments isn't what troubles me. Comments get old and, when they do, they get completely misleading and downright dangerous. As soon as you feel the need to add a comment, it's often because that particular chunk of code should be extracted into its own function/method/whatever and given an intelligent name. Comments should be reserved for really important stuff, like when the code does something totally non-obvious.
Consder this:
char* p1, p2;
You could erroneously think that char* is a type, and p1 and p2 are variables of that type. That's not correct however, since p1 is indeed char*, but p2 is char. Such declarations therefore should be strongly avoided for clarity.[1]: https://github.com/CRYTEK-CRYENGINE/CRYENGINE/blob/release/C...
What can be the rationale behind writing this [1] ?
[1] https://github.com/CRYTEK-CRYENGINE/CRYENGINE/blob/release/C...
I suppose this is the result of deadlines and lax code reviews.
I think that instead of just linking to the license, they should include a copy of it in the root of the repository and refer to that. It is the proper way to do it.
To me, this is a halfhearted attempt to catch up with Epic and Unreal Engine 4, which has really shown the market how to do things right. I actually look forward to engine updates with UE4, not to mention the increasingly better marketplace content. Also, I am hoping to eventually move over to devving completely on linux...
unity and CryEngine are feeling the hurt, ans struggling to respond.
The coding style is very Microsoft-like, which is I suppose not a big surprise given it's DirectX roots. 8-space tabs seems to be the convention (ugh). They use XML for their readable format (which explains a little their slow load times).
The code itself is not very well documented but relatively clear to understand. Overall not a bad engine to learn a few things from but if you're new to Game Engines a lot of stuff will probably seem very complex (check out BreakableManager.cpp).
It's no Quake 3 in elegance but it's got a lot of advanced functionality (especially in the editor). Overall, it's pretty awesome that they released this. Its a huge gift to everyone that is curious what a world class game engine that has shipped a ton of AAA games looks like.
distribute, sublicense or exploit in any other form: the CryEngine (except for the Redistributables), e.g. as a stand-alone development engine; the CryEngine Documentation; the CryEngine Tools; use the CryEngine for the development of any product other than Games, including without limitation: military projects gambling; simulation (technical, scientific, other); science; architecture; pornography; Serious Games.
Serious Games? did lawyers actually even read this?
https://www.cryengine.com/get-cryengine
I am just wondering how the distribution is, so how many pay 0, how many 10 etc.?
Could imagine that this pricing could lead to higher total revenues than the classical three-prices-page.
(By visiting https://www.cryengine.com/, I found out that it's a game development platform.)
Edit: What I mean is that the implementation of C++ classes seems to be in header files and I'm wondering if this is a common way to do things at game studios.
Found cpp files, but it's interesting that so much of the class implementations are directly in the headers.
Maybe this is their attempt to have the community fix it for them =)