Cubitect / cubiomes

C library that mimics the Minecraft biome generation.
MIT License
556 stars 98 forks source link

Idea: Demark enumerated types in layers.c with "SP_" (or the like) to prevent accidental references. #95

Closed Nel-S closed 1 year ago

Nel-S commented 1 year ago

Currently layers.c at one point enumerates the names CONTINENTALNESS, EROSION, RIDGES, WEIRDNESS for, from what I can tell, usage in the context of splines alone (specifically specifying their type and subsequently retrieving it with getSpline). But I personally feel the names by themselves are vague enough that someone writing a climates-oriented program could potentially reference them by accident outside of that specific context, and subsequently obtain unexpected values (perhaps by confusing them with NP_CONTINENTALESS, etc.--or in my case, I attempted to enumerate the climate values to use as flags, only to receive a collision and a compiler error). I was personally envisioning prepending each of those types with SP_ or SPL_ to prevent that, but that might be too similar to the aforementioned NP_-enumerations--and given I don't work with splines in my code this might not even be a problem (or the enumerated values' usages might be widespread enough for this to cause more problems than it solves), hence why I decided to add this here instead of in a pull request.

Cubitect commented 1 year ago

I would have thought the collisions shouldn't matter, since the enum is only locally scoped to the source file. However, using more specialized names is sensible.