1
0

Merge pull request #2239 from cuberite/PortalSize

Added a size check for portals.
This commit is contained in:
Mattes D 2015-06-28 21:04:34 +02:00
commit fe81a0dcde
5 changed files with 56 additions and 0 deletions

View File

@ -2379,8 +2379,12 @@ local CompressedString = cStringCompression.CompressStringGZIP("DataToCompress")
GetLinkedOverworldName = { Params = "", Return = "string", Notes = "Returns the name of the world this world is linked to." },
GetMapManager = { Params = "", Return = "{{cMapManager}}", Notes = "Returns the {{cMapManager|MapManager}} object used by this world." },
GetMaxCactusHeight = { Params = "", Return = "number", Notes = "Returns the configured maximum height to which cacti will grow naturally." },
GetMaxNetherPortalHeight = { Params = "", Return = "number", Notes = "Returns the maximum height for a nether portal" },
GetMaxNetherPortalWidth = { Params = "", Return = "number", Notes = "Returns the maximum width for a nether portal" },
GetMaxSugarcaneHeight = { Params = "", Return = "number", Notes = "Returns the configured maximum height to which sugarcane will grow naturally." },
GetMaxViewDistance = { Params = "", Return = "number", Notes = "Returns the maximum viewdistance that players can see in this world. The view distance is the amount of chunks around the player that the player can see." },
GetMinNetherPortalHeight = { Params = "", Return = "number", Notes = "Returns the minimum height for a nether portal" },
GetMinNetherPortalWidth = { Params = "", Return = "number", Notes = "Returns the minimum width for a nether portal" },
GetName = { Params = "", Return = "string", Notes = "Returns the name of the world, as specified in the settings.ini file." },
GetNumChunks = { Params = "", Return = "number", Notes = "Returns the number of chunks currently loaded." },
GetScoreBoard = { Params = "", Return = "{{cScoreBoard}}", Notes = "Returns the {{cScoreBoard|ScoreBoard}} object used by this world. " },
@ -2448,6 +2452,10 @@ local CompressedString = cStringCompression.CompressStringGZIP("DataToCompress")
SetLinkedNetherWorldName = { Params = "string", Return = "", Notes = "Sets the name of the world that the nether portal should link to." },
SetLinkedOverworldName = { Params = "string", Return = "", Notes = "Sets the name of the world that the nether portal should link to?" },
SetMaxViewDistance = { Params = "number", Return = "", Notes = "Sets the maximum viewdistance of the players in the world." },
SetMaxNetherPortalHeight = { Params = "number", Return = "", Notes = "Sets the maximum height for a nether portal" },
SetMaxNetherPortalWidth = { Params = "number", Return = "", Notes = "Sets the maximum width for a nether portal" },
SetMinNetherPortalHeight = { Params = "number", Return = "", Notes = "Sets the minimum height for a nether portal" },
SetMinNetherPortalWidth = { Params = "number", Return = "", Notes = "Sets the minimum width for a nether portal" },
SetShouldUseChatPrefixes = { Params = "", Return = "ShouldUse (bool)", Notes = "Sets whether coloured chat prefixes such as [INFO] is used with the SendMessageXXX() or BroadcastChatXXX(), or simply the entire message is coloured in the respective colour." },
SetSignLines = { Params = "X, Y, Z, Line1, Line2, Line3, Line4, [{{cPlayer|Player}}]", Return = "", Notes = "Sets the sign text at the specified coords. The sign-updating hooks are called for the change. The Player parameter is used to indicate the player from whom the change has come, it may be nil." },
SetTicksUntilWeatherChange = { Params = "NumTicks", Return = "", Notes = "Sets the number of ticks after which the weather will be changed." },

View File

