aboutsummaryrefslogtreecommitdiff
path: root/advtrains/models/advtrains_dtrack_vst33.obj
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-01-21 22:41:57 +0100
committerorwell96 <orwell@bleipb.de>2019-01-21 22:41:57 +0100
commitf162ebf63f00339dd1b698c051e7b6301bb2c508 (patch)
tree33da1977e38d69af39d1898b0fc2eb581f7b7945 /advtrains/models/advtrains_dtrack_vst33.obj
parente915b61da6f18efa49b6afacb7e9ca181d59cc5c (diff)
downloadadvtrains-f162ebf63f00339dd1b698c051e7b6301bb2c508.tar.gz
advtrains-f162ebf63f00339dd1b698c051e7b6301bb2c508.tar.bz2
advtrains-f162ebf63f00339dd1b698c051e7b6301bb2c508.zip
Avoid division through zero in get_acceleration
Diffstat (limited to 'advtrains/models/advtrains_dtrack_vst33.obj')
0 files changed, 0 insertions, 0 deletions
='n133' href='#n133'>133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
-- advtrains
-- protection.lua: privileges and rail protection, and some helpers


-- Privileges to control TRAIN DRIVING/COUPLING
minetest.register_privilege("train_operator", {
	description = "Without this privilege, a player can't do anything about trains, neither place or remove them nor drive or couple them (but he can build tracks if he has track_builder)",
	give_to_singleplayer= true,
});

minetest.register_privilege("train_admin", {
	description = "Player may drive, place or remove any trains from/to anywhere, regardless of owner, whitelist or protection",
	give_to_singleplayer= true,
});

-- Privileges to control TRACK BUILDING
minetest.register_privilege("track_builder", {
	description = "Player can place and/or dig rails not protected from him. If he also has protection_bypass, he can place/dig any rails",
	give_to_singleplayer= true,
});

-- Privileges to control OPERATING TURNOUTS/SIGNALS
minetest.register_privilege("railway_operator", {
	description = "Player can operate turnouts and signals not protected from him. If he also has protection_bypass, he can operate any turnouts/signals",
	give_to_singleplayer= true,
});

-- there is a configuration option "allow_build_only_owner". If this is active, a player having track_builder can only build rails and operate signals/turnouts in an area explicitly belonging to him
-- (checked using a dummy player called "*dummy*" (which is not an allowed player name))

--[[
Protection/privilege concept:
Tracks:
	Protected 1 node all around a rail and 4 nodes upward (maybe make this dynamically determined by the rail...)
	if track_builder privilege:
		if not protected from* player:
			if allow_build_only_owner:
				if unprotected:
					deny
			else:
				allow
	deny
Wagons in general:
	Players can only place/destroy wagons if they have train_operator
Wagon driving controls:
	The former seat_access tables are unnecessary, instead there is a whitelist for the driving stands
	on player trying to access a driver stand:
	if is owner or is on whitelist:
		allow
	else:
		deny
Wagon coupling:
	Derived from the privileges for driving stands. The whitelist is shared (and also settable on non-driverstand wagons)
	for each of the two bordering wagons:
		if is owner or is on whitelist:
			allow

*"protected from" means the player is not allowed to do things, while "protected by" means that the player is (one of) the owner(s) of this area

]]--

local boo = minetest.settings:get_bool("advtrains_allow_build_to_owner")


local nocheck
-- Check if the node we are about to check is in the range of a track that is protected from a player
--WARN: true means here that the action is forbidden!
function advtrains.check_track_protection(pos, pname)
	if nocheck or pname=="" then
		return false
	end
	nocheck=true --prevent recursive calls, never check this again if we're already in
	local r, vr = 1, 3
	local nodes = minetest.find_nodes_in_area(
		{x = pos.x - r, y = pos.y - vr, z = pos.z - r},
		{x = pos.x + r, y = pos.y, z = pos.z + r},
		{"group:advtrains_track"})
	for _,npos in ipairs(nodes) do
		if not minetest.check_player_privs(pname, {track_builder = true}) then