Ejemplo n.º 1
0
/**
 * Scales the given value by the maps circumference, where the given
 * value is for a 256 by 256 map
 * @param n the value to scale
 * @return the scaled size
 */
//inline
        public static uint ScaleByMapSize1D(uint n)
        {
            /* Normal circumference for the X+Y is 256+256 = 1<<9
             * Note, not actually taking the full circumference into account,
             * just half of it. */
            return(MathFuncs.CeilDiv((n << (int)MapLogX()) + (n << (int)MapLogY()), 1 << 9));
        }
Ejemplo n.º 2
0
/**
 * Scales the given value by the map size, where the given value is
 * for a 256 by 256 map.
 * @param n the value to scale
 * @return the scaled size
 */
//inline
        public static uint ScaleByMapSize(uint n)
        {
            /* Subtract 12 from shift in order to prevent integer overflow
             * for large values of n. It's safe since the min mapsize is 64x64. */
            return(MathFuncs.CeilDiv(n << (int)(MapLogX() + MapLogY() - 12), 1 << 4));
        }