aboutsummaryrefslogtreecommitdiff
path: root/builtin/privileges.lua
blob: 6cb42c103c2dfe53c4a0ffd7f93a6ce4853a3eb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- Minetest: builtin/privileges.lua

--
-- Privileges
--

minetest.registered_privileges = {}

function minetest.register_privilege(name, param)
	local function fill_defaults(def)
		if def.give_to_singleplayer == nil then
			def.give_to_singleplayer = true
		end
		if def.description == nil then
			def.description = "(no description)"
		end
	end
	local def = {}
	if type(param) == "table" then
		def = param
	else
		def = {description = param}
	end
	fill_defaults(def)
	minetest.registered_privileges[name] = def
end

minetest.register_privilege("interact", "Can interact with things and modify the world")
minetest.register_privilege("teleport", "Can use /teleport command")
minetest.register_privilege("bring", "Can teleport other players")
minetest.register_privilege("settime", "Can use /time")
minetest.register_privilege("privs", "Can modify privileges")
minetest.register_privilege("basic_privs", "Can modify 'shout' and 'interact' privileges")
minetest.register_privilege("server", "Can do server maintenance stuff")
minetest.register_privilege("shout", "Can speak in chat")
minetest.register_privilege("ban", "Can ban and unban players")
minetest.register_privilege("give", "Can use /give and /giveme")
minetest.register_privilege("password", "Can use /setpassword and /clearpassword")
minetest.register_privilege("fly", {
	description = "Can fly using the free_move mode",
	give_to_singleplayer = false,
})
minetest.register_privilege("fast", {
	description = "Can walk fast using the fast_move mode",
	give_to_singleplayer = false,
})


an> int next() { m_next = m_next * 1103515245 + 12345; return((unsigned)(m_next/65536) % 32768); } int range(int min, int max) { if(max-min > 32768/10) { //dstream<<"WARNING: PseudoRandom::range: max > 32767"<<std::endl; assert(0); } if(min > max) { assert(0); return max; } return (next()%(max-min+1))+min; } private: int m_next; }; struct NoiseParams { float offset; float scale; v3f spread; int seed; int octaves; float persist; }; // Convenience macros for getting/setting NoiseParams in Settings #define getNoiseParams(x, y) getStruct((x), "f,f,v3,s32,s32,f", &(y), sizeof(y)) #define setNoiseParams(x, y) setStruct((x), "f,f,v3,s32,s32,f", &(y)) class Noise { public: NoiseParams *np; int seed; int sx; int sy; int sz; float *noisebuf; float *buf; float *result; Noise(NoiseParams *np, int seed, int sx, int sy); Noise(NoiseParams *np, int seed, int sx, int sy, int sz); virtual ~Noise(); virtual void init(NoiseParams *np, int seed, int sx, int sy, int sz); void setSize(int sx, int sy); void setSize(int sx, int sy, int sz); void setSpreadFactor(v3f spread); void setOctaves(int octaves); void resizeNoiseBuf(bool is3d); void gradientMap2D( float x, float y, float step_x, float step_y, int seed); void gradientMap3D( float x, float y, float z, float step_x, float step_y, float step_z, int seed); float *perlinMap2D(float x, float y); float *perlinMap2DModulated(float x, float y, float *persist_map); float *perlinMap3D(float x, float y, float z); void transformNoiseMap(); }; // Return value: -1 ... 1 float noise2d(int x, int y, int seed); float noise3d(int x, int y, int z, int seed); float noise2d_gradient(float x, float y, int seed); float noise3d_gradient(float x, float y, float z, int seed); float noise2d_perlin(float x, float y, int seed, int octaves, float persistence); float noise2d_perlin_abs(float x, float y, int seed, int octaves, float persistence); float noise3d_perlin(float x, float y, float z, int seed, int octaves, float persistence); float noise3d_perlin_abs(float x, float y, float z, int seed, int octaves, float persistence); inline float easeCurve(float t) { return t * t * t * (t * (6.f * t - 15.f) + 10.f); } #define NoisePerlin2D(np, x, y, s) \ ((np)->offset + (np)->scale * noise2d_perlin( \ (float)(x) / (np)->spread.X, \ (float)(y) / (np)->spread.Y, \ (s) + (np)->seed, (np)->octaves, (np)->persist)) #define NoisePerlin2DNoTxfm(np, x, y, s) \ (noise2d_perlin( \ (float)(x) / (np)->spread.X, \ (float)(y) / (np)->spread.Y, \ (s) + (np)->seed, (np)->octaves, (np)->persist)) #define NoisePerlin2DPosOffset(np, x, xoff, y, yoff, s) \ ((np)->offset + (np)->scale * noise2d_perlin( \ (float)(xoff) + (float)(x) / (np)->spread.X, \ (float)(yoff) + (float)(y) / (np)->spread.Y, \ (s) + (np)->seed, (np)->octaves, (np)->persist)) #define NoisePerlin2DNoTxfmPosOffset(np, x, xoff, y, yoff, s) \ (noise2d_perlin( \ (float)(xoff) + (float)(x) / (np)->spread.X, \ (float)(yoff) + (float)(y) / (np)->spread.Y, \ (s) + (np)->seed, (np)->octaves, (np)->persist)) #define NoisePerlin3D(np, x, y, z, s) ((np)->offset + (np)->scale * \ noise3d_perlin((float)(x) / (np)->spread.X, (float)(y) / (np)->spread.Y, \ (float)(z) / (np)->spread.Z, (s) + (np)->seed, (np)->octaves, (np)->persist)) #endif