Configurable portals
This commit is contained in:
parent
74cd4f5521
commit
ccbf6cc446
@ -1042,6 +1042,11 @@ void cEntity::DetectCacti(void)
|
|||||||
|
|
||||||
void cEntity::DetectPortal()
|
void cEntity::DetectPortal()
|
||||||
{
|
{
|
||||||
|
if (!GetWorld()->AreNetherPortalsEnabled() && !GetWorld()->AreEndPortalsEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT;
|
int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT;
|
||||||
if ((Y > 0) && (Y < cChunkDef::Height))
|
if ((Y > 0) && (Y < cChunkDef::Height))
|
||||||
{
|
{
|
||||||
@ -1049,11 +1054,18 @@ void cEntity::DetectPortal()
|
|||||||
{
|
{
|
||||||
case E_BLOCK_NETHER_PORTAL:
|
case E_BLOCK_NETHER_PORTAL:
|
||||||
{
|
{
|
||||||
|
if (!GetWorld()->AreNetherPortalsEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (GetWorld()->GetDimension())
|
switch (GetWorld()->GetDimension())
|
||||||
{
|
{
|
||||||
case dimNether:
|
case dimNether:
|
||||||
{
|
{
|
||||||
AString OverworldName = GetWorld()->GetName().substr(0, GetWorld()->GetName().size() - 7);
|
cIniFile OwnIni; OwnIni.ReadFile(GetWorld()->GetIniFileName());
|
||||||
|
AString OverworldName = OwnIni.GetValue("General", "OverworldName", cRoot::Get()->GetDefaultWorld()->GetName());
|
||||||
|
|
||||||
cFile::CreateFolder(FILE_IO_PREFIX + OverworldName);
|
cFile::CreateFolder(FILE_IO_PREFIX + OverworldName);
|
||||||
cIniFile File;
|
cIniFile File;
|
||||||
File.ReadFile(OverworldName + "/world.ini");
|
File.ReadFile(OverworldName + "/world.ini");
|
||||||
@ -1065,14 +1077,14 @@ void cEntity::DetectPortal()
|
|||||||
}
|
}
|
||||||
case dimOverworld:
|
case dimOverworld:
|
||||||
{
|
{
|
||||||
AString NetherWorldName = GetWorld()->GetName() + "_nether";
|
cFile::CreateFolder(FILE_IO_PREFIX + GetWorld()->GetNetherWorldName());
|
||||||
cFile::CreateFolder(FILE_IO_PREFIX + NetherWorldName);
|
|
||||||
cIniFile File;
|
cIniFile File;
|
||||||
File.ReadFile(NetherWorldName + "/world.ini");
|
File.ReadFile(GetWorld()->GetNetherWorldName() + "/world.ini");
|
||||||
File.SetValue("General", "Dimension", "Nether");
|
File.SetValue("General", "Dimension", "Nether");
|
||||||
File.WriteFile(NetherWorldName + "/world.ini");
|
File.SetValue("General", "OverworldName", GetWorld()->GetName());
|
||||||
|
File.WriteFile(GetWorld()->GetNetherWorldName() + "/world.ini");
|
||||||
|
|
||||||
MoveToWorld(NetherWorldName, cRoot::Get()->CreateAndInitializeWorld(NetherWorldName));
|
MoveToWorld(GetWorld()->GetNetherWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetNetherWorldName()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
@ -1081,11 +1093,18 @@ void cEntity::DetectPortal()
|
|||||||
}
|
}
|
||||||
case E_BLOCK_END_PORTAL:
|
case E_BLOCK_END_PORTAL:
|
||||||
{
|
{
|
||||||
|
if (!GetWorld()->AreEndPortalsEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (GetWorld()->GetDimension())
|
switch (GetWorld()->GetDimension())
|
||||||
{
|
{
|
||||||
case dimEnd:
|
case dimEnd:
|
||||||
{
|
{
|
||||||
AString OverworldName = GetWorld()->GetName().substr(0, GetWorld()->GetName().size() - 4);
|
cIniFile OwnIni; OwnIni.ReadFile(GetWorld()->GetIniFileName());
|
||||||
|
AString OverworldName = OwnIni.GetValue("General", "OverworldName", cRoot::Get()->GetDefaultWorld()->GetName());
|
||||||
|
|
||||||
cFile::CreateFolder(FILE_IO_PREFIX + OverworldName);
|
cFile::CreateFolder(FILE_IO_PREFIX + OverworldName);
|
||||||
cIniFile File;
|
cIniFile File;
|
||||||
File.ReadFile(OverworldName + "/world.ini");
|
File.ReadFile(OverworldName + "/world.ini");
|
||||||
@ -1103,14 +1122,14 @@ void cEntity::DetectPortal()
|
|||||||
}
|
}
|
||||||
case dimOverworld:
|
case dimOverworld:
|
||||||
{
|
{
|
||||||
AString EndWorldName = GetWorld()->GetName() + "_end";
|
cFile::CreateFolder(FILE_IO_PREFIX + GetWorld()->GetEndWorldName());
|
||||||
cFile::CreateFolder(FILE_IO_PREFIX + EndWorldName);
|
|
||||||
cIniFile File;
|
cIniFile File;
|
||||||
File.ReadFile(EndWorldName + "/world.ini");
|
File.ReadFile(GetWorld()->GetEndWorldName() + "/world.ini");
|
||||||
File.SetValue("General", "Dimension", "End");
|
File.SetValue("General", "Dimension", "End");
|
||||||
File.WriteFile(EndWorldName + "/world.ini");
|
File.SetValue("General", "OverworldName", GetWorld()->GetName());
|
||||||
|
File.WriteFile(GetWorld()->GetEndWorldName() + "/world.ini");
|
||||||
|
|
||||||
MoveToWorld(EndWorldName, cRoot::Get()->CreateAndInitializeWorld(EndWorldName));
|
MoveToWorld(GetWorld()->GetEndWorldName(), cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetEndWorldName()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
@ -1133,7 +1152,7 @@ bool cEntity::MoveToWorld(const AString & a_WorldName, cWorld * a_World)
|
|||||||
World = cRoot::Get()->GetWorld(a_WorldName);
|
World = cRoot::Get()->GetWorld(a_WorldName);
|
||||||
if (World == NULL)
|
if (World == NULL)
|
||||||
{
|
{
|
||||||
LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName);
|
LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1610,7 +1610,7 @@ bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World)
|
|||||||
{
|
{
|
||||||
GetClientHandle()->SendPlayerMoveLook();
|
GetClientHandle()->SendPlayerMoveLook();
|
||||||
GetClientHandle()->SendHealth();
|
GetClientHandle()->SendHealth();
|
||||||
GetClientHandle()->SendWholeInventory((cWindow &)GetInventory());
|
GetClientHandle()->SendWholeInventory(*GetWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -66,6 +66,9 @@ const int TIME_NIGHT_END = 22812;
|
|||||||
const int TIME_SUNRISE = 23999;
|
const int TIME_SUNRISE = 23999;
|
||||||
const int TIME_SPAWN_DIVISOR = 148;
|
const int TIME_SPAWN_DIVISOR = 148;
|
||||||
|
|
||||||
|
#define DEFAULT_NETHER_NAME GetName() + "_nether"
|
||||||
|
#define DEFAULT_END_NAME GetName() + "_end"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -567,6 +570,14 @@ void cWorld::Start(void)
|
|||||||
m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true);
|
m_VillagersShouldHarvestCrops = IniFile.GetValueSetB("Monsters", "VillagersShouldHarvestCrops", true);
|
||||||
int GameMode = IniFile.GetValueSetI("General", "Gamemode", (int)m_GameMode);
|
int GameMode = IniFile.GetValueSetI("General", "Gamemode", (int)m_GameMode);
|
||||||
|
|
||||||
|
if ((GetDimension() != dimNether) && (GetDimension() != dimEnd))
|
||||||
|
{
|
||||||
|
m_bNetherPortalsEnabled = IniFile.GetValueSetB("General", "NetherPortalsEnabled", true);
|
||||||
|
m_NetherWorldName = IniFile.GetValueSet("General", "NetherWorldName", DEFAULT_NETHER_NAME);
|
||||||
|
m_bEndPortalsEnabled = IniFile.GetValueSetB("General", "EndPortalsEnabled", true);
|
||||||
|
m_EndWorldName = IniFile.GetValueSet("General", "EndWorldName", DEFAULT_END_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
// Adjust the enum-backed variables into their respective bounds:
|
// Adjust the enum-backed variables into their respective bounds:
|
||||||
m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmAdventure);
|
m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmAdventure);
|
||||||
m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll);
|
m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll);
|
||||||
@ -735,6 +746,21 @@ void cWorld::Stop(void)
|
|||||||
m_Clients.clear();
|
m_Clients.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write settings to file; these are all plugin changeable values - keep updated!
|
||||||
|
cIniFile IniFile;
|
||||||
|
IniFile.ReadFile(m_IniFileName);
|
||||||
|
if ((GetDimension() != dimNether) && (GetDimension() != dimEnd))
|
||||||
|
{
|
||||||
|
IniFile.SetValueB("General", "NetherPortalsEnabled", m_bNetherPortalsEnabled);
|
||||||
|
IniFile.SetValue("General", "NetherWorldName", m_NetherWorldName);
|
||||||
|
IniFile.SetValueB("General", "EndPortalsEnabled", m_bEndPortalsEnabled);
|
||||||
|
IniFile.SetValue("General", "EndWorldName", m_EndWorldName);
|
||||||
|
}
|
||||||
|
IniFile.SetValueI("Physics", "TNTShrapnelLevel", (int)m_TNTShrapnelLevel);
|
||||||
|
IniFile.SetValueB("Mechanics", "CommandBlocksEnabled", m_bCommandBlocksEnabled);
|
||||||
|
IniFile.SetValueB("Mechanics", "UseChatPrefixes", m_bUseChatPrefixes);
|
||||||
|
IniFile.WriteFile(m_IniFileName);
|
||||||
|
|
||||||
m_TickThread.Stop();
|
m_TickThread.Stop();
|
||||||
m_Lighting.Stop();
|
m_Lighting.Stop();
|
||||||
m_Generator.Stop();
|
m_Generator.Stop();
|
||||||
|
24
src/World.h
24
src/World.h
@ -625,6 +625,18 @@ public:
|
|||||||
bool ShouldUseChatPrefixes(void) const { return m_bUseChatPrefixes; }
|
bool ShouldUseChatPrefixes(void) const { return m_bUseChatPrefixes; }
|
||||||
void SetShouldUseChatPrefixes(bool a_Flag) { m_bUseChatPrefixes = a_Flag; }
|
void SetShouldUseChatPrefixes(bool a_Flag) { m_bUseChatPrefixes = a_Flag; }
|
||||||
|
|
||||||
|
bool AreNetherPortalsEnabled(void) const { return m_bNetherPortalsEnabled; }
|
||||||
|
void SetNetherPortalsEnabled(bool a_Flag) { m_bNetherPortalsEnabled = a_Flag; }
|
||||||
|
|
||||||
|
bool AreEndPortalsEnabled(void) const { return m_bEndPortalsEnabled; }
|
||||||
|
void SetEndPortalsEnabled(bool a_Flag) { m_bEndPortalsEnabled = a_Flag; }
|
||||||
|
|
||||||
|
AString GetNetherWorldName(void) const { return m_NetherWorldName; }
|
||||||
|
void SetNetherWorldName(const AString & a_Name) { m_NetherWorldName = a_Name; }
|
||||||
|
|
||||||
|
AString GetEndWorldName(void) const { return m_EndWorldName; }
|
||||||
|
void SetEndWorldName(const AString & a_Name) { m_EndWorldName = a_Name; }
|
||||||
|
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
inline static void BlockToChunk( int a_X, int a_Y, int a_Z, int & a_ChunkX, int & a_ChunkY, int & a_ChunkZ )
|
inline static void BlockToChunk( int a_X, int a_Y, int a_Z, int & a_ChunkX, int & a_ChunkY, int & a_ChunkZ )
|
||||||
@ -887,6 +899,18 @@ private:
|
|||||||
*/
|
*/
|
||||||
eShrapnelLevel m_TNTShrapnelLevel;
|
eShrapnelLevel m_TNTShrapnelLevel;
|
||||||
|
|
||||||
|
/** Whether nether portals teleport entities */
|
||||||
|
bool m_bNetherPortalsEnabled;
|
||||||
|
|
||||||
|
/** Whether end portals teleport entities */
|
||||||
|
bool m_bEndPortalsEnabled;
|
||||||
|
|
||||||
|
/** Name of the nether world */
|
||||||
|
AString m_NetherWorldName;
|
||||||
|
|
||||||
|
/** Name of the end world */
|
||||||
|
AString m_EndWorldName;
|
||||||
|
|
||||||
|
|
||||||
cChunkGenerator m_Generator;
|
cChunkGenerator m_Generator;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user