summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MCServer/Plugins/Debuggers/Debuggers.lua69
-rw-r--r--VC2008/.gitignore1
-rw-r--r--VC2008/JsonCpp.vcproj62
-rw-r--r--VC2008/Lua.vcproj61
-rw-r--r--VC2008/MCServer.sln17
-rw-r--r--VC2008/MCServer.vcproj207
-rw-r--r--VC2008/ToLua.vcproj62
-rw-r--r--VC2008/WebServer.vcproj70
-rw-r--r--VC2008/debug_profile_run.cmd73
-rw-r--r--VC2008/expat.vcproj2
-rw-r--r--VC2008/zlib.vcproj62
-rw-r--r--source/Chunk.cpp5
-rw-r--r--source/ClientHandle.cpp2
-rw-r--r--source/DeadlockDetect.cpp20
-rw-r--r--source/DeadlockDetect.h5
-rw-r--r--source/Entities/Player.cpp4
-rw-r--r--source/Entities/Player.h7
-rw-r--r--source/Piston.cpp34
-rw-r--r--source/Server.cpp2
-rw-r--r--source/World.cpp24
20 files changed, 723 insertions, 66 deletions
diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua
index d74b4ea69..90a897aa6 100644
--- a/MCServer/Plugins/Debuggers/Debuggers.lua
+++ b/MCServer/Plugins/Debuggers/Debuggers.lua
@@ -3,6 +3,7 @@ PLUGIN = {}; -- Reference to own plugin object
g_DropSpensersToActivate = {}; -- A list of dispensers and droppers (as {World, X, Y Z} quadruplets) that are to be activated every tick
g_HungerReportTick = 10;
+g_ShowFoodStats = false; -- When true, each player's food stats are sent to them every 10 ticks
@@ -22,6 +23,7 @@ function Initialize(Plugin)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_TICK);
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT);
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY);
+ PluginManager:AddHook(Plugin, cPluginManager.HOOK_WORLD_TICK);
PluginManager:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities");
PluginManager:BindCommand("/ke", "debuggers", HandleKillEntitiesCmd, "- Kills all the loaded entities");
@@ -36,6 +38,7 @@ function Initialize(Plugin)
PluginManager:BindCommand("/fl", "debuggers", HandleFoodLevelCmd, "- Sets the food level to the given value");
PluginManager:BindCommand("/spidey", "debuggers", HandleSpideyCmd, "- Shoots a line of web blocks until it hits non-air");
PluginManager:BindCommand("/ench", "debuggers", HandleEnchCmd, "- Provides an instant dummy enchantment window");
+ PluginManager:BindCommand("/fs", "debuggers", HandleFoodStatsCmd, "- Turns regular foodstats message on or off");
-- Enable the following line for BlockArea / Generator interface testing:
-- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED);
@@ -444,19 +447,6 @@ function OnTick()
GCOnTick = GCOnTick - 1;
end
- --[[
- if (g_HungerReportTick > 0) then
- g_HungerReportTick = g_HungerReportTick - 1;
- else
- g_HungerReportTick = 10;
- cRoot:Get():GetDefaultWorld():ForEachPlayer(
- function(a_Player)
- a_Player:SendMessage("FoodStat: " .. a_Player:GetFoodLevel() .. " / " .. a_Player:GetFoodExhaustionLevel());
- end
- );
- end
- ]]
-
return false;
end
@@ -464,6 +454,27 @@ end
+function OnWorldTick(a_World, a_Dt)
+ local Tick = a_World:GetWorldAge();
+ if (not(g_ShowFoodStats) or (math.mod(Tick, 10) ~= 0)) then
+ return false;
+ end
+ a_World:ForEachPlayer(
+ function(a_Player)
+ a_Player:SendMessage(
+ tostring(Tick / 10) ..
+ " > FS: fl " .. a_Player:GetFoodLevel() ..
+ "; sat " .. a_Player:GetFoodSaturationLevel() ..
+ "; exh " .. a_Player:GetFoodExhaustionLevel()
+ );
+ end
+ );
+end
+
+
+
+
+
function OnChunkGenerated(World, ChunkX, ChunkZ, ChunkDesc)
-- Test ChunkDesc / BlockArea interaction
local BlockArea = cBlockArea();
@@ -708,7 +719,13 @@ function HandleFoodLevelCmd(a_Split, a_Player)
end
a_Player:SetFoodLevel(tonumber(a_Split[2]));
- a_Player:SendMessage("Food level set to " .. a_Player:GetFoodLevel());
+ a_Player:SetFoodSaturationLevel(5);
+ a_Player:SetFoodExhaustionLevel(0);
+ a_Player:SendMessage(
+ "Food level set to " .. a_Player:GetFoodLevel() ..
+ ", saturation reset to " .. a_Player:GetFoodSaturationLevel() ..
+ " and exhaustion reset to " .. a_Player:GetFoodExhaustionLevel()
+ );
return true;
end
@@ -748,9 +765,21 @@ end
function HandleEnchCmd(a_Split, a_Player)
- local Wnd = cLuaWindow(cWindow.Enchantment, 1, 1, "Ench")
- a_Player:OpenWindow(Wnd)
- Wnd:SetProperty(0, 10)
- Wnd:SetProperty(1, 15)
- Wnd:SetProperty(2, 25)
-end \ No newline at end of file
+ local Wnd = cLuaWindow(cWindow.Enchantment, 1, 1, "Ench");
+ a_Player:OpenWindow(Wnd);
+ Wnd:SetProperty(0, 10);
+ Wnd:SetProperty(1, 15);
+ Wnd:SetProperty(2, 25);
+end
+
+
+
+
+
+function HandleFoodStatsCmd(a_Split, a_Player)
+ g_ShowFoodStats = not(g_ShowFoodStats);
+end
+
+
+
+
diff --git a/VC2008/.gitignore b/VC2008/.gitignore
index 3b3be3257..537b749dc 100644
--- a/VC2008/.gitignore
+++ b/VC2008/.gitignore
@@ -1,4 +1,5 @@
Debug/
+Debug profiled/
Release/
*.user
*.ncb
diff --git a/VC2008/JsonCpp.vcproj b/VC2008/JsonCpp.vcproj
index 4ed04067a..5fa1ec685 100644
--- a/VC2008/JsonCpp.vcproj
+++ b/VC2008/JsonCpp.vcproj
@@ -204,6 +204,68 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
+ <Configuration
+ Name="Debug profiled|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\JsonCpp"
+ IntermediateDirectory="$(ConfigurationName)\JsonCpp"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../jsoncpp-src-0.5.0/include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
</Configurations>
<References>
</References>
diff --git a/VC2008/Lua.vcproj b/VC2008/Lua.vcproj
index 83cf4baf2..cb063c53e 100644
--- a/VC2008/Lua.vcproj
+++ b/VC2008/Lua.vcproj
@@ -201,6 +201,67 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
+ <Configuration
+ Name="Debug profiled|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\Lua"
+ IntermediateDirectory="$(ConfigurationName)\Lua"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
</Configurations>
<References>
</References>
diff --git a/VC2008/MCServer.sln b/VC2008/MCServer.sln
index 4da7f6161..6466fdddd 100644
--- a/VC2008/MCServer.sln
+++ b/VC2008/MCServer.sln
@@ -27,53 +27,70 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "expat", "expat.vcproj", "{5
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug profiled|Win32 = Debug profiled|Win32
Debug|Win32 = Debug|Win32
Release profiled|Win32 = Release profiled|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {32012054-0C96-4C43-AB27-174FF8E72D66}.Debug profiled|Win32.ActiveCfg = Debug profiled|Win32
+ {32012054-0C96-4C43-AB27-174FF8E72D66}.Debug profiled|Win32.Build.0 = Debug profiled|Win32
{32012054-0C96-4C43-AB27-174FF8E72D66}.Debug|Win32.ActiveCfg = Debug|Win32
{32012054-0C96-4C43-AB27-174FF8E72D66}.Debug|Win32.Build.0 = Debug|Win32
{32012054-0C96-4C43-AB27-174FF8E72D66}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
{32012054-0C96-4C43-AB27-174FF8E72D66}.Release profiled|Win32.Build.0 = Release profiled|Win32
{32012054-0C96-4C43-AB27-174FF8E72D66}.Release|Win32.ActiveCfg = Release|Win32
{32012054-0C96-4C43-AB27-174FF8E72D66}.Release|Win32.Build.0 = Release|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug profiled|Win32.ActiveCfg = Debug profiled|Win32
+ {EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug profiled|Win32.Build.0 = Debug profiled|Win32
{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.ActiveCfg = Debug|Win32
{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Debug|Win32.Build.0 = Debug|Win32
{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release profiled|Win32.Build.0 = Release profiled|Win32
{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.ActiveCfg = Release|Win32
{EA9D50FD-937A-4EF5-8C37-5F4175AF4FEA}.Release|Win32.Build.0 = Release|Win32
+ {5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug profiled|Win32.ActiveCfg = Debug profiled|Win32
+ {5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug profiled|Win32.Build.0 = Debug profiled|Win32
{5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug|Win32.ActiveCfg = Debug|Win32
{5AAA90B9-946D-4034-83F3-676B06A6E326}.Debug|Win32.Build.0 = Debug|Win32
{5AAA90B9-946D-4034-83F3-676B06A6E326}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
{5AAA90B9-946D-4034-83F3-676B06A6E326}.Release profiled|Win32.Build.0 = Release profiled|Win32
{5AAA90B9-946D-4034-83F3-676B06A6E326}.Release|Win32.ActiveCfg = Release|Win32
{5AAA90B9-946D-4034-83F3-676B06A6E326}.Release|Win32.Build.0 = Release|Win32
+ {082E8185-7B3A-4945-8C82-9132341A329D}.Debug profiled|Win32.ActiveCfg = Debug profiled|Win32
+ {082E8185-7B3A-4945-8C82-9132341A329D}.Debug profiled|Win32.Build.0 = Debug profiled|Win32
{082E8185-7B3A-4945-8C82-9132341A329D}.Debug|Win32.ActiveCfg = Debug|Win32
{082E8185-7B3A-4945-8C82-9132341A329D}.Debug|Win32.Build.0 = Debug|Win32
{082E8185-7B3A-4945-8C82-9132341A329D}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
{082E8185-7B3A-4945-8C82-9132341A329D}.Release profiled|Win32.Build.0 = Release profiled|Win32
{082E8185-7B3A-4945-8C82-9132341A329D}.Release|Win32.ActiveCfg = Release|Win32
{082E8185-7B3A-4945-8C82-9132341A329D}.Release|Win32.Build.0 = Release|Win32
+ {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug profiled|Win32.ActiveCfg = Debug profiled|Win32
+ {EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug profiled|Win32.Build.0 = Debug profiled|Win32
{EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug|Win32.ActiveCfg = Debug|Win32
{EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Debug|Win32.Build.0 = Debug|Win32
{EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
{EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release profiled|Win32.Build.0 = Release profiled|Win32
{EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release|Win32.ActiveCfg = Release|Win32
{EEAB54AD-114C-4AB8-8482-0A52D502BD35}.Release|Win32.Build.0 = Release|Win32
+ {9A476537-42C0-4848-AB40-15CFE83D17A8}.Debug profiled|Win32.ActiveCfg = Debug profiled|Win32
+ {9A476537-42C0-4848-AB40-15CFE83D17A8}.Debug profiled|Win32.Build.0 = Debug profiled|Win32
{9A476537-42C0-4848-AB40-15CFE83D17A8}.Debug|Win32.ActiveCfg = Debug|Win32
{9A476537-42C0-4848-AB40-15CFE83D17A8}.Debug|Win32.Build.0 = Debug|Win32
{9A476537-42C0-4848-AB40-15CFE83D17A8}.Release profiled|Win32.ActiveCfg = Release profiled|Win32
{9A476537-42C0-4848-AB40-15CFE83D17A8}.Release profiled|Win32.Build.0 = Release profiled|Win32
{9A476537-42C0-4848-AB40-15CFE83D17A8}.Release|Win32.ActiveCfg = Release|Win32
{9A476537-42C0-4848-AB40-15CFE83D17A8}.Release|Win32.Build.0 = Release|Win32
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug profiled|Win32.ActiveCfg = Debug|Win32
+ {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug profiled|Win32.Build.0 = Debug|Win32
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.ActiveCfg = Debug|Win32
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.Build.0 = Debug|Win32
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release profiled|Win32.ActiveCfg = Release|Win32
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release profiled|Win32.Build.0 = Release|Win32
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.ActiveCfg = Release|Win32
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.Build.0 = Release|Win32
+ {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug profiled|Win32.ActiveCfg = Debug|Win32
+ {5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug profiled|Win32.Build.0 = Debug|Win32
{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug|Win32.ActiveCfg = Debug|Win32
{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Debug|Win32.Build.0 = Debug|Win32
{5FCFAF8D-FF2C-456D-A72C-1D76F913AD96}.Release profiled|Win32.ActiveCfg = Release|Win32
diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj
index e52125532..fbbd999a9 100644
--- a/VC2008/MCServer.vcproj
+++ b/VC2008/MCServer.vcproj
@@ -251,6 +251,82 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
+ <Configuration
+ Name="Debug profiled|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/MP"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;../zlib-1.2.7&quot;;&quot;../jsoncpp-src-0.5.0/include&quot;;&quot;../lua-5.1.4/src&quot;;&quot;../tolua++-1.0.93/include&quot;;..;../expat"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;XML_STATIC"
+ MinimalRebuild="false"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib Psapi.lib"
+ OutputFile="$(ProjectDir)\..\MCServer\$(ProjectName)_dbgprof.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
</Configurations>
<References>
</References>
@@ -461,6 +537,14 @@
UsePrecompiledHeader="1"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\source\Globals.h"
@@ -540,6 +624,15 @@
UsePrecompiledHeader="0"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\source\LeakFinder.h"
@@ -633,6 +726,19 @@
UsePrecompiledHeader="0"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ OmitFramePointers="true"
+ BasicRuntimeChecks="0"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\source\Noise.h"
@@ -720,6 +826,15 @@
UsePrecompiledHeader="0"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\source\StackWalker.h"
@@ -1302,6 +1417,14 @@
Name="VCCustomBuildTool"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\Android\jni\app-android.cpp"
@@ -1330,6 +1453,14 @@
Name="VCCLCompilerTool"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\Android\jni\Application.mk"
@@ -1358,6 +1489,14 @@
Name="VCCustomBuildTool"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\Android\jni\ToJava.cpp"
@@ -1386,6 +1525,14 @@
Name="VCCLCompilerTool"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\Android\jni\ToJava.h"
@@ -1414,6 +1561,14 @@
Name="VCCustomBuildTool"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
</File>
</Filter>
</Filter>
@@ -1456,6 +1611,17 @@
Outputs="Bindings.cpp"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="GenerateBindings.cmd&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;cTorch.h&quot;;&quot;cStairs.h&quot;;&quot;cLadder.h&quot;;&quot;../iniFile/iniFile.h&quot;;&quot;BlockID.h&quot;;&quot;PacketID.h&quot;;&quot;Defines.h&quot;;&quot;LuaFunctions.h&quot;;&quot;cStringMap.h&quot;;&quot;cChatColor.h&quot;;&quot;cClientHandle.h&quot;;&quot;cEntity.h&quot;;&quot;cPawn.h&quot;;&quot;cPlayer.h&quot;;&quot;cPluginManager.h&quot;;&quot;cPlugin.h&quot;;&quot;cPlugin_NewLua.h&quot;;&quot;cPlugin_Lua.h&quot;;&quot;cServer.h&quot;;&quot;cWorld.h&quot;;&quot;cInventory.h&quot;;&quot;cItem.h&quot;;&quot;cWebAdmin.h&quot;;&quot;cWebPlugin.h&quot;;&quot;cWebPlugin_Lua.h&quot;;&quot;cPickup.h&quot;;&quot;cRoot.h&quot;;&quot;cTCPLink.h&quot;;&quot;Vector3f.h&quot;;&quot;Vector3d.h&quot;;&quot;Vector3i.h&quot;;&quot;Matrix4f.h&quot;;&quot;cCuboid.h&quot;;&quot;cMCLogger.h&quot;;&quot;cTracer.h&quot;;&quot;cGroup.h&quot;;&quot;BlockArea.h&quot;;&quot;packets/cPacket_Login.h&quot;;&quot;packets/cPacket_BlockDig.h&quot;;&quot;packets/cPacket_BlockPlace.h&quot;"
+ Outputs="Bindings.cpp"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\MCServer\API.txt"
@@ -1488,6 +1654,14 @@
UsePrecompiledHeader="0"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\source\Bindings.h"
@@ -1611,6 +1785,15 @@
UsePrecompiledHeader="0"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\source\md5\md5.h"
@@ -2251,6 +2434,14 @@
UsePrecompiledHeader="0"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\source\sqlite\sqlite3.c"
@@ -2279,6 +2470,14 @@
UsePrecompiledHeader="0"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\source\sqlite\sqlite3.h"
@@ -2319,6 +2518,14 @@
UsePrecompiledHeader="0"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\source\LuaExpat\lxplib.h"
diff --git a/VC2008/ToLua.vcproj b/VC2008/ToLua.vcproj
index 21875818b..dd5cfb217 100644
--- a/VC2008/ToLua.vcproj
+++ b/VC2008/ToLua.vcproj
@@ -204,6 +204,68 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
+ <Configuration
+ Name="Debug profiled|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\ToLua"
+ IntermediateDirectory="$(ConfigurationName)\ToLua"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../tolua++-1.0.93/include;../lua-5.1.4/src"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
</Configurations>
<References>
</References>
diff --git a/VC2008/WebServer.vcproj b/VC2008/WebServer.vcproj
index 36519d86a..601d2f554 100644
--- a/VC2008/WebServer.vcproj
+++ b/VC2008/WebServer.vcproj
@@ -204,6 +204,68 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
+ <Configuration
+ Name="Debug profiled|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\WebServer"
+ IntermediateDirectory="$(ConfigurationName)\webserver"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="Globals.h"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
</Configurations>
<References>
</References>
@@ -256,6 +318,14 @@
UsePrecompiledHeader="1"
/>
</FileConfiguration>
+ <FileConfiguration
+ Name="Debug profiled|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
</File>
<File
RelativePath="..\WebServer\Globals.h"
diff --git a/VC2008/debug_profile_run.cmd b/VC2008/debug_profile_run.cmd
new file mode 100644
index 000000000..a078768d0
--- /dev/null
+++ b/VC2008/debug_profile_run.cmd
@@ -0,0 +1,73 @@
+@echo off
+::
+:: Profiling using a MSVC standalone profiler
+::
+:: See http://www.codeproject.com/Articles/144643/Profiling-of-C-Applications-in-Visual-Studio-for-F for details
+::
+
+
+
+
+set pt="C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools"
+set appdir=..\MCServer
+set app=MCServer_dbgprof.exe
+
+:: outputdir is relative to appdir!
+set outputdir=..\Profiling
+set outputname=profile.vsp
+set output=%outputdir%\%outputname%
+
+
+
+
+
+:: Must cd to MCServer's directory so that it can find settings.ini etc.
+cd %appdir%
+
+::Create the output directory, if it didn't exist
+mkdir %outputdir%
+
+
+
+
+
+:: Start the profiler
+%pt%\vsperfcmd /start:sample /output:%output%
+if errorlevel 1 goto haderror
+
+:: Launch the application via the profiler
+%pt%\vsperfcmd /launch:%app%
+if errorlevel 1 goto haderror
+
+:: Shut down the profiler (this command waits, until the application is terminated)
+%pt%\vsperfcmd /shutdown
+if errorlevel 1 goto haderror
+
+
+
+
+
+:: cd to outputdir, so that the reports are generated there
+cd %outputdir%
+
+:: generate the report files (.csv)
+%pt%\vsperfreport /summary:all %outputname% /symbolpath:"srv*C:\Programovani\Symbols*http://msdl.microsoft.com/download/symbols"
+if errorlevel 1 goto haderror
+
+
+
+
+
+goto finished
+
+
+
+
+:haderror
+echo An error was encountered
+pause
+
+
+
+
+:finished
diff --git a/VC2008/expat.vcproj b/VC2008/expat.vcproj
index edd401e04..148fd0cad 100644
--- a/VC2008/expat.vcproj
+++ b/VC2008/expat.vcproj
@@ -18,7 +18,7 @@
<Configurations>
<Configuration
Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)/expat"
IntermediateDirectory="$(ConfigurationName)/expat"
ConfigurationType="4"
CharacterSet="2"
diff --git a/VC2008/zlib.vcproj b/VC2008/zlib.vcproj
index 4693c7284..6858b5610 100644
--- a/VC2008/zlib.vcproj
+++ b/VC2008/zlib.vcproj
@@ -204,6 +204,68 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
+ <Configuration
+ Name="Debug profiled|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)\zlib"
+ IntermediateDirectory="$(ConfigurationName)\zlib"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ DisableSpecificWarnings="4996"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
</Configurations>
<References>
</References>
diff --git a/source/Chunk.cpp b/source/Chunk.cpp
index e17e4bebc..db533f642 100644
--- a/source/Chunk.cpp
+++ b/source/Chunk.cpp
@@ -573,6 +573,11 @@ void cChunk::ProcessQueuedSetBlocks(void)
void cChunk::BroadcastPendingBlockChanges(void)
{
+ if (m_PendingSendBlocks.empty())
+ {
+ return;
+ }
+
for (cClientHandleList::iterator itr = m_LoadedByClient.begin(), end = m_LoadedByClient.end(); itr != end; ++itr)
{
(*itr)->SendBlockChanges(m_PosX, m_PosZ, m_PendingSendBlocks);
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index 07d580085..57830f63c 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -1502,6 +1502,8 @@ void cClientHandle::SendBlockChange(int a_BlockX, int a_BlockY, int a_BlockZ, BL
void cClientHandle::SendBlockChanges(int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes)
{
+ ASSERT(!a_Changes.empty()); // We don't want to be sending empty change packets!
+
m_Protocol->SendBlockChanges(a_ChunkX, a_ChunkZ, a_Changes);
}
diff --git a/source/DeadlockDetect.cpp b/source/DeadlockDetect.cpp
index 960038f81..5af3f973d 100644
--- a/source/DeadlockDetect.cpp
+++ b/source/DeadlockDetect.cpp
@@ -13,10 +13,10 @@
/// Number of milliseconds per cycle
-const int CYCLE_MILLISECONDS = 500;
+const int CYCLE_MILLISECONDS = 100;
/// When the number of cycles for the same world age hits this value, it is considered a deadlock
-const int NUM_CYCLES_LIMIT = 40; // 40 = twenty seconds
+const int NUM_CYCLES_LIMIT = 200; // 200 = twenty seconds
@@ -60,20 +60,10 @@ bool cDeadlockDetect::Start(void)
-void cDeadlockDetect::Stop(void)
-{
- m_EvtTerminate.Set();
- super::Stop();
-}
-
-
-
-
-
void cDeadlockDetect::Execute(void)
{
- // Loop until the event is signalled
- while (m_EvtTerminate.Wait(CYCLE_MILLISECONDS) == cEvent::wrTimeout)
+ // Loop until the signal to terminate:
+ while (!m_ShouldTerminate)
{
// Check the world ages:
class cChecker :
@@ -95,6 +85,8 @@ void cDeadlockDetect::Execute(void)
}
} Checker(this);
cRoot::Get()->ForEachWorld(Checker);
+
+ cSleep::MilliSleep(CYCLE_MILLISECONDS);
} // while (should run)
}
diff --git a/source/DeadlockDetect.h b/source/DeadlockDetect.h
index bbd76826a..2559c3fff 100644
--- a/source/DeadlockDetect.h
+++ b/source/DeadlockDetect.h
@@ -31,9 +31,6 @@ public:
/// Starts the detection. Hides cIsThread's Start, because we need some initialization
bool Start(void);
- /// Stops the detection. Hides cIsThread's Stop, because we need to signal m_EvtTerminate
- void Stop(void);
-
protected:
struct sWorldAge
{
@@ -49,8 +46,6 @@ protected:
WorldAges m_WorldAges;
- cEvent m_EvtTerminate;
-
// cIsThread overrides:
virtual void Execute(void) override;
diff --git a/source/Entities/Player.cpp b/source/Entities/Player.cpp
index 8ad071453..3ccb4ca1d 100644
--- a/source/Entities/Player.cpp
+++ b/source/Entities/Player.cpp
@@ -340,9 +340,9 @@ void cPlayer::SetFoodTickTimer(int a_FoodTickTimer)
-void cPlayer::SetFoodExhaustionLevel(double a_FoodSaturationLevel)
+void cPlayer::SetFoodExhaustionLevel(double a_FoodExhaustionLevel)
{
- m_FoodExhaustionLevel = std::max(0.0, std::min(a_FoodSaturationLevel, 4.0));
+ m_FoodExhaustionLevel = std::max(0.0, std::min(a_FoodExhaustionLevel, 4.0));
}
diff --git a/source/Entities/Player.h b/source/Entities/Player.h
index 62595f980..5dcce8421 100644
--- a/source/Entities/Player.h
+++ b/source/Entities/Player.h
@@ -171,14 +171,17 @@ public:
void SetFoodLevel (int a_FoodLevel);
void SetFoodSaturationLevel (double a_FoodSaturationLevel);
void SetFoodTickTimer (int a_FoodTickTimer);
- void SetFoodExhaustionLevel (double a_FoodSaturationLevel);
+ void SetFoodExhaustionLevel (double a_FoodExhaustionLevel);
void SetFoodPoisonedTicksRemaining(int a_FoodPoisonedTicksRemaining);
/// Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed, false if player "full"
bool Feed(int a_Food, double a_Saturation);
/// Adds the specified exhaustion to m_FoodExhaustion. Expects only positive values.
- void AddFoodExhaustion(double a_Exhaustion) { m_FoodExhaustionLevel += a_Exhaustion; }
+ void AddFoodExhaustion(double a_Exhaustion)
+ {
+ m_FoodExhaustionLevel += a_Exhaustion;
+ }
/// Starts the food poisoning for the specified amount of ticks; if already foodpoisoned, sets FoodPoisonedTicksRemaining to the larger of the two
void FoodPoison(int a_NumTicks);
diff --git a/source/Piston.cpp b/source/Piston.cpp
index d1d2b96a4..2431bdac2 100644
--- a/source/Piston.cpp
+++ b/source/Piston.cpp
@@ -20,6 +20,13 @@ extern bool g_BlockPistonBreakable[];
+/// Number of ticks that the piston extending / retracting waits before setting the block
+const int PISTON_TICK_DELAY = 5;
+
+
+
+
+
cPiston::cPiston(cWorld * a_World)
: m_World(a_World)
{
@@ -39,16 +46,16 @@ int cPiston::FirstPassthroughBlock(int pistonX, int pistonY, int pistonZ, NIBBLE
NIBBLETYPE currMeta;
AddDir(pistonX, pistonY, pistonZ, pistonmeta, 1);
m_World->GetBlockTypeMeta(pistonX, pistonY, pistonZ, currBlock, currMeta);
- if (!CanPush(currBlock, currMeta))
- {
- // This block cannot be pushed at all, the piston can't extend
- return -1;
- }
if (CanBreakPush(currBlock, currMeta))
{
// This block breaks when pushed, extend up to here
return ret;
}
+ if (!CanPush(currBlock, currMeta))
+ {
+ // This block cannot be pushed at all, the piston can't extend
+ return -1;
+ }
}
// There is no space for the blocks to move, piston can't extend
return -1;
@@ -98,7 +105,7 @@ void cPiston::ExtendPiston(int pistx, int pisty, int pistz)
{
AddDir(pistx, pisty, pistz, pistonMeta, -1);
m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currBlockMeta);
- m_World->QueueSetBlock( oldx, oldy, oldz, currBlock, currBlockMeta, 80);
+ m_World->QueueSetBlock( oldx, oldy, oldz, currBlock, currBlockMeta, PISTON_TICK_DELAY);
oldx = pistx;
oldy = pisty;
oldz = pistz;
@@ -113,14 +120,14 @@ void cPiston::ExtendPiston(int pistx, int pisty, int pistz)
m_World->BroadcastBlockAction(pistx, pisty, pistz, 0, pistonMeta, pistonBlock);
m_World->BroadcastSoundEffect("tile.piston.out", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f);
m_World->FastSetBlock( pistx, pisty, pistz, pistonBlock, pistonMeta | 0x8 );
- m_World->QueueSetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0), 80);
+ m_World->QueueSetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0), PISTON_TICK_DELAY);
}
-void cPiston::RetractPiston( int pistx, int pisty, int pistz )
+void cPiston::RetractPiston(int pistx, int pisty, int pistz)
{
BLOCKTYPE pistonBlock;
NIBBLETYPE pistonMeta;
@@ -133,7 +140,7 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz )
m_World->BroadcastBlockAction(pistx, pisty, pistz, 1, pistonMeta & ~(8), pistonBlock);
m_World->BroadcastSoundEffect("tile.piston.in", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f);
- m_World->QueueSetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8), 80);
+ m_World->QueueSetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8), PISTON_TICK_DELAY);
// Check the extension:
@@ -155,18 +162,18 @@ void cPiston::RetractPiston( int pistx, int pisty, int pistz )
if (CanPull(tempBlock, tempMeta))
{
// Pull the block
- m_World->QueueSetBlock(pistx, pisty, pistz, tempBlock, tempMeta, 80);
- m_World->QueueSetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0, 80);
+ m_World->QueueSetBlock(pistx, pisty, pistz, tempBlock, tempMeta, PISTON_TICK_DELAY);
+ m_World->QueueSetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY);
}
else
{
// Retract without pulling
- m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, 80);
+ m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY);
}
}
else
{
- m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, 80);
+ m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY);
}
}
@@ -228,6 +235,7 @@ bool cPiston::CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
return false;
}
+ case E_BLOCK_STICKY_PISTON:
case E_BLOCK_PISTON:
{
// A piston can only be pushed if retracted:
diff --git a/source/Server.cpp b/source/Server.cpp
index 9c1e06c81..dd18f8d3d 100644
--- a/source/Server.cpp
+++ b/source/Server.cpp
@@ -75,7 +75,7 @@ void cServer::cTickThread::Execute(void)
{
cTimer Timer;
- long long msPerTick = 50; // TODO - Put this in server config file
+ long long msPerTick = 50;
long long LastTime = Timer.GetNowTime();
while (!m_ShouldTerminate)
diff --git a/source/World.cpp b/source/World.cpp
index 8f9b3924f..053eaedc7 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -12,6 +12,7 @@
#include "Root.h"
#include "../iniFile/iniFile.h"
#include "ChunkMap.h"
+#include "OSSupport/Timer.h"
// Simulators:
#include "Simulator/SimulatorManager.h"
@@ -206,18 +207,25 @@ cWorld::cTickThread::cTickThread(cWorld & a_World) :
void cWorld::cTickThread::Execute(void)
{
- const int ClocksPerTick = CLOCKS_PER_SEC / 20;
- clock_t LastTime = clock();
+ cTimer Timer;
+
+ long long msPerTick = 50;
+ long long LastTime = Timer.GetNowTime();
+
while (!m_ShouldTerminate)
{
- clock_t Start = clock();
- m_World.Tick((float)(1000 * (Start - LastTime)) / CLOCKS_PER_SEC);
- clock_t Now = clock();
- if (Now - Start < ClocksPerTick)
+ long long NowTime = Timer.GetNowTime();
+ float DeltaTime = (float)(NowTime - LastTime);
+ m_World.Tick(DeltaTime);
+ long long TickTime = Timer.GetNowTime() - NowTime;
+
+ if (TickTime < msPerTick)
{
- cSleep::MilliSleep(1000 * (ClocksPerTick - (Now - Start)) / CLOCKS_PER_SEC);
+ // Stretch tick time until it's at least msPerTick
+ cSleep::MilliSleep((unsigned int)(msPerTick - TickTime));
}
- LastTime = Start;
+
+ LastTime = NowTime;
}
}