limit the range of certain entity attributes
For example, direction angle values can be reduced to +- 360 degree. (0..360 would be sufficient, but some people like their angles negative) This is not a reduction of functionality or a security measure - it's for convenience only: values now wrap around at the borders of their useful ranges.
This commit is contained in:
@@ -662,3 +662,22 @@ void syncentchanges(bool force)
|
||||
changedents.setsize(0);
|
||||
lastentsync = lastmillis;
|
||||
}
|
||||
|
||||
void clampentityattributes(persistent_entity &e)
|
||||
{
|
||||
if(e.type < MAXENTTYPES)
|
||||
{
|
||||
int c;
|
||||
#define CLAMPATTR(x) \
|
||||
c = entwraparound[e.type][x - 1]; \
|
||||
if(c > 0) e.attr##x = (e.attr##x % c + c) % c; /* fold value into range 0..c */ \
|
||||
else if(c < 0) e.attr##x = e.attr##x % (-c) /* fold value into range -c..c */
|
||||
CLAMPATTR(1);
|
||||
CLAMPATTR(2);
|
||||
CLAMPATTR(3);
|
||||
CLAMPATTR(4);
|
||||
CLAMPATTR(5);
|
||||
CLAMPATTR(6);
|
||||
CLAMPATTR(7);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user