Server patche

Základní git commit minetestserveru je

commit 382357d61cde9d6d1b3cb94053ab1127db9d5462
Author: proller <proller@github.com>
Date:   Fri Oct 18 21:56:34 2013 +0400
 
    Masterserver totals fix

Náš server je patchnutý následovně:

Víc než 4000 nodů:

patch

nodelimit.patch
From 8bc68645cb0c0145c8229bc6876bf590a8eef0ca Mon Sep 17 00:00:00 2001
From: ShadowNinja <noreply@gmail.com>
Date: Wed, 30 Oct 2013 15:46:52 -0400
Subject: [PATCH] Raise the maximum node limit to 0x7fff
 
As agreed to by kahrl
---
 src/mapnode.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 
diff --git a/src/mapnode.h b/src/mapnode.h
index 3c62084..f19885d 100644
--- a/src/mapnode.h
+++ b/src/mapnode.h
@@ -43,7 +43,7 @@
 	there is enough room for dummy node IDs, which are created when
 	a MapBlock containing unknown node names is loaded from disk.
 */
-#define MAX_REGISTERED_CONTENT 0xfffU
+#define MAX_REGISTERED_CONTENT 0x7fffU
 
 /*
 	A solid walkable node with the texture unknown_node.png.
-- 
1.8.5.1

Poznámka: tento commit je jen druhý následující od našeho základního commitu, předchozí commit je neškodný: Move new core devs to the "Core Developpers" section of mainmenu. Proto lze s klidným svědomím doporučit případný git checkout rovnou na commit měnící limit nodů.

Prejoin callback:

patch

prejoin-callback.patch
From 33de69a173a3646d8f5b9bf91b3e48d76cd40ae6 Mon Sep 17 00:00:00 2001
From: kaeza <kaeza@users.sf.net>
Date: Thu, 12 Dec 2013 04:51:35 -0200
Subject: [PATCH] Add 'on_prejoinplayer' callback
 
---
 builtin/misc_register.lua       |  1 +
 doc/lua_api.txt                 |  3 +++
 src/script/cpp_api/s_player.cpp | 18 ++++++++++++++++++
 src/script/cpp_api/s_player.h   |  1 +
 src/server.cpp                  | 13 +++++++++++++
 5 files changed, 36 insertions(+)
 
diff --git a/builtin/misc_register.lua b/builtin/misc_register.lua
index 249d272..6c50ff0 100644
--- a/builtin/misc_register.lua
+++ b/builtin/misc_register.lua
@@ -380,6 +380,7 @@ minetest.registered_on_generateds, minetest.register_on_generated = make_registr
 minetest.registered_on_newplayers, minetest.register_on_newplayer = make_registration()
 minetest.registered_on_dieplayers, minetest.register_on_dieplayer = make_registration()
 minetest.registered_on_respawnplayers, minetest.register_on_respawnplayer = make_registration()
+minetest.registered_on_prejoinplayers, minetest.register_on_prejoinplayer = make_registration()
 minetest.registered_on_joinplayers, minetest.register_on_joinplayer = make_registration()
 minetest.registered_on_leaveplayers, minetest.register_on_leaveplayer = make_registration()
 minetest.registered_on_player_receive_fields, minetest.register_on_player_receive_fields = make_registration_reverse()
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index cc8044f..ae71444 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -1175,6 +1175,9 @@ minetest.register_on_respawnplayer(func(ObjectRef))
 ^ Called when player is to be respawned
 ^ Called _before_ repositioning of player occurs
 ^ return true in func to disable regular player placement
+minetest.register_on_prejoinplayer(func(name, ip))
+^ Called before a player joins the game
+^ If it returns a string, the player is disconnected with that string as reason
 minetest.register_on_joinplayer(func(ObjectRef))
 ^ Called when a player joins the game
 minetest.register_on_leaveplayer(func(ObjectRef))
diff --git a/src/script/cpp_api/s_player.cpp b/src/script/cpp_api/s_player.cpp
index 215a34d..d357689 100644
--- a/src/script/cpp_api/s_player.cpp
+++ b/src/script/cpp_api/s_player.cpp
@@ -19,6 +19,7 @@
 
 #include "cpp_api/s_player.h"
 #include "cpp_api/s_internal.h"
+#include "util/string.h"
 
 void ScriptApiPlayer::on_newplayer(ServerActiveObject *player)
 {
@@ -58,6 +59,23 @@ bool ScriptApiPlayer::on_respawnplayer(ServerActiveObject *player)
 	return positioning_handled_by_some;
 }
 
+bool ScriptApiPlayer::on_prejoinplayer(std::string name, std::string ip, std::string &reason)
+{
+	SCRIPTAPI_PRECHECKHEADER
+
+	// Get minetest.registered_on_prejoinplayers
+	lua_getglobal(L, "minetest");
+	lua_getfield(L, -1, "registered_on_prejoinplayers");
+	lua_pushstring(L, name.c_str());
+	lua_pushstring(L, ip.c_str());
+	script_run_callbacks(L, 2, RUN_CALLBACKS_MODE_OR);
+	if (lua_isstring(L, -1)) {
+		reason.assign(lua_tostring(L, -1));
+		return true;
+	}
+	return false;
+}
+
 void ScriptApiPlayer::on_joinplayer(ServerActiveObject *player)
 {
 	SCRIPTAPI_PRECHECKHEADER
diff --git a/src/script/cpp_api/s_player.h b/src/script/cpp_api/s_player.h
index 88221f4..c77d397 100644
--- a/src/script/cpp_api/s_player.h
+++ b/src/script/cpp_api/s_player.h
@@ -34,6 +34,7 @@ class ScriptApiPlayer
 	void on_newplayer(ServerActiveObject *player);
 	void on_dieplayer(ServerActiveObject *player);
 	bool on_respawnplayer(ServerActiveObject *player);
+	bool on_prejoinplayer(std::string name, std::string ip, std::string &reason);
 	void on_joinplayer(ServerActiveObject *player);
 	void on_leaveplayer(ServerActiveObject *player);
 	void on_cheat(ServerActiveObject *player, const std::string &cheat_type);
diff --git a/src/server.cpp b/src/server.cpp
index 13b59e7..2c38c66 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -1970,6 +1970,19 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
 			return;
 		}
 
+		{
+			std::string reason;
+			if(m_script->on_prejoinplayer(playername, addr_s, reason))
+			{
+				actionstream<<"Server: Player with the name \""<<playername<<"\" "
+						<<"tried to connect from "<<addr_s<<" "
+						<<"but it was disallowed for the following reason: "
+						<<reason<<std::endl;
+				DenyAccess(peer_id, narrow_to_wide(reason.c_str()));
+				return;
+			}
+		}
+
 		infostream<<"Server: New connection: \""<<playername<<"\" from "
 				<<addr_s<<" (peer_id="<<peer_id<<")"<<std::endl;
 
-- 
1.8.5.1

Fix proti duplicitám entit

patch

anti-duplicity.patch
From 21789ccc5f2e372fe462e54944fef3a31c790110 Mon Sep 17 00:00:00 2001
From: Perttu Ahola <celeron55@gmail.com>
Date: Tue, 12 Nov 2013 19:54:32 +0200
Subject: [PATCH] Revert patch 58f036ad1 that causes object duplication (which
 tried to fix objects getting hidden from client) and fix the original problem
 correctly. This fixes the second distinct object duplication bug.
 
---
 src/environment.cpp | 83 ++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 60 insertions(+), 23 deletions(-)
 
diff --git a/src/environment.cpp b/src/environment.cpp
index 8a52a14..f019591 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -1417,8 +1417,8 @@ void ServerEnvironment::getAddedActiveObjects(v3s16 pos, s16 radius,
 		ServerActiveObject *object = i->second;
 		if(object == NULL)
 			continue;
-		// Discard if removed
-		if(object->m_removed)
+		// Discard if removed or deactivating
+		if(object->m_removed || object->m_pending_deactivation)
 			continue;
 		if(object->unlimitedTransferDistance() == false){
 			// Discard if too far
@@ -1468,7 +1468,7 @@ void ServerEnvironment::getRemovedActiveObjects(v3s16 pos, s16 radius,
 			continue;
 		}
 
-		if(object->m_removed)
+		if(object->m_removed || object->m_pending_deactivation)
 		{
 			removed_objects.insert(id);
 			continue;
@@ -1556,9 +1556,8 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object,
 		StaticObject s_obj(object->getType(), objectpos, staticdata);
 		// Add to the block where the object is located in
 		v3s16 blockpos = getNodeBlockPos(floatToInt(objectpos, BS));
-		MapBlock *block = m_map->getBlockNoCreateNoEx(blockpos);
-		if(block)
-		{
+		MapBlock *block = m_map->emergeBlock(blockpos);
+		if(block){
 			block->m_static_objects.m_active[object->getId()] = s_obj;
 			object->m_static_exists = true;
 			object->m_static_block = blockpos;
@@ -1566,11 +1565,10 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object,
 			if(set_changed)
 				block->raiseModified(MOD_STATE_WRITE_NEEDED, 
 						"addActiveObjectRaw");
-		}
-		else{
+		} else {
 			v3s16 p = floatToInt(objectpos, BS);
 			errorstream<<"ServerEnvironment::addActiveObjectRaw(): "
-					<<"could not find block for storing id="<<object->getId()
+					<<"could not emerge block for storing id="<<object->getId()
 					<<" statically (pos="<<PP(p)<<")"<<std::endl;
 		}
 	}
@@ -1616,18 +1614,39 @@ void ServerEnvironment::removeRemovedObjects()
 			if (block) {
 				block->m_static_objects.remove(id);
 				block->raiseModified(MOD_STATE_WRITE_NEEDED,
-						"removeRemovedObjects");
+						"removeRemovedObjects/remove");
 				obj->m_static_exists = false;
 			} else {
-				infostream << "failed to emerge block from which "
-					"an object to be removed was loaded from. id="<<id<<std::endl;
+				infostream<<"Failed to emerge block from which an object to "
+						<<"be removed was loaded from. id="<<id<<std::endl;
 			}
 		}
 
-		// If m_known_by_count > 0, don't actually remove.
+		// If m_known_by_count > 0, don't actually remove. On some future
+		// invocation this will be 0, which is when removal will continue.
 		if(obj->m_known_by_count > 0)
 			continue;
-		
+
+		/*
+			Move static data from active to stored if not marked as removed
+		*/
+		if(obj->m_static_exists && !obj->m_removed){
+			MapBlock *block = m_map->emergeBlock(obj->m_static_block, false);
+			if (block) {
+				std::map<u16, StaticObject>::iterator i =
+						block->m_static_objects.m_active.find(id);
+				if(i != block->m_static_objects.m_active.end()){
+					block->m_static_objects.m_stored.push_back(i->second);
+					block->m_static_objects.m_active.erase(id);
+					block->raiseModified(MOD_STATE_WRITE_NEEDED,
+							"removeRemovedObjects/deactivate");
+				}
+			} else {
+				infostream<<"Failed to emerge block from which an object to "
+						<<"be deactivated was loaded from. id="<<id<<std::endl;
+			}
+		}
+
 		// Tell the object about removal
 		obj->removingFromEnvironment();
 		// Deregister in scripting api