@ -121,6 +121,20 @@ public:
}
}
int PortalHeight = MaxY - Y - 1;
int PortalWidth = XZP - XZM + 1;
if ((PortalHeight < a_WorldInterface.GetMinNetherPortalHeight()) || (PortalHeight > a_WorldInterface.GetMaxNetherPortalHeight()))
{
// The portal isn't high enough, or is too high
return;
}
if ((PortalWidth < a_WorldInterface.GetMinNetherPortalWidth()) || (PortalWidth > a_WorldInterface.GetMaxNetherPortalWidth()))
{
// The portal isn't wide enough, or is too wide
return;
}
for (int Height = Y + 1; Height <= MaxY - 1; Height++) // Loop through boundary to set portal blocks
{
for (int Width = XZM; Width <= XZP; Width++)

View File

@ -55,6 +55,18 @@ public:
/** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */
virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) = 0;
/** Returns or sets the minumim or maximum netherportal width */
virtual int GetMinNetherPortalWidth(void) const = 0;
virtual int GetMaxNetherPortalWidth(void) const = 0;
virtual void SetMinNetherPortalWidth(int a_NewMinWidth) = 0;
virtual void SetMaxNetherPortalWidth(int a_NewMaxWidth) = 0;
/** Returns or sets the minumim or maximum netherportal height */
virtual int GetMinNetherPortalHeight(void) const = 0;
virtual int GetMaxNetherPortalHeight(void) const = 0;
virtual void SetMinNetherPortalHeight(int a_NewMinHeight) = 0;
virtual void SetMaxNetherPortalHeight(int a_NewMaxHeight) = 0;
/** Returns the world height at the specified coords; waits for the chunk to get loaded / generated */
virtual int GetHeight(int a_BlockX, int a_BlockZ) = 0;

View File

@ -464,6 +464,10 @@ void cWorld::Start(void)
m_bCommandBlocksEnabled = IniFile.GetValueSetB("Mechanics", "CommandBlocksEnabled", false);
m_bEnabledPVP = IniFile.GetValueSetB("Mechanics", "PVPEnabled", true);
m_bUseChatPrefixes = IniFile.GetValueSetB("Mechanics", "UseChatPrefixes", true);
m_MinNetherPortalWidth = IniFile.GetValueSetI("Mechanics", "MinNetherPortalWidth", 2);
m_MaxNetherPortalWidth = IniFile.GetValueSetI("Mechanics", "MaxNetherPortalWidth", 21);
m_MinNetherPortalHeight = IniFile.GetValueSetI("Mechanics", "MinNetherPortalHeight", 3);
m_MaxNetherPortalHeight = IniFile.GetValueSetI("Mechanics", "MaxNetherPortalHeight", 21);
m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true);
m_IsDaylightCycleEnabled = IniFile.GetValueSetB("General", "IsDaylightCycleEnabled", true);
int GameMode = IniFile.GetValueSetI("General", "Gamemode", (int)m_GameMode);

View File

@ -713,6 +713,18 @@ public:
AString GetLinkedOverworldName(void) const { return m_LinkedOverworldName; }
void SetLinkedOverworldName(const AString & a_Name) { m_LinkedOverworldName = a_Name; }
/** Returns or sets the minumim or maximum netherportal width */
virtual int GetMinNetherPortalWidth(void) const override { return m_MinNetherPortalWidth; }
virtual int GetMaxNetherPortalWidth(void) const override { return m_MaxNetherPortalWidth; }
virtual void SetMinNetherPortalWidth(int a_NewMinWidth) override { m_MinNetherPortalWidth = a_NewMinWidth; }
virtual void SetMaxNetherPortalWidth(int a_NewMaxWidth) override { m_MaxNetherPortalWidth = a_NewMaxWidth; }
/** Returns or sets the minumim or maximum netherportal height */
virtual int GetMinNetherPortalHeight(void) const override { return m_MinNetherPortalHeight; }
virtual int GetMaxNetherPortalHeight(void) const override { return m_MaxNetherPortalHeight; }
virtual void SetMinNetherPortalHeight(int a_NewMinHeight) override { m_MinNetherPortalHeight = a_NewMinHeight; }
virtual void SetMaxNetherPortalHeight(int a_NewMaxHeight) override { m_MaxNetherPortalHeight = a_NewMaxHeight; }
// tolua_end
/** Saves all chunks immediately. Dangerous interface, may deadlock, use QueueSaveAllChunks() instead */
@ -942,6 +954,12 @@ private:
double m_SpawnY;
double m_SpawnZ;
// Variables defining the minimum and maximum size for a nether portal
int m_MinNetherPortalWidth;
int m_MaxNetherPortalWidth;
int m_MinNetherPortalHeight;
int m_MaxNetherPortalHeight;
bool m_BroadcastDeathMessages;
bool m_BroadcastAchievementMessages;