Merge branch 'master' of github.com:p-mcgowan/MCServer into animalTerrainFinisher
update
This commit is contained in:
commit
a8bbd5efe4
@ -444,8 +444,19 @@ local function BuildPermissions(a_PluginInfo)
|
||||
Permissions[info.Permission] = Permission
|
||||
-- Add the command to the list of commands using this permission:
|
||||
Permission.CommandsAffected = Permission.CommandsAffected or {}
|
||||
-- First, make sure that we don't already have this command in the list,
|
||||
-- it may have already been present in a_PluginInfo
|
||||
local NewCommand = true
|
||||
for _, existCmd in ipairs(Permission.CommandsAffected) do
|
||||
if CommandString == existCmd then
|
||||
NewCommand = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if NewCommand then
|
||||
table.insert(Permission.CommandsAffected, CommandString)
|
||||
end
|
||||
end
|
||||
|
||||
-- Process the command param combinations for permissions:
|
||||
local ParamCombinations = info.ParameterCombinations or {}
|
||||
|
@ -52,8 +52,10 @@ static int tolua_get_AllToLua_g_BlockSpreadLightFalloff(lua_State* tolua_S)
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
{
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
@ -78,8 +80,10 @@ static int tolua_get_AllToLua_g_BlockTransparent(lua_State* tolua_S)
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
{
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
@ -104,8 +108,10 @@ static int tolua_get_AllToLua_g_BlockOneHitDig(lua_State* tolua_S)
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
{
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
@ -130,8 +136,10 @@ static int tolua_get_AllToLua_g_BlockPistonBreakable(lua_State* tolua_S)
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
{
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
@ -156,8 +164,10 @@ static int tolua_get_AllToLua_g_BlockIsSnowable(lua_State* tolua_S)
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
{
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
@ -182,8 +192,10 @@ static int tolua_get_AllToLua_g_BlockIsSolid(lua_State* tolua_S)
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
{
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
@ -208,8 +220,10 @@ static int tolua_get_AllToLua_g_BlockFullyOccupiesVoxel(lua_State* tolua_S)
|
||||
{
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
{
|
||||
tolua_error(tolua_S, "#vinvalid type in array indexing.", &tolua_err);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
BlockType = (int)tolua_tonumber(tolua_S, 2, 0);
|
||||
if ((BlockType < 0) || (BlockType > E_BLOCK_MAX_TYPE_ID))
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
virtual bool OnChunkUnloaded (cWorld & a_World, int a_ChunkX, int a_ChunkZ) = 0;
|
||||
virtual bool OnChunkUnloading (cWorld & a_World, int a_ChunkX, int a_ChunkZ) = 0;
|
||||
virtual bool OnCollectingPickup (cPlayer & a_Player, cPickup & a_Pickup) = 0;
|
||||
virtual bool OnCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
||||
virtual bool OnCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe) = 0;
|
||||
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) = 0;
|
||||
virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) = 0;
|
||||
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) = 0;
|
||||
|
@ -382,7 +382,7 @@ bool cPluginLua::OnCollectingPickup(cPlayer & a_Player, cPickup & a_Pickup)
|
||||
|
||||
|
||||
|
||||
bool cPluginLua::OnCraftingNoRecipe(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe * a_Recipe)
|
||||
bool cPluginLua::OnCraftingNoRecipe(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe)
|
||||
{
|
||||
cCSLock Lock(m_CriticalSection);
|
||||
bool res = false;
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
virtual bool OnChunkUnloaded (cWorld & a_World, int a_ChunkX, int a_ChunkZ) override;
|
||||
virtual bool OnChunkUnloading (cWorld & a_World, int a_ChunkX, int a_ChunkZ) override;
|
||||
virtual bool OnCollectingPickup (cPlayer & a_Player, cPickup & a_Pickup) override;
|
||||
virtual bool OnCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe * a_Recipe) override;
|
||||
virtual bool OnCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe) override;
|
||||
virtual bool OnDisconnect (cClientHandle & a_Client, const AString & a_Reason) override;
|
||||
virtual bool OnEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier) override;
|
||||
virtual bool OnExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split) override;
|
||||
|
@ -448,7 +448,7 @@ bool cPluginManager::CallHookCollectingPickup(cPlayer & a_Player, cPickup & a_Pi
|
||||
|
||||
|
||||
|
||||
bool cPluginManager::CallHookCraftingNoRecipe(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe * a_Recipe)
|
||||
bool cPluginManager::CallHookCraftingNoRecipe(cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe)
|
||||
{
|
||||
FIND_HOOK(HOOK_CRAFTING_NO_RECIPE);
|
||||
VERIFY_HOOK;
|
||||
@ -1463,7 +1463,12 @@ cPlugin * cPluginManager::GetPlugin( const AString & a_Plugin) const
|
||||
{
|
||||
for (PluginMap::const_iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ++itr)
|
||||
{
|
||||
if (itr->second == nullptr) continue;
|
||||
if (itr->second == nullptr)
|
||||
{
|
||||
// The plugin is currently unloaded
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itr->second->GetName().compare(a_Plugin) == 0)
|
||||
{
|
||||
return itr->second;
|
||||
|
@ -187,7 +187,7 @@ public:
|
||||
bool CallHookChunkUnloaded (cWorld & a_World, int a_ChunkX, int a_ChunkZ);
|
||||
bool CallHookChunkUnloading (cWorld & a_World, int a_ChunkX, int a_ChunkZ);
|
||||
bool CallHookCollectingPickup (cPlayer & a_Player, cPickup & a_Pickup);
|
||||
bool CallHookCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe * a_Recipe);
|
||||
bool CallHookCraftingNoRecipe (cPlayer & a_Player, cCraftingGrid & a_Grid, cCraftingRecipe & a_Recipe);
|
||||
bool CallHookDisconnect (cClientHandle & a_Client, const AString & a_Reason);
|
||||
bool CallHookEntityAddEffect (cEntity & a_Entity, int a_EffectType, int a_EffectDurationTicks, int a_EffectIntensity, double a_DistanceModifier);
|
||||
bool CallHookExecuteCommand (cPlayer * a_Player, const AStringVector & a_Split); // If a_Player == nullptr, it is a console cmd
|
||||
|
@ -52,7 +52,10 @@ public:
|
||||
static NIBBLETYPE RotationToMetaData(double a_Rotation)
|
||||
{
|
||||
a_Rotation += 180 + (180 / 4); // So its not aligned with axis
|
||||
if (a_Rotation > 360) a_Rotation -= 360;
|
||||
if (a_Rotation > 360)
|
||||
{
|
||||
a_Rotation -= 360;
|
||||
}
|
||||
|
||||
a_Rotation = (a_Rotation / 360) * 4;
|
||||
|
||||
|
@ -145,7 +145,10 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta)
|
||||
// in only the bottom tile while the hinge position is in the top tile. This function only operates on one tile at a time,
|
||||
// so the function can only see either the hinge position or orientation, but not both, at any given time. The class itself
|
||||
// needs extra datamembers.
|
||||
if (a_Meta & 0x08) return a_Meta;
|
||||
if (a_Meta & 0x08)
|
||||
{
|
||||
return a_Meta;
|
||||
}
|
||||
|
||||
// Holds open/closed meta data. 0x0C == 1100.
|
||||
NIBBLETYPE OtherMeta = a_Meta & 0x0C;
|
||||
@ -173,7 +176,10 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta)
|
||||
// so the function can only see either the hinge position or orientation, but not both, at any given time.The class itself
|
||||
// needs extra datamembers.
|
||||
|
||||
if (a_Meta & 0x08) return a_Meta;
|
||||
if (a_Meta & 0x08)
|
||||
{
|
||||
return a_Meta;
|
||||
}
|
||||
|
||||
// Holds open/closed meta data. 0x0C == 1100.
|
||||
NIBBLETYPE OtherMeta = a_Meta & 0x0C;
|
||||
|
@ -151,13 +151,21 @@ public:
|
||||
Neighbors[6] = (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ - 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_NONE));
|
||||
Neighbors[7] = (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ + 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_NONE));
|
||||
if (IsUnstable(a_ChunkInterface, a_BlockX + 1, a_BlockY - 1, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_EAST))
|
||||
{
|
||||
Neighbors[0] = true;
|
||||
}
|
||||
if (IsUnstable(a_ChunkInterface, a_BlockX - 1, a_BlockY - 1, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_WEST))
|
||||
{
|
||||
Neighbors[1] = true;
|
||||
}
|
||||
if (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ - 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_NORTH))
|
||||
{
|
||||
Neighbors[2] = true;
|
||||
}
|
||||
if (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ + 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_SOUTH))
|
||||
{
|
||||
Neighbors[3] = true;
|
||||
}
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (Neighbors[i])
|
||||
@ -167,12 +175,30 @@ public:
|
||||
}
|
||||
if (RailsCnt == 1)
|
||||
{
|
||||
if (Neighbors[7]) return E_META_RAIL_ASCEND_ZP;
|
||||
else if (Neighbors[6]) return E_META_RAIL_ASCEND_ZM;
|
||||
else if (Neighbors[5]) return E_META_RAIL_ASCEND_XM;
|
||||
else if (Neighbors[4]) return E_META_RAIL_ASCEND_XP;
|
||||
else if (Neighbors[0] || Neighbors[1]) return E_META_RAIL_XM_XP;
|
||||
else if (Neighbors[2] || Neighbors[3]) return E_META_RAIL_ZM_ZP;
|
||||
if (Neighbors[7])
|
||||
{
|
||||
return E_META_RAIL_ASCEND_ZP;
|
||||
}
|
||||
else if (Neighbors[6])
|
||||
{
|
||||
return E_META_RAIL_ASCEND_ZM;
|
||||
}
|
||||
else if (Neighbors[5])
|
||||
{
|
||||
return E_META_RAIL_ASCEND_XM;
|
||||
}
|
||||
else if (Neighbors[4])
|
||||
{
|
||||
return E_META_RAIL_ASCEND_XP;
|
||||
}
|
||||
else if (Neighbors[0] || Neighbors[1])
|
||||
{
|
||||
return E_META_RAIL_XM_XP;
|
||||
}
|
||||
else if (Neighbors[2] || Neighbors[3])
|
||||
{
|
||||
return E_META_RAIL_ZM_ZP;
|
||||
}
|
||||
ASSERT(!"Weird neighbor count");
|
||||
return Meta;
|
||||
}
|
||||
@ -185,16 +211,46 @@ public:
|
||||
}
|
||||
if (RailsCnt > 1)
|
||||
{
|
||||
if (Neighbors[3] && Neighbors[0] && CanThisRailCurve()) return E_META_RAIL_CURVED_ZP_XP;
|
||||
else if (Neighbors[3] && Neighbors[1] && CanThisRailCurve()) return E_META_RAIL_CURVED_ZP_XM;
|
||||
else if (Neighbors[2] && Neighbors[0] && CanThisRailCurve()) return E_META_RAIL_CURVED_ZM_XP;
|
||||
else if (Neighbors[2] && Neighbors[1] && CanThisRailCurve()) return E_META_RAIL_CURVED_ZM_XM;
|
||||
else if (Neighbors[7] && Neighbors[2]) return E_META_RAIL_ASCEND_ZP;
|
||||
else if (Neighbors[3] && Neighbors[6]) return E_META_RAIL_ASCEND_ZM;
|
||||
else if (Neighbors[5] && Neighbors[0]) return E_META_RAIL_ASCEND_XM;
|
||||
else if (Neighbors[4] && Neighbors[1]) return E_META_RAIL_ASCEND_XP;
|
||||
else if (Neighbors[0] && Neighbors[1]) return E_META_RAIL_XM_XP;
|
||||
else if (Neighbors[2] && Neighbors[3]) return E_META_RAIL_ZM_ZP;
|
||||
if (Neighbors[3] && Neighbors[0] && CanThisRailCurve())
|
||||
{
|
||||
return E_META_RAIL_CURVED_ZP_XP;
|
||||
}
|
||||
else if (Neighbors[3] && Neighbors[1] && CanThisRailCurve())
|
||||
{
|
||||
return E_META_RAIL_CURVED_ZP_XM;
|
||||
}
|
||||
else if (Neighbors[2] && Neighbors[0] && CanThisRailCurve())
|
||||
{
|
||||
return E_META_RAIL_CURVED_ZM_XP;
|
||||
}
|
||||
else if (Neighbors[2] && Neighbors[1] && CanThisRailCurve())
|
||||
{
|
||||
return E_META_RAIL_CURVED_ZM_XM;
|
||||
}
|
||||
else if (Neighbors[7] && Neighbors[2])
|
||||
{
|
||||
return E_META_RAIL_ASCEND_ZP;
|
||||
}
|
||||
else if (Neighbors[3] && Neighbors[6])
|
||||
{
|
||||
return E_META_RAIL_ASCEND_ZM;
|
||||
}
|
||||
else if (Neighbors[5] && Neighbors[0])
|
||||
{
|
||||
return E_META_RAIL_ASCEND_XM;
|
||||
}
|
||||
else if (Neighbors[4] && Neighbors[1])
|
||||
{
|
||||
return E_META_RAIL_ASCEND_XP;
|
||||
}
|
||||
else if (Neighbors[0] && Neighbors[1])
|
||||
{
|
||||
return E_META_RAIL_XM_XP;
|
||||
}
|
||||
else if (Neighbors[2] && Neighbors[3])
|
||||
{
|
||||
return E_META_RAIL_ZM_ZP;
|
||||
}
|
||||
|
||||
if (CanThisRailCurve())
|
||||
{
|
||||
|
@ -92,6 +92,25 @@ end
|
||||
|
||||
local g_ViolationPatterns =
|
||||
{
|
||||
-- Parenthesis around comparisons:
|
||||
{"==[^)]+&&", "Add parenthesis around comparison"},
|
||||
{"&&[^(]+==", "Add parenthesis around comparison"},
|
||||
{"==[^)]+||", "Add parenthesis around comparison"},
|
||||
{"||[^(]+==", "Add parenthesis around comparison"},
|
||||
{"!=[^)]+&&", "Add parenthesis around comparison"},
|
||||
{"&&[^(]+!=", "Add parenthesis around comparison"},
|
||||
{"!=[^)]+||", "Add parenthesis around comparison"},
|
||||
{"||[^(]+!=", "Add parenthesis around comparison"},
|
||||
{"<[^)T][^)]*&&", "Add parenthesis around comparison"}, -- Must take special care of templates: "template <T> fn(Args && ...)"
|
||||
{"&&[^(]+<", "Add parenthesis around comparison"},
|
||||
{"<[^)T][^)]*||", "Add parenthesis around comparison"}, -- Must take special care of templates: "template <T> fn(Args && ...)"
|
||||
{"||[^(]+<", "Add parenthesis around comparison"},
|
||||
-- Cannot check ">" because of "obj->m_Flag &&". Check at least ">=":
|
||||
{">=[^)]+&&", "Add parenthesis around comparison"},
|
||||
{"&&[^(]+>=", "Add parenthesis around comparison"},
|
||||
{">=[^)]+||", "Add parenthesis around comparison"},
|
||||
{"||[^(]+>=", "Add parenthesis around comparison"},
|
||||
|
||||
-- Check against indenting using spaces:
|
||||
{"^\t* +", "Indenting with a space"},
|
||||
|
||||
@ -162,6 +181,7 @@ local function ProcessFile(a_FileName)
|
||||
-- Ref.: http://stackoverflow.com/questions/10416869/iterate-over-possibly-empty-lines-in-a-way-that-matches-the-expectations-of-exis
|
||||
local lineCounter = 1
|
||||
local lastIndentLevel = 0
|
||||
local isLastLineControl = false
|
||||
all:gsub("\r\n", "\n") -- normalize CRLF into LF-only
|
||||
string.gsub(all .. "\n", "[^\n]*\n", -- Iterate over each line, while preserving empty lines
|
||||
function(a_Line)
|
||||
@ -199,6 +219,24 @@ local function ProcessFile(a_FileName)
|
||||
lastIndentLevel = indentLevel
|
||||
end
|
||||
|
||||
-- Check that control statements have braces on separate lines after them:
|
||||
-- Note that if statements can be broken into multiple lines, in which case this test is not taken
|
||||
if (isLastLineControl) then
|
||||
if not(a_Line:find("^%s*{") or a_Line:find("^%s*#")) then
|
||||
-- Not followed by a brace, not followed by a preprocessor
|
||||
ReportViolation(a_FileName, lineCounter - 1, 1, 1, "Control statement needs a brace on separate line")
|
||||
end
|
||||
end
|
||||
local lineWithSpace = " " .. a_Line
|
||||
isLastLineControl =
|
||||
lineWithSpace:find("^%s+if %b()") or
|
||||
lineWithSpace:find("^%s+else if %b()") or
|
||||
lineWithSpace:find("^%s+for %b()") or
|
||||
lineWithSpace:find("^%s+switch %b()") or
|
||||
lineWithSpace:find("^%s+else\n") or
|
||||
lineWithSpace:find("^%s+else //") or
|
||||
lineWithSpace:find("^%s+do %b()")
|
||||
|
||||
lineCounter = lineCounter + 1
|
||||
end
|
||||
)
|
||||
@ -227,6 +265,9 @@ end
|
||||
|
||||
|
||||
|
||||
-- Remove buffering from stdout, so that the output appears immediately in IDEs:
|
||||
io.stdout:setvbuf("no")
|
||||
|
||||
-- Process all files in the AllFiles.lst file (generated by cmake):
|
||||
for fnam in io.lines("AllFiles.lst") do
|
||||
ProcessItem(fnam)
|
||||
|
@ -199,10 +199,14 @@ void cClientHandle::GenerateOfflineUUID(void)
|
||||
AString cClientHandle::FormatChatPrefix(bool ShouldAppendChatPrefixes, AString a_ChatPrefixS, AString m_Color1, AString m_Color2)
|
||||
{
|
||||
if (ShouldAppendChatPrefixes)
|
||||
{
|
||||
return Printf("%s[%s] %s", m_Color1.c_str(), a_ChatPrefixS.c_str(), m_Color2.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
return Printf("%s", m_Color1.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -294,7 +294,7 @@ void cCraftingRecipes::GetRecipe(cPlayer & a_Player, cCraftingGrid & a_CraftingG
|
||||
if (Recipe.get() == nullptr)
|
||||
{
|
||||
// Allow plugins to intercept a no-recipe-found situation:
|
||||
cRoot::Get()->GetPluginManager()->CallHookCraftingNoRecipe(a_Player, a_CraftingGrid, &a_Recipe);
|
||||
cRoot::Get()->GetPluginManager()->CallHookCraftingNoRecipe(a_Player, a_CraftingGrid, a_Recipe);
|
||||
return;
|
||||
}
|
||||
for (cRecipeSlots::const_iterator itr = Recipe->m_Ingredients.begin(); itr != Recipe->m_Ingredients.end(); ++itr)
|
||||
|
@ -665,7 +665,10 @@ int cEntity::GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_Dama
|
||||
// Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover
|
||||
|
||||
// Filter out damage types that are not protected by armor:
|
||||
if (!ArmorCoversAgainst(a_DamageType)) return 0;
|
||||
if (!ArmorCoversAgainst(a_DamageType))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Add up all armor points:
|
||||
// Ref.: http://www.minecraftwiki.net/wiki/Armor#Defense_points as of 2012_12_20
|
||||
@ -1011,9 +1014,18 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
||||
// Block hit was within our projected path
|
||||
// Begin by stopping movement in the direction that we hit something. The Normal is the line perpendicular to a 2D face and in this case, stores what block face was hit through either -1 or 1.
|
||||
// For example: HitNormal.y = -1 : BLOCK_FACE_YM; HitNormal.y = 1 : BLOCK_FACE_YP
|
||||
if (Tracer.HitNormal.x != 0.f) NextSpeed.x = 0.f;
|
||||
if (Tracer.HitNormal.y != 0.f) NextSpeed.y = 0.f;
|
||||
if (Tracer.HitNormal.z != 0.f) NextSpeed.z = 0.f;
|
||||
if (Tracer.HitNormal.x != 0.f)
|
||||
{
|
||||
NextSpeed.x = 0.f;
|
||||
}
|
||||
if (Tracer.HitNormal.y != 0.f)
|
||||
{
|
||||
NextSpeed.y = 0.f;
|
||||
}
|
||||
if (Tracer.HitNormal.z != 0.f)
|
||||
{
|
||||
NextSpeed.z = 0.f;
|
||||
}
|
||||
|
||||
if (Tracer.HitNormal.y == 1.f) // Hit BLOCK_FACE_YP, we are on the ground
|
||||
{
|
||||
@ -1276,7 +1288,7 @@ bool cEntity::DetectPortal()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsPlayer() && !((cPlayer *)this)->IsGameModeCreative() && m_PortalCooldownData.m_TicksDelayed != 80)
|
||||
if (IsPlayer() && !((cPlayer *)this)->IsGameModeCreative() && (m_PortalCooldownData.m_TicksDelayed != 80))
|
||||
{
|
||||
// Delay teleportation for four seconds if the entity is a non-creative player
|
||||
m_PortalCooldownData.m_TicksDelayed++;
|
||||
|
@ -142,8 +142,13 @@ void cMinecart::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
||||
|
||||
if (!IsBlockRail(InsideType))
|
||||
{
|
||||
Chunk->GetBlockTypeMeta(RelPosX, PosY + 1, RelPosZ, InsideType, InsideMeta); // When an descending minecart hits a flat rail, it goes through the ground; check for this
|
||||
if (IsBlockRail(InsideType)) AddPosY(1); // Push cart upwards
|
||||
// When a descending minecart hits a flat rail, it goes through the ground; check for this
|
||||
Chunk->GetBlockTypeMeta(RelPosX, PosY + 1, RelPosZ, InsideType, InsideMeta);
|
||||
if (IsBlockRail(InsideType))
|
||||
{
|
||||
// Push cart upwards
|
||||
AddPosY(1);
|
||||
}
|
||||
}
|
||||
|
||||
bool WasDetectorRail = false;
|
||||
@ -218,7 +223,10 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
|
||||
|
||||
// Execute both the entity and block collision checks
|
||||
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
|
||||
if (EntCol || BlckCol) return;
|
||||
if (EntCol || BlckCol)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetSpeedZ() != NO_SPEED) // Don't do anything if cart is stationary
|
||||
{
|
||||
@ -243,7 +251,10 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
|
||||
SetSpeedZ(NO_SPEED);
|
||||
|
||||
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
|
||||
if (EntCol || BlckCol) return;
|
||||
if (EntCol || BlckCol)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetSpeedX() != NO_SPEED)
|
||||
{
|
||||
@ -422,7 +433,10 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
|
||||
SetSpeedX(0);
|
||||
|
||||
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
|
||||
if (EntCol || BlckCol) return;
|
||||
if (EntCol || BlckCol)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetSpeedZ() != NO_SPEED)
|
||||
{
|
||||
@ -445,7 +459,10 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
|
||||
SetSpeedZ(NO_SPEED);
|
||||
|
||||
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
|
||||
if (EntCol || BlckCol) return;
|
||||
if (EntCol || BlckCol)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetSpeedX() != NO_SPEED)
|
||||
{
|
||||
|
@ -120,6 +120,11 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) :
|
||||
{
|
||||
m_CanFly = true;
|
||||
}
|
||||
if (World->IsGameModeSpectator()) // Otherwise Player will fall out of the world on join
|
||||
{
|
||||
m_CanFly = true;
|
||||
m_IsFlying = true;
|
||||
}
|
||||
}
|
||||
|
||||
cRoot::Get()->GetServer()->PlayerCreated(this);
|
||||
@ -1074,7 +1079,7 @@ bool cPlayer::IsGameModeAdventure(void) const
|
||||
bool cPlayer::IsGameModeSpectator(void) const
|
||||
{
|
||||
return (m_GameMode == gmSpectator) || // Either the player is explicitly in Spectator
|
||||
((m_GameMode == gmNotSet) && m_World->IsGameModeSpectator()); // or they inherit from the world and the world is Adventure
|
||||
((m_GameMode == gmNotSet) && m_World->IsGameModeSpectator()); // or they inherit from the world and the world is Spectator
|
||||
}
|
||||
|
||||
|
||||
@ -1893,8 +1898,8 @@ void cPlayer::UseEquippedItem(int a_Amount)
|
||||
|
||||
void cPlayer::TickBurning(cChunk & a_Chunk)
|
||||
{
|
||||
// Don't burn in creative and stop burning in creative if necessary
|
||||
if (!IsGameModeCreative())
|
||||
// Don't burn in creative or spectator and stop burning in creative if necessary
|
||||
if (!IsGameModeCreative() && !IsGameModeSpectator())
|
||||
{
|
||||
super::TickBurning(a_Chunk);
|
||||
}
|
||||
@ -1913,9 +1918,9 @@ void cPlayer::HandleFood(void)
|
||||
{
|
||||
// Ref.: http://www.minecraftwiki.net/wiki/Hunger
|
||||
|
||||
if (IsGameModeCreative())
|
||||
if (IsGameModeCreative() || IsGameModeSpectator())
|
||||
{
|
||||
// Hunger is disabled for Creative
|
||||
// Hunger is disabled for Creative and Spectator
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2080,7 +2085,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos)
|
||||
|
||||
void cPlayer::ApplyFoodExhaustionFromMovement()
|
||||
{
|
||||
if (IsGameModeCreative())
|
||||
if (IsGameModeCreative() || IsGameModeSpectator())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -692,8 +692,14 @@ static float GetMarbleNoise( float x, float y, float z, cNoise & a_Noise)
|
||||
float oct1 = (a_Noise.CubicNoise3D(x * 0.1f, y * 0.1f, z * 0.1f)) * 4;
|
||||
|
||||
oct1 = oct1 * oct1 * oct1;
|
||||
if (oct1 < 0.f) oct1 = PI_2;
|
||||
if (oct1 > PI_2) oct1 = PI_2;
|
||||
if (oct1 < 0.f)
|
||||
{
|
||||
oct1 = PI_2;
|
||||
}
|
||||
if (oct1 > PI_2)
|
||||
{
|
||||
oct1 = PI_2;
|
||||
}
|
||||
|
||||
return oct1;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "DungeonRoomsFinisher.h"
|
||||
#include "../FastRandom.h"
|
||||
#include "../BlockEntities/ChestEntity.h"
|
||||
#include "../BlockEntities/MobSpawnerEntity.h"
|
||||
|
||||
|
||||
|
||||
@ -57,6 +58,22 @@ public:
|
||||
int SecondChestPos = (FirstChestPos + 2 + (rnd % (NumPositions - 3))) % NumPositions;
|
||||
m_Chest1 = DecodeChestCoords(FirstChestPos, SizeX, SizeZ);
|
||||
m_Chest2 = DecodeChestCoords(SecondChestPos, SizeX, SizeZ);
|
||||
|
||||
// Choose what the mobspawner will spawn.
|
||||
// 25% chance for a spider, 25% for a skeleton and 50% chance to get a zombie spawer.
|
||||
int MobType = (a_Noise.IntNoise3DInt(a_OriginX, m_FloorHeight, a_OriginZ) / 7) % 100;
|
||||
if (MobType <= 25)
|
||||
{
|
||||
m_MonsterType = mtSkeleton;
|
||||
}
|
||||
else if (MobType <= 50)
|
||||
{
|
||||
m_MonsterType = mtSpider;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MonsterType = mtZombie;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -76,6 +93,8 @@ protected:
|
||||
/** The (absolute) coords of the second chest. The Y coord represents the chest's Meta value (facing). */
|
||||
Vector3i m_Chest2;
|
||||
|
||||
/** The monster type for the mobspawner entity. */
|
||||
eMonsterType m_MonsterType;
|
||||
|
||||
|
||||
/** Decodes the position index along the room walls into a proper 2D position for a chest.
|
||||
@ -246,7 +265,9 @@ protected:
|
||||
)
|
||||
{
|
||||
a_ChunkDesc.SetBlockTypeMeta(CenterX, b, CenterZ, E_BLOCK_MOB_SPAWNER, 0);
|
||||
// TODO: Set the spawned mob
|
||||
cMobSpawnerEntity * MobSpawner = static_cast<cMobSpawnerEntity *>(a_ChunkDesc.GetBlockEntity(CenterX, b, CenterZ));
|
||||
ASSERT((MobSpawner != nullptr) && (MobSpawner->GetBlockType() == E_BLOCK_MOB_SPAWNER));
|
||||
MobSpawner->SetEntity(m_MonsterType);
|
||||
}
|
||||
}
|
||||
} ;
|
||||
|
@ -372,7 +372,8 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
|
||||
(a_ChunkDesc.GetBlockType(x + 1, y, z) == E_BLOCK_AIR) &&
|
||||
(a_ChunkDesc.GetBlockType(x - 1, y, z) == E_BLOCK_AIR) &&
|
||||
(a_ChunkDesc.GetBlockType(x, y, z + 1) == E_BLOCK_AIR) &&
|
||||
(a_ChunkDesc.GetBlockType(x, y, z - 1) == E_BLOCK_AIR)
|
||||
(a_ChunkDesc.GetBlockType(x, y, z - 1) == E_BLOCK_AIR) &&
|
||||
IsDesertVariant(a_ChunkDesc.GetBiome(x, z))
|
||||
)
|
||||
{
|
||||
a_ChunkDesc.SetBlockType(x, ++Top, z, E_BLOCK_CACTUS);
|
||||
@ -393,6 +394,20 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc)
|
||||
|
||||
|
||||
|
||||
bool cFinishGenSprinkleFoliage::IsDesertVariant(EMCSBiome a_Biome)
|
||||
{
|
||||
return
|
||||
(
|
||||
(a_Biome == biDesertHills) ||
|
||||
(a_Biome == biDesert) ||
|
||||
(a_Biome == biDesertM)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// cFinishGenSoulsandRims
|
||||
|
||||
|
@ -150,6 +150,9 @@ protected:
|
||||
/// Tries to place sugarcane at the coords specified, returns true if successful
|
||||
bool TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ);
|
||||
|
||||
// Returns true is the specified biome is a desert or its variant
|
||||
static bool IsDesertVariant(EMCSBiome a_biome);
|
||||
|
||||
// cFinishGen override:
|
||||
virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
|
||||
} ;
|
||||
|
@ -507,7 +507,11 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size,
|
||||
int MaxStackSize = cItemHandler::GetItemHandler(a_Item.m_ItemType)->GetMaxStackSize();
|
||||
for (int i = 0; i < a_Size; i++)
|
||||
{
|
||||
if (m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType && m_Slots[i + a_Offset].m_ItemCount < MaxStackSize && m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage)
|
||||
if (
|
||||
(m_Slots[i + a_Offset].m_ItemType == a_Item.m_ItemType) &&
|
||||
(m_Slots[i + a_Offset].m_ItemCount < MaxStackSize) &&
|
||||
(m_Slots[i + a_Offset].m_ItemDamage == a_Item.m_ItemDamage)
|
||||
)
|
||||
{
|
||||
int NumFree = MaxStackSize - m_Slots[i + a_Offset].m_ItemCount;
|
||||
if (NumFree >= a_Item.m_ItemCount)
|
||||
@ -533,7 +537,7 @@ bool cInventory::AddToBar( cItem & a_Item, const int a_Offset, const int a_Size,
|
||||
if (a_Mode > 0)
|
||||
{
|
||||
// If we got more left, find first empty slot
|
||||
for (int i = 0; i < a_Size && a_Item.m_ItemCount > 0; i++)
|
||||
for (int i = 0; (i < a_Size) && (a_Item.m_ItemCount > 0); i++)
|
||||
{
|
||||
if (m_Slots[i + a_Offset].m_ItemType == -1)
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
||||
{
|
||||
std::set<eMonsterType> allowedMobs;
|
||||
|
||||
if (a_Biome == biMushroomIsland || a_Biome == biMushroomShore)
|
||||
if ((a_Biome == biMushroomIsland) || (a_Biome == biMushroomShore))
|
||||
{
|
||||
addIfAllowed(mtMooshroom, allowedMobs);
|
||||
}
|
||||
@ -84,7 +84,7 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
||||
addIfAllowed(mtCreeper, allowedMobs);
|
||||
addIfAllowed(mtSquid, allowedMobs);
|
||||
|
||||
if (a_Biome != biDesert && a_Biome != biBeach && a_Biome != biOcean)
|
||||
if ((a_Biome != biDesert) && (a_Biome != biBeach) && (a_Biome != biOcean))
|
||||
{
|
||||
addIfAllowed(mtSheep, allowedMobs);
|
||||
addIfAllowed(mtPig, allowedMobs);
|
||||
@ -93,11 +93,11 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
||||
addIfAllowed(mtEnderman, allowedMobs);
|
||||
addIfAllowed(mtSlime, allowedMobs); // MG TODO : much more complicated rule
|
||||
|
||||
if (a_Biome == biForest || a_Biome == biForestHills || a_Biome == biTaiga || a_Biome == biTaigaHills)
|
||||
if ((a_Biome == biForest) || (a_Biome == biForestHills) || (a_Biome == biTaiga) || (a_Biome == biTaigaHills))
|
||||
{
|
||||
addIfAllowed(mtWolf, allowedMobs);
|
||||
}
|
||||
else if (a_Biome == biJungle || a_Biome == biJungleHills)
|
||||
else if ((a_Biome == biJungle) || (a_Biome == biJungleHills))
|
||||
{
|
||||
addIfAllowed(mtOcelot, allowedMobs);
|
||||
}
|
||||
@ -286,6 +286,19 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
||||
);
|
||||
}
|
||||
|
||||
case mtMooshroom:
|
||||
{
|
||||
return (
|
||||
(TargetBlock == E_BLOCK_AIR) &&
|
||||
(BlockAbove == E_BLOCK_AIR) &&
|
||||
(BlockBelow == E_BLOCK_MYCELIUM) &&
|
||||
(
|
||||
(a_Biome == biMushroomShore) ||
|
||||
(a_Biome == biMushroomIsland)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
LOGD("MG TODO: Write spawning rule for mob type %d", a_MobType);
|
||||
|
@ -75,7 +75,9 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
}
|
||||
|
||||
if (m_Target == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cTracer LineOfSight(GetWorld());
|
||||
Vector3d AttackDirection(m_Target->GetPosition() - GetPosition());
|
||||
|
@ -34,7 +34,7 @@ void cBlaze::Attack(float a_Dt)
|
||||
{
|
||||
m_AttackInterval += a_Dt * m_AttackRate;
|
||||
|
||||
if (m_Target != nullptr && m_AttackInterval > 3.0)
|
||||
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
||||
{
|
||||
// Setting this higher gives us more wiggle room for attackrate
|
||||
Vector3d Speed = GetLookVector() * 20;
|
||||
|
@ -36,7 +36,7 @@ void cGhast::Attack(float a_Dt)
|
||||
{
|
||||
m_AttackInterval += a_Dt * m_AttackRate;
|
||||
|
||||
if (m_Target != nullptr && m_AttackInterval > 3.0)
|
||||
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
||||
{
|
||||
// Setting this higher gives us more wiggle room for attackrate
|
||||
Vector3d Speed = GetLookVector() * 20;
|
||||
|
@ -267,7 +267,9 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
}
|
||||
|
||||
if ((m_Target != nullptr) && m_Target->IsDestroyed())
|
||||
{
|
||||
m_Target = nullptr;
|
||||
}
|
||||
|
||||
// Burning in daylight
|
||||
HandleDaylightBurning(a_Chunk);
|
||||
@ -1028,22 +1030,34 @@ void cMonster::AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel)
|
||||
MTRand r1;
|
||||
if (r1.randInt() % 200 < ((m_DropChanceHelmet * 200) + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedHelmet().IsEmpty()) a_Drops.push_back(GetEquippedHelmet());
|
||||
if (!GetEquippedHelmet().IsEmpty())
|
||||
{
|
||||
a_Drops.push_back(GetEquippedHelmet());
|
||||
}
|
||||
}
|
||||
|
||||
if (r1.randInt() % 200 < ((m_DropChanceChestplate * 200) + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedChestplate().IsEmpty()) a_Drops.push_back(GetEquippedChestplate());
|
||||
if (!GetEquippedChestplate().IsEmpty())
|
||||
{
|
||||
a_Drops.push_back(GetEquippedChestplate());
|
||||
}
|
||||
}
|
||||
|
||||
if (r1.randInt() % 200 < ((m_DropChanceLeggings * 200) + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedLeggings().IsEmpty()) a_Drops.push_back(GetEquippedLeggings());
|
||||
if (!GetEquippedLeggings().IsEmpty())
|
||||
{
|
||||
a_Drops.push_back(GetEquippedLeggings());
|
||||
}
|
||||
}
|
||||
|
||||
if (r1.randInt() % 200 < ((m_DropChanceBoots * 200) + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedBoots().IsEmpty()) a_Drops.push_back(GetEquippedBoots());
|
||||
if (!GetEquippedBoots().IsEmpty())
|
||||
{
|
||||
a_Drops.push_back(GetEquippedBoots());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1056,7 +1070,10 @@ void cMonster::AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel)
|
||||
MTRand r1;
|
||||
if (r1.randInt() % 200 < ((m_DropChanceWeapon * 200) + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedWeapon().IsEmpty()) a_Drops.push_back(GetEquippedWeapon());
|
||||
if (!GetEquippedWeapon().IsEmpty())
|
||||
{
|
||||
a_Drops.push_back(GetEquippedWeapon());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ void cSkeleton::Attack(float a_Dt)
|
||||
{
|
||||
m_AttackInterval += a_Dt * m_AttackRate;
|
||||
|
||||
if (m_Target != nullptr && m_AttackInterval > 3.0)
|
||||
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
|
||||
{
|
||||
// Setting this higher gives us more wiggle room for attackrate
|
||||
Vector3d Speed = GetLookVector() * 20;
|
||||
|
@ -38,7 +38,7 @@ void cSnowGolem::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
BLOCKTYPE BlockBelow = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()) - 1, (int) floor(GetPosZ()));
|
||||
BLOCKTYPE Block = m_World->GetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ()));
|
||||
if (Block == E_BLOCK_AIR && cBlockInfo::IsSolid(BlockBelow))
|
||||
if ((Block == E_BLOCK_AIR) && cBlockInfo::IsSolid(BlockBelow))
|
||||
{
|
||||
m_World->SetBlock((int) floor(GetPosX()), (int) floor(GetPosY()), (int) floor(GetPosZ()), E_BLOCK_SNOW, 0);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
inline static bool IsSocketError(int a_ReturnedValue)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return (a_ReturnedValue == SOCKET_ERROR || a_ReturnedValue == 0);
|
||||
return ((a_ReturnedValue == SOCKET_ERROR) || (a_ReturnedValue == 0));
|
||||
#else
|
||||
return (a_ReturnedValue <= 0);
|
||||
#endif
|
||||
|
@ -83,12 +83,16 @@ cThread::~cThread()
|
||||
void cThread::Start( bool a_bWaitOnDelete /* = true */)
|
||||
{
|
||||
if (a_bWaitOnDelete)
|
||||
{
|
||||
m_StopEvent = new cEvent();
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
pthread_t SndThread;
|
||||
if (pthread_create( &SndThread, NULL, MyThread, this))
|
||||
{
|
||||
LOGERROR("ERROR: Could not create thread!");
|
||||
}
|
||||
#else
|
||||
DWORD ThreadID = 0;
|
||||
HANDLE hThread = CreateThread(NULL // security
|
||||
@ -132,6 +136,11 @@ void *cThread::MyThread( void *a_Param)
|
||||
|
||||
ThreadFunction( ThreadParam);
|
||||
|
||||
if (StopEvent) StopEvent->Set();
|
||||
// If the thread was marked as wait-on-delete, signal the event being waited on:
|
||||
if (StopEvent != nullptr)
|
||||
{
|
||||
StopEvent->Set();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -133,8 +133,10 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
|
||||
/*
|
||||
Disabled because of causing problems and being useless atm
|
||||
char BlockBelow = m_World.GetBlock(a_X, a_Y - 1, a_Z); // If there is nothing or fluid below it -> dominating flow is down :D
|
||||
if (BlockBelow == E_BLOCK_AIR || IsAllowedBlock(BlockBelow))
|
||||
if ((BlockBelow == E_BLOCK_AIR) || IsAllowedBlock(BlockBelow))
|
||||
{
|
||||
return Y_MINUS;
|
||||
}
|
||||
*/
|
||||
|
||||
NIBBLETYPE LowestPoint = m_World.GetBlockMeta(a_X, a_Y, a_Z); // Current Block Meta so only lower points will be counted
|
||||
@ -182,7 +184,9 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
|
||||
}
|
||||
|
||||
if (LowestPoint == m_World.GetBlockMeta(a_X, a_Y, a_Z))
|
||||
{
|
||||
return NONE;
|
||||
}
|
||||
|
||||
if (a_X - X > 0)
|
||||
{
|
||||
|
@ -416,24 +416,30 @@ static bool isLegalUTF8(const unsigned char * source, int length)
|
||||
{
|
||||
default: return false;
|
||||
// Everything else falls through when "true"...
|
||||
case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
|
||||
case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
|
||||
case 4: if (((a = (*--srcptr)) < 0x80) || (a > 0xbf)) return false;
|
||||
case 3: if (((a = (*--srcptr)) < 0x80) || (a > 0xbf)) return false;
|
||||
case 2:
|
||||
{
|
||||
if ((a = (*--srcptr)) > 0xBF) return false;
|
||||
if ((a = (*--srcptr)) > 0xbf)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (*source)
|
||||
{
|
||||
// no fall-through in this inner switch
|
||||
case 0xE0: if (a < 0xA0) return false; break;
|
||||
case 0xED: if (a > 0x9F) return false; break;
|
||||
case 0xF0: if (a < 0x90) return false; break;
|
||||
case 0xF4: if (a > 0x8F) return false; break;
|
||||
case 0xe0: if (a < 0xa0) return false; break;
|
||||
case 0xed: if (a > 0x9f) return false; break;
|
||||
case 0xf0: if (a < 0x90) return false; break;
|
||||
case 0xf4: if (a > 0x8f) return false; break;
|
||||
default: if (a < 0x80) return false;
|
||||
}
|
||||
}
|
||||
case 1: if (*source >= 0x80 && *source < 0xC2) return false;
|
||||
case 1: if ((*source >= 0x80) && (*source < 0xc2)) return false;
|
||||
}
|
||||
if (*source > 0xf4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (*source > 0xF4) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -450,7 +456,7 @@ AString UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length)
|
||||
const unsigned char * sourceEnd = source + a_UTF8Length;
|
||||
const int halfShift = 10; // used for shifting by 10 bits
|
||||
const unsigned int halfBase = 0x0010000UL;
|
||||
const unsigned int halfMask = 0x3FFUL;
|
||||
const unsigned int halfMask = 0x3ffUL;
|
||||
|
||||
while (source < sourceEnd)
|
||||
{
|
||||
@ -481,7 +487,7 @@ AString UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length)
|
||||
if (ch <= UNI_MAX_BMP)
|
||||
{
|
||||
// Target is a character <= 0xFFFF
|
||||
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END)
|
||||
if ((ch >= UNI_SUR_HIGH_START) && (ch <= UNI_SUR_LOW_END))
|
||||
{
|
||||
// UTF-16 surrogate values are illegal in UTF-32
|
||||
ch = ' ';
|
||||
@ -520,7 +526,10 @@ are equivalent to the following loop:
|
||||
{
|
||||
ch += *source++;
|
||||
--tmpBytesToRead;
|
||||
if (tmpBytesToRead) ch <<= 6;
|
||||
if (tmpBytesToRead)
|
||||
{
|
||||
ch <<= 6;
|
||||
}
|
||||
} while (tmpBytesToRead > 0);
|
||||
}
|
||||
---------------------------------------------------------------------
|
||||
@ -723,15 +732,15 @@ AString ReplaceAllCharOccurrences(const AString & a_String, char a_From, char a_
|
||||
/// Converts one Hex character in a Base64 encoding into the data value
|
||||
static inline int UnBase64(char c)
|
||||
{
|
||||
if (c >='A' && c <= 'Z')
|
||||
if ((c >='A') && (c <= 'Z'))
|
||||
{
|
||||
return c - 'A';
|
||||
}
|
||||
if (c >='a' && c <= 'z')
|
||||
if ((c >='a') && (c <= 'z'))
|
||||
{
|
||||
return c - 'a' + 26;
|
||||
}
|
||||
if (c >= '0' && c <= '9')
|
||||
if ((c >= '0') && (c <= '9'))
|
||||
{
|
||||
return c - '0' + 52;
|
||||
}
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
|
||||
|
||||
cTracer::cTracer(cWorld * a_World)
|
||||
: m_World(a_World)
|
||||
cTracer::cTracer(cWorld * a_World):
|
||||
m_World(a_World)
|
||||
{
|
||||
m_NormalTable[0].Set(-1, 0, 0);
|
||||
m_NormalTable[1].Set( 0, 0, -1);
|
||||
@ -39,8 +39,14 @@ cTracer::~cTracer()
|
||||
|
||||
float cTracer::SigNum(float a_Num)
|
||||
{
|
||||
if (a_Num < 0.f) return -1.f;
|
||||
if (a_Num > 0.f) return 1.f;
|
||||
if (a_Num < 0.f)
|
||||
{
|
||||
return -1.f;
|
||||
}
|
||||
if (a_Num > 0.f)
|
||||
{
|
||||
return 1.f;
|
||||
}
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
@ -59,7 +65,10 @@ void cTracer::SetValues(const Vector3f & a_Start, const Vector3f & a_Direction)
|
||||
step.z = (int) SigNum(dir.z);
|
||||
|
||||
// normalize the direction vector
|
||||
if (dir.SqrLength() > 0.f) dir.Normalize();
|
||||
if (dir.SqrLength() > 0.f)
|
||||
{
|
||||
dir.Normalize();
|
||||
}
|
||||
|
||||
// how far we must move in the ray direction before
|
||||
// we encounter a new voxel in x-direction
|
||||
@ -250,12 +259,16 @@ int LinesCross(float x0, float y0, float x1, float y1, float x2, float y2, float
|
||||
// float linx, liny;
|
||||
|
||||
float d = (x1 - x0) * (y3 - y2) - (y1 - y0) * (x3 - x2);
|
||||
if (std::abs(d)<0.001) {return 0;}
|
||||
if (std::abs(d) < 0.001)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
float AB = ((y0 - y2) * (x3 - x2) - (x0 - x2) * (y3 - y2)) / d;
|
||||
if (AB>=0.0 && AB<=1.0)
|
||||
if ((AB >= 0.0) && (AB <= 1.0))
|
||||
{
|
||||
float CD = ((y0 - y2) * (x1 - x0) - (x0 - x2) * (y1 - y0)) / d;
|
||||
if (CD>=0.0 && CD<=1.0)
|
||||
if ((CD >= 0.0) && (CD <= 1.0))
|
||||
{
|
||||
// linx = x0 + AB * (x1 - x0);
|
||||
// liny = y0 + AB * (y1 - y0);
|
||||
@ -265,6 +278,9 @@ int LinesCross(float x0, float y0, float x1, float y1, float x2, float y2, float
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// intersect3D_SegmentPlane(): intersect a segment and a plane
|
||||
// Input: a_Ray = a segment, and a_Plane = a plane = {Point V0; Vector n;}
|
||||
// Output: *I0 = the intersect point (when it exists)
|
||||
@ -294,7 +310,7 @@ int cTracer::intersect3D_SegmentPlane( const Vector3f & a_Origin, const Vector3f
|
||||
// they are not parallel
|
||||
// compute intersect param
|
||||
float sI = N / D;
|
||||
if (sI < 0 || sI > 1)
|
||||
if ((sI < 0) || (sI > 1))
|
||||
{
|
||||
return 0; // no intersection
|
||||
}
|
||||
@ -313,7 +329,7 @@ int cTracer::GetHitNormal(const Vector3f & start, const Vector3f & end, const Ve
|
||||
Vector3i SmallBlockPos = a_BlockPos;
|
||||
char BlockID = m_World->GetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z);
|
||||
|
||||
if (BlockID == E_BLOCK_AIR || IsBlockWater(BlockID))
|
||||
if ((BlockID == E_BLOCK_AIR) || IsBlockWater(BlockID))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -1167,7 +1167,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
|
||||
{
|
||||
m_MaximumCost = 39;
|
||||
}
|
||||
if (m_MaximumCost >= 40 && !a_Player.IsGameModeCreative())
|
||||
if ((m_MaximumCost >= 40) && !a_Player.IsGameModeCreative())
|
||||
{
|
||||
Input.Empty();
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ void cWorld::Start(void)
|
||||
}
|
||||
|
||||
// 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)gmSpectator);
|
||||
m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll);
|
||||
m_Weather = (eWeather) Clamp(Weather, (int)wSunny, (int)wStorm);
|
||||
|
||||
@ -1809,7 +1809,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
|
||||
a_FlyAwaySpeed /= 100; // Pre-divide, so that we don't have to divide each time inside the loop
|
||||
for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr)
|
||||
{
|
||||
if (!IsValidItem(itr->m_ItemType) || itr->m_ItemType == E_BLOCK_AIR)
|
||||
if (!IsValidItem(itr->m_ItemType) || (itr->m_ItemType == E_BLOCK_AIR))
|
||||
{
|
||||
// Don't spawn pickup if item isn't even valid; should prevent client crashing too
|
||||
continue;
|
||||
@ -1835,7 +1835,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double
|
||||
{
|
||||
for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr)
|
||||
{
|
||||
if (!IsValidItem(itr->m_ItemType) || itr->m_ItemType == E_BLOCK_AIR)
|
||||
if (!IsValidItem(itr->m_ItemType) || (itr->m_ItemType == E_BLOCK_AIR))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1526,7 +1526,10 @@ void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedN
|
||||
int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "TileID");
|
||||
int MetaIdx = a_NBT.FindChildByName(a_TagIdx, "Data");
|
||||
|
||||
if ((TypeIdx < 0) || (MetaIdx < 0)) { return; }
|
||||
if ((TypeIdx < 0) || (MetaIdx < 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int Type = a_NBT.GetInt(TypeIdx);
|
||||
NIBBLETYPE Meta = (NIBBLETYPE)a_NBT.GetByte(MetaIdx);
|
||||
@ -2199,8 +2202,10 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
|
||||
int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "Type");
|
||||
int ColorIdx = a_NBT.FindChildByName(a_TagIdx, "Color");
|
||||
int StyleIdx = a_NBT.FindChildByName(a_TagIdx, "Style");
|
||||
|
||||
if ((TypeIdx < 0) || (ColorIdx < 0) || (StyleIdx < 0)) { return; }
|
||||
if ((TypeIdx < 0) || (ColorIdx < 0) || (StyleIdx < 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int Type = a_NBT.GetInt(TypeIdx);
|
||||
int Color = a_NBT.GetInt(ColorIdx);
|
||||
@ -2390,8 +2395,10 @@ void cWSSAnvil::LoadSilverfishFromNBT(cEntityList & a_Entities, const cParsedNBT
|
||||
void cWSSAnvil::LoadSkeletonFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
|
||||
{
|
||||
int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "SkeletonType");
|
||||
|
||||
if (TypeIdx < 0) { return; }
|
||||
if (TypeIdx < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool Type = ((a_NBT.GetByte(TypeIdx) == 1) ? true : false);
|
||||
|
||||
@ -2505,8 +2512,10 @@ void cWSSAnvil::LoadSquidFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
|
||||
void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
|
||||
{
|
||||
int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "Profession");
|
||||
|
||||
if (TypeIdx < 0) { return; }
|
||||
if (TypeIdx < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int Type = a_NBT.GetInt(TypeIdx);
|
||||
|
||||
@ -2630,8 +2639,10 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
|
||||
void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
|
||||
{
|
||||
int IsVillagerIdx = a_NBT.FindChildByName(a_TagIdx, "IsVillager");
|
||||
|
||||
if (IsVillagerIdx < 0) { return; }
|
||||
if (IsVillagerIdx < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool IsVillagerZombie = ((a_NBT.GetByte(IsVillagerIdx) == 1) ? true : false);
|
||||
|
||||
|
@ -105,11 +105,11 @@ public:
|
||||
Destroy ();
|
||||
|
||||
// If the encoding or seperator are empty, then nullptr
|
||||
if (pszEncoding != nullptr && pszEncoding [0] == 0)
|
||||
if ((pszEncoding != nullptr) && (pszEncoding[0] == 0))
|
||||
{
|
||||
pszEncoding = nullptr;
|
||||
}
|
||||
if (pszSep != nullptr && pszSep [0] == 0)
|
||||
if ((pszSep != nullptr) && (pszSep[0] == 0))
|
||||
{
|
||||
pszSep = nullptr;
|
||||
}
|
||||
@ -147,7 +147,7 @@ public:
|
||||
bool Parse (const char *pszBuffer, int nLength, bool fIsFinal = true)
|
||||
{
|
||||
assert (m_p != nullptr);
|
||||
return XML_Parse (m_p, pszBuffer, nLength, fIsFinal) != 0;
|
||||
return (XML_Parse (m_p, pszBuffer, nLength, fIsFinal) != 0);
|
||||
}
|
||||
|
||||
// @cmember Parse internal buffer
|
||||
@ -254,8 +254,10 @@ protected:
|
||||
XML_SetDefaultHandlerExpand (m_p, fEnable ? DefaultHandler : nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
XML_SetDefaultHandler (m_p, fEnable ? DefaultHandler : nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
// @cmember Enable/Disable external entity ref handler
|
||||
|
||||
@ -402,12 +404,18 @@ public:
|
||||
{
|
||||
XML_expat_version v = XML_ExpatVersionInfo ();
|
||||
if (pnMajor)
|
||||
{
|
||||
*pnMajor = v .major;
|
||||
}
|
||||
if (pnMinor)
|
||||
{
|
||||
*pnMinor = v .minor;
|
||||
}
|
||||
if (pnMicro)
|
||||
{
|
||||
*pnMicro = v .micro;
|
||||
}
|
||||
}
|
||||
|
||||
// @cmember Get last error string
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user