@@ -1708,10 +1727,9 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s)
 				"large amount of objects");
 		return;
 	}
-	// A list for objects that couldn't be converted to active for some
-	// reason. They will be stored back.
+
+	// Activate stored objects
 	std::list<StaticObject> new_stored;
-	// Loop through stored static objects
 	for(std::list<StaticObject>::iterator
 			i = block->m_static_objects.m_stored.begin();
 			i != block->m_static_objects.m_stored.end(); ++i)
@@ -1750,6 +1768,19 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s)
 		StaticObject &s_obj = *i;
 		block->m_static_objects.m_stored.push_back(s_obj);
 	}
+
+	// Turn the active counterparts of activated objects not pending for
+	// deactivation
+	for(std::map<u16, StaticObject>::iterator
+			i = block->m_static_objects.m_active.begin();
+			i != block->m_static_objects.m_active.end(); ++i)
+	{
+		u16 id = i->first;
+		ServerActiveObject *object = getActiveObject(id);
+		assert(object);
+		object->m_pending_deactivation = false;
+	}
+
 	/*
 		Note: Block hasn't really been modified here.
 		The objects have just been activated and moved from the stored
@@ -1910,6 +1941,8 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
 				block = m_map->emergeBlock(blockpos);
 			} catch(InvalidPositionException &e){
 				// Handled via NULL pointer
+				// NOTE: emergeBlock's failure is usually determined by it
+				//       actually returning NULL
 			}
 
 			if(block)
@@ -1923,17 +1956,21 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
 							<<" Forcing delete."<<std::endl;
 					force_delete = true;
 				} else {
-					// If static counterpart already exists, remove it first.
-					// This shouldn't happen, but happens rarely for some
-					// unknown reason. Unsuccessful attempts have been made to
-					// find said reason.
+					// If static counterpart already exists in target block,
+					// remove it first.
+					// This shouldn't happen because the object is removed from
+					// the previous block before this according to
+					// obj->m_static_block, but happens rarely for some unknown
+					// reason. Unsuccessful attempts have been made to find
+					// said reason.
 					if(id && block->m_static_objects.m_active.find(id) != block->m_static_objects.m_active.end()){
 						infostream<<"ServerEnv: WARNING: Performing hack #83274"
 								<<std::endl;
 						block->m_static_objects.remove(id);
 					}
-					//store static data
-					block->m_static_objects.insert(0, s_obj);
+					// Store static data
+					u16 store_id = pending_delete ? id : 0;
+					block->m_static_objects.insert(store_id, s_obj);
 
 					// Only mark block as modified if data changed considerably
 					if(shall_be_written)
-- 
1.8.5.1
Navigace

Obecné

Vývoj

Naše minetest games

Jiné minetest games

Minecraft

Wurm Unlimited

Ostatní

O této wiki

Tisk/export
Jazyky