Add enable_pvp setting
authorPerttu Ahola <celeron55@gmail.com>
Fri, 2 Dec 2011 09:25:47 +0000 (11:25 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Fri, 2 Dec 2011 09:25:47 +0000 (11:25 +0200)
minetest.conf.example
src/defaultsettings.cpp
src/serverremoteplayer.cpp

index cf27acfac1a05bdeffd75dac2670a85a6005935c..83519e145d610cd541c648da47ed58485411de1a 100644 (file)
 #default_privs = build, shout
 # Whether players are transferred to client without any range limit
 #unlimited_player_transfer_distance = true
+# Whether to enable players killing each other
+#enable_pvp = true
 
 # Profiler data print interval. #0 = disable.
 #profiler_print_interval = 0
index be63fb8706b766d10f4977aadc13576593d9c1e5..1e48183fa028a537e6cc7a62faf539b799b616e5 100644 (file)
@@ -94,6 +94,7 @@ void set_default_settings(Settings *settings)
        settings->setDefault("default_password", "");
        settings->setDefault("default_privs", "build, shout");
        settings->setDefault("unlimited_player_transfer_distance", "true");
+       settings->setDefault("enable_pvp", "true");
 
        settings->setDefault("profiler_print_interval", "0");
        settings->setDefault("enable_mapgen_debug_info", "false");
index bff414e1a96756dce77e5b35502e81441bf0a85e..900cc54329466e6cb32048c3205a0cf636a896ca 100644 (file)
@@ -139,6 +139,12 @@ void ServerRemotePlayer::punch(ServerActiveObject *puncher,
        if(!puncher)
                return;
        
+       // No effect if PvP disabled
+       if(g_settings->getBool("enable_pvp") == false){
+               if(puncher->getType() == ACTIVEOBJECT_TYPE_PLAYER)
+                       return;
+       }
+       
        // "Material" properties of a player
        MaterialProperties mp;
        mp.diggability = DIGGABLE_NORMAL;